diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/SemaCXX/typo-correction.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/SemaCXX/typo-correction.cpp b/test/SemaCXX/typo-correction.cpp index 56417cd87d..b8795e7d00 100644 --- a/test/SemaCXX/typo-correction.cpp +++ b/test/SemaCXX/typo-correction.cpp @@ -113,3 +113,27 @@ struct TestRedecl : public BaseDecl { void add_it(int i); // expected-note{{'add_it' declared here}} }; void TestRedecl::add_in(int i) {} // expected-error{{out-of-line definition of 'add_in' does not match any declaration in 'TestRedecl'; did you mean 'add_it'?}} + +// Test the typo-correction callback in BuildRecoveryCallExpr. +// Solves the main issue in PR 9320 of suggesting corrections that take the +// wrong number of arguments. +void revoke(const char*); // expected-note 2{{'revoke' declared here}} +void Test() { + Invoke(); // expected-error{{use of undeclared identifier 'Invoke'}} + Invoke("foo"); // expected-error{{use of undeclared identifier 'Invoke'; did you mean 'revoke'?}} + Invoke("foo", "bar"); // expected-error{{use of undeclared identifier 'Invoke'}} +} +void Test2(void (*invoke)(const char *, int)) { // expected-note{{'invoke' declared here}} + Invoke(); // expected-error{{use of undeclared identifier 'Invoke'}} + Invoke("foo"); // expected-error{{use of undeclared identifier 'Invoke'; did you mean 'revoke'?}} + Invoke("foo", 7); // expected-error{{use of undeclared identifier 'Invoke'; did you mean 'invoke'?}} + Invoke("foo", 7, 22); // expected-error{{use of undeclared identifier 'Invoke'}} +} + +void provoke(const char *x, bool y=false) {} // expected-note 2{{'provoke' declared here}} +void Test3() { + Provoke(); // expected-error{{use of undeclared identifier 'Provoke'}} + Provoke("foo"); // expected-error{{use of undeclared identifier 'Provoke'; did you mean 'provoke'?}} + Provoke("foo", true); // expected-error{{use of undeclared identifier 'Provoke'; did you mean 'provoke'?}} + Provoke("foo", 7, 22); // expected-error{{use of undeclared identifier 'Provoke'}} +} |