re PR ada/28305 (GNAT bug when inlining instance of a generic subprogram)
authorSamuel Tardieu <sam@rfc1149.net>
Wed, 9 Apr 2008 14:21:18 +0000 (14:21 +0000)
committerSamuel Tardieu <sam@gcc.gnu.org>
Wed, 9 Apr 2008 14:21:18 +0000 (14:21 +0000)
    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.

From-SVN: r134142

gcc/ada/ChangeLog
gcc/ada/sem_ch6.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/specs/fe_inlining.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/fe_inlining_helper.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/fe_inlining_helper.ads [new file with mode: 0644]

index fe17591183e015ef2a7e94433469fae12869d384..f659d3303eac87b56235b9eb91d000bdb560f276 100644 (file)
@@ -1,3 +1,9 @@
+2008-04-09  Samuel Tardieu  <sam@rfc1149.net>
+
+       PR ada/28305
+       * sem_ch6.adb (Build_Body_To_Inline): Do not save and restore
+       environment if generic instance is a top-level one.
+
 2008-04-09  Doug Rupp  <rupp@adacore.com>
 
        * decl.c (validate_size): Set minimum size for fat pointers same as
index 759607e7246c438370d7b7d2624d98b645f3541d..668a2a7b204aa37ca73c1977a957e2f304dbd215 100644 (file)
@@ -2929,7 +2929,11 @@ 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
+      --  Note that we do not do this at the library level, because it is not
+      --  needed, and furthermore this causes trouble if front end inlining
+      --  is activated (-gnatN).
+
+      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
@@ -2977,7 +2981,9 @@ package body Sem_Ch6 is
 
       Expander_Mode_Restore;
 
-      if In_Instance then
+      --  Restore environment if previously saved
+
+      if In_Instance and then Scope (Current_Scope) /= Standard_Standard then
          Restore_Env;
       end if;
 
index 41ad6d375fd82d51d393557c6cbb541e81adb63a..18d9236b778cab69615e9636e6139afc5c5d5d18 100644 (file)
@@ -1,3 +1,9 @@
+2008-04-09  Samuel Tardieu  <sam@rfc1149.net>
+
+       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.
+
 2008-04-09  Kai Tietz  <kai.tietz@onevision.com>
 
        * gcc.dg/torture/fp-int-convert.h: Use TImode type for 
diff --git a/gcc/testsuite/gnat.dg/specs/fe_inlining.ads b/gcc/testsuite/gnat.dg/specs/fe_inlining.ads
new file mode 100644 (file)
index 0000000..ef5f469
--- /dev/null
@@ -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 (file)
index 0000000..c149ea3
--- /dev/null
@@ -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 (file)
index 0000000..733268c
--- /dev/null
@@ -0,0 +1,3 @@
+-- { dg-excess-errors "no code generated" }
+generic
+procedure FE_Inlining_Helper;