From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 0E33F38708A4 for ; Mon, 17 Jun 2024 16:35:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E33F38708A4 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0E33F38708A4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718642103; cv=none; b=myJM0HpnWku3C1oogzHRuyMfMRvPv4eSzfKP2gslgJj4uprZb1C5tGXVj+U0F/vD16XGMlJmmW3h9qA6E5ixe/vpEwxX5nJAf7pZdggEEpgSF4KvfZOxA2DTWngUYthiSV20gEUwh/VnTwCNlWSnBY3fByNXodGBf8AUngvE62g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718642103; c=relaxed/simple; bh=B04yPKh1p4w4/zJ9bvZ48V2pKx198H51e5jRqpjXQco=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=ZHD9UrXhkND7v2UbIfwXnrmxYmaFUsWb6iwO6ABsCBUE3JTNWxuRRnVAg5E7G125pRaDw8MIYH+5J3TdP+58btY5Vys58dCCQSWyB/O90x8ByeoxZlhXFvRq6sEKIFSINUjDKOEVuBC1fakdJxr2Fyu0fh8ysAg3/d41vpgnMGo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718642101; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=PozQyeWfZQKgyj/broGEbRCEwS+ORVO5QJdJOQvS67c=; b=htiq6HahvprW9hws3qNC1X771tp0KPvJN4LJCLv5+DEqYLngtKcFY8lC8vRephTSVsQRcn l53Lpg+Awhf5C8XDWNH5QznFf/w1s8S1zhCTE0ay6sxF+JZk88ZNOTJFBMyRZjyxGeCIxv e4BuZ4eXBEPl1xwufBY5MbmERCVmJKg= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-335-4qm2FmAyMlaqypR391s06w-1; Mon, 17 Jun 2024 12:34:59 -0400 X-MC-Unique: 4qm2FmAyMlaqypR391s06w-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 70BB619560AF for ; Mon, 17 Jun 2024 16:34:57 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.7]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DF9E9300022B; Mon, 17 Jun 2024 16:34:55 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 45HGYqsN1606773 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 17 Jun 2024 18:34:53 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 45HGYpd21606772; Mon, 17 Jun 2024 18:34:51 +0200 Date: Mon, 17 Jun 2024 18:34:51 +0200 From: Jakub Jelinek To: David Malcolm Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] diagnostics: Fix add_misspelling_candidates [PR115440] Message-ID: Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi! The option_map array for most entries contains just non-NULL opt0 { "-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 }, { "--machine-no-", NULL, "-m", false, true }, { "--machine=", NULL, "-m", false, false }, { "--machine=no-", NULL, "-m", false, true }, { "--machine", "", "-m", false, false }, { "--machine", "no-", "-m", false, true }, { "--optimize=", NULL, "-O", false, false }, { "--std=", NULL, "-std=", false, false }, { "--std", "", "-std=", false, false }, { "--warn-", NULL, "-W", true, false }, { "--warn-no-", NULL, "-W", false, true }, { "--", NULL, "-f", true, false }, { "--no-", NULL, "-f", false, true } and so add_misspelling_candidates works correctly for it, but 3 out of these, { "--machine", "", "-m", false, false }, { "--machine", "no-", "-m", false, true }, and { "--std", "", "-std=", false, false }, use non-NULL opt1. That says that --machine foo should map to -mfoo and --machine no-foo should map to -mno-foo and --std c++17 should map to -std=c++17 add_misspelling_canidates was not handling this, so it hapilly registered say --stdc++17 or --machineavx512 (twice) as spelling alternatives, when those options aren't recognized. Instead we support --std c++17 or --machine avx512 --machine no-avx512 The following patch fixes that. On this particular testcase, we no longer suggest anything, even when among the suggestion is say that --std c++17 or -std=c++17 etc. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-06-17 Jakub Jelinek PR driver/115440 * opts-common.cc (add_misspelling_candidates): If opt1 is non-NULL, add a space and opt1 to the alternative suggestion text. * g++.dg/cpp1z/pr115440.C: New test. --- gcc/opts-common.cc.jj 2024-06-14 19:44:34.434236887 +0200 +++ gcc/opts-common.cc 2024-06-17 10:58:14.351178400 +0200 @@ -524,6 +524,7 @@ add_misspelling_candidates (auto_vecsafe_push (alternative); } } --- gcc/testsuite/g++.dg/cpp1z/pr115440.C.jj 2024-06-17 10:55:28.607380969 +0200 +++ gcc/testsuite/g++.dg/cpp1z/pr115440.C 2024-06-17 11:04:38.334075632 +0200 @@ -0,0 +1,8 @@ +// PR driver/115440 +// { dg-do compile { target c++17_only } } +// { dg-options "--c++17" } + +int i; + +// { dg-bogus "unrecognized command-line option '--c\\\+\\\+17'; did you mean '--stdc\\\+\\\+17'" "" { target *-*-* } 0 } +// { dg-error "unrecognized command-line option '--c\\\+\\\+17'" "" { target *-*-* } 0 } Jakub