From: Eric Botcazou Date: Tue, 26 Feb 2019 08:12:21 +0000 (+0000) Subject: re PR ada/81956 (call to null procedure not optimized away) X-Git-Tag: releases/gcc-7.5.0~570 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de4e663d340b3f67be660ff652770a632673f314;p=thirdparty%2Fgcc.git re PR ada/81956 (call to null procedure not optimized away) PR ada/81956 Backport from mainline 2017-09-06 Ed Schonberg * exp_ch6.adb (Expand_Call_Helper): Do not optimize calls to null procedures when GNAT coverage is used, so that their (empty) bodies are properly covered. 2017-09-06 Ed Schonberg * exp_ch6.adb (Expand_Call_Helper): Replace call to null procedure by a single null statement, after evaluating the actuals that require it. From-SVN: r269205 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ee33d9fb21e6..8e4ab2167617 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,19 @@ +2019-02-26 Eric Botcazou + + PR ada/81956 + Backport from mainline + 2017-09-06 Ed Schonberg + + * exp_ch6.adb (Expand_Call_Helper): Do not optimize calls to + null procedures when GNAT coverage is used, so that their (empty) + bodies are properly covered. + + 2017-09-06 Ed Schonberg + + * exp_ch6.adb (Expand_Call_Helper): Replace call to null + procedure by a single null statement, after evaluating the + actuals that require it. + 2019-02-23 Eric Botcazou PR ada/89349 diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index e9f13319ed51..1713581f3c55 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -3937,6 +3937,23 @@ package body Exp_Ch6 is Unchecked_Convert_To (RTE (RE_Address), Relocate_Node (First_Actual (Call_Node)))); return; + + -- A call to a null procedure is replaced by a null statement, but we + -- are not allowed to ignore possible side effects of the call, so we + -- make sure that actuals are evaluated. + -- We also suppress this optimization for GNATCoverage. + + elsif Is_Null_Procedure (Subp) + and then not Opt.Suppress_Control_Flow_Optimizations + then + Actual := First_Actual (Call_Node); + while Present (Actual) loop + Remove_Side_Effects (Actual); + Next_Actual (Actual); + end loop; + + Rewrite (Call_Node, Make_Null_Statement (Loc)); + return; end if; -- Handle inlining. No action needed if the subprogram is not inlined