From 8e2b0632e89343b90e67d6613615e8e43b0f9e93 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 6 Feb 2012 14:28:38 -0800 Subject: [PATCH] Issue an error if an array of references is declared. (More malformed program fixes.) --- decl.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/decl.cpp b/decl.cpp index beff32d8..f5c0eb88 100644 --- a/decl.cpp +++ b/decl.cpp @@ -355,6 +355,11 @@ Declarator::GetType(const Type *base, DeclSpecs *ds) const { Error(pos, "Arrays of \"void\" type are illegal."); return NULL; } + if (dynamic_cast(type)) { + Error(pos, "Arrays of references (type \"%s\") are illegal.", + type->GetString().c_str()); + return NULL; + } type = new ArrayType(type, arraySize); if (child) @@ -472,6 +477,11 @@ Declarator::GetType(const Type *base, DeclSpecs *ds) const { return NULL; } + if (child == NULL) { + Assert(m->errorCount > 0); + return NULL; + } + const Type *functionType = new FunctionType(returnType, args, argNames, argDefaults, argPos, isTask, isExported, isExternC);