diff options
author | Zack Weinberg <zack@gcc.gnu.org> | 2000-07-20 17:57:38 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-07-20 17:57:38 +0000 |
commit | 6fee6033e7379f33c0fc6385f13424262d0bcae8 (patch) | |
tree | 411ca2344aad9c248c5506109b46dc34a0f64bbf /gcc/cpplex.c | |
parent | 1e18a243c26b73e0b22969891ec3584bd62e316c (diff) | |
download | gcc-6fee6033e7379f33c0fc6385f13424262d0bcae8.zip gcc-6fee6033e7379f33c0fc6385f13424262d0bcae8.tar.gz gcc-6fee6033e7379f33c0fc6385f13424262d0bcae8.tar.bz2 |
cppmacro.c (CAN_PASTE_AFTER): New macro.
* cppmacro.c (CAN_PASTE_AFTER): New macro.
(count_params): Don't set GNU_REST_ARGS on anything.
(save_expansion): Set PASTE_LEFT only on tokens for which
CAN_PASTE_AFTER is true, or which are named operators.
* cpplex.c (parse_args): Distinguish between a rest argument
given one empty argument, and a rest argument given zero arguments.
(maybe_paste_with_next): Look for VOID_REST tag, and trigger
deletion of previous token based on that.
(get_raw_token): Flatten some control structure.
* cpplib.h (CPP_LAST_EQ): Correct.
(VOID_REST): New token flag.
(GNU_REST_ARGS): Delete.
* gcc.dg/cpp/20000625-2.c, gcc.dg/cpp/macsyntx.c: Update error
regexps.
* gcc.dg/cpp/paste6.c: New test.
From-SVN: r35146
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r-- | gcc/cpplex.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c index 9c7a03c..36beb95 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -2399,13 +2399,19 @@ parse_args (pfile, hp, args) debug("string"); This is exactly the same as if the rest argument had received no tokens - debug("string",); This extension is deprecated. */ - - if (argc + 1 == macro->paramc && (macro->flags & GNU_REST_ARGS)) + + if (argc + 1 == macro->paramc && (macro->flags & VAR_ARGS)) { /* Duplicate the placemarker. Then we can set its flags and position and safely be using more than one. */ - save_token (args, duplicate_token (pfile, &placemarker_token)); + cpp_token *pm = duplicate_token (pfile, &placemarker_token); + pm->flags = VOID_REST; + save_token (args, pm); args->ends[argc] = total + 1; + + if (CPP_OPTION (pfile, c99) && CPP_PEDANTIC (pfile)) + cpp_pedwarn (pfile, "ISO C99 requires rest arguments to be used"); + return 0; } else @@ -2710,17 +2716,11 @@ maybe_paste_with_next (pfile, token) pasted = duplicate_token (pfile, second); else if (second->type == CPP_PLACEMARKER) { - cpp_context *mac_context = CURRENT_CONTEXT (pfile) - 1; /* GCC has special extended semantics for a ## b where b is - a varargs parameter: a disappears if b consists of no - tokens. This extension is deprecated. */ - if ((mac_context->u.list->flags & GNU_REST_ARGS) - && (mac_context->u.list->tokens[mac_context->posn-1].val.aux + 1 - == (unsigned) mac_context->u.list->paramc)) - { - cpp_warning (pfile, "deprecated GNU ## extension used"); - pasted = duplicate_token (pfile, second); - } + a varargs parameter: a disappears if b was given no actual + arguments (not merely if b is an empty argument). */ + if (second->flags & VOID_REST) + pasted = duplicate_token (pfile, second); else pasted = duplicate_token (pfile, token); } @@ -3161,6 +3161,7 @@ get_raw_token (pfile) { result = context->pushed_token; context->pushed_token = 0; + return result; /* Cannot be a CPP_MACRO_ARG */ } else if (context->posn == context->count) { @@ -3168,21 +3169,19 @@ get_raw_token (pfile) return &eof_token; continue; } - else + else if (IS_ARG_CONTEXT (context)) { - if (IS_ARG_CONTEXT (context)) + result = context->u.arg[context->posn++]; + if (result == 0) { + context->flags ^= CONTEXT_RAW; result = context->u.arg[context->posn++]; - if (result == 0) - { - context->flags ^= CONTEXT_RAW; - result = context->u.arg[context->posn++]; - } - return result; /* Cannot be a CPP_MACRO_ARG */ } - result = &context->u.list->tokens[context->posn++]; + return result; /* Cannot be a CPP_MACRO_ARG */ } + result = &context->u.list->tokens[context->posn++]; + if (result->type != CPP_MACRO_ARG) return result; @@ -3225,7 +3224,6 @@ lex_next (pfile, clear) if (pfile->temp_used) release_temp_tokens (pfile); } - lex_line (pfile, list); pfile->contexts[0].count = list->tokens_used; |