* [pushed] c++: tweak prvalue test [PR98469]
@ 2021-05-07 16:09 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2021-05-07 16:09 UTC (permalink / raw)
To: gcc-patches
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(-)
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))))
{
base-commit: 14ed21f8749ae359690d9c4a69ca38cc45d0d1b0
--
2.27.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-07 16:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07 16:09 [pushed] c++: tweak prvalue test [PR98469] Jason Merrill
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).