From patchwork Fri Feb 8 11:21:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1038575 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-495504-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="SS9c6Yi5"; 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 43wt6N36jSz9sLw for ; Fri, 8 Feb 2019 22:21:15 +1100 (AEDT) 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=AXU/7HREGhP+C2y+ OtGgREVwB4asSywf+xuHDaCym2QEKzykB/A5c+GE5Xh9YG4mUNA0CARkJLxjgIYf nmekUbHIEPHED8/zoXCtPyj2k56yiEW6q52t9nbyuDSbiG2xIBhxVcVWq4zq/u6p wUnAR7C+VjZDsPqPKCHB1hOIZ2g= 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=IHDP7sZN9TyzFI/EyOuSkh UN/Hc=; b=SS9c6Yi5wsAfHHvZ6GAG9DQRQ4tdON6zarC+I9Tw/lDfWYWoUeBPSH PJ5O3lTyQhAZ02PFmEC0f8SQuPHH+sJALkaVDvFeA2tcoU67oPb3iSYvXgB8eCN+ 0z7jGi1aonXU/hOjmDWlzX+ZMgQ0hLgrHg582+xN/pio241bTPrz0= Received: (qmail 75680 invoked by alias); 8 Feb 2019 11:21: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 75668 invoked by uid 89); 8 Feb 2019 11:21:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=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; Fri, 08 Feb 2019 11:21:07 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 169C281393 for ; Fri, 8 Feb 2019 12:21:05 +0100 (CET) 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 QInSzv7v2IQD for ; Fri, 8 Feb 2019 12:21:04 +0100 (CET) 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 E40C581392 for ; Fri, 8 Feb 2019 12:21:04 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix crash on very dynamic record types Date: Fri, 08 Feb 2019 12:21:02 +0100 Message-ID: <2158591.NH29ZIx2tU@polaris> MIME-Version: 1.0 This is a regression present on the mainline and 8 branch: in some specific circumstances, you can get a crash when max_size is called from the gimplifier on very dynamic record types. This makes the function a bit more robust. Tested on x86_64-suse-linux, applied on mainline and 8 branch. 2019-02-08 Eric Botcazou * gcc-interface/utils.c (max_size) : Be prepared for an operand with VOID_TYPE. Index: gcc-interface/utils.c =================================================================== --- gcc-interface/utils.c (revision 268508) +++ gcc-interface/utils.c (working copy) @@ -3642,7 +3642,10 @@ fntype_same_flags_p (const_tree t, tree /* EXP is an expression for the size of an object. If this size contains discriminant references, replace them with the maximum (if MAX_P) or - minimum (if !MAX_P) possible value of the discriminant. */ + minimum (if !MAX_P) possible value of the discriminant. + + Note that the expression may have already been gimplified,in which case + COND_EXPRs have VOID_TYPE and no operands, and this must be handled. */ tree max_size (tree exp, bool max_p) @@ -3714,11 +3717,15 @@ max_size (tree exp, bool max_p) return build_int_cst (type, max_p ? 1 : 0); case tcc_unary: + op0 = TREE_OPERAND (exp, 0); + if (code == NON_LVALUE_EXPR) - return max_size (TREE_OPERAND (exp, 0), max_p); + return max_size (op0, max_p); + + if (VOID_TYPE_P (TREE_TYPE (op0))) + return max_p ? TYPE_MAX_VALUE (type) : TYPE_MIN_VALUE (type); - op0 = max_size (TREE_OPERAND (exp, 0), - code == NEGATE_EXPR ? !max_p : max_p); + op0 = max_size (op0, code == NEGATE_EXPR ? !max_p : max_p); if (op0 == TREE_OPERAND (exp, 0)) return exp;