diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-06-19 01:23:22 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-06-19 01:23:22 +0000 |
commit | c05ca5e40c7eee09a12fe5fff81e7ca1b3450aba (patch) | |
tree | 6a40da951b71e076748c68424d2dee728e4c769a /clang/lib/Parse/ParseDecl.cpp | |
parent | a0050b0961b1fd1cbdd58bc6257bc3f54b25acf4 (diff) | |
download | bcm5719-llvm-c05ca5e40c7eee09a12fe5fff81e7ca1b3450aba.tar.gz bcm5719-llvm-c05ca5e40c7eee09a12fe5fff81e7ca1b3450aba.zip |
DiagnoseUnknownTypename always emits a diagnostic and returns true
Make it return void and delete the dead code in the parser that handled
the case where it might return false. This has been dead since 2010
when John deleted Action.h.
llvm-svn: 211248
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 55 |
1 files changed, 23 insertions, 32 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 0b59fef2f8f..cb0857bd232 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -2170,42 +2170,33 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS, } } - // This is almost certainly an invalid type name. Let the action emit a - // diagnostic and attempt to recover. + // This is almost certainly an invalid type name. Let Sema emit a diagnostic + // and attempt to recover. ParsedType T; IdentifierInfo *II = Tok.getIdentifierInfo(); - if (Actions.DiagnoseUnknownTypeName(II, Loc, getCurScope(), SS, T, - getLangOpts().CPlusPlus && - NextToken().is(tok::less))) { - // The action emitted a diagnostic, so we don't have to. - if (T) { - // The action has suggested that the type T could be used. Set that as - // the type in the declaration specifiers, consume the would-be type - // name token, and we're done. - const char *PrevSpec; - unsigned DiagID; - DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID, T, - Actions.getASTContext().getPrintingPolicy()); - DS.SetRangeEnd(Tok.getLocation()); - ConsumeToken(); - // There may be other declaration specifiers after this. - return true; - } else if (II != Tok.getIdentifierInfo()) { - // If no type was suggested, the correction is to a keyword - Tok.setKind(II->getTokenID()); - // There may be other declaration specifiers after this. - return true; - } - - // Fall through; the action had no suggestion for us. - } else { - // The action did not emit a diagnostic, so emit one now. - SourceRange R; - if (SS) R = SS->getRange(); - Diag(Loc, diag::err_unknown_typename) << Tok.getIdentifierInfo() << R; + Actions.DiagnoseUnknownTypeName(II, Loc, getCurScope(), SS, T, + getLangOpts().CPlusPlus && + NextToken().is(tok::less)); + if (T) { + // The action has suggested that the type T could be used. Set that as + // the type in the declaration specifiers, consume the would-be type + // name token, and we're done. + const char *PrevSpec; + unsigned DiagID; + DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID, T, + Actions.getASTContext().getPrintingPolicy()); + DS.SetRangeEnd(Tok.getLocation()); + ConsumeToken(); + // There may be other declaration specifiers after this. + return true; + } else if (II != Tok.getIdentifierInfo()) { + // If no type was suggested, the correction is to a keyword + Tok.setKind(II->getTokenID()); + // There may be other declaration specifiers after this. + return true; } - // Mark this as an error. + // Otherwise, the action had no suggestion for us. Mark this as an error. DS.SetTypeSpecError(); DS.SetRangeEnd(Tok.getLocation()); ConsumeToken(); |