[Ada] Forbid anonymous access to subprogram in Compiler_Unit mode

Message ID 20110804080045.GA5314@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Aug. 4, 2011, 8 a.m.
This change adds a check that no anonymous access to subprogram types are used
in runtime units containing pragma Compiler_Unit, because such units are on
the bootstrap path and need to be compilable with Ada 95-only releases of GNAT.

The following compilation must be rejected with the given error message:

$ gcc -c -gnat05 comp_unit.ads
comp_unit.ads:3:22: use of construct not allowed in compiler

package Comp_Unit is
   pragma Compiler_Unit;
   procedure P (AP : access procedure); --  ERROR: anon access to subp
end Comp_Unit;

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

2011-08-04  Thomas Quinot  <quinot@adacore.com>

	* sem_ch3.adb (Access_Definition): Anonymous access to subprogram types
	are forbidden in Compiler_Unit mode.


Index: sem_ch3.adb
--- sem_ch3.adb	(revision 177278)
+++ sem_ch3.adb	(working copy)
@@ -793,6 +793,13 @@ 
       --  the corresponding semantic routine
       if Present (Access_To_Subprogram_Definition (N)) then
+         --  Compiler runtime units are compiled in Ada 2005 mode when building
+         --  the runtime library but must also be compilable in Ada 95 mode
+         --  (when bootstrapping the compiler).
+         Check_Compiler_Unit (N);
            (T_Name => Anon_Type,
             T_Def  => Access_To_Subprogram_Definition (N));