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