aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_cat.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/sem_cat.adb')
-rw-r--r--gcc/ada/sem_cat.adb12
1 files changed, 9 insertions, 3 deletions
diff --git a/gcc/ada/sem_cat.adb b/gcc/ada/sem_cat.adb
index 663dca4..780fec9 100644
--- a/gcc/ada/sem_cat.adb
+++ b/gcc/ada/sem_cat.adb
@@ -721,9 +721,15 @@ package body Sem_Cat is
-- The purpose is to set categorization flags before analyzing the
-- unit itself, so as to diagnose violations of categorization as
-- we process each declaration, even though the pragma appears after
- -- the unit.
-
- if Nkind (P) /= N_Compilation_Unit then
+ -- the unit. This processing is only needsd if compilation unit
+ -- pragmas are present.
+ -- Note: this code may be incorrect in the unlikely case a child
+ -- genericc unit is instantiated as a child of its (non-generic)
+ -- parent, so that generic and insstance are siblings,
+
+ if Nkind (P) /= N_Compilation_Unit
+ or else No (First (Pragmas_After (Aux_Decls_Node (P))))
+ then
return;
end if;