From patchwork Thu Jul 30 17:05:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gunther Nikl X-Patchwork-Id: 502219 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44AA11402AE for ; Fri, 31 Jul 2015 03:05:46 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=nRH4yFky; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; q=dns; s= default; b=j24pu9oStM/pTPSO0Yllq38GFpjt6EQmhZvV/2MSz3Qzfug6GyLVr si5Cv8IshwoFnLIuZxymJ3k2ipNom1qTSQt6CAS0osReOpowldqww8A84uqRVYZh GEySgui6LJp7FdND1nGtukqqeAg2QpStkmm8uLrqssEdZMb9ZMem8M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; s=default; bh=XwHovyXpHbr1niaSATTqj9WvcXc=; b=nRH4yFkyIxnZ3F4vw1b5e3UXYFcr UjreqHgK+QGtQOeUUnQjTriJBtTCyKlAfhGigUeUPssSWnY+32EcebUvcHzsnEdk EGbibKf8u3vDa57242RUkiSx6KPH9lW/mO3oZ7I2T68iHtwvg44DNmVwvYB8oh3L 0du07cpUYLLUhRw= Received: (qmail 82822 invoked by alias); 30 Jul 2015 17:05:39 -0000 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 Received: (qmail 82807 invoked by uid 89); 30 Jul 2015 17:05:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 X-HELO: relay.baltic.net Received: from relay.baltic.net (HELO relay.baltic.net) (193.189.247.8) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Jul 2015 17:05:37 +0000 Received: from kirk.baltic.net (kirk.baltic.net [193.189.247.10]) by relay.baltic.net (Postfix) with ESMTPS id 4040B40097 for ; Thu, 30 Jul 2015 19:11:55 +0200 (CEST) Received: (qmail 5338 invoked by uid 89); 30 Jul 2015 17:05:34 -0000 Received: from p5dd3e43b.dip0.t-ipconnect.de (HELO ?192.168.178.100?) (gnikl@baltic.net@93.211.228.59) by with ESMTPA; 30 Jul 2015 17:05:34 -0000 Message-ID: <55BA594A.8030605@users.sourceforge.net> Date: Thu, 30 Jul 2015 19:05:14 +0200 From: Gunther Nikl User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.1.19) Gecko/20110420 NOT Firefox/3.5 SeaMonkey/2.0.14 MIME-Version: 1.0 To: vogt@linux.vnet.ibm.com CC: Jeff Law , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Honour DriverOnly for enum values in error messages. References: <20150727114555.GA7180@linux.vnet.ibm.com> In-Reply-To: <20150727114555.GA7180@linux.vnet.ibm.com> Dominik Vogt schrieb: > The attached patch fixes a glicht in the error message generated > for invalid values of enum options. IMHO, the patch is incomplete. > diff --git a/gcc/opts-common.c b/gcc/opts-common.c > index 8e51974..3bcbaf1 100644 > --- a/gcc/opts-common.c > +++ b/gcc/opts-common.c > @@ -1079,6 +1079,8 @@ read_cmdline_option (struct gcc_options *opts, > p = s; > for (i = 0; e->values[i].arg != NULL; i++) > { > + if (!enum_arg_ok_for_language (&e->values[i], lang_mask)) > + continue; > size_t arglen = strlen (e->values[i].arg); > memcpy (p, e->values[i].arg, arglen); > p[arglen] = ' '; The invalid values are skipped with that change, but there is still space allocated for them. I propose the following additional patch if only the space for valid values should be allocated: -- cut -- -- cut -- Regards, Gunther diff -up a/gcc/opts-common.c b/gcc/opts-common.c --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -1001,7 +1001,10 @@ read_cmdline_option (struct gcc_options len = 0; for (i = 0; e->values[i].arg != NULL; i++) - len += strlen (e->values[i].arg) + 1; + { + if (enum_arg_ok_for_language (&e->values[i], lang_mask)) + len += strlen (e->values[i].arg) + 1; + } s = XALLOCAVEC (char, len); p = s;