Gabor Greif | 19de06b | 2010-08-28 00:45:56 +0000 | [diff] [blame] | 1 | // RUN: %clang %s -S -emit-llvm -o - | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE" |
Gabor Greif | bb452e9 | 2010-08-28 00:48:36 +0000 | [diff] [blame^] | 2 | // PR8007: friend function not instantiated. |
Gabor Greif | c620ace | 2010-08-27 23:39:49 +0000 | [diff] [blame] | 3 | |
| 4 | struct std_ostream |
| 5 | { |
| 6 | int dummy; |
| 7 | }; |
| 8 | |
| 9 | std_ostream cout; |
| 10 | |
| 11 | template <typename STRUCT_TYPE> |
| 12 | struct Streamer |
| 13 | { |
| 14 | friend std_ostream& operator << (std_ostream& o, const Streamer& f) |
| 15 | { |
| 16 | Streamer s(f); |
| 17 | s(o); |
| 18 | return o; |
| 19 | } |
| 20 | |
| 21 | Streamer(const STRUCT_TYPE& s) : s(s) {} |
| 22 | |
| 23 | const STRUCT_TYPE& s; |
| 24 | void operator () (std_ostream&) const; |
| 25 | }; |
| 26 | |
| 27 | typedef struct Foo {} Foo; |
| 28 | |
| 29 | std_ostream& operator << (std_ostream& o, const Streamer<Foo>& f); |
| 30 | /*std_ostream& operator << (std_ostream& o, const Streamer<Foo>& f) |
| 31 | { |
| 32 | // Sema should flag this as a redefinition |
| 33 | }*/ |
| 34 | |
| 35 | template <> |
| 36 | void Streamer<Foo>::operator () (std_ostream& o) const |
| 37 | { |
| 38 | } |
| 39 | |
Gabor Greif | c620ace | 2010-08-27 23:39:49 +0000 | [diff] [blame] | 40 | int main(void) |
| 41 | { |
Gabor Greif | c620ace | 2010-08-27 23:39:49 +0000 | [diff] [blame] | 42 | Foo foo; |
| 43 | cout << foo; |
| 44 | } |