From: pmderodat Date: Tue, 11 Dec 2018 11:09:29 +0000 (+0000) Subject: [Ada] Fix an ACATS regression with CCG X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52b8d5ad199b8af220c6d881e8c0ea53ce6da46e;p=thirdparty%2Fgcc.git [Ada] Fix an ACATS regression with CCG 2018-12-11 Javier Miranda 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266982 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ebcdc6ee25ff..c07f9d0156d6 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2018-12-11 Javier Miranda + + * 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 * doc/gnat_ugn/gnat_utility_programs.rst: Update gnatstub diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 45d517d1cb20..1c1890fac7ab 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 --