https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123162
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> (gdb) p debug_tree(lhs)
> <cond_expr 0x7ffff781c1b0
> type <integer_type 0x7ffff781d5e8 int public SI
> size <integer_cst 0x7ffff781f1b0 constant 32>
> unit-size <integer_cst 0x7ffff781f1c8 constant 4>
> align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
> 0x7ffff781d5e8 precision:32 min <integer_cst 0x7ffff781f168 -2147483648> max
> <integer_cst 0x7ffff781f180 2147483647>
> pointer_to_this <pointer_type 0x7ffff7825b28>>
>
> arg:0 <integer_cst 0x7ffff781f300 type <integer_type 0x7ffff781d5e8 int>
> constant 0> arg:1 <integer_cst 0x7ffff781f300 0> arg:2 <error_mark
> 0x7ffff7802f48>
> t9.c:4:3 start: t9.c:4:3 finish: t9.c:4:11>
>
>
> The bug is in parser_build_binary_op I think.
Sorry build_conditional_expr.
This fixes the issue for me:
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index cab21e29004..68ff223d093 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -6942,7 +6942,10 @@ build_conditional_expr (location_t colon_loc, tree
ifexp, bool ifexp_bcp,
op1 = c_fully_fold (op1, false, NULL);
op2 = c_fully_fold (op2, false, NULL);
}
- ret = build3 (COND_EXPR, result_type, ifexp, op1, op2);
+ if (op1 == error_mark_node || op2 == error_mark_node)
+ ret = error_mark_node;
+ else
+ ret = build3 (COND_EXPR, result_type, ifexp, op1, op2);
if (int_operands)
ret = note_integer_operands (ret);
}