This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix PR 47678 (driver errors for missing option arguments)
On Fri, 11 Feb 2011, Richard Guenther wrote:
> Ok. Can you add a testcase?
Testing the original (regression) problem is tricky because it relies on
an option such as -I at the end of the driver command line, and DejaGnu
wants to add its own options there. I've committed this version with a
patch testing -ftemplate-depth= for C (that particular case does not
involve a regression).
Index: gcc/opts-common.c
===================================================================
--- gcc/opts-common.c (revision 170055)
+++ gcc/opts-common.c (revision 170056)
@@ -960,12 +960,6 @@
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 @@
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 170055)
+++ gcc/gcc.c (revision 170056)
@@ -6597,6 +6597,9 @@
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 @@
printf ("%s\n", bug_report_url);
}
+ out:
return (signal_count != 0 ? 2
: seen_error () ? (pass_exit_codes ? greatest_status : 1)
: 0);
Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog (revision 170055)
+++ gcc/ChangeLog (revision 170056)
@@ -1,3 +1,11 @@
+2011-02-11 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.
+
2011-02-11 Nathan Froyd <froydnj@codesourcery.com>
* cgraph.c: Fix comment typos.
Index: gcc/testsuite/gcc.dg/opts-6.c
===================================================================
--- gcc/testsuite/gcc.dg/opts-6.c (revision 0)
+++ gcc/testsuite/gcc.dg/opts-6.c (revision 170056)
@@ -0,0 +1,6 @@
+/* Missing option arguments take precedence over wrong-language
+ warnings. */
+/* { dg-do compile } */
+/* { dg-options "-ftemplate-depth=" } */
+
+/* { dg-error "missing argument" "" { target *-*-* } 0 } */
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (revision 170055)
+++ gcc/testsuite/ChangeLog (revision 170056)
@@ -1,3 +1,8 @@
+2011-02-11 Joseph Myers <joseph@codesourcery.com>
+
+ PR driver/47678
+ * gcc.dg/opts-6.c: New test.
+
2011-02-11 Jakub Jelinek <jakub@redhat.com>
PR debug/47684
--
Joseph S. Myers
joseph@codesourcery.com