1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2 // RUN: %clang_cc1 -S -triple %itanium_abi_triple -std=c++11 -emit-llvm %s -o - | FileCheck %s
3 // expected-no-diagnostics
4
5 namespace PR10856 {
6 template<typename T> class C;
7
8 template<typename S, typename R = S> C<R> operator - (C<S> m0, C<S> m1);
9 template<typename T> class C {
10 public:
11 template<typename S, typename R> friend C<R> operator - (C<S> m0, C<S> m1);
12 };
13
operator -(C<S> m0,C<S> m1)14 template<typename S, typename R> inline C<R> operator - (C<S> m0, C<S> m1) {
15 C<R> ret;
16 return ret;
17 }
18 };
19
PR10856_main(int argc,char ** argv)20 int PR10856_main(int argc, char** argv) {
21 using namespace PR10856;
22 C<int> a;
23 a-a;
24 return 0;
25 }
26
27 // PR10856::C<int> PR10856::operator-<int, int>(PR10856::C<int>, PR10856::C<int>)
28 // CHECK: define {{.*}} @_ZN7PR10856miIiiEENS_1CIT0_EENS1_IT_EES5_
29
30 namespace PR10856_Root {
31 template<typename Value, typename Defaulted = void>
32 bool g(Value value);
33
34 template<typename ClassValue> class MyClass {
35 private:
36 template<typename Value, typename Defaulted>
37 friend bool g(Value value);
38 };
39 }
40
41 namespace PR10856_Root {
f()42 void f() {
43 MyClass<int> value;
44 g(value);
45 }
46 }
47
48 // bool PR10856_Root::g<PR10856_Root::MyClass<int>, void>(PR10856_Root::MyClass<int>)
49 // CHECK: call {{.*}} @_ZN12PR10856_Root1gINS_7MyClassIiEEvEEbT_
50
51 namespace PR43400 {
52 template<typename T> struct X {
53 friend void f() = delete;
54 };
55 X<int> xi;
56 }
57