From: Joseph Myers Date: Wed, 22 Jan 2020 01:23:42 +0000 (+0000) Subject: Fix ICE with cast of division by zero (PR c/93348). X-Git-Tag: upstream/12.2.0~18903 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ac68e287fc2e939ae6b45ba7ff04e493982b7f62;p=platform%2Fupstream%2Fgcc.git Fix ICE with cast of division by zero (PR c/93348). Bug 93348 reports an ICE on certain cases of casts of expressions that may appear only in unevaluated parts of integer constant expressions, arising from the generation of nested C_MAYBE_CONST_EXPRs. This patch fixes it by adding a call to remove_c_maybe_const_expr in the integer-operands case, as is done in other similar cases. Bootstrapped with no regressions for x86_64-pc-linux-gnu. PR c/93348 gcc/c: * c-typeck.c (build_c_cast): Call remove_c_maybe_const_expr on argument with integer operands. gcc/testsuite: * gcc.c-torture/compile/pr93348-1.c: New test. --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index c638756..9497365 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2020-01-22 Joseph Myers + + PR c/93348 + * c-typeck.c (build_c_cast): Call remove_c_maybe_const_expr on + argument with integer operands. + 2020-01-16 Kerem Kat PR c/92833 diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 9866c83..8df0849 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -5715,6 +5715,8 @@ build_c_cast (location_t loc, tree type, tree expr) expr = TREE_OPERAND (expr, 0); value = expr; + if (int_operands) + value = remove_c_maybe_const_expr (value); if (type == error_mark_node || expr == error_mark_node) return error_mark_node; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9681453..f72c987 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-01-22 Joseph Myers + + PR c/93348 + * gcc.c-torture/compile/pr93348-1.c: New test. + 2020-01-21 David Malcolm PR analyzer/93352 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr93348-1.c b/gcc/testsuite/gcc.c-torture/compile/pr93348-1.c new file mode 100644 index 0000000..d2edec5 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr93348-1.c @@ -0,0 +1,5 @@ +int +ya (void) +{ + return (long int) (1 / 0); +}