From 34e0841e21f97025d76601b802f9e2cd51bb4f38 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 29 Dec 2025 14:31:26 +0100 Subject: [PATCH] Export build_stub_type and use it in reflect.cc where needed. --- gcc/cp/cp-tree.h | 1 + gcc/cp/method.cc | 2 +- gcc/cp/reflect.cc | 37 +++++++++++++++---------------------- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 1be5e845a5c..21d36f6f70d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7825,6 +7825,7 @@ extern tree get_copy_ctor (tree, tsubst_flags_t); extern tree get_copy_assign (tree); extern tree get_default_ctor (tree); extern tree get_dtor (tree, tsubst_flags_t); +extern tree build_stub_type (tree, int, bool); extern tree build_stub_object (tree); extern bool is_stub_object (tree); extern tree build_invoke (tree, const_tree, diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc index e5ad3ac4494..94fdc32d0bd 100644 --- a/gcc/cp/method.cc +++ b/gcc/cp/method.cc @@ -1899,7 +1899,7 @@ maybe_synthesize_method (tree fndecl) /* Build a reference to type TYPE with cv-quals QUALS, which is an rvalue if RVALUE is true. */ -static tree +tree build_stub_type (tree type, int quals, bool rvalue) { tree argtype = cp_build_qualified_type (type, quals); diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc index fe58d5660e8..6eeeb945938 100644 --- a/gcc/cp/reflect.cc +++ b/gcc/cp/reflect.cc @@ -492,11 +492,10 @@ get_range_elts (location_t loc, const constexpr_ctx *ctx, tree call, int n, *non_constant_p = true; return NULL_TREE; } - tree cvaluet - = cp_build_qualified_type (valuet, cp_type_quals (valuet) - | TYPE_QUAL_CONST); TREE_VEC_ELT (args, 0) - = cp_build_reference_type (cvaluet, /*rval=*/false); + = build_stub_type (valuet, + cp_type_quals (valuet) | TYPE_QUAL_CONST, + false); if (!is_xible (INIT_EXPR, valuet, args)) { if (!cxx_constexpr_quiet_p (ctx)) @@ -4390,9 +4389,8 @@ static tree eval_is_copy_constructible_type (tree type) { tree arg = make_tree_vec (1); - tree ctype - = cp_build_qualified_type (type, cp_type_quals (type) | TYPE_QUAL_CONST); - TREE_VEC_ELT (arg, 0) = cp_build_reference_type (ctype, /*rval=*/false); + TREE_VEC_ELT (arg, 0) + = build_stub_type (type, cp_type_quals (type) | TYPE_QUAL_CONST, false); if (is_xible (INIT_EXPR, type, arg)) return boolean_true_node; else @@ -4426,9 +4424,8 @@ static tree eval_is_copy_assignable_type (tree type) { tree type1 = cp_build_reference_type (type, /*rval=*/false); - tree type2 - = cp_build_qualified_type (type, cp_type_quals (type) | TYPE_QUAL_CONST); - type2 = cp_build_reference_type (type2, /*rval=*/false); + tree type2 = build_stub_type (type, cp_type_quals (type) | TYPE_QUAL_CONST, + false); if (is_xible (MODIFY_EXPR, type1, type2)) return boolean_true_node; else @@ -4484,9 +4481,8 @@ static tree eval_is_trivially_copy_constructible_type (tree type) { tree arg = make_tree_vec (1); - tree ctype - = cp_build_qualified_type (type, cp_type_quals (type) | TYPE_QUAL_CONST); - TREE_VEC_ELT (arg, 0) = cp_build_reference_type (ctype, /*rval=*/false); + TREE_VEC_ELT (arg, 0) + = build_stub_type (type, cp_type_quals (type) | TYPE_QUAL_CONST, false); if (is_trivially_xible (INIT_EXPR, type, arg)) return boolean_true_node; else @@ -4520,9 +4516,8 @@ static tree eval_is_trivially_copy_assignable_type (tree type) { tree type1 = cp_build_reference_type (type, /*rval=*/false); - tree type2 - = cp_build_qualified_type (type, cp_type_quals (type) | TYPE_QUAL_CONST); - type2 = cp_build_reference_type (type2, /*rval=*/false); + tree type2 = build_stub_type (type, cp_type_quals (type) | TYPE_QUAL_CONST, + false); if (is_trivially_xible (MODIFY_EXPR, type1, type2)) return boolean_true_node; else @@ -4578,9 +4573,8 @@ static tree eval_is_nothrow_copy_constructible_type (tree type) { tree arg = make_tree_vec (1); - tree ctype - = cp_build_qualified_type (type, cp_type_quals (type) | TYPE_QUAL_CONST); - TREE_VEC_ELT (arg, 0) = cp_build_reference_type (ctype, /*rval=*/false); + TREE_VEC_ELT (arg, 0) + = build_stub_type (type, cp_type_quals (type) | TYPE_QUAL_CONST, false); if (is_nothrow_xible (INIT_EXPR, type, arg)) return boolean_true_node; else @@ -4614,9 +4608,8 @@ static tree eval_is_nothrow_copy_assignable_type (tree type) { tree type1 = cp_build_reference_type (type, /*rval=*/false); - tree type2 - = cp_build_qualified_type (type, cp_type_quals (type) | TYPE_QUAL_CONST); - type2 = cp_build_reference_type (type2, /*rval=*/false); + tree type2 = build_stub_type (type, cp_type_quals (type) | TYPE_QUAL_CONST, + false); if (is_nothrow_xible (MODIFY_EXPR, type1, type2)) return boolean_true_node; else