Ada: fix ICE with empty separate
Arnaud Charlet
charlet@ACT-Europe.FR
Wed Oct 27 10:09:00 GMT 2004
Tested on x86-linux
Fixes an ICE on a procedure with an empty separate:
package T is
procedure Dummy;
end T;
package body T is
package Load is
end Load;
package body Load is separate;
procedure Dummy is
begin
null;
end;
end T;
$ touch t-load.adb
$ gcc -c -gnatc -gnatQ t.adb
2004-10-26 Ed Schonberg <schonberg@gnat.com>
* sem_ch10.adb (Optional_Subunit): If file of expected subunit is
empty, post message on stub.
-------------- next part --------------
Index: sem_ch10.adb
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/sem_ch10.adb,v
retrieving revision 1.30
diff -u -p -r1.30 sem_ch10.adb
--- sem_ch10.adb 26 Jul 2004 10:42:01 -0000 1.30
+++ sem_ch10.adb 27 Oct 2004 09:33:36 -0000
@@ -980,7 +980,14 @@ package body Sem_Ch10 is
then
Comp_Unit := Cunit (Unum);
- if Nkind (Unit (Comp_Unit)) /= N_Subunit then
+ -- If the file was empty or seriously mangled, the unit
+ -- itself may be missing.
+
+ if No (Unit (Comp_Unit)) then
+ Error_Msg_N
+ ("subunit does not contain expected proper body", N);
+
+ elsif Nkind (Unit (Comp_Unit)) /= N_Subunit then
Error_Msg_N
("expected SEPARATE subunit, found child unit",
Cunit_Entity (Unum));
More information about the Gcc-patches
mailing list