This patch adds support for the case where #pragma omp declare variant
with append_args is used inside a #pragma omp dispatch interop that
specifies fewer interop args than required by the variant; new interop
objects are implicitly created and then destroyed around the call to the
variant, using the GOMP_interop builtin.

gcc/ChangeLog
        * gimplify.cc (modify_call_for_omp_dispatch): Adjust arguments.
        Remove the "sorry" for the case where new interop objects must be
        constructed, and add code to make it work instead.
        (expand_variant_call_expr): Adjust arguments and call to
        modify_call_for_omp_dispatch.
        (gimplify_variant_call_expr): Simplify logic for calling
        expand_variant_call_expr.

gcc/testsuite/ChangeLog
        * c-c++-common/gomp/append-args-1.c: Adjust expected behavior.
        * c-c++-common/gomp/append-args-interop.c: New.
        * c-c++-common/gomp/dispatch-11.c: Adjust expected behavior.
        * g++.dg/gomp/append-args-1.C: Likewise.
        * gfortran.dg/gomp/declare-variant-mod-2.f90: Likewise.

Co-Authored-By: Tobias Burnus <tbur...@baylibre.com>
---
 gcc/gimplify.cc                               | 229 +++++++++++++++---
 .../c-c++-common/gomp/append-args-1.c         |  14 +-
 .../c-c++-common/gomp/append-args-interop.c   |  44 ++++
 gcc/testsuite/c-c++-common/gomp/dispatch-11.c |   3 -
 gcc/testsuite/g++.dg/gomp/append-args-1.C     |  18 +-
 .../gomp/declare-variant-mod-2.f90            |   6 -
 6 files changed, 245 insertions(+), 69 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/gomp/append-args-interop.c

diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 354c3d663e7..1ba56149ecc 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -3874,8 +3874,8 @@ find_supercontext (void)
 
 /* OpenMP: Handle the append_args and adjust_args clauses of
    declare_variant for EXPR, which is a CALL_EXPR whose CALL_EXPR_FN
-   is the variant, within a dispatch construct with clauses DISPATCH_CLAUSES
-   and location DISPATCH_LOC.
+   is the variant, within a dispatch construct with clauses DISPATCH_CLAUSES.
+   WANT_VALUE and POINTERIZE are as for expand_variant_call_expr.
 
    'append_args' causes interop objects are added after the last regular
    (nonhidden, nonvariadic) arguments of the variant function.
@@ -3885,7 +3885,7 @@ find_supercontext (void)
    address.  */
 static tree
 modify_call_for_omp_dispatch (tree expr, tree dispatch_clauses,
-                             location_t dispatch_loc)
+                             bool want_value, bool pointerize)
 {
   tree fndecl = get_callee_fndecl (expr);
 
@@ -3893,9 +3893,11 @@ modify_call_for_omp_dispatch (tree expr, tree 
dispatch_clauses,
   if (!fndecl)
     return expr;
 
+  tree init_code = NULL_TREE;
+  tree cleanup = NULL_TREE;
+  tree clobbers = NULL_TREE;
   int nargs = call_expr_nargs (expr);
   tree dispatch_device_num = NULL_TREE;
-  tree dispatch_device_num_init = NULL_TREE;
   tree dispatch_interop = NULL_TREE;
   tree dispatch_append_args = NULL_TREE;
   int nfirst_args = 0;
@@ -3956,14 +3958,6 @@ modify_call_for_omp_dispatch (tree expr, tree 
dispatch_clauses,
                "the %<device%> clause must be present if the %<interop%> "
                "clause has more than one list item");
     }
-  if (dispatch_append_args && nappend != ninterop)
-    {
-      sorry_at (EXPR_LOCATION (TREE_PURPOSE (dispatch_append_args)),
-               "%<append_args%> clause not yet supported for %qD, except "
-               "when specifying all %d objects in the %<interop%> clause "
-               "of the %<dispatch%> directive", fndecl, nappend);
-      inform (dispatch_loc, "required by %<dispatch%> construct");
-    }
   else if (dispatch_append_args)
     {
       tree *buffer = XALLOCAVEC (tree, nargs + nappend);
@@ -3976,11 +3970,153 @@ modify_call_for_omp_dispatch (tree expr, tree 
dispatch_clauses,
          arg = TREE_CHAIN (arg);
          buffer[i] = CALL_EXPR_ARG (expr, i);
        }
-      int j = nappend;
+      int j = ninterop;
       for (tree t = dispatch_interop; t; t = TREE_CHAIN (t))
        if (OMP_CLAUSE_CODE (t) == OMP_CLAUSE_INTEROP)
          buffer[i + --j] = OMP_CLAUSE_DECL (t);
       gcc_checking_assert (j == 0);
+
+      /* Do we need to create additional interop objects?  */
+      if (ninterop < nappend)
+       {
+         if (dispatch_device_num == NULL_TREE)
+           /* Not remapping device number.  */
+           dispatch_device_num = build_int_cst (integer_type_node,
+                                                GOMP_DEVICE_ICV);
+         int nnew = nappend - ninterop;
+         tree nobjs = build_int_cst (integer_type_node, nnew);
+         tree a, t;
+
+         /* Skip to the append_args clause for the first constructed
+            interop argument.  */
+         tree apparg = dispatch_append_args;
+         for (j = 0; j < ninterop; j++)
+           apparg = TREE_CHAIN (apparg);
+
+         /* omp_interop_t *objs[n]; */
+         tree objtype = build_pointer_type (pointer_sized_int_node);
+         t = build_array_type_nelts (objtype, nnew);
+         tree objs = create_tmp_var (t, "interopobjs");
+
+         /* int target_tgtsync[n]; */
+         t = build_array_type_nelts (integer_type_node, nnew);
+         tree target_tgtsync = create_tmp_var (t, "tgt_tgtsync");
+
+         /* Scan first to determine if we need a prefer_type array.  */
+         tree prefer_type = NULL_TREE;
+         tree prefer_type_type = NULL_TREE;
+         for (j = ninterop, a = apparg; j < nappend; j++, a = TREE_CHAIN (a))
+           if (TREE_VALUE (a) != NULL_TREE)
+             {
+               /* const char *prefer_type[n];  */
+               t = build_qualified_type (char_type_node, TYPE_QUAL_CONST);
+               prefer_type_type = build_pointer_type (t);
+               t = build_array_type_nelts (prefer_type_type, nnew);
+               prefer_type = create_tmp_var (t, "pref_type");
+               break;
+             }
+
+         /* Initialize the arrays, generating temp vars and clobbers for
+            the interobject objects.  (The constructed array holding the
+            pointers to these objects shouldn't need clobbering as there's
+            no reason for GOMP_interop to modify its contents.)  */
+         for (j = ninterop, a = apparg; j < nappend; j++, a = TREE_CHAIN (a))
+           {
+             /* The allocated temporaries for the interop objects
+                have type omp_interop_t, which is an integer type that
+                can encode a pointer.  */
+             tree objvar = create_tmp_var (pointer_sized_int_node, "interop");
+             buffer[i + j] = objvar;
+             TREE_ADDRESSABLE (objvar) = 1;
+             /* Generate a clobber for the temporary for when we're done
+                with it.  */
+             tree c = build_clobber (pointer_sized_int_node,
+                                     CLOBBER_OBJECT_END);
+             c = build2 (MODIFY_EXPR, pointer_sized_int_node, objvar, c);
+             if (clobbers)
+               clobbers = build2 (COMPOUND_EXPR, TREE_TYPE (clobbers),
+                                  c, clobbers);
+             else
+               clobbers = c;
+
+             /* objs[offset] = &objvar;  */
+             tree offset = build_int_cst (integer_type_node, j - ninterop);
+             tree init = build4 (ARRAY_REF, objtype, objs, offset,
+                                 NULL_TREE, NULL_TREE);
+             init = build2 (MODIFY_EXPR, objtype, init,
+                            build_fold_addr_expr (objvar));
+             if (init_code)
+               init_code = build2 (COMPOUND_EXPR, TREE_TYPE (init),
+                                   init_code, init);
+             else
+               init_code = init;
+
+             /* target_tgtsync[offset] = tgt;
+                (Don't blame me, I didn't design the encoding of this
+                info into the dispatch interop clause data structure,
+                but the runtime wants a bit mask.)  */
+             tree tree_tgt = TREE_OPERAND (TREE_PURPOSE (a), 0);
+             int tgt = 0;
+             if (TREE_PURPOSE (tree_tgt) == boolean_true_node)
+               tgt |= GOMP_INTEROP_TARGET;
+             if (TREE_VALUE (tree_tgt) == boolean_true_node)
+               tgt |= GOMP_INTEROP_TARGETSYNC;
+             init = build4 (ARRAY_REF, integer_type_node,
+                            target_tgtsync, offset, NULL_TREE, NULL_TREE);
+             init = build2 (MODIFY_EXPR, integer_type_node, init,
+                            build_int_cst (integer_type_node, tgt));
+             init_code = build2 (COMPOUND_EXPR, TREE_TYPE (init),
+                                 init_code, init);
+
+             if (prefer_type)
+               {
+                 tree pref = TREE_VALUE (a);
+                 if (pref == NULL_TREE)
+                   pref = null_pointer_node;
+                 else if (TREE_CODE (pref) == TREE_LIST)
+                   {
+                     /* FIXME: this is a bug in the C++ front end.  */
+                     sorry_at (OMP_CLAUSE_LOCATION (dispatch_interop),
+                               "%<prefer_type%> with template function");
+                     pref = null_pointer_node;
+                   }
+                 else
+                   pref = build_fold_addr_expr (pref);
+                 init = build4 (ARRAY_REF, prefer_type_type, prefer_type,
+                                offset, NULL_TREE, NULL_TREE);
+                 init = build2 (MODIFY_EXPR, prefer_type_type, init,
+                                pref);
+                 init_code = build2 (COMPOUND_EXPR, TREE_TYPE (init),
+                                     init_code, init);
+               }
+           }
+
+         tree fn = builtin_decl_explicit (BUILT_IN_GOMP_INTEROP);
+         tree create
+           = build_call_expr (fn, 11, dispatch_device_num,
+                              nobjs, objs, target_tgtsync,
+                              prefer_type ? prefer_type : null_pointer_node,
+                              integer_zero_node, null_pointer_node,
+                              integer_zero_node, null_pointer_node,
+                              integer_zero_node, null_pointer_node);
+         if (init_code)
+           init_code = build2 (COMPOUND_EXPR, TREE_TYPE (create),
+                               init_code, create);
+         else
+           init_code = create;
+
+         cleanup
+           = build_call_expr (fn, 11, dispatch_device_num,
+                              integer_zero_node, null_pointer_node,
+                              null_pointer_node, null_pointer_node,
+                              integer_zero_node, null_pointer_node,
+                              nobjs, objs,
+                              integer_zero_node, null_pointer_node);
+         if (clobbers)
+           cleanup = build2 (COMPOUND_EXPR, TREE_TYPE (clobbers),
+                             cleanup, clobbers);
+       }
+
       for (j = 0; j < nappend; j++)
        {
          /* Fortran permits by-reference or by-value for the dummy arg
@@ -4040,8 +4176,9 @@ modify_call_for_omp_dispatch (tree expr, tree 
dispatch_clauses,
 
   /* Nothing to do for adjust_args?  */
   if (!dispatch_adjust_args_list || !TYPE_ARG_TYPES (TREE_TYPE (fndecl)))
-    return expr;
+    goto add_cleanup;
 
+  /* Handle adjust_args.  */
   for (int i = 0; i < nargs; i++)
     {
       tree *arg_p = &CALL_EXPR_ARG (expr, i);
@@ -4126,9 +4263,14 @@ modify_call_for_omp_dispatch (tree expr, tree 
dispatch_clauses,
                    = builtin_decl_explicit (BUILT_IN_OMP_GET_DEFAULT_DEVICE);
                  tree call = build_call_expr (fn, 0);
                  dispatch_device_num = create_tmp_var_raw (TREE_TYPE (call));
-                 dispatch_device_num_init
+                 tree init
                    = build4 (TARGET_EXPR, TREE_TYPE (call),
                              dispatch_device_num, call, NULL_TREE, NULL_TREE);
+                 if (init_code)
+                   init_code = build2 (COMPOUND_EXPR, TREE_TYPE (init),
+                                       init_code, init);
+                 else
+                   init_code = init;
                }
 
              // We want to emit the following statement:
@@ -4163,9 +4305,35 @@ modify_call_for_omp_dispatch (tree expr, tree 
dispatch_clauses,
            }
        }
     }
-  if (dispatch_device_num_init)
-    expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr),
-                  dispatch_device_num_init, expr);
+
+ add_cleanup:
+  if (cleanup)
+    {
+      tree result = NULL_TREE;
+      if (want_value && pointerize)
+       {
+         tree tmp = create_tmp_var (build_pointer_type (TREE_TYPE (expr)),
+                                    "cleanuptmp");
+         result = build_simple_mem_ref (tmp);
+         expr = build2 (INIT_EXPR, TREE_TYPE (tmp), tmp,
+                        build_fold_addr_expr (expr));
+       }
+      else if (want_value)
+       {
+         tree tmp = create_tmp_var (TREE_TYPE (expr), "cleanuptmp");
+         result = tmp;
+         expr = build2 (INIT_EXPR, TREE_TYPE (tmp), tmp, expr);
+       }
+      if (init_code)
+       expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr), init_code, expr);
+      expr = build2 (TRY_FINALLY_EXPR, void_type_node, expr, cleanup);
+
+      if (result)
+       expr = build2 (COMPOUND_EXPR, TREE_TYPE (result), expr, result);
+    }
+  else if (init_code)
+    expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr), init_code, expr);
+
   return expr;
 }
 
