From patchwork Thu Aug 4 09:18:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 108388 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 8BD47B6F7C for ; Thu, 4 Aug 2011 19:18:40 +1000 (EST) Received: (qmail 28028 invoked by alias); 4 Aug 2011 09:18:37 -0000 Received: (qmail 28014 invoked by uid 22791); 4 Aug 2011 09:18:36 -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; Thu, 04 Aug 2011 09:18:22 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B3A642BB018; Thu, 4 Aug 2011 05:18:21 -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 OBey3sp8Tr0N; Thu, 4 Aug 2011 05:18:21 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 96FC62BAFDB; Thu, 4 Aug 2011 05:18:21 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 87A2D92A55; Thu, 4 Aug 2011 05:18:21 -0400 (EDT) Date: Thu, 4 Aug 2011 05:18:21 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [Ada] Issue warning for missing -gnat2012 switch on aspect X'Class Message-ID: <20110804091821.GA5328@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 When encountering aspect syntax in a mode where aspects are not allowed (language version < Ada 2012), the compiler was issuing a useful warning in most cases, but not on aspects X'Class. This is now fixed. Compiling the following code raises the error: $ gcc -c p.ads p.ads:3:06: aspect specification is an Ada 2012 feature p.ads:3:06: unit must be compiled with -gnat2012 switch package P is procedure Proc (X : out Boolean) with Post'Class => X; end P; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-04 Yannick Moy * par-ch13.adb (Aspect_Specifications_Present): recognize "with Identifier'Class =>" as an aspect, so that a meaningful warning is issued in Strict mode. * par.adb: Fix typos in comments. Index: par-ch13.adb =================================================================== --- par-ch13.adb (revision 177274) +++ par-ch13.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -89,9 +89,9 @@ Result := Token = Tok_Arrow; end if; - -- If earlier than Ada 2012, check for valid aspect identifier followed - -- by an arrow, and consider that this is still an aspect specification - -- so we give an appropriate message. + -- If earlier than Ada 2012, check for valid aspect identifier (possibly + -- completed with 'CLASS) followed by an arrow, and consider that this + -- is still an aspect specification so we give an appropriate message. else if Get_Aspect_Id (Token_Name) = No_Aspect then @@ -100,10 +100,26 @@ else Scan; -- past aspect name - if Token /= Tok_Arrow then - Result := False; + Result := False; - else + if Token = Tok_Arrow then + Result := True; + + elsif Token = Tok_Apostrophe then + Scan; -- past apostrophe + + if Token = Tok_Identifier + and then Token_Name = Name_Class + then + Scan; -- past CLASS + + if Token = Tok_Arrow then + Result := True; + end if; + end if; + end if; + + if Result then Restore_Scan_State (Scan_State); Error_Msg_SC ("|aspect specification is an Ada 2012 feature"); Error_Msg_SC ("\|unit must be compiled with -gnat2012 switch"); Index: par.adb =================================================================== --- par.adb (revision 177337) +++ par.adb (working copy) @@ -858,8 +858,8 @@ -- attempt at an aspect specification. The default is more strict for -- Ada versions before Ada 2012 (where aspect specifications are not -- permitted). Note: this routine never checks the terminator token - -- for aspects so it does not matter whether the aspect speficiations - -- are terminated by semicolon or some other character + -- for aspects so it does not matter whether the aspect specifications + -- are terminated by semicolon or some other character. procedure P_Aspect_Specifications (Decl : Node_Id;