summaryrefslogtreecommitdiff
path: root/libcpp/directives.c
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2008-01-03 17:58:26 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2008-01-03 17:58:26 +0000
commitcde59b72c9b49740d7f7822c649c2a28c77c187c (patch)
treec6771e54be61d92ae4c113b997d5d553a15c2866 /libcpp/directives.c
parente3a37aef272b028e7720f32f20f2cacab66ba1b1 (diff)
downloadgcc-cde59b72c9b49740d7f7822c649c2a28c77c187c.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131304 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/directives.c')
-rw-r--r--libcpp/directives.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/libcpp/directives.c b/libcpp/directives.c
index e8516e0f39c..6e2e55c5389 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));