summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/constant-expression-cxx11.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-01-27 01:14:48 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-01-27 01:14:48 +0000
commit253c2a390ac95ef9a3039ea6b4e37de6ba13462e (patch)
treeda328fc76dcd26749678a1a67a0b9034d486327f /clang/test/SemaCXX/constant-expression-cxx11.cpp
parentaf0bdfc6920a578ebcc3be986d0cc1644a68ce2f (diff)
downloadbcm5719-llvm-253c2a390ac95ef9a3039ea6b4e37de6ba13462e.tar.gz
bcm5719-llvm-253c2a390ac95ef9a3039ea6b4e37de6ba13462e.zip
constexpr: Implement the [dcl.constexpr]p5 check for whether a constexpr
function definition can produce a constant expression. This also provides the last few checks for [dcl.constexpr]p3 and [dcl.constexpr]p4. llvm-svn: 149108
Diffstat (limited to 'clang/test/SemaCXX/constant-expression-cxx11.cpp')
-rw-r--r--clang/test/SemaCXX/constant-expression-cxx11.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp
index 3c85adcc189..5b837e39d74 100644
--- a/clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -206,7 +206,9 @@ namespace ParameterScopes {
constexpr int b = MaybeReturnNonstaticRef(true, 0); // expected-error {{constant expression}} expected-note {{in call to 'MaybeReturnNonstaticRef(1, 0)'}}
constexpr int InternalReturnJunk(int n) {
- // FIXME: We should reject this: it never produces a constant expression.
+ // TODO: We could reject this: it never produces a constant expression.
+ // However, we currently don't evaluate function calls while testing for
+ // potential constant expressions, for performance.
return MaybeReturnJunk(true, n); // expected-note {{in call to 'MaybeReturnJunk(1, 0)'}}
}
constexpr int n3 = InternalReturnJunk(0); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'InternalReturnJunk(0)'}}
@@ -969,10 +971,9 @@ namespace PR11595 {
struct B { B(); A& x; };
static_assert(B().x == 3, ""); // expected-error {{constant expression}} expected-note {{non-literal type 'PR11595::B' cannot be used in a constant expression}}
- constexpr bool f(int k) {
+ constexpr bool f(int k) { // expected-error {{constexpr function never produces a constant expression}}
return B().x == k; // expected-note {{non-literal type 'PR11595::B' cannot be used in a constant expression}}
}
- constexpr int n = f(1); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'f(1)'}}
}
namespace ExprWithCleanups {
OpenPOWER on IntegriCloud