diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 53d4febe962..245cf11df78 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2015-08-20 Jason Merrill + + * name-lookup.c (hidden_name_p): Handle OVERLOAD. + 2015-08-20 Paolo Carlini PR c++/67065 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 79e28637cae..baaf3e7ca98 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -4346,6 +4346,13 @@ hidden_name_p (tree val) && TYPE_FUNCTION_OR_TEMPLATE_DECL_P (val) && DECL_ANTICIPATED (val)) return true; + if (TREE_CODE (val) == OVERLOAD) + { + for (tree o = val; o; o = OVL_CHAIN (o)) + if (!hidden_name_p (OVL_FUNCTION (o))) + return false; + return true; + } return false; } diff --git a/gcc/testsuite/g++.dg/lookup/friend16.C b/gcc/testsuite/g++.dg/lookup/friend16.C new file mode 100644 index 00000000000..bb27773d7be --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/friend16.C @@ -0,0 +1,24 @@ +namespace std { + class ostream; +} + +namespace N2 { + class C0 {}; +} + +std::ostream& operator<<( std::ostream& os_, const N2::C0& m_); + +namespace N1 { + class C1 { + friend std::ostream& operator<<(std::ostream& os, const C1& what); + }; + + class C2 { + friend std::ostream& operator<<(std::ostream& os, const C2& what); + }; + + void foo(std::ostream & os, const N2::C0& m) + { + os << m; // Is this line valid? + } +} diff --git a/gcc/testsuite/g++.dg/template/friend15.C b/gcc/testsuite/g++.dg/template/friend15.C index 4acbf2d1a56..15ba1c27182 100644 --- a/gcc/testsuite/g++.dg/template/friend15.C +++ b/gcc/testsuite/g++.dg/template/friend15.C @@ -10,10 +10,11 @@ template class X { struct Inner; template - friend typename X::Inner * foo () { return 0; } + friend typename X::Inner * foo (X*) { return 0; } }; template class X; +X* p; struct U { - void bar () { foo (); } + void bar () { foo (p); } }; diff --git a/gcc/testsuite/g++.dg/template/friend18.C b/gcc/testsuite/g++.dg/template/friend18.C index 04ba26e9830..712d4889fea 100644 --- a/gcc/testsuite/g++.dg/template/friend18.C +++ b/gcc/testsuite/g++.dg/template/friend18.C @@ -7,13 +7,14 @@ template struct X { - template friend int foo(X const &) + template friend int foo(X const &, X const&) { return N * 10000 + M; } }; X<1234> bring; +X<5678> brung; int main() { - return foo<5678> (bring) != 12345678; + return foo (bring, brung) != 12345678; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend32.C b/gcc/testsuite/g++.old-deja/g++.pt/friend32.C index 512a69a09a4..db8b724635c 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/friend32.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend32.C @@ -7,8 +7,8 @@ struct S { }; template class S; -template char f(char, long, short); -template char* f(char*, long*, short*); +template char f(char, long, short); // { dg-error "f" } +template char* f(char*, long*, short*); // { dg-error "f" } template X f(X x, Y, Z) {