From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id D3DF83857831 for ; Wed, 18 May 2022 08:43:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D3DF83857831 Received: by mail-wm1-x335.google.com with SMTP id a14-20020a7bc1ce000000b00393fb52a386so2744752wmj.1 for ; Wed, 18 May 2022 01:43:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=g/XIMyqrPYXVs9Ops+tKgl6/7m4Wu/wV6WWQdPEkrMk=; b=tRO5yRqn+7y4lmsfOlj+2/2uBQWRxR/MvjTbWZfcgjhe9g7X6vXdV9f1vseV+Rv0Nr MPx2IYQfm3sKsab0dZDmIhJ2emY6JRCjlYAHpBgHpgSCYJi+zln2J0jgBlSfBTyAgamW Bz27rup2jbuvPAmqmnteWS7Du7X4q/sU+7LWGWlxW/hg1GJabPMZbzBdEfZ8/teocScc EaYm0J6XHEH9ACJdzrBk7PZBMHuPDuTGyQIEPHypSdP2M02qNOiKZT0FGRkevR6MkudV b4EsJbOhqqVInFzuUPkubQqPTK+vALrHo1tnRX0EYJRBeGCa4f+fOhCRAvIswel9V5D+ +Ojg== X-Gm-Message-State: AOAM530+3IebDHB4i311s3Zuddbt+/mL16ZhKGweG/x9pjnNStHJlpb1 vDutcScELaMFVZuH4suwhX4VJ8wfNkI5TQ== X-Google-Smtp-Source: ABdhPJxfMIC1abHQGpNduUG9dRi80IawKRbqR++hdG53Tj8S47/5XMU49lFjOOw/G3AZMGSifyZgGA== X-Received: by 2002:a7b:c3c7:0:b0:394:1aaa:1256 with SMTP id t7-20020a7bc3c7000000b003941aaa1256mr25218344wmj.172.1652863392528; Wed, 18 May 2022 01:43:12 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id r12-20020adfbb0c000000b0020d0e7379casm1394369wrg.95.2022.05.18.01.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 01:43:12 -0700 (PDT) Date: Wed, 18 May 2022 08:43:11 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [Ada] Spurious error on freezing of tagged types in SPARK Message-ID: <20220518084311.GA3322608@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="HcAYCG3uE/tztfnV" Content-Disposition: inline X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 May 2022 08:43:15 -0000 --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --HcAYCG3uE/tztfnV Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" 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 --HcAYCG3uE/tztfnV--