From 35c91e0571501b3d876e4e0c5b4cf33da758f1da Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Wed, 16 Apr 2008 12:37:38 +0000 Subject: [PATCH] re PR ada/29015 (Ada 2005 observer pattern with mutually dependent packages and containers produces compiler error) gcc/ada/ PR ada/29015 * sem_ch12.adb (Instantiate_Type): Check whether the full view of the type is known instead of the underlying type. gcc/testsuite/ PR ada/29015 * gnat.dg/incomplete1.ads, gnat.dg/incomplete2.ads, gnat.dg/incomplete2.adb: New. From-SVN: r134345 --- gcc/ada/ChangeLog | 6 ++++++ gcc/ada/sem_ch12.adb | 2 +- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gnat.dg/incomplete1.ads | 3 +++ gcc/testsuite/gnat.dg/incomplete2.adb | 4 ++++ gcc/testsuite/gnat.dg/incomplete2.ads | 8 ++++++++ 6 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gnat.dg/incomplete1.ads create mode 100644 gcc/testsuite/gnat.dg/incomplete2.adb create mode 100644 gcc/testsuite/gnat.dg/incomplete2.ads diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 950d1ddaadd..346866e9215 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2008-04-16 Samuel Tardieu + + PR ada/29015 + * sem_ch12.adb (Instantiate_Type): Check whether the full view of + the type is known instead of the underlying type. + 2008-04-15 Ed Schonberg PR ada/22387 diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index c44f3929d50..60833fc2bdb 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -9990,7 +9990,7 @@ package body Sem_Ch12 is Ekind (Root_Type (Act_T)) = E_Incomplete_Type) then if Is_Class_Wide_Type (Act_T) - or else No (Underlying_Type (Act_T)) + or else No (Full_View (Act_T)) then Error_Msg_N ("premature use of incomplete type", Actual); Abandon_Instantiation (Actual); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 43715717330..13167d6ef18 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-04-16 Samuel Tardieu + + PR ada/29015 + * gnat.dg/incomplete1.ads, gnat.dg/incomplete2.ads, + gnat.dg/incomplete2.adb: New. + 2008-04-16 Hans-Peter Nilsson PR tree-optimization/35629 diff --git a/gcc/testsuite/gnat.dg/incomplete1.ads b/gcc/testsuite/gnat.dg/incomplete1.ads new file mode 100644 index 00000000000..34900335d8a --- /dev/null +++ b/gcc/testsuite/gnat.dg/incomplete1.ads @@ -0,0 +1,3 @@ +package Incomplete1 is + type T is null record; +end Incomplete1; diff --git a/gcc/testsuite/gnat.dg/incomplete2.adb b/gcc/testsuite/gnat.dg/incomplete2.adb new file mode 100644 index 00000000000..19c83609b01 --- /dev/null +++ b/gcc/testsuite/gnat.dg/incomplete2.adb @@ -0,0 +1,4 @@ +-- { dg-do compile } +-- { dg-excess-errors "instantiation abandoned" } +with Incomplete1; +package body Incomplete2 is end Incomplete2; diff --git a/gcc/testsuite/gnat.dg/incomplete2.ads b/gcc/testsuite/gnat.dg/incomplete2.ads new file mode 100644 index 00000000000..21f2d2bb1bd --- /dev/null +++ b/gcc/testsuite/gnat.dg/incomplete2.ads @@ -0,0 +1,8 @@ +limited with Incomplete1; +package Incomplete2 is + pragma Elaborate_Body; + generic + type T is private; + package G is end G; + package I1 is new G (Incomplete1.T); -- { dg-error "premature use" } +end Incomplete2; -- 2.30.2