re PR middle-end/58809 (ICE with complex variable in OpenMP reduction clause)
authorJakub Jelinek <jakub@redhat.com>
Thu, 23 Jan 2014 13:32:19 +0000 (14:32 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 23 Jan 2014 13:32:19 +0000 (14:32 +0100)
PR middle-end/58809
* c-typeck.c (c_finish_omp_clause): Reject MIN_EXPR, MAX_EXPR,
BIT_AND_EXPR, BIT_IOR_EXPR and BIT_XOR_EXPR on COMPLEX_TYPEs.

* semantics.c (finish_omp_reduction_clause): Reject
BIT_AND_EXPR, BIT_IOR_EXPR and BIT_XOR_EXPR on COMPLEX_TYPEs.

* c-c++-common/gomp/pr58809.c: New test.

From-SVN: r206962

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/gomp/pr58809.c [new file with mode: 0644]

index 3ec4fe7de16cde4d1e50a13d48f7c1ebe97f11a1..dca35d4c7ea9d60e4522c9866d6a7b18698fa7b3 100644 (file)
@@ -1,3 +1,9 @@
+2014-01-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/58809
+       * c-typeck.c (c_finish_omp_clause): Reject MIN_EXPR, MAX_EXPR,
+       BIT_AND_EXPR, BIT_IOR_EXPR and BIT_XOR_EXPR on COMPLEX_TYPEs.
+
 2014-01-22  Marek Polacek  <polacek@redhat.com>
 
        PR c/59891
index 7cb717a9749b013b0df3a1e42d5b15b2cede92e4..92304b0db9ec7cb7c67fac2650c845396e048daf 100644 (file)
@@ -11713,7 +11713,8 @@ c_finish_omp_clauses (tree clauses)
          need_implicitly_determined = true;
          t = OMP_CLAUSE_DECL (c);
          if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == NULL_TREE
-             && FLOAT_TYPE_P (TREE_TYPE (t)))
+             && (FLOAT_TYPE_P (TREE_TYPE (t))
+                 || TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE))
            {
              enum tree_code r_code = OMP_CLAUSE_REDUCTION_CODE (c);
              const char *r_name = NULL;
@@ -11723,8 +11724,14 @@ c_finish_omp_clauses (tree clauses)
                case PLUS_EXPR:
                case MULT_EXPR:
                case MINUS_EXPR:
+                 break;
                case MIN_EXPR:
+                 if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE)
+                   r_name = "min";
+                 break;
                case MAX_EXPR:
+                 if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE)
+                   r_name = "max";
                  break;
                case BIT_AND_EXPR:
                  r_name = "&";
@@ -11736,10 +11743,12 @@ c_finish_omp_clauses (tree clauses)
                  r_name = "|";
                  break;
                case TRUTH_ANDIF_EXPR:
-                 r_name = "&&";
+                 if (FLOAT_TYPE_P (TREE_TYPE (t)))
+                   r_name = "&&";
                  break;
                case TRUTH_ORIF_EXPR:
-                 r_name = "||";
+                 if (FLOAT_TYPE_P (TREE_TYPE (t)))
+                   r_name = "||";
                  break;
                default:
                  gcc_unreachable ();
index 671b36cc193cd3ba8b91013fcf109524be41b761..a16eb66a322c2924a028674808eb9f1f7d4b3406 100644 (file)
@@ -1,3 +1,9 @@
+2014-01-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/58809
+       * semantics.c (finish_omp_reduction_clause): Reject
+       BIT_AND_EXPR, BIT_IOR_EXPR and BIT_XOR_EXPR on COMPLEX_TYPEs.
+
 2014-01-22  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        PR c++/59482
index eb04266aee81f10a76910c4506051c0ac4cc3b3a..bba00f4839aeac0431e177d25a53335af1f4864a 100644 (file)
@@ -4971,6 +4971,10 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor)
       case BIT_AND_EXPR:
       case BIT_IOR_EXPR:
       case BIT_XOR_EXPR:
+       if (FLOAT_TYPE_P (type) || TREE_CODE (type) == COMPLEX_TYPE)
+         break;
+       predefined = true;
+       break;
       case TRUTH_ANDIF_EXPR:
       case TRUTH_ORIF_EXPR:
        if (FLOAT_TYPE_P (type))
index bf9f01dd814e6230becf361d8b132f87106ff814..2180cb81980df8c360749d5b1f332fa9f6b449de 100644 (file)
@@ -1,3 +1,8 @@
+2014-01-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/58809
+       * c-c++-common/gomp/pr58809.c: New test.
+
 2014-01-23  Dominique Dhumieres  <dominiq@lps.ens.fr>
 
        PR sanitizer/59897
diff --git a/gcc/testsuite/c-c++-common/gomp/pr58809.c b/gcc/testsuite/c-c++-common/gomp/pr58809.c
new file mode 100644 (file)
index 0000000..f4fd7c4
--- /dev/null
@@ -0,0 +1,31 @@
+/* PR middle-end/58809 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+_Complex int j;
+_Complex double d;
+
+void
+foo (void)
+{
+  #pragma omp parallel reduction (&:j) /* { dg-error "has invalid type for|user defined reduction not found for" } */
+    ;
+  #pragma omp parallel reduction (|:j) /* { dg-error "has invalid type for|user defined reduction not found for" } */
+    ;
+  #pragma omp parallel reduction (^:j) /* { dg-error "has invalid type for|user defined reduction not found for" } */
+    ;
+  #pragma omp parallel reduction (min:j) /* { dg-error "has invalid type for|user defined reduction not found for" } */
+    ;
+  #pragma omp parallel reduction (max:j) /* { dg-error "has invalid type for|user defined reduction not found for" } */
+    ;
+  #pragma omp parallel reduction (&:d) /* { dg-error "has invalid type for|user defined reduction not found for" } */
+    ;
+  #pragma omp parallel reduction (|:d) /* { dg-error "has invalid type for|user defined reduction not found for" } */
+    ;
+  #pragma omp parallel reduction (^:d) /* { dg-error "has invalid type for|user defined reduction not found for" } */
+    ;
+  #pragma omp parallel reduction (min:d) /* { dg-error "has invalid type for|user defined reduction not found for" } */
+    ;
+  #pragma omp parallel reduction (max:d) /* { dg-error "has invalid type for|user defined reduction not found for" } */
+    ;
+}