On Wed, Aug 29, 2012 at 1:44 AM, Hans Wennborg <[email protected]> wrote:
> Author: hans > Date: Wed Aug 29 03:44:49 2012 > New Revision: 162835 > > URL: http://llvm.org/viewvc/llvm-project?rev=162835&view=rev > Log: > The address of a TLS var is not compile-time constant (PR13720) > > This makes Clang produce an error for code such as: > > __thread int x; > int *p = &x; > > The lvalue of a thread-local variable cannot be evaluated at compile > time. > > Modified: > cfe/trunk/lib/AST/ExprConstant.cpp > cfe/trunk/test/Sema/init.c > > Modified: cfe/trunk/lib/AST/ExprConstant.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=162835&r1=162834&r2=162835&view=diff > > ============================================================================== > --- cfe/trunk/lib/AST/ExprConstant.cpp (original) > +++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Aug 29 03:44:49 2012 > @@ -2832,6 +2832,8 @@ > } > > bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD) { > + if (VD->isThreadSpecified()) > + return false; > That should be 'return Error(E);' (constant expression evaluation shouldn't fail without producing a diagnostic). As a testcase, we should reject this: __thread int n; constexpr int &f() { return n; }
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
