diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-03-30 15:06:14 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-03-30 15:06:14 +0000 |
commit | 6751d1e726664e581f43c47f4c3fa95777d16983 (patch) | |
tree | 38f4527fb4b6f949bb111ebc8a126801b913ffb7 /libcpp | |
parent | 6d6a7eabbc5a592f4b11413fc2b6e4e613e4e792 (diff) |
PR target/39558
* macro.c (cpp_get_token): If macro_to_expand returns NULL
and used some tokens, add CPP_PADDING before next token.
* gcc.target/powerpc/altivec-29.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_4-branch@145298 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 6 | ||||
-rw-r--r-- | libcpp/macro.c | 36 |
2 files changed, 37 insertions, 5 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 61d5b975404..9bcca81c3b6 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,9 @@ +2009-03-30 Jakub Jelinek <jakub@redhat.com> + + PR target/39558 + * macro.c (cpp_get_token): If macro_to_expand returns NULL + and used some tokens, add CPP_PADDING before next token. + 2009-03-28 Joseph Myers <joseph@codesourcery.com> * Makefile.in (po/$(PACKAGE).pot): Use $(mkinstalldirs) not diff --git a/libcpp/macro.c b/libcpp/macro.c index 8122648ea39..a7f97759457 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -1,7 +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, - 2006, 2007, 2008 Free Software Foundation, Inc. + 2006, 2007, 2008, 2009 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 @@ -1260,10 +1260,36 @@ cpp_get_token (cpp_reader *pfile) /* Conditional macros require that a predicate be evaluated first. */ - if (((!(node->flags & NODE_CONDITIONAL)) - || (pfile->cb.macro_to_expand - && (node = pfile->cb.macro_to_expand (pfile, result)))) - && (ret = enter_macro_context (pfile, node, result))) + if ((node->flags & NODE_CONDITIONAL) != 0) + { + if (pfile->cb.macro_to_expand) + { + bool whitespace_after; + const cpp_token *peek_tok = cpp_peek_token (pfile, 0); + + whitespace_after = (peek_tok->type == CPP_PADDING + || (peek_tok->flags & PREV_WHITE)); + node = pfile->cb.macro_to_expand (pfile, result); + if (node) + ret = enter_macro_context (pfile, node, result); + else if (whitespace_after) + { + /* If macro_to_expand hook returned NULL and it + ate some tokens, see if we don't need to add + a padding token in between this and the + next token. */ + peek_tok = cpp_peek_token (pfile, 0); + if (peek_tok->type != CPP_PADDING + && (peek_tok->flags & PREV_WHITE) == 0) + _cpp_push_token_context (pfile, NULL, + padding_token (pfile, + peek_tok), 1); + } + } + } + else + ret = enter_macro_context (pfile, node, result); + if (ret) { if (pfile->state.in_directive || ret == 2) continue; |