From d1edc3936609d114f92bc547761109c2b823c8e3 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 29 Mar 2005 19:54:44 +0100 Subject: [PATCH] re PR c/20672 (New C parser doesn't check whether functions that end files are closed properly) PR c/20672 * c-parser.c (c_parser_compound_statement_nostart): Give error message for EOF instead of just setting parser->error. testsuite: * gcc.dg/pr20672-1.c: New test. From-SVN: r97197 --- gcc/ChangeLog | 6 ++++++ gcc/c-parser.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr20672-1.c | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr20672-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9b7386015aa..ca728cd97f6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-03-29 Joseph S. Myers + + PR c/20672 + * c-parser.c (c_parser_compound_statement_nostart): Give error + message for EOF instead of just setting parser->error. + 2005-03-29 Dorit Naishlos * tree-vectorizer.c (slpeel_update_phi_nodes_for_guard): Removed. diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 8e8626ef248..9a5d669d034 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -3238,7 +3238,7 @@ c_parser_compound_statement_nostart (c_parser *parser) location_t loc = c_parser_peek_token (parser)->location; if (c_parser_next_token_is (parser, CPP_EOF)) { - parser->error = true; + c_parser_error (parser, "expected declaration or statement"); return; } if (c_parser_next_token_is_keyword (parser, RID_CASE) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dba8cc6a10c..2c1e6d0c5e9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-03-29 Joseph S. Myers + + PR c/20672 + * gcc.dg/pr20672-1.c: New test. + 2005-03-29 Dorit Naishlos * gfortran.dg/vect: New directory. diff --git a/gcc/testsuite/gcc.dg/pr20672-1.c b/gcc/testsuite/gcc.dg/pr20672-1.c new file mode 100644 index 00000000000..e47fef3fa43 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr20672-1.c @@ -0,0 +1,7 @@ +/* EOF must cause an error inside a function, not just set parser->error. + Bug 20672. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +int main(void) +{ +int a; /* { dg-error "expected" } */