Patch below fixed PR35037, where we used not to mark as volatile the
members of common or equivalence groups. This is straightforward and
well contained, fixes a wrong-code PR, but it's not a regression
AFAIK, so I'm asking it to be reviewed and for the reviewer to
indicate whether it is suitable for inclusion in 4.3.
Bootstrapped and regtested on x86_64-linux, will come with a testcase
(based on -O3 simplification and scanning of the optimized tree dump,
like is done in the PR).
2008-02-05 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/35037
* trans-common.c (build_field): Mark fields as volatile when needed.
Index: trans-common.c
===================================================================
--- trans-common.c (revision 132112)
+++ trans-common.c (working copy)
@@ -318,6 +318,15 @@ build_field (segment_info *h, tree union
GFC_DECL_ASSIGN_ADDR (field) = pushdecl_top_level (addr);
}
+ /* If this field is volatile, mark it. */
+ if (h->sym->attr.volatile_)
+ {
+ tree new;
+ TREE_THIS_VOLATILE (field) = 1;
+ new = build_qualified_type (TREE_TYPE (field), TYPE_QUAL_VOLATILE);
+ TREE_TYPE (field) = new;
+ }
+
h->field = field;
}