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.
Tested on x86_64-pc-linux-gnu, committed on trunk
2019-07-10 Hristian Kirtchev <kirtc...@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.
--- gcc/ada/sem_ch6.adb
+++ gcc/ada/sem_ch6.adb
@@ -5960,7 +5960,7 @@ package body Sem_Ch6 is
Access_Definition (N, Discriminant_Type (New_Discr));
else
- Analyze (Discriminant_Type (New_Discr));
+ Find_Type (Discriminant_Type (New_Discr));
New_Discr_Type := Etype (Discriminant_Type (New_Discr));
-- Ada 2005: if the discriminant definition carries a null
--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/incomplete7.adb
@@ -0,0 +1,5 @@
+-- { dg-do compile }
+
+package body Incomplete7 is
+ procedure Foo is null;
+end Incomplete7;
--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/incomplete7.ads
@@ -0,0 +1,31 @@
+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;