cpperror.c (_cpp_begin_message): Do the test for suppression of warnings and pedantic warnings before the "is a...

* cpperror.c (_cpp_begin_message):  Do the test for suppression
        of warnings and pedantic warnings before the "is a warning an
        error" tests.
	* cppinit.c (cpp_handle_option): Remove surplus \n.
	* cpplex.c (ON_REST_ARG): Delete.
	(skip_block_comment): Initialise prevc.
	(parse_args): Improve error messages.
	(maybe_paste_with_next): Use CONTEXT_VARARGS rather
	than ON_REST_ARG.
	* cpplib.c (cpp_push_buffer): Fix grammar in message.
	* cppmain.c (main): Set callbacks for #ident and #pragma
	only if no_output option is false.
	(do_pragma_implementation): Only call the #pragma handler
	if it is set in the cpp_reader structure.

From-SVN: r36655
This commit is contained in:
Neil Booth 2000-09-28 05:55:22 +00:00 committed by Neil Booth
parent e93eff9433
commit d809068018
6 changed files with 48 additions and 25 deletions

View File

@ -1,3 +1,20 @@
2000-09-28 Neil Booth <neilb@earthling.net>
* cpperror.c (_cpp_begin_message): Do the test for suppression
of warnings and pedantic warnings before the "is a warning an
error" tests.
* cppinit.c (cpp_handle_option): Remove surplus \n.
* cpplex.c (ON_REST_ARG): Delete.
(skip_block_comment): Initialise prevc.
(parse_args): Improve error messages.
(maybe_paste_with_next): Use CONTEXT_VARARGS rather
than ON_REST_ARG.
* cpplib.c (cpp_push_buffer): Fix grammar in message.
* cppmain.c (main): Set callbacks for #ident and #pragma
only if no_output option is false.
(do_pragma_implementation): Only call the #pragma handler
if it is set in the cpp_reader structure.
Wed Sep 27 14:00:07 2000 Donald Lindsay <dlindsay@cygnus.com> Wed Sep 27 14:00:07 2000 Donald Lindsay <dlindsay@cygnus.com>
* integrate.c (copy_insn_list): if an ignored return value * integrate.c (copy_insn_list): if an ignored return value

View File

