Commit d036b2b8 by Hristian Kirtchev Committed by Pierre-Marie de Rodat

[Ada] Spurious error on discriminant of incomplete type

This patch corrects the conformance verification of discriminants to
provide symmetry between the analysis of incomplete and full view
discriminants. As a result, types of discriminants always resolve to the
proper view.

2019-07-10  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* sem_ch6.adb (Check_Discriminant_Conformance): Use Find_Type to
	discover the type of a full view discriminant.

gcc/testsuite/

	* gnat.dg/incomplete7.adb, gnat.dg/incomplete7.ads: New testcase.

From-SVN: r273347
parent 6056bc73
2019-07-10 Hristian Kirtchev <kirtchev@adacore.com>
* sem_ch6.adb (Check_Discriminant_Conformance): Use Find_Type to
discover the type of a full view discriminant.
2019-07-10 Arnaud Charlet <charlet@adacore.com> 2019-07-10 Arnaud Charlet <charlet@adacore.com>
* doc/gnat_ugn/gnat_and_program_execution.rst: Improve gnatmem's * doc/gnat_ugn/gnat_and_program_execution.rst: Improve gnatmem's
......
...@@ -5960,7 +5960,7 @@ package body Sem_Ch6 is ...@@ -5960,7 +5960,7 @@ package body Sem_Ch6 is
Access_Definition (N, Discriminant_Type (New_Discr)); Access_Definition (N, Discriminant_Type (New_Discr));
else else
Analyze (Discriminant_Type (New_Discr)); Find_Type (Discriminant_Type (New_Discr));
New_Discr_Type := Etype (Discriminant_Type (New_Discr)); New_Discr_Type := Etype (Discriminant_Type (New_Discr));
-- Ada 2005: if the discriminant definition carries a null -- Ada 2005: if the discriminant definition carries a null
......
2019-07-10 Hristian Kirtchev <kirtchev@adacore.com> 2019-07-10 Hristian Kirtchev <kirtchev@adacore.com>
* gnat.dg/incomplete7.adb, gnat.dg/incomplete7.ads: New testcase.
2019-07-10 Hristian Kirtchev <kirtchev@adacore.com>
* gnat.dg/limited2.adb, gnat.dg/limited2_pack_1.adb, * gnat.dg/limited2.adb, gnat.dg/limited2_pack_1.adb,
gnat.dg/limited2_pack_1.ads, gnat.dg/limited2_pack_2.adb, gnat.dg/limited2_pack_1.ads, gnat.dg/limited2_pack_2.adb,
gnat.dg/limited2_pack_2.ads: New testcase. gnat.dg/limited2_pack_2.ads: New testcase.
......
-- { dg-do compile }
package body Incomplete7 is
procedure Foo is null;
end Incomplete7;
package Incomplete7 is
type Color;
type Color is (red, green, blue);
type Action (C : Color := Color'(red));
type Action (C : Color := Color'(red)) is record
case C is
when red =>
Stop_Time : Positive;
when others =>
Go_For_It : Integer;
end case;
end record;
type Num;
type Num is new Integer;
type Rec (N : Num := Num'(1));
type Rec (N : Num := Num'(1)) is record
case N is
when 1 =>
One : Integer;
when others =>
null;
end case;
end record;
procedure Foo;
end Incomplete7;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment