[Ada] Spurious error on discriminant of incomplete type
authorHristian Kirtchev <kirtchev@adacore.com>
Wed, 10 Jul 2019 09:02:31 +0000 (09:02 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Wed, 10 Jul 2019 09:02:31 +0000 (09:02 +0000)
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

gcc/ada/ChangeLog
gcc/ada/sem_ch6.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/incomplete7.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/incomplete7.ads [new file with mode: 0644]

index 246134c..86e3508 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * doc/gnat_ugn/gnat_and_program_execution.rst: Improve gnatmem's
index e00cd57..25ee705 100644 (file)
@@ -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
index 21c5e31..b658817 100644 (file)
@@ -1,5 +1,9 @@
 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_pack_1.ads, gnat.dg/limited2_pack_2.adb,
        gnat.dg/limited2_pack_2.ads: New testcase.
diff --git a/gcc/testsuite/gnat.dg/incomplete7.adb b/gcc/testsuite/gnat.dg/incomplete7.adb
new file mode 100644 (file)
index 0000000..34accbe
--- /dev/null
@@ -0,0 +1,5 @@
+--  { dg-do compile }
+
+package body Incomplete7 is
+   procedure Foo is null;
+end Incomplete7;
diff --git a/gcc/testsuite/gnat.dg/incomplete7.ads b/gcc/testsuite/gnat.dg/incomplete7.ads
new file mode 100644 (file)
index 0000000..3c1ade7
--- /dev/null
@@ -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;