aboutsummaryrefslogtreecommitdiff
path: root/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
commitf1f9b4e5c7fd087e78f2e387c01098d49d41e784 (patch)
tree2b284ad30db30e9d23e65a1142666598ef13751e /lib/Parse/ParseDecl.cpp
parentb4e66d5259f90e9aae4d40fc5de801e046c7df94 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58612 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r--lib/Parse/ParseDecl.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 7a84171a05..f414f16af7 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/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()));