aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplex.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-08-02 07:08:49 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-08-02 07:08:49 +0000
commit5ef865d5709f9c917e1152ee5246906983e23725 (patch)
tree5449dc33f09873b105cb47551859fae03a5f1a89 /gcc/cpplex.c
parenta7a4fd1776384e896797de1f06773ca1e7e908d4 (diff)
downloadgcc-5ef865d5709f9c917e1152ee5246906983e23725.zip
gcc-5ef865d5709f9c917e1152ee5246906983e23725.tar.gz
gcc-5ef865d5709f9c917e1152ee5246906983e23725.tar.bz2
cppexp.c, [...]: Do not use 'legal' or 'illegal' in error messages and comments.
* cppexp.c, cppinit.c, cpplex.c, cpplib.c, cppmacro.c, cppspec.c: Do not use 'legal' or 'illegal' in error messages and comments. * cppmain.c (cb_define, cb_undef): Don't generate any output if not done_initializing. * cpplex.c (maybe_paste_with_next): When the token after a ## is an omitted rest argument, only delete the token before it if that token is a comma. Do not warn about bogus token pastes for , ## rest_arg. * cpp.texi: Update. * cpp.1: Regenerate. * gcc.dg/cpp/macsyntx.c: Fix error regexp. From-SVN: r35421
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r--gcc/cpplex.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index d7ae494..7485fde 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -201,6 +201,10 @@ 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)->u.list->tokens[(c)->posn].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); \
@@ -990,7 +994,7 @@ parse_name (pfile, tok, cur, rlimit)
{
if (! is_idchar (*cur))
break;
- /* $ is not a legal identifier character in the standard, but is
+ /* $ is not a identifier character in the standard, but is
commonly accepted as an extension. Don't warn about it in
skipped conditional blocks. */
if (*cur == '$' && CPP_PEDANTIC (pfile) && ! pfile->skipping)
@@ -2732,10 +2736,11 @@ maybe_paste_with_next (pfile, token)
pasted = duplicate_token (pfile, second);
else if (second->type == CPP_PLACEMARKER)
{
- /* GCC has special extended semantics for a ## b where b is
- 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)
+ /* GCC has special extended 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). */
+ if (token->type == CPP_COMMA && second->flags & VOID_REST)
pasted = duplicate_token (pfile, second);
else
pasted = duplicate_token (pfile, token);
@@ -2748,8 +2753,19 @@ maybe_paste_with_next (pfile, token)
if (type == CPP_EOF)
{
if (CPP_OPTION (pfile, warn_paste))
- cpp_warning (pfile,
+ {
+ /* Do not complain about , ## <whatever> if
+ <whatever> came from a variable argument, because
+ the author probably intended the ## to trigger
+ the special extended semantics (see above). */
+ if (token->type == CPP_COMMA
+ && IS_ARG_CONTEXT (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;
}
@@ -3287,7 +3303,7 @@ lex_next (pfile, clear)
/* Pops a context off the context stack. If we're at the bottom, lexes
the next logical line. Returns EOF if we're at the end of the
- argument list to the # operator, or if it is illegal to "overflow"
+ argument list to the # operator, or we should not "overflow"
into the rest of the file (e.g. 6.10.3.1.1). */
static int
pop_context (pfile)