1 /* PR middle-end/98266 - bogus array subscript is partly outside array
2 bounds on virtual inheritance
4 { dg-options "-O2 -Wall" } */
6 void* operator new (__SIZE_TYPE__, void *p) { return p; }
7 void* operator new[] (__SIZE_TYPE__, void *p) { return p; }
16 struct B: virtual A { };
24 struct D1: virtual B, virtual C
26 /* The warning would ideally point to the assignment but instead points
27 to the opening brace. */
29 { // { dg-warning "\\\[-Warray-bounds" "brace" }
30 ci = 0; // { dg-warning "\\\[-Warray-bounds" "assign" { xfail lp64 } }
36 void warn_derived_ctor_access_new_decl ()
38 char a[sizeof (D1)]; // { dg-message "at offset 1 into object 'a' of size 40" "LP64 note" { target lp64} }
39 // { dg-message "at offset 1 into object 'a' of size 20" "LP64 note" { target ilp32} .-1 }
46 void warn_derived_ctor_access_new_alloc ()
48 char *p = (char*)operator new (sizeof (D1)); // { dg-message "at offset 1 into object of size \\d+ allocated by '\[^\n\r]*operator new\[^\n\r]*'" "note" }
54 void warn_derived_ctor_access_new_array_decl ()
56 char b[sizeof (D1) * 2]; // { dg-message "at offset \\d+ into object 'b' of size 80" "LP64 note" { target { lp64 } xfail { lp64 } } }
57 // { dg-message "at offset \\d+ into object 'b' of size 40" "LP64 note" { target { ilp32 } xfail { ilp32 } } .-1 }
60 D1 *q = new (p) D1[2];
64 void warn_derived_ctor_access_new_array_alloc ()
66 char *p = new char[sizeof (D1) * 2]; // { dg-message "at offset \\d+ into object of size \\d+ allocated by '\[^\n\r]*operator new\[^\n\r]*" "note" { xfail *-*-* } }
68 D1 *q = new (p) D1[2];