[cfe-commits] r39567 - /cfe/cfe/trunk/Parse/ParseDecl.cpp
bwendlin at cs.uiuc.edu
bwendlin at cs.uiuc.edu
Wed Jul 11 09:45:41 PDT 2007
Author: bwendlin
Date: Wed Jul 11 11:45:41 2007
New Revision: 39567
URL: http://llvm.org/viewvc/llvm-project?rev=39567&view=rev
Log:
Submitted by: Bill Wendling
Reviewed by: Chris Lattner
- Update the parsing of references. We allow "restrict" but not "const"
or "volatile".
Modified:
cfe/cfe/trunk/Parse/ParseDecl.cpp
Modified: cfe/cfe/trunk/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseDecl.cpp?rev=39567&r1=39566&r2=39567&view=diff
==============================================================================
--- cfe/cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseDecl.cpp Wed Jul 11 11:45:41 2007
@@ -927,7 +927,6 @@
isInvalid = DS.SetTypeQual(DeclSpec::TQ_restrict, Loc, PrevSpec,
getLang())*2;
break;
-
case tok::kw___attribute:
ParseAttributes();
break;
@@ -960,15 +959,13 @@
/// ParseDeclaratorInternal
/// declarator: [C99 6.7.5]
/// pointer[opt] direct-declarator
-/// [C++] reference direct-declarator [C++ 8p4, dcl.decl]
+/// [C++] '&' declarator [C++ 8p4, dcl.decl]
+/// [GNU] '&' restrict[opt] attributes[opt] declarator
///
/// pointer: [C99 6.7.5]
/// '*' type-qualifier-list[opt]
/// '*' type-qualifier-list[opt] pointer
///
-/// reference: [C++ 8p4, dcl.decl]
-/// [C++] '&' declarator
-///
void Parser::ParseDeclaratorInternal(Declarator &D) {
tok::TokenKind Kind = Tok.getKind();
@@ -991,12 +988,32 @@
D.AddTypeInfo(DeclaratorChunk::getPointer(DS.getTypeQualifiers(), Loc));
} else {
// Is a reference
+ DeclSpec DS;
+
+ // C++ 8.3.2p1: cv-qualified references are ill-formed except when the
+ // cv-qualifiers are introduced through the use of a typedef or of a
+ // template type argument, in which case the cv-qualifiers are ignored.
+ //
+ // [GNU] Retricted references are allowed.
+ // [GNU] Attributes on references are allowed.
+ ParseTypeQualifierListOpt(DS);
+
+ if (DS.getTypeQualifiers() != DeclSpec::TQ_unspecified) {
+ if (DS.getTypeQualifiers() & DeclSpec::TQ_const)
+ Diag(DS.getConstSpecLoc(),
+ diag::err_invalid_reference_qualifier_application,
+ "const");
+ if (DS.getTypeQualifiers() & DeclSpec::TQ_volatile)
+ Diag(DS.getVolatileSpecLoc(),
+ diag::err_invalid_reference_qualifier_application,
+ "volatile");
+ }
// Recursively parse the declarator.
ParseDeclaratorInternal(D);
// Remember that we parsed a reference type. It doesn't have type-quals.
- D.AddTypeInfo(DeclaratorChunk::getReference(Loc));
+ D.AddTypeInfo(DeclaratorChunk::getReference(DS.getTypeQualifiers(), Loc));
}
}
@@ -1355,7 +1372,7 @@
0/*TODO: NumElts is not a C90 constantexpr */)
Diag(StartLoc, diag::ext_c99_array_usage);
}
-
+
// Remember that we parsed a pointer type, and remember the type-quals.
D.AddTypeInfo(DeclaratorChunk::getArray(DS.getTypeQualifiers(),
StaticLoc.isValid(), isStar,
More information about the cfe-commits
mailing list