From patchwork Thu Aug 4 09:43:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 108395 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 83AC5B6F7B for ; Thu, 4 Aug 2011 19:43:53 +1000 (EST) Received: (qmail 3597 invoked by alias); 4 Aug 2011 09:43:51 -0000 Received: (qmail 3587 invoked by uid 22791); 4 Aug 2011 09:43:50 -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:43:36 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 889A92BB371; Thu, 4 Aug 2011 05:43:35 -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 hXheeg+4p25e; Thu, 4 Aug 2011 05:43:35 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 75A2F2BB2A4; Thu, 4 Aug 2011 05:43:35 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 731D892A55; Thu, 4 Aug 2011 05:43:35 -0400 (EDT) Date: Thu, 4 Aug 2011 05:43:35 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Thomas Quinot Subject: [Ada] Improved runtime exception message for duplicated external tag Message-ID: <20110804094335.GA11964@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 This change improves the exception message associated with PROGRAM_ERROR for duplicated external tag by including the value of the offending external tag. The following compilation must raise Program_Error with the indicated exception message: $ gnatmake -z dup_ext_tag.ads $ ./dup_ext_tag raised PROGRAM_ERROR : duplicated external tag foo pragma Ada_2005; package Dup_Ext_Tag is type T1 is tagged null record; for T1'External_Tag use "foo"; type T2 is tagged null record; for T2'External_Tag use "foo"; end Dup_Ext_Tag; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-04 Thomas Quinot * a-tags.adb (Check_TSD): When raising PROGRAM_ERROR for a duplicated external tag, include the value of the external tag in the exception message. Index: a-tags.adb =================================================================== --- a-tags.adb (revision 177275) +++ a-tags.adb (working copy) @@ -310,6 +310,13 @@ procedure Check_TSD (TSD : Type_Specific_Data_Ptr) is T : Tag; + E_Tag_Len : constant Integer := Length (TSD.External_Tag); + E_Tag : String (1 .. E_Tag_Len); + for E_Tag'Address use TSD.External_Tag.all'Address; + pragma Import (Ada, E_Tag); + + -- Start of processing for Check_TSD + begin -- Verify that the external tag of this TSD is not registered in the -- runtime hash table. @@ -317,7 +324,7 @@ T := External_Tag_HTable.Get (To_Address (TSD.External_Tag)); if T /= null then - raise Program_Error with "duplicated external tag"; + raise Program_Error with "duplicated external tag " & E_Tag; end if; end Check_TSD; @@ -718,6 +725,8 @@ -- Length -- ------------ + -- Should this be reimplemented using the strlen GCC builtin??? + function Length (Str : Cstring_Ptr) return Natural is Len : Integer;