[cfe-commits] r162837 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/SemaCXX/constant-expression-cxx11.cpp
Hans Wennborg
hans at hanshq.net
Wed Aug 29 02:17:34 PDT 2012
Author: hans
Date: Wed Aug 29 04:17:34 2012
New Revision: 162837
URL: http://llvm.org/viewvc/llvm-project?rev=162837&view=rev
Log:
Fix r162835 as per Richard's comments.
VisitVarDecl should return Error(E), and we should test that the address
of a TLS var can't be used as a constexpr.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=162837&r1=162836&r2=162837&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Aug 29 04:17:34 2012
@@ -2833,7 +2833,7 @@
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);
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=162837&r1=162836&r2=162837&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp Wed Aug 29 04:17:34 2012
@@ -1374,3 +1374,10 @@
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}}
+ }
+}
More information about the cfe-commits
mailing list