This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Various minor fixes
- To: gcc-patches at gcc dot gnu dot org
- Subject: Various minor fixes
- From: Neil Booth <NeilB at earthling dot net>
- Date: Wed, 27 Sep 2000 19:23:10 +0100
- Cc: Andreas Jaeger <aj at suse dot de>, Andreas Schwab <schwab at suse dot de>
This fixes a few things reported recently:
a) -dM would output #pragmas.
b) Andreas' extra newline with --version.
c) The system header fix for cpplib.
Also removes ON_REST_ARGS which is now redundant, removes a stage2
warning about a possibly unused variable, and improves a few messages.
Neil.
* 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.
Index: gcc/cpperror.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpperror.c,v
retrieving revision 1.38
diff -c -p -r1.38 cpperror.c
*** cpperror.c 2000/09/25 22:54:02 1.38
--- cpperror.c 2000/09/27 18:10:15
*************** _cpp_begin_message (pfile, code, file, l
*** 120,130 ****
switch (code)
{
case WARNING:
if (! CPP_OPTION (pfile, warnings_are_errors))
{
! if (CPP_OPTION (pfile, inhibit_warnings)
! || (CPP_IN_SYSTEM_HEADER (pfile)
! && ! CPP_OPTION (pfile, warn_system_headers)))
return 0;
is_warning = 1;
}
--- 120,131 ----
switch (code)
{
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, inhibit_warnings))
return 0;
is_warning = 1;
}
*************** _cpp_begin_message (pfile, code, file, l
*** 138,148 ****
break;
case PEDWARN:
if (! CPP_OPTION (pfile, pedantic_errors))
{
! if (CPP_OPTION (pfile, inhibit_warnings)
! || (CPP_IN_SYSTEM_HEADER (pfile)
! && ! CPP_OPTION (pfile, warn_system_headers)))
return 0;
is_warning = 1;
}
--- 139,150 ----
break;
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, inhibit_warnings))
return 0;
is_warning = 1;
}
Index: gcc/cppinit.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cppinit.c,v
retrieving revision 1.110
diff -c -p -r1.110 cppinit.c
*** cppinit.c 2000/09/25 22:54:02 1.110
--- cppinit.c 2000/09/27 18:10:20
*************** cpp_handle_option (pfile, argc, argv)
*** 1403,1409 ****
CPP_OPTION (pfile, out_fname) = "";
break;
case OPT_v:
! fprintf (stderr, _("GNU CPP version %s (cpplib)\n"), version_string);
#ifdef TARGET_VERSION
TARGET_VERSION;
#endif
--- 1403,1409 ----
CPP_OPTION (pfile, out_fname) = "";
break;
case OPT_v:
! fprintf (stderr, _("GNU CPP version %s (cpplib)"), version_string);
#ifdef TARGET_VERSION
TARGET_VERSION;
#endif
Index: gcc/cpplex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpplex.c,v
retrieving revision 1.105
diff -c -p -r1.105 cpplex.c
*** cpplex.c 2000/09/25 23:35:09 1.105
--- cpplex.c 2000/09/27 18:10:28
*************** TOKEN_LEN (token)
*** 162,171 ****
#define IS_ARG_CONTEXT(c) ((c)->flags & CONTEXT_ARG)
#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) \
do {(d)->flags = (s)->flags & (PREV_WHITE | BOL | PASTE_LEFT); \
--- 162,167 ----
*************** skip_block_comment (pfile)
*** 573,579 ****
cpp_reader *pfile;
{
cpp_buffer *buffer = pfile->buffer;
! cppchar_t c = EOF, prevc;
pfile->state.lexing_comment = 1;
while (buffer->cur != buffer->rlimit)
--- 569,575 ----
cpp_reader *pfile;
{
cpp_buffer *buffer = pfile->buffer;
! cppchar_t c = EOF, prevc = EOF;
pfile->state.lexing_comment = 1;
while (buffer->cur != buffer->rlimit)
*************** is_macro_disabled (pfile, expansion, tok
*** 1837,1842 ****
--- 1833,1839 ----
pfile->no_expand_level = context - pfile->contexts;
next = _cpp_get_token (pfile);
restore_macro_expansion (pfile, prev_nme);
+
if (next->type != CPP_OPEN_PAREN)
{
_cpp_push_token (pfile, next);
*************** parse_args (pfile, hp, args)
*** 2001,2007 ****
}
else
{
! cpp_error (pfile, "not enough arguments for macro \"%s\"", hp->name);
return 1;
}
}
--- 1998,2005 ----
}
else
{
! cpp_error (pfile, "%u arguments is not enough for macro \"%s\"",
! argc, hp->name);
return 1;
}
}
*************** parse_args (pfile, hp, args)
*** 2009,2015 ****
else if (argc > macro->paramc
&& !(macro->paramc == 0 && argc == 1 && empty_argument (args, 0)))
{
! cpp_error (pfile, "too many arguments for macro \"%s\"", hp->name);
return 1;
}
--- 2007,2014 ----
else if (argc > macro->paramc
&& !(macro->paramc == 0 && argc == 1 && empty_argument (args, 0)))
{
! cpp_error (pfile, "%u arguments is too many for macro \"%s\"",
! argc, hp->name);
return 1;
}
*************** maybe_paste_with_next (pfile, token)
*** 2331,2338 ****
<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 (context)
! && ON_REST_ARG (context - 1))
/* no warning */;
else
cpp_warning (pfile,
--- 2330,2337 ----
<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
! && (context->flags & CONTEXT_VARARGS))
/* no warning */;
else
cpp_warning (pfile,
Index: gcc/cpplib.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpplib.c,v
retrieving revision 1.206
diff -c -p -r1.206 cpplib.c
*** cpplib.c 2000/09/25 22:54:03 1.206
--- cpplib.c 2000/09/27 18:10:32
*************** cpp_push_buffer (pfile, buffer, length)
*** 1495,1501 ****
cpp_buffer *new;
if (++pfile->buffer_stack_depth == CPP_STACK_MAX)
{
! cpp_fatal (pfile, "#include nested too deep");
return NULL;
}
if (pfile->cur_context > 0)
--- 1495,1501 ----
cpp_buffer *new;
if (++pfile->buffer_stack_depth == CPP_STACK_MAX)
{
! cpp_fatal (pfile, "#include nested too deeply");
return NULL;
}
if (pfile->cur_context > 0)
Index: gcc/cppmain.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cppmain.c,v
retrieving revision 1.35
diff -c -p -r1.35 cppmain.c
*** cppmain.c 2000/08/20 21:36:17 1.35
--- cppmain.c 2000/09/27 18:10:34
*************** main (argc, argv)
*** 88,102 ****
return (FATAL_EXIT_CODE);
/* Set callbacks. */
! if (! CPP_OPTION (pfile, no_line_commands)
! && ! CPP_OPTION (pfile, no_output))
{
! pfile->cb.enter_file = cb_enter_file;
! pfile->cb.leave_file = cb_leave_file;
! pfile->cb.rename_file = cb_rename_file;
}
if (CPP_OPTION (pfile, dump_includes))
pfile->cb.include = cb_include;
if (CPP_OPTION (pfile, debug_output)
|| CPP_OPTION (pfile, dump_macros) == dump_names
|| CPP_OPTION (pfile, dump_macros) == dump_definitions)
--- 88,108 ----
return (FATAL_EXIT_CODE);
/* Set callbacks. */
! if (! 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.leave_file = cb_leave_file;
! pfile->cb.rename_file = cb_rename_file;
! }
}
+
if (CPP_OPTION (pfile, dump_includes))
pfile->cb.include = cb_include;
+
if (CPP_OPTION (pfile, debug_output)
|| CPP_OPTION (pfile, dump_macros) == dump_names
|| CPP_OPTION (pfile, dump_macros) == dump_definitions)
*************** main (argc, argv)
*** 105,112 ****
pfile->cb.undef = cb_undef;
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. */
cpp_register_pragma(pfile, 0, "implementation", do_pragma_implementation);
--- 111,116 ----
*************** do_pragma_implementation (pfile)
*** 271,277 ****
}
/* forward to default-pragma handler. */
! cb_def_pragma (pfile);
}
/* Dump out the hash table. */
--- 275,282 ----
}
/* forward to default-pragma handler. */
! if (pfile->cb.def_pragma)
! (*pfile->cb.def_pragma) (pfile);
}
/* Dump out the hash table. */