aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Miranda <miranda@adacore.com>2022-02-06 11:23:53 +0000
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-13 08:04:33 +0000
commitfafccfbf77ac245c7fa77c06e4ae001009c3425e (patch)
tree35fcb6faa4bb449666c2bc9485e88b15f5573009
parent6a28d40dc4dd47431cc52edbb8b1994f81aa1748 (diff)
downloadgcc-fafccfbf77ac245c7fa77c06e4ae001009c3425e.zip
gcc-fafccfbf77ac245c7fa77c06e4ae001009c3425e.tar.gz
gcc-fafccfbf77ac245c7fa77c06e4ae001009c3425e.tar.bz2
[Ada] Crash in task body reference to discriminant
The compiler may crash processing the successor or predecessor of a task type discrete discriminant. gcc/ada/ * sem_attr.adb (Resolve_Attribute): Ensure that attribute expressions are resolved at this stage; required for preanalyzed references to discriminants since their resolution (and expansion) will take care of updating their Entity attribute to reference their discriminal.
-rw-r--r--gcc/ada/sem_attr.adb22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 4748567..55da9ef 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -12500,6 +12500,28 @@ package body Sem_Attr is
when others => null;
end case;
+ -- Ensure that attribute expressions are resolved at this stage;
+ -- required for preanalyzed references to discriminants since
+ -- their resolution (and expansion) will take care of updating
+ -- their Entity attribute to reference their discriminal.
+
+ if Expander_Active
+ and then Present (Expressions (N))
+ then
+ declare
+ Expr : Node_Id := First (Expressions (N));
+
+ begin
+ while Present (Expr) loop
+ if not Analyzed (Expr) then
+ Resolve (Expr, Etype (Expr));
+ end if;
+
+ Next (Expr);
+ end loop;
+ end;
+ end if;
+
-- If the prefix of the attribute is a class-wide type then it
-- will be expanded into a dispatching call to a predefined
-- primitive. Therefore we must check for potential violation