public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-394] [Ada] Crash in task body reference to discriminant
@ 2022-05-13  8:08 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-13  8:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:fafccfbf77ac245c7fa77c06e4ae001009c3425e

commit r13-394-gfafccfbf77ac245c7fa77c06e4ae001009c3425e
Author: Javier Miranda <miranda@adacore.com>
Date:   Sun Feb 6 11:23:53 2022 +0000

    [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.

Diff:
---
 gcc/ada/sem_attr.adb | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 47485676c74..55da9ef73f2 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-13  8:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13  8:08 [gcc r13-394] [Ada] Crash in task body reference to discriminant Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).