Skip to content
Snippets Groups Projects
user avatar
Nathaniel Shead authored
In some cases we can access members of a namespace-scope class without
ever having performed name-lookup on it; this can occur when a
forward-declaration of the class is used as a return type, for
instance, or with PIMPL.

One possible approach would be to do name lookup in complete_type to
force lazy loading to occur, but this seems overly expensive for a
relatively rare case.  Instead, this patch generalises the existing
pending-entity support to handle this case as well.

Unfortunately this does mean that almost every class definition will be
added to the pending-entity table, and almost always unnecessarily, but
I don't see a good way to avoid this.

gcc/cp/ChangeLog:

	* module.cc (depset::DB_IS_MEMBER_BIT): Rename to...
	(depset::DB_IS_PENDING_BIT): ...this.
	(depset::is_member): Remove.
	(depset::is_pending_entity): New function.
	(depset::hash::make_dependency): Mark definitions of
	namespace-scope types as maybe-pending entities.
	(depset::hash::add_class_entities): Rename DB_IS_MEMBER_BIT to
	DB_IS_PENDING_BIT.
	(depset::hash::find_dependencies): Use is_pending_entity
	instead of is_member.
	(module_state::write_pendings): Likewise; adjust comment.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/inst-4_b.C: Adjust pending-entity count.
	* g++.dg/modules/member-def-1_c.C: Likewise.
	* g++.dg/modules/member-def-2_c.C: Likewise.
	* g++.dg/modules/tpl-spec-3_b.C: Likewise.
	* g++.dg/modules/tpl-spec-4_b.C: Likewise.
	* g++.dg/modules/tpl-spec-5_b.C: Likewise.
	* g++.dg/modules/class-9_a.H: New test.
	* g++.dg/modules/class-9_b.H: New test.
	* g++.dg/modules/class-9_c.C: New test.

Signed-off-by: default avatarNathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: default avatarJason Merrill <jason@redhat.com>
9f9afc65
History
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.