]> granicus.if.org Git - clang/commitdiff
Fix r162835 as per Richard's comments.
authorHans Wennborg <hans@hanshq.net>
Wed, 29 Aug 2012 09:17:34 +0000 (09:17 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 29 Aug 2012 09:17:34 +0000 (09:17 +0000)
VisitVarDecl should return Error(E), and we should test that the address
of a TLS var can't be used as a constexpr.

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

lib/AST/ExprConstant.cpp
test/SemaCXX/constant-expression-cxx11.cpp

index 6b88246f82fbb4f41499ebed926e847a924fa943..ac21b469411116ae048902ca69ed428b977242a1 100644 (file)
@@ -2833,7 +2833,7 @@ bool LValueExprEvaluator::VisitDeclRefExpr(const DeclRefExpr *E) {
 
 bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD) {
   if (VD->isThreadSpecified())
-    return false;
+    return Error(E);
   if (!VD->getType()->isReferenceType()) {
     if (isa<ParmVarDecl>(VD)) {
       Result.set(VD, Info.CurrentCall->Index);
index a3ead79a8456867a53fed6d6104f7e72a79011b3..984ee1b08b606ea99d8afe9c46f9ce735cd82217 100644 (file)
@@ -1374,3 +1374,10 @@ namespace ConditionalLValToRVal {
   constexpr A a(4);
   static_assert(f(a).v == 4, "");
 }
+
+namespace TLS {
+  __thread int n;
+  constexpr int &f() { // expected-error {{constexpr function never produces a constant expression}}
+    return n; // expected-note {{subexpression not valid in a constant expression}}
+  }
+}