aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-04-15 08:33:22 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-04-15 08:33:22 +0000
commitdf4cc0a0c75ff9d92ca501ecd40c5413b97506d6 (patch)
treedd5b65ae503ed4ee7d8cdfb29a8ed2f8aa8bd2d1 /lib/Sema/SemaDecl.cpp
parentb6b127f279f89d992e0713866f17fed267147a79 (diff)
Local thread_local variables are implicitly 'static'. (This doesn't apply to _Thread_local nor __thread.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179517 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index b943e310ff..9b3083a4ec 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -4687,8 +4687,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
"Parser allowed 'typedef' as storage class VarDecl.");
VarDecl::StorageClass SC = StorageClassSpecToVarDeclStorageClass(SCSpec);
- if (getLangOpts().OpenCL && !getOpenCLOptions().cl_khr_fp16)
- {
+ if (getLangOpts().OpenCL && !getOpenCLOptions().cl_khr_fp16) {
// OpenCL v1.2 s6.1.1.1: reject declaring variables of the half and
// half array type (unless the cl_khr_fp16 extension is enabled).
if (Context.getBaseElementType(R)->isHalfType()) {
@@ -4705,6 +4704,16 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
SC = SC_None;
}
+ // 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 &&
+ D.getDeclSpec().getThreadStorageClassSpec() ==
+ DeclSpec::TSCS_thread_local && DC->isFunctionOrMethod())
+ SC = SC_Static;
+
IdentifierInfo *II = Name.getAsIdentifierInfo();
if (!II) {
Diag(D.getIdentifierLoc(), diag::err_bad_variable_name)