From patchwork Sun Sep 26 13:25:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Mladjenovic X-Patchwork-Id: 45449 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8BAAE385800C for ; Sun, 26 Sep 2021 13:35:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BAAE385800C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1632663341; bh=6Nmi2E4PjczCl/Glf/6HjoSdaP1DHFYA9JRY5ovPnOg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=K0G9HWakb41uXaFTyR0D+Mpd9YwRjQDtzyBRz6RYBfq+6yJquJO35yH3AxB8beEgz s+DLssNJ8L/UpFs7FtGLI47w5fZp70w0oqlKTCgld0QVFLNXH0cu6xkz0V8Usqi9CB VbbLG9tGK+0G1i9UJZmu5JXaxM5BcQ20nN/gAV6A= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mailgw01.mediatek.com (mailgw01.mediatek.com [216.200.240.184]) by sourceware.org (Postfix) with ESMTPS id BF1AA3858C60; Sun, 26 Sep 2021 13:35:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BF1AA3858C60 X-UUID: 56fd8c14bc104271802a24b6f4721612-20210926 X-UUID: 56fd8c14bc104271802a24b6f4721612-20210926 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1951553952; Sun, 26 Sep 2021 06:35:05 -0700 Received: from MTKMBS62N1.mediatek.inc (172.29.193.41) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 26 Sep 2021 06:25:35 -0700 Received: from MTKMBS62N1.mediatek.inc ([fe80::697c:586d:7cff:34e7]) by MTKMBS62N1.mediatek.inc ([fe80::697c:586d:7cff:34e7%12]) with mapi id 15.00.1497.015; Sun, 26 Sep 2021 06:25:35 -0700 To: "gcc-patches@gcc.gnu.org" Subject: [RFC 5/7] Fix unhelpful messages for disabled options. Thread-Topic: [RFC 5/7] Fix unhelpful messages for disabled options. Thread-Index: AQHXstn9aU1cFnm7hU24KO2CeVyYTg== Date: Sun, 26 Sep 2021 13:25:35 +0000 Message-ID: <5f83621c703c41b79fbc26b4b41d28f3@MTKMBS62N1.mediatek.inc> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [172.29.193.239] MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Dragan Mladjenovic via Gcc-patches From: Dragan Mladjenovic Reply-To: Dragan Mladjenovic Cc: Jeff Law , Matthew Fortune , Jakub Jelinek , YunQiang Su , "Petar.Jovanovic@syrmia.com" , Faraz Shahbazker , Vince Del Vecchio Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Firstly, the option handling was building suggestions without checking if an option is disabled. This could have caused other unhelpful messages for other mistyped options. Secondly, the key issue here appears to be the lack of CL_JOINED flag for the false 'Condition' i.e. an option is disabled but other flags are zeroed out too. This caused find_opt() not to return the right index to an option e.g. for -mabi= we would expect OPT_mabi_ rather than OPT_SPECIAL_unknown, hence, the option did not appear to be correctly marked as disabled. The patch aims to retain the extra flag but to keep an option as disabled. I do not see any fallout with this, -m= are now rejected on the command line and not printed with --target-help. gcc/ChangeLog: * opt-suggestions.c (option_proposer::build_option_suggestions): Ignore disabled options. * opts.c (print_filtered_help): Likewise. * optc-gen.awk: Preserve flags in both cases. gcc/testsuite/ChangeLog: * gcc.target/nanomips/nanomips-err-mabi32.c: New test. --- gcc/opt-suggestions.c | 3 +++ gcc/optc-gen.awk | 5 +++-- gcc/opts.c | 4 ++++ .../gcc.target/nanomips/nanomips-err-mabi32.c (new) | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-) 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/nanomips/nanomips-err-mabi32.c diff --git a/gcc/opt-suggestions.c b/gcc/opt-suggestions.c index 5c36fc8cc8c..03bccd5379f 100644 --- a/gcc/opt-suggestions.c +++ b/gcc/opt-suggestions.c @@ -108,6 +108,9 @@ option_proposer::build_option_suggestions (const char *prefix) switch (i) { default: + /* We don't want to suggest disabled options. */ + if (option->cl_disabled) + continue; if (option->var_type == CLVC_ENUM) { const struct cl_enum *e = &cl_enums[option->var_enum]; diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk index 77e598efd60..eb725fdb8ce 100644 --- a/gcc/optc-gen.awk +++ b/gcc/optc-gen.awk @@ -412,10 +412,11 @@ for (i = 0; i < n_opts; i++) { " %s,\n" \ " 0, %s,\n" \ "#else\n" \ - " 0,\n" \ + " %s,\n" \ " 1 /* Disabled. */, %s,\n" \ "#endif\n", - condition, cl_flags, cl_bit_fields, cl_zero_bit_fields) + condition, cl_flags, cl_bit_fields, + cl_flags, cl_zero_bit_fields) else printf(" %s,\n" \ " 0, %s,\n", diff --git a/gcc/opts.c b/gcc/opts.c index 1d2d22d7a3f..d85fc2adf8a 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1435,6 +1435,10 @@ print_filtered_help (unsigned int include_flags, continue; } + /* Skip disabled options. */ + if (option->cl_disabled) + continue; + /* Skip unwanted switches. */ if ((option->flags & exclude_flags) != 0) continue; diff --git a/gcc/testsuite/gcc.target/nanomips/nanomips-err-mabi32.c b/gcc/testsuite/gcc.target/nanomips/nanomips-err-mabi32.c new file mode 100644 index 00000000000..1bf233a36e3 --- /dev/null +++ b/gcc/testsuite/gcc.target/nanomips/nanomips-err-mabi32.c @@ -0,0 +1,4 @@ +/* Verify that we get an error for unsupported -mabi=32 option. */ +/* { dg-additional-options "-mabi=32" } */ +/* { dg-error "not supported by this configuration" "" { target *-*-* } 0 } */ +void foo (void) {}