[Ada] Legality checks on uses of incomplete types.
Arnaud Charlet
charlet@adacore.com
Wed Aug 6 10:47:00 GMT 2008
This patch prevents compiler aborts in the presence of illegal uses of
incomplete types in various declarations, and rejects such uses in some
object renaming declaration.
Examples in ACATS test B3A1A02.
Tested on i686-pc-linux-gnu, committed on trunk
2008-08-06 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Analyze_Component_Declaration): Protect against misuse
of incomplete type.
* sem_ch8.adb (Analyze_Object_Renaming): Diagnose properly a renaming
of a formal parameter of an incomplete type. Improve error message for
other improper uses of incomplete types.
-------------- next part --------------
Index: sem_ch3.adb
===================================================================
--- sem_ch3.adb (revision 138784)
+++ sem_ch3.adb (working copy)
@@ -1667,6 +1667,7 @@
if Ada_Version >= Ada_05
and then Ekind (T) = E_Anonymous_Access_Type
+ and then Etype (E) /= Any_Type
then
-- Check RM 3.9.2(9): "if the expected type for an expression is
-- an anonymous access-to-specific tagged type, then the object
Index: sem_ch8.adb
===================================================================
--- sem_ch8.adb (revision 138765)
+++ sem_ch8.adb (working copy)
@@ -832,8 +832,11 @@
if Nkind (Nam) = N_Explicit_Dereference
and then Ekind (Etype (T2)) = E_Incomplete_Type
then
- Error_Msg_N ("invalid use of incomplete type", Id);
+ Error_Msg_NE ("invalid use of incomplete type&", Id, T2);
return;
+ elsif Ekind (Etype (T)) = E_Incomplete_Type then
+ Error_Msg_NE ("invalid use of incomplete type&", Id, T);
+ return;
end if;
-- Ada 2005 (AI-327)
More information about the Gcc-patches
mailing list