From patchwork Tue Sep 5 09:17:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 810028 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-461467-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="wLmmLqb0"; dkim-atps=neutral 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 3xmh203HpRz9s7m for ; Tue, 5 Sep 2017 19:17:27 +1000 (AEST) 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:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=feBJg2SPJFyCzAR2 Z6s69fo3C5PnORq+DnU6cGqEdpw7fsqabSodE6zMSTyyf8NUCfV7x7CR6XPpvrpV r33JbPeTp2V1m8enV6n0AXip1BHNejfaMzX+gn35uSU+wjrhfrsNMsKKS33+kNHM C5HQV1/MYKl2jOaRbHCHIhWkyfM= 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:mime-version:content-type :content-transfer-encoding; s=default; bh=s6HO+0dq/GNoPEvwn5eEaw nPUnM=; b=wLmmLqb0iXw2JzFHFZeU4QyCEdzvFkI8L3tO63kOmFCafVlejJIOWI AzL1f5arskWmyvn36JIWFJNO6OTLLHHByti4tiXGhfxsu3qcUi7LiO4PTsp2jvd+ GJECLwuW8p9ith5gYp2Thcm1DbZX6HMjHogxxwK+siNLhSjlSPDz0= Received: (qmail 33590 invoked by alias); 5 Sep 2017 09:17:20 -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 33554 invoked by uid 89); 5 Sep 2017 09:17:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 05 Sep 2017 09:17:13 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id C544F822CA for ; Tue, 5 Sep 2017 11:17:10 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WcqT9liscpGA for ; Tue, 5 Sep 2017 11:17:10 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 94A1782266 for ; Tue, 5 Sep 2017 11:17:10 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix ICE on type witn zero precision Date: Tue, 05 Sep 2017 11:17:09 +0200 Message-ID: <2161599.Jq0VYmRpBJ@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 This is a regression present on the mainline, 7 and 6 branches, in the form of an ICE during tree-ccp, which is confused by a type witn zero precision. Tested on x86_64-suse-linux, applied on mainline, 7 and 6 branches. 2017-09-05 Eric Botcazou * gcc-interface/utils.c (unchecked_convert): When the result type is a non-biased integral type with size 0, set the result to 0 directly. 2017-09-05 Eric Botcazou * gnat.dg/specs/uc2.ads: New test. Index: gcc-interface/utils.c =================================================================== --- gcc-interface/utils.c (revision 251700) +++ gcc-interface/utils.c (working copy) @@ -5257,20 +5257,26 @@ unchecked_convert (tree type, tree expr, ? TYPE_RM_SIZE (etype) : TYPE_SIZE (etype)) == 0))) { - tree base_type - = gnat_type_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)), - type_unsigned_for_rm (type)); - tree shift_expr - = convert (base_type, - size_binop (MINUS_EXPR, - TYPE_SIZE (type), TYPE_RM_SIZE (type))); - expr - = convert (type, - build_binary_op (RSHIFT_EXPR, base_type, - build_binary_op (LSHIFT_EXPR, base_type, - convert (base_type, expr), - shift_expr), - shift_expr)); + if (integer_zerop (TYPE_RM_SIZE (type))) + expr = build_int_cst (type, 0); + else + { + tree base_type + = gnat_type_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)), + type_unsigned_for_rm (type)); + tree shift_expr + = convert (base_type, + size_binop (MINUS_EXPR, + TYPE_SIZE (type), TYPE_RM_SIZE (type))); + expr + = convert (type, + build_binary_op (RSHIFT_EXPR, base_type, + build_binary_op (LSHIFT_EXPR, base_type, + convert (base_type, + expr), + shift_expr), + shift_expr)); + } } /* An unchecked conversion should never raise Constraint_Error. The code