summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2012-08-29 18:27:29 +0000
committerHans Wennborg <hans@hanshq.net>2012-08-29 18:27:29 +0000
commitcb9ad9908bc4fd27625fd9960081d2c3943dfb6d (patch)
tree2c420ffb2dd2a8d26052f797e1b00ba8afd3a4e7 /clang/lib/AST/ExprConstant.cpp
parent7a837b9a76b229ca8bb52392b9c55d29f557daaa (diff)
downloadbcm5719-llvm-cb9ad9908bc4fd27625fd9960081d2c3943dfb6d.tar.gz
bcm5719-llvm-cb9ad9908bc4fd27625fd9960081d2c3943dfb6d.zip
Move TLS check from LValueExprEvaluator::VisitVarDecl to
CheckLValueConstantExpression. Richard pointed out that using the address of a TLS variable is ok in a core C++11 constant expression, as long as it isn't part of the eventual result of constant expression evaluation. Having the check in CheckLValueConstantExpression accomplishes this. llvm-svn: 162850
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r--clang/lib/AST/ExprConstant.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index ac21b469411..fb0c4d26ea8 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -987,6 +987,14 @@ static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc,
LVal.getLValueCallIndex() == 0) &&
"have call index for global lvalue");
+ // Check if this is a thread-local variable.
+ if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>()) {
+ if (const VarDecl *Var = dyn_cast<const VarDecl>(VD)) {
+ if (Var->isThreadSpecified())
+ return false;
+ }
+ }
+
// Allow address constant expressions to be past-the-end pointers. This is
// an extension: the standard requires them to point to an object.
if (!IsReferenceType)
@@ -2832,8 +2840,6 @@ bool LValueExprEvaluator::VisitDeclRefExpr(const DeclRefExpr *E) {
}
bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD) {
- if (VD->isThreadSpecified())
- return Error(E);
if (!VD->getType()->isReferenceType()) {
if (isa<ParmVarDecl>(VD)) {
Result.set(VD, Info.CurrentCall->Index);
OpenPOWER on IntegriCloud