diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-12-09 17:19:49 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-12-09 17:19:49 +0000 |
commit | d5bf49516dfde4e4708fc182e71564ea6875b18e (patch) | |
tree | 55fe007ea4d3250009db6cfbba847208f8c1e982 /gcc/ada/par-ch12.adb | |
parent | 041a8137335bd09376b5cd405c99d1781b7884f1 (diff) | |
download | gcc-d5bf49516dfde4e4708fc182e71564ea6875b18e.tar.gz |
2005-12-05 Robert Dewar <dewar@adacore.com>
Ed Schonberg <schonberg@adacore.com>
Gary Dismukes <dismukes@adacore.com>
Javier Miranda <miranda@adacore.com>
Hristian Kirtchev <kirtchev@adacore.com>
* einfo.adb (Itype_Printed): New flag
(Is_Limited_Type): Derived types do not inherit limitedness from
interface progenitors.
(Is_Return_By_Reference_Type): Predicate does not apply to limited
interfaces.
* einfo.ads (Itype_Printed): New flag
Move Is_Wrapper_Package to proper section
Add missing Inline for Is_Volatile
* output.ads, output.adb (Write_Erase_Char): New procedure
(Save/Restore_Output_Buffer): New procedures
(Save/Restore_Output_Buffer): New procedures
* sprint.ads, sprint.adb (Write_Itype): Handle case of record itypes
Add missing support for anonymous access type
(Write_Id): Insert calls to Write_Itype
(Write_Itype): New procedure to output itypes
* par-ch12.adb (P_Formal_Derived_Type_Definition): In Ada 2005, handle
use of "limited" in declaration.
* sinfo.ads, sinfo.adb:
Formal derived types can carry an explicit "limited" indication.
* sem_ch3.adb: Add with and use of Targparm.
(Create_Component): If Frontend_Layout_On_Target is True and the
copied component does not have a known static Esize, then reset
the size and positional fields of the new component.
(Analyze_Component_Declaration): A limited component is
legal within a protected type that implements an interface.
(Collect_Interfaces): Do not add to the list the interfaces that
are implemented by the ancestors.
(Derived_Type_Declaration): If the parent of the full-view is an
interface perform a transformation of the tree to ensure that it has
the same parent than the partial-view. This simplifies the job of the
expander in order to generate the correct object layout, and it is
needed because the list of interfaces of the full-view can be given in
any order.
(Process_Full_View): The parent of the full-view does not need to be
a descendant of the parent of the partial view if both parents are
interfaces.
(Analyze_Private_Extension_Declaration): If declaration has an explicit
"limited" the parent must be a limited type.
(Build_Derived_Record_Type): A derived type that is explicitly limited
must have limited ancestor and progenitors.
(Build_Derived_Type): Ditto.
(Process_Full_View): Verify that explicit uses of "limited" in partial
and full declarations are consistent.
(Find_Ancestor_Interface): Remove function.
(Collect_Implemented_Interfaces): New procedure used to gather all
implemented interfaces by a type.
(Contain_Interface): New function used to check whether an interface is
present in a list.
(Find_Hidden_Interface): New function used to determine whether two
lists of interfaces constitute a set equality. If not, the first
differing interface is returned.
(Process_Full_View): Improve the check for the "no hidden interface"
rule as defined by AI-396.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108295 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/par-ch12.adb')
-rw-r--r-- | gcc/ada/par-ch12.adb | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/gcc/ada/par-ch12.adb b/gcc/ada/par-ch12.adb index 49e18de7e52..cff5ac44fa1 100644 --- a/gcc/ada/par-ch12.adb +++ b/gcc/ada/par-ch12.adb @@ -519,6 +519,9 @@ package body Ch12 is -- exception is ABSTRACT, where we have to scan ahead to see if we -- have a formal derived type or a formal private type definition. + -- In addition, in Ada 2005 LIMITED may appear after abstract, so + -- that the lookahead must be extended by one more token. + when Tok_Abstract => Save_Scan_State (Scan_State); Scan; -- past ABSTRACT @@ -527,6 +530,18 @@ package body Ch12 is Restore_Scan_State (Scan_State); -- to ABSTRACT return P_Formal_Derived_Type_Definition; + elsif Token = Tok_Limited then + Scan; -- past LIMITED + + if Token = Tok_New then + Restore_Scan_State (Scan_State); -- to ABSTRACT + return P_Formal_Derived_Type_Definition; + + else + Restore_Scan_State (Scan_State); -- to ABSTRACT + return P_Formal_Private_Type_Definition; + end if; + else Restore_Scan_State (Scan_State); -- to ABSTRACT return P_Formal_Private_Type_Definition; @@ -560,7 +575,25 @@ package body Ch12 is Set_Limited_Present (Typedef_Node); return Typedef_Node; + elsif Token = Tok_New then + Restore_Scan_State (Scan_State); -- to LIMITED + return P_Formal_Derived_Type_Definition; + else + if Token = Tok_Abstract then + Error_Msg_SC ("ABSTRACT must come before LIMITED"); + Scan; -- past improper ABSTRACT + + if Token = Tok_New then + Restore_Scan_State (Scan_State); -- to LIMITED + return P_Formal_Derived_Type_Definition; + + else + Restore_Scan_State (Scan_State); + return P_Formal_Private_Type_Definition; + end if; + end if; + Restore_Scan_State (Scan_State); return P_Formal_Private_Type_Definition; end if; @@ -666,6 +699,20 @@ package body Ch12 is Scan; -- past LIMITED end if; + if Token = Tok_Abstract then + if Prev_Token = Tok_Tagged then + Error_Msg_SC ("ABSTRACT must come before TAGGED"); + elsif Prev_Token = Tok_Limited then + Error_Msg_SC ("ABSTRACT must come before LIMITED"); + end if; + + Resync_Past_Semicolon; + + elsif Token = Tok_Tagged then + Error_Msg_SC ("TAGGED must come before LIMITED"); + Resync_Past_Semicolon; + end if; + Set_Sloc (Def_Node, Token_Ptr); T_Private; return Def_Node; @@ -676,9 +723,11 @@ package body Ch12 is -------------------------------------------- -- FORMAL_DERIVED_TYPE_DEFINITION ::= - -- [abstract] new SUBTYPE_MARK [[AND interface_list] with private] + -- [abstract] [limited] + -- new SUBTYPE_MARK [[AND interface_list] with private] - -- The caller has checked the initial token(s) is/are NEW or ASTRACT NEW + -- The caller has checked the initial token(s) is/are NEW, ASTRACT NEW + -- LIMITED NEW, or ABSTRACT LIMITED NEW -- Error recovery: cannot raise Error_Resync @@ -693,6 +742,22 @@ package body Ch12 is Scan; -- past ABSTRACT end if; + if Token = Tok_Limited then + Set_Limited_Present (Def_Node); + Scan; -- past Limited + + if Ada_Version < Ada_05 then + Error_Msg_SP + ("LIMITED in derived type is an Ada 2005 extension"); + Error_Msg_SP + ("\unit must be compiled with -gnat05 switch"); + end if; + + if Token = Tok_Abstract then + Scan; -- past ABSTRACT. diagnosed already in caller. + end if; + end if; + Scan; -- past NEW; Set_Subtype_Mark (Def_Node, P_Subtype_Mark); No_Constraint; |