Message ID | 20241105163812.795560-1-quic_apinski@quicinc.com |
---|---|
State | New |
Headers | show |
Series | c: gimplefe: Only allow an identifier before ? [PR117445] | expand |
> Am 05.11.2024 um 17:39 schrieb Andrew Pinski <quic_apinski@quicinc.com>: > > Since r13-707-g68e0063397ba82, COND_EXPR/VEC_COND_EXPR has not > allowed a comparison as the first operand but the gimple front-end > was not updated for this change and you would error out later on. > An assert was added with r15-4791-gb60031e8f9f8fe which meant an ICE > would happen from the gimple FE. > This removes support for parsing of the `?:` expressions except for an > identifier. > > Bootstrapped and tested on x86_64-linux-gnu. Ok Richard > gcc/c/ChangeLog: > > PR c/117445 > * gimple-parser.cc (c_parser_gimple_statement): Remove > support for comparisons before the querry (`?`) token. > > Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com> > --- > gcc/c/gimple-parser.cc | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc > index 8d505084a8a..7e445ce2ff8 100644 > --- a/gcc/c/gimple-parser.cc > +++ b/gcc/c/gimple-parser.cc > @@ -880,11 +880,9 @@ c_parser_gimple_statement (gimple_parser &parser, gimple_seq *seq) > if (lhs.value != error_mark_node > && rhs.value != error_mark_node) > { > - /* If we parsed a comparison or an identifier and the next token > - is a '?' then parse a conditional expression. */ > - if ((COMPARISON_CLASS_P (rhs.value) > - || SSA_VAR_P (rhs.value)) > - && c_parser_next_token_is (parser, CPP_QUERY)) > + /* If we parsed an identifier and the next token is a '?' then parse > + a conditional expression. */ > + if (SSA_VAR_P (rhs.value) && c_parser_next_token_is (parser, CPP_QUERY)) > { > struct c_expr trueval, falseval; > c_parser_consume_token (parser); > -- > 2.43.0 >
diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc index 8d505084a8a..7e445ce2ff8 100644 --- a/gcc/c/gimple-parser.cc +++ b/gcc/c/gimple-parser.cc @@ -880,11 +880,9 @@ c_parser_gimple_statement (gimple_parser &parser, gimple_seq *seq) if (lhs.value != error_mark_node && rhs.value != error_mark_node) { - /* If we parsed a comparison or an identifier and the next token - is a '?' then parse a conditional expression. */ - if ((COMPARISON_CLASS_P (rhs.value) - || SSA_VAR_P (rhs.value)) - && c_parser_next_token_is (parser, CPP_QUERY)) + /* If we parsed an identifier and the next token is a '?' then parse + a conditional expression. */ + if (SSA_VAR_P (rhs.value) && c_parser_next_token_is (parser, CPP_QUERY)) { struct c_expr trueval, falseval; c_parser_consume_token (parser);
Since r13-707-g68e0063397ba82, COND_EXPR/VEC_COND_EXPR has not allowed a comparison as the first operand but the gimple front-end was not updated for this change and you would error out later on. An assert was added with r15-4791-gb60031e8f9f8fe which meant an ICE would happen from the gimple FE. This removes support for parsing of the `?:` expressions except for an identifier. Bootstrapped and tested on x86_64-linux-gnu. gcc/c/ChangeLog: PR c/117445 * gimple-parser.cc (c_parser_gimple_statement): Remove support for comparisons before the querry (`?`) token. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com> --- gcc/c/gimple-parser.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)