* [COMMITTED] ada: Reject illegal declarations in expression functions
@ 2023-05-22 8:49 Marc Poulhiès
0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-05-22 8:49 UTC (permalink / raw)
To: gcc-patches; +Cc: Steve Baird
From: Steve Baird <baird@adacore.com>
gcc/ada/
* sem_ch4.adb (Analyze_Expression_With_Actions.Check_Action_Ok):
If Comes_From_Source (A) is False, then look at Original_Node (A)
instead of A. In particular, if an (illegal) expression function
is transformed into a "vanilla" function, we don't want to allow
it just because Comes_From_Source is now False.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_ch4.adb | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 153a63586ca..7e8da9f2d5a 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -2368,6 +2368,16 @@ package body Sem_Ch4 is
procedure Check_Action_OK (A : Node_Id) is
begin
if not Comes_From_Source (N) or else not Comes_From_Source (A) then
+
+ -- If, for example, an (illegal) expression function is
+ -- transformed into a"vanilla" function then we don't want to
+ -- allow it just because Comes_From_Source is now False. So look
+ -- at the Original_Node.
+
+ if A /= Original_Node (A) then
+ Check_Action_OK (Original_Node (A));
+ end if;
+
return; -- Allow anything in generated code
end if;
--
2.40.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-22 8:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-22 8:49 [COMMITTED] ada: Reject illegal declarations in expression functions 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).