Aggregates used as actuals of formal object parameters are handled specially 
by Instantiate_Object in Sem_Ch12 and qualifying them is sufficient to block 
this special processing.

Tested on x86-64/Linux, applied on the mainline.


2025-10-29  Eric Botcazou  <[email protected]>

        PR ada/54178
        * sem_ch12.adb (Instantiate_Object): Strip qualification to detect
        aggregates used as actuals.


2025-10-29  Eric Botcazou  <[email protected]>

        * gnat.dg/aggr32.adb: New test.
        * gnat.dg/aggr32_pkg.ads: New helper.
        * gnat.dg/aggr32_pkg-child.ads: Likewise.

-- 
Eric Botcazou
-- { dg-do compile }

with Aggr32_Pkg.Child;

procedure Aggr32 (W, H : Positive) is

  use Aggr32_Pkg;

  package Test_1 is new Child (Frame => (Width => W, Height => H));

  package Test_2 is new Child (Frame => Rec'(Width => W, Height => H));

begin
  null;
end;
package Aggr32_Pkg is

  type Rec is record
    Width  : Positive;
    Height : Positive;
  end record;

end Aggr32_Pkg;
generic

  Frame : Rec;

package Aggr32_Pkg.Child is
end Aggr32_Pkg.Child;
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index cbb0debbf1f..deb19ee118e 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -13223,7 +13223,7 @@ package body Sem_Ch12 is
                --  to capture local names that may be hidden if the generic is
                --  a child unit.
 
-               if Nkind (Actual) = N_Aggregate then
+               if Nkind (Unqualify (Actual)) = N_Aggregate then
                   Preanalyze_And_Resolve (Actual, Typ);
                end if;
 

Reply via email to