This change fixes the circuitry responsible for enforcing the uniqueness of 'External_Tag attribute values. Previously uniqueness was checked at type elaboration time only for types that have an explicit External_Tag attribute definition clause. However we must also account for the fact that the default external tag for a type without any such clause may clash with that of a type with an explicit clause that has been elaborated previously.
The elaboration of the following unit must cause PROGRAM_ERROR to be raised: $ gnatmake -z -gnatws default_explicit_ext_tag.ads $ ./default_explicit_ext_tag raised PROGRAM_ERROR : duplicated external tag "DEFAULT_EXPLICIT_EXT_TAG.T2" package Default_Explicit_Ext_Tag is type T1 is tagged null record; for T1'External_Tag use "DEFAULT_EXPLICIT_EXT_TAG.T2"; type T2 is tagged null record; end Default_Explicit_Ext_Tag; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-07-17 Thomas Quinot <qui...@adacore.com> * exp_disp.adb (Make_DT, Make_VM_TSD): Do not omit Check_TSD call for types that do not have an explicit attribute definition clause for External_Tag, as their default tag may clash with an explicit tag defined for some other type.
Index: exp_disp.adb =================================================================== --- exp_disp.adb (revision 212640) +++ exp_disp.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2014, 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- -- @@ -6209,9 +6209,8 @@ end if; end if; - -- If the type has a representation clause which specifies its external - -- tag then generate code to check if the external tag of this type is - -- the same as the external tag of some other declaration. + -- Generate code to check if the external tag of this type is the same + -- as the external tag of some other declaration. -- Check_TSD (TSD'Unrestricted_Access); @@ -6226,16 +6225,16 @@ if not No_Run_Time_Mode and then Ada_Version >= Ada_2005 - and then Has_External_Tag_Rep_Clause (Typ) and then RTE_Available (RE_Check_TSD) and then not Debug_Flag_QQ then Append_To (Elab_Code, Make_Procedure_Call_Statement (Loc, - Name => New_Occurrence_Of (RTE (RE_Check_TSD), Loc), + Name => + New_Occurrence_Of (RTE (RE_Check_TSD), Loc), Parameter_Associations => New_List ( Make_Attribute_Reference (Loc, - Prefix => New_Occurrence_Of (TSD, Loc), + Prefix => New_Occurrence_Of (TSD, Loc), Attribute_Name => Name_Unchecked_Access)))); end if; @@ -6810,12 +6809,10 @@ Expressions => TSD_Aggr_List))); -- Generate: - -- Check_TSD - -- (TSD => TSD'Unrestricted_Access); + -- Check_TSD (TSD => TSD'Unrestricted_Access); if Ada_Version >= Ada_2005 and then Is_Library_Level_Entity (Typ) - and then Has_External_Tag_Rep_Clause (Typ) and then RTE_Available (RE_Check_TSD) and then not Debug_Flag_QQ then