[cfe-commits] r39569 - /cfe/cfe/trunk/Sema/SemaType.cpp
bwendlin at cs.uiuc.edu
bwendlin at cs.uiuc.edu
Wed Jul 11 09:45:43 PDT 2007
Author: bwendlin
Date: Wed Jul 11 11:45:43 2007
New Revision: 39569
URL: http://llvm.org/viewvc/llvm-project?rev=39569&view=rev
Log:
Submitted by: Bill Wendling
Reviewed by: Chris Lattner
- Disallow references to references, pointers to references, or arrays of
references.
Modified:
cfe/cfe/trunk/Sema/SemaType.cpp
Modified: cfe/cfe/trunk/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/SemaType.cpp?rev=39569&r1=39568&r2=39569&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/SemaType.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaType.cpp Wed Jul 11 11:45:43 2007
@@ -116,12 +116,25 @@
switch (DeclType.Kind) {
default: assert(0 && "Unknown decltype!");
case DeclaratorChunk::Pointer:
- T = Context.getPointerType(T);
+ if (isa<ReferenceType>(T.getCanonicalType().getTypePtr())) {
+ // C++ 8.3.2p4: There shall be no ... pointers to references ...
+ Diag(D.getIdentifierLoc(), diag::err_illegal_decl_pointer_to_reference,
+ D.getIdentifier()->getName());
+ return QualType();
+ }
// Apply the pointer typequals to the pointer object.
- T = T.getQualifiedType(DeclType.Ptr.TypeQuals);
+ T = Context.getPointerType(T).getQualifiedType(DeclType.Ptr.TypeQuals);
break;
case DeclaratorChunk::Reference:
+ if (isa<ReferenceType>(T.getCanonicalType().getTypePtr())) {
+ // C++ 8.3.2p4: There shall be no references to references ...
+ Diag(D.getIdentifierLoc(),
+ diag::err_illegal_decl_reference_to_reference,
+ D.getIdentifier()->getName());
+ return QualType();
+ }
+
T = Context.getReferenceType(T);
break;
case DeclaratorChunk::Array: {
@@ -146,6 +159,11 @@
Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_functions,
D.getIdentifier()->getName());
return QualType();
+ } else if (isa<ReferenceType>(CanonicalT)) {
+ // C++ 8.3.2p4: There shall be no ... arrays of references ...
+ Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_references,
+ D.getIdentifier()->getName());
+ return QualType();
} else if (RecordType *EltTy = dyn_cast<RecordType>(CanonicalT)) {
// If the element type is a struct or union that contains a variadic
// array, reject it: C99 6.7.2.1p2.
More information about the cfe-commits
mailing list