]> granicus.if.org Git - clang/commitdiff
Add a test for a diagnostic special case added in r148439, as requested by
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 24 Jan 2012 05:40:50 +0000 (05:40 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 24 Jan 2012 05:40:50 +0000 (05:40 +0000)
Francois Pichet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148784 91177308-0d34-0410-b5e6-96231b3b80d8

test/SemaCXX/constant-expression-cxx11.cpp

index e1b3781f9f4ea6b4debfa5d475535be91de0dbdf..21c2cb2b4125b8962b46091f5457931ecec1de14 100644 (file)
@@ -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}}
+  };
+}