From efc39b1d7112df5bb5aad3800828beecb65ce64a Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 24 Jan 2012 05:40:50 +0000 Subject: [PATCH] Add a test for a diagnostic special case added in r148439, as requested by Francois Pichet. llvm-svn: 148784 --- .../SemaCXX/constant-expression-cxx11.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp index e1b3781f9f4e..21c2cb2b4125 100644 --- a/clang/test/SemaCXX/constant-expression-cxx11.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp @@ -1027,3 +1027,22 @@ namespace InstantiateCaseStmt { template int g(int c) { switch(c) { case f(): 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(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*)0) // expected-error {{not a constant expression}} expected-note {{reinterpret_cast}} + }; +}