+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.
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;
-- 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