diff --git a/src/shared/cplusplus/CheckDeclarator.cpp b/src/shared/cplusplus/CheckDeclarator.cpp index 86e3541d561f9c548f0afcf2048c1fddfd3b36bf..44aaf32a0bd986ac46d3cf5b0cfacf432de644b2 100644 --- a/src/shared/cplusplus/CheckDeclarator.cpp +++ b/src/shared/cplusplus/CheckDeclarator.cpp @@ -241,6 +241,9 @@ bool CheckDeclarator::visit(ReferenceAST *ast) { const bool rvalueRef = (tokenKind(ast->reference_token) == T_AMPER_AMPER); + if (_fullySpecifiedType->isReferenceType()) + translationUnit()->error(ast->firstToken(), "cannot declare reference to a reference"); + ReferenceType *refTy = control()->referenceType(_fullySpecifiedType, rvalueRef); FullySpecifiedType ty(refTy); _fullySpecifiedType = ty;