diff options
author | kan <kan@FreeBSD.org> | 2002-09-01 20:38:57 +0000 |
---|---|---|
committer | kan <kan@FreeBSD.org> | 2002-09-01 20:38:57 +0000 |
commit | 2e25f3a6c57335cba50111faceb0ce2ab59e9bcb (patch) | |
tree | c6857d31c36dbd89a881b0229bf38b062797d413 /contrib/gcc/cppmacro.c | |
parent | 0895e1acb698e05d503c26bec5471de2e88b7d93 (diff) | |
download | FreeBSD-src-2e25f3a6c57335cba50111faceb0ce2ab59e9bcb.zip FreeBSD-src-2e25f3a6c57335cba50111faceb0ce2ab59e9bcb.tar.gz |
Gcc 3.2.1-prerelease from the FSF anoncvs repo gcc-3_2-branch on 1-Sep-2002 00:00:01 EDT.
Diffstat (limited to 'contrib/gcc/cppmacro.c')
-rw-r--r-- | contrib/gcc/cppmacro.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/contrib/gcc/cppmacro.c b/contrib/gcc/cppmacro.c index b351f96..c85ac21 100644 --- a/contrib/gcc/cppmacro.c +++ b/contrib/gcc/cppmacro.c @@ -613,7 +613,20 @@ collect_args (pfile, node) } if (!error) - return base_buff; + { + /* GCC has special semantics for , ## b where b is a varargs + parameter: we remove the comma if b was omitted entirely. + If b was merely an empty argument, the comma is retained. + If the macro takes just one (varargs) parameter, then we + retain the comma only if we are standards conforming. + + If FIRST is NULL replace_args () swallows the comma. */ + if (macro->variadic && (argc < macro->paramc + || (argc == 1 && args[0].count == 0 + && !CPP_OPTION (pfile, std)))) + args[macro->paramc - 1].first = NULL; + return base_buff; + } _cpp_release_buff (pfile, base_buff); return NULL; @@ -673,6 +686,8 @@ enter_macro_context (pfile, node) /* The presence of a macro invalidates a file's controlling macro. */ pfile->mi_valid = false; + pfile->state.angled_headers = false; + /* Handle standard macros. */ if (! (node->flags & NODE_BUILTIN)) { @@ -797,15 +812,13 @@ replace_args (pfile, node, args) count = arg->count, from = arg->first; if (dest != first) { - /* GCC has special semantics for , ## b where b is a - varargs parameter: the comma disappears if b was - given no actual arguments (not merely if b is an - empty argument); otherwise the paste flag is removed. */ if (dest[-1]->type == CPP_COMMA && macro->variadic && src->val.arg_no == macro->paramc) { - if (count == 0) + /* Swallow a pasted comma if from == NULL, otherwise + drop the paste flag. */ + if (from == NULL) dest--; else paste_flag = dest - 1; @@ -1529,7 +1542,7 @@ cpp_macro_definition (pfile, node) } /* Calculate length. */ - len = NODE_LEN (node) + 1; /* ' ' */ + len = NODE_LEN (node) + 2; /* ' ' and NUL. */ if (macro->fun_like) { len += 4; /* "()" plus possible final ".." of named |