2019-08-30 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 2019-01-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/88976
+ * semantics.c (finish_omp_cancel): Use maybe_convert_cond when not in
+ template or build_x_binary_op otherwise.
+
2019-01-21 Jakub Jelinek <jakub@redhat.com>
PR c++/88949
tree ifc = omp_find_clause (clauses, OMP_CLAUSE_IF);
if (ifc != NULL_TREE)
{
- tree type = TREE_TYPE (OMP_CLAUSE_IF_EXPR (ifc));
- ifc = fold_build2_loc (OMP_CLAUSE_LOCATION (ifc), NE_EXPR,
- boolean_type_node, OMP_CLAUSE_IF_EXPR (ifc),
- build_zero_cst (type));
+ if (!processing_template_decl)
+ ifc = maybe_convert_cond (OMP_CLAUSE_IF_EXPR (ifc));
+ else
+ ifc = build_x_binary_op (OMP_CLAUSE_LOCATION (ifc), NE_EXPR,
+ OMP_CLAUSE_IF_EXPR (ifc), ERROR_MARK,
+ integer_zero_node, ERROR_MARK,
+ NULL, tf_warning_or_error);
}
else
ifc = boolean_true_node;
2019-08-30 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 2019-01-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/88976
+ * c-c++-common/gomp/cancel-2.c: New test.
+ * gcc.dg/gomp/cancel-1.c: New test.
+ * g++.dg/gomp/cancel-1.C: New test.
+ * g++.dg/gomp/cancel-2.C: New test.
+ * g++.dg/gomp/cancel-3.C: New test.
+
2019-01-22 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/49429
--- /dev/null
+/* { dg-do compile } */
+
+void
+foo (void)
+{
+ #pragma omp parallel
+ {
+ #pragma omp cancel parallel if (1) if (1) /* { dg-error "too many 'if' clauses without modifier" } */
+ }
+}
--- /dev/null
+// PR c++/88976
+// { dg-do compile }
+
+template <class T> void
+foo (T x)
+{
+#pragma omp parallel
+ {
+ #pragma omp cancel parallel if (x)
+ }
+#pragma omp parallel
+ {
+ #pragma omp cancel parallel if (1 == 1)
+ }
+}
+
+void
+bar (int x, double y, long long z)
+{
+ foo (0);
+ foo (1LL);
+ foo (1.25);
+ foo (x);
+ foo (y);
+ foo (z);
+}
--- /dev/null
+// PR c++/88976
+// { dg-do compile }
+
+template <class T> void
+foo (T x)
+{
+#pragma omp parallel
+ {
+ #pragma omp cancel parallel if (x) // { dg-error "no match for" }
+ }
+}
+
+struct S {};
+
+void
+bar ()
+{
+ S s;
+ foo (s);
+}
--- /dev/null
+// { dg-do compile }
+
+struct S { int s; } s;
+
+void
+foo (void)
+{
+ #pragma omp parallel
+ {
+ #pragma omp cancel parallel if (s) // { dg-error "could not convert 's' from 'S' to 'bool'" }
+ }
+}
--- /dev/null
+/* { dg-do compile } */
+
+struct S { int s; } s;
+
+void
+foo (void)
+{
+ #pragma omp parallel
+ {
+ #pragma omp cancel parallel if (s) /* { dg-error "used struct type value where scalar is required" } */
+ }
+}