| Message ID | afr60nyd3oXBbOc-@tucnak |
|---|---|
| State | New |
| Headers |
Return-Path: <gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7FD334BA23D3 for <patchwork@sourceware.org>; Wed, 6 May 2026 08:25:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FD334BA23D3 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WD1e/Yrh 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.129.124]) by sourceware.org (Postfix) with ESMTP id 9CDF24BA23D3 for <gcc-patches@gcc.gnu.org>; Wed, 6 May 2026 08:24:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9CDF24BA23D3 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 9CDF24BA23D3 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778055896; cv=none; b=lrQjTeAuDxdccD6dez3NZPN2llMulqQ3LX26Pmeg/9TcldRPLC2IMz5RtZFIoByWgN+3KNSBJuqJTve2FSils2hP79Ne7x/SNG4eeaVO77eLYm7DXk+/I86OsdBu55De7fuSl4RVm30gI0FwAhaGotvLhIkexRA5vHNOX3UxAwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778055896; c=relaxed/simple; bh=ysqNqymZeXVPg/IoaLOBaL/pPO1nKIAPMdDMXzaCUAo=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=VsWoAV22lZeg/zaVUtcuUiZ4WeQCoPxkrmuTvZqPJMb8nyzkOuGCxn91vyekbm+vNp+luMcL3ATjXQLS/iKBvq6+0MeuMDrCCvUZdFfYM0x5BqqC7NOuNfUDoQN66DfqXEy4JTxiWLfg7LtxbVN2chhnfQLwOZgZtCteM6V7E8Y= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WD1e/Yrh DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9CDF24BA23D3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778055896; 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=P0qvmhEgBlzavwmI688u5aqVP6QmuiQnFYxSz3rggR0=; b=WD1e/YrhF9rr9d+sJfu8UuBLzVXzd5vxCHUqXuCw8gDqOeU0vRWHIvwhw4JNP4wSF46R7X gyP5dQqRktZWAz0UDWeqYfWbA5fzYagwg/bcGRvqexbvbo+3O7EILyBgNVgfFjldg1CSvz JASITfj5rrb2fupyQ4v2DGlObccxmQ4= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-111-bNpgvyZdMrW7nCRbAnZ9Xg-1; Wed, 06 May 2026 04:24:54 -0400 X-MC-Unique: bNpgvyZdMrW7nCRbAnZ9Xg-1 X-Mimecast-MFC-AGG-ID: bNpgvyZdMrW7nCRbAnZ9Xg_1778055893 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D04A21800610 for <gcc-patches@gcc.gnu.org>; Wed, 6 May 2026 08:24:53 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.44.48.41]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 36BDC1800240; Wed, 6 May 2026 08:24:53 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.18.1/8.18.1) with ESMTPS id 6468Ooia202546 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 6 May 2026 10:24:50 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 6468Ooau202545; Wed, 6 May 2026 10:24:50 +0200 Date: Wed, 6 May 2026 10:24:50 +0200 From: Jakub Jelinek <jakub@redhat.com> To: Jason Merrill <jason@redhat.com>, Marek Polacek <polacek@redhat.com> Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Don't check for consteval-only uses inside of USING_STMT [PR125184] Message-ID: <afr60nyd3oXBbOc-@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 6KxlgOwIyq7gTz6vw_-2Jyv8qO6RhkGidnBkUjeGm60_1778055893 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Reply-To: Jakub Jelinek <jakub@redhat.com> Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org |
| Series |
c++: Don't check for consteval-only uses inside of USING_STMT [PR125184]
|
|
Commit Message
Jakub Jelinek
May 6, 2026, 8:24 a.m. UTC
Hi! I think a USING_STMT operand shouldn't count as consteval-only use. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2026-05-06 Jakub Jelinek <jakub@redhat.com> PR c++/125184 * reflect.cc (check_out_of_consteval_use): Ignore USING_STMTs. * g++.dg/reflect/using3.C: New test. Jakub
Comments
On Wed, May 06, 2026 at 10:24:50AM +0200, Jakub Jelinek wrote: > Hi! > > I think a USING_STMT operand shouldn't count as consteval-only use. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Looks ok to me. > 2026-05-06 Jakub Jelinek <jakub@redhat.com> > > PR c++/125184 > * reflect.cc (check_out_of_consteval_use): Ignore USING_STMTs. > > * g++.dg/reflect/using3.C: New test. > > --- gcc/cp/reflect.cc.jj 2026-05-05 09:57:59.014541622 +0200 > +++ gcc/cp/reflect.cc 2026-05-05 12:29:03.599363151 +0200 > @@ -8791,6 +8791,9 @@ check_out_of_consteval_use (tree expr, b > if (VAR_P (expr) && DECL_DECLARED_CONSTEXPR_P (expr)) > return false; > > + if (TREE_CODE (expr) == USING_STMT) > + return false; > + > hash_set<tree> pset; > if (tree t = cp_walk_tree (&expr, check_out_of_consteval_use_r, &pset, &pset)) > { > --- gcc/testsuite/g++.dg/reflect/using3.C.jj 2026-05-05 12:29:58.637468773 +0200 > +++ gcc/testsuite/g++.dg/reflect/using3.C 2026-05-05 12:30:45.345709765 +0200 > @@ -0,0 +1,11 @@ > +// PR c++/125184 > +// { dg-do compile { target c++26 } } > +// { dg-additional-options "-freflection" } > + > +#include <meta> > + > +void > +foo () > +{ > + using std::meta::info; > +} > > Jakub > Marek
On 5/6/26 8:38 AM, Marek Polacek wrote: > On Wed, May 06, 2026 at 10:24:50AM +0200, Jakub Jelinek wrote: >> Hi! >> >> I think a USING_STMT operand shouldn't count as consteval-only use. >> >> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > Looks ok to me. Should this be in check_out_of_consteval_use_r instead? I'm unclear on the recursion model of the walk over that function vs. the call to check_out_of_consteval_use in cp_fold_immediate_r. Are we visiting statements too many times? >> 2026-05-06 Jakub Jelinek <jakub@redhat.com> >> >> PR c++/125184 >> * reflect.cc (check_out_of_consteval_use): Ignore USING_STMTs. >> >> * g++.dg/reflect/using3.C: New test. >> >> --- gcc/cp/reflect.cc.jj 2026-05-05 09:57:59.014541622 +0200 >> +++ gcc/cp/reflect.cc 2026-05-05 12:29:03.599363151 +0200 >> @@ -8791,6 +8791,9 @@ check_out_of_consteval_use (tree expr, b >> if (VAR_P (expr) && DECL_DECLARED_CONSTEXPR_P (expr)) >> return false; >> >> + if (TREE_CODE (expr) == USING_STMT) >> + return false; >> + >> hash_set<tree> pset; >> if (tree t = cp_walk_tree (&expr, check_out_of_consteval_use_r, &pset, &pset)) >> { >> --- gcc/testsuite/g++.dg/reflect/using3.C.jj 2026-05-05 12:29:58.637468773 +0200 >> +++ gcc/testsuite/g++.dg/reflect/using3.C 2026-05-05 12:30:45.345709765 +0200 >> @@ -0,0 +1,11 @@ >> +// PR c++/125184 >> +// { dg-do compile { target c++26 } } >> +// { dg-additional-options "-freflection" } >> + >> +#include <meta> >> + >> +void >> +foo () >> +{ >> + using std::meta::info; >> +} >> >> Jakub >> > > Marek >
--- gcc/cp/reflect.cc.jj 2026-05-05 09:57:59.014541622 +0200 +++ gcc/cp/reflect.cc 2026-05-05 12:29:03.599363151 +0200 @@ -8791,6 +8791,9 @@ check_out_of_consteval_use (tree expr, b if (VAR_P (expr) && DECL_DECLARED_CONSTEXPR_P (expr)) return false; + if (TREE_CODE (expr) == USING_STMT) + return false; + hash_set<tree> pset; if (tree t = cp_walk_tree (&expr, check_out_of_consteval_use_r, &pset, &pset)) { --- gcc/testsuite/g++.dg/reflect/using3.C.jj 2026-05-05 12:29:58.637468773 +0200 +++ gcc/testsuite/g++.dg/reflect/using3.C 2026-05-05 12:30:45.345709765 +0200 @@ -0,0 +1,11 @@ +// PR c++/125184 +// { dg-do compile { target c++26 } } +// { dg-additional-options "-freflection" } + +#include <meta> + +void +foo () +{ + using std::meta::info; +}