]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Ada: Fix spurious visibility issue with qualified aggregate in instantiation
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 29 Oct 2025 23:33:36 +0000 (00:33 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Thu, 30 Oct 2025 00:38:29 +0000 (01:38 +0100)
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.

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

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

gcc/ada/sem_ch12.adb
gcc/testsuite/gnat.dg/aggr32.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/aggr32_pkg-child.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/aggr32_pkg.ads [new file with mode: 0644]

index cbb0debbf1fb1fbafec37789955f596bfff680c8..deb19ee118e156cf4a1aa53be485dbfa25a25b5a 100644 (file)
@@ -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;
 
diff --git a/gcc/testsuite/gnat.dg/aggr32.adb b/gcc/testsuite/gnat.dg/aggr32.adb
new file mode 100644 (file)
index 0000000..e5b0887
--- /dev/null
@@ -0,0 +1,15 @@
+-- { 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;
diff --git a/gcc/testsuite/gnat.dg/aggr32_pkg-child.ads b/gcc/testsuite/gnat.dg/aggr32_pkg-child.ads
new file mode 100644 (file)
index 0000000..352e2b5
--- /dev/null
@@ -0,0 +1,6 @@
+generic
+
+  Frame : Rec;
+
+package Aggr32_Pkg.Child is
+end Aggr32_Pkg.Child;
diff --git a/gcc/testsuite/gnat.dg/aggr32_pkg.ads b/gcc/testsuite/gnat.dg/aggr32_pkg.ads
new file mode 100644 (file)
index 0000000..e0e8bef
--- /dev/null
@@ -0,0 +1,8 @@
+package Aggr32_Pkg is
+
+  type Rec is record
+    Width  : Positive;
+    Height : Positive;
+  end record;
+
+end Aggr32_Pkg;