[Ada] Aspect specifications on subprogram renaming declarations
Arnaud Charlet
charlet@adacore.com
Wed Nov 23 14:30:00 GMT 2011
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 db.ads in Ada 2012 mode must yield:
db.ads:9:07: incorrect placement of aspect "PRE"
db.ads:10:07: incorrect placement of aspect "POST"
db.ads:11:06: 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
with
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 <schonberg@adacore.com>
* sem_ch8.adb (Analyze_Subprogram_Renaming_Declaration):
If the declaration has aspects, analyze them so they can be
properly rejected.
-------------- next part --------------
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;
More information about the Gcc-patches
mailing list