From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20604 invoked by alias); 22 Jul 2019 09:36:10 -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 20596 invoked by uid 89); 22 Jul 2019 09:36:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 22 Jul 2019 09:36:08 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B3892AD08 for ; Mon, 22 Jul 2019 09:36:06 +0000 (UTC) Subject: Re: GCC 8 backports From: =?UTF-8?Q?Martin_Li=c5=a1ka?= To: GCC Patches References: <2a0635b9-7901-52e3-891e-509182556d71@suse.cz> Message-ID: <4c9ae038-b586-eece-eb98-c14fecfc3943@suse.cz> Date: Mon, 22 Jul 2019 09:36:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------348D3786604E0EDDBCBF00BA" X-IsSubscribed: yes X-SW-Source: 2019-07/txt/msg01382.txt.bz2 This is a multi-part message in MIME format. --------------348D3786604E0EDDBCBF00BA Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 46 Hi. One more patch I've just tested. Martin --------------348D3786604E0EDDBCBF00BA Content-Type: text/x-patch; name="0001-Backport-r273660.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Backport-r273660.patch" Content-length: 2756 >From eb62ef9ec1edc109aa69137ed077620cafad5253 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 22 Jul 2019 10:00:07 +0200 Subject: [PATCH] Backport r273660 gcc/ChangeLog: 2019-07-22 Martin Liska PR driver/91172 * opts-common.c (decode_cmdline_option): Decode argument of -Werror and check it for a wrong language. * opts-global.c (complain_wrong_lang): Remove such case. gcc/testsuite/ChangeLog: 2019-07-22 Martin Liska PR driver/91172 * gcc.dg/pr91172.c: New test. --- gcc/opts-common.c | 20 +++++++++++++++++++- gcc/opts-global.c | 6 +++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/gcc/opts-common.c b/gcc/opts-common.c index 3c2553368ac..9b0d76d1148 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -438,7 +438,8 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, extra_args = 0; - opt_index = find_opt (argv[0] + 1, lang_mask); + const char *opt_value = argv[0] + 1; + opt_index = find_opt (opt_value, lang_mask); i = 0; while (opt_index == OPT_SPECIAL_unknown && i < ARRAY_SIZE (option_map)) @@ -641,6 +642,23 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, /* Check if this is a switch for a different front end. */ if (!option_ok_for_language (option, lang_mask)) errors |= CL_ERR_WRONG_LANG; + else if (strcmp (option->opt_text, "-Werror=") == 0 + && strchr (opt_value, ',') == NULL) + { + /* Verify that -Werror argument is a valid warning + for a language. */ + char *werror_arg = xstrdup (opt_value + 6); + werror_arg[0] = 'W'; + + size_t warning_index = find_opt (werror_arg, lang_mask); + if (warning_index != OPT_SPECIAL_unknown) + { + const struct cl_option *warning_option + = &cl_options[warning_index]; + if (!option_ok_for_language (warning_option, lang_mask)) + errors |= CL_ERR_WRONG_LANG; + } + } /* Convert the argument to lowercase if appropriate. */ if (arg && option->cl_tolower) diff --git a/gcc/opts-global.c b/gcc/opts-global.c index bfa2afb1987..b45d18996a3 100644 --- a/gcc/opts-global.c +++ b/gcc/opts-global.c @@ -100,10 +100,14 @@ complain_wrong_lang (const struct cl_decoded_option *decoded, text, bad_lang); else if (lang_mask == CL_DRIVER) gcc_unreachable (); - else + else if (ok_langs[0] != '\0') /* Eventually this should become a hard error IMO. */ warning (0, "command line option %qs is valid for %s but not for %s", text, ok_langs, bad_lang); + else + /* Happens for -Werror=warning_name. */ + warning (0, "%<-Werror=%> argument %qs is not valid for %s", + text, bad_lang); free (ok_langs); free (bad_lang); -- 2.22.0 --------------348D3786604E0EDDBCBF00BA--