https://gcc.gnu.org/g:80e82de4b802aa2e4c7cfad6e3288d99a7cb16ac
commit r16-4389-g80e82de4b802aa2e4c7cfad6e3288d99a7cb16ac Author: Jakub Jelinek <[email protected]> Date: Mon Oct 13 09:47:09 2025 +0200 openmp: Teach OpenMP declare variant append_args handling about TYPE_NO_NAMED_ARGS_STDARG_P Since my recent patch, GCC for C++26 uses the TYPE_NO_NAMED_ARGS_STDARG_P flag like C23 uses for (...) function types. The OpenMP declare variant append_args handling does some very ugly hacks (modify TYPE_ARG_TYPES temporarily instead of trying to create new function types) and had to be tweaked to deal with that. This fixes -FAIL: c-c++-common/gomp/append-args-7.c -std=c++26 scan-tree-dump-times gimple "f3 \\\\(obj1, obj2, 1, a, cp, d\\\\);" 1 -FAIL: c-c++-common/gomp/append-args-7.c -std=c++26 (test for excess errors) 2025-10-13 Jakub Jelinek <[email protected]> * decl.cc (omp_declare_variant_finalize_one): If !nbase_args and TREE_TYPE (decl) has TYPE_NO_NAMED_ARGS_STDARG_P bit set and varg is NULL, temporarily set TYPE_NO_NAMED_ARGS_STDARG_P on TREE_TYPE (variant). Diff: --- gcc/cp/decl.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index f198b7e671da..05791076d878 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -9099,6 +9099,7 @@ omp_declare_variant_finalize_one (tree decl, tree attr) for (unsigned i = 0; i < nappend_args && varg; i++) varg = TREE_CHAIN (varg); tree saved_vargs; + int saved_no_named_args_stdarg = 0; if (nbase_args) { saved_vargs = TREE_CHAIN (vargs); @@ -9108,6 +9109,11 @@ omp_declare_variant_finalize_one (tree decl, tree attr) { saved_vargs = vargs; TYPE_ARG_TYPES (TREE_TYPE (variant)) = varg; + saved_no_named_args_stdarg + = TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (variant)); + if (TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (decl)) + && varg == NULL_TREE) + TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (variant)) = 1; } /* Skip assert check that TYPE_CANONICAL is the same. */ fail = !comptypes (TREE_TYPE (decl), TREE_TYPE (variant), @@ -9115,7 +9121,11 @@ omp_declare_variant_finalize_one (tree decl, tree attr) if (nbase_args) TREE_CHAIN (vargs) = saved_vargs; else - TYPE_ARG_TYPES (TREE_TYPE (variant)) = saved_vargs; + { + TYPE_ARG_TYPES (TREE_TYPE (variant)) = saved_vargs; + TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (variant)) + = saved_no_named_args_stdarg; + } varg = saved_vargs; if (!fail && !processing_template_decl) for (unsigned i = 0; i < nappend_args;
