From patchwork Wed Jul 13 10:02:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1655932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=RyblUV3X; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LjYB856rwz9ryY for ; Wed, 13 Jul 2022 20:04:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 783FF3887F65 for ; Wed, 13 Jul 2022 10:04:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 783FF3887F65 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1657706654; bh=jCBGlAAbKkxzH9i+ZiA2ky9PC3F15hI7eRtracS0QAE=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=RyblUV3XQnLmCycAC2D/tIV/1CFGg68dUgZm8JmFeA3VXjpNipqEC3RgaiMOTWKrW iXM6x+NDm1c4GsCKS0pgsoSnTAwLmP7+thTV3rdltjoUWieH1ojsqdt3oNlhlaSd4E SExUqRHtq3KUtPD4JL2hTP+WabFkRJwzDlmJN5u0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id 37CAC38515C9 for ; Wed, 13 Jul 2022 10:02:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 37CAC38515C9 Received: by mail-ed1-x534.google.com with SMTP id e15so13425476edj.2 for ; Wed, 13 Jul 2022 03:02:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=jCBGlAAbKkxzH9i+ZiA2ky9PC3F15hI7eRtracS0QAE=; b=DJIi3iEJoV21tI4AUMIo5TRO0C1u2gV1FHg4SwrLKZG1lqeyhXW6d6BViSoxy9xU6m 7L30eE4piFYHSqKxb97fQxFqwwHVMLHNV79IobgXwPQemXdyBBt1PGXAIksNy8pHhCng 1Q7+1Fz3uXt4G30mFnuHF0BX7EFv2n/KZKTtQyFbwiKoxdFNqVcOSGqArXLcgkHCQFUb ilOCcAywF+nCpCasSfU1CDC4zHxOpRtMz1BrNm5PdKPEo43d3LveLrzbhxpBN1+O5ano Tt9TiQDU9fobblj89HHEZmDQ4/VmZ/03TnzSygiBM/Kun0fJCm5YVrJNDs/hPrxHKoh/ RHdg== X-Gm-Message-State: AJIora9DfZmfpjC0XL5WSodmGXVyc/uxSozrGusMqjUcOBWPHpaEB4vt rPHHFAvHNqGnTe+UNRmWfl3GjnOb+a4aRg== X-Google-Smtp-Source: AGRyM1vLS7Hhmaj+loYZL9fvh1dIbpHd5z9X7XP9wtNulFqxv29yhsmFbIveaH0bIwTCe/bz4rsrYQ== X-Received: by 2002:a05:6402:4244:b0:43a:ded8:563b with SMTP id g4-20020a056402424400b0043aded8563bmr3878351edb.222.1657706572042; Wed, 13 Jul 2022 03:02:52 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id j21-20020a170906255500b006feb479fcb4sm4793818ejb.44.2022.07.13.03.02.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 03:02:51 -0700 (PDT) Date: Wed, 13 Jul 2022 10:02:51 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix crash on frontend inlining of functions with single returns Message-ID: <20220713100251.GA994589@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" When examining expression of the first declaration of the inlined body make sure that this declaration is in fact an object declaration. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * inline.adb (Has_Single_Return): Add guard for the subsequent call to Expression. diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -4648,6 +4648,7 @@ package body Inline is return Present (Declarations (N)) and then Present (First (Declarations (N))) + and then Nkind (First (Declarations (N))) = N_Object_Declaration and then Entity (Expression (Return_Statement)) = Defining_Identifier (First (Declarations (N))); end if;