On 8/25/25 00:13, Jakub Jelinek wrote:
Yes, GCC doesn't have it implemented fully, but that doesn't mean it should
be ripped off, the implementation should be simply finished.

Well, I have no idea how to make this work, nor any enthusiasm for devoting a big block of time to this. So I've taken Tobias's suggestion of emitting a "sorry" for the incomplete functionality instead of silently emitting bad code. New part 2 patch attached. Is this OK?

It would be good if somebody who understands what needs to be done to make this work as you envision would update the PR, BTW. There also needs to be some actual specification of the implementation-defined functionality that could serve as the basis for user-facing documentation.

-Sandra

From aa3ffbaf19236a54ac6c0ac54e84787b81180ac0 Mon Sep 17 00:00:00 2001
From: Sandra Loosemore <sloosem...@baylibre.com>
Date: Mon, 25 Aug 2025 23:22:30 +0000
Subject: [PATCH 2/3] OpenMP: Add "sorry" for unimplemented "declare variant"
 SIMD functionality [PR121630]

As noted in PR middle-end/121630, GCC seems to think that the "simd"
construct selector on "declare variant" implies that the variant
function accepts vectorized arguments, although this is not anywhere
in the OpenMP specification.  Additionally, it does not actually
vectorize the calls when doing variant replacement, causing incorrect
code to be generated.  This is making it through the front ends
because all of C, C++, and Fortran suppress the normal consistency
checking between the variant and base function when "simd" is specified.

Vectorization of the arguments was apparently supposed to be the intent
of the OpenMP committee even if the spec doesn't say so, but since GCC
doesn't implement that, this patch generates a "sorry" for any
"declare variant" using the "simd" construct selector to avoid silently
generating wrong code.

gcc/c/
	PR middle-end/121630
	* c-parser.cc (c_finish_omp_declare_variant): Emit "sorry"
	when the "simd" construct selector is present.

gcc/cp/
	PR middle-end/121630
	* decl.cc (omp_declare_variant_finalize_one): Emit "sorry"
	when the "simd" construct selector is present.

gcc/fortran/
	PR middle-end/121630
	* trans-openmp.cc (gfc_trans_omp_declare_variant): Emit "sorry"
	when the "simd" construct selector is present.

gcc/testsuite/
	PR middle-end/121630
	* c-c++-common/gomp/declare-variant-2.c: Adjust expected output.
	* c-c++-common/gomp/declare-variant-5.c: Likewise.
	* c-c++-common/gomp/declare-variant-7.c: Likewise.
	* gcc.dg/gomp/pr95315-2.c: Likewise.
	* gcc.dg/gomp/pr95315.c: Likewise.
	* gfortran.dg/gomp/declare-variant-5.f90: Likewise.
	* gfortran.dg/gomp/declare-variant-7.f90: Likewise.
---
 gcc/c/c-parser.cc                             | 270 +++++++++---------
 gcc/cp/decl.cc                                |  28 +-
 gcc/fortran/trans-openmp.cc                   |  10 +-
 .../c-c++-common/gomp/declare-variant-2.c     |   3 +-
 .../c-c++-common/gomp/declare-variant-5.c     |   3 +
 .../c-c++-common/gomp/declare-variant-7.c     |  40 ++-
 gcc/testsuite/gcc.dg/gomp/pr95315-2.c         |   3 +
 gcc/testsuite/gcc.dg/gomp/pr95315.c           |  37 ++-
 .../gfortran.dg/gomp/declare-variant-5.f90    |   3 +
 .../gfortran.dg/gomp/declare-variant-7.f90    |  27 +-
 10 files changed, 265 insertions(+), 159 deletions(-)

diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index db669242d58..df283c34064 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -27561,144 +27561,152 @@ c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms)
       return;
     }
 
-  if (!omp_get_context_selector (ctx, OMP_TRAIT_SET_CONSTRUCT,
-				 OMP_TRAIT_CONSTRUCT_SIMD))
-    /* Check that the base and variant have compatible types.  */
+  /* There is apparently an expectation that variants with "simd" in
+     the construct selector set have vectorized arguments.  Nothing
+     implements this on the call site side yet.  */
+  if (omp_get_context_selector (ctx, OMP_TRAIT_SET_CONSTRUCT,
+				OMP_TRAIT_CONSTRUCT_SIMD))
     {
-      tree base_type = TREE_TYPE (fndecl);
-      tree variant_type = TREE_TYPE (variant);
-      bool unprototyped_variant
-	= (TYPE_ARG_TYPES (variant_type) == NULL_TREE
-	   && !TYPE_NO_NAMED_ARGS_STDARG_P (variant_type));
+      sorry_at (token->location,
+		"vectorization for variant function calls not "
+		"implemented yet");
+      return;
+    }
 
