From: Aaron Ballman Date: Wed, 20 Nov 2013 21:41:42 +0000 (+0000) Subject: Removed a duplicate diagnostic related to attribute subjects for thread safety annota... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ec3b680064b6d913e1bc53bec666c8ece7fed33;p=clang Removed a duplicate diagnostic related to attribute subjects for thread safety annotations, and replaced it with the more general attribute diagnostic. Updated the test case in the one instance where wording changed. No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195275 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 6ae7d87cc2..5963ec4e0f 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -2136,11 +2136,6 @@ def warn_thread_attribute_decl_not_lockable : Warning< def warn_thread_attribute_decl_not_pointer : Warning< "'%0' only applies to pointer types; type here is %1">, InGroup, DefaultIgnore; -def warn_thread_attribute_wrong_decl_type : Warning< - "%0 attribute only applies to %select{" - "fields and global variables|functions and methods|" - "classes and structs}1">, - InGroup, DefaultIgnore; def err_attribute_argument_out_of_range : Error< "%0 attribute parameter %1 is out of bounds: " "%plural{0:no parameters to index into|" diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 6f884435d9..6460b040f4 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -535,18 +535,12 @@ static void checkAttrArgsAreLockableObjs(Sema &S, Decl *D, // least add some helper functions to check most argument patterns (# // and types of args). -enum ThreadAttributeDeclKind { - ThreadExpectedFieldOrGlobalVar, - ThreadExpectedFunctionOrMethod, - ThreadExpectedClassOrStruct -}; - static bool checkGuardedVarAttrCommon(Sema &S, Decl *D, const AttributeList &Attr) { // D must be either a member field or global (potentially shared) variable. if (!mayBeSharedVariable(D)) { - S.Diag(Attr.getLoc(), diag::warn_thread_attribute_wrong_decl_type) - << Attr.getName() << ThreadExpectedFieldOrGlobalVar; + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) + << Attr.getName() << ExpectedFieldOrGlobalVar; return false; } @@ -580,8 +574,8 @@ static bool checkGuardedByAttrCommon(Sema &S, Decl *D, Expr* &Arg) { // D must be either a member field or global (potentially shared) variable. if (!mayBeSharedVariable(D)) { - S.Diag(Attr.getLoc(), diag::warn_thread_attribute_wrong_decl_type) - << Attr.getName() << ThreadExpectedFieldOrGlobalVar; + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) + << Attr.getName() << ExpectedFieldOrGlobalVar; return false; } @@ -622,8 +616,8 @@ static bool checkLockableAttrCommon(Sema &S, Decl *D, const AttributeList &Attr) { // FIXME: Lockable structs for C code. if (!isa(D)) { - S.Diag(Attr.getLoc(), diag::warn_thread_attribute_wrong_decl_type) - << Attr.getName() << ThreadExpectedClassOrStruct; + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) + << Attr.getName() << ExpectedStructOrUnionOrClass; return false; } @@ -650,8 +644,8 @@ static void handleScopedLockableAttr(Sema &S, Decl *D, static void handleNoThreadSafetyAnalysis(Sema &S, Decl *D, const AttributeList &Attr) { if (!isa(D) && !isa(D)) { - S.Diag(Attr.getLoc(), diag::warn_thread_attribute_wrong_decl_type) - << Attr.getName() << ThreadExpectedFunctionOrMethod; + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) + << Attr.getName() << ExpectedFunctionOrMethod; return; } @@ -705,8 +699,8 @@ static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, // D must be either a member field or global (potentially shared) variable. ValueDecl *VD = dyn_cast(D); if (!VD || !mayBeSharedVariable(D)) { - S.Diag(Attr.getLoc(), diag::warn_thread_attribute_wrong_decl_type) - << Attr.getName() << ThreadExpectedFieldOrGlobalVar; + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) + << Attr.getName() << ExpectedFieldOrGlobalVar; return false; } @@ -762,8 +756,8 @@ static bool checkLockFunAttrCommon(Sema &S, Decl *D, // check that the attribute is applied to a function if (!isa(D) && !isa(D)) { - S.Diag(Attr.getLoc(), diag::warn_thread_attribute_wrong_decl_type) - << Attr.getName() << ThreadExpectedFunctionOrMethod; + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) + << Attr.getName() << ExpectedFunctionOrMethod; return false; } @@ -835,8 +829,8 @@ static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, return false; if (!isa(D) && !isa(D)) { - S.Diag(Attr.getLoc(), diag::warn_thread_attribute_wrong_decl_type) - << Attr.getName() << ThreadExpectedFunctionOrMethod; + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) + << Attr.getName() << ExpectedFunctionOrMethod; return false; } @@ -885,8 +879,8 @@ static bool checkLocksRequiredCommon(Sema &S, Decl *D, return false; if (!isa(D) && !isa(D)) { - S.Diag(Attr.getLoc(), diag::warn_thread_attribute_wrong_decl_type) - << Attr.getName() << ThreadExpectedFunctionOrMethod; + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) + << Attr.getName() << ExpectedFunctionOrMethod; return false; } @@ -929,8 +923,8 @@ static void handleUnlockFunAttr(Sema &S, Decl *D, // zero or more arguments ok if (!isa(D) && !isa(D)) { - S.Diag(Attr.getLoc(), diag::warn_thread_attribute_wrong_decl_type) - << Attr.getName() << ThreadExpectedFunctionOrMethod; + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) + << Attr.getName() << ExpectedFunctionOrMethod; return; } @@ -948,8 +942,8 @@ static void handleUnlockFunAttr(Sema &S, Decl *D, static void handleLockReturnedAttr(Sema &S, Decl *D, const AttributeList &Attr) { if (!isa(D) && !isa(D)) { - S.Diag(Attr.getLoc(), diag::warn_thread_attribute_wrong_decl_type) - << Attr.getName() << ThreadExpectedFunctionOrMethod; + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) + << Attr.getName() << ExpectedFunctionOrMethod; return; } @@ -971,8 +965,8 @@ static void handleLocksExcludedAttr(Sema &S, Decl *D, return; if (!isa(D) && !isa(D)) { - S.Diag(Attr.getLoc(), diag::warn_thread_attribute_wrong_decl_type) - << Attr.getName() << ThreadExpectedFunctionOrMethod; + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) + << Attr.getName() << ExpectedFunctionOrMethod; return; } diff --git a/test/SemaCXX/warn-thread-safety-parsing.cpp b/test/SemaCXX/warn-thread-safety-parsing.cpp index 1bd4e439b7..c7678581db 100644 --- a/test/SemaCXX/warn-thread-safety-parsing.cpp +++ b/test/SemaCXX/warn-thread-safety-parsing.cpp @@ -229,28 +229,28 @@ class __attribute__((lockable (1))) LTestClass_args { // \ }; void l_test_function() LOCKABLE; // \ - // expected-warning {{'lockable' attribute only applies to classes}} + // expected-warning {{'lockable' attribute only applies to struct, union or class}} int l_testfn(int y) { int x LOCKABLE = y; // \ - // expected-warning {{'lockable' attribute only applies to classes}} + // expected-warning {{'lockable' attribute only applies to struct, union or class}} return x; } int l_test_var LOCKABLE; // \ - // expected-warning {{'lockable' attribute only applies to classes}} + // expected-warning {{'lockable' attribute only applies to struct, union or class}} class LFoo { private: int test_field LOCKABLE; // \ - // expected-warning {{'lockable' attribute only applies to classes}} + // expected-warning {{'lockable' attribute only applies to struct, union or class}} void test_method() LOCKABLE; // \ - // expected-warning {{'lockable' attribute only applies to classes}} + // expected-warning {{'lockable' attribute only applies to struct, union or class}} }; void l_function_params(int lvar LOCKABLE); // \ - // expected-warning {{'lockable' attribute only applies to classes}} + // expected-warning {{'lockable' attribute only applies to struct, union or class}} //-----------------------------------------// @@ -269,28 +269,28 @@ class __attribute__((scoped_lockable (1))) SLTestClass_args { // \ }; void sl_test_function() SCOPED_LOCKABLE; // \ - // expected-warning {{'scoped_lockable' attribute only applies to classes}} + // expected-warning {{'scoped_lockable' attribute only applies to struct, union or class}} int sl_testfn(int y) { int x SCOPED_LOCKABLE = y; // \ - // expected-warning {{'scoped_lockable' attribute only applies to classes}} + // expected-warning {{'scoped_lockable' attribute only applies to struct, union or class}} return x; } int sl_test_var SCOPED_LOCKABLE; // \ - // expected-warning {{'scoped_lockable' attribute only applies to classes}} + // expected-warning {{'scoped_lockable' attribute only applies to struct, union or class}} class SLFoo { private: int test_field SCOPED_LOCKABLE; // \ - // expected-warning {{'scoped_lockable' attribute only applies to classes}} + // expected-warning {{'scoped_lockable' attribute only applies to struct, union or class}} void test_method() SCOPED_LOCKABLE; // \ - // expected-warning {{'scoped_lockable' attribute only applies to classes}} + // expected-warning {{'scoped_lockable' attribute only applies to struct, union or class}} }; void sl_function_params(int lvar SCOPED_LOCKABLE); // \ - // expected-warning {{'scoped_lockable' attribute only applies to classes}} + // expected-warning {{'scoped_lockable' attribute only applies to struct, union or class}} //-----------------------------------------//