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