From patchwork Fri Aug 25 14:30:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 805914 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-460942-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="GMYQRHDQ"; dkim-atps=neutral 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 3xf3WJ1X9pz9sNv for ; Sat, 26 Aug 2017 00:31:24 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; q=dns; s=default; b=b+cDwdZd9Ud39ON0 lGVBNdYh3Umv8AUELfXUP7dX6g1vEvcCSqez29IXtgbWGQC7tKqGxckM/R16t3FC oQd95Sw8gSFN5gzt6nmF1fNm3gRRXjcF/ZwZ5oyPdc0YGswh9glbDBagGHn/A/Fp g5KBLPMWoyizsgbFk+/PtGroR9k= 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:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=default; bh=LbQSBk2FgsVpLlBXCVhv7O cX7cc=; b=GMYQRHDQDlUs3y2ZzZQjteyRdXcRVaeMUyfGzNSl3QNB6f+TMsDm0N NiqPKuICi+ZManFFRzXRxervPNpX4Y5PpcatR1Vd8yYldpIpUeu4CVkuXNSa3xSw nMXzbFqdggIXEnEv81C7hwlstZt0aLwzsx6IFEIGKTxsArSrdyhnQ= Received: (qmail 82662 invoked by alias); 25 Aug 2017 14:30:24 -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 70092 invoked by uid 89); 25 Aug 2017 14:30:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=remembered 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 ESMTP; Fri, 25 Aug 2017 14:30:12 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 48997806A2; Fri, 25 Aug 2017 14:30:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 48997806A2 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=aoliva@redhat.com Received: from freie.home (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C02166E514; Fri, 25 Aug 2017 14:30:10 +0000 (UTC) Received: from livre (livre.home [172.31.160.2]) by freie.home (8.15.2/8.15.2) with ESMTP id v7PEU497016630; Fri, 25 Aug 2017 11:30:04 -0300 From: Alexandre Oliva To: Richard Biener Cc: GCC Patches Subject: Re: Statement Frontier Notes, Location Views, and Inlined Entry Point Markers References: Date: Fri, 25 Aug 2017 11:30:04 -0300 In-Reply-To: (Richard Biener's message of "Wed, 23 Aug 2017 13:01:38 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 On Aug 23, 2017, Richard Biener wrote: > On Wed, Aug 23, 2017 at 12:29 AM, Alexandre Oliva wrote: >> All debug options that support negation seem to have adopted this idiom; >> without it, the negated options end up misparsed as -g with an argument, >> and then set_debug_level complains that "no-..." is not a number. >> >> The logic of matching the longest option name prefix doesn't seem to >> work very well when options have a prefix that is also a valid option >> with a Joined(OrMissing) argument. > Ah, like we don't have -no-g but only -g0. I guess that there's -fno- > is somewhere hardcoded and -g isn't handled that way. Would need > to amend the options machinery somehow (new flag, Negatable?). This patch that adds -g to the set of negatable prefixes along with -f, -m and -W. Besides the mapping from -gno- to negated -g in option_map and adding g to the [fmW] matches for negatable options, I had to introduce gno- as an remapping prefix, for the option searching machinery to backtrack to and recognize as a remapping prefix, instead of backtracking to -g and stopping at it as if no-* was its Joined argument. Adding such remapping prefixes to preempt further backtracking can be accomplished by introducing the prefix as an Undocumented option with a Joined argument and without Driver, Target, Common, or any language-specific option. Whenever we match such a fake options prefix, we abandon further backtracking (it matches, after all), but find_opt returns the same code it would if it hadn't found any match, so that we resort to option mapping. I've arranged for such remapping prefixes to not be considered when looking for and suggesting a correct spelling for misspelled options. While testing that, I found a few -W-started options that were not marked as RejectNegative but should (-Wno-a, is not something we'd like to suggest ;-) I've also marked as such -g-started options that it makes no sense to negate, and removed the explicit -gno- ones, allowing their opposites to be negated. Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok to install? for gcc/ChangeLog * common.opt (Wa, Wl, Wp, g, gz=): Add RejectNegative. (gno-column-info): Remove. (gcolumn-info): Drop RejectNegative. (gno-): New prefix. (gno-record-gcc-switches): Remove. (grecord-gcc-switches): Drop RejectNegative. (gno-split-dwarf): Remove. (gsplit-dwarf): Drop RejectNegative. (gno-strict-dwarf): Remove. (gstrict-dwarf): Drop RejectNegative. * config/darwin.opt (gfull, gused): Add RejectNegative. * dwarf2out.c (gen_producer_string): Drop gno-record-gcc-switches handler. * optc-gen.awk: Add g to prefixes with negative forms. * opts-common.c (remapping_prefix_p): New. (find_opt): Check it. (generate_canonical_option): Test g prefix. (option_map): Add -gno- mapping. (add_misspelling_candidates): Check remapping_prefix_p. for gcc/ada/ChangeLog * gcc-interface/lang.opt (gant, gnatO, gnat): Add RejectNegative. for gcc/c-family/ChangeLog * c.opt (gen-decls): Add RejectNegative. --- gcc/ada/gcc-interface/lang.opt | 6 +++--- gcc/c-family/c.opt | 2 +- gcc/common.opt | 38 +++++++++++++------------------------- gcc/config/darwin.opt | 4 ++-- gcc/dwarf2out.c | 1 - gcc/optc-gen.awk | 4 ++-- gcc/opts-common.c | 27 ++++++++++++++++++++++++++- 7 files changed, 47 insertions(+), 35 deletions(-) diff --git a/gcc/ada/gcc-interface/lang.opt b/gcc/ada/gcc-interface/lang.opt index 241eafc..17c6dc8 100644 --- a/gcc/ada/gcc-interface/lang.opt +++ b/gcc/ada/gcc-interface/lang.opt @@ -81,15 +81,15 @@ Ada AdaWhy AdaSCIL Make \"char\" signed by default. gant -Ada AdaWhy AdaSCIL Driver Joined Undocumented +Ada AdaWhy AdaSCIL Driver Joined Undocumented RejectNegative Catch typos. gnatO -Ada AdaWhy AdaSCIL Driver Separate +Ada AdaWhy AdaSCIL Driver Separate RejectNegative Set name of output ALI file (internal switch). gnat -Ada AdaWhy AdaSCIL Driver Joined +Ada AdaWhy AdaSCIL Driver Joined RejectNegative -gnat Specify options to GNAT. fbuiltin-printf diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index e0ad3ab..55d9405 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -1802,7 +1802,7 @@ ObjC ObjC++ Var(flag_zero_link) Generate lazy class lookup (via objc_getClass()) for use in Zero-Link mode. gen-decls -ObjC ObjC++ Driver Var(flag_gen_declaration) +ObjC ObjC++ Driver Var(flag_gen_declaration) RejectNegative Dump declarations to a .decl file. femit-struct-debug-baseonly diff --git a/gcc/common.opt b/gcc/common.opt index 1cb1c83..d18559a 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -532,13 +532,13 @@ Common RejectNegative Warning Alias(Wextra) This switch is deprecated; use -Wextra instead. Wa, -Driver JoinedOrMissing +Driver JoinedOrMissing RejectNegative Wl, -Driver JoinedOrMissing +Driver JoinedOrMissing RejectNegative Wp, -Driver JoinedOrMissing +Driver JoinedOrMissing RejectNegative Waggregate-return Common Var(warn_aggregate_return) Warning @@ -2819,19 +2819,15 @@ Common Report Var(flag_zero_initialized_in_bss) Init(1) Put zero initialized data in the bss section. g -Common Driver JoinedOrMissing +Common Driver RejectNegative JoinedOrMissing Generate debug information in default format. gcoff Common Driver JoinedOrMissing Negative(gdwarf) Generate debug information in COFF format. -gno-column-info -Common Driver RejectNegative Var(debug_column_info,0) Init(0) -Don't record DW_AT_decl_column and DW_AT_call_column in DWARF. - gcolumn-info -Common Driver RejectNegative Var(debug_column_info,1) +Common Driver Var(debug_column_info,1) Init(0) Record DW_AT_decl_column and DW_AT_call_column in DWARF. gdwarf @@ -2846,6 +2842,10 @@ ggdb Common Driver JoinedOrMissing Generate debug information in default extended format. +gno- +RejectNegative Joined Undocumented +; Catch the gno- prefix, so it doesn't backtrack to g. + gno-pubnames Common Driver Negative(gpubnames) Var(debug_generate_pub_sections, 0) Init(-1) Don't generate DWARF pubnames and pubtypes sections. @@ -2858,20 +2858,12 @@ ggnu-pubnames Common Driver Negative(gno-pubnames) Var(debug_generate_pub_sections, 2) Generate DWARF pubnames and pubtypes sections with GNU extensions. -gno-record-gcc-switches -Common Driver RejectNegative Var(dwarf_record_gcc_switches,0) Init(1) -Don't record gcc command line switches in DWARF DW_AT_producer. - grecord-gcc-switches -Common Driver RejectNegative Var(dwarf_record_gcc_switches,1) +Common Driver Var(dwarf_record_gcc_switches) Init(1) Record gcc command line switches in DWARF DW_AT_producer. -gno-split-dwarf -Common Driver RejectNegative Var(dwarf_split_debug_info,0) Init(0) -Don't generate debug information in separate .dwo files. - gsplit-dwarf -Common Driver RejectNegative Var(dwarf_split_debug_info,1) +Common Driver Var(dwarf_split_debug_info) Init(0) Generate debug information in separate .dwo files. gstabs @@ -2882,12 +2874,8 @@ gstabs+ Common Driver JoinedOrMissing Negative(gvms) Generate debug information in extended STABS format. -gno-strict-dwarf -Common Driver RejectNegative Var(dwarf_strict,0) Init(0) -Emit DWARF additions beyond selected version. - gstrict-dwarf -Common Driver Report RejectNegative Var(dwarf_strict,1) +Common Driver Report Var(dwarf_strict) Init(0) Don't emit DWARF additions beyond selected version. gtoggle @@ -2925,7 +2913,7 @@ Common Driver Generate compressed debug sections. gz= -Common Driver Joined Enum(compressed_debug_sections) +Common Driver RejectNegative Joined Enum(compressed_debug_sections) -gz= Generate compressed debug sections in format . h diff --git a/gcc/config/darwin.opt b/gcc/config/darwin.opt index 135a9c0..48710142 100644 --- a/gcc/config/darwin.opt +++ b/gcc/config/darwin.opt @@ -92,10 +92,10 @@ fterminated-vtables Driver RejectNegative gfull -Driver +Driver RejectNegative gused -Driver +Driver RejectNegative headerpad_max_install_names Driver diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 917ab9f..82f2a50 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -23370,7 +23370,6 @@ gen_producer_string (void) case OPT_SPECIAL_program_name: case OPT_SPECIAL_input_file: case OPT_grecord_gcc_switches: - case OPT_gno_record_gcc_switches: case OPT__output_pch_: case OPT_fdiagnostics_show_location_: case OPT_fdiagnostics_show_option: diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk index 3cb0005..295bae1 100644 --- a/gcc/optc-gen.awk +++ b/gcc/optc-gen.awk @@ -328,7 +328,7 @@ for (i = 0; i < n_opts; i++) { alias_data = "NULL, NULL, N_OPTS" if (flag_set_p("Enum.*", flags[i])) { if (!flag_set_p("RejectNegative", flags[i]) \ - && opts[i] ~ "^[Wfm]") + && opts[i] ~ "^[Wfgm]") print "#error Enum allowing negative form" } } else { @@ -370,7 +370,7 @@ for (i = 0; i < n_opts; i++) { if (flag_set_p("RejectNegative", flags[i])) idx = -1; else { - if (opts[i] ~ "^[Wfm]") + if (opts[i] ~ "^[Wfgm]") idx = indices[opts[i]]; else idx = -1; diff --git a/gcc/opts-common.c b/gcc/opts-common.c index 0cab42a0..dede33c 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -28,6 +28,24 @@ along with GCC; see the file COPYING3. If not see static void prune_options (struct cl_decoded_option **, unsigned int *); +/* An option that is undocumented, that takes a joined argument, and + that doesn't fit any of the classes of uses (language/common, + driver, target) is assumed to be a prefix used to catch + e.g. negated options, and stop them from being further shortened to + a prefix that could use the negated option as an argument. For + example, we want -gno-statement-frontiers to be taken as a negation + of -gstatement-frontiers, but without catching the gno- prefix and + signaling it's to be used for option remapping, it would end up + backtracked to g with no-statemnet-frontiers as the debug level. */ + +static bool +remapping_prefix_p (const struct cl_option *opt) +{ + return opt->flags & CL_UNDOCUMENTED + && opt->flags & CL_JOINED + && !(opt->flags & (CL_DRIVER | CL_TARGET | CL_COMMON | CL_LANG_ALL)); +} + /* Perform a binary search to find which option the command-line INPUT matches. Returns its index in the option array, and OPT_SPECIAL_unknown on failure. @@ -98,6 +116,9 @@ find_opt (const char *input, unsigned int lang_mask) if (opt->flags & lang_mask) return mn; + if (remapping_prefix_p (opt)) + return OPT_SPECIAL_unknown; + /* If we haven't remembered a prior match, remember this one. Any prior match is necessarily better. */ if (match_wrong_lang == OPT_SPECIAL_unknown) @@ -286,7 +307,8 @@ generate_canonical_option (size_t opt_index, const char *arg, int value, if (value == 0 && !option->cl_reject_negative - && (opt_text[1] == 'W' || opt_text[1] == 'f' || opt_text[1] == 'm')) + && (opt_text[1] == 'W' || opt_text[1] == 'f' + || opt_text[1] == 'g' || opt_text[1] == 'm')) { char *t = XOBNEWVEC (&opts_obstack, char, option->opt_len + 5); t[0] = '-'; @@ -349,6 +371,7 @@ static const struct option_map option_map[] = { { "-Wno-", NULL, "-W", false, true }, { "-fno-", NULL, "-f", false, true }, + { "-gno-", NULL, "-g", false, true }, { "-mno-", NULL, "-m", false, true }, { "--debug=", NULL, "-g", false, false }, { "--machine-", NULL, "-m", true, false }, @@ -394,6 +417,8 @@ add_misspelling_candidates (auto_vec *candidates, gcc_assert (candidates); gcc_assert (option); gcc_assert (opt_text); + if (remapping_prefix_p (option)) + return; candidates->safe_push (xstrdup (opt_text + 1)); for (unsigned i = 0; i < ARRAY_SIZE (option_map); i++) {