aboutsummaryrefslogtreecommitdiff
path: root/test/FixIt/fixit.cpp
diff options
context:
space:
mode:
authorKaelyn Uhrain <rikka@google.com>2012-04-25 19:49:54 +0000
committerKaelyn Uhrain <rikka@google.com>2012-04-25 19:49:54 +0000
commit2b90f7637e846ea555dedac14e7f5065d85c5d3b (patch)
tree1b958a95d03853904729c05e6423027752e9488f /test/FixIt/fixit.cpp
parentad579916bc402cf617793e94770bab78e9bdaec8 (diff)
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
Diffstat (limited to 'test/FixIt/fixit.cpp')
-rw-r--r--test/FixIt/fixit.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp
index ac1fb6397f..e6609d8a6c 100644
--- a/test/FixIt/fixit.cpp
+++ b/test/FixIt/fixit.cpp
@@ -217,3 +217,26 @@ class Foo {
};
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