public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-7840] ada: Fix deferred constant wrongly rejected
Date: Tue, 26 Sep 2023 15:33:32 +0000 (GMT)	[thread overview]
Message-ID: <20230926153332.B4A353858404@sourceware.org> (raw)

https://gcc.gnu.org/g:35787c3093fa611ba46008e94f329000d6042be4

commit r13-7840-g35787c3093fa611ba46008e94f329000d6042be4
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Sat Sep 16 20:29:20 2023 +0200

    ada: Fix deferred constant wrongly rejected
    
    This recent regression occurs when the nominal subtype of the constant is a
    discriminated record type with default discriminants.
    
    gcc/ada/
            PR ada/110488
            * sem_ch3.adb (Analyze_Object_Declaration): Do not build a default
            subtype for a deferred constant in the definite case too.

Diff:
---
 gcc/ada/sem_ch3.adb | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 299ea6e989f..7aa13b86607 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -4956,9 +4956,11 @@ package body Sem_Ch3 is
             Apply_Length_Check (E, T);
          end if;
 
-      --  When possible, build the default subtype
+      --  When possible, and not a deferred constant, build the default subtype
 
-      elsif Build_Default_Subtype_OK (T) then
+      elsif Build_Default_Subtype_OK (T)
+        and then (not Constant_Present (N) or else Present (E))
+      then
          if No (E) then
             Act_T := Build_Default_Subtype (T, N);
          else

                 reply	other threads:[~2023-09-26 15:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230926153332.B4A353858404@sourceware.org \
    --to=ebotcazou@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).