@@ -4173,7 +4341,7 @@ modify_call_for_omp_dispatch (tree expr, tree 
dispatch_clauses,
    resolution and expansion of the CALL_EXPR EXPR.  WANT_VALUE is true
    if the result value of the call is needed; POINTERIZE is true if it
    also needs to be pointerized.  If OMP_DISPATCH_P is true, apply
-   associated transformations using DISPATCH_CLAUSES and DISPATCH_LOC.
+   associated transformations using DISPATCH_CLAUSES.
    This function may return either the original call or some other
    expression such as a conditional to select one of multiple calls.
 
@@ -4183,8 +4351,7 @@ modify_call_for_omp_dispatch (tree expr, tree 
dispatch_clauses,
 
 static tree
 expand_variant_call_expr (tree expr, bool want_value, bool pointerize,
-                         bool omp_dispatch_p,
-                         tree dispatch_clauses, location_t dispatch_loc)
+                         bool omp_dispatch_p, tree dispatch_clauses)
 {
   /* If we've already processed this call, stop now.  This can happen
      if the variant call resolves to the original function, or to
@@ -4239,7 +4406,8 @@ expand_variant_call_expr (tree expr, bool want_value, 
bool pointerize,
              if (omp_dispatch_p)
                thiscall = modify_call_for_omp_dispatch (thiscall,
                                                         dispatch_clauses,
-                                                        dispatch_loc);
+                                                        want_value,
+                                                        pointerize);
              if (!tail)
                tail = thiscall;
              else
@@ -4301,7 +4469,8 @@ expand_variant_call_expr (tree expr, bool want_value, 
bool pointerize,
              if (omp_dispatch_p)
                thiscall = modify_call_for_omp_dispatch (thiscall,
                                                         dispatch_clauses,
-                                                        dispatch_loc);
+                                                        want_value,
+                                                        pointerize);
            }
          if (pointerize)
            thiscall = build_fold_addr_expr_loc (loc, thiscall);
@@ -4337,15 +4506,11 @@ gimplify_variant_call_expr (tree expr, fallback_t 
fallback,
          || TREE_ADDRESSABLE (type)))
     pointerize = true;
 
-  if (omp_dispatch_p)
-    return expand_variant_call_expr (expr, want_value, pointerize,
-                                    omp_dispatch_p,
-                                    gimplify_omp_ctxp->clauses,
-                                    gimplify_omp_ctxp->location);
-  else
-    return expand_variant_call_expr (expr, want_value, pointerize,
-                                    omp_dispatch_p,
-                                    NULL_TREE, UNKNOWN_LOCATION);
+  return expand_variant_call_expr (expr, want_value, pointerize,
+                                  omp_dispatch_p,
+                                  (omp_dispatch_p
+                                   ? gimplify_omp_ctxp->clauses
+                                   : NULL_TREE));
 }
 
 
diff --git a/gcc/testsuite/c-c++-common/gomp/append-args-1.c 
b/gcc/testsuite/c-c++-common/gomp/append-args-1.c
index 2a4706362c4..e03b8de60b8 100644
--- a/gcc/testsuite/c-c++-common/gomp/append-args-1.c
+++ b/gcc/testsuite/c-c++-common/gomp/append-args-1.c
@@ -23,25 +23,19 @@ float base0();
 float repl1(omp_interop_t, omp_interop_t);
 #pragma omp declare variant(repl1) match(construct={dispatch}) 
append_args(interop(target), interop(targetsync))
 float base1();
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'repl1', except when specifying all 2 objects in the 'interop' clause of 
the 'dispatch' directive" "" { target c } .-2 }  */
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'float repl1\\(omp_interop_t, omp_interop_t\\)', except when specifying all 
2 objects in the 'interop' clause of the 'dispatch' directive" "" { target c++ 
} .-3 }  */
 
 void repl2(int *, int *, omp_interop_t, omp_interop_t);
 #pragma omp declare variant(repl2) match(construct={dispatch}) 
