From: Tom Tromey Date: Thu, 3 Jan 2008 17:58:26 +0000 (+0000) Subject: re PR preprocessor/34602 (Internal error with invalid #line directive) X-Git-Tag: releases/gcc-4.3.0~767 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33ae48375f1ceba18d2fe42d10acdf7a6b8acaba;p=thirdparty%2Fgcc.git re PR preprocessor/34602 (Internal error with invalid #line directive) libcpp PR preprocessor/34602. * directives.c (do_line): Don't try to spell EOF token. (do_linemarker): Add comment. gcc/testsuite PR preprocessor/34602: * gcc.dg/cpp/pr34602.c: New file. From-SVN: r131304 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index abf7969ffe57..962dc97e6f94 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-01-03 Tom Tromey + + PR preprocessor/34602: + * gcc.dg/cpp/pr34602.c: New file. + 2008-01-03 Jakub Jelinek PR tree-optimization/29484 diff --git a/gcc/testsuite/gcc.dg/cpp/pr34602.c b/gcc/testsuite/gcc.dg/cpp/pr34602.c new file mode 100644 index 000000000000..343c0917aeed --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/pr34602.c @@ -0,0 +1,6 @@ +/* PR preprocessor/34602 - no internal error trying to spell EOF. */ +/* { dg-do preprocess } */ + +/* { dg-error "unexpected end" "" { target *-*-* } 6 } */ + +#line diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 217294af5634..335686f16fc0 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,9 @@ +2008-01-03 Tom Tromey + + PR preprocessor/34602. + * directives.c (do_line): Don't try to spell EOF token. + (do_linemarker): Add comment. + 2007-12-11 DJ Delorie * charset.c (convert_using_iconv): Close out any shift states, diff --git a/libcpp/directives.c b/libcpp/directives.c index e8516e0f39c3..6e2e55c53899 100644 --- a/libcpp/directives.c +++ b/libcpp/directives.c @@ -1,7 +1,7 @@ /* CPP Library. (Directive handling.) Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2007 Free Software Foundation, Inc. + 2007, 2008 Free Software Foundation, Inc. Contributed by Per Bothner, 1994-95. Based on CCCP program by Paul Rubin, June 1986 Adapted to ANSI C, Richard Stallman, Jan 1987 @@ -864,9 +864,12 @@ do_line (cpp_reader *pfile) || strtoul_for_line (token->val.str.text, token->val.str.len, &new_lineno)) { - cpp_error (pfile, CPP_DL_ERROR, - "\"%s\" after #line is not a positive integer", - cpp_token_as_text (pfile, token)); + if (token->type == CPP_EOF) + cpp_error (pfile, CPP_DL_ERROR, "unexpected end of file after #line"); + else + cpp_error (pfile, CPP_DL_ERROR, + "\"%s\" after #line is not a positive integer", + cpp_token_as_text (pfile, token)); return; } @@ -920,6 +923,8 @@ do_linemarker (cpp_reader *pfile) || strtoul_for_line (token->val.str.text, token->val.str.len, &new_lineno)) { + /* Unlike #line, there does not seem to be a way to get an EOF + here. So, it should be safe to always spell the token. */ cpp_error (pfile, CPP_DL_ERROR, "\"%s\" after # is not a positive integer", cpp_token_as_text (pfile, token));