summaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch12.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2004-01-12 12:38:15 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2004-01-12 12:38:15 +0100
commit16bf3959da2377ebbb88ff56ecdc618e70acae6d (patch)
tree8ec15e79687c4c1969fc0de0b76b3d5b6a479077 /gcc/ada/sem_ch12.adb
parent5fb1788b9b93b88de3491894fb0a93450d1cd6db (diff)
downloadgcc-16bf3959da2377ebbb88ff56ecdc618e70acae6d.tar.gz
[multiple changes]
2004-01-12 Javier Miranda <miranda@gnat.com> * sem_ch12.adb: Addition of Component_Definition node. 2004-01-12 Ed Schonberg <schonberg@gnat.com> PR ada/13417 * sem_ch12.adb (Analyze_Formal_Package): Diagnose properly an attempt to use a generic package G as a formal package for another generic declared within G. From-SVN: r75713
Diffstat (limited to 'gcc/ada/sem_ch12.adb')
-rw-r--r--gcc/ada/sem_ch12.adb28
1 files changed, 25 insertions, 3 deletions
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index 6820fe054fa..6a8c9873fde 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2003, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -1214,12 +1214,13 @@ package body Sem_Ch12 is
Error_Msg_N ("premature usage of incomplete type", Def);
elsif Is_Internal (Component_Type (T))
- and then Nkind (Original_Node (Subtype_Indication (Def)))
+ and then Nkind (Original_Node
+ (Subtype_Indication (Component_Definition (Def))))
/= N_Attribute_Reference
then
Error_Msg_N
("only a subtype mark is allowed in a formal",
- Subtype_Indication (Def));
+ Subtype_Indication (Component_Definition (Def)));
end if;
end Analyze_Formal_Array_Type;
@@ -1604,6 +1605,27 @@ package body Sem_Ch12 is
Gen_Id);
Restore_Env;
return;
+
+ elsif In_Open_Scopes (Gen_Unit) then
+ if Is_Compilation_Unit (Gen_Unit)
+ and then Is_Child_Unit (Current_Scope)
+ then
+ -- Special-case the error when the formal is a parent, and
+ -- continue analysis to minimize cascaded errors.
+
+ Error_Msg_N
+ ("generic parent cannot be used as formal package "
+ & "of a child unit",
+ Gen_Id);
+
+ else
+ Error_Msg_N
+ ("generic package cannot be used as a formal package "
+ & "within itself",
+ Gen_Id);
+ Restore_Env;
+ return;
+ end if;
end if;
-- Check for a formal package that is a package renaming.