Add an error message with fixit hint for changing '.' to '->'.
This is mainly for attempting to recover in cases where a class provides
a custom operator-> and a '.' was accidentally used instead of '->' when
accessing a member of the object returned by the current object's
operator->.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155580 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp
index ac1fb63..e6609d8 100644
--- a/test/FixIt/fixit.cpp
+++ b/test/FixIt/fixit.cpp
@@ -217,3 +217,26 @@
};
void Foo::SetBar(Bar bar) { bar_ = bar; } // expected-error {{must use 'enum' tag to refer to type 'Bar' in this scope}}
}
+
+namespace arrow_suggest {
+
+template <typename T>
+class wrapped_ptr {
+ public:
+ wrapped_ptr(T* ptr) : ptr_(ptr) {}
+ T* operator->() { return ptr_; }
+ private:
+ T *ptr_;
+};
+
+class Worker {
+ public:
+ void DoSomething();
+};
+
+void test() {
+ wrapped_ptr<Worker> worker(new Worker);
+ worker.DoSomething(); // expected-error {{no member named 'DoSomething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean to use '->' instead of '.'?}}
+}
+
+} // namespace arrow_suggest