From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp86.iad3b.emailsrvr.com (smtp86.iad3b.emailsrvr.com [146.20.161.86]) by sourceware.org (Postfix) with ESMTPS id F0BAB3857B81 for ; Sat, 30 Jul 2022 23:05:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F0BAB3857B81 X-Auth-ID: tom@honermann.net Received: by smtp19.relay.iad3b.emailsrvr.com (Authenticated sender: tom-AT-honermann.net) with ESMTPSA id 961994006F; Sat, 30 Jul 2022 19:05:22 -0400 (EDT) Message-ID: Date: Sat, 30 Jul 2022 19:05:22 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH 1/1] c++/106423: Fix pragma suppression of -Wc++20-compat diagnostics. Content-Language: en-US To: Joseph Myers Cc: gcc-patches@gcc.gnu.org References: <20220724043902.1777378-1-tom@honermann.net> <20220724043902.1777378-2-tom@honermann.net> From: Tom Honermann In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Classification-ID: f46c3635-5f38-47ba-aac3-a767f1e5fafb-1-1 X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, 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-List-Received-Date: Sat, 30 Jul 2022 23:05:25 -0000 On 7/27/22 7:09 PM, Joseph Myers wrote: > On Sun, 24 Jul 2022, Tom Honermann via Gcc-patches wrote: > >> Gcc's '#pragma GCC diagnostic' directives are processed in "early mode" >> (see handle_pragma_diagnostic_early) for the C++ frontend and, as such, >> require that the target diagnostic option be enabled for the preprocessor >> (see c_option_is_from_cpp_diagnostics). This change modifies the >> -Wc++20-compat option definition to register it as a preprocessor option >> so that its associated diagnostics can be suppressed. The changes also > There are lots of C++ warning options, all of which should support pragma > suppression regardless of whether they are relevant to the preprocessor or > not. Do they all need this kind of handling, or is it only -Wc++20-compat > that has some kind of problem? I had only checked -Wc++20-compat when working on the patch. I did some spot checking now and confirmed that suppression works as expected for C++ for at least the following warnings:   -Wuninitialized   -Warray-compare   -Wbool-compare   -Wtautological-compare   -Wterminate I don't know the diagnostic framework well. As best I can tell, this issue is specific to the -Wc++20-compat option and when the particular diagnostic is issued (e.g., during lexing as opposed to during parsing). The following call chains appear to be relevant.   cp_lexer_new_main -> cp_lexer_handle_early_pragma -> c_invoke_early_pragma_handler   cp_parser_* -> cp_parser_pragma -> c_invoke_pragma_handler   (where * might be "declaration", "toplevel_declaration", "class_head", "objc_interstitial_code", ...) The -Wc++20-compat enabled warning regarding new keywords in C++20 is issued from cp_lexer_get_preprocessor_token. Tom.