re PR preprocessor/28709 (Bad diagnostic pasting tokens with ##)
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. From-SVN: r124356
This commit is contained in:
parent
d4083c80e2
commit
fca35e1b54
@ -1,3 +1,8 @@
|
||||
2007-05-02 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
PR preprocessor/28709:
|
||||
* gcc.dg/cpp/pr28709.c: New file.
|
||||
|
||||
2007-05-02 Richard Guenther <rguenther@suse.de>
|
||||
|
||||
PR tree-optimization/31146
|
||||
|
8
gcc/testsuite/gcc.dg/cpp/pr28709.c
Normal file
8
gcc/testsuite/gcc.dg/cpp/pr28709.c
Normal file
@ -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 } */
|
@ -1,3 +1,8 @@
|
||||
2007-05-02 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
PR preprocessor/28709:
|
||||
* macro.c (paste_tokens): Remove PASTE_LEFT from the old lhs.
|
||||
|
||||
2007-03-30 Michael Meissner <michael.meissner@amd.com>
|
||||
|
||||
* directives.c (lex_macro_node_from_str): Fix alloca call to be
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user