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.133.124]) by sourceware.org (Postfix) with ESMTPS id 523F03858428 for ; Thu, 1 Dec 2022 16:50:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 523F03858428 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669913456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zlkzWRZO2JkO762935fWqgFSeJ1CCbzh4rlQ48jAba4=; b=BZI8UN5npjZEk6CfBUQO1pE/pXCTTas9PWOS/aqroB2GQe0/Mrca9afQv3yX1AJnKkOjIK hRVghkQkrOPkjdoXOx7cBh/k/YouiOMqZg8ugJCayyn7PdhaB3ZJ57xyalA7KTbBPXkli6 jpdD0BpGKAsm2K9COfJQf69T3eO+pC8= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-172-1_TgnHxDOL2tw9aMCun39Q-1; Thu, 01 Dec 2022 11:50:56 -0500 X-MC-Unique: 1_TgnHxDOL2tw9aMCun39Q-1 Received: by mail-qv1-f69.google.com with SMTP id 71-20020a0c804d000000b004b2fb260447so6007595qva.10 for ; Thu, 01 Dec 2022 08:50:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zlkzWRZO2JkO762935fWqgFSeJ1CCbzh4rlQ48jAba4=; b=5FJVnzbBczle/35cJ5PRTDR9FGNnjLKhBo615zEHKyxVvWJenZi815iWixOdFJw5Z0 mh83+PpXiJt1F58sO4JQWvFElz1Wu3SQywk8SeO49MwfX7oHadAIk6DL6kTn3IHSnrsq kMttfObylRVwQdLEZAbdxRrc1lHPC/CkyhiCK6kevZuBkejiyYzoTAiIIqtnd2OpsjKV dLvTd5RDwPen/Fe272lCoTgZ5qKXbqkmu+EUZlUQqVVmnWaJDnO6T2g6SqpjTRRtY20l 57pKBbQcB2rUu2B8szeg5CvSTY8O8fT9ciCphCA8/aNMTyC8GTSliSf5iLD+Vv49G4sG e3bA== X-Gm-Message-State: ANoB5pk65oKi3myWUEj6VFhlRzehnv5rAKLnyLMld1p1k991PvBDcbpN 4CGMmdPz420Y9lFuglUNSXwqyqZ5YYOI/oLX6UvghWnFBUW5Qf1ViK93oLbxqVcbKPjc9S0hEQt VJBVNRKM3VqTNqqJ0XAi1HmZ/wx6kbwMpDmHor/uPR//r8bFfdBcYT+FK5K8Lg08KbA== X-Received: by 2002:a05:620a:1905:b0:6fa:6636:a7b0 with SMTP id bj5-20020a05620a190500b006fa6636a7b0mr42632524qkb.55.1669913455348; Thu, 01 Dec 2022 08:50:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf4105UcmsKdKr6JxYytYKCtok4UZI7/C25Xq8K9Ewc0IsIK3ll6cWo3JK+LAtk/XFJLTINpIA== X-Received: by 2002:a05:620a:1905:b0:6fa:6636:a7b0 with SMTP id bj5-20020a05620a190500b006fa6636a7b0mr42632489qkb.55.1669913454871; Thu, 01 Dec 2022 08:50:54 -0800 (PST) Received: from jason.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id i6-20020a05620a404600b006fc9fe67e34sm3277049qko.81.2022.12.01.08.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 08:50:54 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org Cc: oliva@adacore.com Subject: [PATCH RFA] driver: fix validate_switches logic Date: Thu, 1 Dec 2022 11:50:51 -0500 Message-Id: <20221201165051.51853-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested x86_64-pc-linux-gnu, OK for trunk? -- 8< -- Under the old logic for validate_switches, once suffix or starred got set, they stayed set for all later switches found in the spec. So for e.g. %{g*:%{%:debug-level-gt(0): Once we see g*, starred is set. Then we see %:, and it sees that as a zero-length switch, which because starred is still set, matches any and all command-line options. So targets that use such a spec accept all options in the driver, while ones that don't reject some, such as the recent -nostdlib++. This patch fixes the inconsistency, so all targets would complain about -nostdlib++, and then sets SKIPOPT for it so they don't. gcc/ChangeLog: * gcc.cc (validate_switches): Reset suffix/starred on loop. gcc/cp/ChangeLog: * g++spec.cc (lang_specific_driver): Set SKIPOPT for nostdlib++. --- gcc/cp/g++spec.cc | 4 +++- gcc/gcc.cc | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gcc/cp/g++spec.cc b/gcc/cp/g++spec.cc index e599ac906f6..3d3b042dd56 100644 --- a/gcc/cp/g++spec.cc +++ b/gcc/cp/g++spec.cc @@ -167,8 +167,10 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, need_experimental = true; break; - case OPT_nostdlib: case OPT_nostdlib__: + args[i] |= SKIPOPT; + /* FALLTHRU */ + case OPT_nostdlib: case OPT_nodefaultlibs: library = -1; break; diff --git a/gcc/gcc.cc b/gcc/gcc.cc index ca1c9e27a94..2278e2b6bb1 100644 --- a/gcc/gcc.cc +++ b/gcc/gcc.cc @@ -9299,12 +9299,15 @@ validate_switches (const char *start, bool user_spec, bool braced) const char *atom; size_t len; int i; - bool suffix = false; - bool starred = false; + bool suffix; + bool starred; #define SKIP_WHITE() do { while (*p == ' ' || *p == '\t') p++; } while (0) next_member: + suffix = false; + starred = false; + SKIP_WHITE (); if (*p == '!') base-commit: 4304e09a1617bcf1c87f5bc96017ae5017379d75 -- 2.31.1