From patchwork Tue Nov 8 08:42:58 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: 60186 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 028973886C4F for ; Tue, 8 Nov 2022 08:50:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 028973886C4F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667897430; bh=2c6qd9K8z2Iw7cKbGvjQzpQaaj+KMvsB2AsCsVrc9vo=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=R9esVq5np2JEmmMTwCQikvq6x2oGQdaEIvyxa+x5f7Hm3v62rnYTTEMZtPj+kicC7 KK1U7iy1HJLcSjOEoOOLAQZnFIijreTJe2f596I56f12b3PVP4MWvb5Ve2VfATmRTb QahE0OlVx4YVLQE/cNdW9QAbOfYPe9kx2VerDPxo= 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 98078385736C for ; Tue, 8 Nov 2022 08:43:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 98078385736C Received: by mail-wr1-x430.google.com with SMTP id z14so19792770wrn.7 for ; Tue, 08 Nov 2022 00:43:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2c6qd9K8z2Iw7cKbGvjQzpQaaj+KMvsB2AsCsVrc9vo=; b=Sz6DNFBgM70p7UDsyfMlg5JneHTxbTTkHCDR+k42UWD4w3q9bsJSEggtdTSoO28F3C JbiF1XFDHswUuQSl+wuKa06PLMGO5m2h2NDVuc4pIZz659bw11SLzfbrnHOE/6du4yNq ieVW5hi9N2RS35stCz4MLRN40GMV0J8l3jiQjf56bMSE+FWk4o8m2rkdGz3+ZTkrgmE5 bol/12JrQQXHRRy+DbjPqcvhv3hdRlRncNZSmDUhPYeKK/Jtutj69KYMKJW2G2m5irpo UiHVt0bMllCkXuIWvkbdJUziWJeuliZKnEQkL03TCbgwNCKuyG7JfHicUi9slqXzc/Ra uCKg== X-Gm-Message-State: ACrzQf1CUtSzNIQhI1VxXwJHYogTWV5JAGqyX4Um+lj7c0y6e9qA6/ci 1N1g5opf4SduTs8pXCx4gnVyEsJxXn43jA== X-Google-Smtp-Source: AMsMyM4lrpDpVT8XCXGmdr1+tLx9VhZl8KZCHc+iCRjvUVZJoBXQDNytE0kL1aEDUKlKnTwchmjjVg== X-Received: by 2002:a05:6000:786:b0:236:d441:8f5d with SMTP id bu6-20020a056000078600b00236d4418f5dmr28088215wrb.550.1667896982476; Tue, 08 Nov 2022 00:43:02 -0800 (PST) Received: from localhost.localdomain (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id e4-20020adff344000000b002364c77bc96sm9798942wrp.33.2022.11.08.00.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 00:43:02 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED] ada: Move warnings switches -- initial work Date: Tue, 8 Nov 2022 09:42:58 +0100 Message-Id: <20221108084258.301710-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Bob Duff This patch prepares to move warning switches from Opt into Warnsw. gcc/ada/ * warnsw.ads, warnsw.adb, fe.h, err_vars.ads, errout.ads: Move Warning_Doc_Switch from Err_Vars to Warnsw. Access Warn_On_Questionable_Layout on the C side via a function rather than a variable, because we plan to turn the variables into renamings, and you can't Export renamings. * erroutc.adb, switch-c.adb, errout.adb: Likewise. * gcc-interface/decl.cc: Use Get_Warn_On_Questionable_Layout instead of Warn_On_Questionable_Layout. * gcc-interface/Makefile.in (GNATMAKE_OBJS): Add warnsw.o, because it is indirectly imported via Errout. * gcc-interface/Make-lang.in (GNATBIND_OBJS): Likewise and remove restrict.o (not needed). Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/err_vars.ads | 6 ------ gcc/ada/errout.adb | 2 ++ gcc/ada/errout.ads | 9 --------- gcc/ada/erroutc.adb | 1 + gcc/ada/fe.h | 4 ++-- gcc/ada/gcc-interface/Make-lang.in | 2 +- gcc/ada/gcc-interface/Makefile.in | 2 +- gcc/ada/gcc-interface/decl.cc | 2 +- gcc/ada/switch-c.adb | 1 - gcc/ada/warnsw.adb | 1 - gcc/ada/warnsw.ads | 13 ++++++++++++- 11 files changed, 20 insertions(+), 23 deletions(-) diff --git a/gcc/ada/err_vars.ads b/gcc/ada/err_vars.ads index 05329dc6f21..79d5f319f59 100644 --- a/gcc/ada/err_vars.ads +++ b/gcc/ada/err_vars.ads @@ -81,12 +81,6 @@ package Err_Vars is -- Source_Reference line, then this is initialized to No_Source_File, -- to force an initial reference to the real source file name. - Warning_Doc_Switch : Boolean := True; - -- If this is set True, then the ??/?x?/?x? sequences in error messages - -- are active (see errout.ads for details). If this switch is False, then - -- these sequences are ignored (i.e. simply equivalent to a single ?). The - -- -gnatw.d switch sets this flag True, -gnatw.D sets this flag False. - ---------------------------------------- -- Error Message Insertion Parameters -- ---------------------------------------- diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index 5730a543ee1..19ea1553260 100644 --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -53,6 +53,8 @@ with Stand; use Stand; with Stylesw; use Stylesw; with System.OS_Lib; with Uname; use Uname; +with Warnsw; pragma Unreferenced (Warnsw); +-- Will be referenced when various flags are moved to Warnsw. package body Errout is diff --git a/gcc/ada/errout.ads b/gcc/ada/errout.ads index 846a4a6c07b..aeb9a2fb912 100644 --- a/gcc/ada/errout.ads +++ b/gcc/ada/errout.ads @@ -59,15 +59,6 @@ package Errout is Error_Msg_Exception : exception renames Err_Vars.Error_Msg_Exception; -- Exception raised if Raise_Exception_On_Error is true - Warning_Doc_Switch : Boolean renames Err_Vars.Warning_Doc_Switch; - -- If this is set True, then the ??/?*?/?$?/?x?/?.x?/?_x? insertion - -- sequences in error messages generate appropriate tags for the output - -- error messages. If this switch is False, then these sequences are still - -- recognized (for the purposes of implementing the pattern matching in - -- pragmas Warnings (Off,..) and Warning_As_Error(...) but do not result - -- in adding the error message tag. The -gnatw.d switch sets this flag - -- True, -gnatw.D sets this flag False. - Current_Node : Node_Id := Empty; -- Used by Error_Msg as a default Node_Id. -- Relevant only when Opt.Include_Subprogram_In_Messages is set. diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb index d0cbe9fdff1..9ecc97fb46d 100644 --- a/gcc/ada/erroutc.adb +++ b/gcc/ada/erroutc.adb @@ -44,6 +44,7 @@ with Stringt; use Stringt; with Targparm; with Uintp; use Uintp; with Widechar; use Widechar; +with Warnsw; use Warnsw; package body Erroutc is diff --git a/gcc/ada/fe.h b/gcc/ada/fe.h index 79a1b58836e..8102c6d5ec4 100644 --- a/gcc/ada/fe.h +++ b/gcc/ada/fe.h @@ -366,9 +366,9 @@ extern Boolean Stack_Check_Probes_On_Target; /* warnsw: */ -#define Warn_On_Questionable_Layout warnsw__warn_on_questionable_layout +#define Get_Warn_On_Questionable_Layout warnsw__get_warn_on_questionable_layout -extern Boolean Warn_On_Questionable_Layout; +extern Boolean Get_Warn_On_Questionable_Layout (); // The following corresponds to Ada code in Einfo.Utils. diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in index 02b2d1c6f2a..45a4168e890 100644 --- a/gcc/ada/gcc-interface/Make-lang.in +++ b/gcc/ada/gcc-interface/Make-lang.in @@ -601,7 +601,6 @@ GNATBIND_OBJS = \ ada/osint-b.o \ ada/osint.o \ ada/output.o \ - ada/restrict.o \ ada/rident.o \ ada/scans.o \ ada/scil_ll.o \ @@ -629,6 +628,7 @@ GNATBIND_OBJS = \ ada/uintp.o \ ada/uname.o \ ada/urealp.o \ + ada/warnsw.o \ ada/widechar.o \ ada/gnat.o \ ada/g-dynhta.o \ diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in index 6b19b8be58e..5137ebaa0c6 100644 --- a/gcc/ada/gcc-interface/Makefile.in +++ b/gcc/ada/gcc-interface/Makefile.in @@ -333,7 +333,7 @@ GNATMAKE_OBJS = a-except.o ali.o ali-util.o aspects.o s-casuti.o alloc.o \ s-purexc.o s-htable.o scil_ll.o sem_aux.o sinfo.o sinput.o sinput-c.o \ snames.o stand.o stringt.o styleg.o stylesw.o system.o validsw.o \ switch.o switch-m.o table.o targparm.o tempdir.o types.o uintp.o \ - uname.o urealp.o usage.o widechar.o \ + uname.o urealp.o usage.o widechar.o warnsw.o \ seinfo.o einfo-entities.o einfo-utils.o sinfo-nodes.o sinfo-utils.o \ $(EXTRA_GNATMAKE_OBJS) diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index f8c76982de5..e25ce498f2c 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -8363,7 +8363,7 @@ components_to_record (Node_Id gnat_component_list, Entity_Id gnat_record_type, && !Debug_Flag_Dot_R); const bool w_reorder = (Convention (gnat_record_type) == Convention_Ada - && Warn_On_Questionable_Layout + && Get_Warn_On_Questionable_Layout () && !(No_Reordering (gnat_record_type) && GNAT_Mode)); tree gnu_zero_list = NULL_TREE; tree gnu_self_list = NULL_TREE; diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb index a1a877716f0..364ff55a4a6 100644 --- a/gcc/ada/switch-c.adb +++ b/gcc/ada/switch-c.adb @@ -28,7 +28,6 @@ -- circularities, especially for back ends using Adabkend. with Debug; use Debug; -with Errout; use Errout; with Lib; use Lib; with Osint; use Osint; with Opt; use Opt; diff --git a/gcc/ada/warnsw.adb b/gcc/ada/warnsw.adb index 733c9620631..dd40c8844c3 100644 --- a/gcc/ada/warnsw.adb +++ b/gcc/ada/warnsw.adb @@ -23,7 +23,6 @@ -- -- ------------------------------------------------------------------------------ -with Err_Vars; use Err_Vars; with Opt; use Opt; with Output; use Output; diff --git a/gcc/ada/warnsw.ads b/gcc/ada/warnsw.ads index 9edd6bea37e..645094509f4 100644 --- a/gcc/ada/warnsw.ads +++ b/gcc/ada/warnsw.ads @@ -38,6 +38,15 @@ package Warnsw is -- here as time goes by. And in fact a really nice idea would be to put -- them all in a Warn_Record so that they would be easy to save/restore. + Warning_Doc_Switch : Boolean := True; + -- If this is set True, then the ??/?*?/?$?/?x?/?.x?/?_x? insertion + -- sequences in error messages generate appropriate tags for the output + -- error messages. If this switch is False, then these sequences are still + -- recognized (for the purposes of implementing the pattern matching in + -- pragmas Warnings (Off,..) and Warning_As_Error(...) but do not result + -- in adding the error message tag. The -gnatw.d switch sets this flag + -- True, -gnatw.D sets this flag False. + Warn_On_Anonymous_Allocators : Boolean := False; -- Warn when allocators for anonymous access types are present, which, -- although not illegal in Ada, may be confusing to users due to how @@ -71,7 +80,9 @@ package Warnsw is -- efficiency reasons and would be improved by reordering the components. -- Off by default, modified by use of -gnatw.q/.Q (but not -gnatwa). - -- WARNING: There is a matching C declaration of this variable in fe.h + function Get_Warn_On_Questionable_Layout return Boolean is + (Warn_On_Questionable_Layout); + -- WARNING: There is a matching C declaration of this function in fe.h Warn_On_Record_Holes : Boolean := False; -- Warn when explicit record component clauses leave uncovered holes (gaps)