Eric Botcazou 7f078d5b3e [Ada] Fix spurious instantiation error on private record type
This change was initially aimed at fixing a spurious instantiation error
due to a disambiguation issue which happens when a generic unit with two
formal type parameters is instantiated on a single actual type that is
private.

The compiler internally sets the Is_Generic_Actual_Type flag on the
actual subtypes built for the instantiation in order to ease the
disambiguation, but it would fail to set it on the full view if the
subtypes are private.  The change makes it so that the flag is properly
set and reset on the full view in this case.

But this uncovered an issue in Subtypes_Statically_Match, which was
relying on a stalled Is_Generic_Actual_Type flag set on a full view
outside of the instantiation to return a positive answer.  This bypass
was meant to solve an issue arising with a private discriminated record
type whose completion is a discriminated record type itself derived from
a private discriminated record type, which is used as actual type in an
instantiation in another unit, and the instantiation is used in a child
unit of the original unit.  In this case, the private and full views of
the generic actual type are swapped in the child unit, but there was a
mismatch between the chain of full and underlying full views of the
private discriminated record type and that of the generic actual type.

This secondary issue is solved by avoiding to skip the full view in the
preparation of the completion of the private subtype and by directly
constraining the underlying full view of the full view of the base type
instead of building an underlying full view from scratch.

2019-08-13  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* sem_ch3.adb (Build_Underlying_Full_View): Delete.
	(Complete_Private_Subtype): Do not set the full view on the
	private subtype here.  If the full base is itself derived from
	private, do not re-derive the parent type but instead constrain
	an existing underlying full view.
	(Prepare_Private_Subtype_Completion): Do not get to the
	underlying full view, if any.  Set the full view on the private
	subtype here.
	(Process_Full_View): Likewise.
	* sem_ch12.adb (Check_Generic_Actuals): Also set
	Is_Generic_Actual_Type on the full view if the type of the
	actual is private.
	(Restore_Private_Views): Also reset Is_Generic_Actual_Type on
	the full view if the type of the actual is private.
	* sem_eval.adb (Subtypes_Statically_Match): Remove bypass for
	generic actual types.

gcc/testsuite/

	* gnat.dg/generic_inst10.adb, gnat.dg/generic_inst10_pkg.ads:
	New testcase.

From-SVN: r274357
2019-08-13 08:08:32 +00:00
2019-08-09 23:02:08 +01:00
2019-07-15 21:17:16 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 2.1 GiB
Languages
C++ 31.9%
C 31.3%
Ada 12%
D 6.5%
Go 6.4%
Other 11.5%