Commit 179652df by Jakub Jelinek Committed by Jakub Jelinek

re PR preprocessor/58844 (ICE with invalid use of ##)

	PR preprocessor/58844
	* macro.c (enter_macro_context): Only push
	macro_real_token_count (macro) tokens rather than
	macro->count tokens, regardless of
	CPP_OPTION (pfile, track-macro-expansion).

	* c-c++-common/cpp/pr58844-1.c: New test.
	* c-c++-common/cpp/pr58844-2.c: New test.

From-SVN: r207871
parent 0cfe1b46
2014-02-19 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/58844
* c-c++-common/cpp/pr58844-1.c: New test.
* c-c++-common/cpp/pr58844-2.c: New test.
2014-02-18 Paolo Carlini <paolo.carlini@oracle.com> 2014-02-18 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60225 PR c++/60225
......
/* PR preprocessor/58844 */
/* { dg-do compile } */
/* { dg-options "-ftrack-macro-expansion=0" } */
#define A x######x
int A = 1;
#define A x######x /* { dg-message "previous definition" } */
#define A x##x /* { dg-warning "redefined" } */
/* PR preprocessor/58844 */
/* { dg-do compile } */
/* { dg-options "-ftrack-macro-expansion=2" } */
#define A x######x
int A = 1;
#define A x######x /* { dg-message "previous definition" } */
#define A x##x /* { dg-warning "redefined" } */
2014-02-19 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/58844
* macro.c (enter_macro_context): Only push
macro_real_token_count (macro) tokens rather than
macro->count tokens, regardless of
CPP_OPTION (pfile, track-macro-expansion).
2014-02-07 Jakub Jelinek <jakub@redhat.com> 2014-02-07 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/56824 PR preprocessor/56824
......
...@@ -1115,21 +1115,22 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node, ...@@ -1115,21 +1115,22 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node,
if (macro->paramc == 0) if (macro->paramc == 0)
{ {
unsigned tokens_count = macro_real_token_count (macro);
if (CPP_OPTION (pfile, track_macro_expansion)) if (CPP_OPTION (pfile, track_macro_expansion))
{ {
unsigned int i, count = macro->count; unsigned int i;
const cpp_token *src = macro->exp.tokens; const cpp_token *src = macro->exp.tokens;
const struct line_map *map; const struct line_map *map;
source_location *virt_locs = NULL; source_location *virt_locs = NULL;
_cpp_buff *macro_tokens = _cpp_buff *macro_tokens
tokens_buff_new (pfile, count, &virt_locs); = tokens_buff_new (pfile, tokens_count, &virt_locs);
/* Create a macro map to record the locations of the /* Create a macro map to record the locations of the
tokens that are involved in the expansion. LOCATION tokens that are involved in the expansion. LOCATION
is the location of the macro expansion point. */ is the location of the macro expansion point. */
map = linemap_enter_macro (pfile->line_table, map = linemap_enter_macro (pfile->line_table,
node, location, count); node, location, tokens_count);
for (i = 0; i < count; ++i) for (i = 0; i < tokens_count; ++i)
{ {
tokens_buff_add_token (macro_tokens, virt_locs, tokens_buff_add_token (macro_tokens, virt_locs,
src, src->src_loc, src, src->src_loc,
...@@ -1141,16 +1142,12 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node, ...@@ -1141,16 +1142,12 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node,
virt_locs, virt_locs,
(const cpp_token **) (const cpp_token **)
macro_tokens->base, macro_tokens->base,
count); tokens_count);
num_macro_tokens_counter += count;
} }
else else
{ _cpp_push_token_context (pfile, node, macro->exp.tokens,
unsigned tokens_count = macro_real_token_count (macro); tokens_count);
_cpp_push_token_context (pfile, node, macro->exp.tokens, num_macro_tokens_counter += tokens_count;
tokens_count);
num_macro_tokens_counter += tokens_count;
}
} }
if (pragma_buff) if (pragma_buff)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment