aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSteve Baird <baird@adacore.com>2021-12-06 13:42:51 -0800
committerPierre-Marie de Rodat <derodat@adacore.com>2022-01-06 17:11:36 +0000
commit5bad97d7445d679921e87bc0f94286c3ade02d27 (patch)
treeca1164ecc16a470bfaa3f6c7f9b31b3eb3aaa5de /gcc
parentc60f23e13ecbc5a5b07adb7557f1da094246cb2a (diff)
downloadgcc-5bad97d7445d679921e87bc0f94286c3ade02d27.zip
gcc-5bad97d7445d679921e87bc0f94286c3ade02d27.tar.gz
gcc-5bad97d7445d679921e87bc0f94286c3ade02d27.tar.bz2
[Ada] Avoid building malformed component constraints
gcc/ada/ * sem_util.adb (Build_Discriminant_Reference): In the unexpected case where we previously would fail an assertion, we instead revert to the old behavior.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_util.adb15
1 files changed, 8 insertions, 7 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 2bc3c95..e07e487 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -2107,11 +2107,7 @@ package body Sem_Util is
-- Start of processing for Build_Discriminant_Reference
begin
- if Obj_Is_Good_Prefix then
- return Make_Selected_Component (Loc,
- Prefix => Copy_And_Maybe_Dereference (Obj),
- Selector_Name => New_Occurrence_Of (Discrim, Loc));
- else
+ if not Obj_Is_Good_Prefix then
-- If the given discriminant is not a component of the given
-- object, then try the enclosing object.
@@ -2128,10 +2124,15 @@ package body Sem_Util is
(Discrim_Name => Discrim_Name,
Obj => Name (Parent (Entity (Obj))));
else
- pragma Assert (False);
- raise Program_Error;
+ -- We are in some unexpected case here, so revert to the
+ -- old behavior (by falling through to it).
+ null;
end if;
end if;
+
+ return Make_Selected_Component (Loc,
+ Prefix => Copy_And_Maybe_Dereference (Obj),
+ Selector_Name => New_Occurrence_Of (Discrim, Loc));
end Build_Discriminant_Reference;
------------------------------------