[cfe-commits] r85071 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/attr-deprecated.c

Chris Lattner sabre at nondot.org
Sun Oct 25 15:21:57 PDT 2009


Author: lattner
Date: Sun Oct 25 17:21:57 2009
New Revision: 85071

URL: http://llvm.org/viewvc/llvm-project?rev=85071&view=rev
Log:
When parsing a top level struct declaration, make sure to 
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.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/attr-deprecated.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=85071&r1=85070&r2=85071&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Oct 25 17:21:57 2009
@@ -1319,6 +1319,10 @@
   }
          
   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 @@
   }
       
   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

Modified: cfe/trunk/test/Sema/attr-deprecated.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-deprecated.c?rev=85071&r1=85070&r2=85071&view=diff

==============================================================================
--- cfe/trunk/test/Sema/attr-deprecated.c (original)
+++ cfe/trunk/test/Sema/attr-deprecated.c Sun Oct 25 17:21:57 2009
@@ -43,3 +43,9 @@
 
 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}}
+





More information about the cfe-commits mailing list