blob: 7be613b6d3148987a7259c54896c97e1f6453b60 [file] [log] [blame]
Gabor Greif19de06b2010-08-28 00:45:56 +00001// RUN: %clang %s -S -emit-llvm -o - | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
Chandler Carruthf56017f2010-11-13 10:19:35 +00002// RUN: %clang_cc1 %s -DREDEFINE -verify
Gabor Greifbb452e92010-08-28 00:48:36 +00003// PR8007: friend function not instantiated.
Gabor Greifc620ace2010-08-27 23:39:49 +00004
5struct std_ostream
6{
7 int dummy;
8};
9
10std_ostream cout;
11
12template <typename STRUCT_TYPE>
13struct Streamer
14{
Gabor Greifaaafddb2010-08-28 02:00:22 +000015 friend std_ostream& operator << (std_ostream& o, const Streamer& f) // expected-error{{redefinition of 'operator<<'}}
Gabor Greifc620ace2010-08-27 23:39:49 +000016 {
17 Streamer s(f);
18 s(o);
19 return o;
20 }
21
22 Streamer(const STRUCT_TYPE& s) : s(s) {}
23
24 const STRUCT_TYPE& s;
25 void operator () (std_ostream&) const;
26};
27
28typedef struct Foo {} Foo;
29
Gabor Greifaaafddb2010-08-28 02:00:22 +000030std_ostream& operator << (std_ostream&, const Streamer<Foo>&);
31#ifdef REDEFINE
32std_ostream& operator << (std_ostream& o, const Streamer<Foo>&) // expected-note{{is here}}
Gabor Greifc620ace2010-08-27 23:39:49 +000033{
34 // Sema should flag this as a redefinition
Gabor Greifaaafddb2010-08-28 02:00:22 +000035 return o;
36}
37#endif
Gabor Greifc620ace2010-08-27 23:39:49 +000038
39template <>
Gabor Greifaaafddb2010-08-28 02:00:22 +000040void Streamer<Foo>::operator () (std_ostream& o) const // expected-note{{requested here}}
Gabor Greifc620ace2010-08-27 23:39:49 +000041{
42}
43
Gabor Greifc620ace2010-08-27 23:39:49 +000044int main(void)
45{
Gabor Greifc620ace2010-08-27 23:39:49 +000046 Foo foo;
47 cout << foo;
48}