]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR ada/81956 (call to null procedure not optimized away)
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 26 Feb 2019 08:12:21 +0000 (08:12 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 26 Feb 2019 08:12:21 +0000 (08:12 +0000)
PR ada/81956
Backport from mainline
2017-09-06  Ed Schonberg  <schonberg@adacore.com>

* 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  <schonberg@adacore.com>

* 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

gcc/ada/ChangeLog
gcc/ada/exp_ch6.adb

index ee33d9fb21e699d77d1f969286c054a56b3c6d7b..8e4ab216761741bffe590d067053e2649c8db5bb 100644 (file)
@@ -1,3 +1,19 @@
+2019-02-26  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR ada/81956
+       Backport from mainline
+       2017-09-06  Ed Schonberg  <schonberg@adacore.com>
+
+       * 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  <schonberg@adacore.com>
+
+       * 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  <ebotcazou@adacore.com>
 
        PR ada/89349
index e9f13319ed51505464a7c959f517245cc6f61194..1713581f3c55cd316a76557568f56a1e0a9d2835 100644 (file)
@@ -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