From: Richard Smith Date: Tue, 24 Jan 2012 05:40:50 +0000 (+0000) Subject: Add a test for a diagnostic special case added in r148439, as requested by X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=495f42a32610c03591b49cd06ac09c5408742f86;p=clang 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 --- 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 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}} + }; +}