This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] fix in generic associations


Tested on i686-linux, committed on trunk

In Ada95, generic associations in formal packages and in instances have the
same syntax. In Ada2005 formal packages can also have box associations and
an others association. These must be excluded from instances, but the same
parsing routine is used in both cases, so the filtering must be done during
semantic analysis.

The following incorrect program must produce:

table_inst.adb:10:07: others association not allowed in an instance
table_inst.adb:16:07: box association not allowed in an instance

with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Strings.Wide_Unbounded;

procedure table_inst is

   package Table1 is
     new Ada.Containers.Indefinite_Hashed_Maps
      (Key_Type        => Natural,
      Element_Type    => Ada.Strings.Wide_Unbounded.Unbounded_Wide_String,
      others          => <>);

   package Table2 is
     new Ada.Containers.Indefinite_Hashed_Maps
      (Key_Type        => Natural,
      Element_Type    => Ada.Strings.Wide_Unbounded.Unbounded_Wide_String,
      Hash => <>);
begin
   null;
end table_inst;

A string literal has no syntactic descendants, and must be treated like other
literals. This is a small optimization. This also fixes scoping problems in
the back-end when the string is declared outside of a generic and the copy
of it in an instance carries an itype with the wrong scope.

gnat.dg/str1.adb must compile quietly.


This patch also simplifies the handling of formal interfaces that appear in the
interface list of other formal interfaces. it is best to treat them as full
type declarations, so that the code that collects progenitors can work both
with regular interfaces and with formal interfaces.

gnat.dg/interface4.adb must compile quietly.

2007-06-06  Ed Schonberg  <schonberg@adacore.com>
	    Javier Miranda  <miranda@adacore.com>

	* sem_ch12.adb (Analyze_Associations): Diagnose use of an others
	association in an instance.
	(Copy_Generic_Node): If the node is a string literal, no need to copy
	its descendants.
	(Is_Generic_Formal): For a formal subprogram, the declaration is the
	grandparent of the entity.
	(Analyze_Formal_Interface_Type): Transform into a full type declaration,
	to simplify handling of formal interfaces that derive from other formal
	interfaces.
	(Instantiate_Subprogram_Body): The defining unit name of the body of
	the instance should be a defining identifier.
	(Install_Formal_Packages): make global to the package, for use in
	instantiations of child units.
	(Analyze_Package_Instantiation): Do not attempt to set information on an
	enclosing master of an entry when expansion is disabled.
	(Instantiate_Type): If the actual is a tagged synchronized type and the
	generic ancestor is an interface, create a generic actual for the
	corresponding record.
	(Analyze_Formal_Derived_Interface_Type): Rewrite as a derived type
	declaration, to ensure that the interface list is processed correctly.
	(Inline_Instance_Body): If enclosing scope is an instance body, remove
	its entities from visibiility as well.
	(Pre_Analyze_Actuals): if the actual is an allocator with  constraints
	given with a named association, analyze the expression only, not the
	discriminant association itself.
	(Reset_Entity): If the analysis of a selected component is transformed
	into an expanded name in the prefix of a call with parameters, do not
	transform the original node into an expanded name, to prevent visibility
	errors in the case of nested generics.
	(Check_Private_View): For an array type, check whether the index types
	may need exchanging.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]