From patchwork Wed Nov 23 13:52:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 127309 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 3DC931007D2 for ; Thu, 24 Nov 2011 00:52:47 +1100 (EST) Received: (qmail 27211 invoked by alias); 23 Nov 2011 13:52:45 -0000 Received: (qmail 27203 invoked by uid 22791); 23 Nov 2011 13:52:44 -0000 X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL, BAYES_00, TVD_PH_BODY_ACCOUNTS_PRE 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:27 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id A856E2BB3A5; Wed, 23 Nov 2011 08:52:26 -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 j8V6PrY008A1; Wed, 23 Nov 2011 08:52:26 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 8E80D2BB3A3; Wed, 23 Nov 2011 08:52:26 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id 8AF7D92BF6; Wed, 23 Nov 2011 08:52:26 -0500 (EST) Date: Wed, 23 Nov 2011 08:52:26 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Aspect specifications on subprogram renaming declarations Message-ID: <20111123135226.GA6915@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 syntax of Ada 2012 accepts aspect specifications on renaming declarations, but no language-defined aspects exist for them, so that pre- and postconditions on these declarations must be rejected. Compiling db.ads in Ada 2012 mode must yield: db.ads:9:07: incorrect placement of aspect "PRE" db.ads:10:07: incorrect placement of aspect "POST" db.ads:11:06: incorrect placement of aspect "TEST_CASE" --- package DB is type Account is tagged record X : Integer; end record; procedure Open (It : out Account; V : Integer); procedure Op (It : out Account; V : Integer) renames Open with Pre => (V > 0), Post => (It.X = V), Test_Case => (Name => "existing account", Mode => Nominal, Ensures => T.X > 0); end DB; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-11-23 Ed Schonberg * sem_ch8.adb (Analyze_Subprogram_Renaming_Declaration): If the declaration has aspects, analyze them so they can be properly rejected. Index: sem_ch8.adb =================================================================== --- sem_ch8.adb (revision 181662) +++ sem_ch8.adb (working copy) @@ -52,6 +52,7 @@ with Sem_Ch4; use Sem_Ch4; with Sem_Ch6; use Sem_Ch6; with Sem_Ch12; use Sem_Ch12; +with Sem_Ch13; use Sem_Ch13; with Sem_Disp; use Sem_Disp; with Sem_Dist; use Sem_Dist; with Sem_Eval; use Sem_Eval; @@ -2848,6 +2849,13 @@ ("?redundant renaming, entity is directly visible", Name (N)); end if; + -- Implementation-defined aspect specifications can appear in a renaming + -- declaration, but not language-defined ones. + + if Has_Aspects (N) then + Analyze_Aspect_Specifications (N, New_S); + end if; + Ada_Version := Save_AV; Ada_Version_Explicit := Save_AV_Exp; end Analyze_Subprogram_Renaming;