aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Miranda <miranda@adacore.com>2018-12-11 11:09:29 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-12-11 11:09:29 +0000
commit9f51b8557977e3a48a4ac39eabc9760241b338ad (patch)
treed7fb14e1e75eb8f2fd91fbb94c19b31b366397a7
parente3f2ff72f246cd5ad5c0352ecb2772ba89740aa1 (diff)
downloadgcc-9f51b8557977e3a48a4ac39eabc9760241b338ad.zip
gcc-9f51b8557977e3a48a4ac39eabc9760241b338ad.tar.gz
gcc-9f51b8557977e3a48a4ac39eabc9760241b338ad.tar.bz2
[Ada] Fix an ACATS regression with CCG
2018-12-11 Javier Miranda <miranda@adacore.com> gcc/ada/ * exp_aggr.adb (In_Object_Declaration): Removed. (Is_CCG_Supported_Aggregate): New subprogram that replaces In_Object_Declaration extending its functionality to indicate if an aggregate is in a context supported by the CCG backend. From-SVN: r266982
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/exp_aggr.adb40
2 files changed, 36 insertions, 11 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index ebcdc6e..c07f9d0 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+2018-12-11 Javier Miranda <miranda@adacore.com>
+
+ * exp_aggr.adb (In_Object_Declaration): Removed.
+ (Is_CCG_Supported_Aggregate): New subprogram that replaces
+ In_Object_Declaration extending its functionality to indicate if
+ an aggregate is in a context supported by the CCG backend.
+
2018-12-11 Bob Duff <duff@adacore.com>
* doc/gnat_ugn/gnat_utility_programs.rst: Update gnatstub
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index 45d517d..1c1890f 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -90,8 +90,9 @@ package body Exp_Aggr is
-- N is an aggregate (record or array). Checks the presence of default
-- initialization (<>) in any component (Ada 2005: AI-287).
- function In_Object_Declaration (N : Node_Id) return Boolean;
- -- Return True if N is part of an object declaration, False otherwise
+ function Is_CCG_Supported_Aggregate (N : Node_Id) return Boolean;
+ -- Return True if aggregate N is located in a context supported by the
+ -- CCG backend; False otherwise.
function Is_Static_Dispatch_Table_Aggregate (N : Node_Id) return Boolean;
-- Returns true if N is an aggregate used to initialize the components
@@ -4741,7 +4742,7 @@ package body Exp_Aggr is
-- object declaration, this is the only case where aggregates are
-- supported in C.
- if Modify_Tree_For_C and then not In_Object_Declaration (N) then
+ if Modify_Tree_For_C and then not Is_CCG_Supported_Aggregate (N) then
return;
end if;
@@ -7553,7 +7554,7 @@ package body Exp_Aggr is
-- When generating C, only generate an aggregate when declaring objects
-- since C does not support aggregates in e.g. assignment statements.
- elsif Modify_Tree_For_C and then not In_Object_Declaration (N) then
+ elsif Modify_Tree_For_C and then not Is_CCG_Supported_Aggregate (N) then
Convert_To_Assignments (N, Typ);
-- In all other cases, build a proper aggregate to be handled by gigi
@@ -7661,23 +7662,40 @@ package body Exp_Aggr is
end if;
end Is_Delayed_Aggregate;
- ---------------------------
- -- In_Object_Declaration --
- ---------------------------
+ --------------------------------
+ -- Is_CCG_Supported_Aggregate --
+ --------------------------------
- function In_Object_Declaration (N : Node_Id) return Boolean is
- P : Node_Id := Parent (N);
+ function Is_CCG_Supported_Aggregate
+ (N : Node_Id) return Boolean
+ is
+ In_Obj_Decl : Boolean := False;
+ P : Node_Id := Parent (N);
begin
while Present (P) loop
if Nkind (P) = N_Object_Declaration then
- return True;
+ In_Obj_Decl := True;
end if;
P := Parent (P);
end loop;
+ -- Cases where aggregates are supported by the CCG backend
+
+ if In_Obj_Decl then
+ if Nkind (Parent (N)) = N_Object_Declaration then
+ return True;
+
+ elsif Nkind (Parent (N)) = N_Qualified_Expression
+ and then Nkind_In (Parent (Parent (N)), N_Allocator,
+ N_Object_Declaration)
+ then
+ return True;
+ end if;
+ end if;
+
return False;
- end In_Object_Declaration;
+ end Is_CCG_Supported_Aggregate;
----------------------------------------
-- Is_Static_Dispatch_Table_Aggregate --