aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog9
-rw-r--r--gcc/ada/sem_ch13.adb32
2 files changed, 31 insertions, 10 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index f8c1145..3dfcd9e 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,12 @@
+2014-10-17 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch13.adb (Add_Invariants, Replace_Type_References): Do
+ not perform the replacement on the expression for an inherited
+ class-wide invariant if in ASIS_Mode and the type reference is
+ already the prefix of a 'Class attribute reference: the expression
+ has already been preanalyzed and the replacement performed when
+ first encountered on the declaration of the parent type.
+
2014-10-17 Robert Dewar <dewar@adacore.com>
* sem_ch5.adb, sem_ch7.adb, prj-nmsc.adb, sem_ch13.adb, exp_ch3.adb:
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index ba5a1ee..9ab019a 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -7505,18 +7505,30 @@ package body Sem_Ch13 is
end if;
-- Invariant'Class, replace with T'Class (obj)
+ -- In ASIS mode, an inherited item is analyzed already, and the
+ -- replacement has been done, so do not repeat transformation
+ -- to prevent ill-formed tree.
if Class_Present (Ritem) then
- Rewrite (N,
- Make_Type_Conversion (Sloc (N),
- Subtype_Mark =>
- Make_Attribute_Reference (Sloc (N),
- Prefix => New_Occurrence_Of (T, Sloc (N)),
- Attribute_Name => Name_Class),
- Expression => Make_Identifier (Sloc (N), Object_Name)));
-
- Set_Entity (Expression (N), Object_Entity);
- Set_Etype (Expression (N), Typ);
+ if ASIS_Mode
+ and then Nkind (Parent (N)) = N_Attribute_Reference
+ and then Attribute_Name (Parent (N)) = Name_Class
+ then
+ null;
+
+ else
+ Rewrite (N,
+ Make_Type_Conversion (Sloc (N),
+ Subtype_Mark =>
+ Make_Attribute_Reference (Sloc (N),
+ Prefix => New_Occurrence_Of (T, Sloc (N)),
+ Attribute_Name => Name_Class),
+ Expression =>
+ Make_Identifier (Sloc (N), Object_Name)));
+
+ Set_Entity (Expression (N), Object_Entity);
+ Set_Etype (Expression (N), Typ);
+ end if;
-- Invariant, replace with obj