From patchwork Fri Feb 20 11:49:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 441926 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 7E884140283 for ; Fri, 20 Feb 2015 22:49:17 +1100 (AEDT) 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=F0bbFgnOOKn6xueSYXC35tIGS8ZqXfgskg37aS3FhjIg+4dkr+ 7LtkB8BXxT4JgizKh6fBfSHD7rMKh4JwayFDInqsHs2pB+k9ojhGPVPusb7GL011 C/xpTQNM5URq0YSDHpJoVudx7mUtlf5OBepZbT+ISXKY1SFD4C6t7bZtI= 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=XGdBNYStS/2Xh5DnjPZ7OBECoG0=; b=VYb6BG6B36u+a1egQtX5 a2TV0osBc8X+uWoLAgnen2t3mfvwtlxGS8CNqekZaqT2BhdYntQbuA7TiULUdTK7 i3BGUhSOdDz5leHRkTGcseb/zpY+/wGtSpUZPkXTSkRh4u8qvJ/3CNyt9p6RR+d3 iajIevibZ3ujNjk01YPOzXo= Received: (qmail 16140 invoked by alias); 20 Feb 2015 11:49:08 -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 16128 invoked by uid 89); 20 Feb 2015 11:49:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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; Fri, 20 Feb 2015 11:49:06 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id E5846116805; Fri, 20 Feb 2015 06:49:04 -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 xB7KppbRKhKT; Fri, 20 Feb 2015 06:49:04 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [IPv6:2620:20:4000:0:7a2b:cbff:fe60:cb11]) by rock.gnat.com (Postfix) with ESMTP id D4777116804; Fri, 20 Feb 2015 06:49:04 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id D0AF091A8C; Fri, 20 Feb 2015 06:49:04 -0500 (EST) Date: Fri, 20 Feb 2015 06:49:04 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Better error message for illegal Invariant'class aspect Message-ID: <20150220114904.GA16474@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Within the compiler class-wide aspects use a leading-underscore internal identifier. If the placement of the aspect is illegal, the error message must mention the original form of the aspect. Compiling class_a.ads must yield: class_a.ads:5:10: aspect "Type_Invariant_Class" only allowed for private type declared in visible part --- package Class_A is type A_T is tagged private; private type A_T is tagged null record with Type_Invariant'Class => True; end Class_A; Tested on x86_64-pc-linux-gnu, committed on trunk 2015-02-20 Ed Schonberg * sem_prag.adb (Fix_Error): For an illegal Type_Invariant'Class aspect, use name that mentions Class explicitly, rather than compiler-internal name. Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 220850) +++ sem_prag.adb (working copy) @@ -5918,6 +5918,17 @@ -- Get name from corresponding aspect Error_Msg_Name_1 := Original_Aspect_Name (N); + + if Class_Present (N) then + + -- Replace the name with a leading underscore used + -- internally, with a name that is more user-friendly. + + if Error_Msg_Name_1 = Name_uType_Invariant then + Error_Msg_Name_1 := Name_Type_Invariant_Class; + end if; + end if; + end if; -- Return possibly modified message