-      if (append_args_tree
-	  && TYPE_ARG_TYPES (base_type) == NULL_TREE
-	  && !TYPE_NO_NAMED_ARGS_STDARG_P (base_type))
+    /* Check that the base and variant have compatible types.  */
+  tree base_type = TREE_TYPE (fndecl);
+  tree variant_type = TREE_TYPE (variant);
+  bool unprototyped_variant
+    = (TYPE_ARG_TYPES (variant_type) == NULL_TREE
+       && !TYPE_NO_NAMED_ARGS_STDARG_P (variant_type));
+
+  if (append_args_tree
+      && TYPE_ARG_TYPES (base_type) == NULL_TREE
+      && !TYPE_NO_NAMED_ARGS_STDARG_P (base_type))
+    {
+      /* The base function is a pre-C23 unprototyped function.  Without
+	 a prototype, we don't know the offset where the append_args go.
+	 That offset needs to be stored with the append_args in the
+	 variant function attributes, so we cannot presently handle
+	 this case.  */
+      sorry_at (append_args_loc,
+		"%<append_args%> with unprototyped base function "
+		"is not supported yet");
+      inform (DECL_SOURCE_LOCATION (fndecl),
+	      "base function %qD declared here", fndecl);
+      return;
+    }
+  else if (append_args_tree)
+    {
+      /* Find nbase_args, the number of fixed arguments in the base
+	 function.  */
+      int nappend_args = 0;
+      int nbase_args = 0;
+      for (tree t = TYPE_ARG_TYPES (base_type);
+	   t && TREE_VALUE (t) != void_type_node; t = TREE_CHAIN (t))
+	nbase_args++;
+      for (tree t = append_args_tree; t; t = TREE_CHAIN (t))
+	nappend_args++;
+
+      /* Store as purpose = arg number after which to append
+	 and value = list of interop items.  */
+      append_args_tree = build_tree_list (build_int_cst (integer_type_node,
+							 nbase_args),
+					  append_args_tree);
+
+      /* Give a specific diagnostic if the append_args parameters
+	 of the variant are of the wrong type, or missing.  The
+	 compatible types test below could fail to detect this if
+	 the variant is a varargs function.  */
+      if (!unprototyped_variant)
 	{
-	  /* The base function is a pre-C23 unprototyped function.  Without
-	     a prototype, we don't know the offset where the append_args go.
-	     That offset needs to be stored with the append_args in the
-	     variant function attributes, so we cannot presently handle
-	     this case.  */
-	  sorry_at (append_args_loc,
-		    "%<append_args%> with unprototyped base function "
-		    "is not supported yet");
-	  inform (DECL_SOURCE_LOCATION (fndecl),
-		  "base function %qD declared here", fndecl);
+	  tree args = TYPE_ARG_TYPES (variant_type);
+	  for (int i = 0; args && i < nbase_args;
+	       i++, args = TREE_CHAIN (args))
+	    ;
+	  for (int i = 0; i < nappend_args; i++, args = TREE_CHAIN (args))
+	    if (!args || !c_omp_interop_t_p (TREE_VALUE (args)))
+	      {
+		error_at (DECL_SOURCE_LOCATION (variant),
+			  "argument %d of %qD must be of "
+			  "%<omp_interop_t%>",
+			  nbase_args + i + 1, variant);
+		inform (append_args_loc,
+			"%<append_args%> specified here");
+		return;
+	      }
+	}
+
+      /* Perform the "implementation defined transformation" on the type
+	 of the base function to add the append_args before checking it
+	 for compatibility with the function variant's type.  */
+      tree args = TYPE_ARG_TYPES (base_type);
+      tree newargs = NULL_TREE;
+      tree lastarg = NULL_TREE;
+      for (int j = 0; j < nbase_args; j++, args = TREE_CHAIN (args))
+	{
+	  tree t = tree_cons (TREE_PURPOSE (args),
+			      TREE_VALUE (args), NULL_TREE);
+	  if (lastarg)
+	    TREE_CHAIN (lastarg) = t;
+	  else
+	    newargs = t;
+	  lastarg = t;
+	}
+      tree type = lookup_name (get_identifier ("omp_interop_t"));
+      type = type ? TREE_TYPE (type) : pointer_sized_int_node;
+      for (int j = 0; j < nappend_args; j++)
+	{
+	  tree t = tree_cons (NULL_TREE, type, NULL_TREE);
+	  if (lastarg)
+	    TREE_CHAIN (lastarg) = t;
+	  else
+	    newargs = t;
+	  lastarg = t;
+	}
+      TREE_CHAIN (lastarg) = args;
+
+      /* Temporarily stuff newargs into the original base_type.  */
+      tree saveargs = TYPE_ARG_TYPES (base_type);
+      TYPE_ARG_TYPES (base_type) = newargs;
+      bool fail = !comptypes (base_type, variant_type);
+      TYPE_ARG_TYPES (base_type) = saveargs;
+
+      if (fail)
+	{
+	  error_at (token->location,
+		    "variant %qD and base %qD have incompatible types "
+		    "after %<append_args%> adjustment",
+		    variant, fndecl);
+	  inform (DECL_SOURCE_LOCATION (variant),
+		  "%<declare variant%> candidate %qD declared here",
+		  variant);
 	  return;
 	}
-      else if (append_args_tree)
+      else if (unprototyped_variant)
+	/* If we've got an unprototyped variant, copy the transformed
+	   base arg types to the variant.  This is needed later by
+	   modify_call_for_omp_dispatch.  */
+	TYPE_ARG_TYPES (variant_type) = newargs;
+    }
+  else  /* No append_args present.  */
+    {
+      if (!comptypes (base_type, variant_type))
 	{
-	  /* Find nbase_args, the number of fixed arguments in the base
-	     function.  */
-	  int nappend_args = 0;
-	  int nbase_args = 0;
-	  for (tree t = TYPE_ARG_TYPES (base_type);
-	       t && TREE_VALUE (t) != void_type_node; t = TREE_CHAIN (t))
-	    nbase_args++;
-	  for (tree t = append_args_tree; t; t = TREE_CHAIN (t))
-	    nappend_args++;
-
-	  /* Store as purpose = arg number after which to append
-	     and value = list of interop items.  */
-	  append_args_tree = build_tree_list (build_int_cst (integer_type_node,
-							     nbase_args),
-					      append_args_tree);
-
-	  /* Give a specific diagnostic if the append_args parameters
-	     of the variant are of the wrong type, or missing.  The
-	     compatible types test below could fail to detect this if
-	     the variant is a varargs function.  */
-	  if (!unprototyped_variant)
-	    {
-	      tree args = TYPE_ARG_TYPES (variant_type);
-	      for (int i = 0; args && i < nbase_args;
-		   i++, args = TREE_CHAIN (args))
-		;
-	      for (int i = 0; i < nappend_args; i++, args = TREE_CHAIN (args))
-		if (!args || !c_omp_interop_t_p (TREE_VALUE (args)))
-		  {
-		    error_at (DECL_SOURCE_LOCATION (variant),
-			      "argument %d of %qD must be of "
-			      "%<omp_interop_t%>",
-			      nbase_args + i + 1, variant);
-		    inform (append_args_loc,
-			    "%<append_args%> specified here");
-		    return;
-		  }
-	    }
-
-	  /* Perform the "implementation defined transformation" on the type
-	     of the base function to add the append_args before checking it
-	     for compatibility with the function variant's type.  */
-	  tree args = TYPE_ARG_TYPES (base_type);
-	  tree newargs = NULL_TREE;
-	  tree lastarg = NULL_TREE;
-	  for (int j = 0; j < nbase_args; j++, args = TREE_CHAIN (args))
-	    {
-	      tree t = tree_cons (TREE_PURPOSE (args),
-				  TREE_VALUE (args), NULL_TREE);
-	      if (lastarg)
-		TREE_CHAIN (lastarg) = t;
-	      else
-		newargs = t;
-	      lastarg = t;
-	    }
-	  tree type = lookup_name (get_identifier ("omp_interop_t"));
-	  type = type ? TREE_TYPE (type) : pointer_sized_int_node;
-	  for (int j = 0; j < nappend_args; j++)
-	    {
-	      tree t = tree_cons (NULL_TREE, type, NULL_TREE);
-	      if (lastarg)
-		TREE_CHAIN (lastarg) = t;
-	      else
-		newargs = t;
-	      lastarg = t;
-	    }
-	  TREE_CHAIN (lastarg) = args;
-
-	  /* Temporarily stuff newargs into the original base_type.  */
-	  tree saveargs = TYPE_ARG_TYPES (base_type);
-	  TYPE_ARG_TYPES (base_type) = newargs;
-	  bool fail = !comptypes (base_type, variant_type);
-	  TYPE_ARG_TYPES (base_type) = saveargs;
-
-	  if (fail)
-	    {
-	      error_at (token->location,
-			"variant %qD and base %qD have incompatible types "
-			"after %<append_args%> adjustment",
-			variant, fndecl);
-	      inform (DECL_SOURCE_LOCATION (variant),
-		      "%<declare variant%> candidate %qD declared here",
-		      variant);
-	      return;
-	    }
-	  else if (unprototyped_variant)
-	    /* If we've got an unprototyped variant, copy the transformed
-	       base arg types to the variant.  This is needed later by
-	       modify_call_for_omp_dispatch.  */
-	    TYPE_ARG_TYPES (variant_type) = newargs;
-	}
-      else  /* No append_args present.  */
-	{
-	  if (!comptypes (base_type, variant_type))
-	    {
-	      error_at (token->location,
-			"variant %qD and base %qD have incompatible types",
-			variant, fndecl);
-	      inform (DECL_SOURCE_LOCATION (variant),
-		      "%<declare variant%> candidate %qD declared here",
-		      variant);
-	      return;
-	    }
-	  else if (TYPE_ARG_TYPES (variant_type) == NULL_TREE
-		   && !TYPE_NO_NAMED_ARGS_STDARG_P (variant_type)
-		   && TYPE_ARG_TYPES (base_type) != NULL_TREE)
-	    /* If we've got an unprototyped variant but the base has
-	       a prototype, copy the base arg types to the variant.  */
-	    TYPE_ARG_TYPES (variant_type) = TYPE_ARG_TYPES (base_type);
+	  error_at (token->location,
+		    "variant %qD and base %qD have incompatible types",
+		    variant, fndecl);
+	  inform (DECL_SOURCE_LOCATION (variant),
+		  "%<declare variant%> candidate %qD declared here",
+		  variant);
+	  return;
 	}
+      else if (TYPE_ARG_TYPES (variant_type) == NULL_TREE
+	       && !TYPE_NO_NAMED_ARGS_STDARG_P (variant_type)
+	       && TYPE_ARG_TYPES (base_type) != NULL_TREE)
+	/* If we've got an unprototyped variant but the base has
+	   a prototype, copy the base arg types to the variant.  */
+	TYPE_ARG_TYPES (variant_type) = TYPE_ARG_TYPES (base_type);
     }
 
   /* If we made it here, store the parsed information.  */
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 140cc9b4699..203f8094a08 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -8490,6 +8490,15 @@ omp_declare_variant_finalize_one (tree decl, tree attr)
     }
 
   tree ctx = TREE_VALUE (TREE_VALUE (attr));
