+2020-04-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/94593
+ * c-parser.c (c_parser_pragma) <case PRAGMA_OMP_REQUIRES>: Reject
+ requires directive when not at file scope.
+
2020-04-08 Tobias Burnus <tobias@codesourcery.com>
PR middle-end/94120
return false;
case PRAGMA_OMP_REQUIRES:
+ if (context != pragma_external)
+ {
+ error_at (c_parser_peek_token (parser)->location,
+ "%<#pragma omp requires%> may only be used at file scope");
+ c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
+ return false;
+ }
c_parser_omp_requires (parser);
return false;
+2020-04-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/94593
+ * parser.c (cp_parser_pragma) <case PRAGMA_OMP_REQUIRES>: Reject
+ requires directive when not at file or namespace scope.
+
2020-04-14 Iain Sandoe <iain@sandoe.co.uk>
PR c++/94359
return true;
case PRAGMA_OMP_REQUIRES:
+ if (context != pragma_external)
+ {
+ error_at (pragma_tok->location,
+ "%<#pragma omp requires%> may only be used at file or "
+ "namespace scope");
+ break;
+ }
return cp_parser_omp_requires (parser, pragma_tok);
case PRAGMA_OMP_ORDERED:
+2020-04-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/94593
+ * c-c++-common/gomp/requires-1.c: Fix a typo, requries -> requires.
+ Move directives to file scope.
+ (i): Remove.
+ * c-c++-common/gomp/requires-2.c: Move directives to file scope.
+ (i, foo): Remove.
+ * c-c++-common/gomp/requires-4.c: Move directives to file scope.
+ * gcc.dg/gomp/requires-1.c: New test.
+ * g++.dg/gomp/requires-1.C: New test.
+ * g++.dg/gomp/requires-2.C: New test.
+
2020-04-15 Richard Biener <rguenther@suse.de>
PR middle-end/94539
void
foo ()
{
- int v;
#pragma omp atomic release
i = i + 1;
- #pragma omp requires atomic_default_mem_order (relaxed)
+}
+
+#pragma omp requires atomic_default_mem_order (relaxed)
+
+void
+bar ()
+{
+ int v;
#pragma omp atomic
j = j + 1;
#pragma omp atomic update
void
foo ()
{
- int v;
#pragma omp atomic release
i = i + 1;
- #pragma omp requires atomic_default_mem_order (seq_cst)
+}
+
+#pragma omp requires atomic_default_mem_order (seq_cst)
+
+void
+bar ()
+{
+ int v;
#pragma omp atomic
j = j + 1;
#pragma omp atomic update
void
foo ()
{
- int v;
#pragma omp atomic release
i = i + 1;
- #pragma omp requires atomic_default_mem_order (acq_rel)
+}
+
+#pragma omp requires atomic_default_mem_order (acq_rel)
+
+void
+bar ()
+{
+ int v;
#pragma omp atomic
j = j + 1;
#pragma omp atomic update
i = i + 1;
#pragma omp atomic read
v = j;
- #pragma omp requires atomic_default_mem_order (acq_rel) /* { dg-error "'atomic_default_mem_order' clause used lexically after first 'atomic' construct without memory order clause" } */
}
+
+#pragma omp requires atomic_default_mem_order (acq_rel) /* { dg-error "'atomic_default_mem_order' clause used lexically after first 'atomic' construct without memory order clause" } */
#pragma omp requires unified_shared_memory unified_address
#pragma omp requires dynamic_allocators,reverse_offload
-int i;
-
void
foo ()
{
- if (0)
- #pragma omp requires unified_shared_memory unified_address
- i++;
- #pragma omp requries atomic_default_mem_order(seq_cst)
}
+#pragma omp requires unified_shared_memory unified_address
+#pragma omp requires atomic_default_mem_order(seq_cst)
+
/* { dg-prune-output "not supported yet" } */
#pragma omp requires unified_address unified_address /* { dg-error "too many 'unified_address' clauses" } */
#pragma omp requires reverse_offload reverse_offload /* { dg-error "too many 'reverse_offload' clauses" } */
#pragma omp requires foobarbaz /* { dg-error "expected 'unified_address', 'unified_shared_memory', 'dynamic_allocators', 'reverse_offload' or 'atomic_default_mem_order' clause" } */
-
-int i;
-
-void
-foo ()
-{
- #pragma omp requires dynamic_allocators , dynamic_allocators /* { dg-error "too many 'dynamic_allocators' clauses" } */
- if (0)
- #pragma omp requires atomic_default_mem_order(seq_cst) atomic_default_mem_order(seq_cst) /* { dg-error "too many 'atomic_default_mem_order' clauses" } */
- i++;
-}
-
+#pragma omp requires dynamic_allocators , dynamic_allocators /* { dg-error "too many 'dynamic_allocators' clauses" } */
+#pragma omp requires atomic_default_mem_order(seq_cst) atomic_default_mem_order(seq_cst) /* { dg-error "too many 'atomic_default_mem_order' clauses" } */
#pragma omp requires atomic_default_mem_order (seq_cst) /* { dg-error "more than one 'atomic_default_mem_order' clause in a single compilation unit" } */
/* { dg-prune-output "not supported yet" } */
{
#pragma omp target
;
- #pragma omp requires unified_shared_memory /* { dg-error "'unified_shared_memory' clause used lexically after first target construct or offloading API" } */
}
+#pragma omp requires unified_shared_memory /* { dg-error "'unified_shared_memory' clause used lexically after first target construct or offloading API" } */
#pragma omp requires unified_address /* { dg-error "'unified_address' clause used lexically after first target construct or offloading API" } */
#pragma omp requires reverse_offload /* { dg-error "'reverse_offload' clause used lexically after first target construct or offloading API" } */
i = v;
#pragma omp atomic hint(1),update,release
f = f + 2.0;
- #pragma omp requires atomic_default_mem_order (acq_rel)
+}
+
+#pragma omp requires atomic_default_mem_order (acq_rel)
+
+template <int N, int M, typename T>
+void
+baz (T *p)
+{
#pragma omp atomic hint (M - 1) update
*p += 1;
#pragma omp atomic capture, hint (M)
bar ()
{
foo <0, 1, int> (&i);
+ baz <0, 1, int> (&i);
}
--- /dev/null
+namespace N {
+namespace M {
+#pragma omp requires unified_address
+#pragma omp requires unified_shared_memory
+#pragma omp requires unified_shared_memory unified_address
+#pragma omp requires dynamic_allocators,reverse_offload
+#pragma omp requires unified_shared_memory unified_address
+#pragma omp requires atomic_default_mem_order(seq_cst)
+}
+}
+
+/* { dg-prune-output "not supported yet" } */
--- /dev/null
+int i;
+
+void
+foo ()
+{
+ #pragma omp requires unified_address // { dg-error "may only be used at file or namespace scope" }
+ #pragma omp requires unified_shared_memory // { dg-error "may only be used at file or namespace scope" }
+ #pragma omp requires unified_shared_memory unified_address // { dg-error "may only be used at file or namespace scope" }
+ #pragma omp requires dynamic_allocators,reverse_offload // { dg-error "may only be used at file or namespace scope" }
+ #pragma omp requires atomic_default_mem_order(seq_cst) // { dg-error "may only be used at file or namespace scope" }
+ if (0)
+ #pragma omp requires unified_address // { dg-error "may only be used at file or namespace scope" }
+ i++;
+ if (0)
+ #pragma omp requires atomic_default_mem_order(seq_cst) // { dg-error "may only be used at file or namespace scope" }
+ i++;
+}
+
+struct S {
+ int s;
+ #pragma omp requires unified_address // { dg-error "may only be used at file or namespace scope" }
+};
--- /dev/null
+int i;
+
+void
+foo ()
+{
+ #pragma omp requires unified_address /* { dg-error "may only be used at file scope" } */
+ #pragma omp requires unified_shared_memory /* { dg-error "may only be used at file scope" } */
+ #pragma omp requires unified_shared_memory unified_address /* { dg-error "may only be used at file scope" } */
+ #pragma omp requires dynamic_allocators,reverse_offload /* { dg-error "may only be used at file scope" } */
+ #pragma omp requires atomic_default_mem_order(seq_cst) /* { dg-error "may only be used at file scope" } */
+ if (0)
+ #pragma omp requires unified_address /* { dg-error "may only be used at file scope" } */
+ i++;
+ if (0)
+ #pragma omp requires atomic_default_mem_order(seq_cst) /* { dg-error "may only be used at file scope" } */
+ i++;
+}
+
+struct S {
+ int s;
+ #pragma omp requires unified_address /* { dg-error "may only be used at file scope" } */
+};