From patchwork Fri Feb 11 02:07:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 82710 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 385B0B7125 for ; Fri, 11 Feb 2011 13:08:07 +1100 (EST) Received: (qmail 29976 invoked by alias); 11 Feb 2011 02:08:04 -0000 Received: (qmail 29967 invoked by uid 22791); 11 Feb 2011 02:08:03 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 11 Feb 2011 02:07:59 +0000 Received: (qmail 30859 invoked from network); 11 Feb 2011 02:07:57 -0000 Received: from unknown (HELO digraph.polyomino.org.uk) (joseph@127.0.0.2) by mail.codesourcery.com with ESMTPA; 11 Feb 2011 02:07:57 -0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.72) (envelope-from ) id 1PniQM-0003Gk-KN for gcc-patches@gcc.gnu.org; Fri, 11 Feb 2011 02:07:54 +0000 Date: Fri, 11 Feb 2011 02:07:54 +0000 (UTC) From: "Joseph S. Myers" To: gcc-patches@gcc.gnu.org Subject: Fix PR 47678 (driver errors for missing option arguments) Message-ID: MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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? 2011-02-10 Joseph Myers 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);