From patchwork Wed Oct 18 21:15:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lewis Hyatt X-Patchwork-Id: 155192 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp14388vqb; Wed, 18 Oct 2023 14:50:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyRczb+/4fxcHQM8x10N1ccqIerte4XCHR3kKEjgVI5YLBy1pP/ERZAXvJqWQ0RkJg0sIt X-Received: by 2002:a05:6214:b6d:b0:66d:476:8940 with SMTP id ey13-20020a0562140b6d00b0066d04768940mr660433qvb.46.1697665854665; Wed, 18 Oct 2023 14:50:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697665854; cv=pass; d=google.com; s=arc-20160816; b=GX4CA7A991fp2/3At90obpNVGMk920XsG3ZI8LUlPeOWxJkMWEYyfjwQu/yviRnMCY oqYtugip6POQQNxsEUDnnzg4cP7Gjt028w/KG/YuSDty2iYGel5a7zcsDvjPhA4T8mTV dCDU05Xb+0sLDjeeUobtYFS3t9VQtuVHIS8DwNp9reLVOylJscpN9yJsQPwItRejM0Oe AvuDpDdpogwtcWbYjYE4ssTo+gJA1yHoVksIZT01Sak+TCpyNcNkEu4kvdPPKN4BuHij kuHcF3A7unqaQauyd2mMn5iekX5PlSqDqP2NrV3GOpjbrxOwW06/No6WlhaUymMQIlaX VRRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=lE+OKN520osn0JyhwwnjJzrE5cTmFKVxzlfEkjE205o=; fh=nfBkqenZlXK8N3U+CwE1Ju+aGndKKEqCeWWaqIiAkr0=; b=MMqZ5sJlhn9/8DWK38YumvKqt8FBHKMyutGdKPOdlSOEn1hBzosZslP8XMas6E3BEE wMCrXjwv+zvJgLy9xaJ0uA6plb3HFa533cIiR1aK8OQxUeY3/J1QRd/GA1SH2H0ZiKoM 75hVY6itMznqvhT7Ie5CqMxjBlMmDu8k0szboPmU+6snKniEHBHSWUHtlOcxvJWf5r2v QdzUQ0air34MN/m3+yaETkv2Nl8scMweJKQ2gkRK3324Pw8eDU43iqu7XLXw6cH65ACt C0VjGZLXPkJwSrPjRVMWhnZd5pkISpthF8XqU0c4clD3K5+F8wmCfZQmp3IlM7aTla2Z KaKQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DoPQ2LL6; arc=pass (i=1); 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ld14-20020a056214418e00b0065b1f75bf6esi647249qvb.23.2023.10.18.14.50.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 14:50:54 -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=@gmail.com header.s=20230601 header.b=DoPQ2LL6; arc=pass (i=1); 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6251E3858422 for ; Wed, 18 Oct 2023 21:50:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by sourceware.org (Postfix) with ESMTPS id 5A1303858CDB for ; Wed, 18 Oct 2023 21:50:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5A1303858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5A1303858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::734 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697665828; cv=none; b=TphzFe8xkSxKA8y523BNgpCEDv5mhvGzskMXl0yUzWx3q7UcrXg64RJ+PFWnzS+3565VNaQIiNTk3rD6yVDGgXmTfNat2D3FfX2d/f2t2US9hOyvWzNIFF8Iii9aD7vG1mFmdXj5mIDfYmdbR2z2Cm5OgToDDSTJTyeOIe0Z23w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697665828; c=relaxed/simple; bh=zhi91DWMX6OaYdJwxZSZYQG1hf0NR7InHddZVmYt/jM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=iApmFjFUivh/cUCiRwqsT6IrcxMUZqtUIOH88TJhelrkJMx93obWgoJ4Hq7vR7VXq9uvQK4t0KU7GlRVvz+bEbUMzeaAwF5M9HjTzuVUeYzYKpz4Y/6czheFclE7dhfEMynIrhAFKFFSmGAeYvZvvJMCcvPd+EXsPGCridStgiw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-7789a4c01ddso34003185a.1 for ; Wed, 18 Oct 2023 14:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697665826; x=1698270626; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lE+OKN520osn0JyhwwnjJzrE5cTmFKVxzlfEkjE205o=; b=DoPQ2LL6qmCmw8eq53zvguWfPHhD/DF5yYSGVQH2WFFs5T3uEY5BwgP4f40vNAdDWQ oePceo1znvjgKlV/ekO/EOuQ37YNaBHQ2iZG1CADOYaJhpYT42j/RFhNrkIfqy6g5s/Y cAh5etoQNEbL0Ma9h6eew2+2P883hxCuvBFFYECxF+eN1hPqalbhAgY0GjoDbh1gWXAZ KhVMYUl2S7DX+d3BO46G+84B22PGPc84/scu3JKVRQhO8BJxdPpVyHvnmm3YR+/AYnD0 YVI/EmnV2kIZ4y5H1lc4OdUW7kl7RU4R4pu95mmDy+fgMVsc42laowc2errUc85q/AYZ 4TYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697665826; x=1698270626; 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=lE+OKN520osn0JyhwwnjJzrE5cTmFKVxzlfEkjE205o=; b=GkVpmtFbva5KzSZPJEXtOAVVb5DVIT4KHKphE7TSD+cWrUqMcx/NxFMzpsqZnJhulN /NAmdpiGUIMSZUf4fe06XQFzDdxehCczKniRMAR6Afk2zifa9Ce0rGPI2lCUdtqn4fUy Oap1m3NA0sMKbENAEscWJY7xWFMIJbsOqIJYiOzVR77o57ZzOyffOiaTODNybsE0T7CV Y0cwSkjt4DWOxHa65o7lZfmaSHeDJRi8NRH/oDD4PNcjGMHJsgUljgkukdc1Ky+XZtxN 1lZ41J1Zbph+Dz4jlLk23sKKUXk4wahwsA191t9rYhJOepODOscor8cW91KcTZuI7iE9 DkpA== X-Gm-Message-State: AOJu0Yzf1y5tjk9lp5X7BPYDWejqw4DuVrnvIRvduSlwzhK4XIcOmYzK rxgTD2RE1nAntKwXvyJyHpi1ib3MJV4= X-Received: by 2002:a05:620a:4147:b0:777:2aeb:7dfa with SMTP id k7-20020a05620a414700b007772aeb7dfamr523800qko.38.1697665826625; Wed, 18 Oct 2023 14:50:26 -0700 (PDT) Received: from localhost.localdomain (96-67-140-173-static.hfc.comcastbusiness.net. [96.67.140.173]) by smtp.gmail.com with ESMTPSA id o21-20020a05620a111500b0076f16e98851sm261861qkk.102.2023.10.18.14.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 14:50:26 -0700 (PDT) From: Lewis Hyatt To: gcc-patches@gcc.gnu.org Cc: Lewis Hyatt Subject: [PATCH] c++: Make -Wunknown-pragmas controllable by #pragma GCC diagnostic [PR89038] Date: Wed, 18 Oct 2023 17:15:42 -0400 Message-Id: <20231018211542.1516517-1-lhyatt@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3038.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780131671543877432 X-GMAIL-MSGID: 1780131671543877432 Hello- The PR points out that my fix for PR53431 was incomplete and did not handle -Wunknown-pragmas. This is a one-line fix to correct that, is it OK for trunk and for GCC 13 backport please? bootstrap + regtest all languages on x86-64 Linux. Thanks! -Lewis -- >8 -- 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. --- 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(-) create mode 100644 gcc/testsuite/c-c++-common/cpp/Wunknown-pragmas-1.c diff --git a/gcc/c-family/c-pragma.cc b/gcc/c-family/c-pragma.cc index 293311dd4ce..98dfb0f108b 100644 --- a/gcc/c-family/c-pragma.cc +++ b/gcc/c-family/c-pragma.cc @@ -963,7 +963,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 00000000000..fb58739e2bc --- /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" } */