adjust_args(need_device_ptr : y) \
         append_args(interop(target, targetsync, prefer_type(1)), \
                     interop(prefer_type({fr(3), 
attr("ompx_nop")},{fr(2)},{attr("ompx_all")})))
 void base2(int *x, int *y);
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'repl2', except when specifying all 2 objects in the 'interop' clause of 
the 'dispatch' directive" "" { target c } .-3 }  */
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'void repl2\\(int\\*, int\\*, omp_interop_t, omp_interop_t\\)', except when 
specifying all 2 objects in the 'interop' clause of the 'dispatch' directive" 
"" { target c++ } .-4 }  */
 
 void repl3(int, omp_interop_t, ...);
 #pragma omp declare variant(repl3) match(construct={dispatch}) \
         append_args(interop(prefer_type("cuda", "hsa")))
 void base3(int, ...);
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'repl3', except when specifying all 1 objects in the 'interop' clause of 
the 'dispatch' directive" "" { target c } .-2 }  */
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'void repl3\\(int, omp_interop_t, \\.\\.\\.\\)', except when specifying all 
1 objects in the 'interop' clause of the 'dispatch' directive" "" { target c++ 
} .-3 }  */
-/* { dg-note "'declare variant' candidate 'repl3' declared here" "" { target c 
} .-4 } */
-/* { dg-note "'declare variant' candidate 'void repl3\\(int, omp_interop_t, 
\\.\\.\\.\\)' declared here" "" { target c++ } .-5 } */
+/* { dg-note "'declare variant' candidate 'repl3' declared here" "" { target c 
} .-2 } */
+/* { dg-note "'declare variant' candidate 'void repl3\\(int, omp_interop_t, 
\\.\\.\\.\\)' declared here" "" { target c++ } .-3 } */
 
 float repl4(short, short, omp_interop_t, short);
 #pragma omp declare variant(repl4) match(construct={dispatch}) 