@ -120,11 +120,12 @@ _cpp_begin_message (pfile, code, file, line, col)
switch (code) switch (code)
{ {
case WARNING: case WARNING:
if (CPP_IN_SYSTEM_HEADER (pfile)
&& ! CPP_OPTION (pfile, warn_system_headers))
return 0;
if (! CPP_OPTION (pfile, warnings_are_errors)) if (! CPP_OPTION (pfile, warnings_are_errors))
{ {
if (CPP_OPTION (pfile, inhibit_warnings) if (CPP_OPTION (pfile, inhibit_warnings))
|| (CPP_IN_SYSTEM_HEADER (pfile)
&& ! CPP_OPTION (pfile, warn_system_headers)))
return 0; return 0;
is_warning = 1; is_warning = 1;
} }
@ -138,11 +139,12 @@ _cpp_begin_message (pfile, code, file, line, col)
break; break;
case PEDWARN: case PEDWARN:
if (CPP_IN_SYSTEM_HEADER (pfile)
&& ! CPP_OPTION (pfile, warn_system_headers))
return 0;
if (! CPP_OPTION (pfile, pedantic_errors)) if (! CPP_OPTION (pfile, pedantic_errors))
{ {
if (CPP_OPTION (pfile, inhibit_warnings) if (CPP_OPTION (pfile, inhibit_warnings))
|| (CPP_IN_SYSTEM_HEADER (pfile)
&& ! CPP_OPTION (pfile, warn_system_headers)))
return 0; return 0;
is_warning = 1; is_warning = 1;
} }

View File

@ -1403,7 +1403,7 @@ cpp_handle_option (pfile, argc, argv)
CPP_OPTION (pfile, out_fname) = ""; CPP_OPTION (pfile, out_fname) = "";
break; break;
case OPT_v: case OPT_v:
fprintf (stderr, _("GNU CPP version %s (cpplib)\n"), version_string); fprintf (stderr, _("GNU CPP version %s (cpplib)"), version_string);
#ifdef TARGET_VERSION #ifdef TARGET_VERSION
TARGET_VERSION; TARGET_VERSION;
#endif #endif

View File

@ -162,10 +162,6 @@ TOKEN_LEN (token)
#define IS_ARG_CONTEXT(c) ((c)->flags & CONTEXT_ARG) #define IS_ARG_CONTEXT(c) ((c)->flags & CONTEXT_ARG)
#define CURRENT_CONTEXT(pfile) ((pfile)->contexts + (pfile)->cur_context) #define CURRENT_CONTEXT(pfile) ((pfile)->contexts + (pfile)->cur_context)
#define ON_REST_ARG(c) \
(((c)->u.list->flags & VAR_ARGS) \
&& (c)->u.list->tokens[(c)->posn - 1].val.aux \
== (unsigned int) ((c)->u.list->paramc - 1))
#define ASSIGN_FLAGS_AND_POS(d, s) \ #define ASSIGN_FLAGS_AND_POS(d, s) \
do {(d)->flags = (s)->flags & (PREV_WHITE | BOL | PASTE_LEFT); \ do {(d)->flags = (s)->flags & (PREV_WHITE | BOL | PASTE_LEFT); \
@ -573,7 +569,7 @@ skip_block_comment (pfile)
cpp_reader *pfile; cpp_reader *pfile;
{ {
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
cppchar_t c = EOF, prevc; cppchar_t c = EOF, prevc = EOF;
pfile->state.lexing_comment = 1; pfile->state.lexing_comment = 1;
while (buffer->cur != buffer->rlimit) while (buffer->cur != buffer->rlimit)
@ -1837,6 +1833,7 @@ is_macro_disabled (pfile, expansion, token)
pfile->no_expand_level = context - pfile->contexts; pfile->no_expand_level = context - pfile->contexts;
next = _cpp_get_token (pfile); next = _cpp_get_token (pfile);
restore_macro_expansion (pfile, prev_nme); restore_macro_expansion (pfile, prev_nme);
if (next->type != CPP_OPEN_PAREN) if (next->type != CPP_OPEN_PAREN)
{ {
_cpp_push_token (pfile, next); _cpp_push_token (pfile, next);
@ -2001,7 +1998,8 @@ parse_args (pfile, hp, args)
} }
else else
{ {
cpp_error (pfile, "not enough arguments for macro \"%s\"", hp->name); cpp_error (pfile, "%u arguments is not enough for macro \"%s\"",
argc, hp->name);
return 1; return 1;
} }
} }
@ -2009,7 +2007,8 @@ parse_args (pfile, hp, args)
else if (argc > macro->paramc else if (argc > macro->paramc
&& !(macro->paramc == 0 && argc == 1 && empty_argument (args, 0))) && !(macro->paramc == 0 && argc == 1 && empty_argument (args, 0)))
{ {
cpp_error (pfile, "too many arguments for macro \"%s\"", hp->name); cpp_error (pfile, "%u arguments is too many for macro \"%s\"",
argc, hp->name);
return 1; return 1;
} }
@ -2331,8 +2330,8 @@ maybe_paste_with_next (pfile, token)
<whatever> came from a variable argument, because <whatever> came from a variable argument, because
the author probably intended the ## to trigger the author probably intended the ## to trigger
the special extended semantics (see above). */ the special extended semantics (see above). */
if (token->type == CPP_COMMA && IS_ARG_CONTEXT (context) if (token->type == CPP_COMMA
&& ON_REST_ARG (context - 1)) && (context->flags & CONTEXT_VARARGS))
/* no warning */; /* no warning */;
else else
cpp_warning (pfile, cpp_warning (pfile,

View File

@ -1495,7 +1495,7 @@ cpp_push_buffer (pfile, buffer, length)
cpp_buffer *new; cpp_buffer *new;
if (++pfile->buffer_stack_depth == CPP_STACK_MAX) if (++pfile->buffer_stack_depth == CPP_STACK_MAX)
{ {
cpp_fatal (pfile, "#include nested too deep"); cpp_fatal (pfile, "#include nested too deeply");
return NULL; return NULL;
} }
if (pfile->cur_context > 0) if (pfile->cur_context > 0)

View File

@ -88,15 +88,21 @@ main (argc, argv)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
/* Set callbacks. */ /* Set callbacks. */
if (! CPP_OPTION (pfile, no_line_commands) if (! CPP_OPTION (pfile, no_output))
&& ! CPP_OPTION (pfile, no_output)) {
pfile->cb.ident = cb_ident;
pfile->cb.def_pragma = cb_def_pragma;
if (! CPP_OPTION (pfile, no_line_commands))
{ {
pfile->cb.enter_file = cb_enter_file; pfile->cb.enter_file = cb_enter_file;
pfile->cb.leave_file = cb_leave_file; pfile->cb.leave_file = cb_leave_file;
pfile->cb.rename_file = cb_rename_file; pfile->cb.rename_file = cb_rename_file;
} }
}
if (CPP_OPTION (pfile, dump_includes)) if (CPP_OPTION (pfile, dump_includes))
pfile->cb.include = cb_include; pfile->cb.include = cb_include;
if (CPP_OPTION (pfile, debug_output) if (CPP_OPTION (pfile, debug_output)
|| CPP_OPTION (pfile, dump_macros) == dump_names || CPP_OPTION (pfile, dump_macros) == dump_names
|| CPP_OPTION (pfile, dump_macros) == dump_definitions) || CPP_OPTION (pfile, dump_macros) == dump_definitions)
@ -105,8 +111,6 @@ main (argc, argv)
pfile->cb.undef = cb_undef; pfile->cb.undef = cb_undef;
pfile->cb.poison = cb_def_pragma; pfile->cb.poison = cb_def_pragma;
} }
pfile->cb.ident = cb_ident;
pfile->cb.def_pragma = cb_def_pragma;
/* Register one #pragma which needs special handling. */ /* Register one #pragma which needs special handling. */
cpp_register_pragma(pfile, 0, "implementation", do_pragma_implementation); cpp_register_pragma(pfile, 0, "implementation", do_pragma_implementation);
@ -271,7 +275,8 @@ do_pragma_implementation (pfile)
} }
/* forward to default-pragma handler. */ /* forward to default-pragma handler. */
cb_def_pragma (pfile); if (pfile->cb.def_pragma)
(*pfile->cb.def_pragma) (pfile);
} }
/* Dump out the hash table. */ /* Dump out the hash table. */