aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/c-c++-common')
-rw-r--r--gcc/testsuite/c-c++-common/analyzer/fd-glibc-byte-stream-socket.c2
-rw-r--r--gcc/testsuite/c-c++-common/analyzer/out-of-bounds-diagram-1-json.c13
-rw-r--r--gcc/testsuite/c-c++-common/analyzer/strtok-cppreference.c2
-rw-r--r--gcc/testsuite/c-c++-common/asan/pr120608-1.c43
-rw-r--r--gcc/testsuite/c-c++-common/asan/pr120608-2.c39
-rw-r--r--gcc/testsuite/c-c++-common/asan/pr120608-3.c36
-rw-r--r--gcc/testsuite/c-c++-common/asan/pr120608-4.c30
-rw-r--r--gcc/testsuite/c-c++-common/diagnostic-format-json-1.c22
-rw-r--r--gcc/testsuite/c-c++-common/diagnostic-format-json-2.c26
-rw-r--r--gcc/testsuite/c-c++-common/diagnostic-format-json-3.c26
-rw-r--r--gcc/testsuite/c-c++-common/diagnostic-format-json-4.c44
-rw-r--r--gcc/testsuite/c-c++-common/diagnostic-format-json-5.c38
-rw-r--r--gcc/testsuite/c-c++-common/diagnostic-format-json-file-1.c8
-rw-r--r--gcc/testsuite/c-c++-common/diagnostic-format-json-stderr-1.c24
-rw-r--r--gcc/testsuite/c-c++-common/goacc/acc-wait-1.c51
-rw-r--r--gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c7
-rw-r--r--gcc/testsuite/c-c++-common/gomp/declare-mapper-10.c30
-rw-r--r--gcc/testsuite/c-c++-common/gomp/declare-mapper-11.c70
-rw-r--r--gcc/testsuite/c-c++-common/gomp/declare-mapper-12.c22
-rw-r--r--gcc/testsuite/c-c++-common/gomp/declare-mapper-3.c30
-rw-r--r--gcc/testsuite/c-c++-common/gomp/declare-mapper-4.c78
-rw-r--r--gcc/testsuite/c-c++-common/gomp/declare-mapper-5.c26
-rw-r--r--gcc/testsuite/c-c++-common/gomp/declare-mapper-6.c23
-rw-r--r--gcc/testsuite/c-c++-common/gomp/declare-mapper-7.c29
-rw-r--r--gcc/testsuite/c-c++-common/gomp/declare-mapper-8.c43
-rw-r--r--gcc/testsuite/c-c++-common/gomp/declare-mapper-9.c34
-rw-r--r--gcc/testsuite/c-c++-common/gomp/declare-variant-2.c15
-rw-r--r--gcc/testsuite/c-c++-common/gomp/map-6.c20
-rw-r--r--gcc/testsuite/c-c++-common/gomp/metadirective-3.c7
-rw-r--r--gcc/testsuite/c-c++-common/gomp/metadirective-condition-constexpr.c13
-rw-r--r--gcc/testsuite/c-c++-common/gomp/metadirective-condition.c25
-rw-r--r--gcc/testsuite/c-c++-common/gomp/metadirective-error-recovery.c25
-rw-r--r--gcc/testsuite/c-c++-common/gomp/omp_get_num_devices_initial_device-2.c29
-rw-r--r--gcc/testsuite/c-c++-common/gomp/omp_get_num_devices_initial_device.c32
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr120180.c22
-rw-r--r--gcc/testsuite/c-c++-common/pr106133.c3
-rw-r--r--gcc/testsuite/c-c++-common/pr118868-1.c9
-rw-r--r--gcc/testsuite/c-c++-common/pragma-optimize-1.c10
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/nonnull-8.c32
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/nonnull-9.c41
40 files changed, 850 insertions, 229 deletions
diff --git a/gcc/testsuite/c-c++-common/analyzer/fd-glibc-byte-stream-socket.c b/gcc/testsuite/c-c++-common/analyzer/fd-glibc-byte-stream-socket.c
index fd57d3b..2a44e45 100644
--- a/gcc/testsuite/c-c++-common/analyzer/fd-glibc-byte-stream-socket.c
+++ b/gcc/testsuite/c-c++-common/analyzer/fd-glibc-byte-stream-socket.c
@@ -5,6 +5,8 @@
/* { dg-additional-options "-fno-exceptions" } */
/* { dg-skip-if "" { hppa*-*-hpux* powerpc*-*-aix* } } */
+/* On vxworks, netinet/in.h indirectly includes atomic, that requires C++11. */
+/* { dg-skip-if "" { *-*-vxworks* && { c++ && { ! c++11 } } } } */
#include <stdio.h>
#include <string.h>
diff --git a/gcc/testsuite/c-c++-common/analyzer/out-of-bounds-diagram-1-json.c b/gcc/testsuite/c-c++-common/analyzer/out-of-bounds-diagram-1-json.c
deleted file mode 100644
index 0a2cc34..0000000
--- a/gcc/testsuite/c-c++-common/analyzer/out-of-bounds-diagram-1-json.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/* { dg-additional-options "-fdiagnostics-format=json-file" } */
-
-/* The custom JSON format doesn't support text art, so this is just a simple
- smoketext. */
-
-#include <stdint.h>
-
-int32_t arr[10];
-
-void int_arr_write_element_after_end_off_by_one(int32_t x)
-{
- arr[10] = x;
-}
diff --git a/gcc/testsuite/c-c++-common/analyzer/strtok-cppreference.c b/gcc/testsuite/c-c++-common/analyzer/strtok-cppreference.c
index a396c64..9611727 100644
--- a/gcc/testsuite/c-c++-common/analyzer/strtok-cppreference.c
+++ b/gcc/testsuite/c-c++-common/analyzer/strtok-cppreference.c
@@ -13,7 +13,7 @@
/* { dg-additional-options " -Wno-analyzer-too-complex -Wno-analyzer-symbol-too-complex" } */
-#define __STDC_WANT_LIB_EXT1__ 0
+#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>
#include <stdio.h>
diff --git a/gcc/testsuite/c-c++-common/asan/pr120608-1.c b/gcc/testsuite/c-c++-common/asan/pr120608-1.c
new file mode 100644
index 0000000..114c42d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/pr120608-1.c
@@ -0,0 +1,43 @@
+/* PR middle-end/120608 */
+/* { dg-do run { target musttail } } */
+/* { dg-options "-O2 -fsanitize=address" } */
+
+__attribute__((noipa)) void
+foo (int *x, int *y, int *z)
+{
+ ++x[0];
+ ++y[0];
+ ++z[0];
+}
+
+__attribute__((noipa)) void
+bar (int *x, int *y, int *z)
+{
+ if (x || y || z)
+ __builtin_abort ();
+}
+
+__attribute__((noipa)) void
+baz (int *x, int *y, int *z)
+{
+ (void) x; (void) y; (void) z;
+ int a = 42, b = -42, c = 0;
+ foo (&a, &b, &c);
+ [[gnu::musttail]] return bar (0, 0, 0);
+}
+
+__attribute__((noipa)) void
+qux (int *x, int *y, int *z)
+{
+ (void) x; (void) y; (void) z;
+ int a = 42, b = -42, c = 0;
+ foo (&a, &b, &c);
+ [[gnu::musttail]] return bar (0, 0, 0);
+}
+
+int
+main ()
+{
+ baz (0, 0, 0);
+ qux (0, 0, 0);
+}
diff --git a/gcc/testsuite/c-c++-common/asan/pr120608-2.c b/gcc/testsuite/c-c++-common/asan/pr120608-2.c
new file mode 100644
index 0000000..251ff3a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/pr120608-2.c
@@ -0,0 +1,39 @@
+/* PR middle-end/120608 */
+/* { dg-do run { target musttail } } */
+/* { dg-options "-O2 -fsanitize=address" } */
+/* { dg-set-target-env-var ASAN_OPTIONS "detect_stack_use_after_return=1" } */
+/* { dg-shouldfail "asan" } */
+
+__attribute__((noipa)) void
+foo (int *x, int *y, int *z)
+{
+ ++x[0];
+ ++y[0];
+ ++z[0];
+}
+
+__attribute__((noipa)) void
+bar (int *x, int *y, int *z)
+{
+ volatile int a = x[0] + y[0] + z[0];
+}
+
+__attribute__((noipa)) void
+baz (int *x, int *y, int *z)
+{
+ (void) x; (void) y; (void) z;
+ int a = 42, b = -42, c = 0;
+ foo (&a, &b, &c);
+ [[gnu::musttail]] return bar (&a, &b, &c); /* { dg-warning "address of automatic variable 'a' passed to 'musttail' call argument" } */
+} /* { dg-warning "address of automatic variable 'b' passed to 'musttail' call argument" "" { target *-*-* } .-1 } */
+ /* { dg-warning "address of automatic variable 'c' passed to 'musttail' call argument" "" { target *-*-* } .-2 } */
+
+int
+main ()
+{
+ baz (0, 0, 0);
+}
+
+// { dg-output "ERROR: AddressSanitizer: stack-use-after-return on address.*(\n|\r\n|\r)" }
+// { dg-output "READ of size .*" }
+// { dg-output ".*'a' \\(line 25\\) <== Memory access at offset \[0-9\]* is inside this variable.*" }
diff --git a/gcc/testsuite/c-c++-common/asan/pr120608-3.c b/gcc/testsuite/c-c++-common/asan/pr120608-3.c
new file mode 100644
index 0000000..8ea4468
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/pr120608-3.c
@@ -0,0 +1,36 @@
+/* PR middle-end/120608 */
+/* { dg-do compile { target musttail } } */
+/* { dg-options "-fsanitize=address -fno-exceptions" } */
+
+[[gnu::noipa]] int
+foo (int x)
+{
+ return x;
+}
+
+[[gnu::noipa]] void
+bar (int *x, int *y, int *z)
+{
+ (void) x;
+ (void) y;
+ (void) z;
+}
+
+[[gnu::noipa]] int
+baz (int x)
+{
+ int a = 4;
+ {
+ int b = 8;
+ {
+ int c = 10;
+ bar (&a, &b, &c);
+ if (a + b + c == 22)
+ [[gnu::musttail]] return foo (x);
+ bar (&a, &b, &c);
+ }
+ bar (&a, &b, &a);
+ }
+ bar (&a, &a, &a);
+ return 42;
+}
diff --git a/gcc/testsuite/c-c++-common/asan/pr120608-4.c b/gcc/testsuite/c-c++-common/asan/pr120608-4.c
new file mode 100644
index 0000000..86891454
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/pr120608-4.c
@@ -0,0 +1,30 @@
+/* PR middle-end/120608 */
+/* { dg-do compile { target musttail } } */
+/* { dg-options "-fsanitize=address -fno-exceptions" } */
+
+[[gnu::noipa]] void
+bar (int *x, int *y, int *z)
+{
+ (void) x;
+ (void) y;
+ (void) z;
+}
+
+[[gnu::noipa]] int
+baz (int x)
+{
+ int a = 4;
+ {
+ int b = 8;
+ {
+ int c = 10;
+ bar (&a, &b, &c);
+ if (a + b + c + x == 22)
+ [[gnu::musttail]] return baz (x - 1);
+ bar (&a, &b, &c);
+ }
+ bar (&a, &b, &a);
+ }
+ bar (&a, &a, &a);
+ return 42;
+}
diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c
deleted file mode 100644
index c95218c..0000000
--- a/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-format=json" } */
-
-#error message
-
-/* { dg-begin-multiline-output "" }
-[{"kind": "error",
- "message": "#error message",
- "children": [],
- "column-origin": 1,
- "locations": [{"caret": {"file":
- "line": 4,
- "display-column": 2,
- "byte-column": 2,
- "column": 2},
- "finish": {"file":
- "line": 4,
- "display-column": 6,
- "byte-column": 6,
- "column": 6}}],
- "escape-source": false}]
- { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c
deleted file mode 100644
index a8828b7..0000000
--- a/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-format=json" } */
-
-#warning message
-
-/* { dg-begin-multiline-output "" }
-[{"kind": "warning",
- "message": "#warning message",
- "option": "-Wcpp",
- { dg-end-multiline-output "" } */
-/* { dg-regexp " \"option_url\": \"https:\[^\n\r\"\]*#index-Wcpp\",\n" } */
-/* { dg-begin-multiline-output "" }
- "children": [],
- "column-origin": 1,
- "locations": [{"caret": {"file":
- "line": 4,
- "display-column": 2,
- "byte-column": 2,
- "column": 2},
- "finish": {"file":
- "line": 4,
- "display-column": 8,
- "byte-column": 8,
- "column": 8}}],
- "escape-source": false}]
- { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c
deleted file mode 100644
index 178bbf9..0000000
--- a/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-format=json -Werror" } */
-
-#warning message
-
-/* { dg-begin-multiline-output "" }
-[{"kind": "error",
- "message": "#warning message",
- "option": "-Werror=cpp",
- { dg-end-multiline-output "" } */
-/* { dg-regexp " \"option_url\": \"https:\[^\n\r\"\]*#index-Wcpp\",\n" } */
-/* { dg-begin-multiline-output "" }
- "children": [],
- "column-origin": 1,
- "locations": [{"caret": {"file":
- "line": 4,
- "display-column": 2,
- "byte-column": 2,
- "column": 2},
- "finish": {"file":
- "line": 4,
- "display-column": 8,
- "byte-column": 8,
- "column": 8}}],
- "escape-source": false}]
- { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c
deleted file mode 100644
index 899a03f..0000000
--- a/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-format=json -Wmisleading-indentation" } */
-
-int test (void)
-{
- if (1)
- return 3;
- return 4;
- return 5;
-}
-
-/* { dg-begin-multiline-output "" }
-[{"kind": "warning",
- "message": "this 'if' clause does not guard...",
- "option": "-Wmisleading-indentation",
- { dg-end-multiline-output "" } */
-/* { dg-regexp " \"option_url\": \"https:\[^\n\r\"\]*#index-Wmisleading-indentation\",\n" } */
-/* { dg-begin-multiline-output "" }
- "children": [{"kind": "note",
- "message": "...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'",
- "locations": [{"caret": {"file":
- "line": 8,
- "display-column": 5,
- "byte-column": 5,
- "column": 5},
- "finish": {"file":
- "line": 8,
- "display-column": 10,
- "byte-column": 10,
- "column": 10}}],
- "escape-source": false}],
- "column-origin": 1,
- "locations": [{"caret": {"file":
- "line": 6,
- "display-column": 3,
- "byte-column": 3,
- "column": 3},
- "finish": {"file":
- "line": 6,
- "display-column": 4,
- "byte-column": 4,
- "column": 4}}],
- "escape-source": false}]
- { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c
deleted file mode 100644
index ed3139c..0000000
--- a/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-format=json" } */
-
-struct s { int color; };
-
-int test (struct s *ptr)
-{
- return ptr->colour;
-}
-
-/* { dg-begin-multiline-output "" }
-[{"kind": "error",
- "message": "'struct s' has no member named 'colour'; did you mean 'color'?",
- "children": [],
- "column-origin": 1,
- "locations": [{"caret": {"file":
- "line": 8,
- "display-column": 15,
- "byte-column": 15,
- "column": 15},
- "finish": {"file":
- "line": 8,
- "display-column": 20,
- "byte-column": 20,
- "column": 20}}],
- "fixits": [{"start": {"file":
- "line": 8,
- "display-column": 15,
- "byte-column": 15,
- "column": 15},
- "next": {"file":
- "line": 8,
- "display-column": 21,
- "byte-column": 21,
- "column": 21},
- "string": "color"}],
- "escape-source": false}]
- { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-file-1.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-file-1.c
deleted file mode 100644
index ddac780..0000000
--- a/gcc/testsuite/c-c++-common/diagnostic-format-json-file-1.c
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Check that -fdiagnostics-format=json-file works. */
-/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-format=json-file" } */
-
-#warning message
-
-/* Verify that some JSON was written to a file with the expected name. */
-/* { dg-final { scan-file "diagnostic-format-json-file-1.c.gcc.json" "\"message\": \"#warning message\"" } } */
diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-stderr-1.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-stderr-1.c
deleted file mode 100644
index e798c6b..0000000
--- a/gcc/testsuite/c-c++-common/diagnostic-format-json-stderr-1.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Check that "json" and "json-stderr" are synonymous when used as
- arguments to "-fdiagnostics-format=". */
-/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-format=json-stderr" } */
-
-#error message
-
-/* { dg-begin-multiline-output "" }
-[{"kind": "error",
- "message": "#error message",
- "children": [],
- "column-origin": 1,
- "locations": [{"caret": {"file":
- "line": 6,
- "display-column": 2,
- "byte-column": 2,
- "column": 2},
- "finish": {"file":
- "line": 6,
- "display-column": 6,
- "byte-column": 6,
- "column": 6}}],
- "escape-source": false}]
- { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/goacc/acc-wait-1.c b/gcc/testsuite/c-c++-common/goacc/acc-wait-1.c
new file mode 100644
index 0000000..bc7ff02
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/acc-wait-1.c
@@ -0,0 +1,51 @@
+// { dg-do compile }
+// { dg-additional-options "-fdump-tree-original" }
+
+void f0 (int x)
+{
+ #pragma acc wait(x) if(false) async
+}
+// { dg-final { scan-tree-dump-times "if \\(0\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(-1, 1, x\\);" 1 "original" { target c } } }
+// { dg-final { scan-tree-dump-not "__builtin_GOACC_wait \\(-1, 1, x\\);" "original" { target c++ } } }
+
+
+void f1 (int y, int ia)
+{
+ #pragma acc wait(y) if(true) async(ia)
+}
+// { dg-final { scan-tree-dump-times "if \\(1\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(ia, 1, y\\);" 1 "original" { target c } } }
+// { dg-final { scan-tree-dump-times "__builtin_GOACC_wait \\(ia, 1, y\\)" 1 "original" { target c++ } } }
+// { dg-final { scan-tree-dump-not "if \\(\[^\\n\\r\]+\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(ia, 1, y\\);" "original" { target c++ } } }
+
+
+void fl (int z, bool ll)
+{
+ #pragma acc wait(z) if(ll) async(3)
+}
+// { dg-final { scan-tree-dump-times "if \\(ll != 0\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(3, 1, z\\);" 1 "original" { target c } } }
+// { dg-final { scan-tree-dump-times "if \\(ll\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(3, 1, z\\);" 1 "original" { target c++ } } }
+
+
+void a0 (int a)
+{
+ #pragma acc wait(a) if(false)
+}
+// { dg-final { scan-tree-dump-times "if \\(0\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(-2, 1, a\\);" 1 "original" { target c } } }
+// { dg-final { scan-tree-dump-not "__builtin_GOACC_wait \\(-2, 1, a\\);" "original" { target c++ } } }
+
+
+void a1 (int b)
+{
+ #pragma acc wait(b) if(true)
+}
+// { dg-final { scan-tree-dump-times "if \\(1\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(-2, 1, b\\);" 1 "original" { target c } } }
+// { dg-final { scan-tree-dump-times "__builtin_GOACC_wait \\(-2, 1, b\\)" 1 "original" { target c++ } } }
+// { dg-final { scan-tree-dump-not "if \\(\[^\\n\\r\]+\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(-2, 1, b\\);" "original" { target c++ } } }
+
+
+void al (int c, bool qq)
+{
+ #pragma acc wait(c) if(qq)
+}
+// { dg-final { scan-tree-dump-times "if \\(qq != 0\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(-2, 1, c\\);" 1 "original" { target c } } }
+// { dg-final { scan-tree-dump-times "if \\(qq\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(-2, 1, c\\);" 1 "original" { target c++ } } }
diff --git a/gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c b/gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c
index 31dd054..803bf0a 100644
--- a/gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c
+++ b/gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c
@@ -9,7 +9,7 @@ f (int x[], int y[], int z[])
{
int i;
- [[omp::sequence (directive (target map(to: x, y) map(from: z)),
+ [[omp::sequence (directive (target map(to: x, y) map(from: z)), /* { dg-bogus "'target' construct with nested 'teams' construct contains directives outside of the 'teams' construct" "PR118694" { xfail offload_nvptx } } */
directive (metadirective
when (device={arch("nvptx")}: teams loop)
default (parallel loop)))]]
@@ -20,5 +20,6 @@ f (int x[], int y[], int z[])
/* If offload device "nvptx" isn't supported, the front end can eliminate
that alternative and not produce a metadirective at all. Otherwise this
won't be resolved until late. */
-/* { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" { target { ! offload_nvptx } } } } */
-/* { dg-final { scan-tree-dump "#pragma omp metadirective" "gimple" { target { offload_nvptx } } } } */
+/* { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" } } */
+/* { dg-final { scan-tree-dump-not " teams" "gimple" { target { ! offload_nvptx } } } } */
+/* { dg-final { scan-tree-dump "variant.\[0-9\]+ = \\\[omp_next_variant\\\] OMP_NEXT_VARIANT <0,\[\r\n \]+construct context = 14\[\r\n \]+1: device = \\{arch \\(.nvptx.\\)\\}\[\r\n \]+2: >;" "gimple" { target { offload_nvptx } } } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-10.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-10.c
new file mode 100644
index 0000000..4020c4b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-10.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fdump-tree-gimple" } */
+
+struct S {
+ int x,y;
+};
+
+#pragma omp declare mapper(default : struct S var) map(mapper(default), tofrom: var)
+#pragma omp declare mapper(only_x : struct S var) map(mapper(default), tofrom: var.x)
+
+void f(){
+ struct S z = {1,2};
+#pragma omp target defaultmap(alloc)
+ z.x += 5;
+#pragma omp target map(z)
+ z.x += 7;
+#pragma omp target map(mapper(default), tofrom: z)
+ z.x += 8;
+#pragma omp target map(mapper(only_x), tofrom: z)
+ z.x += 9;
+if (z.x != 1+5+7+8+9) __builtin_abort ();
+}
+
+/* { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) defaultmap\\(alloc\\) map\\(tofrom:z \\\[len: 8\\\]\\)" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) map\\(tofrom:z \\\[len: 8\\\]\\)" 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) map\\(struct:z \\\[len: 1\\\]\\) map\\(tofrom:z.x \\\[len: 4\\\]\\)" 1 "gimple" } } */
+
+int main() {
+ f();
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-11.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-11.c
new file mode 100644
index 0000000..1f65bad
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-11.c
@@ -0,0 +1,70 @@
+#pragma omp declare mapper (int v)
+// { dg-error "missing 'map' clause before end of line" "" { target c++ } .-1 }
+// { dg-error "'int' is not a struct or union type in '#pragma omp declare mapper'" "" { target c } .-2 }
+
+#pragma omp declare mapper (float v) map()
+// { dg-error "expected primary-expression before '\\)' token" "" { target c++ } .-1 }
+// { dg-error "'float' is not a struct, union or class type in '#pragma omp declare mapper'" "" { target c++ } .-2 }
+// { dg-error "'float' is not a struct or union type in '#pragma omp declare mapper'" "" { target c } .-3 }
+
+#pragma omp declare mapper (char v) map(v)
+// { dg-error "'char' is not a struct, union or class type in '#pragma omp declare mapper'" "" { target c++ } .-1 }
+// { dg-error "'char' is not a struct or union type in '#pragma omp declare mapper'" "" { target c } .-2 }
+
+struct XT {
+ int x;
+};
+#pragma omp declare mapper (XT y) map()
+// { dg-error "expected primary-expression before '\\)' token" "" { target c++ } .-1 }
+// { dg-error "unknown type name 'XT'" "" { target c } .-2 }
+// { dg-error "expected end of line before 'y'" "" { target c } .-3 }
+#pragma omp declare mapper ( bar : struct XT y) map()
+// { dg-error "expected primary-expression before '\\)' token" "" { target c++ } .-1 }
+// { dg-error "expected expression before '\\)' token" "" { target c } .-2 }
+
+struct t {
+ int x;
+};
+
+typedef struct t myStruct;
+
+#pragma omp declare mapper(t)
+// { dg-error "expected unqualified-id before '\\)' token" "" { target c++ } .-1 }
+// { dg-error "unknown type name 't'" "" { target c } .-2 }
+// { dg-error "expected end of line before '\\)' token" "" { target c } .-3 }
+#pragma omp declare mapper(struct t)
+// { dg-error "expected unqualified-id before '\\)' token" "" { target c++ } .-1 }
+// { dg-error "expected identifier" "" { target c } .-2 }
+// { dg-error "expected end of line before '\\)' token" "" { target c } .-3 }
+#pragma omp declare mapper(myStruct)
+// { dg-error "expected unqualified-id before '\\)' token" "" { target c++ } .-1 }
+// { dg-error "expected identifier" "" { target c } .-2 }
+// { dg-error "expected end of line before '\\)' token" "" { target c } .-3 }
+
+#pragma omp declare mapper(name : t v) map()
+// { dg-error "expected primary-expression before '\\)' token" "" { target c++ } .-1 }
+// { dg-error "unknown type name 't'" "" { target c } .-2 }
+// { dg-error "expected end of line before 'v'" "" { target c } .-3 }
+
+#pragma omp declare mapper(fancy : struct t v) map(always,present,close,mapper(d),tofrom: v) // { dg-error "in 'declare mapper' directives, parameter to 'mapper' modifier must be 'default'" }
+
+#pragma omp declare mapper(myStruct v) map(v, v.x)
+// { dg-note "'#pragma omp declare mapper \\(myStruct\\)' previously declared here" "" { target c++ } .-1 }
+// { dg-note "'#pragma omp declare mapper' previously declared here" "" { target c } .-2 }
+#pragma omp declare mapper(default : struct t v) map(v, v.x)
+// { dg-error "redefinition of '#pragma omp declare mapper \\(t\\)'" "" { target c++ } .-1 }
+// { dg-error "redeclaration of '<default>' '#pragma omp declare mapper' for type 'struct t'" "" { target c } .-2 }
+
+union u_t { };
+union u_q { };
+
+#pragma omp declare mapper(union u_t v) map()
+// { dg-error "expected primary-expression before '\\)' token" "" { target c++ } .-1 }
+// { dg-error "expected expression before '\\)' token" "" { target c } .-2 }
+
+#pragma omp declare mapper( one : union u_t v) map(v)
+// { dg-note "'#pragma omp declare mapper \\(one: u_t\\)' previously declared here" "" { target c++ } .-1 }
+// { dg-note "'#pragma omp declare mapper' previously declared here" "" { target c } .-2 }
+#pragma omp declare mapper( one : union u_t u) map( u )
+// { dg-error "redefinition of '#pragma omp declare mapper \\(one: u_t\\)'" "" { target c++ } .-1 }
+// { dg-error "redeclaration of 'one' '#pragma omp declare mapper' for type 'union u_t'" "" { target c } .-2 }
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-12.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-12.c
new file mode 100644
index 0000000..dffb19d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-12.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+
+struct XYZ {
+ int a;
+ int *b;
+ int c;
+};
+
+#pragma omp declare mapper(struct XYZ t)
+/* { dg-error "missing 'map' clause" "" { target c } .-1 } */
+/* { dg-error "missing 'map' clause before end of line" "" { target c++ } .-2 } */
+
+struct ABC {
+ int *a;
+ int b;
+ int c;
+};
+
+#pragma omp declare mapper(struct ABC d) firstprivate(d.b)
+/* { dg-error "unexpected clause" "" { target c } .-1 } */
+/* { dg-error "expected end of line before '\\(' token" "" { target c } .-2 } */
+/* { dg-error "unexpected clause before '\\(' token" "" { target c++ } .-3 } */
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-3.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-3.c
new file mode 100644
index 0000000..e491bcd
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-3.c
@@ -0,0 +1,30 @@
+// { dg-do compile }
+// { dg-additional-options "-fdump-tree-gimple" }
+
+#include <stdlib.h>
+
+// Test named mapper invocation.
+
+struct S {
+ int *ptr;
+ int size;
+};
+
+int main (int argc, char *argv[])
+{
+ int N = 1024;
+#pragma omp declare mapper (mapN:struct S s) map(to:s.ptr, s.size) \
+ map(s.ptr[:N])
+
+ struct S s;
+ s.ptr = (int *) malloc (sizeof (int) * N);
+
+#pragma omp target map(mapper(mapN), tofrom: s)
+// { dg-final { scan-tree-dump {map\(struct:s \[len: 2\]\) map\(alloc:s\.ptr \[len: [0-9]+\]\) map\(to:s\.size \[len: [0-9]+\]\) map\(tofrom:\*_[0-9]+ \[len: _[0-9]+\]\) map\(attach:s\.ptr \[bias: 0\]\)} "gimple" } }
+ {
+ for (int i = 0; i < N; i++)
+ s.ptr[i]++;
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-4.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-4.c
new file mode 100644
index 0000000..39e3ab1
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-4.c
@@ -0,0 +1,78 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fdump-tree-original" } */
+
+/* Check mapper binding clauses. */
+
+struct Y {
+ int z;
+};
+
+struct Z {
+ int z;
+};
+
+#pragma omp declare mapper (struct Y y) map(tofrom: y)
+#pragma omp declare mapper (struct Z z) map(tofrom: z)
+
+int foo (void)
+{
+ struct Y yy;
+ struct Z zz;
+ int dummy;
+
+#pragma omp target data map(dummy)
+ {
+ #pragma omp target
+ {
+ yy.z++;
+ zz.z++;
+ }
+ yy.z++;
+ }
+ return yy.z;
+}
+
+struct P
+{
+ struct Z *zp;
+};
+
+int bar (void)
+{
+ struct Y yy;
+ struct Z zz;
+ struct P pp;
+ struct Z t;
+ int dummy;
+
+ pp.zp = &t;
+
+#pragma omp declare mapper (struct Y y) map(tofrom: y.z)
+#pragma omp declare mapper (struct Z z) map(tofrom: z.z)
+
+#pragma omp target data map(dummy)
+ {
+ #pragma omp target
+ {
+ yy.z++;
+ zz.z++;
+ }
+ yy.z++;
+ }
+
+ #pragma omp declare mapper(struct P x) map(to:x.zp) map(tofrom:*x.zp)
+
+ #pragma omp target
+ {
+ zz = *pp.zp;
+ }
+
+ return zz.z;
+}
+
+/* { dg-final { scan-tree-dump-times {mapper_binding\(struct Y,omp declare mapper ~1Y\) mapper_binding\(struct Z,omp declare mapper ~1Z\)} 2 "original" { target c++ } } } */
+/* { dg-final { scan-tree-dump {mapper_binding\(struct Z,omp declare mapper ~1Z\) mapper_binding\(struct P,omp declare mapper ~1P\)} "original" { target c++ } } } */
+
+/* { dg-final { scan-tree-dump {mapper_binding\(struct Z,#pragma omp declare mapper \(struct Z z\) map\(tofrom:z\)\) mapper_binding\(struct Y,#pragma omp declare mapper \(struct Y y\) map\(tofrom:y\)\)} "original" { target c } } } */
+/* { dg-final { scan-tree-dump {mapper_binding\(struct Z,#pragma omp declare mapper \(struct Z z\) map\(tofrom:z\.z\)\) mapper_binding\(struct Y,#pragma omp declare mapper \(struct Y y\) map\(tofrom:y\.z\)\)} "original" { target c } } } */
+/* { dg-final { scan-tree-dump {mapper_binding\(struct P,#pragma omp declare mapper \(struct P x\) map\(tofrom:\(x\.zp\)\[0:1\]\) map\(to:x.zp\)\) mapper_binding\(struct Z,#pragma omp declare mapper \(struct Z z\) map\(tofrom:z\.z\)\)} "original" { target c } } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-5.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-5.c
new file mode 100644
index 0000000..e8ab159
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-5.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+
+typedef struct S_ {
+ int *myarr;
+ int size;
+} S;
+
+#pragma omp declare mapper (named: struct S_ v) map(to:v.size, v.myarr) \
+ map(tofrom: v.myarr[0:v.size])
+/* { dg-note "'#pragma omp declare mapper' previously declared here" "" { target c } .-2 } */
+/* { dg-note "'#pragma omp declare mapper \\(named: S_\\)' previously defined here" "" { target c++ } .-3 } */
+
+#pragma omp declare mapper (named: S v) map(to:v.size, v.myarr) \
+ map(tofrom: v.myarr[0:v.size])
+/* { dg-error "redeclaration of 'named' '#pragma omp declare mapper' for type 'S' \\\{aka 'struct S_'\\\}" "" { target c } .-2 } */
+/* { dg-error "redefinition of '#pragma omp declare mapper \\(named: S\\)'" "" { target c++ } .-3 } */
+
+#pragma omp declare mapper (struct S_ v) map(to:v.size, v.myarr) \
+ map(tofrom: v.myarr[0:v.size])
+/* { dg-note "'#pragma omp declare mapper' previously declared here" "" { target c } .-2 } */
+/* { dg-note "'#pragma omp declare mapper \\(S_\\)' previously defined here" "" { target c++ } .-3 } */
+
+#pragma omp declare mapper (S v) map(to:v.size, v.myarr) \
+ map(tofrom: v.myarr[0:v.size])
+/* { dg-error "redeclaration of '<default>' '#pragma omp declare mapper' for type 'S' \\\{aka 'struct S_'\\\}" "" { target c } .-2 } */
+/* { dg-error "redefinition of '#pragma omp declare mapper \\(S\\)'" "" { target c++ } .-3 } */
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-6.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-6.c
new file mode 100644
index 0000000..c13eb8b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-6.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+
+int x = 5;
+
+struct Q {
+ int *arr1;
+ int *arr2;
+ int *arr3;
+};
+
+#pragma omp declare mapper (struct Q myq) map(myq.arr2[0:x])
+
+struct R {
+ int *arr1;
+ int *arr2;
+ int *arr3;
+};
+
+#pragma omp declare mapper (struct R myr) map(myr.arr3[0:y])
+/* { dg-error "'y' undeclared" "" { target c } .-1 } */
+/* { dg-error "'y' was not declared in this scope" "" { target c++ } .-2 } */
+
+int y = 7;
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-7.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-7.c
new file mode 100644
index 0000000..0f8dd25
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-7.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+
+struct Q {
+ int *arr1;
+ int *arr2;
+ int *arr3;
+};
+
+int foo (void)
+{
+ int x = 5;
+ #pragma omp declare mapper (struct Q myq) map(myq.arr2[0:x])
+ return x;
+}
+
+struct R {
+ int *arr1;
+ int *arr2;
+ int *arr3;
+};
+
+int bar (void)
+{
+ #pragma omp declare mapper (struct R myr) map(myr.arr3[0:y])
+ /* { dg-error "'y' undeclared" "" { target c } .-1 } */
+ /* { dg-error "'y' was not declared in this scope" "" { target c++ } .-2 } */
+ int y = 7;
+ return y;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-8.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-8.c
new file mode 100644
index 0000000..dadca28
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-8.c
@@ -0,0 +1,43 @@
+/* { dg-do compile } */
+
+struct Q {
+ int *arr1;
+ int *arr2;
+ int *arr3;
+ int len;
+};
+
+struct R {
+ struct Q qarr[5];
+};
+
+struct R2 {
+ struct Q *qptr;
+};
+
+#pragma omp declare mapper (struct Q myq) map(myq.arr1[0:myq.len]) \
+ map(myq.arr2[0:myq.len]) \
+ map(myq.arr3[0:myq.len])
+
+#pragma omp declare mapper (struct R myr) map(myr.qarr[2:3])
+
+#pragma omp declare mapper (struct R2 myr2) map(myr2.qptr[2:3])
+
+int main (int argc, char *argv[])
+{
+ struct R r;
+ struct R2 r2;
+ int N = 256;
+
+#pragma omp target
+/* { dg-message "sorry, unimplemented: user-defined mapper with non-unit length array section" "" { target *-*-* } .-1 } */
+ {
+ for (int i = 2; i < 5; i++)
+ for (int j = 0; j < N; j++)
+ {
+ r.qarr[i].arr1[j]++;
+ r2.qptr[i].arr2[j]++;
+ }
+ }
+}
+
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-9.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-9.c
new file mode 100644
index 0000000..709bc0c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-9.c
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+
+int x = 5;
+
+struct Q {
+ int *arr1;
+ int *arr2;
+ int *arr3;
+};
+
+int y = 5;
+
+#pragma omp declare mapper (struct Q myq) map(myq.arr2[0:x])
+/* { dg-note "'#pragma omp declare mapper' previously declared here" "" { target c } .-1 } */
+/* { dg-note "'#pragma omp declare mapper \\(Q\\)' previously defined here" "" { target c++ } .-2 } */
+
+#pragma omp declare mapper (struct Q myq) map(myq.arr2[0:y])
+/* { dg-error "redeclaration of '<default>' '#pragma omp declare mapper' for type 'struct Q'" "" { target c } .-1 } */
+/* { dg-error "redefinition of '#pragma omp declare mapper \\(Q\\)'" "" { target c++ } .-2 } */
+
+struct R {
+ int *arr1;
+};
+
+void foo (void)
+{
+#pragma omp declare mapper (struct R myr) map(myr.arr1[0:x])
+/* { dg-note "'#pragma omp declare mapper' previously declared here" "" { target c } .-1 } */
+/* { dg-note "'#pragma omp declare mapper \\(R\\)' previously declared here" "" { target c++ } .-2 } */
+
+#pragma omp declare mapper (struct R myr) map(myr.arr1[0:y])
+/* { dg-error "redeclaration of '<default>' '#pragma omp declare mapper' for type 'struct R'" "" { target c } .-1 } */
+/* { dg-error "redeclaration of '#pragma omp declare mapper \\(R\\)'" "" { target c++ } .-2 } */
+}
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 7711dbc..83e1bb1 100644
--- a/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c
+++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c
@@ -38,7 +38,7 @@ void f18 (void);
void f19 (void);
#pragma omp declare variant (f1) match(user={condition()}) /* { dg-error "expected \[^\n\r]*expression before '\\)' token" } */
void f20 (void);
-#pragma omp declare variant (f1) match(user={condition(f1)}) /* { dg-error "property must be integer expression" } */
+#pragma omp declare variant (f1) match(user={condition(f1)})
void f21 (void);
#pragma omp declare variant (f1) match(user={condition(1, 2, 3)}) /* { dg-error "expected '\\)' before ',' token" } */
void f22 (void);
@@ -47,10 +47,9 @@ void f23 (void);
#pragma omp declare variant (f1) match(construct={teams,parallel,master,for}) /* { dg-warning "unknown selector 'master' for context selector set 'construct'" } */
void f24 (void);
#pragma omp declare variant (f1) match(construct={parallel(1 /* { dg-error "selector 'parallel' does not accept any properties" } */
-void f25 (void); /* { dg-error "expected '\\\}' before end of line" "" { target c++ } .-1 } */
- /* { dg-error "expected '\\\}' before '\\(' token" "" { target c } .-2 } */
+void f25 (void); /* { dg-error "expected '\\\}' before end of line" "" { target *-*-* } .-1 } */
#pragma omp declare variant (f1) match(construct={parallel(1)}) /* { dg-error "selector 'parallel' does not accept any properties" } */
-void f26 (void); /* { dg-error "expected '\\\}' before '\\(' token" "" { target c } .-1 } */
+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 } */
#pragma omp declare variant (f1) match(construct={parallel},construct={for}) /* { dg-error "selector set 'construct' specified more than once" } */
@@ -96,13 +95,13 @@ void f46 (void);
#pragma omp declare variant (f1) match(implementation={vendor("foobar")}) /* { dg-warning "unknown property '.foobar.' of 'vendor' selector" } */
void f47 (void);
#pragma omp declare variant (f1) match(implementation={unified_address(yes)}) /* { dg-error "selector 'unified_address' does not accept any properties" } */
-void f48 (void); /* { dg-error "expected '\\\}' before '\\(' token" "" { target c } .-1 } */
+void f48 (void);
#pragma omp declare variant (f1) match(implementation={unified_shared_memory(no)}) /* { dg-error "selector 'unified_shared_memory' does not accept any properties" } */
-void f49 (void); /* { dg-error "expected '\\\}' before '\\(' token" "" { target c } .-1 } */
+void f49 (void);
#pragma omp declare variant (f1) match(implementation={dynamic_allocators(42)}) /* { dg-error "selector 'dynamic_allocators' does not accept any properties" } */
-void f50 (void); /* { dg-error "expected '\\\}' before '\\(' token" "" { target c } .-1 } */
+void f50 (void);
#pragma omp declare variant (f1) match(implementation={reverse_offload()}) /* { dg-error "selector 'reverse_offload' does not accept any properties" } */
-void f51 (void); /* { dg-error "expected '\\\}' before '\\(' token" "" { target c } .-1 } */
+void f51 (void);
#pragma omp declare variant (f1) match(implementation={atomic_default_mem_order}) /* { dg-error "expected '\\(' before '\\\}' token" } */
void f52 (void);
#pragma omp declare variant (f1) match(implementation={atomic_default_mem_order(acquire)})
diff --git a/gcc/testsuite/c-c++-common/gomp/map-6.c b/gcc/testsuite/c-c++-common/gomp/map-6.c
index 014ed35..852839e 100644
--- a/gcc/testsuite/c-c++-common/gomp/map-6.c
+++ b/gcc/testsuite/c-c++-common/gomp/map-6.c
@@ -13,20 +13,20 @@ foo (void)
#pragma omp target map (to:a)
;
- #pragma omp target map (a to: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close' or 'present'" } */
- ;
+ #pragma omp target map (a to: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present'" "" { target c++ } } */
+ ; /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present' before 'a'" "" { target c } .-1 } */
- #pragma omp target map (close, a to: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close' or 'present'" } */
- ;
+ #pragma omp target map (close, a to: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present'" "" { target c++ } } */
+ ; /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present' before 'a'" "" { target c } .-1 } */
- #pragma omp target enter data map(b7) map (close, a to: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close' or 'present'" } */
- ;
+ #pragma omp target enter data map(b7) map (close, a to: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present'" "" { target c++ } } */
+ ; /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present' before 'a'" "" { target c } .-1 } */
- #pragma omp target exit data map(b7) map (close, a from: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close' or 'present'" } */
- ;
+ #pragma omp target exit data map(b7) map (close, a from: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present'" "" { target c++ } } */
+ ; /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present' before 'a'" "" { target c } .-1 } */
- #pragma omp target data map(b7) map (close, a from: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close' or 'present'" } */
- ;
+ #pragma omp target data map(b7) map (close, a from: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present'" "" { target c++ } } */
+ ; /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present' before 'a'" "" { target c } .-1 } */
#pragma omp target map (close a) /* { dg-error "'close' undeclared" "" { target c } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/metadirective-3.c b/gcc/testsuite/c-c++-common/gomp/metadirective-3.c
index 0ac0d1d..b6c1601 100644
--- a/gcc/testsuite/c-c++-common/gomp/metadirective-3.c
+++ b/gcc/testsuite/c-c++-common/gomp/metadirective-3.c
@@ -8,7 +8,7 @@ f (int x[], int y[], int z[])
{
int i;
- #pragma omp target map(to: x, y) map(from: z)
+ #pragma omp target map(to: x, y) map(from: z) /* { dg-bogus "'target' construct with nested 'teams' construct contains directives outside of the 'teams' construct" "PR118694" { xfail offload_nvptx } } */
#pragma omp metadirective \
when (device={arch("nvptx")}: teams loop) \
default (parallel loop)
@@ -19,5 +19,6 @@ f (int x[], int y[], int z[])
/* If offload device "nvptx" isn't supported, the front end can eliminate
that alternative and not produce a metadirective at all. Otherwise this
won't be resolved until late. */
-/* { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" { target { ! offload_nvptx } } } } */
-/* { dg-final { scan-tree-dump "#pragma omp metadirective" "gimple" { target { offload_nvptx } } } } */
+/* { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" } } */
+/* { dg-final { scan-tree-dump-not " teams" "gimple" { target { ! offload_nvptx } } } } */
+/* { dg-final { scan-tree-dump "variant.\[0-9\]+ = \\\[omp_next_variant\\\] OMP_NEXT_VARIANT <0,\[\r\n \]+construct context = 14\[\r\n \]+1: device = \\{arch \\(.nvptx.\\)\\}\[\r\n \]+2: >;" "gimple" { target { offload_nvptx } } } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/metadirective-condition-constexpr.c b/gcc/testsuite/c-c++-common/gomp/metadirective-condition-constexpr.c
new file mode 100644
index 0000000..3484478
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/metadirective-condition-constexpr.c
@@ -0,0 +1,13 @@
+/* { dg-do compile { target { c || c++11 } } } */
+/* { dg-additional-options "-std=c23" { target c } } */
+/* { dg-additional-options "-fdump-tree-original" } */
+
+constexpr int flag = 1;
+
+void f() {
+#pragma omp metadirective when(user={condition(flag)} : nothing) \
+ otherwise(error at(execution))
+}
+
+/* { dg-final { scan-tree-dump-not "__builtin_GOMP_error" "original" } } */
+
diff --git a/gcc/testsuite/c-c++-common/gomp/metadirective-condition.c b/gcc/testsuite/c-c++-common/gomp/metadirective-condition.c
new file mode 100644
index 0000000..099ad9d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/metadirective-condition.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fdump-tree-original" } */
+
+static int arr[10];
+static int g (int a) { return -a; }
+
+void f (int *ptr, float x) {
+
+ /* Implicit conversion float -> bool */
+ #pragma omp metadirective when(user={condition(x)} : nothing) otherwise(nothing)
+
+ /* Implicit conversion pointer -> bool */
+ #pragma omp metadirective when(user={condition(ptr)} : nothing) otherwise(nothing)
+
+ /* Array expression undergoes array->pointer conversion, OK but test is
+ always optimized away. */
+ #pragma omp metadirective when(user={condition(arr)} : nothing) otherwise(nothing)
+
+ /* Function reference has pointer-to-function type, OK but test is
+ always optimized away. */
+ #pragma omp metadirective when(user={condition(g)} : nothing) otherwise(nothing)
+}
+
+/* { dg-final { scan-tree-dump "x != 0.0" "original" } } */
+/* { dg-final { scan-tree-dump "ptr != 0B" "original" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/metadirective-error-recovery.c b/gcc/testsuite/c-c++-common/gomp/metadirective-error-recovery.c
new file mode 100644
index 0000000..92995a2
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/metadirective-error-recovery.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+
+/* This test used to ICE in C and only diagnose the first error in C++. */
+
+struct s {
+ int a, b;
+};
+
+void f (int aa, int bb)
+{
+ struct s s1, s2;
+ s1.a = aa;
+ s1.b = bb;
+ s2.a = aa + 1;
+ s2.b = bb + 1;
+
+ /* A struct is not a valid argument for the condition selector. */
+ #pragma omp metadirective when(user={condition(s1)} : nothing) otherwise(nothing)
+ /* { dg-error "used struct type value where scalar is required" "" { target c } .-1 } */
+ /* { dg-error "could not convert .s1. from .s. to .bool." "" { target c++ } .-2 } */
+ #pragma omp metadirective when(user={condition(s2)} : nothing) otherwise(nothing)
+ /* { dg-error "used struct type value where scalar is required" "" { target c } .-1 } */
+ /* { dg-error "could not convert .s2. from .s. to .bool." "" { target c++ } .-2 } */
+
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/omp_get_num_devices_initial_device-2.c b/gcc/testsuite/c-c++-common/gomp/omp_get_num_devices_initial_device-2.c
new file mode 100644
index 0000000..891f5cf
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/omp_get_num_devices_initial_device-2.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O1 -fdump-tree-optimized -fno-builtin-omp_get_num_devices -fno-builtin-omp_get_initial_device" } */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int omp_get_initial_device ();
+extern int omp_get_num_devices ();
+#ifdef __cplusplus
+}
+#endif
+
+int f()
+{
+/* The following assumes that omp_get_initial_device () will not return
+ omp_initial_device (== -1), which is also permitted since OpenMP 6.0. */
+ if (omp_get_initial_device () != omp_get_num_devices ()) __builtin_abort ();
+
+ if (omp_get_num_devices () != omp_get_num_devices ()) __builtin_abort ();
+
+ if (omp_get_initial_device () != omp_get_initial_device ()) __builtin_abort ();
+
+ return omp_get_num_devices ();
+}
+
+/* { dg-final { scan-tree-dump-times "abort" 3 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "omp_get_num_devices" 4 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "omp_get_initial_device" 3 "optimized" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/omp_get_num_devices_initial_device.c b/gcc/testsuite/c-c++-common/gomp/omp_get_num_devices_initial_device.c
new file mode 100644
index 0000000..6e2c1a8
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/omp_get_num_devices_initial_device.c
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O1 -fdump-tree-optimized" } */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int omp_get_initial_device ();
+extern int omp_get_num_devices ();
+#ifdef __cplusplus
+}
+#endif
+
+int f()
+{
+/* The following assumes that omp_get_initial_device () will not return
+ omp_initial_device (== -1), which is also permitted since OpenMP 6.0. */
+ if (omp_get_initial_device () != omp_get_num_devices ()) __builtin_abort ();
+
+ if (omp_get_num_devices () != omp_get_num_devices ()) __builtin_abort ();
+
+ if (omp_get_initial_device () != omp_get_initial_device ()) __builtin_abort ();
+
+ return omp_get_num_devices ();
+}
+
+/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */
+
+/* { dg-final { scan-tree-dump-not "omp_get_num_devices" "optimized" { target { ! offloading_enabled } } } } */
+/* { dg-final { scan-tree-dump "return 0;" "optimized" { target { ! offloading_enabled } } } } */
+
+/* { dg-final { scan-tree-dump-times "omp_get_num_devices" 1 "optimized" { target offloading_enabled } } } */
+/* { dg-final { scan-tree-dump "_1 = __builtin_omp_get_num_devices \\(\\);\[\\r\\n\]+\[ \]+return _1;" "optimized" { target offloading_enabled } } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/pr120180.c b/gcc/testsuite/c-c++-common/gomp/pr120180.c
new file mode 100644
index 0000000..cb5a0d5
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr120180.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+
+/* This test used to ICE after erroring on the metadirective in the
+ loop nest. */
+
+int main()
+{
+ int blksize = 15000;
+ double *qq;
+ int i, k, nq;
+
+ #pragma omp metadirective when(user={condition(0)}: target teams distribute parallel for collapse(2) map(qq[:0]) private(i)) \
+ when(user={condition(0)}: target teams distribute parallel for map(qq[:0]) private(i)) \
+ when(user={condition(1)}: target teams loop collapse(2) map(qq[:0]) private(i))
+ for(k=0; k<blksize; k++)
+ {
+#pragma omp metadirective when(user={condition(0)}: simd) default() // { dg-error "intervening code must not contain OpenMP directives" }
+ for (i=0; i<nq; i++)
+ qq[k*nq + i] = 0.0;
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/pr106133.c b/gcc/testsuite/c-c++-common/pr106133.c
deleted file mode 100644
index 7d2c5af..0000000
--- a/gcc/testsuite/c-c++-common/pr106133.c
+++ /dev/null
@@ -1,3 +0,0 @@
-/* PR middle-end/106133 */
-/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-format=json-file -E" } */
diff --git a/gcc/testsuite/c-c++-common/pr118868-1.c b/gcc/testsuite/c-c++-common/pr118868-1.c
new file mode 100644
index 0000000..d0a9e77f7
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr118868-1.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+/* PR middle-end/118868 */
+
+/* __builtin_assoc_barrier should work on pointers without any ICE */
+void *f(void *a)
+{
+ return __builtin_assoc_barrier(a);
+}
diff --git a/gcc/testsuite/c-c++-common/pragma-optimize-1.c b/gcc/testsuite/c-c++-common/pragma-optimize-1.c
new file mode 100644
index 0000000..1446e5a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pragma-optimize-1.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast" } */
+
+/* PR c++/48026 */
+/* Make sure `#pragma GCC optimize` affects the pre-defined macros too */
+
+#pragma GCC optimize ("no-fast-math")
+#ifdef __FAST_MATH__
+# error Hey yo, What you doing on FAST_MATH??
+#endif
diff --git a/gcc/testsuite/c-c++-common/ubsan/nonnull-8.c b/gcc/testsuite/c-c++-common/ubsan/nonnull-8.c
new file mode 100644
index 0000000..e2320df
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/nonnull-8.c
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-options "-fsanitize=undefined -fno-sanitize-recover=undefined" } */
+
+__attribute__((noipa, nonnull_if_nonzero (1, 4, 7)))
+__attribute__((nonnull (3), nonnull_if_nonzero (5, 2, 6))) void
+foo (void *a, unsigned long b, void *c, int d, void *e, unsigned long f, int g)
+{
+ (void) a;
+ (void) b;
+ (void) c;
+ (void) d;
+ (void) e;
+ (void) f;
+ (void) g;
+}
+
+__attribute__((noipa))
+void
+bar (void *a, unsigned long b, void *c, int d, void *e, unsigned long f, int g)
+{
+ foo (a, b, c, d, e, f, g);
+}
+
+int
+main ()
+{
+ char x;
+ bar (&x, 42, &x, 1, &x, 2, 3);
+ bar (0, 0, &x, 0, 0, 0, 0);
+ bar (0, 5, &x, 4, 0, 0, 0);
+ bar (0, 0, &x, 0, 0, 6, 7);
+}
diff --git a/gcc/testsuite/c-c++-common/ubsan/nonnull-9.c b/gcc/testsuite/c-c++-common/ubsan/nonnull-9.c
new file mode 100644
index 0000000..68a4417
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/nonnull-9.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-options "-fsanitize=nonnull-attribute" } */
+
+__attribute__((noipa, nonnull_if_nonzero (1, 4, 7)))
+__attribute__((nonnull (3), nonnull_if_nonzero (5, 2, 6))) void
+foo (void *a, unsigned long b, void *c, int d, void *e, unsigned long f, int g)
+{
+ (void) a;
+ (void) b;
+ (void) c;
+ (void) d;
+ (void) e;
+ (void) f;
+ (void) g;
+}
+
+__attribute__((noipa))
+void
+bar (void *a, unsigned long b, void *c, int d, void *e, unsigned long f, int g)
+{
+ foo (a, b, c, d, e, f, g);
+}
+
+int
+main ()
+{
+ char x;
+ bar (&x, 42, 0, 1, &x, 17, 18);
+ bar (0, 25, &x, 7, &x, 0, 8);
+ bar (&x, -82, &x, 68, 0, 9, 0);
+ foo (&x, 42, 0, 1, &x, 17, 18);
+ foo (0, 25, &x, 7, &x, 0, 8);
+ foo (&x, -82, &x, 68, 0, 9, 0);
+}
+
+/* { dg-output "\.c:21:\[0-9]*:\[^\n\r]*null pointer passed as argument 3, which is declared to never be null\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*\.c:21:\[0-9]*:\[^\n\r]*null pointer passed as argument 1, which is declared to never be null\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*\.c:21:\[0-9]*:\[^\n\r]*null pointer passed as argument 5, which is declared to never be null\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*\.c:31:\[0-9]*:\[^\n\r]*null pointer passed as argument 3, which is declared to never be null\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*\.c:32:\[0-9]*:\[^\n\r]*null pointer passed as argument 1, which is declared to never be null\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*\.c:33:\[0-9]*:\[^\n\r]*null pointer passed as argument 5, which is declared to never be null" } */