aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-11-04 02:18:39 +0000
committerJohn McCall <rjmccall@apple.com>2009-11-04 02:18:39 +0000
commit54abf7d4fa3123b8324c09d2a4dfb789fd818403 (patch)
treee0a899f37d5b05f29b984352e1d9f09b610e12f5 /lib/Parse/ParseDecl.cpp
parent05a2338f7ba1c8a0136e120502f80a38cf0e9fd3 (diff)
Change our basic strategy for avoiding deprecation warnings when the decl use
appears in a deprecated context. In the new strategy, we emit the warnings as usual unless we're currently parsing a declaration, where "declaration" is restricted to mean a decl group or a few special cases in Objective C. If we *are* parsing a declaration, we queue up the deprecation warnings until the declaration has been completely parsed, and then emit them only if the decl is not deprecated. We also standardize the bookkeeping for deprecation so as to avoid special cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85998 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r--lib/Parse/ParseDecl.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index a47065c2b5..e905553fd8 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -338,7 +338,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclaration(unsigned Context,
Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration(unsigned Context,
SourceLocation &DeclEnd) {
// Parse the common declaration-specifiers piece.
- DeclSpec DS;
+ ParsingDeclSpec DS(*this);
ParseDeclarationSpecifiers(DS);
// C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
@@ -346,6 +346,7 @@ Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration(unsigned Context,
if (Tok.is(tok::semi)) {
ConsumeToken();
DeclPtrTy TheDecl = Actions.ParsedFreeStandingDeclSpec(CurScope, DS);
+ DS.complete(TheDecl);
return Actions.ConvertDeclToDeclGroup(TheDecl);
}
@@ -357,11 +358,12 @@ Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration(unsigned Context,
/// ParseDeclGroup - Having concluded that this is either a function
/// definition or a group of object declarations, actually parse the
/// result.
-Parser::DeclGroupPtrTy Parser::ParseDeclGroup(DeclSpec &DS, unsigned Context,
+Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,
+ unsigned Context,
bool AllowFunctionDefinitions,
SourceLocation *DeclEnd) {
// Parse the first declarator.
- Declarator D(DS, static_cast<Declarator::TheContext>(Context));
+ ParsingDeclarator D(*this, DS, static_cast<Declarator::TheContext>(Context));
ParseDeclarator(D);
// Bail out if the first declarator didn't seem well-formed.
@@ -397,6 +399,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(DeclSpec &DS, unsigned Context,
llvm::SmallVector<DeclPtrTy, 8> DeclsInGroup;
DeclPtrTy FirstDecl = ParseDeclarationAfterDeclarator(D);
+ D.complete(FirstDecl);
if (FirstDecl.get())
DeclsInGroup.push_back(FirstDecl);
@@ -425,6 +428,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(DeclSpec &DS, unsigned Context,
ParseDeclarator(D);
DeclPtrTy ThisDecl = ParseDeclarationAfterDeclarator(D);
+ D.complete(ThisDecl);
if (ThisDecl.get())
DeclsInGroup.push_back(ThisDecl);
}
@@ -1505,6 +1509,7 @@ ParseStructDeclaration(DeclSpec &DS, FieldCallback &Fields) {
// Read struct-declarators until we find the semicolon.
bool FirstDeclarator = true;
while (1) {
+ ParsingDeclRAIIObject PD(*this);
FieldDeclarator DeclaratorInfo(DS);
// Attributes are only allowed here on successive declarators.
@@ -1536,7 +1541,8 @@ ParseStructDeclaration(DeclSpec &DS, FieldCallback &Fields) {
}
// We're done with this declarator; invoke the callback.
- (void) Fields.invoke(DeclaratorInfo);
+ DeclPtrTy D = Fields.invoke(DeclaratorInfo);
+ PD.complete(D);
// If we don't have a comma, it is either the end of the list (a ';')
// or an error, bail out.
@@ -2587,6 +2593,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
SourceLocation DSStart = Tok.getLocation();
// Parse the declaration-specifiers.
+ // Just use the ParsingDeclaration "scope" of the declarator.
DeclSpec DS;
// If the caller parsed attributes for the first argument, add them now.