gcc/testsuite/g++.dg/cpp0x/constexpr-object2.C
raw| 1 | // { dg-do compile { target c++11 } } |
| 2 | |
| 3 | constexpr int verysquare(int x) { return x * x; } |
| 4 | |
| 5 | const double mass = 9.8; |
| 6 | constexpr double energy = mass * verysquare(56.6); // { dg-error "mass" } |
| 7 | |
| 8 | int arr[(int)mass]; // { dg-error "" } |
| 9 | |
| 10 | float array[verysquare(9)]; // OK -- not C99 VLA |
| 11 | |
| 12 | extern const int medium; |
| 13 | const int high = verysquare(medium); // OK -- dynamic initialization |
| 14 | |
| 15 | enum { Max = verysquare(7) }; // OK |