aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2020-04-27 14:22:53 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-19 04:17:11 -0400
commitd48bb126eac73c0d1e311eb4084a6f62742fbf76 (patch)
tree1a0571bd8e689cb2fc35201c5fce474eed8b70cb /gcc/ada
parentd57f8e40433cb73fa08fab92b3238a1981c7c037 (diff)
downloadgcc-d48bb126eac73c0d1e311eb4084a6f62742fbf76.zip
gcc-d48bb126eac73c0d1e311eb4084a6f62742fbf76.tar.gz
gcc-d48bb126eac73c0d1e311eb4084a6f62742fbf76.tar.bz2
[Ada] Fix validity checks on attribute 'Old prefix
2020-06-19 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference): Call Ensure_Valid on the expression of an object declaration that captures the value of 'Old prefix.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/exp_attr.adb16
1 files changed, 11 insertions, 5 deletions
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index 84a36f8..30bb7cc 100644
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -4587,6 +4587,7 @@ package body Exp_Attr is
Typ : constant Entity_Id := Etype (N);
CW_Temp : Entity_Id;
CW_Typ : Entity_Id;
+ Decl : Node_Id;
Ins_Nod : Node_Id;
Subp : Node_Id;
Temp : Entity_Id;
@@ -4685,13 +4686,15 @@ package body Exp_Attr is
CW_Temp := Make_Temporary (Loc, 'T');
CW_Typ := Class_Wide_Type (Typ);
- Insert_Before_And_Analyze (Ins_Nod,
+ Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => CW_Temp,
Constant_Present => True,
Object_Definition => New_Occurrence_Of (CW_Typ, Loc),
Expression =>
- Convert_To (CW_Typ, Relocate_Node (Pref))));
+ Convert_To (CW_Typ, Relocate_Node (Pref)));
+
+ Insert_Before_And_Analyze (Ins_Nod, Decl);
-- Generate:
-- Temp : Typ renames Typ (CW_Temp);
@@ -4709,12 +4712,15 @@ package body Exp_Attr is
-- Generate:
-- Temp : constant Typ := Pref;
- Insert_Before_And_Analyze (Ins_Nod,
+ Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Temp,
Constant_Present => True,
Object_Definition => New_Occurrence_Of (Typ, Loc),
- Expression => Relocate_Node (Pref)));
+ Expression => Relocate_Node (Pref));
+
+ Insert_Before_And_Analyze (Ins_Nod, Decl);
+
end if;
if Present (Subp) then
@@ -4726,7 +4732,7 @@ package body Exp_Attr is
-- to reflect the new placement of the prefix.
if Validity_Checks_On and then Validity_Check_Operands then
- Ensure_Valid (Pref);
+ Ensure_Valid (Expression (Decl));
end if;
Rewrite (N, New_Occurrence_Of (Temp, Loc));