From patchwork Tue Nov 7 15:08:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1861141 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PJrOCHvq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SPsFG112qz1yQL for ; Wed, 8 Nov 2023 02:14:10 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D01C385DC04 for ; Tue, 7 Nov 2023 15:14:07 +0000 (GMT) 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 ESMTPS id 60B28388216B for ; Tue, 7 Nov 2023 15:13:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 60B28388216B 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 60B28388216B 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=1699370036; cv=none; b=k7aevhuyN6KCqf+yypEJS/ACw0lHw96aQTu06GpxQvtjHM1s5tsFDzp68CMoWTuiF3saSnaJZD3RyrGXhcteHHnbj+X+ZhLFbSV0qZFLLiNVwPgB15PeKyY0alZap4dbqf+x+gGgC4pkrGbAQz83dnGVA+QnNmRcvyPL4puFV9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699370036; c=relaxed/simple; bh=+523No+sT1S+VSdp0C93tYPWaDKRt9NHpvCdPjq033o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aPSnmNPsQbFh00Ymq8ekXP5haTc/3/tgrZ0HcsYzvECqXDAHNbZLvIcLvNPwrNtN/AkKfJMFxH+Q3azUnP2/YcglNBV07k4sOY/c3LqMbR7s27dJBs04dTtj2EgQmO+JvSLL/ZZcmECoMiGw0QPOKt1en84S+pMWb+wIr08KoBM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699370035; 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=FlFEiDvTgUSUP1tcGV125QiAbQv4Uu9gNUtgMx7H8tg=; b=PJrOCHvqHHl+9o+UQU9+wXvz2+TEJvD4YqRU5ZHj7DV8AMg8oPms8azbk9hUXQieG1DTff ETTFYkY8AQDAxPriRuBCYx/3d+e6jYZ1/vWvicdzmx4AQPoW7xGU9RU7OUw/A7y3sIclrC sFtw84GivIBfaIsy00bOE+OwYgtfR4k= Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-179-kWAi-vlTP5u93lfj1eNB1A-1; Tue, 07 Nov 2023 10:13:53 -0500 X-MC-Unique: kWAi-vlTP5u93lfj1eNB1A-1 Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-280152efdefso4006176a91.0 for ; Tue, 07 Nov 2023 07:13:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699370031; x=1699974831; 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=FlFEiDvTgUSUP1tcGV125QiAbQv4Uu9gNUtgMx7H8tg=; b=iBMTOpYS8MAdR+g5dgI8wKXCYnx7ozC2KIIC5dhxPPzSE/+YQIIg+japl9DQ8cTvQ6 nqqBqKU2tQPQ2FVThzqCJwTnvdhxfsRI3ftenW3sG6X3qRZSzkT6VIgf7fM5Urz7Jbb4 jf85Yl/olLfiA0XVAHNXhPHZ47SV5/+1Yfzv+Nqh0yjRGrh6TGKt5171S1YNoW5ojObD 6SLPIG7xoR32ApOGj/hHQDv2GjUZboGPt1vQrmqLqVRP9DNl2PHCXTtLS10hltzfX7Ux GQJtWWyxNpW9OyOKD5GLJnuH8f2/BAPvIccDohSgciBmjVuWTxptwX9PftOZgomITpx8 5Fag== X-Gm-Message-State: AOJu0YzWuDXcB2FWnC0rTelBdnK3CfXV5ryHfhjWPSwhMtbMd9iHdNh4 hwp+HEAeEh0iLgup3Sq0SgsP9FTaKs/drBIfP+DsgeHvioFt5sDnnxo63karEXOCvh4pmcM1+nP T9GOKogUEMKVTbNNOyheG7bPkwbCf7BcRnDsn3J5FdhDgC29mnjVBReA5TWMpnITO3F1Guf/WOV A= X-Received: by 2002:a05:6214:2a48:b0:66f:bc4b:2246 with SMTP id jf8-20020a0562142a4800b0066fbc4b2246mr39735859qvb.51.1699369721661; Tue, 07 Nov 2023 07:08:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkM+tAQDmE74SR2UndTaHOVdEVH0cv7ryKbQc0JovZVgMYHX+Q7V9tSY72qWTtFC/mRPniNQ== X-Received: by 2002:a05:6214:2a48:b0:66f:bc4b:2246 with SMTP id jf8-20020a0562142a4800b0066fbc4b2246mr39735833qvb.51.1699369721354; Tue, 07 Nov 2023 07:08:41 -0800 (PST) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id pp20-20020a056214139400b0065aff6b49afsm4438785qvb.110.2023.11.07.07.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 07:08:40 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: fix tf_decltype manipulation for COMPOUND_EXPR Date: Tue, 7 Nov 2023 10:08:38 -0500 Message-ID: <20231107150838.1031324-1-ppalka@redhat.com> X-Mailer: git-send-email 2.43.0.rc0.23.g8be77c5de6 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org bootstrapped and regtested on x86_64-pc-linxu-gnu, does this look OK for trunk? -- >8 -- In the COMPOUND_EXPR case of tsubst_expr, we were redundantly clearing the tf_decltype flag when substituting the LHS and also neglecting to propagate it when substituting the RHS. This patch corrects this flag manipulation, which allows us to accept the below testcase. gcc/cp/ChangeLog: * pt.cc (tsubst_expr) : Don't redundantly clear tf_decltype when substituting the LHS. Propagate tf_decltype when substituting the RHS. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/decltype-call7.C: New test. --- gcc/cp/pt.cc | 9 ++++----- gcc/testsuite/g++.dg/cpp0x/decltype-call7.C | 9 +++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/decltype-call7.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 521749df525..5f879287a58 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -20382,11 +20382,10 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) case COMPOUND_EXPR: { - tree op0 = tsubst_expr (TREE_OPERAND (t, 0), args, - complain & ~tf_decltype, in_decl); - RETURN (build_x_compound_expr (EXPR_LOCATION (t), - op0, - RECUR (TREE_OPERAND (t, 1)), + tree op0 = RECUR (TREE_OPERAND (t, 0)); + tree op1 = tsubst_expr (TREE_OPERAND (t, 1), args, + complain|decltype_flag, in_decl); + RETURN (build_x_compound_expr (EXPR_LOCATION (t), op0, op1, templated_operator_saved_lookups (t), complain|decltype_flag)); } diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-call7.C b/gcc/testsuite/g++.dg/cpp0x/decltype-call7.C new file mode 100644 index 00000000000..4ce3e68381e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype-call7.C @@ -0,0 +1,9 @@ +// { dg-do compile { target c++11 } } + +struct A; +template A f(); + +template +decltype(42, f()) g(); + +using type = decltype(g());