aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2021-05-04 13:38:03 +0200
committerTobias Burnus <tobias@codesourcery.com>2021-05-04 14:42:26 +0200
commit1580fc764423bf89e9b853aaa8c65999e37ccb8b (patch)
tree36f6858bdddd10b59525a1dca23df6bd03bb93d1 /gcc/cp/semantics.c
parent9174343256c06f7879f480c59203c1615601055c (diff)
downloadgcc-1580fc764423bf89e9b853aaa8c65999e37ccb8b.zip
gcc-1580fc764423bf89e9b853aaa8c65999e37ccb8b.tar.gz
gcc-1580fc764423bf89e9b853aaa8c65999e37ccb8b.tar.bz2
OpenMP: Support complex/float in && and || reduction
C/C++ permit logical AND and logical OR also with floating-point or complex arguments by doing an unequal zero comparison; the result is an 'int' with value one or zero. Hence, those are also permitted as reduction variable, even though it is not the most sensible thing to do. gcc/c/ChangeLog: * c-typeck.c (c_finish_omp_clauses): Accept float + complex for || and && reductions. gcc/cp/ChangeLog: * semantics.c (finish_omp_reduction_clause): Accept float + complex for || and && reductions. gcc/ChangeLog: * omp-low.c (lower_rec_input_clauses, lower_reduction_clauses): Handle && and || with floating-point and complex arguments. gcc/testsuite/ChangeLog: * gcc.dg/gomp/clause-1.c: Use 'reduction(&:..)' instead of '...(&&:..)'. libgomp/ChangeLog: * testsuite/libgomp.c-c++-common/reduction-1.c: New test. * testsuite/libgomp.c-c++-common/reduction-2.c: New test. * testsuite/libgomp.c-c++-common/reduction-3.c: New test.
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 6224f49..0d590c3 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -6032,6 +6032,8 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor)
case PLUS_EXPR:
case MULT_EXPR:
case MINUS_EXPR:
+ case TRUTH_ANDIF_EXPR:
+ case TRUTH_ORIF_EXPR:
predefined = true;
break;
case MIN_EXPR:
@@ -6047,12 +6049,6 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor)
break;
predefined = true;
break;
- case TRUTH_ANDIF_EXPR:
- case TRUTH_ORIF_EXPR:
- if (FLOAT_TYPE_P (type))
- break;
- predefined = true;
- break;
default:
break;
}