From patchwork Wed Jun 23 10:21:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 56666 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]) by ozlabs.org (Postfix) with SMTP id A7B59101086 for ; Wed, 23 Jun 2010 20:22:03 +1000 (EST) Received: (qmail 8222 invoked by alias); 23 Jun 2010 10:21:59 -0000 Received: (qmail 8207 invoked by uid 22791); 23 Jun 2010 10:21:57 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Jun 2010 10:21:48 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id B4EE0CB024B; Wed, 23 Jun 2010 12:21:51 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YZFM4GFnl6iA; Wed, 23 Jun 2010 12:21:51 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id 9FB6ACB01F8; Wed, 23 Jun 2010 12:21:51 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 7D42CD9BA8; Wed, 23 Jun 2010 12:21:51 +0200 (CEST) Date: Wed, 23 Jun 2010 12:21:51 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Secondary stack usage and operators that rename functions Message-ID: <20100623102151.GA2065@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes 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 To determine whether a function that returns a record type uses the secondary stack, we examine the expressions of each component definition and return true if any of them is a function call that itself uses the secondary stack. This patch corrects an omission: the call may have been written as a operator in prefix or infix notation. The following must compile and execute quietly: ---- with Ada.Strings.Unbounded;use Ada.Strings.Unbounded; pragma Warnings (Off); with system.secondary_stack; use system.secondary_stack; procedure SS_Leak is function "+" (Item : in String) return Unbounded_String renames To_Unbounded_String; type Rate_Record is record Feed_Id : Unbounded_String := +"Y"; end record; procedure P is x : Rate_Record; begin null; end; Top : Mark_Id := SS_Mark; begin for I in 1 .. 5 loop P; if SS_Mark /= Top then raise Constraint_Error; end if; end loop; end SS_Leak; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-23 Ed Schonberg * sem_res.adb (Uses_SS): The expression that initializes a controlled component of a record type may be a user-defined operator that is rewritten as a function call. Index: sem_res.adb =================================================================== --- sem_res.adb (revision 161265) +++ sem_res.adb (working copy) @@ -906,10 +906,12 @@ package body Sem_Res is Expr := Original_Node (Expression (Parent (Comp))); -- Return True if the expression is a call to a function - -- (including an attribute function such as Image) with - -- a result that requires a transient scope. + -- (including an attribute function such as Image, or a + -- user-defined operator) with a result that requires a + -- transient scope. if (Nkind (Expr) = N_Function_Call + or else Nkind (Expr) in N_Op or else (Nkind (Expr) = N_Attribute_Reference and then Present (Expressions (Expr)))) and then Requires_Transient_Scope (Etype (Expr))