From 165b05717cfe9ed17a87b5430e5f9dd19aa8eb1a Mon Sep 17 00:00:00 2001 From: Steve Baird Date: Mon, 30 Jan 2023 17:05:13 -0800 Subject: [PATCH] ada: Reject illegal declarations in expression functions 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. --- 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 153a63586ca5..7e8da9f2d5ae 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.47.2