* name-lookup.c (hidden_name_p): Handle OVERLOAD.

From-SVN: r227044
This commit is contained in:
Jason Merrill 2015-08-20 16:55:15 -04:00 committed by Jason Merrill
parent 4ba1fef27d
commit 062ed8758d
6 changed files with 43 additions and 6 deletions

View File

@ -1,3 +1,7 @@
2015-08-20 Jason Merrill <jason@redhat.com>
* name-lookup.c (hidden_name_p): Handle OVERLOAD.
2015-08-20 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/67065

View File

@ -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;
}

View File

@ -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?
}
}

View File

@ -10,10 +10,11 @@ template <typename> class X {
struct Inner;
template <typename R>
friend typename X<R>::Inner * foo () { return 0; }
friend typename X<R>::Inner * foo (X<R>*) { return 0; }
};
template class X<void>;
X<void>* p;
struct U {
void bar () { foo<void> (); }
void bar () { foo (p); }
};

View File

@ -7,13 +7,14 @@
template <int N> struct X
{
template <int M> friend int foo(X const &)
template <int M> friend int foo(X const &, X<M> const&)
{
return N * 10000 + M;
}
};
X<1234> bring;
X<5678> brung;
int main() {
return foo<5678> (bring) != 12345678;
return foo (bring, brung) != 12345678;
}

View File

@ -7,8 +7,8 @@ struct S {
};
template class S<int, double>;
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 <class X, class Y, class Z>
X f(X x, Y, Z) {