diff options
author | Ed Schonberg <schonberg@adacore.com> | 2012-06-12 10:34:33 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2012-06-12 12:34:33 +0200 |
commit | 967e927f1b8c1971e4bad6b3327ca984cb18083f (patch) | |
tree | f140f24bc213ee097fe7069f1e32b700943da3eb | |
parent | 02f588343104177827aeb428ea9fca6e55910ef3 (diff) | |
download | gcc-967e927f1b8c1971e4bad6b3327ca984cb18083f.zip gcc-967e927f1b8c1971e4bad6b3327ca984cb18083f.tar.gz gcc-967e927f1b8c1971e4bad6b3327ca984cb18083f.tar.bz2 |
sem_ch3.adb (Analyze_Subtype_Declaration): if an incomplete type is tagged, so is a subtype of it.
2012-06-12 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Analyze_Subtype_Declaration): if an incomplete
type is tagged, so is a subtype of it.
* sem_ch12.adb (Validate_Actual_Subprogram): implement AI05-0296,
concerning freeze rules in the presence of formal incomplete
types: a formal abstract subprogram cannot have an incomplete
controlling type, and the profile of the actual subprogram does
not freeze if it includes an incomplete untagged type.
From-SVN: r188442
-rw-r--r-- | gcc/ada/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/ada/sem_ch12.adb | 61 | ||||
-rw-r--r-- | gcc/ada/sem_ch3.adb | 12 |
3 files changed, 79 insertions, 4 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 4f67822..6da4ac6 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2012-06-12 Ed Schonberg <schonberg@adacore.com> + + * sem_ch3.adb (Analyze_Subtype_Declaration): if an incomplete + type is tagged, so is a subtype of it. + * sem_ch12.adb (Validate_Actual_Subprogram): implement AI05-0296, + concerning freeze rules in the presence of formal incomplete + types: a formal abstract subprogram cannot have an incomplete + controlling type, and the profile of the actual subprogram does + not freeze if it includes an incomplete untagged type. + 2012-06-12 Robert Dewar <dewar@adacore.com> * a-direct.adb: Minor reformatting. diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index d38d2e2..4bb7cee 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -2664,6 +2664,14 @@ package body Sem_Ch12 is Error_Msg_N ("abstract formal subprogram must have a controlling type", N); + + elsif Ada_Version >= Ada_2012 + and then Is_Incomplete_Type (Ctrl_Type) + then + Error_Msg_NE + ("controlling type of abstract formal subprogram cannot " & + "be incomplete type", N, Ctrl_Type); + else Check_Controlling_Formals (Ctrl_Type, Nam); end if; @@ -9411,6 +9419,59 @@ package body Sem_Ch12 is end; end if; + -- In Ada 2012, enforce the (RM 13.14(10.2/3)) freezing rule concerning + -- formal incomplete types: a callable entity freezes its profile, + -- unless it has an incomplete untagged formal. + + if Ada_Version >= Ada_2012 then + declare + F : Entity_Id; + Has_Untagged_Inc : Boolean; + + begin + F := First_Formal (Analyzed_S); + Has_Untagged_Inc := False; + while Present (F) loop + if Ekind (Etype (F)) = E_Incomplete_Type + and then not Is_Tagged_Type (Etype (F)) + then + Has_Untagged_Inc := True; + exit; + end if; + + F := Next_Formal (F); + end loop; + + if Ekind (Analyzed_S) = E_Function + and then Ekind (Etype (Analyzed_S)) = E_Incomplete_Type + and then not Is_Tagged_Type (Etype (F)) + then + Has_Untagged_Inc := True; + end if; + + if Is_Entity_Name (Actual) + and then not Has_Untagged_Inc + then + F := First_Formal (Entity (Actual)); + while Present (F) loop + Freeze_Before (Instantiation_Node, Etype (F)); + + if Is_Incomplete_Or_Private_Type (Etype (F)) + and then No (Full_View (Etype (F))) + and then not Is_Generic_Type (Etype (F)) + then + Error_Msg_NE + ("type& must be frozen before this point", + Instantiation_Node, Etype (F)); + Abandon_Instantiation (Instantiation_Node); + end if; + + F := Next_Formal (F); + end loop; + end if; + end; + end if; + return Decl_Node; end Instantiate_Formal_Subprogram; diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index e6f3c4c..1fdf17e 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -4340,11 +4340,15 @@ package body Sem_Ch3 is when E_Incomplete_Type => if Ada_Version >= Ada_2005 then - Set_Ekind (Id, E_Incomplete_Subtype); - -- Ada 2005 (AI-412): Decorate an incomplete subtype - -- of an incomplete type visible through a limited - -- with clause. + -- A subtype of an incomplete type can be explicitly tagged + + Set_Ekind (Id, E_Incomplete_Subtype); + Set_Is_Tagged_Type (Id, Is_Tagged_Type (T)); + Set_Private_Dependents (Id, New_Elmt_List); + + -- Ada 2005 (AI-412): Decorate an incomplete subtype of an + -- incomplete type visible through a limited with clause. if From_With_Type (T) and then Present (Non_Limited_View (T)) |