aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-01-24 05:40:50 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-01-24 05:40:50 +0000
commit495f42a32610c03591b49cd06ac09c5408742f86 (patch)
tree109516aa00e365881daf6d08f41a4751edea95e8
parent2dd52e3815d040e340a5d953d838cd2268e25372 (diff)
Add a test for a diagnostic special case added in r148439, as requested by
Francois Pichet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148784 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/SemaCXX/constant-expression-cxx11.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/SemaCXX/constant-expression-cxx11.cpp b/test/SemaCXX/constant-expression-cxx11.cpp
index e1b3781f9f..21c2cb2b41 100644
--- a/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1027,3 +1027,22 @@ namespace InstantiateCaseStmt {
template<int x> int g(int c) { switch(c) { case f<x>(): return 1; } return 0; }
int gg(int c) { return g<4>(c); }
}
+
+namespace ConvertedConstantExpr {
+ extern int &m;
+ extern int &n;
+
+ constexpr int k = 4;
+ int &m = const_cast<int&>(k);
+
+ // If we have nothing more interesting to say, ensure we don't produce a
+ // useless note and instead just point to the non-constant subexpression.
+ enum class E {
+ em = m,
+ en = n, // expected-error {{not a constant expression}}
+ eo = (m +
+ n // expected-error {{not a constant expression}}
+ ),
+ eq = reinterpret_cast<int>((int*)0) // expected-error {{not a constant expression}} expected-note {{reinterpret_cast}}
+ };
+}