Properly check for a constant initializer for a thread-local variable.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 15 Apr 2013 08:07:34 +0000 (08:07 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 15 Apr 2013 08:07:34 +0000 (08:07 +0000)
llvm-svn: 179516

clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/thread-specifier.c

index 99702be..b943e31 100644 (file)
@@ -7630,7 +7630,8 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init,
     else if (VDecl->getTLSKind() == VarDecl::TLS_Static &&
              !VDecl->isInvalidDecl() && !DclT->isDependentType() &&
              !Init->isValueDependent() && !VDecl->isConstexpr() &&
-             !Init->isEvaluatable(Context)) {
+             !Init->isConstantInitializer(
+                 Context, VDecl->getType()->isReferenceType())) {
       // GNU C++98 edits for __thread, [basic.start.init]p4:
       //   An object of thread storage duration shall not require dynamic
       //   initialization.
index ccffe73..01bb8f7 100644 (file)
@@ -108,3 +108,5 @@ __thread S s;
 #endif
 #endif
 #endif
+
+__thread int aggregate[10] = {0};