]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Mon, 20 Jan 2014 15:55:52 +0000 (16:55 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 20 Jan 2014 15:55:52 +0000 (16:55 +0100)
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

gcc/ada/ChangeLog
gcc/ada/sem_attr.adb
gcc/ada/sem_cat.adb

index 8aa7d605aa04831665abc6837e456c7e6737d4a5..4b1d4c93f4b6129d50664cc501f371699e3e1667 100644 (file)
@@ -1,3 +1,17 @@
+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.
index e434697340a8925e7c740d6af7de864974eb9130..8f1a1eef225e1a1d3fdc6f0b452674e00f23ac82 100644 (file)
@@ -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;
 
index 69cb626dd067a7f545a1618e9b490851b337add4..3692e519330bbaea400b440d07aa965cc5412912 100644 (file)
@@ -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