From patchwork Mon Oct 3 22:32:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lewis Hyatt X-Patchwork-Id: 58316 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 112DD385841F for ; Mon, 3 Oct 2022 22:33:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 112DD385841F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664836410; bh=8Fi/9FKwGpHmgpiSuTm/SzF+qgVWybzYmy3/4JD5Qic=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=D6hPSJF/PotJyYPUiLET3UqRWiINsnky8CfpAmchterpVBkeWu6mbU8d1dg2Yw41Q olKYGOTl3MVMa3YFaa2EfI7yevN564+E5ibM3uNtia1CZThCDjvCtcdi+uYPGJuC8+ PzntX9U0e31dUudbPX1W98lN92UpPlJq/hyfHMvg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by sourceware.org (Postfix) with ESMTPS id 3AAFA3858D1E for ; Mon, 3 Oct 2022 22:32:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3AAFA3858D1E Received: by mail-qt1-x832.google.com with SMTP id s18so7230124qtx.6 for ; Mon, 03 Oct 2022 15:32:28 -0700 (PDT) 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; bh=8Fi/9FKwGpHmgpiSuTm/SzF+qgVWybzYmy3/4JD5Qic=; b=6FkUAdBgR7KwSv1hvLCcxookXbtmBSYCKU+ZsuYxWQNv7S67GnfCogNm/zRNPZ7a22 jHKcXK8opaHU+ARig1J/7ttZjmFYqaPoSvzzcKDG4tObiUADpmFWJkrGe+jOjUix8yBs QLxYrLZc3Wr0I/PK9cZPVJEOvt4vttkeYxicfx3mV2opDTIb+nnHi+JDuXg7Gxd3DpHJ VJuba8/QqJSjlCfZAu/eQv64kjkAs/9VQKVf85AvrgUk3Sp1AgFH1GSuYEA0QSVf4D7a LDrU9080LLzo9E+VSCKTi0aWpDMO4sgIJqHDikQK1QDjsw0AORIC8aUESrCtRktM8Uuq mZDw== X-Gm-Message-State: ACrzQf0QzFIclhRa04FfivBkuWdnWqRM7TsiXbXtrTm7KGTUPMOOuS4q MzHgsWEum6Vz5F/njn+OjhIQ0886TbY= X-Google-Smtp-Source: AMsMyM7pPGOmdro3Fbvj8YfLzlKNWxCVPnY8/xLbCNQNzygup/dUNUKWCEk63/4X1CBdz7Nhrl9/mg== X-Received: by 2002:a05:622a:164d:b0:35c:c465:911b with SMTP id y13-20020a05622a164d00b0035cc465911bmr17091249qtj.250.1664836347506; Mon, 03 Oct 2022 15:32:27 -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 r17-20020ac85c91000000b0035d4a6b8413sm10655449qta.71.2022.10.03.15.32.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 15:32:26 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] diagnostics: Add test for fixed _Pragma location issue [PR91669] Date: Mon, 3 Oct 2022 18:32:14 -0400 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3039.0 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Lewis Hyatt via Gcc-patches From: Lewis Hyatt Reply-To: Lewis Hyatt Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This PR related to _Pragma locations and diagnostic pragmas was fixed by a combination of r10-325 and r13-1596. Add missing test coverage. gcc/testsuite/ChangeLog: PR c/91669 * c-c++-common/pr91669.c: New test. --- Notes: Hello- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91669#c4 The above PR was already fixed, but I'd like to add missing test coverage before closing it. Does this look OK please? Thanks! -Lewis gcc/testsuite/c-c++-common/pr91669.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/pr91669.c diff --git a/gcc/testsuite/c-c++-common/pr91669.c b/gcc/testsuite/c-c++-common/pr91669.c new file mode 100644 index 00000000000..1070751ed2e --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr91669.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Wreturn-type" } */ + +/* The location of the right brace within the macro expansion can be an adhoc + location, because the frontend attached custom data to it. In order for the + diagnostic pragma to correctly understand that the diagnostic pop occurs + after the function and not before, linemap_location_before_p needs to handle + adhoc locations within a macro map, which was broken until fixed by r10-325. + Verify that we get it right, both when the brace is a macro token and when it + is part of the macro expansion. */ + +#define ENDFUNC1 \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ + } /* { dg-bogus {-Wreturn-type} } */ \ + _Pragma("GCC diagnostic pop") + +int f1 () { +ENDFUNC1 /* { dg-bogus {in expansion of macro 'ENDFUNC1' } } */ + +#define ENDFUNC2(term) \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ + term /* { dg-bogus {in definition of macro 'ENDFUNC2'} } */ \ + _Pragma("GCC diagnostic pop") + +int f2 () { +ENDFUNC2(}) /* { dg-bogus {-Wreturn-type} } */