summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-14 13:36:42 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-14 13:36:42 +0000
commit2c3ae800c05857ca3bbf0718754c657dd27d91f8 (patch)
treeffd9fb930548d3afa4848ddb0346bf0494d1ff65
parent3755dbc5803218c7b66e96bf8330379c78cff9c6 (diff)
downloadgcc-2c3ae800c05857ca3bbf0718754c657dd27d91f8.tar.gz
2010-06-14 Ed Schonberg <schonberg@adacore.com>
* sem_ch8.adb (Find_Type): The attribute 'class cannot be applied to an untagged incomplete type that is a limited view. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160741 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/sem_ch8.adb29
2 files changed, 25 insertions, 9 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 9f8ca7dfa91..19b0aa2095f 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-14 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch8.adb (Find_Type): The attribute 'class cannot be applied to
+ an untagged incomplete type that is a limited view.
+
2010-06-14 Sergey Rybin <rybin@adacore.com>
* gnat_ugn.texi: Add description of '-cargs gcc_switches' to gnatstub
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index ad722430890..c10ab2b53c4 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -5624,7 +5624,19 @@ package body Sem_Ch8 is
-- It is legal to denote the class type of an incomplete
-- type. The full type will have to be tagged, of course.
-- In Ada 2005 this usage is declared obsolescent, so we
- -- warn accordingly.
+ -- warn accordingly. This usage is only legal if the type
+ -- is completed in the current scope, and not for a limited
+ -- view of a type.
+
+ if not Is_Tagged_Type (T)
+ and then Ada_Version >= Ada_05
+ then
+ if From_With_Type (T) then
+ Error_Msg_N
+ ("prefix of Class attribute must be tagged", N);
+ Set_Etype (N, Any_Type);
+ Set_Entity (N, Any_Type);
+ return;
-- ??? This test is temporarily disabled (always False)
-- because it causes an unwanted warning on GNAT sources
@@ -5632,14 +5644,13 @@ package body Sem_Ch8 is
-- Feature). Once this issue is cleared in the sources, it
-- can be enabled.
- if not Is_Tagged_Type (T)
- and then Ada_Version >= Ada_05
- and then Warn_On_Obsolescent_Feature
- and then False
- then
- Error_Msg_N
- ("applying 'Class to an untagged incomplete type"
- & " is an obsolescent feature (RM J.11)", N);
+ elsif Warn_On_Obsolescent_Feature
+ and then False
+ then
+ Error_Msg_N
+ ("applying 'Class to an untagged incomplete type"
+ & " is an obsolescent feature (RM J.11)", N);
+ end if;
end if;
Set_Is_Tagged_Type (T);