This changes from: pragma-diag-3.c:2:9: warning: missing [error|warning|ignored] after ‘#pragma GCC diagnostic’ [-Wpragmas] #pragma GCC diagnostic /* { dg-warning "24:missing" "missing" { xfail *-*-* } } */ ^ pragma-diag-3.c:4:9: warning: expected [error|warning|ignored|push|pop] after ‘#pragma GCC diagnostic’ [-Wpragmas] #pragma GCC diagnostic warn /* { dg-warning "24:expected" } */ ^ pragma-diag-3.c:6:9: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas] #pragma GCC diagnostic ignored "-Wfoo" /* { dg-warning "32:unknown" } */ ^ to: pragma-diag-3.c:2:83: warning: missing [error|warning|ignored|push|pop] after ‘#pragma GCC diagnostic’ [-Wpragmas] pragma-diag-3.c:4:24: warning: expected [error|warning|ignored|push|pop] after ‘#pragma GCC diagnostic’ [-Wpragmas] #pragma GCC diagnostic warn /* { dg-warning "24:expected" } */ ^ pragma-diag-3.c:6:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas] #pragma GCC diagnostic ignored "-Wfoo" /* { dg-warning "32:unknown" } */ ^ which is a clear improvement except for the fact that CPP_PRAGMA_EOL tokens do not have a valid location. I think this is a bug and will open a PR. Of course, this opens the door to giving better locations for all diagnostics in c-pragma.c, but I'll leave that for the future. Bootstrapped and regression tested on x86_64-linux-gnu. OK? gcc/cp/ChangeLog: 2015-05-25 Manuel López-Ibáñez * parser.c (pragma_lex): Add loc argument. Rearrange the code to make it more similar to the C version. gcc/c-family/ChangeLog: 2015-05-25 Manuel López-Ibáñez * c-pragma.c (handle_pragma_diagnostic): Use explicit location when warning. * c-pragma.h (pragma_lex): Add optional loc argument. gcc/c/ChangeLog: 2015-05-25 Manuel López-Ibáñez * c-parser.c (pragma_lex): Add loc argument. gcc/testsuite/ChangeLog: 2015-05-25 Manuel López-Ibáñez * gcc.dg/pragma-diag-3.c: New test.