Here we ICE in c_expr_sizeof_expr on an erroneous expr.value. The
code checks for expr.value == error_mark_node but here the e_m_n is
wrapped in a C_MAYBE_CONST_EXPR. I don't think we should have created
such a tree, so let's return earlier in c_cast_expr.
PR c/115642
gcc/c/ChangeLog:
* c-typeck.cc (c_cast_expr): Return error_mark_node if build_c_cast
failed.
gcc/testsuite/ChangeLog:
* gcc.dg/noncompile/sizeof-1.c: New test.
return error_mark_node;
ret = build_c_cast (loc, type, expr);
+ if (ret == error_mark_node)
+ return error_mark_node;
+
if (type_expr)
{
bool inner_expr_const = true;
--- /dev/null
+/* PR c/115642 */
+/* { dg-do compile } */
+
+void f (int N) {
+ int a[2][N];
+ sizeof ((int [2][N])a); /* { dg-error "cast specifies array type" } */
+}