summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/typo-correction-delayed.cpp
diff options
context:
space:
mode:
authorKaelyn Takata <rikka@google.com>2015-01-16 22:11:04 +0000
committerKaelyn Takata <rikka@google.com>2015-01-16 22:11:04 +0000
commit1b578c21b8068771e63b3fbe331f6e42e9b9d628 (patch)
treef1a2b087a6ce31dad663ce9340961c19b5b8af6e /test/SemaCXX/typo-correction-delayed.cpp
parenta77e006fa0a5c215e4b48a21e70dd323d165a5b4 (diff)
Fix a case where delayed typo correction should have resolved an
ambiguity but wasn't. In the new test case, "click" wasn't being corrected properly because Sema::ClassifyName would call CorrectTypo for "click" then later Sema::DiagnoseEmptyLookup would call CorrectTypoDelayed for the same use of "click" (the former by the parser needing to determine what the identifier is so it knows how to parse the statement, i.e. is it the beginning of a declaration or an expression). CorrectTypo would record that typo correction for "click" failed and CorrectTypoDelayed would see that and not even try to correct the typo, even though in this case CorrectTypo failed due to an ambiguity (both "Click" and "clock" having an edit distance of one from "click") that could be resolved with more information. The fix is two-fold: 1) Have CorrectTypo not record failed corrections if the reason for the failure was two or more corrections with the same edit distance, and 2) Make the CorrectionCandidateCallback used by Parser::ParseCastExpression reject FunctionDecl candidates when the next token after the identifier is a ".", "=", or "->" since functions cannot be assigned to and do not have members that can be referenced. The reason for two correction spots is that from r222549 until r224375 landed, the first correction attempt would fail completely but the second would suggest "clock" while having the note point to the declaration of "Click". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226334 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/typo-correction-delayed.cpp')
-rw-r--r--test/SemaCXX/typo-correction-delayed.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/SemaCXX/typo-correction-delayed.cpp b/test/SemaCXX/typo-correction-delayed.cpp
index e028faad25..454a8b365c 100644
--- a/test/SemaCXX/typo-correction-delayed.cpp
+++ b/test/SemaCXX/typo-correction-delayed.cpp
@@ -157,3 +157,13 @@ namespace PR22092 {
a = b ? : 0; // expected-error {{C++ requires a type specifier for all declarations}} \
// expected-error-re {{use of undeclared identifier 'b'{{$}}}}
}
+
+extern long clock (void);
+struct Pointer {
+ void set_xpos(int);
+ void set_ypos(int);
+};
+void MovePointer(Pointer &Click, int x, int y) { // expected-note 2 {{'Click' declared here}}
+ click.set_xpos(x); // expected-error {{use of undeclared identifier 'click'; did you mean 'Click'?}}
+ click.set_ypos(x); // expected-error {{use of undeclared identifier 'click'; did you mean 'Click'?}}
+}