From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17930 invoked by alias); 11 May 2016 20:40:52 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 17921 invoked by uid 89); 11 May 2016 20:40:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 11 May 2016 20:40:41 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 193D783F44 for ; Wed, 11 May 2016 20:40:40 +0000 (UTC) Received: from redhat.com (ovpn-204-17.brq.redhat.com [10.40.204.17]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4BKebRT010210 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 11 May 2016 16:40:39 -0400 Date: Wed, 11 May 2016 20:40:00 -0000 From: Marek Polacek To: GCC Patches Subject: [PATCH] Fix crash with --help=^ (PR driver/71063) Message-ID: <20160511204036.GJ20450@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.6.0 (2016-04-01) X-SW-Source: 2016-05/txt/msg00865.txt.bz2 We crashed when given --help=^ and Kyrill explained why in the PR (). The following seems as good a fix as any, I think. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2016-05-11 Marek Polacek PR driver/71063 * opts.c (common_handle_option): Detect missing argument for --help^. * gcc.dg/opts-7.c: New test. diff --git gcc/opts.c gcc/opts.c index 0f9431a..71e0779 100644 --- gcc/opts.c +++ gcc/opts.c @@ -1640,6 +1640,11 @@ common_handle_option (struct gcc_options *opts, if (* a == '^') { ++ a; + if (*a == '\0') + { + error_at (loc, "missing argument to %qs", "--help=^"); + break; + } pflags = & exclude_flags; } else diff --git gcc/testsuite/gcc.dg/opts-7.c gcc/testsuite/gcc.dg/opts-7.c index e69de29..c54d0b8 100644 --- gcc/testsuite/gcc.dg/opts-7.c +++ gcc/testsuite/gcc.dg/opts-7.c @@ -0,0 +1,6 @@ +/* PR driver/71063 */ +/* Test we don't ICE. */ +/* { dg-do compile } */ +/* { dg-options "--help=^" } */ + +/* { dg-error "missing argument to" "" { target *-*-* } 0 } */ Marek