diff mbox

[Ada] Obsolescence considerations for pragma Interface/Interface_Name

Message ID 20130129140139.GA21465@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Jan. 29, 2013, 2:01 p.m. UTC
Interface is now flagged as violating restriction No_Obsolescent_Features
even in Ada 95 mode.

Both Interface and Interface_Name cause warnings to be issued
with -gnatwj (but we don't consider that Interface_Name
violates the restriction, since Interface_Name is a GNAT
defined pragma that is not in the RM, and in particular not
in Annex J). The following is compiled with -gnatwj

      1. pragma Restrictions (No_Obsolescent_Features);
      2. package ObsInter is
      3.    procedure q;
      4.    pragma Interface (C, q);
            1      3
         >>> warning: pragma Interface is an obsolescent feature
         >>> warning: use pragma Import instead
         >>> violation of restriction "no_obsolescent_features" at line 1

      5.    pragma Interface_Name (q, "qroutine");
            |
         >>> warning: pragma Interface_Name is an obsolescent feature
         >>> warning: use pragma Import instead

      6. end;

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

2013-01-29  Robert Dewar  <dewar@adacore.com>

	* sem_prag.adb (Analyze_Pragma, case Interface): Consider to
	be a violation of No_Obsolescent_Features even in Ada 95. Also
	generates a warning in -gnatwj mode.
	(Analyze_Pragma, case Interface_Name): Generates a warning in -gnatwj
	mode.
	* gnat_ugn.texi: Additional documentation on -gnatwj and pragma
	Interface[_Name].
diff mbox

Patch

Index: gnat_ugn.texi
===================================================================
--- gnat_ugn.texi	(revision 195533)
+++ gnat_ugn.texi	(working copy)
@@ -5523,7 +5523,9 @@ 
 GNAT features that have been provided in past versions but which
 have been superseded (typically by features in the new Ada standard).
 For example, @code{pragma Ravenscar} will be flagged since its
-function is replaced by @code{pragma Profile(Ravenscar)}.
+function is replaced by @code{pragma Profile(Ravenscar)}, and
+@code{pragma Interface_Name} will be flagged since its function
+is replaced by @code{pragma Import}.
 
 Note that this warning option functions differently from the
 restriction @code{No_Obsolescent_Features} in two respects.
Index: sem_prag.adb
===================================================================
--- sem_prag.adb	(revision 195533)
+++ sem_prag.adb	(working copy)
@@ -11095,11 +11095,19 @@ 
             Process_Import_Or_Interface;
 
             --  In Ada 2005, the permission to use Interface (a reserved word)
-            --  as a pragma name is considered an obsolescent feature.
+            --  as a pragma name is considered an obsolescent feature, and this
+            --  pragma was already obsolescent in Ada 95.
 
-            if Ada_Version >= Ada_2005 then
+            if Ada_Version >= Ada_95 then
                Check_Restriction
                  (No_Obsolescent_Features, Pragma_Identifier (N));
+
+               if Warn_On_Obsolescent_Feature then
+                  Error_Msg_N
+                    ("pragma Interface is an obsolescent feature?j?", N);
+                  Error_Msg_N
+                    ("|use pragma Import instead?j?", N);
+               end if;
             end if;
 
          --------------------
@@ -11126,6 +11134,19 @@ 
             Id := Get_Pragma_Arg (Arg1);
             Analyze (Id);
 
+            --  This is obsolete from Ada 95 on, but it is an implementation
+            --  defined pragma, so we do not consider that it violates the
+            --  restriction (No_Obsolescent_Features).
+
+            if Ada_Version >= Ada_95 then
+               if Warn_On_Obsolescent_Feature then
+                  Error_Msg_N
+                    ("pragma Interface_Name is an obsolescent feature?j?", N);
+                  Error_Msg_N
+                    ("|use pragma Import instead?j?", N);
+               end if;
+            end if;
+
             if not Is_Entity_Name (Id) then
                Error_Pragma_Arg
                  ("first argument for pragma% must be entity name", Arg1);