From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17586 invoked by alias); 6 Sep 2011 10:35:50 -0000 Received: (qmail 17370 invoked by uid 22791); 6 Sep 2011 10:35:49 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 06 Sep 2011 10:35:35 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D33152BAF96; Tue, 6 Sep 2011 06:35:34 -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 lGPj0U5m9uHg; Tue, 6 Sep 2011 06:35:34 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id A15422BAF8E; Tue, 6 Sep 2011 06:35:34 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id A211A3FEE8; Tue, 6 Sep 2011 06:35:34 -0400 (EDT) Date: Tue, 06 Sep 2011 10:35:00 -0000 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Class-wide operations in instantations Message-ID: <20110906103534.GA27745@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="G4iJoqBmSsgzjUCe" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg00365.txt.bz2 --G4iJoqBmSsgzjUCe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1328 AI05-0071 stipulates that: In an instance, if the actual for a formal type FT with unknown discriminants is a class-wide type CT, and the generic has a formal subprogram with a box for a primitive operation of FT, the corresponding actual subprogram denoted by the default is a class-wide operation whose body is a dispatching call. This body is analyzed when the operation is frozen, and is attached to the Freeze_Actions of the corresponding entity. Freeze actions are not processed when expansion is disabled, so the body should not be placed in the tree in that case, to prevent problems in the back-end when compiling with -gnatct. The following must compile quietly: gcc -c -gnat05 -gnatct pck.ads --- with Ada.Containers.Indefinite_Doubly_Linked_Lists; with Ada.Finalization; use Ada.Finalization; package Pck is type Editor_Buffer is abstract new Controlled with null record; overriding function "=" (This : Editor_Buffer; Buffer : Editor_Buffer) return Boolean; package Buffer_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists (Editor_Buffer'Class); end Pck; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-09-06 Ed Schonberg * sem_ch8.adb (Check_Class_Wide_Actual): Do not generate body of class-wide operation if expansion is not enabled. --G4iJoqBmSsgzjUCe Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=difs Content-length: 767 Index: sem_ch8.adb =================================================================== --- sem_ch8.adb (revision 178565) +++ sem_ch8.adb (working copy) @@ -1859,9 +1859,12 @@ Statements (Handled_Statement_Sequence (New_Body))); -- The generated body does not freeze. It is analyzed when the - -- generated operation is frozen. + -- generated operation is frozen. This body is only needed if + -- expansion is enabled. - Append_Freeze_Action (Defining_Entity (New_Decl), New_Body); + if Expander_Active then + Append_Freeze_Action (Defining_Entity (New_Decl), New_Body); + end if; Result := Defining_Entity (New_Decl); end if; --G4iJoqBmSsgzjUCe--