Fixup generating error messages for unrecognised switches

Nick Clifton
Fri Nov 12 07:33:00 GMT 1999

Hi Guys,

  The patch below fixes a bug in my recent patch to tidy up cc1's
  command line parsing.  If the user did invoke gcc/cc1 with a
  completely invalid switch then no error would be generated because
  the string 'option' would always be non-NULL at the end of the 
  loop checking to see if the switch was recognised by other

  In a related issue the cpplib function cpp_handle_option would
  always claim to have successfully consumed an option starting with
  -f, even if it hadn't, and so no errors about unrecognised options
  starting with -f or -- would ever be generated.

  Is this patch OK to install ?


PS. I know that the curly braces around the 'return i;' statement in
  the patch to cpp_handle_option are unnecessary and do not conform to 
  the GNU coding standard.  They are there to make merging with the
  internal Cygnus version of the code easier.

Fri Nov 12 15:31:10 1999  Nick Clifton  <>

	* toplev.c (main): Correctly detect an unrecognised option.

	* cppinit.c (cpp_handle_option): Do not claim to have consumed
	a -f option if it has not been recognised.

Index: toplev.c
RCS file: /cvs/gcc/egcs/gcc/toplev.c,v
retrieving revision 1.257
diff -p -r1.257 toplev.c
*** toplev.c	1999/11/08 15:27:56	1.257
--- toplev.c	1999/11/12 15:23:01
*************** main (argc, argv)
*** 5461,5467 ****
! 	  if (option)
  	      if (extra_warnings)
--- 5461,5467 ----
! 	  if (j != NUM_ELEM (documented_lang_options))
  	      if (extra_warnings)
Index: cppinit.c
RCS file: /cvs/gcc/egcs/gcc/cppinit.c,v
retrieving revision 1.24
diff -p -r1.24 cppinit.c
*** cppinit.c	1999/11/10 17:57:20	1.24
--- cppinit.c	1999/11/12 15:23:02
*************** cpp_handle_option (pfile, argc, argv)
*** 1105,1110 ****
--- 1105,1114 ----
  	  opts->preprocessed = 1;
  	else if (!strcmp (argv[i], "-fno-preprocessed"))
  	  opts->preprocessed = 0;
+ 	else
+ 	  {
+ 	    return i;
+ 	  }
        case 'I':			/* Add directory to path for includes.  */

More information about the Gcc-patches mailing list