brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · f0f287c Raw
51 lines · cpp
1// RUN: %clang_cc1 %s -emit-llvm -triple %itanium_abi_triple -o - | FileCheck %s2// RUN: %clang_cc1 %s -DREDEFINE -verify3// PR8007: friend function not instantiated.4 5// CHECK: define linkonce_odr{{.*}}_ZlsR11std_ostreamRK8StreamerI3FooE6 7struct std_ostream8{9  int dummy;10};11 12std_ostream cout;13 14template <typename STRUCT_TYPE>15struct Streamer16{17    friend std_ostream& operator << (std_ostream& o, const Streamer& f) // expected-error{{redefinition of 'operator<<'}}18        {19            Streamer s(f);20            s(o);21            return o;22        }23 24    Streamer(const STRUCT_TYPE& s) : s(s) {}25 26    const STRUCT_TYPE& s;27    void operator () (std_ostream&) const;28};29 30typedef struct Foo {} Foo;31 32inline std_ostream& operator << (std_ostream&, const Streamer<Foo>&);33#ifdef REDEFINE34std_ostream& operator << (std_ostream& o, const Streamer<Foo>&) // expected-note{{is here}}35{36  // Sema should flag this as a redefinition37  return o;38}39#endif40 41template <>42void Streamer<Foo>::operator () (std_ostream& o) const // expected-note{{requested here}}43{44}45 46int main(void)47{48    Foo foo;49    cout << foo;50}51