From: Eric Botcazou Date: Tue, 14 Feb 2023 12:33:08 +0000 (+0100) Subject: Fix small regression in Ada X-Git-Tag: release-12.2.mpacbti-rel1~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2155c14612ed63fc7e93d038f0a8fe01bb14fefb;p=thirdparty%2Fgcc.git Fix small regression in Ada gcc/ * gimplify.cc (gimplify_save_expr): Add missing guard. gcc/testsuite/ * gnat.dg/shift2.adb: New test. --- diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index a3aa90262c52..a551c574a2df 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -6373,7 +6373,7 @@ gimplify_save_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) gcc_assert (TREE_CODE (*expr_p) == SAVE_EXPR); val = TREE_OPERAND (*expr_p, 0); - if (TREE_TYPE (val) == error_mark_node) + if (val && TREE_TYPE (val) == error_mark_node) return GS_ERROR; /* If the SAVE_EXPR has not been resolved, then evaluate it once. */ diff --git a/gcc/testsuite/gnat.dg/shift2.adb b/gcc/testsuite/gnat.dg/shift2.adb new file mode 100644 index 000000000000..b45e44018132 --- /dev/null +++ b/gcc/testsuite/gnat.dg/shift2.adb @@ -0,0 +1,8 @@ +-- { dg-do compile } + +with Interfaces; use Interfaces; + +function Shift2 (V : Unsigned_32) return Unsigned_32 is +begin + return Shift_Left (V, (case V is when 0 => 1, when others => 0)); +end;