This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix PR 47678 (driver errors for missing option arguments)


On Fri, Feb 11, 2011 at 3:07 AM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> This patch fixes PR 47678, a regression from some of my option
> handling changes where missing arguments to -I options were not
> diagnosed because -I was considered as a front-end option, not a
> driver one, and so was a "wrong language" option in the driver, with
> "wrong language" taking precedence over errors in the option.
>
> The patch moves the "wrong language" checks - generally a warning
> condition in the compilers proper, and quietly ignored in the driver
> since that needs to pass down lots of non-driver options - after the
> checks for error conditions. ?This restores the driver error for -I
> without an argument. ?To avoid problems arising with the compilers
> proper then being called after such an error (the erroneous options
> having been removed rather than passed down to the compilers proper),
> the driver is changed to avoid compilation if an error occurs in
> option processing. ?(In particular, objc.dg/strings/const-str-2.m
> expects an error in option processing to cause subsequent compilation
> not to occur. ?That was the case when the erroneous option was
> detected in cc1obj; when the driver detects it as erroneous rather
> than passing it down as wrong-language, the driver must also take
> responsibility for stopping subsequent compilation.)
>
> (These were changes I'd planned to make anyway for 4.7 - along with
> requiring all driver options to be in .opt files, which is still
> planned for 4.7 not 4.6 - but the regression PR provides a case for
> making the changes in this patch now.)
>
> Bootstrapped with no regressions on x86_64-unknown-linux-gnu. ?Are the
> driver changes OK to commit?

Ok.  Can you add a testcase?

Thanks,
Richard.

> 2011-02-10 ?Joseph Myers ?<joseph@codesourcery.com>
>
> ? ? ? ?PR driver/47678
> ? ? ? ?* gcc.c (main): Do not compile inputs if there were errors in
> ? ? ? ?option handling.
> ? ? ? ?* opts-common.c (read_cmdline_option): Check for wrong language
> ? ? ? ?after other error checks.
>
> Index: gcc/opts-common.c
> ===================================================================
> --- gcc/opts-common.c ? (revision 170011)
> +++ gcc/opts-common.c ? (working copy)
> @@ -960,12 +960,6 @@ read_cmdline_option (struct gcc_options
> ? ? ? return;
> ? ? }
>
> - ?if (decoded->errors & CL_ERR_WRONG_LANG)
> - ? ?{
> - ? ? ?handlers->wrong_lang_callback (decoded, lang_mask);
> - ? ? ?return;
> - ? ?}
> -
> ? if (decoded->errors & CL_ERR_MISSING_ARG)
> ? ? {
> ? ? ? if (option->missing_argument_error)
> @@ -1012,6 +1006,12 @@ read_cmdline_option (struct gcc_options
> ? ? ? return;
> ? ? }
>
> + ?if (decoded->errors & CL_ERR_WRONG_LANG)
> + ? ?{
> + ? ? ?handlers->wrong_lang_callback (decoded, lang_mask);
> + ? ? ?return;
> + ? ?}
> +
> ? gcc_assert (!decoded->errors);
>
> ? if (!handle_option (opts, opts_set, decoded, lang_mask, DK_UNSPECIFIED,
> Index: gcc/gcc.c
> ===================================================================
> --- gcc/gcc.c ? (revision 170011)
> +++ gcc/gcc.c ? (working copy)
> @@ -6597,6 +6597,9 @@ warranty; not even for MERCHANTABILITY o
> ? if (n_infiles == added_libraries)
> ? ? fatal_error ("no input files");
>
> + ?if (seen_error ())
> + ? ?goto out;
> +
> ? /* Make a place to record the compiler output file names
> ? ? ?that correspond to the input files. ?*/
>
> @@ -6864,6 +6867,7 @@ warranty; not even for MERCHANTABILITY o
> ? ? ? printf ("%s\n", bug_report_url);
> ? ? }
>
> + out:
> ? return (signal_count != 0 ? 2
> ? ? ? ? ?: seen_error () ? (pass_exit_codes ? greatest_status : 1)
> ? ? ? ? ?: 0);
>
> --
> Joseph S. Myers
> joseph@codesourcery.com
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]