From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x430.google.com with SMTP id f15so5318116wrw.3 for ; Mon, 05 Sep 2022 00:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date; bh=ZvVSiR3DnYWw6oNw4Fzp16IP+wTOaz0sHkbSf3lQ7HI=; b=PIiuZcVRe7CS3yqnUMTJR8vEcNy1YCo/2RbPg6dcQmU9CEwID+arwJFOhaJbWsarlc W4lkpPobHX92QT0KaOHo0bL91woHGybQptx8E5xflV8ZZwsmcQExB9RSwABOL78FrrOU Y/U0XkUCHTeCWnyMaYx1MjZCj7l8EKALTjmN6gHbn+SFWq2udmg9ztipHam+c/BkaLJ1 lecIPLpc07vDKMUOsYs0nIGtv6xm8ccLRby3lkmrCNa5t8h1e+9lusfTjb+KRUZjnfrG Spt3P7DEoyhwtCkD1LaBClvNQareIVwAyuwjpBzCO/qrl5bXAZlFEbXMVzrQs4ipdNOX SAtA== 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-Google-Smtp-Source: AA6agR48ccAPlF7yHT7S815Ai9jlIHqnFLIwkydzPcRn2qICmfXTl2TcHGO6RvfWCtgcgf1Ner+L8Q== 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 From: Marc =?iso-8859-1?Q?Poulhi=E8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] Enable Error_Msg_GNAT_Extension for mixed decl/stmts Message-ID: <20220905072601.GA1174654@poulhies-Precision-5550> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="YZ5djTAD1cGYuMQK" 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 List-Id: --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --YZ5djTAD1cGYuMQK Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" 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; --YZ5djTAD1cGYuMQK--