1*67e74705SXin Li // RUN: %clang_cc1 %s -emit-llvm -triple %itanium_abi_triple -o - | FileCheck %s 2*67e74705SXin Li // RUN: %clang_cc1 %s -DREDEFINE -verify 3*67e74705SXin Li // PR8007: friend function not instantiated. 4*67e74705SXin Li 5*67e74705SXin Li // CHECK: define linkonce_odr{{.*}}_ZlsR11std_ostreamRK8StreamerI3FooE 6*67e74705SXin Li 7*67e74705SXin Li struct std_ostream 8*67e74705SXin Li { 9*67e74705SXin Li int dummy; 10*67e74705SXin Li }; 11*67e74705SXin Li 12*67e74705SXin Li std_ostream cout; 13*67e74705SXin Li 14*67e74705SXin Li template <typename STRUCT_TYPE> 15*67e74705SXin Li struct Streamer 16*67e74705SXin Li { operator <<(std_ostream & o,const Streamer & f)17*67e74705SXin Li friend std_ostream& operator << (std_ostream& o, const Streamer& f) // expected-error{{redefinition of 'operator<<'}} 18*67e74705SXin Li { 19*67e74705SXin Li Streamer s(f); 20*67e74705SXin Li s(o); 21*67e74705SXin Li return o; 22*67e74705SXin Li } 23*67e74705SXin Li StreamerStreamer24*67e74705SXin Li Streamer(const STRUCT_TYPE& s) : s(s) {} 25*67e74705SXin Li 26*67e74705SXin Li const STRUCT_TYPE& s; 27*67e74705SXin Li void operator () (std_ostream&) const; 28*67e74705SXin Li }; 29*67e74705SXin Li 30*67e74705SXin Li typedef struct Foo {} Foo; 31*67e74705SXin Li 32*67e74705SXin Li inline std_ostream& operator << (std_ostream&, const Streamer<Foo>&); 33*67e74705SXin Li #ifdef REDEFINE operator <<(std_ostream & o,const Streamer<Foo> &)34*67e74705SXin Listd_ostream& operator << (std_ostream& o, const Streamer<Foo>&) // expected-note{{is here}} 35*67e74705SXin Li { 36*67e74705SXin Li // Sema should flag this as a redefinition 37*67e74705SXin Li return o; 38*67e74705SXin Li } 39*67e74705SXin Li #endif 40*67e74705SXin Li 41*67e74705SXin Li template <> operator ()(std_ostream & o) const42*67e74705SXin Livoid Streamer<Foo>::operator () (std_ostream& o) const // expected-note{{requested here}} 43*67e74705SXin Li { 44*67e74705SXin Li } 45*67e74705SXin Li main(void)46*67e74705SXin Liint main(void) 47*67e74705SXin Li { 48*67e74705SXin Li Foo foo; 49*67e74705SXin Li cout << foo; 50*67e74705SXin Li } 51