public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-7873] ada: Fix internal error with pragma Compile_Time_{Warning, Error}
@ 2023-09-27  8:25 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2023-09-27  8:25 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5ac700a00ffe73f4b7eb11f691c63a56a17c49c4

commit r13-7873-g5ac700a00ffe73f4b7eb11f691c63a56a17c49c4
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Tue Apr 4 19:25:11 2023 +0200

    ada: Fix internal error with pragma Compile_Time_{Warning,Error}
    
    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.

Diff:
---
 gcc/ada/sem_prag.adb | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 266a433d6c4..87c30c81faa 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -7826,7 +7826,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));
@@ -7844,7 +7846,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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-27  8:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27  8:25 [gcc r13-7873] ada: Fix internal error with pragma Compile_Time_{Warning, Error} Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).