aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSteve Baird <baird@adacore.com>2023-01-30 17:05:13 -0800
committerMarc Poulhiès <poulhies@adacore.com>2023-05-22 10:44:08 +0200
commit165b05717cfe9ed17a87b5430e5f9dd19aa8eb1a (patch)
tree6b9e4f73756daaa0f544d5693863ed3b6730b062 /gcc
parente1f5cf0b14c460f04e878e8c52c90132f19c5e3f (diff)
downloadgcc-165b05717cfe9ed17a87b5430e5f9dd19aa8eb1a.zip
gcc-165b05717cfe9ed17a87b5430e5f9dd19aa8eb1a.tar.gz
gcc-165b05717cfe9ed17a87b5430e5f9dd19aa8eb1a.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_ch4.adb10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 153a635..7e8da9f 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;