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.
This commit is contained in:
parent
27c3d986c4
commit
2a0225e478
|
@ -1,3 +1,61 @@
|
|||
2020-05-12 Nathan Sidwell <nathan@acm.org>
|
||||
|
||||
PR preprocessor/95013
|
||||
* 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 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c++/95074
|
||||
|
|
|
@ -3,4 +3,6 @@
|
|||
void
|
||||
foo ()
|
||||
{
|
||||
#pragma acc routine /* { dg-error ".#pragma acc routine. must be at file scope|expected" } */
|
||||
#pragma acc routine /* { dg-error ".#pragma acc routine. must be at file scope" } */
|
||||
// { dg-error "expected" "end" { target c } .-1 }
|
||||
// { dg-error "-:expected" "end" { target c++ } .+1 }
|
||||
|
|
|
@ -4,4 +4,6 @@ void
|
|||
foo ()
|
||||
{
|
||||
#pragma omp sections
|
||||
#pragma omp section /* { dg-error "'#pragma omp section' may only be used in '#pragma omp sections' construct|not allowed|expected" } */
|
||||
#pragma omp section /* { dg-error "'#pragma omp section' may only be used in '#pragma omp sections' construct|not allowed" } */
|
||||
// { dg-error "expected" "end" { target c } .-1 }
|
||||
// { dg-error "-:expected" "end" { target c++ } .+1 }
|
||||
|
|
|
@ -5,4 +5,4 @@ template<typename T>
|
|||
class C{
|
||||
T t;
|
||||
decltype(t)::a:: // { dg-error "expected" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
// { dg-do compile { target c++11 } }
|
||||
|
||||
namespace alignas() N {} // { dg-error "expected" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -5,4 +5,4 @@ template <typename> struct A {
|
|||
template <typename... _Args>
|
||||
using __has_construct typename __construct_helper<_Args...>::type; // { dg-error "expected" }
|
||||
} struct : A<int> { // { dg-error "expected" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
// { dg-do compile { target c++11 } }
|
||||
|
||||
alignas (alignas double // { dg-error "expected" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -25,4 +25,4 @@ int main()
|
|||
foo<ns::bar> f;
|
||||
adl::swap(f, f) // { dg-error "expected ';'" }
|
||||
}
|
||||
// { dg-error "-:expected '.'" "expected end of namespace" }
|
||||
// { dg-error "-:expected '.'" "expected end of namespace" { target *-*-* } .+1 }
|
||||
|
|
|
@ -16,4 +16,5 @@ struct traverse {
|
|||
};
|
||||
}
|
||||
auto &traverse = constant < functors :: traverse > ;
|
||||
operator()()->decltype(traverse(0, 0)) // { dg-error "no match|expected" }
|
||||
operator()()->decltype(traverse(0, 0))// { dg-error "no match" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// { dg-do compile { target c++14 } }
|
||||
|
||||
template <typename> struct bar foo; template <> struct foo<>: // { dg-error "class template|expected" }
|
||||
template <typename> struct bar foo; template <> struct foo<>: // { dg-error "class template" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
|
||||
template <typename> struct A;
|
||||
template <typename> struct B : A < B { , // { dg-error "" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -10,4 +10,4 @@ void bar (void);
|
|||
|
||||
void test (void);
|
||||
// { message "12: to match this '.'" "" { target *-*-* } open_extern_c }
|
||||
/* { dg-error "-:expected '.' at end of input" } */
|
||||
/* { dg-error "-:expected '.' at end of input" "" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
void test (void)
|
||||
{ /* { dg-message "1: to match this '.'" } */
|
||||
int filler;
|
||||
/* { dg-error "-:expected '.' at end of input" } */
|
||||
/* { dg-error "-:expected '.' at end of input" "" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
namespace unclosed { /* { dg-message "20: to match this '.'" } */
|
||||
int filler;
|
||||
/* { dg-error "-:expected '.' at end of input" } */
|
||||
/* { dg-error "-:expected '.' at end of input" "" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
struct unclosed { /* { dg-message "17: to match this '.'" } */
|
||||
int dummy;
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// { dg-options "-fpermissive -w" }
|
||||
|
||||
template<int b> __attribute__ a([] { class c, __attribute__(vector_size(operator+()))) d; // { dg-error "" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -4,4 +4,4 @@ class a b; // { dg-error "aggregate" }
|
|||
void c() {
|
||||
switch () // { dg-error "expected" }
|
||||
case b // { dg-error "expected" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// PR c++/93684 - ICE-on-invalid with broken attribute.
|
||||
|
||||
[[a:: // { dg-error "expected|expected" }
|
||||
[[a:: // { dg-error "expected" }
|
||||
// { dg-error "-:expected" "" { target c++14 } .+1 }
|
||||
|
|
|
@ -4,3 +4,4 @@
|
|||
void foo()
|
||||
{
|
||||
if (struct A{}// { dg-error "types may not be defined|expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -9,4 +9,4 @@ class
|
|||
{
|
||||
typename::
|
||||
; // { dg-error "expected" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
// PR 18095: ICE
|
||||
// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
|
||||
|
||||
struct A // { dg-error "-:expected" }
|
||||
struct A // { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Bug: 23225
|
||||
|
||||
void Dispatcher()
|
||||
(__builtin_offsetof (ArgsType, largeMsgLen)) // { dg-error "initialize|end of input" }
|
||||
(__builtin_offsetof (ArgsType, largeMsgLen)) // { dg-error "initialize" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -3,4 +3,5 @@
|
|||
|
||||
void foo()
|
||||
{
|
||||
namespace N { /* { dg-error "is not allowed|at end of input" } */
|
||||
namespace N { /* { dg-error "is not allowed" } */
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
struct a {};
|
||||
|
||||
class foo : public a, a // { dg-error "duplicate base" }
|
||||
{ // { dg-error "-:at end of input" }
|
||||
{ // { dg-error "-:at end of input" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// PR c++/39053
|
||||
|
||||
void foo() = // { dg-error "initialized|expected" }
|
||||
void foo() = // { dg-error "initialized" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// PR c++/53003
|
||||
|
||||
struct A{ void a{} return b // { dg-error "16:function definition" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
struct pair { constexpr pair (const) : }; // { dg-error "" }
|
||||
template <0> make_pair () {} // { dg-error "" }
|
||||
pair prefix[] = { 0, make_pair } // { dg-error "" }
|
||||
// { dg-error "-:expected" "" { target c++11 } }
|
||||
// { dg-error "-:expected" "" { target c++11 } .+1 }
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
class x0;
|
||||
template <x1> x2() { // { dg-error "declared|type" }
|
||||
x0 x3 = x3. // { dg-error "incomplete type" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -20,4 +20,4 @@ struct X
|
|||
// }
|
||||
|
||||
}; // { dg-error "1:expected primary-expression before '.' token" "primary" }
|
||||
// { dg-error "-:expected" "at end of input" }
|
||||
// { dg-error "-:expected" "at end of input" { target *-*-* } .+1 }
|
||||
|
|
|
@ -4,4 +4,4 @@ template <0> int __copy_streambufs_eof; // { dg-error "" }
|
|||
class {
|
||||
// { dg-error "forbids" "" { target *-*-* } .+1 }
|
||||
friend __copy_streambufs_eof <> ( // { dg-error "" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
// { dg-options "-w" }
|
||||
|
||||
int foo ( foo += *[ // { dg-error "expected" }
|
||||
// { dg-error "-:invalid|expected" }
|
||||
// { dg-error "-:invalid|expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
|
||||
struct {
|
||||
a(void = 0; a(0), a(0) // { dg-error "" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -8,4 +8,4 @@ main (void)
|
|||
|
||||
z = __complex__ (1.90000007326203904e+19, 0.0); // { dg-error "expected primary-expression before '__complex__'" "primary-expression" }
|
||||
z = __complex__ (1.0e+0, 0.0) / z; // { dg-error "expected primary-expression before '__complex__'" "primaty-expression" }
|
||||
// { dg-error "-:at end of input" "end" }
|
||||
// { dg-error "-:at end of input" "end" { target *-*-* } .+1 }
|
||||
|
|
|
@ -8,4 +8,4 @@ main (void)
|
|||
|
||||
z = _Complex (1.90000007326203904e+19, 0.0); // { dg-error "expected primary-expression before '_Complex'" "primary-expression" }
|
||||
z = _Complex (1.0e+0, 0.0) / z; // { dg-error "expected primary-expression before '_Complex'" "primary-expression" }
|
||||
// { dg-error "-:at end of input" "end" }
|
||||
// { dg-error "-:at end of input" "end" { target *-*-* } .+1 }
|
||||
|
|
|
@ -6,4 +6,4 @@ class A {
|
|||
A _M_ios_locale ios_base(ios_base &) template <_Traits> class basic_ios { // { dg-error "" }
|
||||
basic_ios basic_ios = operator= // { dg-error "" }
|
||||
// { dg-prune-output "file ends in default argument" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -5,4 +5,4 @@ template
|
|||
<
|
||||
class
|
||||
{ // { dg-error "" }
|
||||
// { dg-error "-:" }
|
||||
// { dg-error "-:" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
// { dg-do compile }
|
||||
|
||||
template < int > struct S { S < // { dg-error "" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// PR c++/56534
|
||||
|
||||
template < struct template rebind < > // { dg-error "expected|must follow" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -5,4 +5,4 @@ extern "C" {
|
|||
struct ___is_pod {
|
||||
enum {
|
||||
__value = (sizeof(__gnu_internal::__test_type<_Tp>(0)))}; // { dg-error "expected|declared" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -4,4 +4,6 @@ template < unsigned >
|
|||
struct A ;
|
||||
template < typename >
|
||||
struct B ;
|
||||
template < typename T , A < B < T > {}// { dg-error "initializer|parse error|type|expected" }
|
||||
template < typename T , A < B < T > {} // { dg-error "parse error|non-type|initializer" }
|
||||
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -7,4 +7,4 @@ template < typename > struct T
|
|||
template < bool > struct T < S > // { dg-error "" }
|
||||
{
|
||||
void f () { // { dg-error "expected" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
template <int()> struct a;
|
||||
template <int(b)> a < b // { dg-error "int" }
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -7,4 +7,4 @@ struct foo
|
|||
{
|
||||
foo();
|
||||
};
|
||||
// { dg-error "-:expected" }
|
||||
// { dg-error "-:expected" "" { target *-*-* } .+1 }
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-pedantic" } */
|
||||
|
||||
/* { dg-warning "-:ISO C forbids an empty translation unit" "empty" } */
|
||||
/* { dg-warning "-:ISO C forbids an empty translation unit" "empty" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-pedantic-errors" } */
|
||||
|
||||
/* { dg-error "-:ISO C forbids an empty translation unit" "empty" } */
|
||||
/* { dg-error "-:ISO C forbids an empty translation unit" "empty" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -12,4 +12,5 @@ int main()
|
|||
int g()
|
||||
int a[( {int b} )]; /* { dg-error "braced-group within expression allowed only inside a function|declaration for parameter" } */
|
||||
return 0; /* { dg-error "expected declaration specifiers before" } */
|
||||
} /* { dg-error "expected declaration specifiers before|end of input|expected declaration or statement at end of input" } */
|
||||
} /* { dg-error "expected declaration" } */
|
||||
/* { dg-error "-:expected" "" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -4,4 +4,5 @@
|
|||
void foo()
|
||||
{
|
||||
({ int i().; }); /* { dg-error "expected" } */
|
||||
} /* { dg-error "-:expected" } */
|
||||
} /* { dg-error "expected declaration" }
|
||||
/* { dg-error "-:expected" "" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "" } */
|
||||
|
||||
void foo() x; /* { dg-error "-:expected" } */
|
||||
void foo() x; /* { dg-error "expected" } */
|
||||
/* { dg-error "-:expected" "" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* { dg-do compile } */
|
||||
void foo()
|
||||
const char* p = __FUNCTION__; /* { dg-error "" } */
|
||||
/* { dg-error "-:expected" "" } */
|
||||
/* { dg-error "-:expected" "" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
void __RTL test (void)
|
||||
{ /* { dg-error "-:no closing brace" } */
|
||||
{ /* { dg-error "-:no closing brace" "" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
int unclosed[] = { /* { dg-message "18: to match this '.'" } */
|
||||
42
|
||||
/* { dg-error "-: expected '.' at end of input" } */
|
||||
/* { dg-error "-: expected '.' at end of input" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
int iVar;
|
||||
}
|
||||
@property int FooBar /* { dg-error "expected ';' at end of input" } */
|
||||
/* { dg-error "expected '@end' at end of input" "" { target *-*-* } .-1 } */
|
||||
/* { dg-error "-:expected '@end' at end of input" "" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
@interface /* { dg-error "expected identifier" } */
|
||||
@interface
|
||||
/* { dg-error "-:expected identifier" "" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -1 +1 @@
|
|||
@interface A /* { dg-error "expected ..end." } */
|
||||
@interface A /* { dg-error "-:expected ..end." "" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
@implementation SaturnDoc /* { dg-warning "cannot find interface declaration" } */
|
||||
- read: (void*)aStream ggg /* { dg-error "expected .:. at end of input" } */
|
||||
/* { dg-error "expected ..end. at end of input" "" { target *-*-* } .-1 } */
|
||||
/* { dg-error "-:expected ..end. at end of input" "" { target *-*-* } .+1 } */
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
2020-05-12 Nathan Sidwell <nathan@acm.org>
|
||||
|
||||
EOF location is at end of file
|
||||
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.
|
||||
|
||||
2020-05-12 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* Makefile.in (CET_HOST_FLAGS): New.
|
||||
|
|
31
libcpp/lex.c
31
libcpp/lex.c
|
@ -1897,12 +1897,13 @@ lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base,
|
|||
|
||||
BUF_APPEND (base, cur - base);
|
||||
|
||||
if (pfile->buffer->cur < pfile->buffer->rlimit)
|
||||
pfile->buffer->cur = cur-1;
|
||||
_cpp_process_line_notes (pfile, false);
|
||||
|
||||
if (pfile->buffer->next_line < pfile->buffer->rlimit)
|
||||
CPP_INCREMENT_LINE (pfile, 0);
|
||||
pfile->buffer->need_line = true;
|
||||
|
||||
pfile->buffer->cur = cur-1;
|
||||
_cpp_process_line_notes (pfile, false);
|
||||
if (!_cpp_get_fresh_line (pfile))
|
||||
{
|
||||
location_t src_loc = token->src_loc;
|
||||
|
@ -1914,6 +1915,8 @@ lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base,
|
|||
_cpp_release_buff (pfile, first_buff);
|
||||
cpp_error_with_line (pfile, CPP_DL_ERROR, src_loc, 0,
|
||||
"unterminated raw string");
|
||||
/* Now pop the buffer that _cpp_get_fresh_line did not. */
|
||||
_cpp_pop_buffer (pfile);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2651,8 +2654,6 @@ _cpp_lex_token (cpp_reader *pfile)
|
|||
bool
|
||||
_cpp_get_fresh_line (cpp_reader *pfile)
|
||||
{
|
||||
int return_at_eof;
|
||||
|
||||
/* We can't get a new line until we leave the current directive. */
|
||||
if (pfile->state.in_directive)
|
||||
return false;
|
||||
|
@ -2683,10 +2684,17 @@ _cpp_get_fresh_line (cpp_reader *pfile)
|
|||
buffer->next_line = buffer->rlimit;
|
||||
}
|
||||
|
||||
return_at_eof = buffer->return_at_eof;
|
||||
_cpp_pop_buffer (pfile);
|
||||
if (pfile->buffer == NULL || return_at_eof)
|
||||
return false;
|
||||
if (buffer->prev && !buffer->return_at_eof)
|
||||
_cpp_pop_buffer (pfile);
|
||||
else
|
||||
{
|
||||
/* End of translation. Do not pop the buffer yet. Increment
|
||||
line number so that the EOF token is on a line of its own
|
||||
(_cpp_lex_direct doesn't increment in that case, because
|
||||
it's hard for it to distinguish this special case). */
|
||||
CPP_INCREMENT_LINE (pfile, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2740,6 +2748,8 @@ _cpp_lex_direct (cpp_reader *pfile)
|
|||
/* Tell the compiler the line number of the EOF token. */
|
||||
result->src_loc = pfile->line_table->highest_line;
|
||||
result->flags = BOL;
|
||||
/* Now pop the buffer that _cpp_get_fresh_line did not. */
|
||||
_cpp_pop_buffer (pfile);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -3975,7 +3985,8 @@ cpp_directive_only_process (cpp_reader *pfile,
|
|||
/* Prep things for directive handling. */
|
||||
buffer->next_line = pos;
|
||||
buffer->need_line = true;
|
||||
_cpp_get_fresh_line (pfile);
|
||||
bool ok = _cpp_get_fresh_line (pfile);
|
||||
gcc_checking_assert (ok);
|
||||
|
||||
/* Ensure proper column numbering for generated
|
||||
error messages. */
|
||||
|
|
|
@ -312,7 +312,11 @@ _cpp_read_logical_line_trad (cpp_reader *pfile)
|
|||
do
|
||||
{
|
||||
if (pfile->buffer->need_line && !_cpp_get_fresh_line (pfile))
|
||||
return false;
|
||||
{
|
||||
/* Now pop the buffer that _cpp_get_fresh_line did not. */
|
||||
_cpp_pop_buffer (pfile);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
while (!_cpp_scan_out_logical_line (pfile, NULL, false)
|
||||
|| pfile->state.skipping);
|
||||
|
|
Loading…
Reference in New Issue