]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: Teach OpenMP declare variant append_args handling about TYPE_NO_NAMED_ARGS_ST...
authorJakub Jelinek <jakub@redhat.com>
Mon, 13 Oct 2025 07:47:09 +0000 (09:47 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 13 Oct 2025 07:47:09 +0000 (09:47 +0200)
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  <jakub@redhat.com>

* 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).

gcc/cp/decl.cc

index f198b7e671da763f509ea24e9a8a3cd08d8f79e2..05791076d87802b14cd0b1ef2c7b3e8cbf344c46 100644 (file)
@@ -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;