On Fri, Oct 10, 2025 at 01:59:54PM +0200, Christophe Lyon wrote:
> We've noticed a regression (on aarch64):
> Running g++:g++.dg/gomp/gomp.exp ...
> 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)

Sorry, seems I've missed this.

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)

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

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

--- gcc/cp/decl.cc.jj   2025-10-10 18:26:04.000000000 +0200
+++ gcc/cp/decl.cc      2025-10-11 22:22:24.649283582 +0200
@@ -9099,6 +9099,7 @@ omp_declare_variant_finalize_one (tree d
          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 d
            {
              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 d
          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;

        Jakub

Reply via email to