From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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-qt1-x832.google.com with SMTP id s18so7230124qtx.6 for ; Mon, 03 Oct 2022 15:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=8Fi/9FKwGpHmgpiSuTm/SzF+qgVWybzYmy3/4JD5Qic=; b=YeAFywbAMGyO6qqci/Twr5dq6PcI4F954ug2GrNobE2tl67As5Q3Fb8nEnSx5pXNiZ F4N33T0vaycgrFfJxhWxk6TrpWhdQLKeAovs8xBy4+YBjEO0R4Laa6vPF7tcLpzL1593 mpxkp+2I7aRJ6lQWSwT96mJfNOYz6/m/Ov4mIO2MNkkvp0q1lApFXN8zMSGAcCiVOya1 MWBUTYreIdHsadioruhUAQFvVszdmGDklmTOXY+9vEAhEdl6ypHifmbTAEn9RgfJw4A+ MhLzRK/FRNAS1ONJXSBSItQGm6yZz2HQt+n4ArbBy2isfmMCfAryZ/xJYEdj1rlfcieg zoPg== 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) From: Lewis Hyatt To: gcc-patches@gcc.gnu.org Cc: Lewis Hyatt 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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} } */