This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] ada: Do not save and restore environment if generic instance is a top-level one


Compiled and regtested on i686-pc-linux-gnu.


    gcc/ada/
	PR ada/28305
	* sem_ch6.adb (Build_Body_To_Inline): Do not save and restore
	environment if generic instance is a top-level one.

    gcc/testsuite/
	PR ada/28305
	* gnat.dg/specs/fe_inlining.ads, gnat.dg/specs/fe_inlining_helper.ads,
	gnat.dg/specs/fe_inlining_helper.adb: New test.
---
 gcc/ada/sem_ch6.adb                                |    4 ++--
 gcc/testsuite/gnat.dg/specs/fe_inlining.ads        |    4 ++++
 gcc/testsuite/gnat.dg/specs/fe_inlining_helper.adb |    4 ++++
 gcc/testsuite/gnat.dg/specs/fe_inlining_helper.ads |    2 ++
 4 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gnat.dg/specs/fe_inlining.ads
 create mode 100644 gcc/testsuite/gnat.dg/specs/fe_inlining_helper.adb
 create mode 100644 gcc/testsuite/gnat.dg/specs/fe_inlining_helper.ads

diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 69064c2..3d77135 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -2837,7 +2837,7 @@ package body Sem_Ch6 is
       --  Within an instance, the body to inline must be treated as a nested
       --  generic, so that the proper global references are preserved.
 
-      if In_Instance then
+      if In_Instance and then Scope (Current_Scope) /= Standard_Standard then
          Save_Env (Scope (Current_Scope), Scope (Current_Scope));
          Original_Body := Copy_Generic_Node (N, Empty, True);
       else
@@ -2885,7 +2885,7 @@ package body Sem_Ch6 is
 
       Expander_Mode_Restore;
 
-      if In_Instance then
+      if In_Instance and then Scope (Current_Scope) /= Standard_Standard then
          Restore_Env;
       end if;
 
diff --git a/gcc/testsuite/gnat.dg/specs/fe_inlining.ads b/gcc/testsuite/gnat.dg/specs/fe_inlining.ads
new file mode 100644
index 0000000..ef5f469
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/fe_inlining.ads
@@ -0,0 +1,4 @@
+-- { dg-do compile }
+-- { dg-options "-O -gnatN" }
+with FE_Inlining_Helper;
+procedure FE_Inlining is new FE_Inlining_Helper;
diff --git a/gcc/testsuite/gnat.dg/specs/fe_inlining_helper.adb b/gcc/testsuite/gnat.dg/specs/fe_inlining_helper.adb
new file mode 100644
index 0000000..c149ea3
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/fe_inlining_helper.adb
@@ -0,0 +1,4 @@
+procedure FE_Inlining_Helper is
+begin
+   null;
+end FE_Inlining_Helper;
diff --git a/gcc/testsuite/gnat.dg/specs/fe_inlining_helper.ads b/gcc/testsuite/gnat.dg/specs/fe_inlining_helper.ads
new file mode 100644
index 0000000..358dc9e
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/fe_inlining_helper.ads
@@ -0,0 +1,2 @@
+generic
+procedure FE_Inlining_Helper;
-- 
1.5.3.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]