]> gcc.gnu.org Git - gcc.git/commitdiff
[Ada] Fix crash on pragma Compile_Time_Warning/Error
authorBob Duff <duff@adacore.com>
Wed, 17 Nov 2021 17:06:32 +0000 (12:06 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 1 Dec 2021 10:24:42 +0000 (10:24 +0000)
gcc/ada/

* sem_prag.adb (Process_Compile_Time_Warning_Or_Error): Do not
follow the Corresponding_Spec pointer if Acts_As_Spec is True,
because Corresponding_Spec is Empty in that case, so we would
exit the loop prematurely, and incorrectly think we are not
inside a generic unit when we are.

gcc/ada/sem_prag.adb

index 1d5cc2535bdf9e57e45d9e69e59734f26fb11cf5..9fdec53b3741abd8e499485d068c3a5fb811e756 100644 (file)
@@ -7827,11 +7827,15 @@ package body Sem_Prag is
 
          if Compile_Time_Known_Value (Arg1x) then
             Validate_Compile_Time_Warning_Or_Error (N, Sloc (Arg1));
+
          else
             while Present (P) and then Nkind (P) not in N_Generic_Declaration
             loop
-               if Nkind (P) in N_Package_Body | N_Subprogram_Body then
-                  P := Corresponding_Spec (P);
+               if (Nkind (P) = N_Subprogram_Body and then not Acts_As_Spec (P))
+                 or else Nkind (P) = N_Package_Body
+               then
+                  P := Parent (Corresponding_Spec (P));
+
                else
                   P := Parent (P);
                end if;
This page took 0.092027 seconds and 5 git commands to generate.