2010-08-28 08:45:56 +08:00
|
|
|
// RUN: %clang %s -S -emit-llvm -o - | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
|
2010-11-13 18:19:35 +08:00
|
|
|
// RUN: %clang_cc1 %s -DREDEFINE -verify
|
2010-08-28 08:48:36 +08:00
|
|
|
// PR8007: friend function not instantiated.
|
2010-08-28 07:39:49 +08:00
|
|
|
|
|
|
|
struct std_ostream
|
|
|
|
{
|
|
|
|
int dummy;
|
|
|
|
};
|
|
|
|
|
|
|
|
std_ostream cout;
|
|
|
|
|
|
|
|
template <typename STRUCT_TYPE>
|
|
|
|
struct Streamer
|
|
|
|
{
|
2010-08-28 10:00:22 +08:00
|
|
|
friend std_ostream& operator << (std_ostream& o, const Streamer& f) // expected-error{{redefinition of 'operator<<'}}
|
2010-08-28 07:39:49 +08:00
|
|
|
{
|
|
|
|
Streamer s(f);
|
|
|
|
s(o);
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
Streamer(const STRUCT_TYPE& s) : s(s) {}
|
|
|
|
|
|
|
|
const STRUCT_TYPE& s;
|
|
|
|
void operator () (std_ostream&) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct Foo {} Foo;
|
|
|
|
|
2010-08-28 10:00:22 +08:00
|
|
|
std_ostream& operator << (std_ostream&, const Streamer<Foo>&);
|
|
|
|
#ifdef REDEFINE
|
|
|
|
std_ostream& operator << (std_ostream& o, const Streamer<Foo>&) // expected-note{{is here}}
|
2010-08-28 07:39:49 +08:00
|
|
|
{
|
|
|
|
// Sema should flag this as a redefinition
|
2010-08-28 10:00:22 +08:00
|
|
|
return o;
|
|
|
|
}
|
|
|
|
#endif
|
2010-08-28 07:39:49 +08:00
|
|
|
|
|
|
|
template <>
|
2010-08-28 10:00:22 +08:00
|
|
|
void Streamer<Foo>::operator () (std_ostream& o) const // expected-note{{requested here}}
|
2010-08-28 07:39:49 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
Foo foo;
|
|
|
|
cout << foo;
|
|
|
|
}
|