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