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: Yannick Moy <moy@adacore.com>
Subject: [Ada] Spurious error on freezing of tagged types in SPARK
Date: Wed, 18 May 2022 08:43:11 +0000	[thread overview]
Message-ID: <20220518084311.GA3322608@adacore.com> (raw)

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

SPARK RM 7.7(8) mandates that the freezing point of a tagged type must
occur within the so-called early call region of all its primitives.
This check may lead to spurious errors due to generated constructs being
considered in the search for the start of the early call region.

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

gcc/ada/

	* sem_elab.adb (Is_Suitable_Construct): Fix for generated
	constructs.

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

diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb
--- a/gcc/ada/sem_elab.adb
+++ b/gcc/ada/sem_elab.adb
@@ -7346,7 +7346,7 @@ package body Sem_Elab is
             --  is a byproduct of the parser. Such a null statement should be
             --  excluded from the early call region because it carries the
             --  source location of the "end" keyword, and may lead to confusing
-            --  diagnistics.
+            --  diagnostics.
 
             if Nkind (N) = N_Null_Statement
               and then not Comes_From_Source (N)
@@ -7354,6 +7354,16 @@ package body Sem_Elab is
               and then Nkind (Context) = N_Handled_Sequence_Of_Statements
             then
                return False;
+
+            --  Similarly, internally-generated objects and types may have
+            --  out-of-order source locations that confuse diagnostics, e.g.
+            --  source locations in the body for objects/types generated in
+            --  the spec.
+
+            elsif Nkind (N) in N_Full_Type_Declaration | N_Object_Declaration
+              and then not Comes_From_Source (N)
+            then
+               return False;
             end if;
 
             --  Otherwise only constructs which correspond to pure Ada



                 reply	other threads:[~2022-05-18  8:43 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=20220518084311.GA3322608@adacore.com \
    --to=derodat@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=moy@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).