From 4fb71b0cc3c199cc0c736b4ec4fabdd01f56f4e8 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sun, 19 Apr 2009 21:48:33 +0000 Subject: [PATCH] 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 --- include/clang/Basic/DiagnosticSemaKinds.td | 2 ++ lib/Sema/SemaDecl.cpp | 2 ++ test/CodeGen/thread-specifier.c | 2 +- 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; -- 2.40.0