From patchwork Thu Jan 5 13:08:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 90015 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp8959001qgi; Thu, 5 Jan 2017 05:09:14 -0800 (PST) X-Received: by 10.84.234.23 with SMTP id m23mr125095898plk.89.1483621754442; Thu, 05 Jan 2017 05:09:14 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id r12si75819941pgn.241.2017.01.05.05.09.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jan 2017 05:09:14 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-445455-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-445455-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-445455-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=yaGqfOKMgbhDiilgP 6bbpk3U0QLuazOAzOwiDMi56n/JRpr04YbkUtma+/ExZgf48zBkpcqSuDXgCZuIm 5hGjGnuhjId5XAntqkVsHwo453fAmg6DRA6BUrO6U5X8edNHLBX9dRgdEAHG5PVW vNuTddhZH+sUni14asUwBB9liQ= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=ZeJFH+xD68TNzjzHRD0ZM7y Yzao=; b=d34roA9tb3izG8aMFoo5tLwDdFqNtFaHegj5tZRp8UYEoieD9DjaYCk C6e0sObdM0dcU7Nr7Z2eqllGKDf/zyaPrbHqnJzhOBq0yyNdJMfKBSQUFwmY1U6Z t48nrdV612vVZ68fGxLuwZAkjMKMkll5n5RrNKGeqypqzT+8eq44= Received: (qmail 78899 invoked by alias); 5 Jan 2017 13:08:54 -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 78882 invoked by uid 89); 5 Jan 2017 13:08:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=Wont, Won't X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Jan 2017 13:08:43 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CFCE8AAC4; Thu, 5 Jan 2017 13:08:40 +0000 (UTC) Subject: Re: [PATCH] Fix precompiled header for '-' being input file (PR, pch/78970) To: Jakub Jelinek References: <2577a04a-611e-ab46-b2c5-f39c71f02cca@suse.cz> <20170105091107.GW21933@tucnak> <20170105100947.GY21933@tucnak> Cc: GCC Patches From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: <3f5a5773-959f-1c7d-5263-10ab3d1d3467@suse.cz> Date: Thu, 5 Jan 2017 14:08:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20170105100947.GY21933@tucnak> X-IsSubscribed: yes On 01/05/2017 11:09 AM, Jakub Jelinek wrote: > On Thu, Jan 05, 2017 at 11:01:37AM +0100, Martin Liška wrote: >> >From 0e14f21128c7aa67ed0eaa10877323a0b2011b63 Mon Sep 17 00:00:00 2001 >> From: marxin >> Date: Wed, 4 Jan 2017 16:04:44 +0100 >> Subject: [PATCH] Error for '-' as filename of a precompiled header (PR >> pch/78970) >> >> gcc/ChangeLog: >> >> 2017-01-05 Martin Liska >> >> * gcc.c (lookup_compiler): Reject '-' filename for a precompiled >> header. >> --- >> gcc/gcc.c | 14 +++++++++++++- >> 1 file changed, 13 insertions(+), 1 deletion(-) >> >> diff --git a/gcc/gcc.c b/gcc/gcc.c >> index 8154953eb1d..ea4af119e73 100644 >> --- a/gcc/gcc.c >> +++ b/gcc/gcc.c >> @@ -8325,7 +8325,19 @@ lookup_compiler (const char *name, size_t length, const char *language) >> { >> for (cp = compilers + n_compilers - 1; cp >= compilers; cp--) >> if (cp->suffix[0] == '@' && !strcmp (cp->suffix + 1, language)) >> - return cp; >> + { >> + if (name != NULL && strcmp (name, "-") == 0 >> + && (strcmp (cp->suffix, "@c-header") == 0 >> + || strcmp (cp->suffix, "@c++-header") == 0)) >> + { >> + fatal_error (input_location, >> + "can't use '-' as input filename for a " >> + "precompiled header"); > > That would be can%'t Change to 'cannot', as Andreas suggested. > > Won't the compiler still ICE if you invoke cc1 or cc1plus rather than the driver? It ICEs, fixed in the patch that bootstraps and survives regression tests. Martin > > Jakub > >From c2d521336f6c2d8d0048352dde6e690de7dc1ddd Mon Sep 17 00:00:00 2001 From: marxin Date: Wed, 4 Jan 2017 16:04:44 +0100 Subject: [PATCH] Error for '-' as filename of a precompiled header (PR pch/78970) gcc/c-family/ChangeLog: 2017-01-05 Martin Liska * c-opts.c (c_common_post_options): Reject '-' filename for a precompiled header. gcc/ChangeLog: 2017-01-05 Martin Liska * gcc.c (lookup_compiler): Reject '-' filename for a precompiled header. --- gcc/c-family/c-opts.c | 7 ++++++- gcc/gcc.c | 14 +++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 14e038c02b3..49df9e19157 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -744,7 +744,12 @@ c_common_post_options (const char **pfilename) in_fnames[0] = ""; } else if (strcmp (in_fnames[0], "-") == 0) - in_fnames[0] = ""; + { + if (pch_file) + error ("cannot use '-' as input filename for a precompiled header"); + + in_fnames[0] = ""; + } if (out_fname == NULL || !strcmp (out_fname, "-")) out_fname = ""; diff --git a/gcc/gcc.c b/gcc/gcc.c index 8154953eb1d..f42c4ef372e 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -8325,7 +8325,19 @@ lookup_compiler (const char *name, size_t length, const char *language) { for (cp = compilers + n_compilers - 1; cp >= compilers; cp--) if (cp->suffix[0] == '@' && !strcmp (cp->suffix + 1, language)) - return cp; + { + if (name != NULL && strcmp (name, "-") == 0 + && (strcmp (cp->suffix, "@c-header") == 0 + || strcmp (cp->suffix, "@c++-header") == 0)) + { + fatal_error (input_location, + "cannot use '-' as input filename for a " + "precompiled header"); + return 0; + } + + return cp; + } error ("language %s not recognized", language); return 0; -- 2.11.0