From patchwork Sat Jul 12 09:51:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Zamyatin, Igor" X-Patchwork-Id: 369286 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id F29DF1400BE for ; Sat, 12 Jul 2014 19:52:23 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=GPU KVEXAhdXlQbgtVfYRbwIsDAgVeyUq/MbW8rT8B5LvF5NDxS49y9uC2Z6XqFFxRGP FkSw7jx+DJYeQIweJJJCdq/8Z0s0QT4GDSUSRtyJ2QR0/FQv1AfJA3Bf6sRQKGHU 7eApGK25Py6aDXgJhRopypif8q+n0fAOcWE3XLY0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=default; bh=8ujbaBpVV ThYgpBGSA9RrUb6MTg=; b=pV0fw0Jubf31eJBgMiX/qhD/M4CDcnfs17kkNLOQE cnAt2DdpOs8rHOK90/adS9S5vmlQbjppWGkAM/e9pZXvMydGudvsNG8GJtVdn2YQ 9z5SFMITYzLrZoutvAwF99oNEudCUKLamH74cta3I6/ATdGrYQbpf59rISsrQDfN g8= Received: (qmail 2394 invoked by alias); 12 Jul 2014 09:52:16 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 2377 invoked by uid 89); 12 Jul 2014 09:52:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.8 required=5.0 tests=AWL, BAYES_00, BODY_8BITS, GARBLED_BODY, MIME_CHARSET_FARAWAY, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 X-HELO: mga09.intel.com Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 12 Jul 2014 09:52:14 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 12 Jul 2014 02:46:25 -0700 X-ExtLoop1: 1 Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by orsmga002.jf.intel.com with ESMTP; 12 Jul 2014 02:51:58 -0700 Received: from irsmsx154.ger.corp.intel.com (163.33.192.96) by IRSMSX102.ger.corp.intel.com (163.33.3.155) with Microsoft SMTP Server (TLS) id 14.3.123.3; Sat, 12 Jul 2014 10:51:57 +0100 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.56]) by IRSMSX154.ger.corp.intel.com ([169.254.12.68]) with mapi id 14.03.0123.003; Sat, 12 Jul 2014 10:51:57 +0100 From: "Zamyatin, Igor" To: "GCC Patches (gcc-patches@gcc.gnu.org)" Subject: [PATCH 2/3, Cilk+] Fix for PR61455 Date: Sat, 12 Jul 2014 09:51:56 +0000 Message-ID: <0EFAB2BDD0F67E4FB6CCC8B9F87D756969A815B1@IRSMSX101.ger.corp.intel.com> MIME-Version: 1.0 X-IsSubscribed: yes Hi! This patch adds correct handling of declarations whit initializations that contain array notation. It fixes ICE in PR61455. Regtested for x86_64 (along with the first patch in the chain). Ok for trunk/4.9? Thanks, Igor gcc/c-family/ChangeLog: 2014-07-08  Igor Zamyatin  PR middle-end/61455 * array-notation-common.c (extract_array_notation_exprs): Handling of DECL_EXPR added. gcc/c/ChangeLog: 2014-07-08  Igor Zamyatin  PR middle-end/61455 * c-array-notation.c (expand_array_notations): Handling of DECL_EXPR added. gcc/cp/ChangeLog: 2014-07-08  Igor Zamyatin  PR middle-end/61455 * cp-array-notation.c (expand_array_notation_exprs): Handling of DECL_EXPR improved. Changed handling for INIT_EXPR. gcc/testsuite/ChangeLog: 2014-07-08  Igor Zamyatin  PR middle-end/61455 * c-c++-common/cilk-plus/AN/pr61455.c: New test. * c-c++-common/cilk-plus/AN/pr61455-2.c: Likewise. diff --git a/gcc/c-family/array-notation-common.c b/gcc/c-family/array-notation-common.c index c010039..84f6f45 100644 --- a/gcc/c-family/array-notation-common.c +++ b/gcc/c-family/array-notation-common.c @@ -329,6 +329,14 @@ extract_array_notation_exprs (tree node, bool ignore_builtin_fn,        vec_safe_push (*array_list, node);        return;      } +  if (TREE_CODE (node) == DECL_EXPR) +    { +      tree x = DECL_EXPR_DECL (node); +      if (DECL_INITIAL (x)) +       extract_array_notation_exprs (DECL_INITIAL (x), +                                     ignore_builtin_fn, +                                     array_list); +    }    else if (TREE_CODE (node) == STATEMENT_LIST)      {        tree_stmt_iterator ii_tsi; diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c index 67a8931..597adc9 100644 --- a/gcc/c/c-array-notation.c +++ b/gcc/c/c-array-notation.c @@ -1265,6 +1265,25 @@ expand_array_notations (tree *tp, int *walk_subtrees, void *)                                          rhs_loc, rhs, TREE_TYPE (rhs));        }        break; +    case DECL_EXPR: +      { +       tree x = DECL_EXPR_DECL (*tp); +       if (DECL_INITIAL (x)) +         { +           location_t loc = DECL_SOURCE_LOCATION (x); +           tree lhs = x; +           tree rhs = DECL_INITIAL (x); +           DECL_INITIAL (x) = NULL; +           tree new_modify_expr = build_modify_expr (loc, lhs, +                                                     TREE_TYPE (lhs), +                                                     NOP_EXPR, +                                                     loc, rhs, +                                                     TREE_TYPE(rhs)); +           expand_array_notations (&new_modify_expr, walk_subtrees, NULL); +           *tp = new_modify_expr; +         } +      } +      break;      case CALL_EXPR:        *tp = fix_array_notation_call_expr (*tp);        break; diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c index b45449b..31253ff 100644 --- a/gcc/cp/cp-array-notation.c +++ b/gcc/cp/cp-array-notation.c @@ -1148,13 +1148,13 @@ expand_array_notation_exprs (tree t)      case PARM_DECL:      case NON_LVALUE_EXPR:      case NOP_EXPR: -    case INIT_EXPR:      case ADDR_EXPR:      case ARRAY_REF:      case BIT_FIELD_REF:      case VECTOR_CST:      case COMPLEX_CST:        return t; +    case INIT_EXPR:      case MODIFY_EXPR:        if (contains_array_notation_expr (t))         t = expand_an_in_modify_expr (loc, TREE_OPERAND (t, 0), NOP_EXPR, @@ -1176,13 +1176,24 @@ expand_array_notation_exprs (tree t)         return t;        }      case DECL_EXPR: -      { -       tree x = DECL_EXPR_DECL (t); -       if (t && TREE_CODE (x) != FUNCTION_DECL) +      if (contains_array_notation_expr (t)) +       { +         tree x = DECL_EXPR_DECL (t);           if (DECL_INITIAL (x)) -           t = expand_unary_array_notation_exprs (t); +           { +             location_t loc = DECL_SOURCE_LOCATION (x); +             tree lhs = x; +             tree rhs = DECL_INITIAL (x); +             DECL_INITIAL (x) = NULL; +             tree new_modify_expr = build_modify_expr (loc, lhs, +                                                       TREE_TYPE (lhs), +                                                       NOP_EXPR, +                                                       loc, rhs, +                                                       TREE_TYPE(rhs)); +             t = expand_array_notation_exprs (new_modify_expr); +           } +       }        return t; -      }      case STATEMENT_LIST:        {         tree_stmt_iterator i; diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61455-2.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61455-2.c new file mode 100644 index 0000000..60b4248 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61455-2.c @@ -0,0 +1,13 @@ +/* PR c++/61455 */ +/* { dg-options "-fcilkplus" } */ + +int a[3] = {2, 3, 4}; + +int main () +{ +  int c = 10; +  int b = __sec_reduce_add(a[:]); +  if (b+c != 19) +    __builtin_abort(); +  return 0; +} diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61455.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61455.c new file mode 100644 index 0000000..35a11b6 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61455.c @@ -0,0 +1,9 @@ +/* PR c++/61455 */ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +void foo () +{ +  int a[2]; +  int b = a[:]; /* { dg-error "cannot be scalar" } */ +}