diff options
Diffstat (limited to 'gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-builtin2.C')
-rw-r--r-- | gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-builtin2.C | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-builtin2.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-builtin2.C new file mode 100644 index 0000000..dde38f0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-builtin2.C @@ -0,0 +1,16 @@ +// PR c++/54021 +// { dg-do compile { target c++11 } } + +extern int nonconst_func(int); +constexpr int identity(int x) { return x; } +constexpr int zero() { return identity(0); } +constexpr int one() { return identity(1); } + +// These are the same. Only the latter is accepted, though. +constexpr int rejected_const_4(int x) +{ return __builtin_constant_p(x) ? 4 : nonconst_func(x); } +constexpr int accepted_const_4(int x) +{ return identity(__builtin_constant_p(x)) ? 4 : nonconst_func(x); } + +// This is rejected. I would like it to work. +constexpr int four = accepted_const_4(1); |