public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Ed Schonberg <schonberg@adacore.com>
Subject: [Ada] In a generic use Presanalyze_Spec_Expression on Predicates
Date: Tue, 17 Sep 2019 08:07:00 -0000	[thread overview]
Message-ID: <20190917080633.GA37464@adacore.com> (raw)

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

When verifying that the meaning of an aspect has not changed between the
freeze point of the entity and the end of the declarations, we analkyze
a copy of the expression to verify its conformance to previous analysis.
If the expression contains overloaded references, these have to be
resolved, which is not done if the expression is only preanalyzed.  This
applies in particular to expressions in predicates.

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

2019-09-17  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): In a
	generic context, for a Predicate aspect, use
	Preanalyze_Spec_Expression to verify conformance.

gcc/testsuite/

	* gnat.dg/predicate13.adb, gnat.dg/predicate13.ads: New
	testcase.

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

--- gcc/ada/sem_ch13.adb
+++ gcc/ada/sem_ch13.adb
@@ -9383,7 +9383,7 @@ package body Sem_Ch13 is
               or else A_Id = Aspect_Priority
             then
                Push_Type (Ent);
-               Preanalyze (Freeze_Expr);
+               Preanalyze_Spec_Expression (Freeze_Expr, T);
                Pop_Type (Ent);
             else
                Preanalyze (Freeze_Expr);

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/predicate13.adb
@@ -0,0 +1,3 @@
+package body Predicate13 is
+    procedure Dummy is null;
+end Predicate13;
\ No newline at end of file

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/predicate13.ads
@@ -0,0 +1,23 @@
+--  { dg-do compile }
+generic
+package Predicate13 is
+
+    function Valid return Boolean is
+    (True);
+
+    function Foo return Boolean is
+    (True);
+
+    type State_Type is (Valid, Invalid);
+    type Context_Type is private;
+
+    private
+
+    type Context_Type is
+    record
+    State : State_Type;
+    end record  with Dynamic_Predicate => (State = Valid);
+
+    procedure Dummy;
+
+end Predicate13;


                 reply	other threads:[~2019-09-17  8:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190917080633.GA37464@adacore.com \
    --to=derodat@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=schonberg@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).