* [Ada] Improved runtime exception message for duplicated external tag
@ 2011-08-04 9:43 Arnaud Charlet
0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2011-08-04 9:43 UTC (permalink / raw)
To: gcc-patches; +Cc: Thomas Quinot
[-- Attachment #1: Type: text/plain, Size: 786 bytes --]
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 <quinot@adacore.com>
* 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.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1108 bytes --]
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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-08-04 9:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-04 9:43 [Ada] Improved runtime exception message for duplicated external tag Arnaud Charlet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).