ref: 0e38613504c7711310c22403a692bef825f00dc8
parent: 825d523e6ae30a93224c2d6799592ae73f7ea926
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Aug 5 14:20:31 EDT 2014
Forbids castings to array or functions These casting are explicitily forbidden in the standard, and it has sense, since we can not change the type of an object memory. There is no legal use of a function type name, and it makes ambigous the gramatic, because the parentheses can be nested directdcl or a fundcl. So the simpler solution is to forbid always the type names of functions.
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -500,6 +500,8 @@
tp = specifier(&sclass);
if (sclass)
error("class storage in type name");
+ if (yytoken == '(')
+ error("type name specifies a function type");
sym = declarator(tp, ID_FORBIDDEN);
return sym->type;
}
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -551,6 +551,8 @@
case TQUALIFIER: case TYPE:
tp = typename();
expect(')');
+ if (tp->op == ARY)
+ error("cast specify an array type");
if ((np1 = eval(cast())) == NULL)
unexpected();
if ((np2 = convert(np1, tp, 1)) == NULL)