aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplex.c
diff options
context:
space:
mode:
authorNeil Booth <neilb@earthling.net>2000-07-08 02:18:25 +0000
committerNeil Booth <neil@gcc.gnu.org>2000-07-08 02:18:25 +0000
commit563dd08adfa12573fdecf9669fdf685fef5fd360 (patch)
tree9ca49cb51958d754a1e1218f2ee16625c7cb8dc6 /gcc/cpplex.c
parent0828a0bd1b6f503880c694f106c8424967cb38aa (diff)
downloadgcc-563dd08adfa12573fdecf9669fdf685fef5fd360.zip
gcc-563dd08adfa12573fdecf9669fdf685fef5fd360.tar.gz
gcc-563dd08adfa12573fdecf9669fdf685fef5fd360.tar.bz2
cpphash.c (is__va_args__): New function.
* cpphash.c (is__va_args__): New function. (count_params): Fix line reported in error messages. Use is__va_args__. Don't return ')' on error. Flag GNU style rest args macro definitions. (parse_define): Check macro name is not __VA_ARGS__. (save_expansion): Check identifier in non-varargs-macro is not __VA_ARGS__. Don't flag GNU_VARARGS. * cpplex.c (parse_args): Accept no argument iff GNU_REST_ARGS. (maybe_paste_with_next): Use per-macro GNU_REST_ARGS rather than per-token GNU_VARARGS. * cpplib.h (GNU_VARARGS): Remove. (GNU_REST_ARGS): New. * gcc.dg/cpp/macsyntx.c: New tests. From-SVN: r34919
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r--gcc/cpplex.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index 24e4712..03439fa 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -2222,9 +2222,9 @@ parse_args (pfile, hp, args)
e.g. #define debug(format, args...) ...
debug("string");
This is exactly the same as if the rest argument had received no
- tokens - debug("string",); */
+ tokens - debug("string",); This extension is deprecated. */
- if (argc + 1 == macro->paramc && (macro->flags & VAR_ARGS))
+ if (argc + 1 == macro->paramc && (macro->flags & GNU_REST_ARGS))
{
/* Duplicate the placemarker. Then we can set its flags and
position and safely be using more than one. */
@@ -2525,15 +2525,19 @@ maybe_paste_with_next (pfile, token)
second = cpp_get_token (pfile);
pfile->paste_level = 0;
- /* Ignore placemarker argument tokens. */
+ /* Ignore placemarker argument tokens (cannot be from an empty macro
+ since macros are not expanded). */
if (token->type == CPP_PLACEMARKER)
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 (token->flags & GNU_VARARGS)
+ 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);