aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2020-12-03 10:06:47 -0500
committerPierre-Marie de Rodat <derodat@adacore.com>2021-04-28 05:38:04 -0400
commitff683f9f0341391253eef171890f1b98f18ec99d (patch)
tree1574b25474bb0dbc8d01b42679ba42017f8ea95d /gcc
parentdf5f901ce89cdbf73ae827ee528da776cbcacfac (diff)
downloadgcc-ff683f9f0341391253eef171890f1b98f18ec99d.zip
gcc-ff683f9f0341391253eef171890f1b98f18ec99d.tar.gz
gcc-ff683f9f0341391253eef171890f1b98f18ec99d.tar.bz2
[Ada] Crash with declare expression used in a postcondition
gcc/ada/ * sem_aux.adb (Is_Limited_Type): Fix logic to check Is_Type before assuming Ent is a typo. * sem_ch4.adb (Analyze_Expression_With_Actions): Update comments, minor reformatting. * sem_res.adb (Resolve_Declare_Expression): Add protection against no type.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_aux.adb10
-rw-r--r--gcc/ada/sem_ch4.adb11
-rw-r--r--gcc/ada/sem_res.adb1
3 files changed, 15 insertions, 7 deletions
diff --git a/gcc/ada/sem_aux.adb b/gcc/ada/sem_aux.adb
index 4925ffd..3eddad9 100644
--- a/gcc/ada/sem_aux.adb
+++ b/gcc/ada/sem_aux.adb
@@ -1072,14 +1072,18 @@ package body Sem_Aux is
---------------------
function Is_Limited_Type (Ent : Entity_Id) return Boolean is
- Btype : constant E := Base_Type (Ent);
- Rtype : constant E := Root_Type (Btype);
+ Btype : Entity_Id;
+ Rtype : Entity_Id;
begin
if not Is_Type (Ent) then
return False;
+ end if;
- elsif Ekind (Btype) = E_Limited_Private_Type
+ Btype := Base_Type (Ent);
+ Rtype := Root_Type (Btype);
+
+ if Ekind (Btype) = E_Limited_Private_Type
or else Is_Limited_Composite (Btype)
then
return True;
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 7a8c261..ad6c7fd 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -2278,9 +2278,12 @@ package body Sem_Ch4 is
procedure Analyze_Expression_With_Actions (N : Node_Id) is
procedure Check_Action_OK (A : Node_Id);
- -- Check that the action is something that is allows as a declare_item
- -- of a declare_expression, except the checks are suppressed for
- -- generated code.
+ -- Check that the action A is allowed as a declare_item of a declare
+ -- expression if N and A come from source.
+
+ ---------------------
+ -- Check_Action_OK --
+ ---------------------
procedure Check_Action_OK (A : Node_Id) is
begin
@@ -2324,7 +2327,7 @@ package body Sem_Ch4 is
Error_Msg_N ("object renaming or constant declaration expected", A);
end Check_Action_OK;
- A : Node_Id;
+ A : Node_Id;
EWA_Scop : Entity_Id;
-- Start of processing for Analyze_Expression_With_Actions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index f6e0eab..39907ae 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -7494,6 +7494,7 @@ package body Sem_Res is
Node := First (Actions (N));
while Present (Node) loop
if Nkind (Node) = N_Object_Declaration
+ and then Is_Type (Etype (Defining_Identifier (Node)))
and then Requires_Transient_Scope
(Etype (Defining_Identifier (Node)))
then