doc: Document struct-layout-1.exp for ABI checks
[official-gcc.git] / gcc / testsuite / g++.dg / init / new46.C
blobf0b3921cb34f21c72a9be37f93b05c5b97cc2d5d
1 // { dg-do compile }
2 // { dg-options "-Wall" }
4 // Test for c++/68308 - [6 Regression] ICE: tree check: expected integer_cst,
5 //                      have var_decl in decompose, at tree.h:5105
7 typedef __typeof__ (sizeof 0) size_t;
9 // Not defined, only referenced in templates that aren't expected
10 // to be instantiated to make sure they really aren't to verify
11 // verify c++/68308.
12 template <class T> void inst_check ();
14 // Not instantiated (must not be diagnosed).
15 template <class T>
16 char* fn1_x () {
17     const size_t a = sizeof (T);
18     return inst_check<T>() ? new char [a] : 0;
21 // Not instantiated (must not be diagnosed).
22 template <size_t N>
23 char* fn2_1_x () {
24     return inst_check<char [N]>() ? new char [N] : 0;
27 template <size_t N>
28 char* fn2_1 () {
29     return new char [N];
32 // Not instantiated (must not be diagnosed).
33 template <size_t M, size_t N>
34 char* fn2_2_x () {
35     return inst_check<char [M][N]>() ? new char [M][N] : 0;
38 template <size_t M, size_t N>
39 char* fn2_2 () {
40     return new char [M][N];   // { dg-error "size .\[0-9\]+. of array exceeds maximum object size" }
43 // Not instantiated (must not be diagnosed).
44 template <class T>
45 T* fn3_x () {
46     const size_t a = sizeof (T);
47     return inst_check<T>() ? new T [a] : 0;
50 template <class T>
51 T* fn3 () {
52     const size_t a = sizeof (T);
53     return new T [a];         // { dg-error "size .\[0-9\]+. of array exceeds maximum object size" }
57 struct S { char a [__SIZE_MAX__ / 8]; };
59 void foo ()
61     fn2_1<1>();
62     fn2_1<__SIZE_MAX__ / 4>();
63     fn2_2<__SIZE_MAX__ / 4, 4>();
64     fn3<S>();