aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog54
-rw-r--r--gcc/cp/cp-gimplify.cc15
-rw-r--r--gcc/cp/decl2.cc14
-rw-r--r--gcc/cp/method.cc4
-rw-r--r--gcc/cp/module.cc32
-rw-r--r--gcc/cp/name-lookup.cc3
-rw-r--r--gcc/cp/optimize.cc4
-rw-r--r--gcc/cp/pt.cc10
8 files changed, 102 insertions, 34 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 764e158..b102f17 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,57 @@
+2025-05-15 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/120161
+ * pt.cc (unify) <case RECORD_TYPE>: When comparing specializations
+ of a non-primary template, still perform a type comparison.
+
+2025-05-15 Jason Merrill <jason@redhat.com>
+
+ * module.cc (trees_out::lang_decl_bools): Stream implicit_constexpr.
+ (trees_in::lang_decl_bools): Likewise.
+ (trees_in::is_matching_decl): Check it.
+
+2025-05-15 Jason Merrill <jason@redhat.com>
+
+ PR c++/99599
+ * pt.cc (conversion_may_instantiate_p): Make sure
+ classes are complete.
+
+2025-05-14 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ * cp-gimplify.cc (cp_fold): Remove a remnant comment.
+
+2025-05-14 Nathaniel Shead <nathanieloshead@gmail.com>
+
+ PR c++/120125
+ * module.cc (trees_out::write_function_def): Only set
+ DECL_NOT_REALLY_EXTERN if the importer might need to emit it.
+ * optimize.cc (maybe_thunk_body): Don't assume 'fn' has a cgraph
+ node created.
+
+2025-05-14 Nathaniel Shead <nathanieloshead@gmail.com>
+
+ PR c++/119864
+ * decl2.cc (start_objects): Only use module initialized for
+ host.
+ (c_parse_final_cleanups): Don't always create an OMP offload
+ init function in modules.
+
+2025-05-14 Nathaniel Shead <nathanieloshead@gmail.com>
+
+ * name-lookup.cc (lookup_imported_hidden_friend): Add back
+ lazy_load_pendings with comment.
+
+2025-05-14 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ * cp-gimplify.cc (cp_fold): Add to_underlying.
+
+2025-05-14 Owen Avery <powerboat9.gamer@gmail.com>
+ Jason Merrill <jason@redhat.com>
+
+ * method.cc (synthesized_method_walk): Check whether
+ -Wvirtual-move-assign is enabled at the location of a base
+ class's move assignment operator.
+
2025-05-12 Jason Merrill <jason@redhat.com>
PR c++/120012
diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc
index d2423fd..eab5550 100644
--- a/gcc/cp/cp-gimplify.cc
+++ b/gcc/cp/cp-gimplify.cc
@@ -3343,19 +3343,14 @@ cp_fold (tree x, fold_flags_t flags)
|| id_equal (DECL_NAME (callee), "addressof")
/* This addressof equivalent is used heavily in libstdc++. */
|| id_equal (DECL_NAME (callee), "__addressof")
+ || id_equal (DECL_NAME (callee), "to_underlying")
|| id_equal (DECL_NAME (callee), "as_const")))
{
r = CALL_EXPR_ARG (x, 0);
- /* Check that the return and argument types are sane before
- folding. */
- if (INDIRECT_TYPE_P (TREE_TYPE (x))
- && INDIRECT_TYPE_P (TREE_TYPE (r)))
- {
- if (!same_type_p (TREE_TYPE (x), TREE_TYPE (r)))
- r = build_nop (TREE_TYPE (x), r);
- x = cp_fold (r, flags);
- break;
- }
+ if (!same_type_p (TREE_TYPE (x), TREE_TYPE (r)))
+ r = build_nop (TREE_TYPE (x), r);
+ x = cp_fold (r, flags);
+ break;
}
int sv = optimize, nw = sv;
diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc
index 15db1d6..a08d173 100644
--- a/gcc/cp/decl2.cc
+++ b/gcc/cp/decl2.cc
@@ -4186,7 +4186,11 @@ start_objects (bool initp, unsigned priority, bool has_body,
bool omp_target = false)
{
bool default_init = initp && priority == DEFAULT_INIT_PRIORITY;
- bool is_module_init = default_init && module_global_init_needed ();
+ /* FIXME: We may eventually want to treat OpenMP offload initializers
+ in modules specially as well. */
+ bool is_module_init = (default_init
+ && !omp_target
+ && module_global_init_needed ());
tree name = NULL_TREE;
if (is_module_init)
@@ -5878,12 +5882,8 @@ c_parse_final_cleanups (void)
if (static_init_fini_fns[true]->get_or_insert (DEFAULT_INIT_PRIORITY))
has_module_inits = true;
- if (flag_openmp)
- {
- if (!static_init_fini_fns[2 + true])
- static_init_fini_fns[2 + true] = priority_map_t::create_ggc ();
- static_init_fini_fns[2 + true]->get_or_insert (DEFAULT_INIT_PRIORITY);
- }
+ /* FIXME: We need to work out what static constructors on OpenMP offload
+ target in modules will look like. */
}
/* Generate initialization and destruction functions for all
diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc
index 05c19cf..092bae2 100644
--- a/gcc/cp/method.cc
+++ b/gcc/cp/method.cc
@@ -2949,7 +2949,9 @@ synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p,
&& BINFO_VIRTUAL_P (base_binfo)
&& fn && TREE_CODE (fn) == FUNCTION_DECL
&& move_fn_p (fn) && !trivial_fn_p (fn)
- && vbase_has_user_provided_move_assign (BINFO_TYPE (base_binfo)))
+ && vbase_has_user_provided_move_assign (BINFO_TYPE (base_binfo))
+ && warning_enabled_at (DECL_SOURCE_LOCATION (fn),
+ OPT_Wvirtual_move_assign))
warning (OPT_Wvirtual_move_assign,
"defaulted move assignment for %qT calls a non-trivial "
"move assignment operator for virtual base %qT",
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index f562bf8..4f9c378 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -6024,7 +6024,7 @@ trees_out::lang_decl_bools (tree t, bits_out& bits)
WB (lang->u.fn.has_dependent_explicit_spec_p);
WB (lang->u.fn.immediate_fn_p);
WB (lang->u.fn.maybe_deleted);
- /* We do not stream lang->u.fn.implicit_constexpr. */
+ WB (lang->u.fn.implicit_constexpr);
WB (lang->u.fn.escalated_p);
WB (lang->u.fn.xobj_func);
goto lds_min;
@@ -6095,7 +6095,7 @@ trees_in::lang_decl_bools (tree t, bits_in& bits)
RB (lang->u.fn.has_dependent_explicit_spec_p);
RB (lang->u.fn.immediate_fn_p);
RB (lang->u.fn.maybe_deleted);
- /* We do not stream lang->u.fn.implicit_constexpr. */
+ RB (lang->u.fn.implicit_constexpr);
RB (lang->u.fn.escalated_p);
RB (lang->u.fn.xobj_func);
goto lds_min;
@@ -12193,13 +12193,23 @@ trees_in::is_matching_decl (tree existing, tree decl, bool is_typedef)
/* Similarly if EXISTING has undeduced constexpr, but DECL's
is already deduced. */
- if (DECL_MAYBE_DELETED (e_inner) && !DECL_MAYBE_DELETED (d_inner)
- && DECL_DECLARED_CONSTEXPR_P (d_inner))
- DECL_DECLARED_CONSTEXPR_P (e_inner) = true;
- else if (!DECL_MAYBE_DELETED (e_inner) && DECL_MAYBE_DELETED (d_inner))
- /* Nothing to do. */;
+ if (DECL_DECLARED_CONSTEXPR_P (e_inner)
+ == DECL_DECLARED_CONSTEXPR_P (d_inner))
+ /* Already matches. */;
+ else if (DECL_DECLARED_CONSTEXPR_P (d_inner)
+ && (DECL_MAYBE_DELETED (e_inner)
+ || decl_implicit_constexpr_p (d_inner)))
+ /* DECL was deduced, copy to EXISTING. */
+ {
+ DECL_DECLARED_CONSTEXPR_P (e_inner) = true;
+ if (decl_implicit_constexpr_p (d_inner))
+ DECL_LANG_SPECIFIC (e_inner)->u.fn.implicit_constexpr = true;
+ }
else if (DECL_DECLARED_CONSTEXPR_P (e_inner)
- != DECL_DECLARED_CONSTEXPR_P (d_inner))
+ && (DECL_MAYBE_DELETED (d_inner)
+ || decl_implicit_constexpr_p (e_inner)))
+ /* EXISTING was deduced, leave it alone. */;
+ else
{
mismatch_msg = G_("conflicting %<constexpr%> for imported "
"declaration %#qD");
@@ -12638,7 +12648,11 @@ trees_out::write_function_def (tree decl)
{
unsigned flags = 0;
- flags |= 1 * DECL_NOT_REALLY_EXTERN (decl);
+ /* Whether the importer should emit this definition, if used. */
+ flags |= 1 * (DECL_NOT_REALLY_EXTERN (decl)
+ && (get_importer_interface (decl)
+ != importer_interface::always_import));
+
if (f)
{
flags |= 2;
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 9b317c4..84b5e67 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -4556,6 +4556,9 @@ lookup_imported_hidden_friend (tree friend_tmpl)
|| !DECL_MODULE_ENTITY_P (inner))
return NULL_TREE;
+ /* Load any templates matching FRIEND_TMPL from importers. */
+ lazy_load_pendings (friend_tmpl);
+
tree name = DECL_NAME (inner);
tree *slot = find_namespace_slot (current_namespace, name, false);
if (!slot || !*slot || TREE_CODE (*slot) != BINDING_VECTOR)
diff --git a/gcc/cp/optimize.cc b/gcc/cp/optimize.cc
index 6f9a77f..fc4d6c2 100644
--- a/gcc/cp/optimize.cc
+++ b/gcc/cp/optimize.cc
@@ -309,8 +309,8 @@ maybe_thunk_body (tree fn, bool force)
defer_mangling_aliases = save_defer_mangling_aliases;
cgraph_node::get_create (fns[0])->set_comdat_group (comdat_group);
cgraph_node::get_create (fns[1])->add_to_same_comdat_group
- (cgraph_node::get_create (fns[0]));
- symtab_node::get (fn)->add_to_same_comdat_group
+ (cgraph_node::get (fns[0]));
+ symtab_node::get_create (fn)->add_to_same_comdat_group
(symtab_node::get (fns[0]));
if (fns[2])
/* If *[CD][12]* dtors go into the *[CD]5* comdat group and dtor is
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 0d64a1c..1973d25 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -23529,13 +23529,13 @@ conversion_may_instantiate_p (tree to, tree from)
/* Converting to a non-aggregate class type will consider its
user-declared constructors, which might induce instantiation. */
- if (CLASS_TYPE_P (to)
+ if (CLASS_TYPE_P (complete_type (to))
&& type_has_converting_constructor (to))
return true;
/* Similarly, converting from a class type will consider its conversion
functions. */
- if (CLASS_TYPE_P (from)
+ if (CLASS_TYPE_P (complete_type (from))
&& TYPE_HAS_CONVERSION (from))
return true;
@@ -25785,10 +25785,10 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (parm)),
INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (t)),
UNIFY_ALLOW_NONE, explain_p);
- else
- return unify_success (explain_p);
+ gcc_checking_assert (t == arg);
}
- else if (!same_type_ignoring_top_level_qualifiers_p (parm, arg))
+
+ if (!same_type_ignoring_top_level_qualifiers_p (parm, arg))
return unify_type_mismatch (explain_p, parm, arg);
return unify_success (explain_p);