summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorMichael Han <Michael.Han@autodesk.com>2012-10-04 16:42:52 +0000
committerMichael Han <Michael.Han@autodesk.com>2012-10-04 16:42:52 +0000
commit360d225ae99b276df0ab705760de37c93016f16f (patch)
treefdaa8fa862c444019df75abd5b7d3333b70a7555 /clang/lib
parent2247f8afbd8c35c5ff61d816c6f36d3480c4e4f6 (diff)
downloadbcm5719-llvm-360d225ae99b276df0ab705760de37c93016f16f.tar.gz
bcm5719-llvm-360d225ae99b276df0ab705760de37c93016f16f.zip
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. llvm-svn: 165234
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp9
-rw-r--r--clang/lib/Sema/SemaDecl.cpp3
2 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index e90d0eb9fe4..27cc4843cf0 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -155,7 +155,7 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs,
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 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName,
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 @@ void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
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 @@ void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
// 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();
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 5a33230b2c5..d177fd91034 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2774,8 +2774,7 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS,
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 :
OpenPOWER on IntegriCloud