This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Reorganise cc command line parsing
- To: jason at cygnus dot com
- Subject: Re: Reorganise cc command line parsing
- From: Nick Clifton <nickc at cygnus dot com>
- Date: Sun, 26 Sep 1999 11:27:01 +0100
- CC: gcc-patches at gcc dot gnu dot org
- Reply-to: nickc at cygnus dot co dot uk
Hi Jason,
: This patch causes us to complain about getting flags that are accepted by
: other languages, contrary to the comment in the old code,
:
: ! /* If the option is valid for *some* language,
: ! treat it as valid even if this language doesn't understand it. */
:
: Please fix.
Your wish is my command.
Here is a patch to fix this problem. It has one additional feature
over the behaviour of the original, and I am not sure if you will
approve. The new code will generate a warning message, explaining
that the command line option is being ignored, if extra warnings are
enabled. So for example this command line:
% gcc -faccess-control foo.c
will generate any errors or warnings (about the -faccess-control
switch), whereas this command line:
% gcc -faccess-control -W foo.c
will generate the warning message:
cc1: warning: Ignoring command line option '-faccess-control'
cc1: warning: (It is valid for C++ but not the selected langauge)
May I apply this patch ?
Cheers
Nick
Sun Sep 26 11:25:38 1999 Nick Clifton <nickc@cygnus.com>
* toplev.c (main): Do not generate an error message if an
unrecognised command line switch is recognisable by another
language. If extra_warnings are enabled, then generate a
warning message instead.
Index: toplev.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/toplev.c,v
retrieving revision 1.232
diff -p -r1.232 toplev.c
*** toplev.c 1999/09/25 19:13:18 1.232
--- toplev.c 1999/09/26 10:24:29
*************** main (argc, argv)
*** 5379,5391 ****
only be decoded in a language independent way if the were not
decoded in a langauge specific way, which is why 'lang_processed'
is passed in. */
! indep_processed = independent_decode_option (argc - i, argv + i, lang_processed);
if (lang_processed || indep_processed)
! i += lang_processed > indep_processed ? lang_processed : indep_processed;
else
{
! error ("Invalid option `%s'", argv[i]);
i++;
}
}
--- 5379,5426 ----
only be decoded in a language independent way if the were not
decoded in a langauge specific way, which is why 'lang_processed'
is passed in. */
! indep_processed = independent_decode_option (argc - i, argv + i,
! lang_processed);
if (lang_processed || indep_processed)
! i += lang_processed > indep_processed
! ? lang_processed : indep_processed;
else
{
! const char * option = NULL;
! const char * lang = NULL;
! unsigned int j;
!
! /* It is possible that the command line switch is not valid for the
! current language, but it is valid for another language. In order
! to be compatible with previous versions of the compiler (which
! did not issue an error message in this case) we check for this
! possibilty here. If we do find a match, then if extra_warnings
! is set we generate a warning message, otherwise we will just
! ignore the option. */
! for (j = 0; j < NUM_ELEM (documented_lang_options); j++)
! {
! option = documented_lang_options[j].option;
!
! if (option == NULL)
! lang = documented_lang_options[j].description;
! else if (! strncmp (argv[i], option, strlen (option)))
! break;
! }
!
! if (option)
! {
! if (extra_warnings)
! {
! warning ("Ignoring command line option '%s'", argv[i]);
! if (lang)
! warning ("\
! (It is valid for %s but not the selected langauge)", lang);
! }
! }
! else
! error ("Unrecognised option `%s'", argv[i]);
!
i++;
}
}