diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-04-19 21:48:33 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-04-19 21:48:33 +0000 |
commit | 4fb71b0cc3c199cc0c736b4ec4fabdd01f56f4e8 (patch) | |
tree | 1c770a07c9898783a6a5441f548b082abbab3d91 | |
parent | b030f0272500c6c5602f587ac029ee0dc0e5a05c (diff) |
Print an error for uses of __thread on targets which don't support it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69553 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | test/CodeGen/thread-specifier.c | 2 | ||||
-rw-r--r-- | test/Sema/thread-specifier.c | 2 |
4 files changed, 6 insertions, 2 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 1c2b0e915c..b2f14633bf 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -97,6 +97,8 @@ def err_invalid_thread : Error< "'__thread' is only allowed on variable declarations">; def err_thread_non_global : Error< "'__thread' variables must have global storage">; +def err_thread_unsupported : Error< + "thread-local storage is unsupported for the current target">; /// Built-in functions. def ext_implicit_lib_function_decl : ExtWarn< diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 90df45a5b2..64fcddd92d 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1734,6 +1734,8 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, if (D.getDeclSpec().isThreadSpecified()) { if (NewVD->hasLocalStorage()) Diag(D.getDeclSpec().getThreadSpecLoc(), diag::err_thread_non_global); + else if (!Context.Target.isTLSSupported()) + Diag(D.getDeclSpec().getThreadSpecLoc(), diag::err_thread_unsupported); else NewVD->setThreadSpecified(true); } diff --git a/test/CodeGen/thread-specifier.c b/test/CodeGen/thread-specifier.c index 08992a6e22..456f7a6d97 100644 --- a/test/CodeGen/thread-specifier.c +++ b/test/CodeGen/thread-specifier.c @@ -1,4 +1,4 @@ -// RUN: clang-cc -emit-llvm -o - %s | grep thread_local | count 4 +// RUN: clang-cc -triple i686-pc-linux-gnu -emit-llvm -o - %s | grep thread_local | count 4 __thread int a; extern __thread int b; diff --git a/test/Sema/thread-specifier.c b/test/Sema/thread-specifier.c index 1d711c1b27..8d66e539c8 100644 --- a/test/Sema/thread-specifier.c +++ b/test/Sema/thread-specifier.c @@ -1,4 +1,4 @@ -// RUN: clang-cc -fsyntax-only -verify %s +// RUN: clang-cc -triple i686-pc-linux-gnu -fsyntax-only -verify %s __thread int t1; __thread extern int t2; |