From: tromey Date: Wed, 2 May 2007 19:33:44 +0000 (+0000) Subject: libcpp X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=3127c3578f232a6b59c622134694c64a00c7f6e9;hp=43bd286f942a79975a566d675d6283e14f16842f libcpp PR preprocessor/28709: * macro.c (paste_tokens): Remove PASTE_LEFT from the old lhs. gcc/testsuite PR preprocessor/28709: * gcc.dg/cpp/pr28709.c: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@124356 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 287a0973101..d8493a1f3a9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-05-02 Tom Tromey + + PR preprocessor/28709: + * gcc.dg/cpp/pr28709.c: New file. + 2007-05-02 Richard Guenther PR tree-optimization/31146 diff --git a/gcc/testsuite/gcc.dg/cpp/pr28709.c b/gcc/testsuite/gcc.dg/cpp/pr28709.c new file mode 100644 index 00000000000..11cccbe8b5d --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/pr28709.c @@ -0,0 +1,8 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. */ +/* PR preprocessor/28709 */ + +/* { dg-do compile } */ +#define foo - ## >> +foo; +/* { dg-error "expected identifier.*'-'" "" { target *-*-* } 6 } */ +/* { dg-error pasting "" { target *-*-* } 6 } */ diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index a56357f392e..0193de47cf3 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,8 @@ +2007-05-02 Tom Tromey + + PR preprocessor/28709: + * macro.c (paste_tokens): Remove PASTE_LEFT from the old lhs. + 2007-03-30 Michael Meissner * directives.c (lex_macro_node_from_str): Fix alloca call to be diff --git a/libcpp/macro.c b/libcpp/macro.c index ede29ff62bc..748635f408e 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -432,19 +432,18 @@ static bool paste_tokens (cpp_reader *pfile, const cpp_token **plhs, const cpp_token *rhs) { unsigned char *buf, *end, *lhsend; - const cpp_token *lhs; + cpp_token *lhs; unsigned int len; - lhs = *plhs; - len = cpp_token_len (lhs) + cpp_token_len (rhs) + 1; + len = cpp_token_len (*plhs) + cpp_token_len (rhs) + 1; buf = (unsigned char *) alloca (len); - end = lhsend = cpp_spell_token (pfile, lhs, buf, false); + end = lhsend = cpp_spell_token (pfile, *plhs, buf, false); /* Avoid comment headers, since they are still processed in stage 3. It is simpler to insert a space here, rather than modifying the lexer to ignore comments in some circumstances. Simply returning false doesn't work, since we want to clear the PASTE_LEFT flag. */ - if (lhs->type == CPP_DIV && rhs->type != CPP_EQ) + if ((*plhs)->type == CPP_DIV && rhs->type != CPP_EQ) *end++ = ' '; end = cpp_spell_token (pfile, rhs, end, false); *end = '\n'; @@ -454,13 +453,22 @@ paste_tokens (cpp_reader *pfile, const cpp_token **plhs, const cpp_token *rhs) /* Set pfile->cur_token as required by _cpp_lex_direct. */ pfile->cur_token = _cpp_temp_token (pfile); - *plhs = _cpp_lex_direct (pfile); + lhs = _cpp_lex_direct (pfile); if (pfile->buffer->cur != pfile->buffer->rlimit) { + source_location saved_loc = lhs->src_loc; + _cpp_pop_buffer (pfile); _cpp_backup_tokens (pfile, 1); *lhsend = '\0'; + /* We have to remove the PASTE_LEFT flag from the old lhs, but + we want to keep the new location. */ + *lhs = **plhs; + *plhs = lhs; + lhs->src_loc = saved_loc; + lhs->flags &= ~PASTE_LEFT; + /* Mandatory error for all apart from assembler. */ if (CPP_OPTION (pfile, lang) != CLK_ASM) cpp_error (pfile, CPP_DL_ERROR, @@ -469,6 +477,7 @@ paste_tokens (cpp_reader *pfile, const cpp_token **plhs, const cpp_token *rhs) return false; } + *plhs = lhs; _cpp_pop_buffer (pfile); return true; }