[cfe-commits] r61198 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Parse/ParseDecl.cpp
Chris Lattner
sabre at nondot.org
Wed Dec 17 23:03:00 PST 2008
Author: lattner
Date: Thu Dec 18 01:02:59 2008
New Revision: 61198
URL: http://llvm.org/viewvc/llvm-project?rev=61198&view=rev
Log:
disallow attributes in a few callers of ParseTypeQualifierListOpt,
these completely ignore parsed attributes anyway, so don't try
to read them.
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseDecl.cpp
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=61198&r1=61197&r2=61198&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Dec 18 01:02:59 2008
@@ -889,7 +889,7 @@
typedef void (Parser::*DirectDeclParseFunction)(Declarator&);
void ParseDeclaratorInternal(Declarator &D,
DirectDeclParseFunction DirectDeclParser);
- void ParseTypeQualifierListOpt(DeclSpec &DS);
+ void ParseTypeQualifierListOpt(DeclSpec &DS, bool AllowAttributes = true);
void ParseDirectDeclarator(Declarator &D);
void ParseParenDeclarator(Declarator &D);
void ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=61198&r1=61197&r2=61198&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Dec 18 01:02:59 2008
@@ -1251,22 +1251,17 @@
/// 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 @@
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 @@
// 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 @@
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 @@
// 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.
More information about the cfe-commits
mailing list