1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 struct T { 3 void f(); 4 }; 5 6 struct A { 7 T* operator->(); // expected-note{{candidate function}} 8 }; 9 10 struct B { 11 T* operator->(); // expected-note{{candidate function}} 12 }; 13 14 struct C : A, B { 15 }; 16 17 struct D : A { }; 18 19 struct E; // expected-note {{forward declaration of 'E'}} 20 f(C & c,D & d,E & e)21void f(C &c, D& d, E& e) { 22 c->f(); // expected-error{{use of overloaded operator '->' is ambiguous}} 23 d->f(); 24 e->f(); // expected-error{{incomplete definition of type}} 25 } 26 27 // rdar://8875304 28 namespace rdar8875304 { 29 class Point {}; Line_Segment(const Point &)30class Line_Segment{ public: Line_Segment(const Point&){} }; Location()31class Node { public: Point Location(){ Point p; return p; } }; 32 f()33void f() 34 { 35 Node** node1; 36 Line_Segment(node1->Location()); // expected-error {{not a structure or union}} 37 } 38 } 39 40 41 namespace arrow_suggest { 42 43 template <typename T> 44 class wrapped_ptr { 45 public: wrapped_ptr(T * ptr)46 wrapped_ptr(T* ptr) : ptr_(ptr) {} operator ->()47 T* operator->() { return ptr_; } 48 void Check(); // expected-note {{'Check' declared here}} 49 private: 50 T *ptr_; 51 }; 52 53 class Worker { 54 public: 55 void DoSomething(); // expected-note {{'DoSomething' declared here}} 56 void Chuck(); 57 }; 58 test()59void test() { 60 wrapped_ptr<Worker> worker(new Worker); 61 worker.DoSomething(); // expected-error {{no member named 'DoSomething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean to use '->' instead of '.'?}} 62 worker.DoSamething(); // expected-error {{no member named 'DoSamething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean to use '->' instead of '.'?}} \ 63 // expected-error {{no member named 'DoSamething' in 'arrow_suggest::Worker'; did you mean 'DoSomething'?}} 64 worker.Chuck(); // expected-error {{no member named 'Chuck' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean 'Check'?}} 65 } 66 67 } // namespace arrow_suggest 68 69 namespace no_crash_dependent_type { 70 71 template <class T> 72 struct A { 73 void call(); 74 A *operator->(); 75 }; 76 77 template <class T> foo()78void foo() { 79 // The "requires an initializer" error seems unnecessary. 80 A<int> &x = blah[7]; // expected-error {{use of undeclared identifier 'blah'}} \ 81 // expected-error {{requires an initializer}} 82 // x is dependent. 83 x->call(); 84 } 85 test()86void test() { 87 foo<int>(); // expected-note {{requested here}} 88 } 89 90 } // namespace no_crash_dependent_type 91 92 namespace clangd_issue_1073_no_crash_dependent_type { 93 94 template <typename T> struct Ptr { 95 T *operator->(); 96 }; 97 98 struct Struct { 99 int len; 100 }; 101 102 template <int> 103 struct TemplateStruct { 104 Ptr<Struct> val(); // expected-note {{declared here}} 105 }; 106 107 template <int I> templateFunc(const TemplateStruct<I> & ts)108void templateFunc(const TemplateStruct<I> &ts) { 109 Ptr<Struct> ptr = ts.val(); // expected-error {{function is not marked const}} 110 auto foo = ptr->len; 111 } 112 113 template void templateFunc<0>(const TemplateStruct<0> &); // expected-note {{requested here}} 114 115 } // namespace clangd_issue_1073_no_crash_dependent_type 116