gcc/libcpp
Nathan Sidwell 2a0225e478 preprocessor: EOF location is at end of file [PR95013]
My recent C++ parser change to pay attention to EOF location uncovered
a separate bug.  The preprocesor's EOF logic would set the EOF
location to be the beginning of the last line of text in the file --
not the 'line' after that, which contains no characters.  Mostly.
This fixes things so that when we attempt to read the last line of the
main file, we don't pop the buffer until the tokenizer has a chance to
create an EOF token with the correct location information.  It is then
responsible for popping the buffer.  As it happens, raw string literal
tokenizing contained a bug -- it would increment the line number
prematurely, because it cached buffer->cur in a local variable, but
checked buffer->cur before updating it to figure out if it was at end
of file.   We fix up that too.

The EOF token intentionally doesn't have a column number -- it's not a
position on a line, it's a non-existant line.

The testsuite churn is just correcting the EOF location diagnostics.

	libcpp/
	PR preprocessor/95013
	* lex.c (lex_raw_string): Process line notes before incrementing.
	Correct incrementing condition.  Adjust for new
	_cpp_get_fresh_line EOF behaviour.
	(_cpp_get_fresh_line): Do not pop buffer at EOF, increment line
	instead.
	(_cpp_lex_direct): Adjust for new _cpp_get_fresh_line behaviour.
	(cpp_directive_only_process): Assert we got a fresh line.
	* traditional.c (_cpp_read_logical_line_trad): Adjust for new
	_cpp_get_fresh_line behaviour.

	gcc/testsuite/
	* c-c++-common/goacc/pr79428-1.c: Adjust EOF diagnostic location.
	* c-c++-common/gomp/pr79428-2.c: Likewise.
	* g++.dg/cpp0x/decltype63.C: Likewise.
	* g++.dg/cpp0x/gen-attrs-64.C: Likewise.
	* g++.dg/cpp0x/pr68726.C: Likewise.
	* g++.dg/cpp0x/pr78341.C: Likewise.
	* g++.dg/cpp1y/pr65202.C: Likewise.
	* g++.dg/cpp1y/pr65340.C: Likewise.
	* g++.dg/cpp1y/pr68578.C: Likewise.
	* g++.dg/cpp1z/class-deduction44.C: Likewise.
	* g++.dg/diagnostic/unclosed-extern-c.C: Likewise.
	* g++.dg/diagnostic/unclosed-function.C: Likewise.
	* g++.dg/diagnostic/unclosed-namespace.C: Likewise.
	* g++.dg/diagnostic/unclosed-struct.C: Likewise.
	* g++.dg/ext/pr84598.C: Likewise.
	* g++.dg/other/switch4.C: Likewise.
	* g++.dg/parse/attr4.C: Likewise.
	* g++.dg/parse/cond4.C: Likewise.
	* g++.dg/parse/crash10.C: Likewise.
	* g++.dg/parse/crash18.C: Likewise.
	* g++.dg/parse/crash27.C: Likewise.
	* g++.dg/parse/crash34.C: Likewise.
	* g++.dg/parse/crash35.C: Likewise.
	* g++.dg/parse/crash52.C: Likewise.
	* g++.dg/parse/crash59.C: Likewise.
	* g++.dg/parse/crash61.C: Likewise.
	* g++.dg/parse/crash67.C: Likewise.
	* g++.dg/parse/error14.C: Likewise.
	* g++.dg/parse/error56.C: Likewise.
	* g++.dg/parse/invalid1.C: Likewise.
	* g++.dg/parse/parameter-declaration-1.C: Likewise.
	* g++.dg/parse/parser-pr28152-2.C: Likewise.
	* g++.dg/parse/parser-pr28152.C: Likewise.
	* g++.dg/parse/pr68722.C: Likewise.
	* g++.dg/pr46852.C: Likewise.
	* g++.dg/pr46868.C: Likewise.
	* g++.dg/template/crash115.C: Likewise.
	* g++.dg/template/crash43.C: Likewise.
	* g++.dg/template/crash90.C: Likewise.
	* g++.dg/template/error-recovery1.C: Likewise.
	* g++.dg/template/error57.C: Likewise.
	* g++.old-deja/g++.other/crash31.C: Likewise.
	* gcc.dg/empty-source-2.c: Likewise.
	* gcc.dg/empty-source-3.c: Likewise.
	* gcc.dg/noncompile/pr30552-3.c: Likewise.
	* gcc.dg/noncompile/pr35447-1.c: Likewise.
	* gcc.dg/pr20245-1.c: Likewise.
	* gcc.dg/pr28419.c: Likewise.
	* gcc.dg/rtl/truncated-rtl-file.c: Likewise.
	* gcc.dg/unclosed-init.c: Likewise.
	* obj-c++.dg/property/property-neg-6.mm: Likewise.
	* obj-c++.dg/syntax-error-10.mm: Likewise.
	* obj-c++.dg/syntax-error-8.mm: Likewise.
	* obj-c++.dg/syntax-error-9.mm: Likewise.
