From patchwork Wed Nov 23 13:52:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 127308 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 DD6011007D2 for ; Thu, 24 Nov 2011 00:52:37 +1100 (EST) Received: (qmail 26520 invoked by alias); 23 Nov 2011 13:52:36 -0000 Received: (qmail 26512 invoked by uid 22791); 23 Nov 2011 13:52:34 -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; Wed, 23 Nov 2011 13:52:19 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id CABE12BB3A9; Wed, 23 Nov 2011 08:52:18 -0500 (EST) 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 T445l71767NQ; Wed, 23 Nov 2011 08:52:18 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id A55CB2BB3A3; Wed, 23 Nov 2011 08:52:18 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id 9E56192BF6; Wed, 23 Nov 2011 08:52:18 -0500 (EST) Date: Wed, 23 Nov 2011 08:52:18 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Taft-amendment types and Ada 2012 type invariants Message-ID: <20111123135218.GA6900@adacore.com> MIME-Version: 1.0 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org The presence of a body freezes all entities previously declared in the current list of declarations, but this does not apply if the body does not come from source. A type invariant is transformed into a subprogram body which is placed at the end of the private part of the current package, but this body does not freeze incomplete types that may be declared in this private part. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-11-23 Ed Schonberg * freeze.adb (Freeze_All_Ent): An incomplete type is not frozen by a subprogram body that does not come from source. Index: freeze.adb =================================================================== --- freeze.adb (revision 181662) +++ freeze.adb (working copy) @@ -1342,7 +1342,9 @@ -- If an incomplete type is still not frozen, this may be a -- premature freezing because of a body declaration that follows. - -- Indicate where the freezing took place. + -- Indicate where the freezing took place. Freezing will happen + -- if the body comes from source, but not if it is internally + -- generated, for example as the body of a type invariant. -- If the freezing is caused by the end of the current declarative -- part, it is a Taft Amendment type, and there is no error. @@ -1360,8 +1362,9 @@ N_Protected_Body, N_Task_Body) or else Nkind (Bod) in N_Body_Stub) - and then - List_Containing (After) = List_Containing (Parent (E)) + and then + List_Containing (After) = List_Containing (Parent (E)) + and then Comes_From_Source (Bod) then Error_Msg_Sloc := Sloc (Next (After)); Error_Msg_NE