From patchwork Fri Aug 16 13:44:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1148239 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-507127-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="BGxVEbvm"; 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 4694N32Yj1z9sDQ for ; Fri, 16 Aug 2019 23:45:53 +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=q3vSxLGbVkdf5lJ3 XniSPpOSWSwaEoo//qEvADmdQUvmGCx4Bx+pAA+8lp706gHfzW+dOPSn9xAVXlfC j4NKD3lcRxIv0E5BCUYbxpMb9j4fexpJFTPlVX9s5dc9ArS/f+PePzEAmb/rlvKI iG0pBBx/YgpkmiVFvCfwh96WLhQ= 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=eOIecdfXL5H5hCWQ59flv2 Xbins=; b=BGxVEbvmCT9orlL9H88KYgcaJEj2nga6hquB+ENlI2+Ni6SjXI5syr eOB13HweYnIxsTOtI6BtEHa3gJ9DOX2V0aHtbMZyG6O3U7eBoLIwtxa8JSlWeUWO 0mr1MRdSrQ1U4xPCZQozwuq/y7nXu1jUHJ6dkoVUoYQREwPZJK360= Received: (qmail 72853 invoked by alias); 16 Aug 2019 13:45:43 -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 50059 invoked by uid 89); 16 Aug 2019 13:45:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:build_r, UD:ad, H*M:home, H*MI:home 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, 16 Aug 2019 13:45:04 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id A68A182461 for ; Fri, 16 Aug 2019 15:45:01 +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 YJmyTsPqP9M6 for ; Fri, 16 Aug 2019 15:45:01 +0200 (CEST) Received: from arcturus.home (adijon-653-1-26-201.w90-6.abo.wanadoo.fr [90.6.61.201]) (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 7E56881382 for ; Fri, 16 Aug 2019 15:45:01 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Add guard to build_reconstructed_reference Date: Fri, 16 Aug 2019 15:44:36 +0200 Message-ID: <1613858.L1Fq68rkEG@arcturus.home> MIME-Version: 1.0 Hi, this adds a small guard to the new function build_reconstructed_reference for broken VIEW_CONVERT_EXPRs. Users can easily generate these in Ada through the generic function Ada.Unchecked_Conversion and they need to be accepted... Tested on x86_64-suse-linux, OK for the mainline? 2019-08-16 Eric Botcazou * tree-sra.c (build_reconstructed_reference): Return NULL_TREE instead of NULL. Add guard for broken VIEW_CONVERT_EXPRs. 2019-08-16 Eric Botcazou * gnat.dg/opt81.ad[sb]: New test. Index: tree-sra.c =================================================================== --- tree-sra.c (revision 274487) +++ tree-sra.c (working copy) @@ -1812,11 +1812,15 @@ build_reconstructed_reference (location_t, tree ba while (!types_compatible_p (TREE_TYPE (expr), TREE_TYPE (base))) { if (!handled_component_p (expr)) - return NULL; + return NULL_TREE; prev_expr = expr; expr = TREE_OPERAND (expr, 0); } + /* Guard against broken VIEW_CONVERT_EXPRs... */ + if (!prev_expr) + return NULL_TREE; + TREE_OPERAND (prev_expr, 0) = base; tree ref = unshare_expr (model->expr); TREE_OPERAND (prev_expr, 0) = expr;