append_args(interop(target)) append_args(interop(targetsync))  /* { dg-error 
"too many 'append_args' clauses" } */
@@ -75,15 +69,12 @@ test (int *a, int *b)
 
   #pragma omp dispatch interop ( obj1 )
     x = base1 ();
-  /* { dg-note "required by 'dispatch' construct" "" { target *-*-* } .-2 }  */
 
   #pragma omp dispatch interop ( obj1 )
     base2 (a, b);
-  /* { dg-note "required by 'dispatch' construct" "" { target *-*-* } .-2 }  */
 
   #pragma omp dispatch
     base3 (5, 1, 2, 3);
-  /* { dg-note "required by 'dispatch' construct" "" { target *-*-* } .-2 }  */
 
   #pragma omp dispatch interop (obj2)
     base3 (5, 1, 2, 3);
@@ -92,7 +83,6 @@ test (int *a, int *b)
     base3 (5, 1, 2, 3);
   /* { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the 
number of 'append_args' items \\(1\\) for 'declare variant' candidate 'repl3'" 
"" { target c } .-2 } */
   /* { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the 
number of 'append_args' items \\(1\\) for 'declare variant' candidate 'void 
repl3\\(int, omp_interop_t, \\.\\.\\.\\)'" "" { target c++ } .-3 } */
-  /* { dg-note "required by 'dispatch' construct" "" { target *-*-* } .-4 }  */
 
   return x;
 }
