summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/typo-correction-delayed.cpp
diff options
context:
space:
mode:
authorKaelyn Takata <rikka@google.com>2014-10-27 18:07:46 +0000
committerKaelyn Takata <rikka@google.com>2014-10-27 18:07:46 +0000
commit627380e9f70671aacaa77ae8fd1b6a55d6634a89 (patch)
treeec81759106c6fddc2a5285738d0158d8fec28611 /test/SemaCXX/typo-correction-delayed.cpp
parentfb608dd7d0896f85baf1f929dc39a2321d8a49b7 (diff)
Wire up LookupMemberExpr to use the new TypoExpr.
This includes adding the new TypoExpr-based lazy typo correction to LookupMemberExprInRecord as an alternative to the existing eager typo correction. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220698 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/typo-correction-delayed.cpp')
-rw-r--r--test/SemaCXX/typo-correction-delayed.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/SemaCXX/typo-correction-delayed.cpp b/test/SemaCXX/typo-correction-delayed.cpp
new file mode 100644
index 0000000000..c79fe45629
--- /dev/null
+++ b/test/SemaCXX/typo-correction-delayed.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions %s
+
+struct A {};
+struct B {};
+struct D {
+ A fizbin; // expected-note 2 {{declared here}}
+ A foobar; // expected-note 2 {{declared here}}
+ B roxbin; // expected-note 2 {{declared here}}
+ B toobad; // expected-note 2 {{declared here}}
+ void BooHoo();
+ void FoxBox();
+};
+
+void something(A, B);
+void test() {
+ D obj;
+ something(obj.fixbin, // expected-error {{did you mean 'fizbin'?}}
+ obj.toobat); // expected-error {{did you mean 'toobad'?}}
+ something(obj.toobat, // expected-error {{did you mean 'foobar'?}}
+ obj.fixbin); // expected-error {{did you mean 'roxbin'?}}
+ something(obj.fixbin, // expected-error {{did you mean 'fizbin'?}}
+ obj.fixbin); // expected-error {{did you mean 'roxbin'?}}
+ something(obj.toobat, // expected-error {{did you mean 'foobar'?}}
+ obj.toobat); // expected-error {{did you mean 'toobad'?}}
+ // Both members could be corrected to methods, but that isn't valid.
+ something(obj.boohoo, // expected-error-re {{no member named 'boohoo' in 'D'{{$}}}}
+ obj.foxbox); // expected-error-re {{no member named 'foxbox' in 'D'{{$}}}}
+ // The first argument has a usable correction but the second doesn't.
+ something(obj.boobar, // expected-error-re {{no member named 'boobar' in 'D'{{$}}}}
+ obj.foxbox); // expected-error-re {{no member named 'foxbox' in 'D'{{$}}}}
+}
+
+// Ensure the delayed typo correction does the right thing when trying to
+// recover using a seemingly-valid correction for which a valid expression to
+// replace the TypoExpr cannot be created (but which does have a second
+// correction candidate that would be a valid and usable correction).
+class Foo {
+public:
+ template <> void testIt(); // expected-error {{no function template matches}}
+ void textIt(); // expected-note {{'textIt' declared here}}
+};
+void testMemberExpr(Foo *f) {
+ f->TestIt(); // expected-error {{no member named 'TestIt' in 'Foo'; did you mean 'textIt'?}}
+}