summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/tree-ssa/pr27549.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/pr27549.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/pr27549.C')
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/pr27549.C79
1 files changed, 79 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr27549.C b/gcc/testsuite/g++.dg/tree-ssa/pr27549.C
new file mode 100644
index 000000000..cd5944d24
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr27549.C
@@ -0,0 +1,79 @@
+// PR tree-optimization/27549
+// { dg-do compile }
+// { dg-options "-O2" }
+
+typedef __SIZE_TYPE__ size_t;
+
+struct E
+{
+ virtual ~E () {}
+ virtual size_t e () const = 0;
+ virtual void f (char *x) const = 0;
+};
+
+struct F : public E
+{
+ F () {}
+ virtual ~F () {}
+ virtual size_t e () const { return 0; }
+ virtual void f (char *x) const { *x = '\0'; }
+};
+
+struct S
+{
+ S () { a = new char[32]; b = 32; c = 0; a[0] = 0; }
+ void s (const char *x, size_t y) { v (c + y + 1); __builtin_memcpy(a + c, x, y); c += y; a[c] = '\0'; }
+ void s (const E *x) { size_t l = x->e(); v (c + l + 1); x->f (a + c); c += l; }
+ const char *t () { return a; }
+ void v (size_t n)
+ {
+ if (b >= n) return;
+
+ size_t b2 = b;
+ char *a2 = a;
+
+ for (;;)
+ {
+ b *= 2;
+ if (b >= n)
+ break;
+ }
+
+ a = new char[b];
+
+ if (b2)
+ {
+ __builtin_memcpy(a, a2, c);
+ a2[0] = 0;
+ for (size_t i = 1; i < b2; i++)
+ a2[i] = a2[i - 1];
+ delete[] a2;
+ }
+ }
+
+ ~S ()
+ {
+ if (b)
+ {
+ a[0] = 0;
+ for (size_t i = 1; i < b; i++)
+ a[i] = a[i - 1];
+ }
+ delete[] a;
+ }
+ char * a;
+ size_t b, c;
+};
+
+const char *p;
+size_t q;
+const F u;
+
+const char *
+foo ()
+{
+ S s;
+ s.s (p, q);
+ s.s (&u);
+ return s.t ();
+}