From cf28c974d4868d94b6a5cee2c36c5dc617a7444d Mon Sep 17 00:00:00 2001 From: Robert Dewar Date: Fri, 18 Jul 2014 09:34:17 +0000 Subject: [PATCH] sem_attr.adb, [...]: Minor reformatting. 2014-07-18 Robert Dewar * sem_attr.adb, s-os_lib.ads, prj-tree.adb: Minor reformatting. * types.h: Fix typo. 2014-07-18 Robert Dewar * freeze.adb (Check_Address_Clause): Use Kill_Rep_Clause (no functional change). * gnat_ugn.texi: Document that -gnatI removes rep clauses from ASIS trees. * sem_ch13.adb (Kill_Rep_Clause): New procedure (Analyze_Attribute_Definition_Clause): Use Kill_Rep_Clause. This is just a cleanup, no functional effect. (Analyze_Enumeration_Representation_Clause): Use Kill_Rep_Clause. This means that enum rep clauses are now properly removed from -gnatct trees. (Analyze_Record_Representation_Clause): Same change. * sem_ch13.ads (Kill_Rep_Clause): New procedure. From-SVN: r212789 --- gcc/ada/ChangeLog | 20 ++++++++++++++++++++ gcc/ada/freeze.adb | 4 +++- gcc/ada/gnat_ugn.texi | 6 ++++++ gcc/ada/prj-tree.adb | 9 ++++----- gcc/ada/s-os_lib.ads | 6 +++--- gcc/ada/sem_attr.adb | 2 ++ gcc/ada/sem_ch13.adb | 32 ++++++++++++++++++++++---------- gcc/ada/sem_ch13.ads | 5 +++++ gcc/ada/types.h | 4 ++-- 9 files changed, 67 insertions(+), 21 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 897853b0bf1..90853093d78 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,23 @@ +2014-07-18 Robert Dewar + + * sem_attr.adb, s-os_lib.ads, prj-tree.adb: Minor reformatting. + * types.h: Fix typo. + +2014-07-18 Robert Dewar + + * freeze.adb (Check_Address_Clause): Use Kill_Rep_Clause (no + functional change). + * gnat_ugn.texi: Document that -gnatI removes rep clauses from + ASIS trees. + * sem_ch13.adb (Kill_Rep_Clause): New procedure + (Analyze_Attribute_Definition_Clause): Use + Kill_Rep_Clause. This is just a cleanup, no functional effect. + (Analyze_Enumeration_Representation_Clause): + Use Kill_Rep_Clause. This means that enum rep + clauses are now properly removed from -gnatct trees. + (Analyze_Record_Representation_Clause): Same change. + * sem_ch13.ads (Kill_Rep_Clause): New procedure. + 2014-07-18 Pascal Obry * s-os_lib.ads, s-os_lib.adb (GM_Time_Of): New routine to create an diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 26e2e0d3a4e..84914106097 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -604,7 +604,9 @@ package body Freeze is end if; end; - Rewrite (Addr, Make_Null_Statement (Sloc (E))); + -- And now remove the address clause + + Kill_Rep_Clause (Addr); elsif not Error_Posted (Expr) and then not Needs_Finalization (Typ) diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 83b06792c87..c8b8ca69906 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -4091,6 +4091,12 @@ Object_Size, Size, Small, Stream_Size, and Value_Size. Note that this option should be used only for compiling -- the code is likely to malfunction at run time. +Note that when @code{-gnatct} is used to generate trees for input +into @code{ASIS} tools, these representation clauses are removed +from the tree. This means that the tool will not see them. For +example, if you use @command{gnatpp} with @code{-gnatI}, the pretty printed +output will not include the ignored representation clauses. + @item -gnatjnn @cindex @option{-gnatjnn} (@command{gcc}) Reformat error messages to fit on nn character lines diff --git a/gcc/ada/prj-tree.adb b/gcc/ada/prj-tree.adb index e4a23602e20..2ff5a9fff18 100644 --- a/gcc/ada/prj-tree.adb +++ b/gcc/ada/prj-tree.adb @@ -1121,20 +1121,19 @@ package body Prj.Tree is In_Tree : Project_Node_Tree_Ref; With_Name : Name_Id) return Project_Node_Id is - With_Clause : Project_Node_Id := - First_With_Clause_Of (Project, In_Tree); + With_Clause : Project_Node_Id; Result : Project_Node_Id := Empty_Node; begin -- First check all the imported projects + With_Clause := First_With_Clause_Of (Project, In_Tree); while Present (With_Clause) loop - -- Only non limited imported project may be used as prefix - -- of variable or attributes. + -- Only non limited imported project may be used as prefix of + -- variables or attributes. Result := Non_Limited_Project_Node_Of (With_Clause, In_Tree); - while Present (Result) loop if Name_Of (Result, In_Tree) = With_Name then return Result; diff --git a/gcc/ada/s-os_lib.ads b/gcc/ada/s-os_lib.ads index 810d7d4414a..50574a932e4 100644 --- a/gcc/ada/s-os_lib.ads +++ b/gcc/ada/s-os_lib.ads @@ -159,9 +159,9 @@ package System.OS_Lib is Hour : Hour_Type; Minute : Minute_Type; Second : Second_Type) return OS_Time; - -- Analogous to the Time_Of routine in Ada.Calendar, takes a set of - -- time component parts and returns an OS_Time. Returns Invalid_Time - -- if the creation fails. + -- Analogous to the Time_Of routine in Ada.Calendar, takes a set of time + -- component parts and returns an OS_Time. Returns Invalid_Time if the + -- creation fails. ---------------- -- File Stuff -- diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index e65fecd339e..d76f8ce3417 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -6336,11 +6336,13 @@ package body Sem_Attr is Hi := High_Bound (Index); Analyze_And_Resolve (Lo, Etype (Index_Type)); + if not Is_OK_Static_Expression (Lo) then Set_Do_Range_Check (Lo); end if; Analyze_And_Resolve (Hi, Etype (Index_Type)); + if not Is_OK_Static_Expression (Hi) then Set_Do_Range_Check (Hi); end if; diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index a9cdc2cb533..aab0ea10df4 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -3647,19 +3647,12 @@ package body Sem_Ch13 is Attribute_Machine_Radix | Attribute_Object_Size | Attribute_Size | + Attribute_Small | Attribute_Stream_Size | Attribute_Value_Size => - Rewrite (N, Make_Null_Statement (Sloc (N))); + Kill_Rep_Clause (N); return; - -- Perhaps 'Small should not be ignored by Ignore_Rep_Clauses ??? - - when Attribute_Small => - if Ignore_Rep_Clauses then - Rewrite (N, Make_Null_Statement (Sloc (N))); - return; - end if; - -- The following should not be ignored, because in the first place -- they are reasonably portable, and should not cause problems in -- compiling code from another target, and also they do affect @@ -3676,6 +3669,13 @@ package body Sem_Ch13 is Attribute_Write => null; + -- We do not do anything here with address clauses, they will be + -- removed by Freeze later on, but for now, it works better to + -- keep then in the tree. + + when Attribute_Address => + null; + -- Other cases are errors ("attribute& cannot be set with -- definition clause"), which will be caught below. @@ -3830,7 +3830,7 @@ package body Sem_Ch13 is -- Even when ignoring rep clauses we need to indicate that the -- entity has an address clause and thus it is legal to declare - -- it imported. + -- it imported. Freeze will get rid of the address clause later. if Ignore_Rep_Clauses then if Ekind_In (U_Ent, E_Variable, E_Constant) then @@ -5365,6 +5365,7 @@ package body Sem_Ch13 is begin if Ignore_Rep_Clauses then + Kill_Rep_Clause (N); return; end if; @@ -5740,6 +5741,7 @@ package body Sem_Ch13 is begin if Ignore_Rep_Clauses then + Kill_Rep_Clause (N); return; end if; @@ -10286,6 +10288,16 @@ package body Sem_Ch13 is end if; end Is_Operational_Item; + --------------------- + -- Kill_Rep_Clause -- + --------------------- + + procedure Kill_Rep_Clause (N : Node_Id) is + begin + pragma Assert (Ignore_Rep_Clauses); + Rewrite (N, Make_Null_Statement (Sloc (N))); + end Kill_Rep_Clause; + ------------------ -- Minimum_Size -- ------------------ diff --git a/gcc/ada/sem_ch13.ads b/gcc/ada/sem_ch13.ads index 0f31265b621..9bef91cc384 100644 --- a/gcc/ada/sem_ch13.ads +++ b/gcc/ada/sem_ch13.ads @@ -79,6 +79,11 @@ package Sem_Ch13 is procedure Initialize; -- Initialize internal tables for new compilation + procedure Kill_Rep_Clause (N : Node_Id); + -- This procedure is called for a rep clause N when we are in -gnatI mode + -- (Ignore_Rep_Clauses). It rewrites the node N to a null statement. This + -- is only called if Ignore_Rep_Clauses is True. + procedure Set_Enum_Esize (T : Entity_Id); -- This routine sets the Esize field for an enumeration type T, based -- on the current representation information available for T. Note that diff --git a/gcc/ada/types.h b/gcc/ada/types.h index 1330730b71b..dc3f82fec31 100644 --- a/gcc/ada/types.h +++ b/gcc/ada/types.h @@ -6,7 +6,7 @@ * * * C Header File * * * - * Copyright (C) 1992-2013, Free Software Foundation, Inc. * + * Copyright (C) 1992-2014, 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- * @@ -375,7 +375,7 @@ typedef Int Mechanism_Type; #define PE_Address_Of_Intrinsic 16 #define PE_Aliased_Parameters 17 #define PE_All_Guards_Closed 18 -#define PE_Bad_Attribute_For_Predicate 19 +#define PE_Bad_Predicated_Generic_Type 19 #define PE_Current_Task_In_Entry_Body 20 #define PE_Duplicated_Entry_Address 21 #define PE_Explicit_Raise 22