diff mbox series

[Ada] Inlining nonstatic calls to static expression functions

Message ID 20201020072329.GA31405@adacore.com
State New
Headers show
Series [Ada] Inlining nonstatic calls to static expression functions | expand

Commit Message

Pierre-Marie de Rodat Oct. 20, 2020, 7:23 a.m. UTC
Static expression functions were already effectively inlined in the
case of calls to them with static arguments, but calls with nonstatic
arguments were not generally being inlined, but now they are, as a result
of setting the Has_Pragma_Inline and Is_Inlined flags on such functions.
It appears that it isn't strictly necessary to set the latter flag,
but it still seems reasonable to set it and may be needed in general.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_ch6.adb (Analyze_Expression_Function): Mark static
	expression functions as inlined.
diff mbox series

Patch

diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -609,6 +609,12 @@  package body Sem_Ch6 is
                   Set_Expression
                     (Original_Node (Subprogram_Spec (Def_Id)),
                      New_Copy_Tree (Expr));
+
+                  --  Mark static expression functions as inlined, to ensure
+                  --  that even calls with nonstatic actuals will be inlined.
+
+                  Set_Has_Pragma_Inline (Def_Id);
+                  Set_Is_Inlined (Def_Id);
                end if;
             end if;
          end;