From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2108) id 138253858D38; Tue, 4 Oct 2022 01:29:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 138253858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664846967; bh=BE0Hv7eW/PezRF8ykcaZSLzIofURWqVnOzk44mbB40w=; h=From:To:Subject:Date:From; b=DjbEPKpqbwN94WC7whUx36A3iX7bM+qFuBB2tf4/NUoKHflvzt5IgGrd6TytJ1jhW ry3CR+zpdTBESThOWk5BLQkrMd4ZhRJQS8bNxxDKxOfbhYHRraoFSEGwUfC/mVA6CY tcJCQmujr/CLlH44S8quAGzLDEz3KuysY78aWr5E= 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-3051] diagnostics: Add test for fixed _Pragma location issue [PR91669] X-Act-Checkin: gcc X-Git-Author: Lewis Hyatt X-Git-Refname: refs/heads/master X-Git-Oldrev: 69fd6dcc32c92132010b7d1fe4c2a37bc045d524 X-Git-Newrev: 70e3f71a279856eabf99bbc92c0345c3ad20b615 Message-Id: <20221004012927.138253858D38@sourceware.org> Date: Tue, 4 Oct 2022 01:29:26 +0000 (GMT) List-Id: https://gcc.gnu.org/g:70e3f71a279856eabf99bbc92c0345c3ad20b615 commit r13-3051-g70e3f71a279856eabf99bbc92c0345c3ad20b615 Author: Lewis Hyatt Date: Sat Oct 1 12:05:13 2022 -0400 diagnostics: Add test for fixed _Pragma location issue [PR91669] 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. Diff: --- gcc/testsuite/c-c++-common/pr91669.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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} } */