From: Lewis Hyatt <lhyatt@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: Lewis Hyatt <lhyatt@gmail.com>
Subject: [PATCH] diagnostics: Add test for fixed _Pragma location issue [PR91669]
Date: Mon, 3 Oct 2022 18:32:14 -0400 [thread overview]
Message-ID: <ead367999f6136b51ae6206184a1193864b234aa.1664836268.git.lhyatt@gmail.com> (raw)
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} } */
next reply other threads:[~2022-10-03 22:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-03 22:32 Lewis Hyatt [this message]
2022-10-04 0:54 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ead367999f6136b51ae6206184a1193864b234aa.1664836268.git.lhyatt@gmail.com \
--to=lhyatt@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).