+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
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 }
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 }
class C{
T t;
decltype(t)::a:: // { dg-error "expected" }
-// { dg-error "-:expected" }
+// { dg-error "-:expected" "" { target *-*-* } .+1 }
// { dg-do compile { target c++11 } }
namespace alignas() N {} // { dg-error "expected" }
-// { dg-error "-:expected" }
+// { dg-error "-:expected" "" { target *-*-* } .+1 }
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 }
// { dg-do compile { target c++11 } }
alignas (alignas double // { dg-error "expected" }
-// { dg-error "-:expected" }
+// { dg-error "-:expected" "" { target *-*-* } .+1 }
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 }
};
}
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 }
// { 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 }
template <typename> struct A;
template <typename> struct B : A < B { , // { dg-error "" }
-// { dg-error "-:expected" }
+// { dg-error "-:expected" "" { target *-*-* } .+1 }
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 } */
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 } */
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 } */
struct unclosed { /* { dg-message "17: to match this '.'" } */
int dummy;
- // { dg-error "-:expected" }
+ // { dg-error "-:expected" "" { target *-*-* } .+1 }
// { 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 }
void c() {
switch () // { dg-error "expected" }
case b // { dg-error "expected" }
- // { dg-error "-:expected" }
+ // { dg-error "-:expected" "" { target *-*-* } .+1 }
// 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 }
void foo()
{
if (struct A{}// { dg-error "types may not be defined|expected" }
+// { dg-error "-:expected" "" { target *-*-* } .+1 }
{
typename::
; // { dg-error "expected" }
- // { dg-error "-:expected" }
+ // { dg-error "-:expected" "" { target *-*-* } .+1 }
// PR 18095: ICE
// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
-struct A // { dg-error "-:expected" }
+struct A // { dg-error "-:expected" "" { target *-*-* } .+1 }
// 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 }
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 }
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 }
// PR c++/39053
-void foo() = // { dg-error "initialized|expected" }
+void foo() = // { dg-error "initialized" }
+// { dg-error "-:expected" "" { target *-*-* } .+1 }
// PR c++/53003
struct A{ void a{} return b // { dg-error "16:function definition" }
-// { dg-error "-:expected" }
+// { dg-error "-:expected" "" { target *-*-* } .+1 }
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 }
class x0;
template <x1> x2() { // { dg-error "declared|type" }
x0 x3 = x3. // { dg-error "incomplete type" }
-// { dg-error "-:expected" }
+// { dg-error "-:expected" "" { target *-*-* } .+1 }
// }
}; // { 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 }
class {
// { dg-error "forbids" "" { target *-*-* } .+1 }
friend __copy_streambufs_eof <> ( // { dg-error "" }
- // { dg-error "-:expected" }
+ // { dg-error "-:expected" "" { target *-*-* } .+1 }
// { dg-options "-w" }
int foo ( foo += *[ // { dg-error "expected" }
-// { dg-error "-:invalid|expected" }
+// { dg-error "-:invalid|expected" "" { target *-*-* } .+1 }
struct {
a(void = 0; a(0), a(0) // { dg-error "" }
-// { dg-error "-:expected" }
+// { dg-error "-:expected" "" { target *-*-* } .+1 }
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 }
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 }
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 }
<
class
{ // { dg-error "" }
-// { dg-error "-:" }
+// { dg-error "-:" "" { target *-*-* } .+1 }
// { dg-do compile }
template < int > struct S { S < // { dg-error "" }
- // { dg-error "-:expected" }
+ // { dg-error "-:expected" "" { target *-*-* } .+1 }
// PR c++/56534
template < struct template rebind < > // { dg-error "expected|must follow" }
-// { dg-error "-:expected" }
+// { dg-error "-:expected" "" { target *-*-* } .+1 }
struct ___is_pod {
enum {
__value = (sizeof(__gnu_internal::__test_type<_Tp>(0)))}; // { dg-error "expected|declared" }
-// { dg-error "-:expected" }
+// { dg-error "-:expected" "" { target *-*-* } .+1 }
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 }
template < bool > struct T < S > // { dg-error "" }
{
void f () { // { dg-error "expected" }
-// { dg-error "-:expected" }
+// { dg-error "-:expected" "" { target *-*-* } .+1 }
template <int()> struct a;
template <int(b)> a < b // { dg-error "int" }
-// { dg-error "-:expected" }
+// { dg-error "-:expected" "" { target *-*-* } .+1 }
{
foo();
};
-// { dg-error "-:expected" }
+// { dg-error "-:expected" "" { target *-*-* } .+1 }
/* { 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 } */
/* { 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 } */
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 } */
void foo()
{
({ int i().; }); /* { dg-error "expected" } */
-} /* { dg-error "-:expected" } */
+} /* { dg-error "expected declaration" }
+/* { dg-error "-:expected" "" { target *-*-* } .+1 } */
/* { dg-do compile } */
/* { dg-options "" } */
-void foo() x; /* { dg-error "-:expected" } */
+void foo() x; /* { dg-error "expected" } */
+/* { dg-error "-:expected" "" { target *-*-* } .+1 } */
/* { dg-do compile } */
void foo()
const char* p = __FUNCTION__; /* { dg-error "" } */
-/* { dg-error "-:expected" "" } */
+/* { dg-error "-:expected" "" { target *-*-* } .+1 } */
void __RTL test (void)
-{ /* { dg-error "-:no closing brace" } */
+{ /* { dg-error "-:no closing brace" "" { target *-*-* } .+1 } */
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 } */
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 } */
-@interface /* { dg-error "expected identifier" } */
+@interface
+/* { dg-error "-:expected identifier" "" { target *-*-* } .+1 } */
-@interface A /* { dg-error "expected ..end." } */
\ No newline at end of file
+@interface A /* { dg-error "-:expected ..end." "" { target *-*-* } .+1 } */
@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 } */
\ No newline at end of file
+/* { dg-error "-:expected ..end. at end of input" "" { target *-*-* } .+1 } */
+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.
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;
_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;
}
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;
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;
+ }
}
}
/* 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;
}
/* 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. */
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);