Sandra Loosemore wrote:
gcc/testsuite/ChangeLog
        * c-c++-common/gomp/delim-declare-variant-1.c: New.
        * c-c++-common/gomp/delim-declare-variant-2.c: New.
        * c-c++-common/gomp/delim-declare-variant-3.c: New.
        * c-c++-common/gomp/delim-declare-variant-4.c: New.
        * c-c++-common/gomp/delim-declare-variant-5.c: New.
        * c-c++-common/gomp/delim-declare-variant-6.c: New.
        * c-c++-common/gomp/delim-declare-variant-7.c: New.
        * c-c++-common/gomp/delim-declare-variant-8.c: New.
        * c-c++-common/gomp/delim-declare-variant-9.c: New.

libgomp/ChangeLog
        * testsuite/libgomp.c-c++-common/delim-declare-variant-1.c: New.
        * testsuite/libgomp.c-c++-common/delim-declare-variant-2.c: New.

LGTM. [Side remark: C++ testcases are part of the C++ patch, 3/6]


diff --git a/gcc/testsuite/c-c++-common/gomp/delim-declare-variant-3.c 
b/gcc/testsuite/c-c++-common/gomp/delim-declare-variant-3.c
new file mode 100644
index 00000000000..6b9d819c765
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/delim-declare-variant-3.c
@@ -0,0 +1,49 @@
+/* { dg-do compile } */
+
+/* Check that an error is diagnosed when a function defined in a
+   "begin declare variant" construct doesn't have a visible declaration
+   at that point.
+
+   The spec is not completely clear on this; it says the base function must be
+   "declared elsewhere without an associated declare variant directive",
+   without defining what "elsewhere" means.  Particularly in C++ it would be
+   incorrect to inject such a declaration at the point of the variant
+   definition (think of a variant for a class method that is defined with a
+   qualified name outside of the class declaration, for instance).  The C++
+   front end could differentiate between cases where base declaration injection
+   is allowed vs not, but for now it seems simplest just to require that a
+   definition always be visible.  */
...
+int bar (int x)  /* { dg-error "no declaration of base function" } */
+{
+  return x * 2;
+}

There is a related OpenMP specification issue:
Issue 4464, "error out when an implicit base variant is
             still selected at end of processing"

It seems as if one line of thought is that is is valid to have no
base function (but the implicit) if it wouldn't be used. In any case,
for now, let's use what we currently have – we can still think about
extending/modifying this later.

+++ b/gcc/testsuite/c-c++-common/gomp/delim-declare-variant-6.c
@@ -0,0 +1,71 @@
+/* { dg-do compile { target x86_64-*-* } } */
+/* { dg-additional-options "-fdump-tree-gimple -foffload=disable" } */
+
+/* Test merging of context selectors for nested "begin declare variant"
+   directives.
+
+   The spec (TR12) says: "the effective context selectors of the outer

For what it is worth, that's the same wording as in OpenMP 6
(6.0, Sect. 9.6.5, [335:26-30, 336:1])

Tobias

Reply via email to