diff --git a/gcc/testsuite/c-c++-common/gomp/append-args-interop.c 
b/gcc/testsuite/c-c++-common/gomp/append-args-interop.c
new file mode 100644
index 00000000000..9494625cbbb
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/append-args-interop.c
@@ -0,0 +1,44 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fdump-tree-gimple" } */
+
+/* Test that interop objects are implicitly created/destroyed when a dispatch
+   construct doesn't provide enough of them to satisfy the declare variant
+   append_args clause.  */
+
+/* The following definitions are in omp_lib, which cannot be included
+   in gcc/testsuite/  */
+
+#if __cplusplus >= 201103L
+# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__
+#else
+# define __GOMP_UINTPTR_T_ENUM
+#endif
+
+typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM
+{
+  omp_interop_none = 0,
+  __omp_interop_t_max__ = __UINTPTR_MAX__
+} omp_interop_t;
+
+float repl1(omp_interop_t, omp_interop_t, omp_interop_t);
+
+#pragma omp declare variant(repl1) match(construct={dispatch}) 
append_args(interop(target), interop(targetsync), interop (target))
+float base1();
+
+float
+test (int *a, int *b)
+{
+  omp_interop_t obj1;
+  float x;
+
+  /* repl1 takes 3 interop arguments, one will come from the dispatch
+     construct and the other 2 will be consed up.  */
+  #pragma omp dispatch interop ( obj1 )
+    x = base1 ();
+
+  return x;
+}
+
+/* { dg-final { scan-tree-dump "__builtin_GOMP_interop \\(D\.\[0-9\]+, 2, 
interopobjs\.\[0-9\]+, tgt_tgtsync\.\[0-9\]+," "gimple" } } */
+/* { dg-final { scan-tree-dump "__builtin_GOMP_interop \\(D\.\[0-9\]+, 0, 0B, 
0B, 0B, 0, 0B, 2, interopobjs\.\[0-9\]+," "gimple" } } */
+/* { dg-final { scan-tree-dump "repl1 \\(obj1, interop\.\[0-9\]+, 
interop\.\[0-9\]+\\)" "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/dispatch-11.c 
b/gcc/testsuite/c-c++-common/gomp/dispatch-11.c
index e59985a5691..79dcd0a409e 100644
--- a/gcc/testsuite/c-c++-common/gomp/dispatch-11.c
+++ b/gcc/testsuite/c-c++-common/gomp/dispatch-11.c
@@ -87,12 +87,9 @@ test (int *a, int *b)
     base3 (a, b);
   /* { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the 
number of 'append_args' items \\(1\\) for 'declare variant' candidate 'repl3'" 
"" { target c } .-2 } */
   /* { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the 
number of 'append_args' items \\(1\\) for 'declare variant' candidate 'void 
repl3\\(int\\*, int\\*, omp_interop_t\\)'" "" { target c++ } .-3 } */
-  /* { dg-note "required by 'dispatch' construct" "" { target *-*-* } .-4 } */
 
   #pragma omp dispatch interop(obj3)
     base3 (a, b);
-  /* { dg-message "sorry, unimplemented: 'append_args' clause not yet 
supported for 'repl3'" "" { target c } 28 }  */
-  /* { dg-message "sorry, unimplemented: 'append_args' clause not yet 
supported for 'void repl3\\(int\\*, int\\*, omp_interop_t\\)'" "" { target c++ 
} 28 }  */
   return x + y;
 }
 
diff --git a/gcc/testsuite/g++.dg/gomp/append-args-1.C 
b/gcc/testsuite/g++.dg/gomp/append-args-1.C
index 7ff402336ce..25ea4c28e4a 100644
--- a/gcc/testsuite/g++.dg/gomp/append-args-1.C
+++ b/gcc/testsuite/g++.dg/gomp/append-args-1.C
@@ -20,8 +20,6 @@ template<typename T>
 float base1(T);
 
 
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'float repl1\\(T, T2, T2\\) \\\[with T = omp_interop_t; T2 = 
omp_interop_t\\\]', except when specifying all 2 objects in the 'interop' 
clause of the 'dispatch' directive" "" { target *-*-* } .-5 }  */
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'float repl1\\(T, T2, T2\\) \\\[with T = float; T2 = omp_interop_t\\\]', 
except when specifying all 2 objects in the 'interop' clause of the 'dispatch' 
directive" "" { target *-*-* } .-6 }  */
 
 
 
@@ -45,8 +43,6 @@ void repl99(T);
         append_args(interop(target, targetsync, prefer_type("cuda")))
 void base99();
 
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'void repl99\\(T\\) \\\[with T = omp_interop_t\\\]', except when specifying 
all 1 objects in the 'interop' clause of the 'dispatch' directive" "" { target 
*-*-* } .-3 }  */
-
 
 
 template<typename T, typename T2, typename T3>
