Commit 5ef865d5 by Zack Weinberg Committed by Zack Weinberg

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
parent a7a4fd17
2000-08-02 Zack Weinberg <zack@wolery.cumb.org>
* 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.
2000-08-02 Fred Fish <fnf@be.com>
* config/i386/beos-elf.h (STARTFILE_SPEC): Add i386-mcount.o
......
......@@ -193,7 +193,7 @@ parse_number (pfile, tok)
{
/* Check for a floating point constant. Note that float constants
with an exponent or suffix but no decimal point are technically
illegal (C99 6.4.4.2) but accepted elsewhere. */
invalid (C99 6.4.4.2) but accepted elsewhere. */
if ((c == '.' || c == 'F' || c == 'f')
|| (base == 10 && (c == 'E' || c == 'e')
&& p+1 < end && (p[1] == '+' || p[1] == '-'))
......
......@@ -785,7 +785,7 @@ cpp_start_read (pfile, print, fname)
if (CPP_OPTION (pfile, cplusplus))
CPP_OPTION (pfile, warn_traditional) = 0;
/* Do not warn about illegal token pasting if -lang-asm. */
/* Do not warn about invalid token pasting if -lang-asm. */
if (CPP_OPTION (pfile, lang_asm))
CPP_OPTION (pfile, warn_paste) = 0;
......
......@@ -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)
......
......@@ -433,7 +433,7 @@ read_line_number (pfile, num)
/* Another subroutine of do_line. Convert a number in STR, of length
LEN, to binary; store it in NUMP, and return 0 if the number was
legal, 1 if not. Temporary, hopefully. */
well-formed, 1 if not. Temporary, hopefully. */
static int
strtoul_for_line (str, len, nump)
const U_CHAR *str;
......
......@@ -127,7 +127,7 @@ count_params (pfile, info)
{
default:
cpp_error_with_line (pfile, token->line, token->col,
"illegal token in macro parameter list");
"token may not appear in macro parameter list");
return;
case CPP_EOF:
......@@ -462,7 +462,7 @@ save_expansion (pfile, info)
else
dest->flags = token->flags; /* Particularly PREV_WHITE. */
/* Turn off PREV_WHITE if we immediately follow a paste.
That way, even if the paste turns out to be illegal, there
That way, even if the paste turns out to be invalid, there
will be no space between the two tokens in the output. */
if (token[-1].type == CPP_PASTE)
dest->flags &= ~PREV_WHITE;
......
......@@ -145,11 +145,14 @@ cb_define (pfile, hash)
cpp_reader *pfile;
cpp_hashnode *hash;
{
cpp_printf (pfile, &parse_out, "#define %s", hash->name);
if (CPP_OPTION (pfile, debug_output)
|| CPP_OPTION (pfile, dump_macros) == dump_definitions)
cpp_dump_definition (pfile, parse_out.outf, hash);
putc ('\n', parse_out.outf);
if (pfile->done_initializing)
{
cpp_printf (pfile, &parse_out, "#define %s", hash->name);
if (CPP_OPTION (pfile, debug_output)
|| CPP_OPTION (pfile, dump_macros) == dump_definitions)
cpp_dump_definition (pfile, parse_out.outf, hash);
putc ('\n', parse_out.outf);
}
}
static void
......@@ -157,7 +160,8 @@ cb_undef (pfile, hash)
cpp_reader *pfile;
cpp_hashnode *hash;
{
cpp_printf (pfile, &parse_out, "#undef %s\n", hash->name);
if (pfile->done_initializing)
cpp_printf (pfile, &parse_out, "#undef %s\n", hash->name);
}
static void
......
......@@ -125,7 +125,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
need_E = 0;
else if (argv[i][1] == 'S' || argv[i][1] == 'c')
{
fatal ("\"%s\" is not a legal option to the preprocessor",
fatal ("\"%s\" is not a valid option to the preprocessor",
argv[i]);
return;
}
......
2000-08-02 Zack Weinberg <zack@wolery.cumb.org>
* gcc.dg/cpp/macsyntx.c: Fix error regexp.
Mon Jul 31 21:14:49 2000 Jeffrey A Law (law@cygnus.com)
* gcc-c-torture/execute/20000731-2.c: New test.
......
......@@ -28,7 +28,7 @@
#define foo(, X) /* { dg-error "parameter name" } */
#define foo(X, X) /* { dg-error "duplicate" } */
#define foo(X Y) /* { dg-error "comma" } */
#define foo(() /* { dg-error "illegal token" } */
#define foo(() /* { dg-error "token may not appear" } */
#define foo(..., X) /* { dg-error "missing" } */
#define foo \
__VA_ARGS__ /* { dg-warning "__VA_ARGS__" } */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment