public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: fix tf_decltype manipulation for COMPOUND_EXPR
@ 2023-11-07 15:08 Patrick Palka
  2023-11-10  0:44 ` Jason Merrill
  0 siblings, 1 reply; 5+ messages in thread
From: Patrick Palka @ 2023-11-07 15:08 UTC (permalink / raw)
  To: gcc-patches; +Cc: jason, Patrick Palka

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) <case COMPOUND_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<class T> A f();
+
+template<class T>
+decltype(42, f<T>()) g();
+
+using type = decltype(g<int>());
-- 
2.43.0.rc0.23.g8be77c5de6


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-11-10 20:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-07 15:08 [PATCH] c++: fix tf_decltype manipulation for COMPOUND_EXPR Patrick Palka
2023-11-10  0:44 ` Jason Merrill
2023-11-10 17:25   ` Patrick Palka
2023-11-10 19:33     ` Jason Merrill
2023-11-10 20:22       ` Patrick Palka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).