Find a file
Patrick Palka f5c1224708 c++/modules: member alias tmpl partial inst [PR103994]
Alias templates are weird in that their specializations can appear in
both decl_specializations and type_specializations.  They're always in
the decl table, and additionally appear in the type table only at parse
time via finish_template_type.  There seems to be no good reason for
them to appear in both tables, and the code paths end up stepping over
each other in particular for a partial instantiation such as
A<B>::key_arg<T> in the below modules testcase: the type code path
(lookup_template_class) wants to set TI_TEMPLATE to the most general
template whereas the decl code path (tsubst_template_decl called during
instantiation of A<B>) already set TI_TEMPLATE to the partially
instantiated TEMPLATE_DECL.  This TI_TEMPLATE change ends up confusing
modules which decides to stream the logically equivalent TYPE_DECL and
TEMPLATE_DECL for this partial instantiation separately.

This patch fixes this by making lookup_template_class dispatch to
instantiate_alias_template early for alias template specializations.
In turn we now add such specializations only to the decl table.  This
admits some nice simplification in the modules code which otherwise has
to cope with such specializations appearing in both tables.

	PR c++/103994

gcc/cp/ChangeLog:

	* cp-tree.h (add_mergeable_specialization): Remove second
	parameter.
	* module.cc (depset::disc_bits::DB_ALIAS_TMPL_INST_BIT): Remove.
	(depset::disc_bits::DB_ALIAS_SPEC_BIT): Remove.
	(depset::is_alias_tmpl_inst): Remove.
	(depset::is_alias): Remove.
	(merge_kind::MK_tmpl_alias_mask): Remove.
	(merge_kind::MK_alias_spec): Remove.
	(merge_kind_name): Remove entries for alias specializations.
	(trees_out::core_vals) <case TEMPLATE_DECL>: Adjust after
	removing is_alias_tmpl_inst.
	(trees_in::decl_value): Adjust add_mergeable_specialization
	calls.
	(trees_out::get_merge_kind) <case depset::EK_SPECIALIZATION>:
	Use MK_decl_spec for alias template specializations.
	(trees_out::key_mergeable): Simplify after MK_tmpl_alias_mask
	removal.
	(depset:#️⃣:make_dependency): Adjust after removing
	DB_ALIAS_TMPL_INST_BIT.
	(specialization_add): Don't allow alias templates when !decl_p.
	(depset:#️⃣:add_specializations): Remove now-dead code
	accomodating alias template specializations in the type table.
	* pt.cc (lookup_template_class): Dispatch early to
	instantiate_alias_template for alias templates.  Simplify
	accordingly.
	(add_mergeable_specialization): Remove alias_p parameter and
	simplify accordingly.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/pr99425-1_b.H: s/alias/decl in dump scan.
	* g++.dg/modules/tpl-alias-1_a.H: Likewise.
	* g++.dg/modules/tpl-alias-2_a.H: New test.
	* g++.dg/modules/tpl-alias-2_b.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2024-03-07 16:39:20 -05:00
.github Minor formatting fix for newly-added file from previous commit 2023-11-01 19:28:56 -04:00
c++tools Update copyright years. 2024-01-03 12:19:35 +01:00
config Daily bump. 2024-01-12 00:17:54 +00:00
contrib contrib: Update test_mklog to correspond to mklog 2024-03-07 13:23:49 +01:00
fixincludes Daily bump. 2023-11-23 00:18:14 +00:00
gcc c++/modules: member alias tmpl partial inst [PR103994] 2024-03-07 16:39:20 -05:00
gnattools Update Copyright year in ChangeLog files 2024-01-03 11:35:18 +01:00
gotools Daily bump. 2023-11-04 00:16:45 +00:00
include Daily bump. 2024-03-01 00:16:41 +00:00
INSTALL
libada Update copyright years. 2024-01-03 12:19:35 +01:00
libatomic Daily bump. 2024-02-15 00:17:50 +00:00
libbacktrace Daily bump. 2024-03-03 00:17:08 +00:00
libcc1 Daily bump. 2024-03-01 00:16:41 +00:00
libcody Update Copyright year in ChangeLog files 2024-01-03 11:35:18 +01:00
libcpp Daily bump. 2024-02-23 00:16:46 +00:00
libdecnumber Update copyright years. 2024-01-03 12:19:35 +01:00
libffi Daily bump. 2023-10-27 00:17:12 +00:00
libgcc Daily bump. 2024-02-23 00:16:46 +00:00
libgfortran Fortran: Fix issue with using snprintf function. 2024-03-06 19:57:05 -08:00
libgm2 Daily bump. 2024-02-26 00:16:54 +00:00
libgo libgo: bump libgo version for GCC 14 release 2024-02-05 11:28:30 -08:00
libgomp Daily bump. 2024-03-07 00:17:38 +00:00
libgrust Update copyright years. 2024-02-21 13:51:26 +01:00
libiberty Daily bump. 2024-02-20 00:17:58 +00:00
libitm Daily bump. 2024-02-06 00:18:46 +00:00
libobjc Update copyright years. 2024-01-03 12:19:35 +01:00
libphobos Daily bump. 2024-03-04 00:16:47 +00:00
libquadmath Daily bump. 2024-01-04 00:18:45 +00:00
libsanitizer Daily bump. 2024-02-17 00:17:08 +00:00
libssp Daily bump. 2024-02-07 00:18:31 +00:00
libstdc++-v3 libstdc++: Do not define lock-free atomic aliases if not fully lock-free [PR114103] 2024-03-07 20:55:25 +00:00
libvtv Update copyright years. 2024-01-03 12:19:35 +01:00
lto-plugin Update copyright years. 2024-01-03 12:19:35 +01:00
maintainer-scripts Daily bump. 2023-11-14 12:23:39 +00:00
zlib Daily bump. 2023-10-23 00:16:43 +00:00
.dir-locals.el
.gitattributes
.gitignore *: add modern gettext 2023-11-14 00:47:11 +01:00
ABOUT-NLS
ar-lib
ChangeLog Daily bump. 2024-03-05 00:18:04 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in LoongArch: Reimplement multilib build option handling. 2023-09-15 10:42:12 +08:00
config.guess
config.rpath
config.sub
configure LoongArch: Don't falsely claim gold supported in toplevel configure 2024-02-23 18:13:25 +08:00
configure.ac LoongArch: Don't falsely claim gold supported in toplevel configure 2024-02-23 18:13:25 +08:00
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
depcomp
install-sh
libtool-ldflags
libtool.m4 Build: fix error in fixinclude configure 2023-11-22 11:54:33 +01:00
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
MAINTAINERS MAINTAINERS: Add myself to write after approval 2024-03-04 14:42:17 +08:00
Makefile.def gccrs: Fix missing build dependency 2024-01-16 16:23:02 +01:00
Makefile.in gccrs: Fix missing build dependency 2024-01-16 16:23:02 +01:00
Makefile.tpl Pass GUILE down to subdirectories 2024-01-09 08:02:31 -07:00
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
SECURITY.txt SECURITY.txt: Drop "exploitable" in reference to hardening issues 2024-01-09 10:49:01 -05:00
symlink-tree
test-driver
ylwrap

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.