public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Add comments about attribute 'Valid_Scalars on private tagged types
@ 2020-06-19  8:28 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2020-06-19  8:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

[-- Attachment #1: Type: text/plain, Size: 528 bytes --]

Attribute 'Valid_Scalars on private tagged types doesn't work as it
should on private tagged types. Fix most likely needs to modify three
routines.  This patch document the problem with a ??? comment.

Tested on x86_64-pc-linux-gnu, committed on trunk

2020-06-19  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

	* exp_attr.adb (Expand_N_Attribute_Reference): Add comment.
	* sem_attr.adb (Analyze_Attribute): Add ??? comment.
	* sem_util.ads (Valid_Scalars): This routine is only used for
	'Valid_Scalars and not for 'Valid.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 2089 bytes --]

--- gcc/ada/exp_attr.adb
+++ gcc/ada/exp_attr.adb
@@ -7094,7 +7094,8 @@ package body Exp_Attr is
 
          Expr := Empty;
 
-         --  Attribute 'Valid_Scalars is not supported on private tagged types
+         --  Attribute 'Valid_Scalars is not supported on private tagged types;
+         --  see a detailed explanation where this attribute is analyzed.
 
          if Is_Private_Type (Ptyp) and then Is_Tagged_Type (Ptyp) then
             null;

--- gcc/ada/sem_attr.adb
+++ gcc/ada/sem_attr.adb
@@ -7016,6 +7016,10 @@ package body Sem_Attr is
                --  types due to a code generation issue. Is_Visible_Component
                --  does not allow for a component of a private tagged type to
                --  be successfully retrieved.
+               --  ??? This attribute should simply ignore type privacy
+               --  (see Validated_View). It should examine components of the
+               --  tagged type extensions (if any) and recursively examine
+               --  'Valid_Scalars of the parent's type (if any).
 
                --  Do not use Error_Attr_P because this bypasses any subsequent
                --  processing and leaves the attribute with type Any_Type. This

--- gcc/ada/sem_util.ads
+++ gcc/ada/sem_util.ads
@@ -3050,10 +3050,10 @@ package Sem_Util is
    --  conversions, and unchecked conversions.
 
    function Validated_View (Typ : Entity_Id) return Entity_Id;
-   --  Obtain the "validated view" of arbitrary type Typ which is suitable
-   --  for verification by attributes 'Valid and 'Valid_Scalars. This view
-   --  is the type itself or its full view while stripping away concurrency,
-   --  derivations, and privacy.
+   --  Obtain the "validated view" of arbitrary type Typ which is suitable for
+   --  verification by attributes 'Valid_Scalars. This view is the type itself
+   --  or its full view while stripping away concurrency, derivations, and
+   --  privacy.
 
    function Visible_Ancestors (Typ : Entity_Id) return Elist_Id;
    --  [Ada 2012:AI-0125-1]: Collect all the visible parents and progenitors


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-19  8:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-19  8:28 [Ada] Add comments about attribute 'Valid_Scalars on private tagged types Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).