From patchwork Mon Sep 5 07:26:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 972 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp57622wrt; Mon, 5 Sep 2022 00:32:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR57GWkvMjD0xYNJtLyxpQCjQamIcjfSWGi2/lmCSZuYYNxi7/6tg24C6ccbXbu4lW5u+GYQ X-Received: by 2002:a17:907:2722:b0:731:23a3:be78 with SMTP id d2-20020a170907272200b0073123a3be78mr35042545ejl.330.1662363133537; Mon, 05 Sep 2022 00:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662363133; cv=none; d=google.com; s=arc-20160816; b=k7R/1jA4sTAtNVVD5sMqNmXm5g1zYENJ4Ty8UqGkvcJjTLFV7tK2QBKRHcDvGhtTeq U+OtjSVRNc0sGNXwL2yLpqY4F9nwfGGVZa8UoWy9LKFuvS4J4exH4NroIJ0buEeUo6MJ W52XHqwdmYev++dvKq5c2UwkbSeV7afX5L7WpyoqMpaAxNcYCWINNgJjpnjkTqJpOxCY lSzsqA8LCYT1Nfyda50MV52UYeiYB+oJzsmFxa+WC9OzJsTqHpptgW+gGW4HhXwns8J0 EM3JnqeRVXyAoEn0wsbR+i0aePZB7cSou54B1TMtJUGWe27Ag9NUD87slJQJpjW2xUCO R2CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=ZvVSiR3DnYWw6oNw4Fzp16IP+wTOaz0sHkbSf3lQ7HI=; b=O2xGjVWDpKpNqGSVEjSZs9Y9A6DYChqO+/GX0gYuFNKBv8hhT92scMoXuEHToZ3oUX MgbLukDs6L/i9Z4Rg1Z4CzHkvbY0ltJs9ZE1eL9yjC6XS5SR9ly78DAUvw84sCX4kXwN ekfYTbxj9cvqpxq5goC42aI59PJ/FbHz/26wqNcux6I9OUhPLmnx0YN08R2uuBlkB+Jm YBmc67wlc+RAkuyKlAdJwlaS1YYOkcl3rlPZxCX9AJWH+W1KLKHS5U7EmbOkQEuzUIxr 3dCcSZSIg4f9Ly6hZnndajGrRZf3e++HJNHPxKaWPOrJ1QKvusngKLZVfvCC87JbIsao rDbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=uZ1xQSVP; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id qf28-20020a1709077f1c00b00730a1f55ac8si8083870ejc.821.2022.09.05.00.32.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:32:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=uZ1xQSVP; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D6A49385380F for ; Mon, 5 Sep 2022 07:28:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D6A49385380F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662362934; bh=ZvVSiR3DnYWw6oNw4Fzp16IP+wTOaz0sHkbSf3lQ7HI=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=uZ1xQSVPsrFbVvxwGulcdXu0JzMxgxtge6iBkznhsb00o4i15hIa/vkuCq33N32IN 4pqhaVqFRx4vxXQ7TZWt6N37cSscg5VcqRtWnKMi53JGiee64PkUZ9DuB1GX9p2UMO KJrzwZUnmzTJldjZWW2Dz5EB8y3kzDjJNCm8eGI4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 155443856965 for ; Mon, 5 Sep 2022 07:26:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 155443856965 Received: by mail-wr1-x430.google.com with SMTP id f15so5318116wrw.3 for ; Mon, 05 Sep 2022 00:26:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=ZvVSiR3DnYWw6oNw4Fzp16IP+wTOaz0sHkbSf3lQ7HI=; b=rgFEqPfpr87TdVSXbw0BaWyoabJavQ0sU1A6pO+0e484jL9ojs1sY9rptGpdJd88ep krQX/1int/3TfJ26cprEVx7xJ382k2ytLFMK7ZCSKiBAmBc1qxaoq0Anjbwt1Z7wASy0 U/Y5lP5/REwsAFu7RicP8gb9zLCdljrT3hi0PV2IJmuQlLF/VyFuaXy4I8ohjJlh3ZsR 0ZCfo/L6jws7pjP+7nlAP2KsuXjnDglcBhzKpt5xF+Ua8hnTLVt7RXHFp11E4jVFKopp Nllw9OHD17rekGVGqKesgBFjsmU4618nd8nWH+10drhGZDpKcXoKSotUcv/Fq74+dqLF bQvQ== X-Gm-Message-State: ACgBeo3Z6iZqsiOOyQFg0Erj82UlD3ENkvkukhv5yu/70QSNuY7SS+1r ocYi60w3HgqE+Yb4HcwLxLUQBAtIA008rQ== X-Received: by 2002:a5d:584b:0:b0:220:7624:5aae with SMTP id i11-20020a5d584b000000b0022076245aaemr23360544wrf.119.1662362763004; Mon, 05 Sep 2022 00:26:03 -0700 (PDT) Received: from poulhies-Precision-5550 (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id v5-20020adf8b45000000b0021e6c52c921sm9842590wra.54.2022.09.05.00.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:26:02 -0700 (PDT) Date: Mon, 5 Sep 2022 09:26:01 +0200 To: gcc-patches@gcc.gnu.org Subject: [Ada] Enable Error_Msg_GNAT_Extension for mixed decl/stmts Message-ID: <20220905072601.GA1174654@poulhies-Precision-5550> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.4 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-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: Marc =?iso-8859-1?q?Poulhi=E8s?= Cc: Bob Duff Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743114085202480941?= X-GMAIL-MSGID: =?utf-8?q?1743114085202480941?= Enable mixing of declarative items and statements under the -gnatX switch. The previous version used the -gnat2022 switch. In addition, change the error message so that it advertises the new feature when it is disabled. Instead of: declarations must come before "begin" we now say (without -gnatX): declarations mixed with statements is a GNAT-specific extension unit must be compiled with -gnatX or use pragma Extensions_Allowed (On) Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch5.adb (P_Sequence_Of_Statements): Call Error_Msg_GNAT_Extension to give the error message. diff --git a/gcc/ada/par-ch5.adb b/gcc/ada/par-ch5.adb --- a/gcc/ada/par-ch5.adb +++ b/gcc/ada/par-ch5.adb @@ -242,8 +242,8 @@ package body Ch5 is -- In Ada 2022, we allow declarative items to be mixed with -- statements. The loop below alternates between calling - -- P_Declarative_Items to parse zero or more declarative items, and - -- parsing a statement. + -- P_Declarative_Items to parse zero or more declarative items, + -- and parsing a statement. loop Ignore (Tok_Semicolon); @@ -255,26 +255,17 @@ package body Ch5 is (Statement_List, Declare_Expression => False, In_Spec => False, In_Statements => True); - -- Use the length of the list to determine whether we parsed any - -- declarative items. If so, it's an error pre-2022. ???We should - -- be calling Error_Msg_Ada_2022_Feature below, to advertise the - -- new feature, but that causes a lot of test diffs, so for now, - -- we mimic the old "...before begin" message. + -- Use the length of the list to determine whether we parsed + -- any declarative items. If so, it's an error unless language + -- extensions are enabled. if List_Length (Statement_List) > Num_Statements then if All_Errors_Mode or else No (Decl_Loc) then Decl_Loc := Sloc (Pick (Statement_List, Num_Statements + 1)); - if False then - Error_Msg_Ada_2022_Feature - ("declarations mixed with statements", - Sloc (Pick (Statement_List, Num_Statements + 1))); - else - if Ada_Version < Ada_2022 then - Error_Msg - ("declarations must come before BEGIN", Decl_Loc); - end if; - end if; + Error_Msg_GNAT_Extension + ("declarations mixed with statements", + Sloc (Pick (Statement_List, Num_Statements + 1))); end if; end if; end;