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 bug in handling of initialization of controlled objects


Tested on i686-linux. Committed on mainline.

An initialization call for controlled objects is generated in different
contexts, including within the expansion of stream functions. In some
cases the current context and the initialize function have different views
of the type of the object. Routine Convert_View applies an unchecked
conversion when it is found that the views don't match (at this point the
types themselves are known to be correct). In some cases the routine has
to examine the base types of the underlying types, because discriminants
will introduce different subtypes for components in derivations.

Test case:
$ gcc -c bug.ads
--
with P; use P;

package Bug is
  type Derived is tagged record T : Prop; end record;
end Bug;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package P is
  type Prop (Bool : Boolean := False) is private;
private
  type Prop (Bool : Boolean := False) is record
    S : Unbounded_String := Null_Unbounded_String;
  end record;
end P;

2005-03-08  Ed Schonberg  <schonberg@adacore.com>

	* exp_ch7.adb (Convert_View): Use base types of underlying types when
	determining whether an unchecked conversion is needed for the argument
	of an initialization call.

Attachment: difs.15
Description: Text document


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