OSDN Git Service

* g++.dg/parse/constant1.C: Specify C++98 mode.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / template / nontype3.C
1 // { dg-do compile }
2 // { dg-options -std=c++98 }
3 // Origin: <drow at gcc dot gnu dot org>,
4 //         <giovannibajo at gcc dot gnu dot org>
5 // c++/13243: Template parameters of non integral or enumeration type can't be
6 //  used for integral constant expressions. ADDR_EXPR and INDIRECT_REF are
7 //  invalid too.
8
9 template <int T> class foo {};
10 template <int *T> class bar {};
11
12 template <int *PI>
13 void dep5(bar<PI> *);
14
15 template <int *PI>
16 void dep6(bar<PI+1> *); // { dg-error "" "integral or enumeration" }
17
18 template <int I>
19 void dep7(bar<I+1> *);
20
21 template <int *PI>
22 void dep8(foo< *PI > *); // { dg-error "" "integral or enumeration" }
23
24 template <int PI[1]>
25 void dep9(foo< *PI > *); // { dg-error "" "integral or enumeration" }
26
27 template <int PI[1]>
28 void dep9a(foo< sizeof(*PI) > *);
29
30 template <int PI[1]>
31 void dep10(foo< PI[0] > *); // { dg-error "" "integral or enumeration" }
32
33 template <int I>
34 void dep11(foo< *&I > *); // { dg-error "" "constant-expression" }
35
36 template <int I>
37 void dep12(foo< (&I)[4] > *); // { dg-error "" "constant-expression" }
38