This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for bug 20672


This patch fixes bug 20672, a new C parser regression.  Bootstrapped with 
no regressions on x86_64-unknown-linux-gnu.  Applied to mainline.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

2005-03-29  Joseph S. Myers  <joseph@codesourcery.com>

	PR c/20672
	* c-parser.c (c_parser_compound_statement_nostart): Give error
	message for EOF instead of just setting parser->error.

testsuite:
2005-03-29  Joseph S. Myers  <joseph@codesourcery.com>

	PR c/20672
	* gcc.dg/pr20672-1.c: New test.

diff -rupN GCC.orig/gcc/c-parser.c GCC/gcc/c-parser.c
--- GCC.orig/gcc/c-parser.c	2005-03-23 01:31:37.000000000 +0000
+++ GCC/gcc/c-parser.c	2005-03-29 14:14:56.000000000 +0000
@@ -3238,7 +3238,7 @@ c_parser_compound_statement_nostart (c_p
       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 -rupN GCC.orig/gcc/testsuite/gcc.dg/pr20672-1.c GCC/gcc/testsuite/gcc.dg/pr20672-1.c
--- GCC.orig/gcc/testsuite/gcc.dg/pr20672-1.c	1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/pr20672-1.c	2005-03-29 14:13:38.000000000 +0000
@@ -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" } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]