diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-12-18 07:02:59 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-12-18 07:02:59 +0000 |
| commit | cf0bab204205bcb48fbe831ced4b33eefae87e24 (patch) | |
| tree | a7e1291af3ddc716ab2dde19dd5756806a97313e /clang/lib | |
| parent | b6ec4e75ad1147dea55cb9e9c150c53fedfe9e1f (diff) | |
| download | bcm5719-llvm-cf0bab204205bcb48fbe831ced4b33eefae87e24.tar.gz bcm5719-llvm-cf0bab204205bcb48fbe831ced4b33eefae87e24.zip | |
disallow attributes in a few callers of ParseTypeQualifierListOpt,
these completely ignore parsed attributes anyway, so don't try
to read them.
llvm-svn: 61198
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index e31b87bd432..bb3f6479729 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -1251,22 +1251,17 @@ bool Parser::isDeclarationSpecifier() { /// ParseTypeQualifierListOpt /// type-qualifier-list: [C99 6.7.5] /// type-qualifier -/// [GNU] attributes +/// [GNU] attributes [ only if AttributesAllowed=true ] /// type-qualifier-list type-qualifier -/// [GNU] type-qualifier-list attributes +/// [GNU] type-qualifier-list attributes [ only if AttributesAllowed=true ] /// -void Parser::ParseTypeQualifierListOpt(DeclSpec &DS) { +void Parser::ParseTypeQualifierListOpt(DeclSpec &DS, bool AttributesAllowed) { while (1) { int isInvalid = false; const char *PrevSpec = 0; SourceLocation Loc = Tok.getLocation(); switch (Tok.getKind()) { - default: - // If this is not a type-qualifier token, we're done reading type - // qualifiers. First verify that DeclSpec's are consistent. - DS.Finish(Diags, PP.getSourceManager(), getLang()); - return; case tok::kw_const: isInvalid = DS.SetTypeQual(DeclSpec::TQ_const , Loc, PrevSpec, getLang())*2; @@ -1280,8 +1275,16 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS) { getLang())*2; break; case tok::kw___attribute: - DS.AddAttributes(ParseAttributes()); - continue; // do *not* consume the next token! + if (AttributesAllowed) { + DS.AddAttributes(ParseAttributes()); + continue; // do *not* consume the next token! + } + // otherwise, FALL THROUGH! + default: + // If this is not a type-qualifier token, we're done reading type + // qualifiers. First verify that DeclSpec's are consistent. + DS.Finish(Diags, PP.getSourceManager(), getLang()); + return; } // If the specifier combination wasn't legal, issue a diagnostic. @@ -1688,7 +1691,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, // cv-qualifier-seq[opt]. DeclSpec DS; if (getLang().CPlusPlus) { - ParseTypeQualifierListOpt(DS); + ParseTypeQualifierListOpt(DS, false /*no attributes*/); // Parse exception-specification[opt]. if (Tok.is(tok::kw_throw)) @@ -1845,7 +1848,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, DeclSpec DS; if (getLang().CPlusPlus) { // Parse cv-qualifier-seq[opt]. - ParseTypeQualifierListOpt(DS); + ParseTypeQualifierListOpt(DS, false /*no attributes*/); // Parse exception-specification[opt]. if (Tok.is(tok::kw_throw)) @@ -1945,7 +1948,7 @@ void Parser::ParseBracketDeclarator(Declarator &D) { // If there is a type-qualifier-list, read it now. // Type qualifiers in an array subscript are a C99 feature. DeclSpec DS; - ParseTypeQualifierListOpt(DS); + ParseTypeQualifierListOpt(DS, false /*no attributes*/); // If we haven't already read 'static', check to see if there is one after the // type-qualifier-list. |

