This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] ada/35792: Refuse completion of tagged type by task type or protected type
- From: Samuel Tardieu <sam at rfc1149 dot net>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 9 Apr 2008 15:32:09 +0200
- Subject: [PATCH] ada/35792: Refuse completion of tagged type by task type or protected type
- Organisation: RFC1149 (see http://www.rfc1149.net/)
gcc/ada/
PR ada/35792
* sem_ch3.adb (Find_Type_Name): Refuse completion of tagged type
by a task type or a protected type.
gcc/testsuite/
PR ada/35792
* gnat.dg/specs/tag2.ads: New.
---
gcc/ada/sem_ch3.adb | 10 +++++++---
gcc/testsuite/gnat.dg/specs/tag2.ads | 10 ++++++++++
2 files changed, 17 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gnat.dg/specs/tag2.ads
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 2bd3a4c..9e2ae0e 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -13046,13 +13046,17 @@ package body Sem_Ch3 is
if Is_Type (Prev)
and then (Is_Tagged_Type (Prev)
or else Present (Class_Wide_Type (Prev)))
- and then not Nkind_In (N, N_Task_Type_Declaration,
- N_Protected_Type_Declaration)
then
-- The full declaration is either a tagged record or an
-- extension otherwise this is an error
- if Nkind (Type_Definition (N)) = N_Record_Definition then
+ if Nkind_In (N, N_Task_Type_Declaration,
+ N_Protected_Type_Declaration)
+ then
+ Error_Msg_NE
+ ("full declaration of } must be a tagged type ", Id, Prev);
+
+ elsif Nkind (Type_Definition (N)) = N_Record_Definition then
if not Tagged_Present (Type_Definition (N)) then
Error_Msg_NE
("full declaration of } must be tagged", Id, Prev);
diff --git a/gcc/testsuite/gnat.dg/specs/tag2.ads b/gcc/testsuite/gnat.dg/specs/tag2.ads
new file mode 100644
index 0000000..0517f5d
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/tag2.ads
@@ -0,0 +1,10 @@
+-- { dg-do compile }
+
+package tag2 is
+ type T1 is tagged;
+ type T2 is tagged;
+ type T3 is tagged;
+ protected type T1 is end T1; -- { dg-error "must be a tagged type" }
+ task type T2; -- { dg-error "must be a tagged type" }
+ type T3 is null record; -- { dg-error "must be tagged" }
+end tag2;
--
1.5.5.144.g3e42