summaryrefslogtreecommitdiff
path: root/gcc/ada/exp_aggr.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2012-02-08 10:04:46 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2012-02-08 10:04:46 +0000
commitb15003c30f919aedce170d8e0166745eec4d83aa (patch)
treef945e59cb67b3ec51266c32d20145f259333bf06 /gcc/ada/exp_aggr.adb
parent2e5f66c6c3997b728c30c7de11c894cd7a381b10 (diff)
downloadgcc-b15003c30f919aedce170d8e0166745eec4d83aa.tar.gz
2012-02-08 Yannick Moy <moy@adacore.com>
* gnat_rm.texi: Minor reshuffling to place restriction at appropriate place. 2012-02-08 Bob Duff <duff@adacore.com> * warnsw.adb (Set_Warning_Switch): Set Warn_On_Suspicious_Modulus_Value False for '-gnatwA', to suppress these warnings. 2012-02-08 Vincent Celier <celier@adacore.com> * sinput-p.adb (Source_File_Is_Subunit): Check for BOM before starting to scan, so that UTF8 encoding is taken into account. 2012-02-08 Arnaud Charlet <charlet@adacore.com> * s-tasren.adb, s-tasren.ads (Internal_Complete_Rendezvous): New function. (Complete_Rendezvous): Now call Internal_Complete_Rendezvous. (Exceptional_Complete_Rendezvous): Mark No_Return. 2012-02-08 Eric Botcazou <ebotcazou@adacore.com> * exp_aggr.adb (Compile_Time_Known_Composite_Value): New predicate to compute whether a composite value can be evaluated at compile time. (Component_Not_OK_For_Backend): Use Compile_Time_Known_Value for all expressions of elementary type and Compile_Time_Known_Composite_Value for all other expressions. (Expand_Record_Aggregate): Convert to assignments in the case of a type with mutable components if the aggregate cannot be built statically. 2012-02-08 Gary Dismukes <dismukes@adacore.com> * aspects.ads (type Aspect_Id): Add Simple_Storage_Pool_Type. (Impl_Defined_Aspects): Add association for Aspect_Simple_Storage_Pool_Type. (Aspect_Names): Add association for Aspect_Simple_Storage_Pool_Type. * aspects.adb: (Canonical_Aspect): Add association for Simple_Storage_Pool_Type. * exp_attr.adb (Expand_N_Attribute_Reference): Change name to Name_Simple_Storage_Pool_Type. * exp_ch4.adb (Expand_N_Allocator): Change name to Name_Simple_Storage_Pool_Type. * exp_intr.adb (Expand_Unc_Deallocation): Change name to Name_Simple_Storage_Pool_Type. * freeze.adb (Freeze_Entity): Change names to Name_Simple_Storage_Pool_Type. * par-prag.adb: Change names to Name_Simple_Storage_Pool_Type. * sem_attr.adb: (Analyze_Attribute): Change name to Name_Simple_Storage_Pool_Type. * sem_ch13.adb (Analyze_Attribute_Definition_Clause): Change name to Name_Simple_Storage_Pool_Type. * sem_prag.adb: (Analyze_Pragma): Change name to Name_Simple_Storage_Pool_Type. (Sig_Flags): Change name to Name_Simple_Storage_Pool_Type. * sem_res.adb (Resolve_Allocator): Change name to Name_Simple_Storage_Pool_Type. * snames.ads-tmpl: (Name_Simple_Storage_Pool_Type): New name constant. (type Pragma_Id): Change name to Name_Simple_Storage_Pool_Type and move to main pragma section because it no longer matches the attribute name. * snames.adb-tmpl (Get_Pragma_Id): Remove test for Name_Simple_Storage_Pool. (Is_Pragma_Name): Remove test for Name_Simple_Storage_Pool. 2012-02-08 Robert Dewar <dewar@adacore.com> * gnat_ugn.texi: Add some clarification to -gnatwA and -gnatws. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184003 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/exp_aggr.adb')
-rw-r--r--gcc/ada/exp_aggr.adb60
1 files changed, 54 insertions, 6 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index 94f2c3dd68d..10cb04c1628 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -5115,6 +5115,14 @@ package body Exp_Aggr is
-- and the aggregate can be constructed statically and handled by
-- the back-end.
+ function Compile_Time_Known_Composite_Value (N : Node_Id) return Boolean;
+ -- Returns true if N is an expression of composite type which can be
+ -- fully evaluated at compile time without raising constraint error.
+ -- Such expressions can be passed as is to Gigi without any expansion.
+ --
+ -- This returns true for N_Aggregate with Compile_Time_Known_Aggregate
+ -- set and constants whose expression is such an aggregate, recursively.
+
function Component_Not_OK_For_Backend return Boolean;
-- Check for presence of component which makes it impossible for the
-- backend to process the aggregate, thus requiring the use of a series
@@ -5145,6 +5153,46 @@ package body Exp_Aggr is
-- For nested aggregates return the ultimate enclosing aggregate; for
-- non-nested aggregates return N.
+ ----------------------------------------
+ -- Compile_Time_Known_Composite_Value --
+ ----------------------------------------
+
+ function Compile_Time_Known_Composite_Value (N : Node_Id) return Boolean
+ is
+
+ begin
+ -- If we have an entity name, then see if it is the name of a
+ -- constant and if so, test the corresponding constant value.
+
+ if Is_Entity_Name (N) then
+ declare
+ E : constant Entity_Id := Entity (N);
+ V : Node_Id;
+
+ begin
+ if Ekind (E) /= E_Constant then
+ return False;
+ end if;
+
+ V := Constant_Value (E);
+ return Present (V)
+ and then Compile_Time_Known_Composite_Value (V);
+ end;
+
+ -- We have a value, see if it is compile time known
+
+ else
+ if Nkind (N) = N_Aggregate then
+ return Compile_Time_Known_Aggregate (N);
+ end if;
+
+ -- All other types of values are not known at compile time
+
+ return False;
+ end if;
+
+ end Compile_Time_Known_Composite_Value;
+
----------------------------------
-- Component_Not_OK_For_Backend --
----------------------------------
@@ -5201,14 +5249,12 @@ package body Exp_Aggr is
return True;
end if;
- if Is_Scalar_Type (Etype (Expr_Q)) then
+ if Is_Elementary_Type (Etype (Expr_Q)) then
if not Compile_Time_Known_Value (Expr_Q) then
Static_Components := False;
end if;
- elsif Nkind (Expr_Q) /= N_Aggregate
- or else not Compile_Time_Known_Aggregate (Expr_Q)
- then
+ elsif not Compile_Time_Known_Composite_Value (Expr_Q) then
Static_Components := False;
if Is_Private_Type (Etype (Expr_Q))
@@ -5374,12 +5420,14 @@ package body Exp_Aggr is
-- may be distinct from the default size of the type component, so
-- we need to expand to insure that the back-end copies the proper
-- size of the data. However, if the aggregate is the initial value of
- -- a constant, the target is immutable and may be built statically.
+ -- a constant, the target is immutable and might be built statically
+ -- if components are appropriate.
elsif Has_Mutable_Components (Typ)
and then
(Nkind (Parent (Top_Level_Aggr)) /= N_Object_Declaration
- or else not Constant_Present (Parent (Top_Level_Aggr)))
+ or else not Constant_Present (Parent (Top_Level_Aggr))
+ or else not Static_Components)
then
Convert_To_Assignments (N, Typ);