Fix an error recovery ICE that occurs when a typename
can not be parsed correctly in the controlling expression
of a generic selection.
PR c/120303
gcc/c/ChangeLog:
* c-parser.cc (c_parser_generic_selection): Handle error
condition.
gcc/testsuite/ChangeLog:
* gcc.dg/pr120303.c: New test.
"ISO C does not support use of type name as %<_Generic%> "
"controlling operand before C2Y");
struct c_type_name *type = c_parser_type_name (parser);
- selector_type = groktypename (type, NULL, NULL);
+ if (type)
+ selector_type = groktypename (type, NULL, NULL);
c_inhibit_evaluation_warnings--;
+ if (!type)
+ {
+ c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
+ return error_expr;
+ }
}
else
{
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-std=c2y" } */
+
+int t = _Generic (char(1)); /* { dg-error "before numeric constant" } */
+