re PR middle-end/58809 (ICE with complex variable in OpenMP reduction clause)

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
This commit is contained in:
Jakub Jelinek 2014-01-23 14:32:19 +01:00 committed by Jakub Jelinek
parent 7fd841e250
commit 652fea3922
6 changed files with 64 additions and 3 deletions

View 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

View 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 ();

View 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

View 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))

View 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

View file

@ -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" } */
;
}