From patchwork Mon Apr 18 09:52:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 611634 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 3qpNk50SV4z9t3y for ; Mon, 18 Apr 2016 19:53:00 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=C/BsyNy6; 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:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=WckXY7kNifP5i45f9kDnFz1r0Y4MNH5mMHDIP687up+K8d5f1M KyvPICzCEYWl8yahHcUTbuag+4FVNplFxN88aU6JOTUM64OTAfqADLPou9MV4pTh nTGBwBqkrZ/Stcv6G6X2THTi9s2y4u+o/ctnS3NI4Qy2z+Sx44Rm+bxYQ= 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:cc:subject:message-id:mime-version:content-type; s= default; bh=gPJJzaiQA29lB/YCTQRf86iL7eM=; b=C/BsyNy6hpBrM0BCoahz 1Fc+elDS15Z+4Rlyqy50wPycFufNGD/ArlHWKSbDvbMnXZmJNoiMtYaq7kCmHZ+t Qwcrimk9tNyZiuVfcEI8J2qmN+fgJl1B2neLLzu2aq2vr/zNy9xk9lUnQgBLS+7z 9VniIzci5RBOuSYvLgCIKcA= Received: (qmail 98508 invoked by alias); 18 Apr 2016 09:52:42 -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 98438 invoked by uid 89); 18 Apr 2016 09:52:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=ali, D*adacore.com, formals, 235093 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 18 Apr 2016 09:52:32 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 779831168C0; Mon, 18 Apr 2016 05:52:30 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id j6JzzYHm3tlm; Mon, 18 Apr 2016 05:52:30 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 674951168BB; Mon, 18 Apr 2016 05:52:30 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id 64061457; Mon, 18 Apr 2016 05:52:30 -0400 (EDT) Date: Mon, 18 Apr 2016 05:52:30 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Spurious inlining error with function completed by an expression function Message-ID: <20160418095230.GA117794@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This patch fixes a spurious error on a call to an expression function whose expression is a call to a function whose full declaration is another expression function, when compiling with optimization and inlining warnings enabled. The following must compile quietly: gcc -c p.adb -gnatn -O -fdump-tree-optimized grep is_two p.adb.*.optimized --- with Q; use Q; procedure P is begin if not Is_Two (2) then raise Program_Error; end if; end; --- with R; use R; package Q is function Is_Two (I : Integer) return Boolean; private function Is_Two (I : Integer) return Boolean is (Is_One (I - 1)); end Q; --- package R is function Is_One (I : Integer) return Boolean is (I = 1); pragma Inline_Always (Is_One); end R; Tested on x86_64-pc-linux-gnu, committed on trunk 2016-04-18 Ed Schonberg * sem_ch6.adb (Analyze_Expression_Function): Set Inlined flag on the entity of a subprogram declaration that is completed by an expression function. Index: sem_ch6.adb =================================================================== --- sem_ch6.adb (revision 235093) +++ sem_ch6.adb (working copy) @@ -362,7 +362,7 @@ Set_Is_Inlined (Prev); -- If the expression function is a completion, the previous declaration - -- must come from source. We know already that appears in the current + -- must come from source. We know already that it appears in the current -- scope. The entity itself may be internally created if within a body -- to be inlined. @@ -371,6 +371,7 @@ and then not Is_Formal_Subprogram (Prev) then Set_Has_Completion (Prev, False); + Set_Is_Inlined (Prev); -- An expression function that is a completion freezes the -- expression. This means freezing the return type, and if it is @@ -411,7 +412,6 @@ -- Not clear that the backend can inline it in this case ??? if Has_Completion (Prev) then - Set_Is_Inlined (Prev); -- The formals of the expression function are body formals, -- and do not appear in the ali file, which will only contain