Patchwork [Ada] Aspect specifications on subprogram renaming declarations

mail settings
Submitter Arnaud Charlet
Date Nov. 23, 2011, 1:52 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/127309/
State New
Headers show


Arnaud Charlet - Nov. 23, 2011, 1:52 p.m.
The syntax of Ada 2012 accepts aspect specifications on renaming declarations,
but no language-defined aspects exist for them, so that pre- and postconditions
on these declarations must be rejected.

Compiling in Ada 2012 mode must yield: incorrect placement of aspect "PRE" incorrect placement of aspect "POST" incorrect placement of aspect "TEST_CASE"

package DB is
   type Account is tagged record
      X : Integer;
   end record;

   procedure Open (It : out Account; V : Integer);
   procedure Op (It : out Account; V : Integer) renames Open
      Pre      => (V > 0),
      Post     => (It.X = V),
     Test_Case => (Name     => "existing account",
                   Mode     => Nominal,
                   Ensures  =>  T.X > 0);
end DB;

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

2011-11-23  Ed Schonberg  <>

	* sem_ch8.adb (Analyze_Subprogram_Renaming_Declaration):
	If the declaration has aspects, analyze them so they can be
	properly rejected.


Index: sem_ch8.adb
--- sem_ch8.adb	(revision 181662)
+++ sem_ch8.adb	(working copy)
@@ -52,6 +52,7 @@ 
 with Sem_Ch4;  use Sem_Ch4;
 with Sem_Ch6;  use Sem_Ch6;
 with Sem_Ch12; use Sem_Ch12;
+with Sem_Ch13; use Sem_Ch13;
 with Sem_Disp; use Sem_Disp;
 with Sem_Dist; use Sem_Dist;
 with Sem_Eval; use Sem_Eval;
@@ -2848,6 +2849,13 @@ 
           ("?redundant renaming, entity is directly visible", Name (N));
       end if;
+      --  Implementation-defined aspect specifications can appear in a renaming
+      --  declaration, but not language-defined ones.
+      if Has_Aspects (N) then
+         Analyze_Aspect_Specifications (N, New_S);
+      end if;
       Ada_Version := Save_AV;
       Ada_Version_Explicit := Save_AV_Exp;
    end Analyze_Subprogram_Renaming;