diff options
author | Martin Sebor <msebor@redhat.com> | 2021-03-25 16:08:00 -0600 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2021-03-25 16:08:00 -0600 |
commit | 26e80a496853b21da1886779d97ff613ccb64f9b (patch) | |
tree | 9064735f013e664dd995634ffbc02d61483ab2d5 | |
parent | 1b229a305091f0a9c64e5be3c1af5ef62b75e3cb (diff) | |
download | gcc-26e80a496853b21da1886779d97ff613ccb64f9b.zip gcc-26e80a496853b21da1886779d97ff613ccb64f9b.tar.gz gcc-26e80a496853b21da1886779d97ff613ccb64f9b.tar.bz2 |
PR tree-optimization/48483 - Construct from yourself w/o warning
gcc/testsuite/ChangeLog:
PR tree-optimization/48483
* g++.dg/warn/uninit-pr48483.C: New test.
-rw-r--r-- | gcc/testsuite/g++.dg/warn/uninit-pr48483.C | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/warn/uninit-pr48483.C b/gcc/testsuite/g++.dg/warn/uninit-pr48483.C new file mode 100644 index 0000000..41e8513 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/uninit-pr48483.C @@ -0,0 +1,56 @@ +/* PR tree-optimization/48483 - Construct from yourself w/o warning + { dg-do compile } + { dg-options "-Wall" } */ + +void sink (int); + +struct B +{ + int x; +}; + +struct A +{ + B& b; + A (B &x): b(x) { } +}; + +__attribute__ ((noipa)) void test_c0_O0 () +{ + A a (a.b); // { dg-warning "'a.A::b' is used uninitialized" } + sink (a.b.x); +} + +__attribute__ ((noipa)) int test_c3_O0 (void) +{ + struct S { int a; } s; + return s.a; // { dg-warning "s.test_c3_O0\\\(\\\)::S::a' is used uninitialized" } +} + +#pragma GCC optimize ("1") + +__attribute__ ((noipa)) void test_c0_O1 () +{ + A a (a.b); // { dg-warning "'a.A::b' is used uninitialized" } + sink (a.b.x); +} + +__attribute__ ((noipa)) int test_c3_O1 (void) +{ + struct S { int a; } s; + return s.a; // { dg-warning "s.test_c3_O1\\\(\\\)::S::a' is used uninitialized" } +} + +#pragma GCC optimize ("2") + +__attribute__ ((noipa)) void test_c0_O2 () +{ + A a (a.b); // { dg-warning "'a.A::b' is used uninitialized" } + sink (a.b.x); +} + +__attribute__ ((noipa)) int test_c3_O2 (void) +{ + struct S { int a; } s; + return s.a; // { dg-warning "s.test_c3_O2\\\(\\\)::S::a' is used uninitialized" } +} |