diff mbox series

[pushed] c++: tweak prvalue test [PR98469]

Message ID 20210507160906.4125446-1-jason@redhat.com
State New
Headers show
Series [pushed] c++: tweak prvalue test [PR98469] | expand

Commit Message

Jason Merrill May 7, 2021, 4:09 p.m. UTC
Discussing the 98469 patch and class prvalues with Jakub also inspired me to
change the place that was mishandling BIT_CAST_EXPR and one other to use the
lvalue_kind machinery to decide whether something is a prvalue, instead of
looking specifically for a TARGET_EXPR.

Tested x86_64-pc-linux-gnu, applying to trunk.

gcc/cp/ChangeLog:

	* call.c (build_special_member_call): Use !glvalue_p rather
	than specific tree codes to test for prvalue.
	(conv_is_prvalue): Likewise.
	(implicit_conversion): Check CLASS_TYPE_P first.
---
 gcc/cp/call.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)


base-commit: 14ed21f8749ae359690d9c4a69ca38cc45d0d1b0
diff mbox series

Patch

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 57bac05fe70..8e455e59909 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -2133,8 +2133,8 @@  implicit_conversion (tree to, tree from, tree expr, bool c_cast_p,
 					    flags, complain);
   if (!conv || conv->bad_p)
     return conv;
-  if (conv_is_prvalue (conv)
-      && CLASS_TYPE_P (conv->type)
+  if (CLASS_TYPE_P (conv->type)
+      && conv_is_prvalue (conv)
       && CLASSTYPE_PURE_VIRTUALS (conv->type))
     conv->bad_p = true;
   return conv;
@@ -8733,8 +8733,7 @@  conv_is_prvalue (conversion *c)
     return true;
   if (c->kind == ck_user && !TYPE_REF_P (c->type))
     return true;
-  if (c->kind == ck_identity && c->u.expr
-      && TREE_CODE (c->u.expr) == TARGET_EXPR)
+  if (c->kind == ck_identity && c->u.expr && !glvalue_p (c->u.expr))
     return true;
 
   return false;
@@ -10192,8 +10191,7 @@  build_special_member_call (tree instance, tree name, vec<tree, va_gc> **args,
 	  && CONSTRUCTOR_NELTS (arg) == 1)
 	arg = CONSTRUCTOR_ELT (arg, 0)->value;
 
-      if ((TREE_CODE (arg) == TARGET_EXPR
-	   || TREE_CODE (arg) == CONSTRUCTOR)
+      if (!glvalue_p (arg)
 	  && (same_type_ignoring_top_level_qualifiers_p
 	      (class_type, TREE_TYPE (arg))))
 	{