public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-5645] ada: Fix spurious error on call with default parameter in generic package
@ 2023-11-21 9:58 Marc Poulhi?s
0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2023-11-21 9:58 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:50e0095904e0c66b24c205a7d776e6366bc9c7c0
commit r14-5645-g50e0095904e0c66b24c205a7d776e6366bc9c7c0
Author: Eric Botcazou <ebotcazou@adacore.com>
Date: Fri Oct 20 17:22:07 2023 +0200
ada: Fix spurious error on call with default parameter in generic package
This occurs when the default value is a function call returning a private
type, and is caused by a bad interaction between two internal mechanisms.
gcc/ada/
* sem_ch12.adb (Save_Global_References.Set_Global_Type): Beef up
comment about the setting of the full view.
* sem_res.adb (Resolve_Actuals.Insert_Default): Add another bypass
for the case of a generic context.
Diff:
---
gcc/ada/sem_ch12.adb | 7 +++++--
gcc/ada/sem_res.adb | 14 +++++++++++---
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index f73e1b53b0e..31fcbedf774 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -16938,8 +16938,11 @@ package body Sem_Ch12 is
elsif No (Full_View (Typ)) and then Typ /= Etype (Typ) then
null;
- -- Otherwise mark the type for flipping and use the full view when
- -- available.
+ -- Otherwise mark the type for flipping and set the full view on N2
+ -- when available, which is necessary for Check_Private_View to swap
+ -- back the views in case the full declaration of Typ is visible in
+ -- the instantiation context. Note that this will be problematic if
+ -- N2 is re-analyzed later, e.g. if it's a default value in a call.
else
Set_Has_Private_View (N);
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 42f7c10c5c5..70a84176054 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -4017,13 +4017,21 @@ package body Sem_Res is
Analyze_And_Resolve (Actval, Base_Type (Etype (Actval)));
-- Resolve entities with their own type, which may differ from
- -- the type of a reference in a generic context (the view
- -- swapping mechanism did not anticipate the re-analysis of
- -- default values in calls).
+ -- the type of a reference in a generic context because of the
+ -- trick used in Save_Global_References.Set_Global_Type to set
+ -- full views forcefully, which did not anticipate the need to
+ -- re-analyze default values in calls.
elsif Is_Entity_Name (Actval) then
Analyze_And_Resolve (Actval, Etype (Entity (Actval)));
+ -- Ditto for calls whose name is an entity, for the same reason
+
+ elsif Nkind (Actval) = N_Function_Call
+ and then Is_Entity_Name (Name (Actval))
+ then
+ Analyze_And_Resolve (Actval, Etype (Entity (Name (Actval))));
+
else
Analyze_And_Resolve (Actval, Etype (Actval));
end if;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-21 9:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-21 9:58 [gcc r14-5645] ada: Fix spurious error on call with default parameter in generic package 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).