c++: EOF location [PR 96045]
authorNathan Sidwell <nathan@acm.org>
Wed, 23 Dec 2020 22:17:17 +0000 (14:17 -0800)
committerNathan Sidwell <nathan@acm.org>
Wed, 23 Dec 2020 22:26:50 +0000 (14:26 -0800)
commit745f22096c3a2a5e63d5bab1fb079e2c437cf9bc
tree536cc4b67f0c8e27bf3dd5e2d328fdcd5d4c9d0e
parent612cf351c700b6216209e3f3f4b3a0959bf2dee7
c++: EOF location [PR 96045]

Setting the EOF token location to be the start of a line just after
the ending newline is not most helpful.  While that location is
probably the right place to report preprocessing and lexing issues,
when parsing, the location just after the last token is better.  That
way we get to point at some actual text.  Setting the location from
the previous token has the advantage over just setting the location to
be the end of the final line, in that any ending comments do not get
considered, which I think is better.

PR c++/96045
gcc/cp/
* parser.c (cp_lexer_new_main): Adjust EOF token location.
gcc/testsuite/
* g++.dg/diagnostic/pr96045-1.C: New.
* g++.dg/diagnostic/pr96045-2.C: New.
* g++.dg/diagnostic/pr96045-3.C: New.
* c-c++-common/goacc/pr79428-1.c: Adjust EOF diagnostic location.
* c-c++-common/gomp/pr79428-2.c: Likewise
* c-c++-common/raw-string-6.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/parse/pr96258.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
48 files changed:
gcc/cp/parser.c
gcc/testsuite/c-c++-common/goacc/pr79428-1.c
gcc/testsuite/c-c++-common/gomp/pr79428-2.c
gcc/testsuite/c-c++-common/raw-string-6.c
gcc/testsuite/g++.dg/cpp0x/decltype63.C
gcc/testsuite/g++.dg/cpp0x/gen-attrs-64.C
gcc/testsuite/g++.dg/cpp0x/pr68726.C
gcc/testsuite/g++.dg/cpp0x/pr78341.C
gcc/testsuite/g++.dg/cpp1y/pr65202.C
gcc/testsuite/g++.dg/cpp1y/pr65340.C
gcc/testsuite/g++.dg/cpp1y/pr68578.C
gcc/testsuite/g++.dg/cpp1z/class-deduction44.C
gcc/testsuite/g++.dg/diagnostic/pr96045-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/diagnostic/pr96045-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/diagnostic/pr96045-3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/diagnostic/unclosed-extern-c.C
gcc/testsuite/g++.dg/diagnostic/unclosed-function.C
gcc/testsuite/g++.dg/diagnostic/unclosed-namespace.C
gcc/testsuite/g++.dg/diagnostic/unclosed-struct.C
gcc/testsuite/g++.dg/ext/pr84598.C
gcc/testsuite/g++.dg/other/switch4.C
gcc/testsuite/g++.dg/parse/attr4.C
gcc/testsuite/g++.dg/parse/cond4.C
gcc/testsuite/g++.dg/parse/crash10.C
gcc/testsuite/g++.dg/parse/crash18.C
gcc/testsuite/g++.dg/parse/crash27.C
gcc/testsuite/g++.dg/parse/crash34.C
gcc/testsuite/g++.dg/parse/crash35.C
gcc/testsuite/g++.dg/parse/crash52.C
gcc/testsuite/g++.dg/parse/crash59.C
gcc/testsuite/g++.dg/parse/crash61.C
gcc/testsuite/g++.dg/parse/crash67.C
gcc/testsuite/g++.dg/parse/error14.C
gcc/testsuite/g++.dg/parse/error56.C
gcc/testsuite/g++.dg/parse/invalid1.C
gcc/testsuite/g++.dg/parse/parameter-declaration-1.C
gcc/testsuite/g++.dg/parse/parser-pr28152-2.C
gcc/testsuite/g++.dg/parse/parser-pr28152.C
gcc/testsuite/g++.dg/parse/pr68722.C
gcc/testsuite/g++.dg/parse/pr96258.C
gcc/testsuite/g++.dg/pr46852.C
gcc/testsuite/g++.dg/pr46868.C
gcc/testsuite/g++.dg/template/crash115.C
gcc/testsuite/g++.dg/template/crash43.C
gcc/testsuite/g++.dg/template/crash90.C
gcc/testsuite/g++.dg/template/error-recovery1.C
gcc/testsuite/g++.dg/template/error57.C
gcc/testsuite/g++.old-deja/g++.other/crash31.C