From patchwork Wed May 21 15:43:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 351231 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 5FE66140084 for ; Thu, 22 May 2014 01:44:12 +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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=k87DjIS15llGudawP/mOa/CIjMnKhXKctNyKckiu60Le3HUXYhOnm UpbHOO/PWCTBzYPwsmrSQxo+I3l0Vj55aPcEslaUnVA1zFwD+Fe+DNYk/Q8fnJd1 NRpK5wLKFfu8ivNi4psTQl7s4c2Ep3zeYnzBo32vKlNSk5Q8cue1hM= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=gWGd3oln+3yJCEYki/yMFFVtCvE=; b=M8jbX5YRXcKs7dl0oVBs y0w8m5oEvls4b3tLdp5GqWUz0P7r9GbIrYCgIj+TAuKhhBYueiw7aGHLgwMNJOaV 7G3BI02vQVhWy9OaPzDPfEzRNTQwoO1LexIqfmYSE2IFSJujpfLuH3X6LfaIgUHF gP/fxy8ahEXUGyZ2pN1xZgY= Received: (qmail 3960 invoked by alias); 21 May 2014 15:44:05 -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 3946 invoked by uid 89); 21 May 2014 15:44:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 May 2014 15:44:01 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4LFhxmc013853 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 21 May 2014 11:44:00 -0400 Received: from localhost (vpn1-4-15.ams2.redhat.com [10.36.4.15]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s4LFhwUH027030 for ; Wed, 21 May 2014 11:43:59 -0400 Date: Wed, 21 May 2014 16:43:58 +0100 From: Jonathan Wakely To: gcc-patches@gcc.gnu.org Subject: [patch] c/61271 fix ICE for invalid cilkplus array notation Message-ID: <20140521154358.GE6953@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This is only one of several cases in the PR, but one that's simple enough for me to write a test for and fix. Tested x86_64-linux, OK for trunk? commit 3ddcc29423746afb348c15160d33d3b1eec6fe12 Author: Jonathan Wakely Date: Wed May 21 16:20:25 2014 +0100 cp: PR c/61271 * cp-array-notation.c (cilkplus_an_triplet_types_ok_p): Fix condition. testsuite: PR c/61271 * g++.dg/cilk-plus/AN/array_function.cc: New. diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c index 0ff0967..ff82dee 100644 --- a/gcc/cp/cp-array-notation.c +++ b/gcc/cp/cp-array-notation.c @@ -26,7 +26,7 @@ An array notation expression has 4 major components: 1. The array name 2. Start Index - 3. Number of elements we need to acess (we call it length) + 3. Number of elements we need to access (we call it length) 4. Stride So, if we have something like A[0:5:2], we are accessing A[0], A[2], A[4], @@ -1418,7 +1418,7 @@ cilkplus_an_triplet_types_ok_p (location_t loc, tree start_index, tree length, error_at (loc, "stride of array notation triplet is not an integer"); return false; } - if (!TREE_CODE (type) == FUNCTION_TYPE) + if (TREE_CODE (type) == FUNCTION_TYPE) { error_at (loc, "array notation cannot be used with function type"); return false; diff --git a/gcc/testsuite/g++.dg/cilk-plus/AN/array_function.cc b/gcc/testsuite/g++.dg/cilk-plus/AN/array_function.cc new file mode 100644 index 0000000..b111e21 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/AN/array_function.cc @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +void f() { } +int main() +{ + f[0:1:1]; // { dg-error "function type" } +}