PR lto/84212 - -Wno-* does not disable warnings from -flto link stage
[official-gcc.git] / gcc / testsuite / g++.dg / warn / Wplacement-new-size-6.C
blob06dfb3a0ba0b4d80486539a1c5518f284597ae24
1 // { dg-do compile }
2 // { dg-options "-Wno-pedantic -Wplacement-new=1" }
4 typedef __typeof__ (sizeof 0) size_t;
6 void* operator new (size_t, void *p) { return p; }
7 void* operator new[] (size_t, void *p) { return p; }
9 struct Ax { char n, a []; };
11 typedef __INT16_TYPE__ Int16;
12 typedef __INT32_TYPE__ Int32;
14 struct BAx { int i; Ax ax; };
16 void fBx1 ()
18   BAx bax1 = { 1, /* Ax = */ { 2, /* a[] = */ { 3 } } };        // { dg-error "initialization of flexible array member in a nested context" }
20   new (bax1.ax.a) char;     // { dg-warning "placement" }
21   new (bax1.ax.a) char[2];  // { dg-warning "placement" }
22   new (bax1.ax.a) Int16;    // { dg-warning "placement" }
23   new (bax1.ax.a) Int32;    // { dg-warning "placement" }
26 void fBx2 ()
28   BAx bax2 = { 1, /* Ax = */ { 2, /* a[] = */ { 3, 4 } } };     // { dg-error "initialization of flexible array member in a nested context" }
30   new (bax2.ax.a) char;       // { dg-warning "placement" }
31   new (bax2.ax.a) char[2];    // { dg-warning "placement" }
32   new (bax2.ax.a) char[3];    // { dg-warning "placement" }
33   new (bax2.ax.a) Int16;      // { dg-warning "placement" }
34   new (bax2.ax.a) char[4];    // { dg-warning "placement" }
35   new (bax2.ax.a) Int32;      // { dg-warning "placement" }
38 void fBx3 ()
40   BAx bax2 = { 1, /* Ax = */ { 3, /* a[] = */ { 4, 5, 6 } } };  // { dg-error "initialization of flexible array member in a nested context" }
42   new (bax2.ax.a) char;       // { dg-warning "placement" }
43   new (bax2.ax.a) char[2];    // { dg-warning "placement" }
44   new (bax2.ax.a) Int16;      // { dg-warning "placement" }
45   new (bax2.ax.a) char[3];    // { dg-warning "placement" }
46   new (bax2.ax.a) char[4];    // { dg-warning "placement" }
47   new (bax2.ax.a) Int32;      // { dg-warning "placement" }