diff options
author | Nathan Sidwell <nathan@acm.org> | 2017-12-15 15:04:59 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2017-12-15 15:04:59 +0000 |
commit | 0cf4820dd596a5884fb59c2c9874ed100a7ff614 (patch) | |
tree | 599aa3e7811f0d64352939a93b471f1440562272 /gcc/cp/friend.c | |
parent | e7425c18b5af5a12f68bde8b5f30adf02a774536 (diff) | |
download | gcc-0cf4820dd596a5884fb59c2c9874ed100a7ff614.zip gcc-0cf4820dd596a5884fb59c2c9874ed100a7ff614.tar.gz gcc-0cf4820dd596a5884fb59c2c9874ed100a7ff614.tar.bz2 |
[PR C++/59930] template friend classes & default args
https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01055.html
PR c++/59930
* decl.c (xref_tag_1): Correct comments about template friends and
default args.
* friend.c (make_friend_class): Move comments concerning
self-friendliness to code dealing with such.
* pt.c (check_default_tmpl_args): Deal with template friend
classes too.
(push_template_decl_real): Check default args for non-function
template friends.
PR c++/59930
* g++.dg/cpp0x/temp_default4.C: Adjust diagnostic.
* g++.old-deja/g++.pt/friend23.C: Likewise.
* g++.old-deja/g++.pt/friend24.C: Delete.
From-SVN: r255698
Diffstat (limited to 'gcc/cp/friend.c')
-rw-r--r-- | gcc/cp/friend.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index ef93bfe..e99ae68 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -283,21 +283,18 @@ make_friend_class (tree type, tree friend_type, bool complain) return; if (friend_depth) - /* If the TYPE is a template then it makes sense for it to be - friends with itself; this means that each instantiation is - friends with all other instantiations. */ { + /* [temp.friend] Friend declarations shall not declare partial + specializations. */ if (CLASS_TYPE_P (friend_type) && CLASSTYPE_TEMPLATE_SPECIALIZATION (friend_type) && uses_template_parms (friend_type)) { - /* [temp.friend] - Friend declarations shall not declare partial - specializations. */ error ("partial specialization %qT declared %<friend%>", friend_type); return; } + if (TYPE_TEMPLATE_INFO (friend_type) && !PRIMARY_TEMPLATE_P (TYPE_TI_TEMPLATE (friend_type))) { @@ -311,7 +308,11 @@ make_friend_class (tree type, tree friend_type, bool complain) return; } } - else if (same_type_p (type, friend_type)) + + /* It makes sense for a template class to be friends with itself, + that means the instantiations can be friendly. Other cases are + not so meaningful. */ + if (!friend_depth && same_type_p (type, friend_type)) { if (complain) warning (0, "class %qT is implicitly friends with itself", |