From patchwork Thu Mar 16 22:09:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 70983 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp21428wrt; Thu, 16 Mar 2023 15:11:19 -0700 (PDT) X-Google-Smtp-Source: AK7set+hy0HLT1ZLbbvcQthu9mTaUM5OFh1jkZ1neBvhUsLxP8oKrToKe2voWbPNaRPuBGJ2R4O+ X-Received: by 2002:aa7:cb85:0:b0:4fc:65c7:a985 with SMTP id r5-20020aa7cb85000000b004fc65c7a985mr1045431edt.1.1679004679669; Thu, 16 Mar 2023 15:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679004679; cv=none; d=google.com; s=arc-20160816; b=RMBrAnedjY347Pz6fxTgSusatOv6SFzeP3EzDQ5GLjYATz082amWrbTxuPjqWss7n/ GC4LaxbkDYRPAbAnyk1BaFSxs/3mqp4eSEWcJQXcCuTTt9Jp7zGmJsRVqUJpEA6bFyIW JfZEcsv9v9wE3eH9oj19WqOLBMGPh71R/K95giuqWcEGjxUsZ4qPyr2kqD6px/XSZcYl cWmND+eEXWsjvkHX7SoC/74OKmmVBlh9t33zdk1SiNWPtFsawNRqB272d6q5hVDwhGm4 OVHYy1vg7OvbeKPv4SqMfdZmeyQ3wn8xKxIEoTdzJRl0UamsW3BWlHo8i4PFG0WltSOO B8Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=t2V3QrugGjMcPLUbdeCX4wz5onJBOG8osVY48jtWnQM=; b=Ke0gyiMySEf+vUC38347yGCvpEmRO5gs067nBpgrBWe54+CygFZGtToldzTcqFCa+6 PNUFtynVR0lRd6e5Gou5OPjHlUQovDvKDlPykcEXIzrnLTRu0Vh6yIFlGCHpC+cDLum2 9Ogovb+Bqev+nnb1kC9kHEa6vJ5+3Qc1N/7EKjR5YSxZPGpa6KGvZprHE1Y1dVrb27gw wAlEmVORXHV+ouaLZmfbrBfb/4T4OKzUfCgCzjUXvX2DCsSMMdqINqGJjeZm+iFgaUif RX8rr10i5M5savwMIfRl4hmFpbS3eVEXfI+mbBZQMBtDs4Z+B7jOQCXF6MWX5TExgk9E AZCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=pbAEZWNg; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id q23-20020a056402033700b004c10381668csi200018edw.286.2023.03.16.15.11.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 15:11:19 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=pbAEZWNg; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 574E738555B6 for ; Thu, 16 Mar 2023 22:11:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 574E738555B6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679004678; bh=t2V3QrugGjMcPLUbdeCX4wz5onJBOG8osVY48jtWnQM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=pbAEZWNgP15KxjbNxpeP/H2hvrpASmyc8ofriIQLuZdSn+3F8aCVCuJSPI9Qzz1LS t9nCAfjQ08qblb0LgPzLNFWCHtJBStN6STTzZOQ9LKzCD0GadcRjR1t+gy024XNXaI z8t1SuOY4ky9pU0+VOF1KLvLbJ/cvoVzngrNgrdI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 A73BA3858D35 for ; Thu, 16 Mar 2023 22:10:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A73BA3858D35 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-120-qdxd0W-CM1WH1yWy75UOJA-1; Thu, 16 Mar 2023 18:10:10 -0400 X-MC-Unique: qdxd0W-CM1WH1yWy75UOJA-1 Received: by mail-qt1-f200.google.com with SMTP id i24-20020ac84f58000000b003bfe3358691so1595998qtw.21 for ; Thu, 16 Mar 2023 15:10:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679004609; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=t2V3QrugGjMcPLUbdeCX4wz5onJBOG8osVY48jtWnQM=; b=3xiodz/V4ZL0HvH9l+ONk89n0uTO5SZZwCN2MGBeQ1pHWtBEZvHkwEWiUSvqFHMZSi s4r4N0du6BVDX9ChjPZimOtzrpCD3cJmmpIZLn0sPIN3UkQ5rNPVFNwVp09nRUnPBtsc tz6X0mQ/3KnRzH+HbVdPNtAtxA3y8Tc380h1HrIBY5MNyH6aNFVU7hObF1r+Qxi4AEAQ Gr378AWfSCe1ItLCZmRBMz2GE0MTcRkbMGI9mkYWy6s5A/SSefmBuZ3ZjqXOg7fj11T6 bUsJqwGibEI6Kh/zK3H+I+6QPSLiVF1x6JVFApyt1RknS4rLc447jZual60ebazYPEhU tBAg== X-Gm-Message-State: AO0yUKUg4G4RH4TwMzvKkPc7wPM6MIi8XeuvASmfkp7G8z+wG7yCsF8p jozEq0Q6CbJGB++NIroAlUhd5dMdgvpQG2cRZJsDYokGuOAU6osHrXN2O3hxb0cfMW5H9fSr5E4 Wv3SbVpow6uu1C//3QxWotnQzUvACXz6GgBMhuXQBgNM+4/I5mJjCfiiYRyuy/V6/onxyAEoCIg == X-Received: by 2002:ad4:5bc7:0:b0:56e:bb43:a087 with SMTP id t7-20020ad45bc7000000b0056ebb43a087mr33659098qvt.16.1679004609406; Thu, 16 Mar 2023 15:10:09 -0700 (PDT) X-Received: by 2002:ad4:5bc7:0:b0:56e:bb43:a087 with SMTP id t7-20020ad45bc7000000b0056ebb43a087mr33659061qvt.16.1679004608981; Thu, 16 Mar 2023 15:10:08 -0700 (PDT) Received: from jason.cygnus.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 p138-20020a374290000000b007426b917031sm352685qka.121.2023.03.16.15.10.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 15:10:08 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: &enum::enumerator [PR101869] Date: Thu, 16 Mar 2023 18:09:48 -0400 Message-Id: <20230316220948.1138021-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 X-Spam-Status: No, score=-12.6 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 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: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760564010815552217?= X-GMAIL-MSGID: =?utf-8?q?1760564010815552217?= Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- We don't want to call build_offset_ref with an enum. PR c++/101869 gcc/cp/ChangeLog: * semantics.cc (finish_qualified_id_expr): Don't try to build a pointer-to-member if the scope is an enumeration. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/enum43.C: New test. --- gcc/cp/semantics.cc | 3 ++- gcc/testsuite/g++.dg/cpp0x/enum43.C | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/enum43.C base-commit: e6ccae0ac0d53cfa9099d62fada050ee87d4d0ad diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 57dd7b66da8..87c2e8a7111 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -2386,7 +2386,8 @@ finish_qualified_id_expr (tree qualifying_class, /* If EXPR occurs as the operand of '&', use special handling that permits a pointer-to-member. */ - if (address_p && done) + if (address_p && done + && TREE_CODE (qualifying_class) != ENUMERAL_TYPE) { if (TREE_CODE (expr) == SCOPE_REF) expr = TREE_OPERAND (expr, 1); diff --git a/gcc/testsuite/g++.dg/cpp0x/enum43.C b/gcc/testsuite/g++.dg/cpp0x/enum43.C new file mode 100644 index 00000000000..b2cd9797a06 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum43.C @@ -0,0 +1,11 @@ +// PR c++/101869 + +enum E { A }; +E operator & (E e) +{ + return e; +} +E f(void) +{ + return &E::A; // { dg-error "not a class" "" { target c++98_only } } +}