summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/tree-ssa/pr13146.C
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.dg/tree-ssa/pr13146.C
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.dg/tree-ssa/pr13146.C')
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/pr13146.C77
1 files changed, 77 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr13146.C b/gcc/testsuite/g++.dg/tree-ssa/pr13146.C
new file mode 100644
index 000000000..22baf03d3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr13146.C
@@ -0,0 +1,77 @@
+/* { dg-do link } */
+/* { dg-options "-O -fstrict-aliasing" } */
+
+class first
+{
+public:
+ double d;
+ int f1;
+};
+
+class middle : public first
+{
+};
+
+class second : public middle
+{
+public:
+ int f2;
+ short a;
+};
+
+class third
+{
+public:
+ char a;
+ char b;
+};
+
+class multi: public third, public second
+{
+public:
+ short s;
+ /* The following field used to be of type char but that causes
+ class multi to effectively get alias-set zero which we end
+ up not optimizing because of the fix for PR44164. */
+ int f3;
+};
+
+extern void link_error ();
+
+void
+foo (first *s1, second *s2)
+{
+ s1->f1 = 0;
+ s2->f2 = 0;
+ s1->f1++;
+ s2->f2++;
+ s1->f1++;
+ s2->f2++;
+ if (s1->f1 != 2)
+ link_error ();
+}
+
+void
+bar (first *s1, multi *s3)
+{
+ s1->f1 = 0;
+ s3->f3 = 0;
+ s1->f1++;
+ s3->f3++;
+ s1->f1++;
+ s3->f3++;
+ if (s1->f1 != 2)
+ link_error ();
+}
+
+
+int
+main()
+{
+ first a;
+ second b;
+ multi c;
+ foo (&a, &b);
+ bar (&a, &c);
+ return 0;
+}