Commit 6f41f92b by Bernd Edlinger Committed by Bernd Edlinger

re PR c/69558 (glib2 warning pragmas stopped working)

libcpp:
2018-07-18  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR 69558
        * macro.c (enter_macro_context): Change the location info for builtin
        macros and _Pragma from location of the closing parenthesis to location
        of the macro expansion point.

testsuite:
2018-07-18  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR 69558
        * c-c++-common/cpp/diagnostic-pragma-2.c: New test.
        * c-c++-common/pr69558.c: Remove xfail.
        * gcc.dg/cpp/builtin-macro-1.c: Adjust test expectations.
        * gcc.dg/pr61817-1.c: Likewise.
        * gcc.dg/pr61817-2.c: Likewise.
        * g++.dg/plugin/pragma_plugin.c: Warn at expansion_point_location.

From-SVN: r262861
parent 6457b1f0
2018-07-18 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR 69558
* c-c++-common/cpp/diagnostic-pragma-2.c: New test.
* c-c++-common/pr69558.c: Remove xfail.
* gcc.dg/cpp/builtin-macro-1.c: Adjust test expectations.
* gcc.dg/pr61817-1.c: Likewise.
* gcc.dg/pr61817-2.c: Likewise.
* g++.dg/plugin/pragma_plugin.c: Warn at expansion_point_location.
2018-07-18 Janus Weil <janus@gcc.gnu.org> 2018-07-18 Janus Weil <janus@gcc.gnu.org>
PR fortran/85599 PR fortran/85599
......
/* { dg-do compile } */
#define B _Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wattributes\"")
#define E _Pragma("GCC diagnostic pop")
#define X() B int __attribute((unknown_attr)) x; E /* { dg-bogus "attribute directive ignored" } */
#define Y B int __attribute((unknown_attr)) y; E /* { dg-bogus "attribute directive ignored" } */
void test1(void)
{
X() /* { dg-bogus "in expansion of macro" } */
Y /* { dg-bogus "in expansion of macro" } */
}
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
_Pragma ("GCC diagnostic pop") _Pragma ("GCC diagnostic pop")
#define C(x) \ #define C(x) \
A \ A \
static inline void bar (void) { x (); } /* { dg-bogus "in definition of|deprecated" "" { xfail { c++ } } } */ \ static inline void bar (void) { x (); } /* { dg-bogus "in definition of|deprecated" "" } */ \
B B
__attribute__((deprecated)) void foo (void); /* { dg-bogus "declared here" "" { xfail { c++ } } } */ __attribute__((deprecated)) void foo (void); /* { dg-bogus "declared here" "" } */
C (foo) /* { dg-bogus "is deprecated" } */ C (foo) /* { dg-bogus "is deprecated" } */
...@@ -33,12 +33,13 @@ handle_pragma_sayhello (cpp_reader *dummy) ...@@ -33,12 +33,13 @@ handle_pragma_sayhello (cpp_reader *dummy)
} }
if (TREE_STRING_LENGTH (message) > 1) if (TREE_STRING_LENGTH (message) > 1)
{ {
location_t loc = expansion_point_location (input_location);
if (cfun) if (cfun)
warning (OPT_Wpragmas, warning_at (loc, OPT_Wpragmas,
"%<pragma GCCPLUGIN sayhello%> from function %qE: %s", "%<pragma GCCPLUGIN sayhello%> from function %qE: %s",
cfun->decl, TREE_STRING_POINTER (message)); cfun->decl, TREE_STRING_POINTER (message));
else else
warning (OPT_Wpragmas, warning_at (loc, OPT_Wpragmas,
"%<pragma GCCPLUGIN sayhello%> outside of function: %s", "%<pragma GCCPLUGIN sayhello%> outside of function: %s",
TREE_STRING_POINTER (message)); TREE_STRING_POINTER (message));
} }
......
/* Origin PR preprocessor/64803 /* Origin PR preprocessor/64803
This test ensures that the value the __LINE__ macro expands to is This test ensures that the value the __LINE__ macro expands to is
constant and corresponds to the line of the closing parenthesis of constant and corresponds to the line of the macro expansion point
the top-most function-like macro expansion it's part of. the function-like macro expansion it's part of.
{ dg-do run } { dg-do run }
{ do-options -no-integrated-cpp } */ { do-options -no-integrated-cpp } */
...@@ -19,8 +19,8 @@ main() ...@@ -19,8 +19,8 @@ main()
M(a M(a
); );
assert(L20 == 20); /* 20 is the line number of the assert(L19 == 19); /* 19 is the line number of the
closing parenthesis of the macro expansion point of the
invocation of the M macro. Please invocation of the M macro. Please
adjust in case the layout of this adjust in case the layout of this
file changes. */ file changes. */
......
...@@ -14,6 +14,6 @@ enum { ...@@ -14,6 +14,6 @@ enum {
) )
}; };
A(a == 15); A(a == 10);
A(b == 15); A(b == 10);
A(c == 15); A(c == 10);
...@@ -14,6 +14,6 @@ enum { ...@@ -14,6 +14,6 @@ enum {
) )
}; };
A(a == 15); A(a == 10);
A(b == 15); A(b == 10);
A(c == 15); A(c == 14);
2018-07-18 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR 69558
* macro.c (enter_macro_context): Change the location info for builtin
macros and _Pragma from location of the closing parenthesis to location
of the macro expansion point.
2018-07-17 Jason Franklin <j_fra@fastmail.us> 2018-07-17 Jason Franklin <j_fra@fastmail.us>
Jakub Jelinek <jakub@redhat.com> Jakub Jelinek <jakub@redhat.com>
......
...@@ -1410,29 +1410,25 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node, ...@@ -1410,29 +1410,25 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node,
pfile->about_to_expand_macro_p = false; pfile->about_to_expand_macro_p = false;
/* Handle built-in macros and the _Pragma operator. */ /* Handle built-in macros and the _Pragma operator. */
{ {
source_location loc, expand_loc; source_location expand_loc;
if (/* The top-level macro invocation that triggered the expansion if (/* The top-level macro invocation that triggered the expansion
we are looking at is with a standard macro ...*/ we are looking at is with a standard macro ... */
!(pfile->top_most_macro_node->flags & NODE_BUILTIN) !(pfile->top_most_macro_node->flags & NODE_BUILTIN)
/* ... and it's a function-like macro invocation. */ /* ... and it's a function-like macro invocation, */
&& pfile->top_most_macro_node->value.macro->fun_like) && pfile->top_most_macro_node->value.macro->fun_like
{ /* ... and we are tracking the macro expansion. */
&& CPP_OPTION (pfile, track_macro_expansion))
/* Then the location of the end of the macro invocation is the /* Then the location of the end of the macro invocation is the
location of the closing parenthesis. */ location of the expansion point of this macro. */
loc = pfile->cur_token[-1].src_loc; expand_loc = location;
expand_loc = loc;
}
else else
{
/* Otherwise, the location of the end of the macro invocation is /* Otherwise, the location of the end of the macro invocation is
the location of the expansion point of that top-level macro the location of the expansion point of that top-level macro
invocation. */ invocation. */
loc = location;
expand_loc = pfile->invocation_location; expand_loc = pfile->invocation_location;
}
return builtin_macro (pfile, node, loc, expand_loc); return builtin_macro (pfile, node, location, expand_loc);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment