]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/88976 (ICE in fold_convert_loc, at fold-const.c:2552)
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 11:31:02 +0000 (13:31 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 11:31:02 +0000 (13:31 +0200)
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.

* 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.

From-SVN: r275091

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/gomp/cancel-2.c [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/cancel-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/cancel-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/cancel-3.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/gomp/cancel-1.c [new file with mode: 0644]

index 1e60d3a52c91f2186ce6e480d1e06f885524b6e7..350a73f88e93fe7ff06ea30fcd2248bd311419da 100644 (file)
@@ -1,6 +1,12 @@
 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
index 785fc4a7b380f141d63458cc06d700f5bdde79c7..0f25b6ecd39c2a48ed735594d32f52b85773d614 100644 (file)
@@ -8691,10 +8691,13 @@ finish_omp_cancel (tree clauses)
   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;
index 8b2cd793cdc2c424d9574e383612fe32592b9cb4..1aace97c0262ccf098348d3cd58679e7c42cfd91 100644 (file)
@@ -1,6 +1,15 @@
 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
diff --git a/gcc/testsuite/c-c++-common/gomp/cancel-2.c b/gcc/testsuite/c-c++-common/gomp/cancel-2.c
new file mode 100644 (file)
index 0000000..b69d48f
--- /dev/null
@@ -0,0 +1,10 @@
+/* { 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" } */
+  }
+}
diff --git a/gcc/testsuite/g++.dg/gomp/cancel-1.C b/gcc/testsuite/g++.dg/gomp/cancel-1.C
new file mode 100644 (file)
index 0000000..a6b1167
--- /dev/null
@@ -0,0 +1,26 @@
+// 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);
+}
diff --git a/gcc/testsuite/g++.dg/gomp/cancel-2.C b/gcc/testsuite/g++.dg/gomp/cancel-2.C
new file mode 100644 (file)
index 0000000..c9269e7
--- /dev/null
@@ -0,0 +1,20 @@
+// 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);
+}
diff --git a/gcc/testsuite/g++.dg/gomp/cancel-3.C b/gcc/testsuite/g++.dg/gomp/cancel-3.C
new file mode 100644 (file)
index 0000000..87e757b
--- /dev/null
@@ -0,0 +1,12 @@
+// { 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'" }
+  }
+}
diff --git a/gcc/testsuite/gcc.dg/gomp/cancel-1.c b/gcc/testsuite/gcc.dg/gomp/cancel-1.c
new file mode 100644 (file)
index 0000000..c283290
--- /dev/null
@@ -0,0 +1,12 @@
+/* { 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" } */
+  }
+}