]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Reject illegal declarations in expression functions
authorSteve Baird <baird@adacore.com>
Tue, 31 Jan 2023 01:05:13 +0000 (17:05 -0800)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 22 May 2023 08:44:08 +0000 (10:44 +0200)
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

index 153a63586ca5d9c92508199c346e6972df7ed8a6..7e8da9f2d5ae6c5de6b78d434621cb8ddb2e1c37 100644 (file)
@@ -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;