variant);
variant = error_mark_node;
}
+ else if (variant == fndecl)
+ {
+ error_at (token->location, "variant %qD is the same as base function",
+ variant);
+ variant = error_mark_node;
+ }
c_parser_consume_token (parser);
variant = cp_get_callee_fndecl_nofold (STRIP_REFERENCE_REF (variant));
input_location = save_loc;
+ if (variant == decl)
+ {
+ error_at (varid_loc, "variant %qD is the same as base function",
+ variant);
+ return true;
+ }
+
if (variant)
{
bool fail;
variant_proc_name, &odv->where);
variant_proc_sym = NULL;
}
+ else if (variant_proc_sym == ns->proc_name)
+ {
+ gfc_error ("variant %qs at %L is the same as base function",
+ variant_proc_name, &odv->where);
+ variant_proc_sym = NULL;
+ }
else if (omp_get_context_selector (set_selectors,
OMP_TRAIT_SET_CONSTRUCT,
OMP_TRAIT_CONSTRUCT_SIMD)
--- /dev/null
+/* PR118839: Check that error is diagnosed when the variant is the same as
+ the base function. */
+
+/* No previous declaration. */
+#pragma omp declare variant(f) match(user={condition(1)}) /* { dg-error "variant 'f' is the same as base function" } */
+void f(int *x);
+
+/* Previous declaration. */
+void g(int *x)
+{
+ *x = 42;
+}
+
+#pragma omp declare variant(g) match(user={condition(1)}) /* { dg-error "variant 'g' is the same as base function" } */
+void g(int *x);
+
+
+
--- /dev/null
+! PR118839: Check that error is diagnosed when the variant is the same
+! as the base function.
+
+subroutine f()
+ !$omp declare variant(f) match(user={condition(.true.)}) ! { dg-error "variant 'f' at .1. is the same as base function" }
+end subroutine