https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118486
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Actually, it seems to be a general struct-returning issue.
The following compiles with clang++-19 but g++ rejects it with the same error:
struct NotAnInt {};
NotAnInt expl();
#pragma omp declare variant(expl) match(user={condition(1)})
NotAnInt base();
void f() {
NotAnInt x;
x = base();
}
* * *
The following patch seems to fix all issues mentioned here:
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -8552,6 +8552,9 @@ omp_declare_variant_finalize_one (tree decl, tree attr)
if (variant == error_mark_node && !processing_template_decl)
return true;
+ if (TREE_CODE (variant) == TARGET_EXPR)
+ variant = TARGET_EXPR_INITIAL (variant);
+
variant = cp_get_callee_fndecl_nofold (STRIP_REFERENCE_REF (variant));
input_location = save_loc;