@@ -57,9 +53,6 @@ void repl2(T, T2, T3, T3);
 template<typename T, typename T2>
 void base2(T x, T2 y);
 
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'void repl2\\(T, T2, T3, T3\\) \\\[with T = int\\*; T2 = int\\*; T3 = 
omp_interop_t\\\]', except when specifying all 2 objects in the 'interop' 
clause of the 'dispatch' directive" "" { target *-*-* } .-5 }  */
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'void repl2\\(T, T2, T3, T3\\) \\\[with T = int\\*; T2 = omp_interop_t; T3 
= omp_interop_t\\\]', except when specifying all 2 objects in the 'interop' 
clause of the 'dispatch' directive" "" { target *-*-* } .-6 }  */
-
 
 template<typename T,typename T3>
 void tooFewRepl(T, T, T3);
@@ -83,7 +76,6 @@ void repl3(T, T2, ...);
 template<typename T>
 void base3(T, ...);
 
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'void repl3\\(T, T2, \.\.\.\\) \\\[with T = int\\*; T2 = 
omp_interop_t\\\]', except when specifying all 1 objects in the 'interop' 
clause of the 'dispatch' directive" "" { target *-*-* } .-4 }  */
 
 
 
@@ -104,23 +96,18 @@ test (int *a, int *b)
 
   #pragma omp dispatch
     base99 ();
-  /* { dg-note "required by 'dispatch' construct" "" { target *-*-* } .-2 }  */
 
-  #pragma omp dispatch interop ( obj1 )
+  #pragma omp dispatch interop ( obj1 )  // { dg-message "sorry" }
     base2<int *, omp_interop_t> (b, omp_interop_none);
-  /* { dg-note "required by 'dispatch' construct" "" { target *-*-* } .-2 }  */
 
-  #pragma omp dispatch interop ( obj1 )
+  #pragma omp dispatch interop ( obj1 )  // { dg-message "sorry" }
     base2<int *, int *> (b, a);
-  /* { dg-note "required by 'dispatch' construct" "" { target *-*-* } .-2 }  */
 
   #pragma omp dispatch interop ( obj1 )
     x = base1<omp_interop_t> (omp_interop_none);
-  /* { dg-note "required by 'dispatch' construct" "" { target *-*-* } .-2 }  */
 
   #pragma omp dispatch interop ( obj1 )
     x = base1<float> (1.0f);
-  /* { dg-note "required by 'dispatch' construct" "" { target *-*-* } .-2 }  */
 
   #pragma omp dispatch
     tooFewBase<int*,int*>(a,b);
@@ -130,7 +117,6 @@ test (int *a, int *b)
 
   #pragma omp dispatch
     base3<int*>(a, 1, 2, "abc");
-  /* { dg-note "required by 'dispatch' construct" "" { target *-*-* } .-2 }  */
 
   return x;
 }
diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-mod-2.f90 
b/gcc/testsuite/gfortran.dg/gomp/declare-variant-mod-2.f90
index f75b49ce063..ab4405056a9 100644
--- a/gcc/testsuite/gfortran.dg/gomp/declare-variant-mod-2.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/declare-variant-mod-2.f90
@@ -9,12 +9,6 @@
 
 ! { dg-error "'x' at .1. is specified more than once" "" { target *-*-* } 17 }
 
-! { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'm2_f1', except when specifying all 1 objects in the 'interop' clause of 
the 'dispatch' directive" "" { target *-*-* } 27 }
-! { dg-note "required by 'dispatch' construct" "" { target *-*-* } 33 }
-! { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'm2_f2', except when specifying all 2 objects in the 'interop' clause of 
the 'dispatch' directive" "" { target *-*-* } 27 }
-! { dg-note "required by 'dispatch' construct" "" { target *-*-* } 37 }
-! { dg-message "sorry, unimplemented: 'append_args' clause not yet supported 
for 'm2_f3', except when specifying all 3 objects in the 'interop' clause of 
the 'dispatch' directive" "" { target *-*-* } 27 }
-! { dg-note "required by 'dispatch' construct" "" { target *-*-* } 43 }
 
 ! Check that module-file handling works for declare_variant
 ! and its match/adjust_args/append_args clauses
-- 
2.34.1

Reply via email to