* decl.c (make_typename_type): s/parameters/arguments/.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / constexpr-neg2.C
blob793b4c3f5d3583293489cfaadd1e6cee4ac34652
1 // PR c++/54020
2 // { dg-do compile { target c++11 } }
4 // Preliminaries.
5 extern int nonconst_func(int);
6 constexpr int identity(int x) { return x; }
7 constexpr int zero() { return identity(0); }
8 constexpr int one() { return identity(1); }
10 // Correctly accepted.
11 constexpr int three = one() ? 3 : nonconst_func(0);
13 // Incorrectly accepted.  See [dcl.constexpr] #5:
14 //   For a constexpr function, if no function argument values exist
15 //   such that the function invocation sub-stitution would produce a
16 //   constant expression (5.19), the program is ill-formed; no diagnostic
17 //   required.
18 constexpr int bogus() { return zero () ? 3 : nonconst_func(0); } // { dg-error "nonconst_func" }
20 // Correctly rejected (not sure why).
21 constexpr int correct_error() { return nonconst_func(0); } // { dg-error "nonconst_func" }
23 // Correctly rejected.
24 constexpr int z = bogus();      // { dg-error "" }
26 // This is also correctly rejected.
27 constexpr int correct_failure() { return 0 ? 3 : nonconst_func(0); } // { dg-error "nonconst_func" }