diff options
author | Momchil Velikov <momchil.velikov@gmail.com> | 2015-01-15 21:02:15 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2015-01-15 16:02:15 -0500 |
commit | 199b7a3586061f951fa737656217206164456910 (patch) | |
tree | b986595b92e98bfac8ddd733fa895f37db151c48 /gcc/cp/decl.c | |
parent | 58b59d5ee7ac732d67736bc3654b6dc6c9af9e44 (diff) | |
download | gcc-199b7a3586061f951fa737656217206164456910.zip gcc-199b7a3586061f951fa737656217206164456910.tar.gz gcc-199b7a3586061f951fa737656217206164456910.tar.bz2 |
re PR c++/59366 (A friend function template defined in a class is found without ADL)
PR c++/59366
* name-lookup.c (pushdecl_maybe_friend_1): Hide friend functions
and function templates, declared only in the class.
* decl.c (duplicate_decls): Reveal hidden friend functions or
function templates, if they are redeclared outside the class.
From-SVN: r219689
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 9d9a04e..35f4833 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1871,6 +1871,19 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) DECL_ATTRIBUTES (newdecl) = (*targetm.merge_decl_attributes) (olddecl, newdecl); + if (DECL_DECLARES_FUNCTION_P (olddecl) && DECL_DECLARES_FUNCTION_P (newdecl)) + { + olddecl_friend = DECL_FRIEND_P (olddecl); + hidden_friend = (DECL_ANTICIPATED (olddecl) + && DECL_HIDDEN_FRIEND_P (olddecl) + && newdecl_is_friend); + if (!hidden_friend) + { + DECL_ANTICIPATED (olddecl) = 0; + DECL_HIDDEN_FRIEND_P (olddecl) = 0; + } + } + if (TREE_CODE (newdecl) == TEMPLATE_DECL) { tree old_result; @@ -2153,10 +2166,6 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) if (DECL_DECLARES_FUNCTION_P (newdecl)) { DECL_NONCONVERTING_P (newdecl) = DECL_NONCONVERTING_P (olddecl); - olddecl_friend = DECL_FRIEND_P (olddecl); - hidden_friend = (DECL_ANTICIPATED (olddecl) - && DECL_HIDDEN_FRIEND_P (olddecl) - && newdecl_is_friend); DECL_BEFRIENDING_CLASSES (newdecl) = chainon (DECL_BEFRIENDING_CLASSES (newdecl), DECL_BEFRIENDING_CLASSES (olddecl)); |