summaryrefslogtreecommitdiff
path: root/libcpp/macro.c
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2007-05-02 19:33:44 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2007-05-02 19:33:44 +0000
commit3127c3578f232a6b59c622134694c64a00c7f6e9 (patch)
treebdc237ad2964e2effe02d52d9c8f7d2f4f5419cb /libcpp/macro.c
parent43bd286f942a79975a566d675d6283e14f16842f (diff)
downloadgcc-3127c3578f232a6b59c622134694c64a00c7f6e9.tar.gz
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
Diffstat (limited to 'libcpp/macro.c')
-rw-r--r--libcpp/macro.c21
1 files changed, 15 insertions, 6 deletions
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;
}