gcc/include
Jason Merrill 810bcc0015 c++: constrained hidden friends [PR109751]
r13-4035 avoided a problem with overloading of constrained hidden friends by
checking satisfaction, but checking satisfaction early is inconsistent with
the usual late checking and can lead to hard errors, so let's not do that
after all.

We were wrongly treating the different instantiations of the same friend
template as the same function because maybe_substitute_reqs_for was failing
to actually substitute in the case of a non-template friend.  But we don't
actually need to do the substitution anyway, because [temp.friend] says that
such a friend can't be the same as any other declaration.

After fixing that, instead of a redefinition error we got an ambiguous
overload error, fixed by allowing constrained hidden friends to coexist
until overload resolution, at which point they probably won't be in the same
ADL overload set anyway.

And we avoid mangling collisions by following the proposed mangling for
these friends as a member function with an extra 'F' before the name.  I
demangle this by just adding [friend] to the name of the function because
it's not feasible to reconstruct the actual scope of the function since the
mangling ABI doesn't distinguish between class and namespace scopes.

	PR c++/109751

gcc/cp/ChangeLog:

	* cp-tree.h (member_like_constrained_friend_p): Declare.
	* decl.cc (member_like_constrained_friend_p): New.
	(function_requirements_equivalent_p): Check it.
	(duplicate_decls): Check it.
	(grokfndecl): Check friend template constraints.
	* mangle.cc (decl_mangling_context): Check it.
	(write_unqualified_name): Check it.
	* pt.cc (uses_outer_template_parms_in_constraints): Fix for friends.
	(tsubst_friend_function): Don't check satisfaction.

include/ChangeLog:

	* demangle.h (enum demangle_component_type): Add
	DEMANGLE_COMPONENT_FRIEND.

libiberty/ChangeLog:

	* cp-demangle.c (d_make_comp): Handle DEMANGLE_COMPONENT_FRIEND.
	(d_count_templates_scopes): Likewise.
	(d_print_comp_inner): Likewise.
	(d_unqualified_name): Handle member-like friend mangling.
	* testsuite/demangle-expected: Add test.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-friend11.C: Now works.  Add template.
	* g++.dg/cpp2a/concepts-friend15.C: New test.
2023-08-22 14:34:53 -04:00
..
cuda libgomp: cuda.h and omp_target_memcpy_rect cleanup 2023-07-29 13:25:03 +02:00
gdb Update copyright years. 2023-01-16 11:52:17 +01:00
ansidecl.h Update copyright years. 2023-01-16 11:52:17 +01:00
btf.h Update copyright years. 2023-01-16 11:52:17 +01:00
ChangeLog Daily bump. 2023-08-08 00:17:37 +00:00
ChangeLog-9103
ChangeLog.jit
collectorAPI.h gprofng: a new GNU profiler 2023-08-07 22:59:38 +02:00
COPYING
COPYING3
ctf.h Synchronize include/ctf.h with upstream binutils/libctf. 2023-04-28 14:20:24 +01:00
demangle.h c++: constrained hidden friends [PR109751] 2023-08-22 14:34:53 -04:00
dwarf2.def Update copyright years. 2023-01-16 11:52:17 +01:00
dwarf2.h Update copyright years. 2023-01-16 11:52:17 +01:00
dyn-string.h Update copyright years. 2023-01-16 11:52:17 +01:00
environ.h Update copyright years. 2023-01-16 11:52:17 +01:00
fibheap.h Update copyright years. 2023-01-16 11:52:17 +01:00
filenames.h Update copyright years. 2023-01-16 11:52:17 +01:00
floatformat.h Update copyright years. 2023-01-16 11:52:17 +01:00
fnmatch.h Update copyright years. 2023-01-16 11:52:17 +01:00
gcc-c-fe.def Update copyright years. 2023-01-16 11:52:17 +01:00
gcc-c-interface.h Update copyright years. 2023-01-16 11:52:17 +01:00
gcc-cp-fe.def Update copyright years. 2023-01-16 11:52:17 +01:00
gcc-cp-interface.h Update copyright years. 2023-01-16 11:52:17 +01:00
gcc-interface.h Update copyright years. 2023-01-16 11:52:17 +01:00
getopt.h Update copyright years. 2023-01-16 11:52:17 +01:00
gomp-constants.h OpenMP: Cleanups related to the 'present' modifier 2023-06-12 18:15:28 +02:00
hashtab.h Update copyright years. 2023-01-16 11:52:17 +01:00
hsa_ext_amd.h
hsa_ext_image.h
hsa.h
leb128.h Update copyright years. 2023-01-16 11:52:17 +01:00
libcollector.h gprofng: a new GNU profiler 2023-08-07 22:59:38 +02:00
libfcollector.h gprofng: a new GNU profiler 2023-08-07 22:59:38 +02:00
libiberty.h Update copyright years. 2023-01-16 11:52:17 +01:00
longlong.h Update copyright years. 2023-01-16 11:52:17 +01:00
lto-symtab.h Update copyright years. 2023-01-16 11:52:17 +01:00
md5.h Update copyright years. 2023-01-16 11:52:17 +01:00
objalloc.h Update copyright years. 2023-01-16 11:52:17 +01:00
obstack.h Update copyright years. 2023-01-16 11:52:17 +01:00
partition.h Update copyright years. 2023-01-16 11:52:17 +01:00
plugin-api.h PR29961, plugin-api.h: "Could not detect architecture endianess" 2023-08-07 22:59:36 +02:00
safe-ctype.h Update copyright years. 2023-01-16 11:52:17 +01:00
sha1.h Update copyright years. 2023-01-16 11:52:17 +01:00
simple-object.h Update copyright years. 2023-01-16 11:52:17 +01:00
sort.h Update copyright years. 2023-01-16 11:52:17 +01:00
splay-tree.h Update copyright years. 2023-01-16 11:52:17 +01:00
symcat.h Update copyright years. 2023-01-16 11:52:17 +01:00
timeval-utils.h Update copyright years. 2023-01-16 11:52:17 +01:00
vtv-change-permission.h Update copyright years. 2023-01-16 11:52:17 +01:00
xregex2.h Update copyright years. 2023-01-16 11:52:17 +01:00
xregex.h
xtensa-config.h Update copyright years. 2023-01-16 11:52:17 +01:00
xtensa-dynconfig.h gcc-4.5 build fixes 2023-08-07 22:59:36 +02:00