r222512 - Fix missing diagnostic for unsupported TLS for some thread_local variables.
Bob Wilson
bob.wilson at apple.com
Thu Nov 20 22:52:52 PST 2014
Author: bwilson
Date: Fri Nov 21 00:52:52 2014
New Revision: 222512
URL: http://llvm.org/viewvc/llvm-project?rev=222512&view=rev
Log:
Fix missing diagnostic for unsupported TLS for some thread_local variables.
Clang r181627 moved a check for block-scope variables into this code for
handling thread storage class specifiers, but in the process, it broke the
logic for checking if the target supports TLS. Fix this with some simple
restructuring of the code. rdar://problem/18796883
Added:
cfe/trunk/test/SemaCXX/cxx11-thread-unsupported.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=222512&r1=222511&r2=222512&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Nov 21 00:52:52 2014
@@ -5613,22 +5613,20 @@ Sema::ActOnVariableDeclarator(Scope *S,
NewVD->setLocalExternDecl();
if (DeclSpec::TSCS TSCS = D.getDeclSpec().getThreadStorageClassSpec()) {
- if (NewVD->hasLocalStorage()) {
- // C++11 [dcl.stc]p4:
- // When thread_local is applied to a variable of block scope the
- // storage-class-specifier static is implied if it does not appear
- // explicitly.
- // Core issue: 'static' is not implied if the variable is declared
- // 'extern'.
- if (SCSpec == DeclSpec::SCS_unspecified &&
- TSCS == DeclSpec::TSCS_thread_local &&
- DC->isFunctionOrMethod())
- NewVD->setTSCSpec(TSCS);
- else
- Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
- diag::err_thread_non_global)
- << DeclSpec::getSpecifierName(TSCS);
- } else if (!Context.getTargetInfo().isTLSSupported())
+ // C++11 [dcl.stc]p4:
+ // When thread_local is applied to a variable of block scope the
+ // storage-class-specifier static is implied if it does not appear
+ // explicitly.
+ // Core issue: 'static' is not implied if the variable is declared
+ // 'extern'.
+ if (NewVD->hasLocalStorage() &&
+ (SCSpec != DeclSpec::SCS_unspecified ||
+ TSCS != DeclSpec::TSCS_thread_local ||
+ !DC->isFunctionOrMethod()))
+ Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
+ diag::err_thread_non_global)
+ << DeclSpec::getSpecifierName(TSCS);
+ else if (!Context.getTargetInfo().isTLSSupported())
Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
diag::err_thread_unsupported);
else
Added: cfe/trunk/test/SemaCXX/cxx11-thread-unsupported.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx11-thread-unsupported.cpp?rev=222512&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx11-thread-unsupported.cpp (added)
+++ cfe/trunk/test/SemaCXX/cxx11-thread-unsupported.cpp Fri Nov 21 00:52:52 2014
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-apple-macosx10.6 -verify %s
+
+void f() {
+ thread_local int x; // expected-error {{thread-local storage is not supported for the current target}}
+}
More information about the cfe-commits
mailing list