]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix internal error with pragma Compile_Time_{Warning,Error}
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 4 Apr 2023 17:25:11 +0000 (19:25 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 29 May 2023 08:23:21 +0000 (10:23 +0200)
This happens when the pragmas are deferred to the back-end from an external
unit to the main unit that is generic, because the back-end does not compile
a main unit that is generic.

gcc/ada/

* sem_prag.adb (Process_Compile_Time_Warning_Or_Error): Do not defer
anything to the back-end when the main unit is generic.

gcc/ada/sem_prag.adb

index b74c60cd18330f23da5db43176dfe9a4bfde3643..0d62b04cc37f5744567b8e7f65f4c369be7e6ee5 100644 (file)
@@ -8137,7 +8137,9 @@ package body Sem_Prag is
          --  then. For example, if the expression is "Record_Type'Size /= 32"
          --  it might be known after the back end has determined the size of
          --  Record_Type. We do not defer validation if we're inside a generic
-         --  unit, because we will have more information in the instances.
+         --  unit, because we will have more information in the instances, and
+         --  this ultimately applies to the main unit itself, because it is not
+         --  compiled by the back end when it is generic.
 
          if Compile_Time_Known_Value (Arg1x) then
             Validate_Compile_Time_Warning_Or_Error (N, Sloc (Arg1));
@@ -8155,7 +8157,10 @@ package body Sem_Prag is
                end if;
             end loop;
 
-            if No (P) then
+            if No (P)
+              and then
+                Nkind (Unit (Cunit (Main_Unit))) not in N_Generic_Declaration
+            then
                Defer_Compile_Time_Warning_Error_To_BE (N);
             end if;
          end if;