This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 1/3] Fix logic bug in Cilk Plus array expansion


The Cilk Plus code may sometimes turn a COND_EXPR into an
error_mark_node for no good reason.  This can be seen by compiling the
test case c-c++-common/cilk-plus/CK/pr60469.c with both gcc and g++ and
observing the differences of the -fdump-tree-original dumps:

With gcc, we get the following code in the GENERIC dump:

finally
  {
    _Cilk_sync;
    D.1897.worker->current_stack_frame = D.1897.call_parent;
    __cilkrts_pop_frame (&D.1897);
    if (D.1897.flags != 16777216)
      {
        __cilkrts_leave_frame (&D.1897);
      }
  }

Whereas with g++ we get

finally
  {
    _Cilk_sync;
    D.2387.worker->current_stack_frame = D.2387.call_parent;
    __cilkrts_pop_frame (&D.2387);
    <<< error >>>
  }

Notice that the COND_EXPR is replaced with an << error >> in the g++
dump.

This patch fixes the COND_EXPR handling within Cilk Plus.  I think the
cause is a simple typo/logic bug.

gcc/cp/ChangeLog:

	* cp-array-notation.c (cp_expand_cond_array_notations): Return
	error_mark_node only if find_rank failed, not if it was
	successful.
---
 gcc/cp/cp-array-notation.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c
index 8862af1..3a6d773 100644
--- a/gcc/cp/cp-array-notation.c
+++ b/gcc/cp/cp-array-notation.c
@@ -807,8 +807,8 @@ cp_expand_cond_array_notations (tree orig_stmt)
       if (!find_rank (EXPR_LOCATION (cond), cond, cond, true, &cond_rank)
 	  || !find_rank (EXPR_LOCATION (yes_expr), yes_expr, yes_expr, true,
 			 &yes_rank)
-	  || find_rank (EXPR_LOCATION (no_expr), no_expr, no_expr, true,
-			&no_rank))
+	  || !find_rank (EXPR_LOCATION (no_expr), no_expr, no_expr, true,
+			 &no_rank))
 	return error_mark_node;
       /* If the condition has a zero rank, then handle array notations in body
 	 separately.  */
-- 
2.7.0.rc3.56.g64157c6.dirty


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]