aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/cond1.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/opt/cond1.C')
-rw-r--r--gcc/testsuite/g++.dg/opt/cond1.C24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/opt/cond1.C b/gcc/testsuite/g++.dg/opt/cond1.C
new file mode 100644
index 00000000000..ae8fa4d45d9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/cond1.C
@@ -0,0 +1,24 @@
+// { dg-do run }
+// { dg-options "-O2" }
+
+struct D { int x; };
+struct W
+{
+ W () {}
+ D & operator * () { return d; }
+ D d;
+};
+
+int
+foo (int y)
+{
+ W m;
+ (*m).x = (y > 1 ? y : 0);
+ return (*m).x;
+}
+
+int
+main ()
+{
+ return (foo (6) != 6);
+}