]> granicus.if.org Git - clang/commitdiff
When parsing a top level struct declaration, make sure to
authorChris Lattner <sabre@nondot.org>
Sun, 25 Oct 2009 22:21:57 +0000 (22:21 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 25 Oct 2009 22:21:57 +0000 (22:21 +0000)
process decl attributes instead of dropping them on the floor.
This allows us to diagnose cases like the testcase.  Also don't
diagnose deprecated stuff in ActOnTag: not all uses of tags
may be 'uses', and SemaType does this now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85071 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Sema/attr-deprecated.c

index 08d7235665bbbccedb283930243cc894427b1e8d..7b37df9cbee2e4fc20a92f228a3ca77ac588be34 100644 (file)
@@ -1319,6 +1319,10 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
   }
          
   if (RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag)) {
+    // If there are attributes in the DeclSpec, apply them to the record.
+    if (const AttributeList *AL = DS.getAttributes())
+      ProcessDeclAttributeList(S, Record, AL);
+    
     if (!Record->getDeclName() && Record->isDefinition() &&
         DS.getStorageClassSpec() != DeclSpec::SCS_typedef) {
       if (getLangOptions().CPlusPlus ||
@@ -4305,9 +4309,6 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
   }
       
   if (PrevDecl) {
-    // Check whether the previous declaration is usable.
-    (void)DiagnoseUseOfDecl(PrevDecl, NameLoc);
-
     if (TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
       // If this is a use of a previous tag, or if the tag is already declared
       // in the same scope (so that the definition/declaration completes or
index e15381e4c6d10fcf31cfc9c7f26c3347aed01f89..45c5dd0676b533a02e1ed390c3bca6c229738703 100644 (file)
@@ -43,3 +43,9 @@ void test1(struct foo *F) {
 
 typedef struct foo foo_dep __attribute__((deprecated));
 foo_dep *test2;    // expected-warning {{'foo_dep' is deprecated}}
+
+struct bar_dep __attribute__((deprecated, 
+                              invalid_attribute));  // expected-warning {{'invalid_attribute' attribute ignored}}
+
+struct bar_dep *test3;   // expected-warning {{'bar_dep' is deprecated}}
+