add opensuse toolchain support, patch by Ismail Donmez!
[clang/stm8.git] / test / SemaTemplate / inject-templated-friend-post.cpp
blob39c445ca0f996ec70a62ce550c05845fe2bb64af
1 // RUN: %clang %s -S -emit-llvm -o - | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
2 // RUN: %clang %s -S -emit-llvm -o - -DPROTOTYPE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
3 // RUN: %clang %s -S -emit-llvm -o - -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
4 // RUN: %clang %s -S -emit-llvm -o - -DPROTOTYPE -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
5 // RUN: %clang_cc1 %s -DREDEFINE -verify
6 // RUN: %clang_cc1 %s -DPROTOTYPE -DREDEFINE -verify
7 // PR8007: friend function not instantiated, reordered version.
8 // Corresponds to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38392
10 struct std_ostream
12 int dummy;
15 std_ostream cout;
17 template <typename STRUCT_TYPE>
18 struct Streamer;
20 typedef struct Foo {} Foo;
22 std_ostream& operator << (std_ostream&, const Streamer<Foo>&);
24 void test(const Streamer<Foo>& foo)
26 cout << foo;
29 template <typename STRUCT_TYPE>
30 struct Streamer
32 friend std_ostream& operator << (std_ostream& o, const Streamer& f) // expected-error{{redefinition of 'operator<<'}}
34 Streamer s(f);
35 s(o);
36 return o;
39 Streamer(const STRUCT_TYPE& s) : s(s) {}
41 const STRUCT_TYPE& s;
42 void operator () (std_ostream&) const;
45 #ifdef PROTOTYPE
46 std_ostream& operator << (std_ostream&, const Streamer<Foo>&);
47 #endif
49 #ifdef INSTANTIATE
50 template struct Streamer<Foo>;
51 #endif
53 #ifdef REDEFINE
54 std_ostream& operator << (std_ostream& o, const Streamer<Foo>&) // expected-note{{is here}}
56 return o;
58 #endif
60 #ifndef INSTANTIATE
61 template <>
62 void Streamer<Foo>::operator () (std_ostream& o) const // expected-note{{requested here}}
65 #endif
67 int main(void)
69 Foo foo;
70 test(foo);