aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2014-01-20 16:55:52 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2014-01-20 16:55:52 +0100
commita61524283eb4439d870431cb5befc613b72a7828 (patch)
tree565d37ca1822b76afb520e484f16476161d93a49 /gcc
parente19fd0bde5ebf61308817cd9bf05e90a7d5a0aee (diff)
downloadgcc-a61524283eb4439d870431cb5befc613b72a7828.zip
gcc-a61524283eb4439d870431cb5befc613b72a7828.tar.gz
gcc-a61524283eb4439d870431cb5befc613b72a7828.tar.bz2
[multiple changes]
2014-01-20 Ed Schonberg <schonberg@adacore.com> * sem_attr.adb (Analyze_Attribute, case 'Constrained): In an instance the attribute is legal, and its value is determined statically if the type has no discriminants. This choice is more useful than rechecking the legality rule in the instance, is consistent with older usage, and is also consistent with all existing tests. 2014-01-20 Arnaud Charlet <charlet@adacore.com> * sem_cat.adb (Validate_Static_Object_Name): Change error into warning in Relaxed_Semantic_Mode. From-SVN: r206838
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog14
-rw-r--r--gcc/ada/sem_attr.adb35
-rw-r--r--gcc/ada/sem_cat.adb7
3 files changed, 37 insertions, 19 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 8aa7d60..4b1d4c9 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,19 @@
2014-01-20 Ed Schonberg <schonberg@adacore.com>
+ * sem_attr.adb (Analyze_Attribute, case 'Constrained): In an
+ instance the attribute is legal, and its value is determined
+ statically if the type has no discriminants. This choice is
+ more useful than rechecking the legality rule in the instance,
+ is consistent with older usage, and is also consistent with all
+ existing tests.
+
+2014-01-20 Arnaud Charlet <charlet@adacore.com>
+
+ * sem_cat.adb (Validate_Static_Object_Name): Change error into
+ warning in Relaxed_Semantic_Mode.
+
+2014-01-20 Ed Schonberg <schonberg@adacore.com>
+
* sem_attr.adb: Code and comments cleanup.
2014-01-20 Yannick Moy <moy@adacore.com>
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index e434697..8f1a1ee 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -3018,34 +3018,37 @@ package body Sem_Attr is
end if;
-- Must have discriminants or be an access type designating
- -- a type with discriminants. If it is a classwide type is ???
+ -- a type with discriminants. If it is a classwide type it
-- has unknown discriminants.
if Has_Discriminants (P_Type)
- or else Has_Unknown_Discriminants (P_Type)
- or else
- (Is_Access_Type (P_Type)
- and then Has_Discriminants (Designated_Type (P_Type)))
+ or else Has_Unknown_Discriminants (P_Type)
+ or else
+ (Is_Access_Type (P_Type)
+ and then Has_Discriminants (Designated_Type (P_Type)))
then
return;
+ -- The rule given in 3.7.2 is part of static semantics, but the
+ -- intent is clearly that it be treated as a legality rule, and
+ -- rechecked in the visible part of an instance. Nevertheless
+ -- the intent also seems to be it should legally apply to the
+ -- actual of a formal with unknown discriminants, regardless of
+ -- whether the actual has discriminants, in which case the value
+ -- of the attribute is determined using the J.4 rules. This choice
+ -- seems the most useful, and is compatible with existing tests.
+
+ elsif In_Instance then
+ return;
+
-- Also allow an object of a generic type if extensions allowed
- -- and allow this for any type at all.
+ -- and allow this for any type at all. (this may be obsolete ???)
elsif (Is_Generic_Type (P_Type)
- or else Is_Generic_Actual_Type (P_Type))
+ or else Is_Generic_Actual_Type (P_Type))
and then Extensions_Allowed
then
return;
-
- -- For compatibility with Declib code, treat all prefixes as
- -- legal, including non-discriminated types. This is because
- -- DECLIB uses the obsolescent interpretation of the attribute,
- -- and applies it to types as well as to objects, while the
- -- current definition applies to objects of a discriminated type.
-
- elsif OpenVMS_On_Target then
- return;
end if;
end if;
diff --git a/gcc/ada/sem_cat.adb b/gcc/ada/sem_cat.adb
index 69cb626..3692e51 100644
--- a/gcc/ada/sem_cat.adb
+++ b/gcc/ada/sem_cat.adb
@@ -2172,10 +2172,11 @@ package body Sem_Cat is
-- This is the error case
else
- -- In GNAT mode, this is just a warning, to allow it to be
- -- judiciously turned off. Otherwise it is a real error.
+ -- In GNAT mode or Relaxed RM Semantic mode, this is just a
+ -- warning, to allow it to be judiciously turned off.
+ -- Otherwise it is a real error.
- if GNAT_Mode then
+ if GNAT_Mode or Relaxed_RM_Semantics then
Error_Msg_N
("??non-static constant in preelaborated unit", N);
else