aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorLewis Hyatt <lhyatt@gmail.com>2022-10-01 12:05:13 -0400
committerLewis Hyatt <lhyatt@gmail.com>2022-10-03 21:12:47 -0400
commit70e3f71a279856eabf99bbc92c0345c3ad20b615 (patch)
tree1b25c0d309390da0d1bb6445adddc8b742f52bc7 /gcc
parent69fd6dcc32c92132010b7d1fe4c2a37bc045d524 (diff)
downloadgcc-70e3f71a279856eabf99bbc92c0345c3ad20b615.zip
gcc-70e3f71a279856eabf99bbc92c0345c3ad20b615.tar.gz
gcc-70e3f71a279856eabf99bbc92c0345c3ad20b615.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/c-c++-common/pr91669.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/pr91669.c b/gcc/testsuite/c-c++-common/pr91669.c
new file mode 100644
index 0000000..1070751e
--- /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} } */