public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3733] [Ada] Enforce legality rule for Predicate_Failure aspect specifications
@ 2021-09-21 15:26 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-09-21 15:26 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e9068967876383bf0d9280b4f455fd50e7faf152

commit r12-3733-ge9068967876383bf0d9280b4f455fd50e7faf152
Author: Steve Baird <baird@adacore.com>
Date:   Thu Jul 1 17:03:25 2021 -0700

    [Ada] Enforce legality rule for Predicate_Failure aspect specifications
    
    gcc/ada/
    
            * sem_ch13.adb (Analyze_Aspect_Specifications): Add a new nested
            function, Directly_Specified, and then use it in the
            implementation of the required check.

Diff:
---
 gcc/ada/sem_ch13.adb | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 0ac8bdccda4..e841dda5c78 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -1884,6 +1884,11 @@ package body Sem_Ch13 is
             --  expression is allowed. Includes checking that the expression
             --  does not raise Constraint_Error.
 
+            function Directly_Specified
+              (Id : Entity_Id; A : Aspect_Id) return Boolean;
+            --  Returns True if the given aspect is directly (as opposed to
+            --  via any form of inheritance) specified for the given entity.
+
             function Make_Aitem_Pragma
               (Pragma_Argument_Associations : List_Id;
                Pragma_Name                  : Name_Id) return Node_Id;
@@ -2777,6 +2782,18 @@ package body Sem_Ch13 is
                end if;
             end Check_Expr_Is_OK_Static_Expression;
 
+            ------------------------
+            -- Directly_Specified --
+            ------------------------
+
+            function Directly_Specified
+              (Id : Entity_Id; A : Aspect_Id) return Boolean
+            is
+               Aspect_Spec : constant Node_Id := Find_Aspect (Id, A);
+            begin
+               return Present (Aspect_Spec) and then Entity (Aspect_Spec) = Id;
+            end Directly_Specified;
+
             -----------------------
             -- Make_Aitem_Pragma --
             -----------------------
@@ -3342,6 +3359,15 @@ package body Sem_Ch13 is
                        ("Predicate_Failure requires previous predicate" &
                         " specification", Aspect);
                      goto Continue;
+
+                  elsif not (Directly_Specified (E, Aspect_Dynamic_Predicate)
+                    or else Directly_Specified (E, Aspect_Static_Predicate)
+                    or else Directly_Specified (E, Aspect_Predicate))
+                  then
+                     Error_Msg_N
+                       ("Predicate_Failure requires accompanying" &
+                        " noninherited predicate specification", Aspect);
+                     goto Continue;
                   end if;
 
                   --  Construct the pragma


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

only message in thread, other threads:[~2021-09-21 15:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-21 15:26 [gcc r12-3733] [Ada] Enforce legality rule for Predicate_Failure aspect specifications 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).