1 /* { dg-do compile } */
2 /* { dg-additional-options "-Wreturn-type" } */
3
4 /* The location of the right brace within the macro expansion can be an adhoc
5 location, because the frontend attached custom data to it. In order for the
6 diagnostic pragma to correctly understand that the diagnostic pop occurs
7 after the function and not before, linemap_location_before_p needs to handle
8 adhoc locations within a macro map, which was broken until fixed by r10-325.
9 Verify that we get it right, both when the brace is a macro token and when it
10 is part of the macro expansion. */
11
12 #define ENDFUNC1 \
13 _Pragma("GCC diagnostic push") \
14 _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
15 } /* { dg-bogus {-Wreturn-type} } */ \
16 _Pragma("GCC diagnostic pop")
17
18 int f1 () {
19 ENDFUNC1 /* { dg-bogus {in expansion of macro 'ENDFUNC1' } } */
20
21 #define ENDFUNC2(term) \
22 _Pragma("GCC diagnostic push") \
23 _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
24 term /* { dg-bogus {in definition of macro 'ENDFUNC2'} } */ \
25 _Pragma("GCC diagnostic pop")
26
27 int f2 () {
28 ENDFUNC2(}) /* { dg-bogus {-Wreturn-type} } */