2020-05-12 13:40:29 -07:00
..
include preprocessor: Reimplement directives only processing, support raw literals. 2020-05-08 11:13:29 -07:00
po Update cpplib eo.po. 2020-04-06 21:34:20 +00:00
ChangeLog preprocessor: EOF location is at end of file [PR95013] 2020-05-12 13:40:29 -07:00
ChangeLog.jit
Makefile.in libcpp: Enable Intel CET on Intel CET enabled host for jit 2020-05-12 09:17:45 -07:00
aclocal.m4 libcpp: Enable Intel CET on Intel CET enabled host for jit 2020-05-12 09:17:45 -07:00
charset.c Update copyright years. 2020-01-01 12:51:42 +01:00
config.in Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
configure libcpp: Enable Intel CET on Intel CET enabled host for jit 2020-05-12 09:17:45 -07:00
configure.ac libcpp: Enable Intel CET on Intel CET enabled host for jit 2020-05-12 09:17:45 -07:00
directives.c preprocessor: Make __has_include a builtin macro [PR93452] 2020-01-28 08:02:17 -08:00
errors.c Update copyright years. 2020-01-01 12:51:42 +01:00
expr.c preprocessor: Make __has_include a builtin macro [PR93452] 2020-01-28 08:02:17 -08:00
files.c [PR 80005] Fix __has_include 2020-01-20 05:39:59 -08:00
generated_cpp_wcwidth.h Byte vs column awareness for diagnostic-show-locus.c (PR 49973) 2019-12-09 20:03:47 +00:00
identifiers.c [PR 80005] Fix __has_include 2020-01-20 05:39:59 -08:00
init.c preprocessor: Make __has_include a builtin macro [PR93452] 2020-01-28 08:02:17 -08:00
internal.h preprocessor: Reimplement directives only processing, support raw literals. 2020-05-08 11:13:29 -07:00
lex.c preprocessor: EOF location is at end of file [PR95013] 2020-05-12 13:40:29 -07:00
line-map.c Add diagnostic paths 2020-01-10 21:22:12 +00:00
location-example.txt PR preprocessor/83173: Enhance -fdump-internal-locations output 2018-11-27 16:04:31 +00:00
macro.c c++: Partially implement P1042R1: __VA_OPT__ wording clarifications [PR92319] 2020-02-14 09:04:14 +01:00
makeucnid.c Update copyright years. 2020-01-01 12:51:42 +01:00
mkdeps.c Work around array out of bounds warning in mkdeps 2020-01-16 11:09:24 +01:00
pch.c preprocessor: Make __has_include a builtin macro [PR93452] 2020-01-28 08:02:17 -08:00
symtab.c Update copyright years. 2020-01-01 12:51:42 +01:00
system.h Update copyright years. 2020-01-01 12:51:42 +01:00
traditional.c preprocessor: EOF location is at end of file [PR95013] 2020-05-12 13:40:29 -07:00
ucnid.h Update copyright years. 2020-01-01 12:51:42 +01:00
ucnid.tab Update copyright years. 2020-01-01 12:51:42 +01:00