Fortran: Fix PR 47485.
[gcc.git] / gcc / testsuite / g++.dg / warn / Wplacement-new-size-3.C
blobc93e4e698a77e7ffcffdaf26f1e4c8c60229e9a9
1 // PR c++/71306 - bogus -Wplacement-new with an array element
2 // { dg-do compile }
3 // { dg-options "-Wplacement-new" }
5 void* operator new (__SIZE_TYPE__, void *p) { return p; }
7 struct S64 { char c [64]; };
9 S64 s2 [2];
10 S64* ps2 [2];
11 S64* ps2_2 [2][2];
13 void* pv2 [2];
15 void f ()
17   char a [2][sizeof (S64)];
19   new (a) S64;
20   new (a [0]) S64;
21   new (a [1]) S64;
23   // Verify there is no warning with buffers of sufficient size.
24   new (&s2 [0]) S64;
25   new (&s2 [1]) S64;
27   // ..and no warning with pointers to buffers of unknown size.
28   new (ps2 [0]) S64;
29   new (ps2 [1]) S64;
31   // But a warning when using the ps2_2 array itself as opposed
32   // to the pointers it's elements might point to.
33   new (ps2_2 [0]) S64;  // { dg-warning "placement new" }
34   new (ps2_2 [1]) S64;  // { dg-warning "placement new" }
36   // ..and no warning again with pointers to buffers of unknown
37   // size.
38   new (pv2 [0]) S64;
39   new (pv2 [1]) S64;