[Ada] Elaboration checks in generic units

Message ID 20100614093750.GA3937@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet June 14, 2010, 9:37 a.m.
Calls within a generic unit do not need an elaboration check. This patch fixes
a hole in the dynamic elaboration machinery, which allowed internal calls from 
a subprogram nested within a generic unit to be placed in the list of calls 
that are examined after semantic analysis, leading to crashes in units
compiled with -gnatE.

The following must compile quietly:

   gcc -c -gnatE p1.adb
package P1 is
  function Gen (X : Integer) return Integer;
package body P1 is
   function Gen (X : Integer) return Integer is
      function Gen2 (X: integer) return Integer is
        return Gen (X - 1);
      if X = 0 then
          return 0;
         return Gen2 (X - Gen (2));
      end if;
   end Gen;

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

2010-06-14  Ed Schonberg  <schonberg@adacore.com>

	* sem_elab.adb (Check_Internal_Call): Do not place a call appearing
	within a generic unit in the table of delayed calls.


Index: sem_elab.adb
--- sem_elab.adb	(revision 149925)
+++ sem_elab.adb	(working copy)
@@ -1891,6 +1891,11 @@  package body Sem_Elab is
       elsif In_Task_Activation then
+      --  Nothing to do if call is within a generic unit.
+      elsif Inside_A_Generic then
+         return;
       end if;
       --  Delay this call if we are still delaying calls