From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2108) id 26D013858D28; Thu, 19 Oct 2023 16:59:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26D013858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697734747; bh=D+DmP78NPwmvSrWkCqXNZzCGQSXAA2yQ043IrHvZ0Hc=; h=From:To:Subject:Date:From; b=dv7Y3zf3vEYu4II68eCSrE0dMScJHQjRg78xUVNPM9G0rO6x8apo7cdZTRHu2jfHo sF3/xVEUO8rnAxV+Sw8ZcdfsBG03tpncwx61YwR/UE2gYabqbsS5uzH0/jEMpFmHZX cFQb13xrbqqlgaGu7gIBbwZAEIw8Nxjiqx48ZZ/Q= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Lewis Hyatt To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-7964] c++: Make -Wunknown-pragmas controllable by #pragma GCC diagnostic [PR89038] X-Act-Checkin: gcc X-Git-Author: Lewis Hyatt X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: 8d7250fa7d61892a27c59f53b025581e33477311 X-Git-Newrev: 7a1de35f9cdc13098375baa277496147be271dd3 Message-Id: <20231019165907.26D013858D28@sourceware.org> Date: Thu, 19 Oct 2023 16:59:07 +0000 (GMT) List-Id: https://gcc.gnu.org/g:7a1de35f9cdc13098375baa277496147be271dd3 commit r13-7964-g7a1de35f9cdc13098375baa277496147be271dd3 Author: Lewis Hyatt Date: Wed Oct 18 12:37:08 2023 -0400 c++: Make -Wunknown-pragmas controllable by #pragma GCC diagnostic [PR89038] As noted on the PR, commit r13-1544, the fix for PR53431, did not handle the specific case of -Wunknown-pragmas, because that warning is issued during preprocessing, but not by libcpp directly (it comes from the cb_def_pragma callback). Address that by handling this pragma in addition to libcpp pragmas during the early pragma handler. gcc/c-family/ChangeLog: PR c++/89038 * c-pragma.cc (handle_pragma_diagnostic_impl): Handle -Wunknown-pragmas during early processing. gcc/testsuite/ChangeLog: PR c++/89038 * c-c++-common/cpp/Wunknown-pragmas-1.c: New test. Diff: --- gcc/c-family/c-pragma.cc | 3 ++- gcc/testsuite/c-c++-common/cpp/Wunknown-pragmas-1.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/c-family/c-pragma.cc b/gcc/c-family/c-pragma.cc index 0d2b333cebbe..d660ff1d922a 100644 --- a/gcc/c-family/c-pragma.cc +++ b/gcc/c-family/c-pragma.cc @@ -1006,7 +1006,8 @@ handle_pragma_diagnostic_impl () /* option_string + 1 to skip the initial '-' */ unsigned int option_index = find_opt (data.option_str + 1, lang_mask); - if (early && !c_option_is_from_cpp_diagnostics (option_index)) + if (early && !(c_option_is_from_cpp_diagnostics (option_index) + || option_index == OPT_Wunknown_pragmas)) return; if (option_index == OPT_SPECIAL_unknown) diff --git a/gcc/testsuite/c-c++-common/cpp/Wunknown-pragmas-1.c b/gcc/testsuite/c-c++-common/cpp/Wunknown-pragmas-1.c new file mode 100644 index 000000000000..fb58739e2bce --- /dev/null +++ b/gcc/testsuite/c-c++-common/cpp/Wunknown-pragmas-1.c @@ -0,0 +1,13 @@ +/* PR c++/89038 */ +/* { dg-additional-options "-Wunknown-pragmas" } */ + +#pragma oops /* { dg-warning "-:-Wunknown-pragmas" } */ +#pragma GGC diagnostic push /* { dg-warning "-:-Wunknown-pragmas" } */ +#pragma GCC diagnostics push /* { dg-warning "-:-Wunknown-pragmas" } */ + +/* Test we can disable the warnings. */ +#pragma GCC diagnostic ignored "-Wunknown-pragmas" + +#pragma oops /* { dg-bogus "-:-Wunknown-pragmas" } */ +#pragma GGC diagnostic push /* { dg-bogus "-:-Wunknown-pragmas" } */ +#pragma GCC diagnostics push /* { dg-bogus "-:-Wunknown-pragmas" } */