From patchwork Mon Mar 2 09:29:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 444990 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5D03714015A for ; Mon, 2 Mar 2015 20:29:12 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=PSBThHj2; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=BbhaU517A53S4XUd2imfEEaPKHYRAV9MAJMK7UmmbvxRl0PRLl 4XVOa1/1ijo2DjT+ip16XZeTvRHTmc8LPQ/1QAqK+r8/CJWt7mSfTiA1+/lY3n/m W3tQMng9K7xbNhvbc5FU6W8waWYAtO7czarSGVkdna2mK3tlL0qDwdKXo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=3XJCfbcld3V/JGh9W3SDxpypCyo=; b=PSBThHj2cYbzX5KfIreL tke0c982s1/tgs1JoPYG+jQFVny1lTiaMgjNNk7JAmwR4DIWjaNCI518cJqtmv0e tVSHQVZPe9A84snduT29ShMp/tTXy01L/9kodkHCebeJk+LcdkQhvYNUFAnog5Zv 7Nk8U2ctKvAfTRIaGZBv59g= Received: (qmail 119779 invoked by alias); 2 Mar 2015 09:29:04 -0000 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 Received: (qmail 119767 invoked by uid 89); 2 Mar 2015 09:29:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.6 required=5.0 tests=AWL, BAYES_50, FILL_THIS_FORM, FILL_THIS_FORM_LONG autolearn=no version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 02 Mar 2015 09:29:02 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 9E6011166EE; Mon, 2 Mar 2015 04:29:00 -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 FN5KNerQzTwo; Mon, 2 Mar 2015 04:29:00 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 8E1DD1166E4; Mon, 2 Mar 2015 04:29:00 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id 847F591A8C; Mon, 2 Mar 2015 04:29:00 -0500 (EST) Date: Mon, 2 Mar 2015 04:29:00 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Hristian Kirtchev Subject: [Ada] Output of errors related to Pre'Class, Pre_Class, Post'Class, Post_Class Message-ID: <20150302092900.GA15452@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) This patch takes advantage of the recently introduced mechanism that outputs special names _Pre and _Post to emit errors related to pre/postconditions. No change in behavior, no test. Tested on x86_64-pc-linux-gnu, committed on trunk 2015-03-02 Hristian Kirtchev * sem_prag.adb (Duplication_Error): Remove the special handling of 'Class or _Class in the context of pre/postconditions. (Process_Class_Wide_Condition): Remove the special handling of 'Class or _Class in the context of pre/postconditions. * sem_util.adb (Original_Aspect_Pragma_Name): Names Pre_Class and Post_Class no longer need to be converted to _Pre and _Post. * sem_util.ads (Original_Aspect_Pragma_Name): Update the comment on usage. Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 221101) +++ sem_prag.adb (working copy) @@ -21445,10 +21445,6 @@ procedure Replace_Types is new Traverse_Proc (Replace_Type); - -- Local variables - - Prag_Nam : constant Name_Id := Original_Aspect_Pragma_Name (N); - -- Start of processing for Process_Class_Wide_Condition begin @@ -21456,8 +21452,9 @@ -- dispatching type, therefore the aspect/pragma is illegal. if No (Disp_Typ) then + Error_Msg_Name_1 := Original_Aspect_Pragma_Name (N); + if From_Aspect_Specification (N) then - Error_Msg_Name_1 := Prag_Nam; Error_Msg_N ("aspect % can only be specified for a primitive operation " & "of a tagged type", Corresponding_Aspect (N)); @@ -21465,12 +21462,6 @@ -- The pragma is a source construct else - if Prag_Nam = Name_Precondition then - Error_Msg_Name_1 := Name_Pre_Class; - else - Error_Msg_Name_1 := Name_Post_Class; - end if; - Error_Msg_N ("pragma % can only be specified for a primitive operation " & "of a tagged type", N); @@ -24973,11 +24964,11 @@ procedure Duplication_Error (Prag : Node_Id; Prev : Node_Id) is Prag_From_Asp : constant Boolean := From_Aspect_Specification (Prag); - Prag_Nam : constant Name_Id := Original_Aspect_Pragma_Name (Prag); Prev_From_Asp : constant Boolean := From_Aspect_Specification (Prev); begin - Error_Msg_Sloc := Sloc (Prev); + Error_Msg_Sloc := Sloc (Prev); + Error_Msg_Name_1 := Original_Aspect_Pragma_Name (Prag); -- Emit a precise message to distinguish between source pragmas and -- pragmas generated from aspects. The ordering of the two pragmas is @@ -24989,43 +24980,15 @@ -- No error is emitted when both pragmas come from aspects because this -- is already detected by the general aspect analysis mechanism. - if Prag_Nam = Name_uPre then - Error_Msg_Name_1 := Name_Pre; - elsif Prag_Nam = Name_uPost then - Error_Msg_Name_1 := Name_Post; + if Prag_From_Asp and Prev_From_Asp then + null; + elsif Prag_From_Asp then + Error_Msg_N ("aspect % duplicates pragma declared #", Prag); + elsif Prev_From_Asp then + Error_Msg_N ("pragma % duplicates aspect declared #", Prag); else - Error_Msg_Name_1 := Prag_Nam; + Error_Msg_N ("pragma % duplicates pragma declared #", Prag); end if; - - -- The item appears as aspect XXX'Class or pragma XXX_Class - - if Class_Present (Prag) then - if Prag_From_Asp and Prev_From_Asp then - null; - elsif Prag_From_Asp then - Error_Msg_N - ("aspect `%'Class` duplicates pragma declared #", Prag); - elsif Prev_From_Asp then - Error_Msg_N - ("pragma `%_Class` duplicates aspect declared #", Prag); - else - Error_Msg_N - ("pragma `%_Class` duplicates pragma declared #", Prag); - end if; - - -- Otherwise the pragma appears in its normal form - - else - if Prag_From_Asp and Prev_From_Asp then - null; - elsif Prag_From_Asp then - Error_Msg_N ("aspect % duplicates pragma declared #", Prag); - elsif Prev_From_Asp then - Error_Msg_N ("pragma % duplicates aspect declared #", Prag); - else - Error_Msg_N ("pragma % duplicates pragma declared #", Prag); - end if; - end if; end Duplication_Error; ---------------------------------- Index: sem_util.adb =================================================================== --- sem_util.adb (revision 221101) +++ sem_util.adb (working copy) @@ -15538,15 +15538,12 @@ if Item_Nam = Name_Invariant then Item_Nam := Name_uInvariant; - elsif Nam_In (Item_Nam, Name_Post, Name_Post_Class) then + elsif Item_Nam = Name_Post then Item_Nam := Name_uPost; - elsif Nam_In (Item_Nam, Name_Pre, Name_Pre_Class) then + elsif Item_Nam = Name_Pre then Item_Nam := Name_uPre; - elsif Item_Nam = Name_Invariant then - Item_Nam := Name_uInvariant; - elsif Nam_In (Item_Nam, Name_Type_Invariant, Name_Type_Invariant_Class) then Index: sem_util.ads =================================================================== --- sem_util.ads (revision 221101) +++ sem_util.ads (working copy) @@ -1683,9 +1683,7 @@ -- returns the following values: -- -- Invariant -> Name_uInvariant - -- Post -> Name_uPost -- Post'Class -> Name_uPost - -- Pre -> Name_uPre -- Pre'Class -> Name_uPre -- Type_Invariant -> Name_uType_Invariant -- Type_Invariant'Class -> Name_uType_Invariant