aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr101824.c19
-rw-r--r--gcc/tree-nested.c1
2 files changed, 20 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr101824.c b/gcc/testsuite/gcc.dg/tree-ssa/pr101824.c
new file mode 100644
index 0000000..d5987e1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr101824.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-pcom-details -fdump-tree-optimized" } */
+
+int main()
+{
+ volatile int y;
+ void bar()
+ {
+ __builtin_printf ("%d", y);
+ }
+ while (y)
+ ;
+ return 0;
+}
+
+/* Make sure the load from y is correctly interpreted as volatile, even
+ when going through FRAME. */
+/* { dg-final { scan-tree-dump-not "Executing predictive commoning" "pcom" } } */
+/* { dg-final { scan-tree-dump " ={v} FRAME" "optimized" } } */
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 0c3fb02..cc59526 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1033,6 +1033,7 @@ get_frame_field (struct nesting_info *info, tree target_context,
}
x = build3 (COMPONENT_REF, TREE_TYPE (field), x, field, NULL_TREE);
+ TREE_THIS_VOLATILE (x) = TREE_THIS_VOLATILE (field);
return x;
}