summaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2007-01-30 15:46:01 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2007-01-30 15:46:01 +0000
commite0ff79356f763a6a1a5d6b519407ef66e19fa746 (patch)
treefada9dec211b86baa03a82bf99d474f9823cb875 /libcpp
parent3d5a3e764e0ab7c5873690d25c6c4679134f9ac7 (diff)
downloadgcc-e0ff79356f763a6a1a5d6b519407ef66e19fa746.tar.gz
PR preprocessor/29966:
* macro.c (lex_expansion_token): Save and restore cpp_reader's cur_token. (_cpp_create_definition): Don't restore cur_token here. * lex.c (_cpp_lex_token): Added assertion. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121340 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog8
-rw-r--r--libcpp/lex.c5
-rw-r--r--libcpp/macro.c15
3 files changed, 19 insertions, 9 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index e0ac504910a..40c216b3bb1 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,11 @@
+2007-01-30 Tom Tromey <tromey@redhat.com>
+
+ PR preprocessor/29966:
+ * macro.c (lex_expansion_token): Save and restore cpp_reader's
+ cur_token.
+ (_cpp_create_definition): Don't restore cur_token here.
+ * lex.c (_cpp_lex_token): Added assertion.
+
2007-01-27 Tom Tromey <tromey@redhat.com>
* configure: Rebuilt.
diff --git a/libcpp/lex.c b/libcpp/lex.c
index 5d1a688af9a..296b3999811 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -766,6 +766,11 @@ _cpp_lex_token (cpp_reader *pfile)
pfile->cur_run = next_tokenrun (pfile->cur_run);
pfile->cur_token = pfile->cur_run->base;
}
+ /* We assume that the current token is somewhere in the current
+ run. */
+ if (pfile->cur_token < pfile->cur_run->base
+ || pfile->cur_token >= pfile->cur_run->limit)
+ abort ();
if (pfile->lookaheads)
{
diff --git a/libcpp/macro.c b/libcpp/macro.c
index be50c111e32..ede29ff62bc 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -1,6 +1,7 @@
/* Part of CPP library. (Macro and #define handling.)
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+ 2006 Free Software Foundation, Inc.
Written by Per Bothner, 1994.
Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987
@@ -1398,10 +1399,12 @@ alloc_expansion_token (cpp_reader *pfile, cpp_macro *macro)
static cpp_token *
lex_expansion_token (cpp_reader *pfile, cpp_macro *macro)
{
- cpp_token *token;
+ cpp_token *token, *saved_cur_token;
+ saved_cur_token = pfile->cur_token;
pfile->cur_token = alloc_expansion_token (pfile, macro);
token = _cpp_lex_direct (pfile);
+ pfile->cur_token = saved_cur_token;
/* Is this a parameter? */
if (token->type == CPP_NAME
@@ -1590,18 +1593,12 @@ _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node)
ok = _cpp_create_trad_definition (pfile, macro);
else
{
- cpp_token *saved_cur_token = pfile->cur_token;
-
ok = create_iso_definition (pfile, macro);
- /* Restore lexer position because of games lex_expansion_token()
- plays lexing the macro. We set the type for SEEN_EOL() in
- directives.c.
+ /* We set the type for SEEN_EOL() in directives.c.
Longer term we should lex the whole line before coming here,
and just copy the expansion. */
- saved_cur_token[-1].type = pfile->cur_token[-1].type;
- pfile->cur_token = saved_cur_token;
/* Stop the lexer accepting __VA_ARGS__. */
pfile->state.va_args_ok = 0;