aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-04-05 09:31:28 +0200
committerJakub Jelinek <jakub@redhat.com>2024-04-05 09:31:28 +0200
commit592536eb3c0a97a55b1019ff0216ef77e6ca847e (patch)
tree73d684ddc1ac6db79cc19b77db7a603a16691804 /gcc
parent12b04452b40d49bb5322653cb5716b1ebf71b73d (diff)
downloadgcc-592536eb3c0a97a55b1019ff0216ef77e6ca847e.zip
gcc-592536eb3c0a97a55b1019ff0216ef77e6ca847e.tar.gz
gcc-592536eb3c0a97a55b1019ff0216ef77e6ca847e.tar.bz2
c++: Fix ICE with weird copy assignment operator [PR114572]
While ctors/dtors don't return anything (undeclared void or this pointer on arm) and copy assignment operators normally return a reference to *this, it isn't invalid to return uselessly some class object which might need destructing, but the OpenMP clause handling code wasn't expecting that. The following patch fixes that. 2024-04-05 Jakub Jelinek <jakub@redhat.com> PR c++/114572 * cp-gimplify.cc (cxx_omp_clause_apply_fn): Call build_cplus_new on build_call_a result if it has class type. * testsuite/libgomp.c++/pr114572.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/cp-gimplify.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc
index f3baae6..ab5acd1 100644
--- a/gcc/cp/cp-gimplify.cc
+++ b/gcc/cp/cp-gimplify.cc
@@ -2480,6 +2480,8 @@ cxx_omp_clause_apply_fn (tree fn, tree arg1, tree arg2)
TREE_PURPOSE (parm), fn,
i - is_method, tf_warning_or_error);
t = build_call_a (fn, i, argarray);
+ if (MAYBE_CLASS_TYPE_P (TREE_TYPE (t)))
+ t = build_cplus_new (TREE_TYPE (t), t, tf_warning_or_error);
t = fold_convert (void_type_node, t);
t = fold_build_cleanup_point_expr (TREE_TYPE (t), t);
append_to_statement_list (t, &ret);
@@ -2513,6 +2515,8 @@ cxx_omp_clause_apply_fn (tree fn, tree arg1, tree arg2)
TREE_PURPOSE (parm), fn,
i - is_method, tf_warning_or_error);
t = build_call_a (fn, i, argarray);
+ if (MAYBE_CLASS_TYPE_P (TREE_TYPE (t)))
+ t = build_cplus_new (TREE_TYPE (t), t, tf_warning_or_error);
t = fold_convert (void_type_node, t);
return fold_build_cleanup_point_expr (TREE_TYPE (t), t);
}