]> granicus.if.org Git - clang/commitdiff
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)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179516 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 99702bed1cc1c66481b5dd187bffb8550d9ecfe0..b943e310ffa69f602c89456a6150d6313749847e 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 ccffe7335f4c7c236f48639d758d4bc89a983f95..01bb8f7773f9e9386afd0a006ed48208d3662845 100644 (file)
@@ -108,3 +108,5 @@ __thread S s;
 #endif
 #endif
 #endif
+
+__thread int aggregate[10] = {0};