From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Eric Botcazou <ebotcazou@adacore.com>
Subject: [Ada] Do not mark user parameters of protected subprograms as artificial
Date: Mon, 12 Sep 2022 10:19:20 +0200 [thread overview]
Message-ID: <20220912081920.GA1512860@poulhies-Precision-5550> (raw)
[-- Attachment #1: Type: text/plain, Size: 459 bytes --]
This occurs because protected subprograms are not translated directly into
object code but first rewritten as a pair of subprograms by the front-end.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* exp_ch9.adb (Build_Protected_Spec): Tidy up and propagate the
Comes_From_Source flag onto the new formal parameters.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Do not check
references for subprograms generated for protected subprograms.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 2949 bytes --]
diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -3868,32 +3868,35 @@ package body Exp_Ch9 is
Ident : Entity_Id;
Unprotected : Boolean := False) return List_Id
is
- Loc : constant Source_Ptr := Sloc (N);
- Decl : Node_Id;
- Formal : Entity_Id;
- New_Plist : List_Id;
- New_Param : Node_Id;
+ Loc : constant Source_Ptr := Sloc (N);
+
+ Decl : Node_Id;
+ Formal : Entity_Id;
+ New_Formal : Entity_Id;
+ New_Plist : List_Id;
begin
New_Plist := New_List;
Formal := First_Formal (Ident);
while Present (Formal) loop
- New_Param :=
+ New_Formal :=
+ Make_Defining_Identifier (Sloc (Formal), Chars (Formal));
+ Set_Comes_From_Source (New_Formal, Comes_From_Source (Formal));
+
+ if Unprotected then
+ Mutate_Ekind (New_Formal, Ekind (Formal));
+ Set_Protected_Formal (Formal, New_Formal);
+ end if;
+
+ Append_To (New_Plist,
Make_Parameter_Specification (Loc,
- Defining_Identifier =>
- Make_Defining_Identifier (Sloc (Formal), Chars (Formal)),
+ Defining_Identifier => New_Formal,
Aliased_Present => Aliased_Present (Parent (Formal)),
In_Present => In_Present (Parent (Formal)),
Out_Present => Out_Present (Parent (Formal)),
- Parameter_Type => New_Occurrence_Of (Etype (Formal), Loc));
-
- if Unprotected then
- Set_Protected_Formal (Formal, Defining_Identifier (New_Param));
- Mutate_Ekind (Defining_Identifier (New_Param), Ekind (Formal));
- end if;
+ Parameter_Type => New_Occurrence_Of (Etype (Formal), Loc)));
- Append (New_Param, New_Plist);
Next_Formal (Formal);
end loop;
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -5511,12 +5511,22 @@ package body Sem_Ch6 is
-- Check references of the subprogram spec when we are dealing with
-- an expression function due to it having a generated body.
- -- Otherwise, we simply check the formals of the subprogram body.
if Present (Spec_Id)
and then Is_Expression_Function (Spec_Id)
then
Check_References (Spec_Id);
+
+ -- Skip the check for subprograms generated for protected subprograms
+ -- because it is also done for the protected subprograms themselves.
+
+ elsif Present (Spec_Id)
+ and then Present (Protected_Subprogram (Spec_Id))
+ then
+ null;
+
+ -- Otherwise, we simply check the formals of the subprogram body.
+
else
Check_References (Body_Id);
end if;
reply other threads:[~2022-09-12 8:19 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=20220912081920.GA1512860@poulhies-Precision-5550 \
--to=poulhies@adacore.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@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).