public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r15-544] ada: Formal_Derived_Type'Size is not static
@ 2024-05-16  8:53 Marc Poulhi?s
  0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2024-05-16  8:53 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:91c6302c8d641990f8977bf8eb5a40370da6efa9

commit r15-544-g91c6302c8d641990f8977bf8eb5a40370da6efa9
Author: Steve Baird <baird@adacore.com>
Date:   Thu Feb 15 14:49:18 2024 -0800

    ada: Formal_Derived_Type'Size is not static
    
    In deciding whether a Size attribute reference is static, the compiler could
    get confused about whether an implicitly-declared subtype of a generic formal
    type is itself a generic formal type, possibly resulting in an assertion
    failure and then a bugbox.
    
    gcc/ada/
    
            * sem_attr.adb (Eval_Attribute): Expand existing checks for
            generic formal types for which Is_Generic_Type returns False. In
            that case, mark the attribute reference as nonstatic.

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

diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 65442d45a85f..2fa7d7d25d22 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -8685,10 +8685,20 @@ package body Sem_Attr is
       --  If the root type or base type is generic, then we cannot fold. This
       --  test is needed because subtypes of generic types are not always
       --  marked as being generic themselves (which seems odd???)
+      --
+      --  Should this situation be addressed instead by either
+      --     a) setting Is_Generic_Type in more cases
+      --  or b) replacing preceding calls to Is_Generic_Type with calls to
+      --        Sem_Util.Some_New_Function
+      --  so that we wouldn't have to deal with these cases here ???
 
       if Is_Generic_Type (P_Root_Type)
         or else Is_Generic_Type (P_Base_Type)
+        or else (Present (Associated_Node_For_Itype (P_Base_Type))
+                  and then Is_Generic_Type (Defining_Identifier
+                             (Associated_Node_For_Itype (P_Base_Type))))
       then
+         Set_Is_Static_Expression (N, False);
          return;
       end if;

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

only message in thread, other threads:[~2024-05-16  8:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-16  8:53 [gcc r15-544] ada: Formal_Derived_Type'Size is not static Marc Poulhi?s

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