111
|
1 // { dg-do compile }
|
|
2 // { dg-options "-Wall" }
|
|
3
|
|
4 // Test for c++/68308 - [6 Regression] ICE: tree check: expected integer_cst,
|
|
5 // have var_decl in decompose, at tree.h:5105
|
|
6
|
|
7 typedef __typeof__ (sizeof 0) size_t;
|
|
8
|
|
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 ();
|
|
13
|
|
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;
|
|
19 }
|
|
20
|
|
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;
|
|
25 }
|
|
26
|
|
27 template <size_t N>
|
|
28 char* fn2_1 () {
|
|
29 return new char [N];
|
|
30 }
|
|
31
|
|
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;
|
|
36 }
|
|
37
|
|
38 template <size_t M, size_t N>
|
|
39 char* fn2_2 () {
|
145
|
40 return new char [M][N]; // { dg-error "size .\[0-9\]+. of array exceeds maximum object size" }
|
111
|
41 }
|
|
42
|
|
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;
|
|
48 }
|
|
49
|
|
50 template <class T>
|
|
51 T* fn3 () {
|
|
52 const size_t a = sizeof (T);
|
145
|
53 return new T [a]; // { dg-error "size .\[0-9\]+. of array exceeds maximum object size" }
|
111
|
54 }
|
|
55
|
|
56
|
|
57 struct S { char a [__SIZE_MAX__ / 8]; };
|
|
58
|
|
59 void foo ()
|
|
60 {
|
|
61 fn2_1<1>();
|
|
62 fn2_1<__SIZE_MAX__ / 4>();
|
|
63 fn2_2<__SIZE_MAX__ / 4, 4>();
|
|
64 fn3<S>();
|
|
65 }
|