[cfe-commits] r148784 - /cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Mon Jan 23 21:40:51 PST 2012
Author: rsmith
Date: Mon Jan 23 23:40:50 2012
New Revision: 148784
URL: http://llvm.org/viewvc/llvm-project?rev=148784&view=rev
Log:
Add a test for a diagnostic special case added in r148439, as requested by
Francois Pichet.
Modified:
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp?rev=148784&r1=148783&r2=148784&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp Mon Jan 23 23:40:50 2012
@@ -1027,3 +1027,22 @@
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}}
+ };
+}
More information about the cfe-commits
mailing list