Follow up to
r16-5508-g77b8221af8fc82; seemingly, a testcase never got
added - and the internal representation changed afther the code was
written. At least the previous code ICE'd for the included testcase.
PR c/125377
gcc/ChangeLog:
* omp-general.cc (omp_check_for_duplicate_variant): Fix used
tree for 'inform' part of the error message.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/begin-declare-variant-1.c: New test.
error_at (loc,
"multiple definitions of variants with the same "
"context selector violate the one-definition rule");
- inform (DECL_SOURCE_LOCATION (TREE_PURPOSE (attr)),
+ inform (DECL_SOURCE_LOCATION (TREE_PURPOSE (TREE_VALUE (attr))),
"previous variant declaration here");
return false;
}
--- /dev/null
+/* PR c/125377 */
+
+static int omp_is_initial_device(void);
+// { dg-warning "'omp_is_initial_device' used but never defined" "" { target c } .-1 }
+#pragma omp begin declare variant match(device={kind(host)})
+ static inline int omp_is_initial_device(void) { return 1; } // { dg-note "previous variant declaration here" }
+#pragma omp end declare variant
+
+#pragma omp begin declare variant match(device={kind(host)})
+ static inline int omp_is_initial_device(void) { return 1; } // { dg-error "multiple definitions of variants with the same context selector violate the one-definition rule" }
+#pragma omp end declare variant
+
+int main()
+{
+ __builtin_printf("%d\n", omp_is_initial_device());
+}