aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplex.c
diff options
context:
space:
mode:
authorNeil Booth <neilb@earthling.net>2000-09-15 05:55:36 +0000
committerNeil Booth <neil@gcc.gnu.org>2000-09-15 05:55:36 +0000
commitff94c747653bba7f146f1f8304286d82f17d8ae9 (patch)
tree46b2b60f181bbf21ca0786fa960ec2f8d89df671 /gcc/cpplex.c
parentb437f1a754649a06bd783fc707b5bff14c9c5eed (diff)
downloadgcc-ff94c747653bba7f146f1f8304286d82f17d8ae9.zip
gcc-ff94c747653bba7f146f1f8304286d82f17d8ae9.tar.gz
gcc-ff94c747653bba7f146f1f8304286d82f17d8ae9.tar.bz2
cpplex.c (ON_REST_ARG): Correct the test.
* cpplex.c (ON_REST_ARG): Correct the test. (maybe_paste_with_next): Duplicate a token that fail pasting, and clear its PASTE_LEFT flag, so that nested pasting attempts do not occur. * gcc.dg/cpp/paste10.c: Testcase. From-SVN: r36424
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r--gcc/cpplex.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index 5cb6b7f..56b8543 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -201,9 +201,9 @@ TOKEN_LEN (token)
#define IS_ARG_CONTEXT(c) ((c)->flags & CONTEXT_ARG)
#define CURRENT_CONTEXT(pfile) ((pfile)->contexts + (pfile)->cur_context)
#define ON_REST_ARG(c) \
- (((c)->flags & VAR_ARGS) \
- && ((c)-1)->u.list->tokens[((c)-1)->posn - 1].val.aux \
- == (unsigned int) (((c)-1)->u.list->paramc - 1))
+ (((c)->u.list->flags & VAR_ARGS) \
+ && (c)->u.list->tokens[(c)->posn - 1].val.aux \
+ == (unsigned int) ((c)->u.list->paramc - 1))
#define ASSIGN_FLAGS_AND_POS(d, s) \
do {(d)->flags = (s)->flags & (PREV_WHITE | BOL | PASTE_LEFT); \
@@ -2787,14 +2787,17 @@ maybe_paste_with_next (pfile, token)
the special extended semantics (see above). */
if (token->type == CPP_COMMA
&& IS_ARG_CONTEXT (CURRENT_CONTEXT (pfile))
- && ON_REST_ARG (CURRENT_CONTEXT (pfile)))
+ && ON_REST_ARG (CURRENT_CONTEXT (pfile) - 1))
/* no warning */;
else
cpp_warning (pfile,
"pasting would not give a valid preprocessing token");
}
_cpp_push_token (pfile, second);
- return token;
+ /* A short term hack to safely clear the PASTE_LEFT flag. */
+ pasted = duplicate_token (pfile, token);
+ pasted->flags &= ~PASTE_LEFT;
+ return pasted;
}
if (type == CPP_NAME || type == CPP_NUMBER)