From patchwork Mon Oct 2 22:23:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lewis Hyatt X-Patchwork-Id: 1842327 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=VGiClhCl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RzwV502F7z1ypx for ; Tue, 3 Oct 2023 09:24:08 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 081A4385700B for ; Mon, 2 Oct 2023 22:24:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by sourceware.org (Postfix) with ESMTPS id 752A33858D33 for ; Mon, 2 Oct 2023 22:23:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 752A33858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-77428e40f71so22759285a.1 for ; Mon, 02 Oct 2023 15:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696285429; x=1696890229; 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=hHGPotvjxfpzMHfWxt8IUUJCCmt9himczjCvI4Zulpc=; b=VGiClhClDIHJ1U8Ib2bxVJpeBL9xwV9DqrwFBBitehS/bKIYHzh2Tfb3d0DkLiAxgh DgZIIYpoJlfwAUtrOheElQ/JAT3Kq9VlG4UKzQnZkc9UyPQIPoaOdUwYjG64G03a/i5E 4QcugwhW97kdLsnXNd1864JR/hI5Sf4tjm2w3nHIu7o8izAb/nyYgSHL0DzgXqaDLDgc yCZ6V8/dBRg9Fh9gzHCVgriRxgUTpY5tAJUzXbR4cAjNVjuYhPLVs682C6HhcDbi7Yc0 9T6AiJw8zE0C/YkWa4TtI1zFVNKpLPRh9wGGy32Uio1xk4G5OsLDEcmBqz3/nEtMc4Tt oRUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696285429; x=1696890229; 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=hHGPotvjxfpzMHfWxt8IUUJCCmt9himczjCvI4Zulpc=; b=svR7n/RV1Pvkb5lWAfqe+0Dh1qNRXxEBhVOtzCrL3s1S9lVTVQLOG983yTJcu7jSYA rsowAQwnK+u2tfaPp+39ALX6lUcVSTS5ajd4AZV9CqOqKOKaskj1ySc0nqpMedyXcwBk Eayb/RzX/s4cViwO2GlKFwZYVt2yM9sfJtKKuGRG9n5Z3yl7TUWx+rn/pHpqmYXHuTFd kf56KoTU0SiESFzoIzmoZ3PvLacJfqjSgsb+SOdYsX0KgANA9Zg3p9PZiJfTDHrjjfpt vs07h2PCM/DmNLUBNCjx/whOtYxGlFbQxNxjNKDnnxDaW4CV8c+Zx7Dap5n605WZVzSQ Ge0w== X-Gm-Message-State: AOJu0YzFb17ZCoTIQUyqcuEjBT2BbRoUcwzjc3zRYxTYQLgOXA25avMa pi4hzwu+Sgd0si3qJXt+alynNRPgo6Q= X-Google-Smtp-Source: AGHT+IHEjn+CQrHLtvfKaA2e+UJ7ll739MPNWobeZWM5WqcbYMFoRYTy9oEoWH989GmZwy25CAA+oQ== X-Received: by 2002:a0c:a998:0:b0:658:6d82:54bc with SMTP id a24-20020a0ca998000000b006586d8254bcmr15022173qvb.32.1696285429477; Mon, 02 Oct 2023 15:23:49 -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 c13-20020a0ca9cd000000b0065b079366a7sm7209987qvb.114.2023.10.02.15.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 15:23:48 -0700 (PDT) From: Lewis Hyatt To: gcc-patches@gcc.gnu.org Cc: Lewis Hyatt Subject: [PATCH] libcpp: testsuite: Add test for fixed _Pragma bug [PR82335] Date: Mon, 2 Oct 2023 18:23:44 -0400 Message-Id: <20231002222344.2714786-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, KAM_SHORT, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Hello- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82335 is another _Pragma-related bug that got fixed in GCC 12 but is still open. Before closing it out, I thought it would be good to add the testcase from that PR, which we don't have exactly in the testsuite already. Is it OK please? Thanks! -Lewis -- >8 -- This PR was fixed by r12-4797 and r12-5454. Add test coverage from the PR that is not represented elsewhere. gcc/testsuite/ChangeLog: PR preprocessor/82335 * c-c++-common/cpp/diagnostic-pragma-3.c: New test. --- .../c-c++-common/cpp/diagnostic-pragma-3.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/cpp/diagnostic-pragma-3.c diff --git a/gcc/testsuite/c-c++-common/cpp/diagnostic-pragma-3.c b/gcc/testsuite/c-c++-common/cpp/diagnostic-pragma-3.c new file mode 100644 index 00000000000..459dcec73b3 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cpp/diagnostic-pragma-3.c @@ -0,0 +1,37 @@ +/* This is like diagnostic-pragma-2.c, but handles the case where everything + is wrapped inside a macro, which previously caused additional issues tracked + in PR preprocessor/82335. */ + +/* { dg-do compile } */ +/* { dg-additional-options "-save-temps -Wattributes -Wtype-limits" } */ + +#define B _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wattributes\"") +#define E _Pragma("GCC diagnostic pop") + +#define X() B int __attribute((unknown_attr)) x; E +#define Y B int __attribute((unknown_attr)) y; E +#define WRAP(x) x + +void test1(void) +{ + WRAP(X()) + WRAP(Y) +} + +/* Additional test provided on the PR. */ +#define PRAGMA(...) _Pragma(#__VA_ARGS__) +#define PUSH_IGN(X) PRAGMA(GCC diagnostic push) PRAGMA(GCC diagnostic ignored X) +#define POP() PRAGMA(GCC diagnostic pop) +#define TEST(X, Y) \ + PUSH_IGN("-Wtype-limits") \ + int Y = (__typeof(X))-1 < 0; \ + POP() + +int test2() +{ + unsigned x; + TEST(x, i1); + WRAP(TEST(x, i2)) + return i1 + i2; +}