Ricardo FERNANDEZ PASCUAL writes:
>
> Notice that the arg 1 of the MODIFY_EXPR is a COMPONENT_REF which
> is marked as volatile. Notice also that the arg 1 of the
> COMPONENT_REF is not marked as such, because that field is not
> volatile itself and there are other accesses to it which are not
> volatile. This is because in my source language individual load or
> stores can be marked as volatile, not the variables.
> So, I think the real question is: are COMPONENT_REF nodes allowed
> to be marked as volatile by themselves? I think they should, and
> actually it seems to work (the generated code looks correct).
volatile is a type qualifier. The type of a COMPONENT_REF is the type
of the operand to which it refers. If you want to change the
effective type of a reference, you should generate a suitable
CONVERT_EXPR. Like this:
tree exp_type = TREE_TYPE (exp);
tree v_type
= build_qualified_type (exp_type,
TYPE_QUALS (exp_type) | TYPE_QUAL_VOLATILE);
tree addr = build_fold_addr_expr (exp);
v_type = build_pointer_type (v_type);
addr = fold_convert (v_type, addr);
exp = build_fold_indirect_ref (addr);
Andrew.