public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-coroutines] [Ada] Visibility error with aggregate in Declare_Expression
@ 2020-07-06 20:59 Iain D Sandoe
0 siblings, 0 replies; only message in thread
From: Iain D Sandoe @ 2020-07-06 20:59 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:07ac6d8aadae834c20493def3c38ce6b67383c6a
commit 07ac6d8aadae834c20493def3c38ce6b67383c6a
Author: Ed Schonberg <schonberg@adacore.com>
Date: Wed May 6 12:03:27 2020 -0400
[Ada] Visibility error with aggregate in Declare_Expression
gcc/ada/
* sem_res.adb (Resolve_Declare_Expression): New subprogram, to
install the scope holding local declarations of the expression,
before completing its resolution.
(Resolve): For an Expression_With_Actions that comes from a
source occurrence of a Declare_Expression, call new subprogram.
Diff:
---
gcc/ada/sem_res.adb | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 5c75a3b2aab..eabde9176cc 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -178,6 +178,7 @@ package body Sem_Res is
procedure Resolve_Case_Expression (N : Node_Id; Typ : Entity_Id);
procedure Resolve_Character_Literal (N : Node_Id; Typ : Entity_Id);
procedure Resolve_Comparison_Op (N : Node_Id; Typ : Entity_Id);
+ procedure Resolve_Declare_Expression (N : Node_Id; Typ : Entity_Id);
procedure Resolve_Entity_Name (N : Node_Id; Typ : Entity_Id);
procedure Resolve_Equality_Op (N : Node_Id; Typ : Entity_Id);
procedure Resolve_Explicit_Dereference (N : Node_Id; Typ : Entity_Id);
@@ -2285,10 +2286,18 @@ package body Sem_Res is
Check_Parameterless_Call (N);
-- The resolution of an Expression_With_Actions is determined by
- -- its Expression.
+ -- its Expression, but if the node comes from source it is a
+ -- Declare_Expression and requires scope management.
if Nkind (N) = N_Expression_With_Actions then
- Resolve (Expression (N), Typ);
+ if Comes_From_Source (N)
+ and then N = Original_Node (N)
+ then
+ Resolve_Declare_Expression (N, Typ);
+
+ else
+ Resolve (Expression (N), Typ);
+ end if;
Found := True;
Expr_Type := Etype (Expression (N));
@@ -7399,6 +7408,49 @@ package body Sem_Res is
end if;
end Resolve_Comparison_Op;
+ --------------------------------
+ -- Resolve_Declare_Expression --
+ --------------------------------
+
+ procedure Resolve_Declare_Expression
+ (N : Node_Id;
+ Typ : Entity_Id)
+ is
+ Decl : Node_Id;
+ begin
+ -- Install the scope created for local declarations, if
+ -- any. The syntax allows a Declare_Expression with no
+ -- declarations, in analogy with block statements.
+
+ Decl := First (Actions (N));
+
+ while Present (Decl) loop
+ exit when Nkind (Decl) = N_Object_Declaration;
+ Next (Decl);
+ end loop;
+
+ if Present (Decl) then
+ Push_Scope (Scope (Defining_Identifier (Decl)));
+
+ declare
+ E : Entity_Id := First_Entity (Current_Scope);
+
+ begin
+ while Present (E) loop
+ Set_Current_Entity (E);
+ Set_Is_Immediately_Visible (E);
+ Next_Entity (E);
+ end loop;
+ end;
+
+ Resolve (Expression (N), Typ);
+ End_Scope;
+
+ else
+ Resolve (Expression (N), Typ);
+ end if;
+ end Resolve_Declare_Expression;
+
-----------------------------------------
-- Resolve_Discrete_Subtype_Indication --
-----------------------------------------
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-07-06 20:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-06 20:59 [gcc/devel/c++-coroutines] [Ada] Visibility error with aggregate in Declare_Expression Iain D Sandoe
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).