Index: sem_ch6.adb =================================================================== --- sem_ch6.adb (revision 255683) +++ sem_ch6.adb (working copy) @@ -366,10 +366,13 @@ procedure Check_And_Freeze_Type (Typ : Entity_Id) is begin - -- Skip Itypes created by the preanalysis + -- Skip Itypes created by the preanalysis, and itypes + -- whose scope is another type (i.e. component subtypes + -- that depend on a discriminant), if Is_Itype (Typ) - and then Scope_Within_Or_Same (Scope (Typ), Def_Id) + and then (Scope_Within_Or_Same (Scope (Typ), Def_Id) + or else Is_Type (Scope (Typ))) then return; end if; Index: ../testsuite/gnat.dg/expr_func2.ads =================================================================== --- ../testsuite/gnat.dg/expr_func2.ads (revision 0) +++ ../testsuite/gnat.dg/expr_func2.ads (revision 0) @@ -0,0 +1,22 @@ +package Expr_Func2 is + + type T_Index is range 1 .. 255; + + type T_Table is array (T_Index range <>) of Boolean; + + type T_Variable_Table (N : T_Index := T_Index'First) is record + Table : T_Table (1 .. N); + end record; + + type T_A_Variable_Table is access T_Variable_Table; + + function Element (A_Variable_Table : T_A_Variable_Table) return Boolean; + +private + + function Element (A_Variable_Table : T_A_Variable_Table) return Boolean is + (A_Variable_Table.all.Table (1)); + + procedure Foo; + +end Expr_Func2; Index: ../testsuite/gnat.dg/expr_func2.adb =================================================================== --- ../testsuite/gnat.dg/expr_func2.adb (revision 0) +++ ../testsuite/gnat.dg/expr_func2.adb (revision 0) @@ -0,0 +1,5 @@ +-- { dg-do compile } + +package body Expr_Func2 is + procedure Foo is null; +end Expr_Func2;