From: Chris Lattner Date: Tue, 9 Nov 2010 20:14:26 +0000 (+0000) Subject: fix PR8380, a crash on invalid due to an illogical DeclSpec SourceRange being constru... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=729ad83035f4e62eaec403fbdc7c1c843fa30f59;p=clang fix PR8380, a crash on invalid due to an illogical DeclSpec SourceRange being constructed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118625 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 9e430a4296..7e01bacf5c 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -889,6 +889,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, AccessSpecifier AS, DeclSpecContext DSContext) { DS.SetRangeStart(Tok.getLocation()); + DS.SetRangeEnd(Tok.getLocation()); while (1) { bool isInvalid = false; const char *PrevSpec = 0; diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 083d6ab798..c5906aa19a 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -187,7 +187,6 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, unsigned Context) { assert(Tok.is(tok::string_literal) && "Not a string literal!"); llvm::SmallString<8> LangBuffer; - // LangBuffer is guaranteed to be big enough. bool Invalid = false; llvm::StringRef Lang = PP.getSpelling(Tok, LangBuffer, &Invalid); if (Invalid) diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp index e00ffd070f..6b355e814a 100644 --- a/test/Parser/cxx-decl.cpp +++ b/test/Parser/cxx-decl.cpp @@ -83,3 +83,14 @@ struct CodeCompleteConsumer { void CodeCompleteConsumer::() { // expected-error {{xpected unqualified-id}} } + +; + +// PR8380 +extern "" // expected-error {{unknown linkage language}} +test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} \ + // expected-error {{expected ';' after top level declarator}} + + int test6b; + +