aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-04-04 19:25:11 +0200
committerEric Botcazou <ebotcazou@adacore.com>2023-09-27 10:16:26 +0200
commit5ac700a00ffe73f4b7eb11f691c63a56a17c49c4 (patch)
tree9dcb4b7e40a0ac6bf194de9d2e33807520d2f299 /gcc
parent5cc6e7886b7f6cf31e25257268eec3336433fd5f (diff)
downloadgcc-5ac700a00ffe73f4b7eb11f691c63a56a17c49c4.zip
gcc-5ac700a00ffe73f4b7eb11f691c63a56a17c49c4.tar.gz
gcc-5ac700a00ffe73f4b7eb11f691c63a56a17c49c4.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_prag.adb9
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 266a433..87c30c8 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;