+  tree chain = TREE_CHAIN (TREE_VALUE (attr));
+  location_t varid_loc
+    = cp_expr_loc_or_input_loc (TREE_PURPOSE (TREE_CHAIN (chain)));
+  location_t match_loc = cp_expr_loc_or_input_loc (TREE_PURPOSE (chain));
+  cp_id_kind idk = (cp_id_kind) tree_to_uhwi (TREE_VALUE (chain));
+  tree variant = TREE_PURPOSE (TREE_VALUE (attr));
+  location_t save_loc = input_location;
+  input_location = varid_loc;
+
   tree simd = omp_get_context_selector (ctx, OMP_TRAIT_SET_CONSTRUCT,
 					OMP_TRAIT_CONSTRUCT_SIMD);
   if (simd)
@@ -8497,20 +8506,17 @@ omp_declare_variant_finalize_one (tree decl, tree attr)
       TREE_VALUE (simd)
 	= c_omp_declare_simd_clauses_to_numbers (DECL_ARGUMENTS (decl),
 						 OMP_TS_PROPERTIES (simd));
-      /* FIXME, adjusting simd args unimplemented.  */
+      /* There is apparently an expectation that variants with "simd" in
+	 the construct selector set have vectorized arguments.  Nothing
+	 implements this on the call site side yet, nor do we correctly
+	 adjust the types when resolving the mapping the from base function
+	 to the variant.  */
+      sorry_at (varid_loc,
+		"vectorization for variant function calls not "
+		"implemented yet");
       return true;
     }
 
