diff options
author | Richard Trieu <rtrieu@google.com> | 2013-07-31 00:48:10 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2013-07-31 00:48:10 +0000 |
commit | 2ac682a671eb201b56dd85397c25836d08455706 (patch) | |
tree | deff77ee90caecd341bfac49972349479bf31bec | |
parent | 7f8042c8f3b1cfda2c4576888b54e06a701512e6 (diff) | |
download | bcm5719-llvm-2ac682a671eb201b56dd85397c25836d08455706.tar.gz bcm5719-llvm-2ac682a671eb201b56dd85397c25836d08455706.zip |
Fix a crasher than manifests when typo correction suggests a function template.
llvm-svn: 187467
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaCXX/typo-correction-pt2.cpp | 19 |
2 files changed, 21 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 5b0029a91f3..65654b67cfb 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3932,7 +3932,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, << Fn->getSourceRange() << CorrectedQuotedStr << FixItHint::CreateReplacement(TC.getCorrectionRange(), CorrectedStr); - Diag(TC.getCorrectionDeclAs<FunctionDecl>()->getLocStart(), + Diag(TC.getCorrectionDecl()->getLocStart(), diag::note_previous_decl) << CorrectedQuotedStr; } else if (MinArgs == 1 && FDecl && FDecl->getParamDecl(0)->getDeclName()) Diag(RParenLoc, MinArgs == NumArgsInProto && !Proto->isVariadic() @@ -3978,7 +3978,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, << Fn->getSourceRange() << CorrectedQuotedStr << FixItHint::CreateReplacement(TC.getCorrectionRange(), CorrectedStr); - Diag(TC.getCorrectionDeclAs<FunctionDecl>()->getLocStart(), + Diag(TC.getCorrectionDecl()->getLocStart(), diag::note_previous_decl) << CorrectedQuotedStr; } else if (NumArgsInProto == 1 && FDecl && FDecl->getParamDecl(0)->getDeclName()) Diag(Args[NumArgsInProto]->getLocStart(), diff --git a/clang/test/SemaCXX/typo-correction-pt2.cpp b/clang/test/SemaCXX/typo-correction-pt2.cpp index ee4971709f8..c79a869b5a5 100644 --- a/clang/test/SemaCXX/typo-correction-pt2.cpp +++ b/clang/test/SemaCXX/typo-correction-pt2.cpp @@ -14,3 +14,22 @@ void zif::nab(int) { nab(); // expected-error{{too few arguments to function call, expected 1, have 0; did you mean '::PR12287::nab'?}} } } + +namespace TemplateFunction { +template <class T> // expected-note {{'::TemplateFunction::A' declared here}} +void A(T) { } + +template <class T> // expected-note {{'::TemplateFunction::B' declared here}} +void B(T) { } + +class Foo { + public: + void A(int, int) {} + void B() {} +}; + +void test(Foo F, int num) { + F.A(num); // expected-error {{too few arguments to function call, expected 2, have 1; did you mean '::TemplateFunction::A'?}} + F.B(num); // expected-error {{too many arguments to function call, expected 0, have 1; did you mean '::TemplateFunction::B'?}} +} +} |