From: H.J. Lu Date: Fri, 30 Jan 2009 17:31:24 +0000 (+0000) Subject: [multiple changes] X-Git-Tag: releases/gcc-4.3.4~369 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db1eabbf02690d6cf06d2fbbf69776b9594a4bb7;p=thirdparty%2Fgcc.git [multiple changes] 2009-01-30 H.J. Lu 2009-01-27 Richard Guenther PR tree-optimization/38503 * g++.dg/warn/Wstrict-aliasing-bogus-placement-new.C: New testcase. 2009-01-26 Richard Guenther PR tree-optimization/38745 * g++.dg/torture/pr38745.C: New testcase. 2009-01-26 Richard Guenther PR middle-end/38851 * g++.dg/warn/Wuninitialized-1.C: New testcase. 2009-01-20 Andrew Pinski Richard Guenther PR tree-optimization/38747 PR tree-optimization/38748 * gcc.dg/tree-ssa/struct-aliasing-1.c: New test. * gcc.c-torture/execute/struct-aliasing-1.c: Likewise. From-SVN: r143798 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 05c350719bc7..e2c0572524b5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,28 @@ +2009-01-30 H.J. Lu + + 2009-01-27 Richard Guenther + + PR tree-optimization/38503 + * g++.dg/warn/Wstrict-aliasing-bogus-placement-new.C: New testcase. + + 2009-01-26 Richard Guenther + + PR tree-optimization/38745 + * g++.dg/torture/pr38745.C: New testcase. + + 2009-01-26 Richard Guenther + + PR middle-end/38851 + * g++.dg/warn/Wuninitialized-1.C: New testcase. + + 2009-01-20 Andrew Pinski + Richard Guenther + + PR tree-optimization/38747 + PR tree-optimization/38748 + * gcc.dg/tree-ssa/struct-aliasing-1.c: New test. + * gcc.c-torture/execute/struct-aliasing-1.c: Likewise. + 2009-01-29 H.J. Lu 2009-01-28 Richard Guenther diff --git a/gcc/testsuite/g++.dg/torture/pr38745.C b/gcc/testsuite/g++.dg/torture/pr38745.C new file mode 100644 index 000000000000..4ad9d85fe369 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr38745.C @@ -0,0 +1,36 @@ +/* { dg-do compile } */ + +union u_u16 +{ + unsigned short v; + struct + { + unsigned char lo8, hi8; + } __attribute__ ((__may_alias__)) u; +} __attribute__ ((__may_alias__)); +union u_u32 +{ + unsigned int v; + struct + { + u_u16 lo16, hi16; + } u; +} __attribute__ ((__may_alias__)); +union u_u64 +{ + struct + { + u_u32 lo32, hi32; + } u; +}; +struct Record +{ +}; +long long +UnpackFullKey (Record & rec, const char *&p) +{ + long long c64 = 0; + (*(u_u16 *) & (*(u_u32 *) & ( *(u_u64*)&c64).u.lo32.v).u.lo16.v).u.hi8 = 1; + return c64; +} + diff --git a/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-placement-new.C b/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-placement-new.C new file mode 100644 index 000000000000..514957bcde2f --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-placement-new.C @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-aliasing" } */ + +inline void *operator new (__SIZE_TYPE__, void *__p) throw() { return __p; } + +struct Y { + Y() {} + int i; +}; + +struct X { + X() {} + void construct(const Y& y) + { + new (&m_data[0]) Y(y); + } + bool initialized; + char m_data[sizeof (Y)]; +}; + +void bar(const X&); +void foo(Y& y) +{ + X x; + x.construct(y); + x.initialized = true; + bar(x); +} + diff --git a/gcc/testsuite/g++.dg/warn/Wuninitialized-1.C b/gcc/testsuite/g++.dg/warn/Wuninitialized-1.C new file mode 100644 index 000000000000..7b1b90b944d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wuninitialized-1.C @@ -0,0 +1,15 @@ +/* { dg-options "-O2 -Wuninitialized" } */ + +struct Empty { Empty() {} }; /* { dg-bogus "uninitialized" } */ +struct Other { + Other(const Empty& e_) : e(e_) {} + Empty e; +}; +void bar(Other&); +void foo() +{ + Empty e; + Other o(e); + bar(o); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/struct-aliasing-1.c b/gcc/testsuite/gcc.c-torture/execute/struct-aliasing-1.c new file mode 100644 index 000000000000..9786b44c2454 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/struct-aliasing-1.c @@ -0,0 +1,17 @@ +struct S { float f; }; +int __attribute__((noinline)) +foo (int *r, struct S *p) +{ + int *q = (int *)&p->f; + int i = *q; + *r = 0; + return i + *q; +} +extern void abort (void); +int main() +{ + int i = 1; + if (foo (&i, (struct S *)&i) != 1) + abort (); + return (0); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/struct-aliasing-1.c b/gcc/testsuite/gcc.dg/tree-ssa/struct-aliasing-1.c new file mode 100644 index 000000000000..78e92d769e4b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/struct-aliasing-1.c @@ -0,0 +1,15 @@ +/* { dg-do "compile" } */ +/* { dg-options "-O2 -fdump-tree-fre" } */ + +struct S { float f; }; +int __attribute__((noinline)) +foo (float *r, struct S *p) +{ + int *q = (int *)&p->f; + int i = *q; + *r = 0.0; + return i + *q; +} + +/* { dg-final { scan-tree-dump-times "\\\*q" 1 "fre" } } */ +/* { dg-final { cleanup-tree-dump "fre" } } */