-  tree chain = TREE_CHAIN (TREE_VALUE (attr));
-  location_t varid_loc
-    = cp_expr_loc_or_input_loc (TREE_PURPOSE (TREE_CHAIN (chain)));
-  location_t match_loc = cp_expr_loc_or_input_loc (TREE_PURPOSE (chain));
-  cp_id_kind idk = (cp_id_kind) tree_to_uhwi (TREE_VALUE (chain));
-  tree variant = TREE_PURPOSE (TREE_VALUE (attr));
-
-  location_t save_loc = input_location;
-  input_location = varid_loc;
-
   releasing_vec args;
   tree parm = DECL_ARGUMENTS (decl);
   if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index 278e91c2c49..c1932ef8b3d 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -9737,8 +9737,14 @@ gfc_trans_omp_declare_variant (gfc_namespace *ns, gfc_namespace *parent_ns)
 	    }
 	  else if (omp_get_context_selector (set_selectors,
 					     OMP_TRAIT_SET_CONSTRUCT,
-					     OMP_TRAIT_CONSTRUCT_SIMD)
-		   == NULL_TREE)
+					     OMP_TRAIT_CONSTRUCT_SIMD))
+	    {
+	      sorry_at (gfc_get_location (&odv->where),
+			"vectorization for variant function calls not "
+			"implemented yet");
+	      variant_proc_sym = NULL;
+	    }
+	  else
 	    {
 	      char err[256];
 	      gfc_formal_arglist *last_arg = NULL, *extra_arg = NULL;
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c
index 83e1bb10058..64576241bdc 100644
--- a/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c
+++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c
@@ -51,7 +51,8 @@ void f25 (void);						/* { dg-error "expected '\\\}' before end of line" "" { ta
 #pragma omp declare variant (f1) match(construct={parallel(1)})	/* { dg-error "selector 'parallel' does not accept any properties" } */
 void f26 (void);
 #pragma omp declare variant (f0) match(construct={simd(12)})	/* { dg-error "expected \[^\n\r]* clause before" } */
-void f27 (void);						/* { dg-error "'\\)' before numeric constant" "" { target c++ } .-1 } */
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
+void f27 (void);						/* { dg-error "'\\)' before numeric constant" "" { target c++ } .-2 } */
 #pragma omp declare variant (f1) match(construct={parallel},construct={for})	/* { dg-error "selector set 'construct' specified more than once" } */
 void f28 (void);
 #pragma omp declare variant (f1) match(construct={parallel},construct={parallel})	/* { dg-error "selector set 'construct' specified more than once" } */
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-5.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-5.c
index 6ebf09457c0..2b636a3dedd 100644
--- a/gcc/testsuite/c-c++-common/gomp/declare-variant-5.c
+++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-5.c
@@ -10,10 +10,13 @@ __v8si f2 (__v8sf, __v8sf, float *);
 __v4si f3 (__v4si, int, __v4si);
 
 #pragma omp declare variant (f1) match (construct={parallel,for,simd(simdlen(4),notinbranch,uniform(z),aligned(z:4 * sizeof (*z)))})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
 #pragma omp declare variant (f2) match (construct={for,simd(uniform(z),simdlen(8),notinbranch)})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
 int f4 (float x, float y, float *z);
 
 #pragma omp declare variant (f3) match (construct={simd(simdlen(4),inbranch,linear(y:1))})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
 int f5 (int x, int y);
 
 void
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-7.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-7.c
index 4eebcbcd1d2..e836344d7ee 100644
--- a/gcc/testsuite/c-c++-common/gomp/declare-variant-7.c
+++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-7.c
@@ -10,28 +10,58 @@ __v8si f2 (__v8sf, __v8sf, float *);
 __v4si f3 (__v4si, int, __v4si);
 
 #pragma omp declare variant (f1) match (construct={parallel,for,simd(simdlen(4),notinbranch,uniform(z),aligned(z:4 * sizeof (*z)))})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
 int f4 (float x, float y, float *z);
+
 #pragma omp declare variant (f1) match (construct={parallel,for,simd(uniform(w),simdlen(8*2-12),aligned(w:4*sizeof (float)),notinbranch)})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
 int f5 (float u, float v, float *w);
-#pragma omp declare variant (f1) match (construct={parallel,for,simd(linear(w),notinbranch,simdlen(4),aligned(w:4*sizeof (float)))})	/* { dg-error "'f1' used as a variant with incompatible 'construct' selector sets" "" { target c } } */
+
+#pragma omp declare variant (f1) match (construct={parallel,for,simd(linear(w),notinbranch,simdlen(4),aligned(w:4*sizeof (float)))})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
+/* dg-error "'f1' used as a variant with incompatible 'construct' selector sets" "" { target c } */
 int f6 (float u, float v, float *w);
-#pragma omp declare variant (f1) match (construct={parallel,for,simd(uniform(w),notinbranch,simdlen(4),aligned(w:2*sizeof (float)))})	/* { dg-error "'f1' used as a variant with incompatible 'construct' selector sets" "" { target c } } */
+
+#pragma omp declare variant (f1) match (construct={parallel,for,simd(uniform(w),notinbranch,simdlen(4),aligned(w:2*sizeof (float)))})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
+/* dg-error "'f1' used as a variant with incompatible 'construct' selector sets" "" { target c } */
 int f7 (float u, float v, float *w);
-#pragma omp declare variant (f1) match (construct={parallel,for,simd(uniform(w),notinbranch,simdlen(4),aligned(w))})			/* { dg-error "'f1' used as a variant with incompatible 'construct' selector sets" "" { target c } } */
+
+#pragma omp declare variant (f1) match (construct={parallel,for,simd(uniform(w),notinbranch,simdlen(4),aligned(w))})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
+/* dg-error "'f1' used as a variant with incompatible 'construct' selector sets" "" { target c } */
 int f8 (float u, float v, float *w);
+
 #pragma omp declare variant (f2) match (construct={for,simd(uniform(z),simdlen(8),notinbranch)})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
 int f9 (float x, float y, float *z);
+
 #pragma omp declare variant (f2) match (construct={for,simd(notinbranch,simdlen(2+2+4),uniform (q))})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
 int f10 (float x, float y, float *q);
-#pragma omp declare variant (f2) match (construct={for,simd(linear(z:2),simdlen(8),notinbranch)})	/* { dg-error "'f2' used as a variant with incompatible 'construct' selector sets" "" { target c } } */
+
+#pragma omp declare variant (f2) match (construct={for,simd(linear(z:2),simdlen(8),notinbranch)})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
+/* dg-error "'f2' used as a variant with incompatible 'construct' selector sets" "" { target c } */
 int f11 (float x, float y, float *z);
+
 #pragma omp declare variant (f3) match (construct={simd(simdlen(4),inbranch,linear(y:1))})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
 int f12 (int x, int y);
+
 #pragma omp declare variant (f3) match (construct={simd(inbranch, simdlen (5-1), linear (q:4-3))})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
 int f13 (int x, int q);
-#pragma omp declare variant (f3) match (construct={simd(inbranch,simdlen(4),linear(q:2))})		/* { dg-error "'f3' used as a variant with incompatible 'construct' selector sets" "" { target c } } */
+
+#pragma omp declare variant (f3) match (construct={simd(inbranch,simdlen(4),linear(q:2))})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
+/* dg-error "'f3' used as a variant with incompatible 'construct' selector sets" "" { target c } */
 int f14 (int x, int q);
+
 #pragma omp declare variant (f3) match (construct={simd(inbranch simdlen (4) linear (q:1))})		/* { dg-error "clauses in 'simd' trait should be separated by ','" } */
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
 int f15 (int x, int q);
+
 #pragma omp declare variant (f3) match (construct={simd(inbranch, simdlen (5-1) linear (q:4-3))})	/* { dg-error "clauses in 'simd' trait should be separated by ','" } */
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
 int f16 (int x, int q);
diff --git a/gcc/testsuite/gcc.dg/gomp/pr95315-2.c b/gcc/testsuite/gcc.dg/gomp/pr95315-2.c
index 3a5018a1eee..f706b020833 100644
--- a/gcc/testsuite/gcc.dg/gomp/pr95315-2.c
+++ b/gcc/testsuite/gcc.dg/gomp/pr95315-2.c
@@ -11,10 +11,13 @@ __v8si f2 (__v8sf, __v8sf, float *);
 __v4si f3 (__v4si, int, __v4si);
 
 #pragma omp declare variant (f1) match (construct={parallel,for,simd(simdlen(4),notinbranch,uniform(z),aligned(z:4 * sizeof (*z)))})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
 #pragma omp declare variant (f2) match (construct={for,simd(uniform(z),simdlen(8),notinbranch)})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
 int f4 (float x, float y, float *z);
 
 #pragma omp declare variant (f3) match (construct={simd(simdlen(4),inbranch,linear(y:1))})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
 int f5 (int x, int y);
 
 static inline __attribute__((always_inline)) int
diff --git a/gcc/testsuite/gcc.dg/gomp/pr95315.c b/gcc/testsuite/gcc.dg/gomp/pr95315.c
index 4981e0b8949..28c28753fe2 100644
--- a/gcc/testsuite/gcc.dg/gomp/pr95315.c
+++ b/gcc/testsuite/gcc.dg/gomp/pr95315.c
@@ -2,4 +2,39 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -fopenmp --param ggc-min-heapsize=0" } */
 
-#include "../../c-c++-common/gomp/declare-variant-5.c"
+typedef float __v4sf __attribute__((vector_size (16)));
+typedef int __v4si __attribute__((vector_size (16)));
+typedef float __v8sf __attribute__((vector_size (32)));
+typedef int __v8si __attribute__((vector_size (32)));
+__v4si f1 (__v4sf, __v4sf, float *);
+__v8si f2 (__v8sf, __v8sf, float *);
+__v4si f3 (__v4si, int, __v4si);
+
+#pragma omp declare variant (f1) match (construct={parallel,for,simd(simdlen(4),notinbranch,uniform(z),aligned(z:4 * sizeof (*z)))})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
+#pragma omp declare variant (f2) match (construct={for,simd(uniform(z),simdlen(8),notinbranch)})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
+int f4 (float x, float y, float *z);
+
+#pragma omp declare variant (f3) match (construct={simd(simdlen(4),inbranch,linear(y:1))})
+/* { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 } */
+int f5 (int x, int y);
+
+void
+test (int *x, float *y, float *z, float *w)
+{
+  #pragma omp parallel
+  #pragma omp for simd aligned (w:4 * sizeof (float))
+  for (int i = 0; i < 1024; i++)
+    x[i] = f4 (y[i], z[i], w);
+  #pragma omp parallel for simd aligned (w:4 * sizeof (float)) simdlen(4)
+  for (int i = 1024; i < 2048; i++)
+    x[i] = f4 (y[i], z[i], w);
+  #pragma omp simd aligned (w:4 * sizeof (float))
+  for (int i = 2048; i < 4096; i++)
+    x[i] = f4 (y[i], z[i], w);
+  #pragma omp simd
+  for (int i = 4096; i < 8192; i++)
+    if (x[i] > 10)
+      x[i] = f5 (x[i], i);
+}
diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-5.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-variant-5.f90
index ad7acb9842d..e67d412cfde 100644
--- a/gcc/testsuite/gfortran.dg/gomp/declare-variant-5.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/declare-variant-5.f90
@@ -32,12 +32,15 @@ contains
     real, intent(in) :: x, y
     real, intent(out) :: z
     !$omp declare variant (f1) match (construct={parallel,do,simd(simdlen(4),notinbranch,uniform(z),aligned(z:16))})
+! { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 }
     !$omp declare variant (f2) match (construct={do,simd(uniform(z),simdlen(8),notinbranch)})
+! { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 }
   end function
 
   integer function f5 (x, y)
     integer, intent(in) :: x, y
     !$omp declare variant (f3) match (construct={simd(simdlen(4),inbranch,linear(y:1))})
+! { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 }
   end function
 
   subroutine test (x, y, z, w)
diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-7.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-variant-7.f90
index 1590a2a26f0..7f35e23e3e8 100644
--- a/gcc/testsuite/gfortran.dg/gomp/declare-variant-7.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/declare-variant-7.f90
@@ -31,63 +31,74 @@ contains
   integer function f4 (x, y, z)
     real, intent(in) :: x, y
     real, pointer, intent(out) :: z
-    !$omp declare variant (f1) match (construct={parallel,do,simd(simdlen(4),notinbranch,uniform(z),aligned(z:16))})	! { dg-error "'f1' used as a variant with incompatible 'construct' selector sets" }
+    !$omp declare variant (f1) match (construct={parallel,do,simd(simdlen(4),notinbranch,uniform(z),aligned(z:16))})	! { dg-error "'f1' used as a variant with incompatible 'construct' selector sets" "" { xfail *-*-*} }
+! { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 }
   end function
 
   integer function f5 (u, v, w)
     real, intent(in) :: u, v
     real, pointer, intent(out) :: w
-    !$omp declare variant (f1) match (construct={parallel,do,simd(uniform(w),simdlen(8*2-12),aligned(w:16),notinbranch)})	! { dg-error "'f1' used as a variant with incompatible 'construct' selector sets" }
+    !$omp declare variant (f1) match (construct={parallel,do,simd(uniform(w),simdlen(8*2-12),aligned(w:16),notinbranch)})	! { dg-error "'f1' used as a variant with incompatible 'construct' selector sets" "" { xfail *-*-*} }
+! { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 }
   end function
 
   integer function f6 (u, v, w)
     real, intent(in) :: u, v
     real, pointer, intent(out) :: w
-    !$omp declare variant (f1) match (construct={parallel,do,simd(linear(w),notinbranch,simdlen(4),aligned(w:16))})	! { dg-error "'f1' used as a variant with incompatible 'construct' selector sets" }
+    !$omp declare variant (f1) match (construct={parallel,do,simd(linear(w),notinbranch,simdlen(4),aligned(w:16))})	! { dg-error "'f1' used as a variant with incompatible 'construct' selector sets" "" { xfail *-*-*} }
+! { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 }
   end function
 
   integer function f7 (u, v, w)
     real, intent(in) :: u, v
     real, pointer, intent(out) :: w
-    !$omp declare variant (f1) match (construct={parallel,do,simd(uniform(w),notinbranch,simdlen(4),aligned(w:8))})	! { dg-error "'f1' used as a variant with incompatible 'construct' selector sets" }
+    !$omp declare variant (f1) match (construct={parallel,do,simd(uniform(w),notinbranch,simdlen(4),aligned(w:8))})	! { dg-error "'f1' used as a variant with incompatible 'construct' selector sets" "" { xfail *-*-*} }
+! { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 }
   end function
 
   integer function f8 (u, v, w)
     real, intent(in) :: u, v
     real, pointer, intent(out) :: w
     !$omp declare variant (f1) match (construct={parallel,do,simd(uniform(w),notinbranch,simdlen(4),aligned(w))})
+! { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 }
   end function
 
   integer function f9 (x, y, z)
     real, intent(in) :: x, y
     real, pointer, intent(out) :: z
-    !$omp declare variant (f2) match (construct={do,simd(uniform(z),simdlen(8),notinbranch)})	! { dg-error "'f2' used as a variant with incompatible 'construct' selector sets" }
+    !$omp declare variant (f2) match (construct={do,simd(uniform(z),simdlen(8),notinbranch)})	! { dg-error "'f2' used as a variant with incompatible 'construct' selector sets" "" { xfail *-*-*} }
+! { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 }
   end function
 
   integer function f10 (x, y, q)
     real, intent(in) :: x, y
     real, pointer, intent(out) :: q
-    !$omp declare variant (f2) match (construct={do,simd(notinbranch,simdlen(2+2+4),uniform (q))})	! { dg-error "'f2' used as a variant with incompatible 'construct' selector sets" }
+    !$omp declare variant (f2) match (construct={do,simd(notinbranch,simdlen(2+2+4),uniform (q))})	! { dg-error "'f2' used as a variant with incompatible 'construct' selector sets" "" { xfail *-*-*} }
+! { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 }
   end function
 
   integer function f11 (x, y, z)
     real, intent(in) :: x, y
     real, pointer, intent(out) :: z
     !$omp declare variant (f2) match (construct={do,simd(linear(z:2),simdlen(8),notinbranch)})
+! { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 }
   end function
 
   integer function f12 (x, y)
     integer, intent(in) :: x, y
-    !$omp declare variant (f3) match (construct={simd(simdlen(4),inbranch,linear(y:1))})	! { dg-error "'f3' used as a variant with incompatible 'construct' selector sets" }
+    !$omp declare variant (f3) match (construct={simd(simdlen(4),inbranch,linear(y:1))})	! { dg-error "'f3' used as a variant with incompatible 'construct' selector sets" "" { xfail *-*-*} }
+! { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 }
   end function
 
   integer function f13 (x, q)
     integer, intent(in) :: x, q
-    !$omp declare variant (f3) match (construct={simd(inbranch, simdlen (5-1), linear (q:4-3))})	! { dg-error "'f3' used as a variant with incompatible 'construct' selector sets" }
+    !$omp declare variant (f3) match (construct={simd(inbranch, simdlen (5-1), linear (q:4-3))})	! { dg-error "'f3' used as a variant with incompatible 'construct' selector sets" "" { xfail *-*-*} }
+! { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 }
   end function
 
   integer function f14 (x, q)
     integer, intent(in) :: x, q
     !$omp declare variant (f3) match (construct={simd(inbranch,simdlen(4),linear(q:2))})
+! { dg-message "vectorization for variant function calls not implemented yet" "" { target *-*-* } .-1 }
   end function
 end module
-- 
2.39.5

Reply via email to