From patchwork Wed Jun 12 22:00:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Iyer, Balaji V" X-Patchwork-Id: 250901 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id C7F152C0095 for ; Thu, 13 Jun 2013 08:00:39 +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:cc:subject:date:message-id:content-type:mime-version; q=dns; s=default; b=nFpKbMua3NszfNGZlre1Zg9VSjAyNBVWWpFxeHLKF9WL4C14VA ymzHWB4RtQ+RDE4msDFjDnzeodZQllNj3caPYwEdLj/bB37R/pwMuUUIsrNCFslr 3HLSiUB4cD0HqG4Ks334GAKrPP6ekv5MqP/IH7DGd8M1vAgkqG+KWx/nw= 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:cc:subject:date:message-id:content-type:mime-version; s= default; bh=wta+HSXkK8qGSqaQb+QUSC2zybY=; b=rWEgTb8tAaGmVdgt/4as +fQGbWfEg3OeymQZeITEhS+xymfV14tWrLoVyWa3J4MCpHUEKS34xBdcnwMGX62F bqc4LCOfJTljBL5ohAHQJ1hL+Ogila+3I4H4cOUO8IKIwkUu4xNs0vMwNQUcHgjr oNuhag4LWZ+ETBhJZ9+cLY8= Received: (qmail 10869 invoked by alias); 12 Jun 2013 22:00:32 -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 10801 invoked by uid 89); 12 Jun 2013 22:00:25 -0000 X-Spam-SWARE-Status: No, score=-5.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_PASS, TW_TM autolearn=ham version=3.3.1 Received: from mga14.intel.com (HELO mga14.intel.com) (143.182.124.37) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 12 Jun 2013 22:00:24 +0000 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 12 Jun 2013 15:00:22 -0700 X-ExtLoop1: 1 Received: from fmsmsx104.amr.corp.intel.com ([10.19.9.35]) by AZSMGA002.ch.intel.com with ESMTP; 12 Jun 2013 15:00:21 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX104.amr.corp.intel.com (10.19.9.35) with Microsoft SMTP Server (TLS) id 14.3.123.3; Wed, 12 Jun 2013 15:00:21 -0700 Received: from fmsmsx101.amr.corp.intel.com ([169.254.1.135]) by FMSMSX109.amr.corp.intel.com ([169.254.5.117]) with mapi id 14.03.0123.003; Wed, 12 Jun 2013 15:00:21 -0700 From: "Iyer, Balaji V" To: "gcc-patches@gcc.gnu.org" CC: "anna.m.tikhonova@gmail.com" Subject: [PATCH] fix for c/PR57577 Date: Wed, 12 Jun 2013 22:00:20 +0000 Message-ID: MIME-Version: 1.0 X-Virus-Found: No Hello Everyone, This patch fixes an ICE when rank mismatch occurs in a modify expression where the right-hand side is a function call. The crash is actually occuring in a while loop whose result is not used, i.e. dead code. I removed the dead code and things seem to work fine now. Tested on x86 and x86_64. I have also added test case. I am committing this patch as obvious. If anyone has objections I am willing to correct it (or even revert the patch). Here are the ChangeLog entries: gcc/c/ChangeLog +2013-06-12 Balaji V. Iyer + + * c-array-notation.c (build_array_notation_expr): Reject array notation + mismatch between LHS and RHS even inside a call_expr. Also, removed + a couple while statements that were dead code. + gcc/testsuite/ChangeLog +2013-06-12 Balaji V. Iyer + + PR c/57577 + * c-c++-common/cilk-plus/AN/pr57577.c: New testcase. + Thanks, Balaji V. Iyer. diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 72d182b..6179c3b 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2013-06-12 Balaji V. Iyer + + * c-array-notation.c (build_array_notation_expr): Reject array notation + mismatch between LHS and RHS even inside a call_expr. Also, removed + a couple while statements that were dead code. + 2013-06-10 Balaji V. Iyer * c-array-notation.c (fix_builtin_array_notation_fn): Fully folded diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c index 3285969..03b66b9 100644 --- a/gcc/c/c-array-notation.c +++ b/gcc/c/c-array-notation.c @@ -781,7 +781,7 @@ build_array_notation_expr (location_t location, tree lhs, tree lhs_origtype, rhs_list_size = vec_safe_length (rhs_list); lhs_list_size = vec_safe_length (lhs_list); - if (lhs_rank == 0 && rhs_rank != 0 && TREE_CODE (rhs) != CALL_EXPR) + if (lhs_rank == 0 && rhs_rank != 0) { tree rhs_base = rhs; if (TREE_CODE (rhs_base) == ARRAY_NOTATION_REF) @@ -802,17 +802,6 @@ build_array_notation_expr (location_t location, tree lhs, tree lhs_origtype, } if (lhs_rank != 0 && rhs_rank != 0 && lhs_rank != rhs_rank) { - tree lhs_base = lhs; - tree rhs_base = rhs; - - for (ii = 0; ii < lhs_rank; ii++) - lhs_base = ARRAY_NOTATION_ARRAY (lhs_base); - - while (rhs_base && TREE_CODE (rhs_base) != ARRAY_NOTATION_REF) - rhs_base = TREE_OPERAND (rhs_base, 0); - for (ii = 0; ii < rhs_rank; ii++) - rhs_base = ARRAY_NOTATION_ARRAY (rhs_base); - error_at (location, "rank mismatch between %qE and %qE", lhs, rhs); pop_stmt_list (an_init); return error_mark_node; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b167e4c..5c45e1a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-06-12 Balaji V. Iyer + + PR c/57577 + * c-c++-common/cilk-plus/AN/pr57577.c: New testcase. + 2013-06-12 Paolo Carlini PR c++/38958 diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57577.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57577.c new file mode 100755 index 0000000..fb3490e --- /dev/null +++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57577.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int A[10], B[10][10]; +int foo (int a); + +int main () { + A[:] = foo (B[:][:]); /* { dg-error "rank mismatch between" } */ + A[0] = foo (B[:][:]); /* { dg-error "cannot be scalar when" } */ + return 0; +}