[cfe-commits] r165234 - in /cfe/trunk/lib: Parse/ParseDecl.cpp Sema/SemaDecl.cpp

Michael Han Michael.Han at autodesk.com
Thu Oct 4 09:42:52 PDT 2012


Author: hanm
Date: Thu Oct  4 11:42:52 2012
New Revision: 165234

URL: http://llvm.org/viewvc/llvm-project?rev=165234&view=rev
Log:
Fix scope location when parsing GNU attributes.

For GNU attributes, instead of reusing attribute source 
location for the scope location, use SourceLocation() since 
GNU attributes don not have scope tokens. 


Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=165234&r1=165233&r2=165234&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Oct  4 11:42:52 2012
@@ -155,7 +155,7 @@
           LA->Toks.push_back(Eof);
         } else {
           ParseGNUAttributeArgs(AttrName, AttrNameLoc, attrs, endLoc,
-                                0, AttrNameLoc, AttributeList::AS_GNU);
+                                0, SourceLocation(), AttributeList::AS_GNU);
         }
       } else {
         attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc,
@@ -282,8 +282,9 @@
 
   SourceLocation RParen = Tok.getLocation();
   if (!ExpectAndConsume(tok::r_paren, diag::err_expected_rparen)) {
+    SourceLocation AttrLoc = ScopeLoc.isValid() ? ScopeLoc : AttrNameLoc;
     AttributeList *attr =
-      Attrs.addNew(AttrName, SourceRange(AttrNameLoc, RParen),
+      Attrs.addNew(AttrName, SourceRange(AttrLoc, RParen),
                    ScopeName, ScopeLoc, ParmName, ParmLoc,
                    ArgExprs.data(), ArgExprs.size(), Syntax);
     if (BuiltinType && attr->getKind() == AttributeList::AT_IBOutletCollection)
@@ -929,7 +930,7 @@
         Actions.ActOnReenterFunctionContext(Actions.CurScope, D);
 
       ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc,
-                            0, LA.AttrNameLoc, AttributeList::AS_GNU);
+                            0, SourceLocation(), AttributeList::AS_GNU);
 
       if (HasFunScope) {
         Actions.ActOnExitFunctionContext();
@@ -942,7 +943,7 @@
       // If there are multiple decls, then the decl cannot be within the
       // function scope.
       ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc,
-                            0, LA.AttrNameLoc, AttributeList::AS_GNU);
+                            0, SourceLocation(), AttributeList::AS_GNU);
     }
   } else {
     Diag(Tok, diag::warn_attribute_no_decl) << LA.AttrName.getName();

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=165234&r1=165233&r2=165234&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Oct  4 11:42:52 2012
@@ -2774,8 +2774,7 @@
         TypeSpecType == DeclSpec::TST_enum) {
       AttributeList* attrs = DS.getAttributes().getList();
       while (attrs) {
-        Diag(attrs->getScopeLoc(),
-             diag::warn_declspec_attribute_ignored)
+        Diag(attrs->getLoc(), diag::warn_declspec_attribute_ignored)
         << attrs->getName()
         << (TypeSpecType == DeclSpec::TST_class ? 0 :
             TypeSpecType == DeclSpec::TST_struct ? 1 :





More information about the cfe-commits mailing list