]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Reject Valid_Value arguments originating from Standard
authorViljar Indus <indus@adacore.com>
Mon, 20 Jan 2025 13:10:22 +0000 (15:10 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Thu, 5 Jun 2025 13:38:44 +0000 (15:38 +0200)
The constraint for Valid_Value not applying to types from Standard
should also apply to all types derived from those types.

gcc/ada/ChangeLog:

* doc/gnat_rm/implementation_defined_attributes.rst: Update the
documentation for Valid_Value.
* sem_attr.adb (Analyze_Attribute): Reject types where
the root type originates from Standard.
* gnat_rm.texi: Regenerate.

gcc/ada/doc/gnat_rm/implementation_defined_attributes.rst
gcc/ada/gnat_rm.texi
gcc/ada/sem_attr.adb

index f0518106853fd4ca48b8b533ab34a8182ac6c3d2..86d2a815e1e0961320cc912151312a24b79b326c 100644 (file)
@@ -1629,9 +1629,9 @@ Attribute Valid_Value
 .. index:: Valid_Value
 
 The ``'Valid_Value`` attribute is defined for enumeration types other than
-those in package Standard. This attribute is a function that takes
-a String, and returns Boolean. ``T'Valid_Value (S)`` returns True
-if and only if ``T'Value (S)`` would not raise Constraint_Error.
+those in package Standard or types derived from those types. This attribute is
+a function that takes a String, and returns Boolean. ``T'Valid_Value (S)``
+returns True if and only if ``T'Value (S)`` would not raise Constraint_Error.
 
 Attribute Valid_Scalars
 =======================
index 97469d7395201f30fa50786d1f28a311e403a17c..54830b80a7f7562497f109097afbefe967e96ee8 100644 (file)
@@ -12360,9 +12360,9 @@ which changes element (1,2) to 20 and (3,4) to 30.
 @geindex Valid_Value
 
 The @code{'Valid_Value} attribute is defined for enumeration types other than
-those in package Standard. This attribute is a function that takes
-a String, and returns Boolean. @code{T'Valid_Value (S)} returns True
-if and only if @code{T'Value (S)} would not raise Constraint_Error.
+those in package Standard or types derived from those types. This attribute is
+a function that takes a String, and returns Boolean. @code{T'Valid_Value (S)}
+returns True if and only if @code{T'Value (S)} would not raise Constraint_Error.
 
 @node Attribute Valid_Scalars,Attribute VADS_Size,Attribute Valid_Value,Implementation Defined Attributes
 @anchor{gnat_rm/implementation_defined_attributes attribute-valid-scalars}@anchor{1c5}
index af08fdb2e33f9aaa9097c86a5fac47b854184116..08da29a21984140456fc22f80f28fb70044d8f9d 100644 (file)
@@ -7511,13 +7511,14 @@ package body Sem_Attr is
          Set_Etype (N, Standard_Boolean);
          Validate_Non_Static_Attribute_Function_Call;
 
-         if P_Type in Standard_Boolean
+         if Root_Type (P_Type) in Standard_Boolean
                     | Standard_Character
                     | Standard_Wide_Character
                     | Standard_Wide_Wide_Character
          then
             Error_Attr_P
-              ("prefix of % attribute must not be a type in Standard");
+              ("prefix of % attribute must not be a type originating from " &
+               "Standard");
          end if;
 
          if Discard_Names (First_Subtype (P_Type)) then