From patchwork Fri May 31 13:54: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: 247962 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 722A42C02F7 for ; Fri, 31 May 2013 23:55:04 +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=BaCwfQI/4RSQPl0cyiAvIpcb6+NfQP93KUK41AS+w8UB0cBAv2 wMGGQtvI6KuZeXpu9kq7BAlZN8l32YMHh478iFLbSoYpDzDclA50c7YlopdZseOb j15D34dYgJw5Hl5xeCYhfo+YfAQOuPmKd4upiVu2F7f1sEahrE2A4y1ig= 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=tq1rVtZ8e2F6gRg+oX6M/sUElAA=; b=G9SPaBLhiUZ9K3SpK9wX 1JWe7LaLqt62VlsR2WVdPNFE0I/2FTPbU+IKKWvV5Aa3+KMWvRjNbTnyk3Ue6VQY fYvdN5NbrnwcPUq8SwUZnAC0965V84ByhQMHlKsvMRaJbEtL4ARqJ1m24jo9bajb L9eFwEPCODhkAfn3hv1mVgM= Received: (qmail 3146 invoked by alias); 31 May 2013 13:54:25 -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 3059 invoked by uid 89); 31 May 2013 13:54:24 -0000 X-Spam-SWARE-Status: No, score=-5.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_PASS, TW_FN autolearn=ham version=3.3.1 Received: from mga03.intel.com (HELO mga03.intel.com) (143.182.124.21) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 31 May 2013 13:54:23 +0000 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 31 May 2013 06:54:21 -0700 X-ExtLoop1: 1 Received: from fmsmsx108.amr.corp.intel.com ([10.19.9.228]) by azsmga001.ch.intel.com with ESMTP; 31 May 2013 06:54:20 -0700 Received: from fmsmsx102.amr.corp.intel.com (10.19.9.53) by FMSMSX108.amr.corp.intel.com (10.19.9.228) with Microsoft SMTP Server (TLS) id 14.3.123.3; Fri, 31 May 2013 06:54:20 -0700 Received: from fmsmsx101.amr.corp.intel.com ([169.254.1.135]) by FMSMSX102.amr.corp.intel.com ([169.254.2.160]) with mapi id 14.03.0123.003; Fri, 31 May 2013 06:54:20 -0700 From: "Iyer, Balaji V" To: "gcc-patches@gcc.gnu.org" CC: Steve Ellcey Subject: [PATCH] pr57457 Date: Fri, 31 May 2013 13:54:20 +0000 Message-ID: MIME-Version: 1.0 X-Virus-Found: No Hello Everyone, This patch will fix a bug reported in PR57457. One of the array notation function was not checking for NULL_TREE before accessing its fields. This patch should fix that issue. A test case is also added. Is this OK for trunk? Here are the ChangeLog Entries: gcc/c/ChangeLog 2013-05-31 Balaji V. Iyer * c-array-notation.c (is_cilkplus_reduce_builtin): Added a check for NULL_TREE parameter input. gcc/testsuite/ChangeLog 2013-05-31 Balaji V. Iyer PR c/57457 * c-c++-common/cilk-plus/AN/pr57457.c: New testcase. Thanks, Balaji V. Iyer. diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 828d7c8..e376276 100755 Binary files a/gcc/c/ChangeLog and b/gcc/c/ChangeLog differ diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c index 681e111..8d43fd9 100755 --- a/gcc/c/c-array-notation.c +++ b/gcc/c/c-array-notation.c @@ -140,6 +140,8 @@ length_mismatch_in_expr_p (location_t loc, tree **list, size_t x, size_t y) enum built_in_function is_cilkplus_reduce_builtin (tree fndecl) { + if (!fndecl) + return BUILT_IN_NONE; if (TREE_CODE (fndecl) == ADDR_EXPR) fndecl = TREE_OPERAND (fndecl, 0); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 20bf8b5..e1339db 100755 Binary files a/gcc/testsuite/ChangeLog and b/gcc/testsuite/ChangeLog differ diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457.c new file mode 100644 index 0000000..68a1fd8 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +/* This test has no array notation components in it and thus should compile + fine without crashing. */ + +typedef unsigned int size_t; +typedef int (*__compar_fn_t) (const void *, const void *); +extern void *bsearch (const void *__key, const void *__base, + size_t __nmemb, size_t __size, __compar_fn_t + __compar) + __attribute__ ((__nonnull__ (1, 2, 5))) ; +extern __inline __attribute__ ((__gnu_inline__)) void * +bsearch (const void *__key, const void *__base, size_t __nmemb, size_t + __size, + __compar_fn_t __compar) +{ + size_t __l, __u, __idx; + const void *__p; + int __comparison; + __l = 0; + __u = __nmemb; + while (__l < __u) + { + __idx = (__l + __u) / 2; + __p = (void *) (((const char *) __base) + + (__idx * __size)); + __comparison = (*__compar) (__key, + __p); + if (__comparison < 0) + __u = __idx; + else if (__comparison > 0) + __l = __idx + 1; + else + return (void *) + __p; + } + return ((void *)0); +}