diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-02-04 17:00:24 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-02-04 17:00:24 +0000 |
commit | b696ea3a0693798daeafd896d77f0b8f1fec3cc5 (patch) | |
tree | b0d300f2f25fe4de861bacc0011a4ed2110ecb49 /lib/Parse | |
parent | f680a0fe2dcab32b59fe6fdf71145b5313c40950 (diff) |
Diagnose ambiguities in getTypeName. Fixes http://llvm.org/bugs/show_bug.cgi?id=3475
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63737 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse')
-rw-r--r-- | lib/Parse/MinimalAction.cpp | 4 | ||||
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 12 | ||||
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 3 | ||||
-rw-r--r-- | lib/Parse/Parser.cpp | 2 |
4 files changed, 12 insertions, 9 deletions
diff --git a/lib/Parse/MinimalAction.cpp b/lib/Parse/MinimalAction.cpp index 6fd5fc0315..2d6c9a6ba5 100644 --- a/lib/Parse/MinimalAction.cpp +++ b/lib/Parse/MinimalAction.cpp @@ -80,8 +80,8 @@ void MinimalAction::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { /// /// FIXME: Use the passed CXXScopeSpec for accurate C++ type checking. Action::TypeTy * -MinimalAction::getTypeName(IdentifierInfo &II, Scope *S, - const CXXScopeSpec *SS) { +MinimalAction::getTypeName(IdentifierInfo &II, SourceLocation Loc, + Scope *S, const CXXScopeSpec *SS) { if (TypeNameInfo *TI = II.getFETokenInfo<TypeNameInfo>()) if (TI->isTypeName) return TI; diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index cc1e9970e9..114f4cb570 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -484,8 +484,9 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, GetLookAheadToken(2).is(tok::l_paren)) goto DoneWithDeclSpec; - TypeTy *TypeRep = Actions.getTypeName(*NextToken().getIdentifierInfo(), - CurScope, &SS); + Token Next = NextToken(); + TypeTy *TypeRep = Actions.getTypeName(*Next.getIdentifierInfo(), + Next.getLocation(), CurScope, &SS); if (TypeRep == 0) goto DoneWithDeclSpec; @@ -538,7 +539,8 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, goto DoneWithDeclSpec; // It has to be available as a typedef too! - TypeTy *TypeRep = Actions.getTypeName(*Tok.getIdentifierInfo(), CurScope); + TypeTy *TypeRep = Actions.getTypeName(*Tok.getIdentifierInfo(), + Tok.getLocation(), CurScope); if (TypeRep == 0) goto DoneWithDeclSpec; @@ -1737,7 +1739,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) { // constructor name. else if (Actions.isCurrentClassName(*Tok.getIdentifierInfo(), CurScope)) D.setConstructor(Actions.getTypeName(*Tok.getIdentifierInfo(), - CurScope), + Tok.getLocation(), CurScope), Tok.getLocation()); // This is a normal identifier. else @@ -2191,7 +2193,7 @@ void Parser::ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc, IdentifierInfo *ParmII = Tok.getIdentifierInfo(); // Reject 'typedef int y; int test(x, y)', but continue parsing. - if (Actions.getTypeName(*ParmII, CurScope)) + if (Actions.getTypeName(*ParmII, Tok.getLocation(), CurScope)) Diag(Tok, diag::err_unexpected_typedef_ident) << ParmII; // Verify that the argument identifier has not already been mentioned. diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 628331fd1d..1fbe32a459 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -232,7 +232,8 @@ Parser::TypeTy *Parser::ParseClassName(const CXXScopeSpec *SS) { } // We have an identifier; check whether it is actually a type. - TypeTy *Type = Actions.getTypeName(*Tok.getIdentifierInfo(), CurScope, SS); + TypeTy *Type = Actions.getTypeName(*Tok.getIdentifierInfo(), + Tok.getLocation(), CurScope, SS); if (!Type) { Diag(Tok, diag::err_expected_class_name); return 0; diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 8685a599d2..c5c7dd4733 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -758,7 +758,7 @@ bool Parser::TryAnnotateTypeOrScopeToken() { if (Tok.is(tok::identifier)) { // Determine whether the identifier is a type name. if (TypeTy *Ty = Actions.getTypeName(*Tok.getIdentifierInfo(), - CurScope, &SS)) { + Tok.getLocation(), CurScope, &SS)) { // This is a typename. Replace the current token in-place with an // annotation type token. Tok.setKind(tok::annot_typename); |