Skip to content

Commit c2b3d5e

Browse files
author
Eric Botcazou
committed
Ada: Fix spurious visibility issue with qualified aggregate in instantiation
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.
1 parent 28a10da commit c2b3d5e

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

gcc/ada/sem_ch12.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13223,7 +13223,7 @@ package body Sem_Ch12 is
1322313223
-- to capture local names that may be hidden if the generic is
1322413224
-- a child unit.
1322513225

13226-
if Nkind (Actual) = N_Aggregate then
13226+
if Nkind (Unqualify (Actual)) = N_Aggregate then
1322713227
Preanalyze_And_Resolve (Actual, Typ);
1322813228
end if;
1322913229

gcc/testsuite/gnat.dg/aggr32.adb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- { dg-do compile }
2+
3+
with Aggr32_Pkg.Child;
4+
5+
procedure Aggr32 (W, H : Positive) is
6+
7+
use Aggr32_Pkg;
8+
9+
package Test_1 is new Child (Frame => (Width => W, Height => H));
10+
11+
package Test_2 is new Child (Frame => Rec'(Width => W, Height => H));
12+
13+
begin
14+
null;
15+
end;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
generic
2+
3+
Frame : Rec;
4+
5+
package Aggr32_Pkg.Child is
6+
end Aggr32_Pkg.Child;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package Aggr32_Pkg is
2+
3+
type Rec is record
4+
Width : Positive;
5+
Height : Positive;
6+
end record;
7+
8+
end Aggr32_Pkg;

0 commit comments

Comments
 (0)