Hi! Now that input_location can be adhoc location (if it represents a location range rather than a single loc and it is long enough), we need to avoid passing it to cpp_included_before which compares locations as numbers. This can't be done on the libcpp side, because cpp_included_before isn't called with the line_table parameter.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-01-05 Jakub Jelinek <ja...@redhat.com> PR c++/69145 * lex.c (handle_pragma_implementation): Pass LOCATION_LOCUS of input_location instead of input_location itself to cpp_included_before. * g++.dg/ext/pr69145-1.C: New test. * g++.dg/ext/pr69145-2-very-long-filename.cc: New file. * g++.dg/ext/pr69145-2.h: New file. --- gcc/cp/lex.c.jj 2016-01-04 14:55:57.000000000 +0100 +++ gcc/cp/lex.c 2016-01-05 12:27:36.056749882 +0100 @@ -408,7 +408,8 @@ handle_pragma_implementation (cpp_reader else { filename = TREE_STRING_POINTER (fname); - if (cpp_included_before (parse_in, filename, input_location)) + if (cpp_included_before (parse_in, filename, + LOCATION_LOCUS (input_location))) warning (0, "#pragma implementation for %qs appears after " "file is included", filename); } --- gcc/testsuite/g++.dg/ext/pr69145-1.C.jj 2016-01-05 12:22:58.206729760 +0100 +++ gcc/testsuite/g++.dg/ext/pr69145-1.C 2016-01-05 12:22:52.017818392 +0100 @@ -0,0 +1,4 @@ +// PR c++/69145 +// { dg-do compile } +#pragma implementation "pr69145-2-very-long-filename.cc" // { dg-bogus "appears after file is included" } +#include "pr69145-2-very-long-filename.cc" --- gcc/testsuite/g++.dg/ext/pr69145-2-very-long-filename.cc.jj 2016-01-05 12:23:47.151028824 +0100 +++ gcc/testsuite/g++.dg/ext/pr69145-2-very-long-filename.cc 2016-01-05 12:23:42.629093583 +0100 @@ -0,0 +1,3 @@ +// PR c++/69145 +// { dg-do compile } */ +#include "pr69145-2.h" --- gcc/testsuite/g++.dg/ext/pr69145-2.h.jj 2016-01-05 12:23:49.963988539 +0100 +++ gcc/testsuite/g++.dg/ext/pr69145-2.h 2016-01-05 12:06:42.000000000 +0100 @@ -0,0 +1,3 @@ +#ifndef PR69145_2_H +# define PR69145_2_H +#endif Jakub