From patchwork Mon Jun 16 20:13:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Zamyatin, Igor" X-Patchwork-Id: 360233 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 585AA1400CF for ; Tue, 17 Jun 2014 06:13: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=NYo HI6tEybeT0LdvD32DAqEc5L7czI4FwydCVd4NrVozb0PylnNDcHbi3vdeQLq5zcj atu1v4lZx4IOUOmcfEIdq9IDqJD+F7P7ubWEoUzwEFbLMW2+zmhVwP/tW2maXQRu XRK9EUitXm4zBqs9E6oUO9r7sVjT5DIPMr0k3MIY= 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=+Mi/3XAxO Nq8tPQKkn44DtnUIe8=; b=R1A+gkHZ6mgDq0TaPZAITnz1w2UsJv6WZEKBozy7G g0GeBvGNO0GLvRBnM/3S8YBzxQUfT1twWVl+KFXJL+4GCp/xTgDC6F4zyL++tiMG Y5IhaOhu/VZRNMVXMxt3RGuOkXY46ol1Uh49uprhxk5izJzESSLPrV7/f/y3pCMO 5Q= Received: (qmail 30092 invoked by alias); 16 Jun 2014 20:13:15 -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 30055 invoked by uid 89); 16 Jun 2014 20:13:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.5 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: mga03.intel.com Received: from mga03.intel.com (HELO mga03.intel.com) (143.182.124.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Jun 2014 20:13:09 +0000 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 16 Jun 2014 13:13:07 -0700 X-ExtLoop1: 1 Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by azsmga001.ch.intel.com with ESMTP; 16 Jun 2014 13:13:06 -0700 Received: from irsmsx106.ger.corp.intel.com (163.33.3.31) by IRSMSX102.ger.corp.intel.com (163.33.3.155) with Microsoft SMTP Server (TLS) id 14.3.123.3; Mon, 16 Jun 2014 21:13:05 +0100 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.245]) by IRSMSX106.ger.corp.intel.com ([169.254.8.14]) with mapi id 14.03.0123.003; Mon, 16 Jun 2014 21:13:05 +0100 From: "Zamyatin, Igor" To: "GCC Patches (gcc-patches@gcc.gnu.org)" Subject: [PATCH, Cilk+, PR57541] Additional fix for issues witn array notations Date: Mon, 16 Jun 2014 20:13:04 +0000 Message-ID: <0EFAB2BDD0F67E4FB6CCC8B9F87D756956489DB3@IRSMSX101.ger.corp.intel.com> MIME-Version: 1.0 X-IsSubscribed: yes Hi All! The patch fixes ICE in array notation for the cases of incorrect arguments of Cilk+ builtins and undeclared initial index. Is it ok for trunk and 4.9? Thanks, Igor diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 54d0de7..56e1b0b 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,12 @@ +2014-06-16  Igor Zamyatin  + +       PR middle-end/57541 +       * c-array-notation.c (fix_builtin_array_notation_fn): +       Check for 0 arguments in builtin call. Check that bultin argument is +       correct. +       * c-parser.c (c_parser_array_notation): Check for incorrect initial +       index. + diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 053155a..a2c66a8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2014-06-16  Igor Zamyatin  + +       PR middle-end/57541 +       * cp-array-notation.c (expand_sec_reduce_builtin): +       Check that bultin argument is correct. +       * call.c (build_cxx_call): Check for 0 arguments in builtin call. + diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f9f03d9..f08600c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-06-16  Igor Zamyatin  + +       PR middle-end/57541 +       * c-c++-common/cilk-plus/AN/pr57541.c: New case added. +       * c-c++-common/cilk-plus/AN/pr57541-2.c: New test. + diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c index b4015b8..67a8931 100644 --- a/gcc/c/c-array-notation.c +++ b/gcc/c/c-array-notation.c @@ -214,6 +214,13 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree *new_var)    if (an_type == BUILT_IN_NONE)      return NULL_TREE; +  /* Builtin call should contain at least one argument.  */ +  if (call_expr_nargs (an_builtin_fn) == 0) +    { +      error_at (EXPR_LOCATION (an_builtin_fn), "Invalid builtin arguments"); +      return error_mark_node; +    } +    if (an_type == BUILT_IN_CILKPLUS_SEC_REDUCE        || an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MUTATING)      { @@ -238,7 +245,10 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree *new_var)      return error_mark_node;      if (rank == 0) -    return an_builtin_fn; +    { +      error_at (location, "Invalid builtin arguments"); +      return error_mark_node; +    }    else if (rank > 1            && (an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MAX_IND                || an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MIN_IND)) diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index abd636c..a04a23e 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -14097,7 +14097,7 @@ c_parser_array_notation (location_t loc, c_parser *parser, tree initial_index,    tree value_tree = NULL_TREE, type = NULL_TREE, array_type = NULL_TREE;    tree array_type_domain = NULL_TREE;   -  if (array_value == error_mark_node) +  if (array_value == error_mark_node || initial_index == error_mark_node)      {        /* No need to continue.  If either of these 2 were true, then an error          must be emitted already.  Thus, no need to emit them twice.  */ diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 75a6a4a..e021a38 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7415,6 +7415,11 @@ build_cxx_call (tree fn, int nargs, tree *argarray,           || bif == BUILT_IN_CILKPLUS_SEC_REDUCE           || bif == BUILT_IN_CILKPLUS_SEC_REDUCE_MUTATING)         { +         if (call_expr_nargs (fn) == 0) +           { +             error_at (EXPR_LOCATION (fn), "Invalid builtin arguments"); +             return error_mark_node; +           }           /* for bif == BUILT_IN_CILKPLUS_SEC_REDUCE_ALL_ZERO or              BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_ZERO or              BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_NONZERO or diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c index 0538e55..b45449b 100644 --- a/gcc/cp/cp-array-notation.c +++ b/gcc/cp/cp-array-notation.c @@ -250,7 +250,10 @@ expand_sec_reduce_builtin (tree an_builtin_fn, tree *new_var)    if (!find_rank (location, an_builtin_fn, an_builtin_fn, true, &rank))        return error_mark_node;    if (rank == 0) -    return an_builtin_fn; +    { +      error_at (location, "Invalid builtin arguments"); +      return error_mark_node; +    }    else if (rank > 1            && (an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MAX_IND                || an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MIN_IND)) diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541-2.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541-2.c new file mode 100644 index 0000000..83325a7 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541-2.c @@ -0,0 +1,15 @@ +/* PR middle-end/57541 */ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int foo1 () +{ +  int a; +  a = __sec_reduce_add (1); /* { dg-error "Invalid builtin arguments" } */ +} + +int foo2 () +{ +  int a; +  a = __sec_reduce_add (); /* { dg-error "Invalid builtin arguments" } */ +} diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541.c index 9bff079..f379e46 100755 --- a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541.c +++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541.c @@ -1,9 +1,10 @@ +/* PR middle-end/57541 */ /* { dg-do compile } */ /* { dg-options "-fcilkplus" } */  int A[10]; -int main () { +int foo () {    /* C compiler uses the term "undeclared" whereas C++ compiler uses      "not declared".  Thus, grepping for declared seem to be the easiest.  */ @@ -13,5 +14,13 @@ int main () {    A[l:s:c]; } -/* { dg-message "note: each" "defined" { target c }  10 } */ +int foo1 (int N) { + +  char c = (char)N; +  short s = (short)N; +  A[l:s:c]; /* { dg-error "declared" } */ +} + + +/* { dg-message "note: each" "defined" { target c }  11 } */