summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-11-03 15:51:28 +0000
committerDouglas Gregor <dgregor@apple.com>2008-11-03 15:51:28 +0000
commit66583c5ff3234a3302a13cfb763b7b4924ef2e24 (patch)
treed92cefe7471f54ecdb1028c6cf9848755947504d /clang/lib/Parse/ParseDecl.cpp
parentfb2f87bbfe1cb18c3f33b809da83b96bf2682bb1 (diff)
downloadbcm5719-llvm-66583c5ff3234a3302a13cfb763b7b4924ef2e24.tar.gz
bcm5719-llvm-66583c5ff3234a3302a13cfb763b7b4924ef2e24.zip
Implement C++ DR 106 and C++ DR 540, both of which deal with
reference-collapsing. Implement diagnostic for formation of a reference to cv void. Drop cv-qualifiers added to a reference type when the reference type comes from a typedef. llvm-svn: 58612
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 7a84171a058..f414f16af73 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -1222,6 +1222,19 @@ void Parser::ParseDeclaratorInternal(Declarator &D) {
// Recursively parse the declarator.
ParseDeclaratorInternal(D);
+ if (D.getNumTypeObjects() > 0) {
+ // C++ [dcl.ref]p4: There shall be no references to references.
+ DeclaratorChunk& InnerChunk = D.getTypeObject(D.getNumTypeObjects() - 1);
+ if (InnerChunk.Kind == DeclaratorChunk::Reference) {
+ Diag(InnerChunk.Loc, diag::err_illegal_decl_reference_to_reference,
+ D.getIdentifier() ? D.getIdentifier()->getName() : "type name");
+
+ // Once we've complained about the reference-to-referwnce, we
+ // can go ahead and build the (technically ill-formed)
+ // declarator: reference collapsing will take care of it.
+ }
+ }
+
// Remember that we parsed a reference type. It doesn't have type-quals.
D.AddTypeInfo(DeclaratorChunk::getReference(DS.getTypeQualifiers(), Loc,
DS.TakeAttributes()));
OpenPOWER on IntegriCloud