| 1 |
/* PR tree-optimization/48483 - Construct from yourself w/o warning |
| 2 |
{ dg-do compile } |
| 3 |
{ dg-options "-Wall" } */ |
| 4 |
|
| 5 |
void sink (int); |
| 6 |
|
| 7 |
struct B |
| 8 |
{ |
| 9 |
int x; |
| 10 |
}; |
| 11 |
|
| 12 |
struct A |
| 13 |
{ |
| 14 |
B& b; |
| 15 |
A (B &x): b(x) { } |
| 16 |
}; |
| 17 |
|
| 18 |
__attribute__ ((noipa)) void test_c0_O0 () |
| 19 |
{ |
| 20 |
A a (a.b); // { dg-warning "'a.A::b' is used uninitialized" } |
| 21 |
sink (a.b.x); |
| 22 |
} |
| 23 |
|
| 24 |
__attribute__ ((noipa)) int test_c3_O0 (void) |
| 25 |
{ |
| 26 |
struct S { int a; } s; |
| 27 |
return s.a; // { dg-warning "s.test_c3_O0\\\(\\\)::S::a' is used uninitialized" } |
| 28 |
} |
| 29 |
|
| 30 |
#pragma GCC optimize ("1") |
| 31 |
|
| 32 |
__attribute__ ((noipa)) void test_c0_O1 () |
| 33 |
{ |
| 34 |
A a (a.b); // { dg-warning "'a.A::b' is used uninitialized" } |
| 35 |
sink (a.b.x); |
| 36 |
} |
| 37 |
|
| 38 |
__attribute__ ((noipa)) int test_c3_O1 (void) |
| 39 |
{ |
| 40 |
struct S { int a; } s; |
| 41 |
return s.a; // { dg-warning "s.test_c3_O1\\\(\\\)::S::a' is used uninitialized" } |
| 42 |
} |
| 43 |
|
| 44 |
#pragma GCC optimize ("2") |
| 45 |
|
| 46 |
__attribute__ ((noipa)) void test_c0_O2 () |
| 47 |
{ |
| 48 |
A a (a.b); // { dg-warning "'a.A::b' is used uninitialized" } |
| 49 |
sink (a.b.x); |
| 50 |
} |
| 51 |
|
| 52 |
__attribute__ ((noipa)) int test_c3_O2 (void) |
| 53 |
{ |
| 54 |
struct S { int a; } s; |
| 55 |
return s.a; // { dg-warning "s.test_c3_O2\\\(\\\)::S::a' is used uninitialized" } |
| 56 |
} |