From patchwork Thu Jun 8 19:26:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 773448 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 3wkFlh0kckz9s0m for ; Fri, 9 Jun 2017 05:26:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="PVDtL3oS"; dkim-atps=neutral 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:reply-to:mime-version:content-type; q=dns; s=default; b=H2osfG1GltS70R2pe+401mMZEn4u0u6f+NmybNTUzbs x6N5cWQzR2oPtnoi/1N1W2rd7Zz3iaVVR2zS6PJryJuyUrHfVwGX90EDstDesnMr kvHhd07bKK9DBwY4DJ4NSMGdX8PA87JWDvBGyugetNACdcxZJwM/9SolzMdCOJJU = 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:reply-to:mime-version:content-type; s=default; bh=aSh7q4uBUeb4pw2B0x4MSfgm3dE=; b=PVDtL3oSP/nwb6Fj6 LReVHRMcEryFQagvT/hUwu5iejTCBJCgYX5bV+QQSCD0xlLvrvcVC66WdDzIABQx i6fm6TX5C6J1WUTt3eq30P9GLfescETEyCh0kw5RaCbPO6G10Lfy/GrhzzRjw4vD i8r8Ub60p4raJMgMYTgirJoGMU= Received: (qmail 79372 invoked by alias); 8 Jun 2017 19:26:08 -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 79029 invoked by uid 89); 8 Jun 2017 19:26:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=5x 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; Thu, 08 Jun 2017 19:26:06 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3CDEBC00861C for ; Thu, 8 Jun 2017 19:26:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3CDEBC00861C Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3CDEBC00861C Received: from tucnak.zalov.cz (ovpn-117-9.ams2.redhat.com [10.36.117.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D93D717108 for ; Thu, 8 Jun 2017 19:26:08 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v58JQ6QH011243 for ; Thu, 8 Jun 2017 21:26:06 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v58JQ54n011242 for gcc-patches@gcc.gnu.org; Thu, 8 Jun 2017 21:26:05 +0200 Date: Thu, 8 Jun 2017 21:26:05 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Fix ICE in OpenMP array section handling (PR c/81006) Message-ID: <20170608192605.GC2154@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes Hi! Apparently TYPE_MAX_VALUE (TYPE_DOMAIN (type)) on some arrays doesn't have expected sizetype type, but instead has ssizetype -1, which causes the size_binop verification to ICE. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk, 7.x, 6.x and 5.x (on the last one with additional xfail for the diagnostics - we only fix the ICE, but don't introduce something we failed to diagnose). 2017-06-08 Jakub Jelinek PR c/81006 * c-typeck.c (handle_omp_array_sections_1): Convert TYPE_MAX_VALUE to sizetype before size_binop. * semantics.c (handle_omp_array_sections_1): Convert TYPE_MAX_VALUE to sizetype before size_binop. * c-c++-common/gomp/pr81006.c: New test. Jakub --- gcc/c/c-typeck.c.jj 2017-06-02 09:01:07.000000000 +0200 +++ gcc/c/c-typeck.c 2017-06-08 14:46:53.940730138 +0200 @@ -12362,9 +12362,9 @@ handle_omp_array_sections_1 (tree c, tre && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) == INTEGER_CST) { - tree size = size_binop (PLUS_EXPR, - TYPE_MAX_VALUE (TYPE_DOMAIN (type)), - size_one_node); + tree size + = fold_convert (sizetype, TYPE_MAX_VALUE (TYPE_DOMAIN (type))); + size = size_binop (PLUS_EXPR, size, size_one_node); if (TREE_CODE (low_bound) == INTEGER_CST) { if (tree_int_cst_lt (size, low_bound)) --- gcc/cp/semantics.c.jj 2017-06-02 09:01:19.000000000 +0200 +++ gcc/cp/semantics.c 2017-06-08 14:40:34.141432913 +0200 @@ -4731,9 +4731,9 @@ handle_omp_array_sections_1 (tree c, tre && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) == INTEGER_CST) { - tree size = size_binop (PLUS_EXPR, - TYPE_MAX_VALUE (TYPE_DOMAIN (type)), - size_one_node); + tree size + = fold_convert (sizetype, TYPE_MAX_VALUE (TYPE_DOMAIN (type))); + size = size_binop (PLUS_EXPR, size, size_one_node); if (TREE_CODE (low_bound) == INTEGER_CST) { if (tree_int_cst_lt (size, low_bound)) --- gcc/testsuite/c-c++-common/gomp/pr81006.c.jj 2017-06-08 14:50:15.195219648 +0200 +++ gcc/testsuite/c-c++-common/gomp/pr81006.c 2017-06-08 14:49:50.000000000 +0200 @@ -0,0 +1,10 @@ +/* PR c/81006 */ +/* { dg-do compile } */ + +int a[] = {}; + +void foo() +{ + #pragma omp task depend(out: a[:]) /* { dg-error "zero length array section in .depend. clause" } */ + {} +}