]> granicus.if.org Git - clang/commitdiff
Fix a crasher than manifests when typo correction suggests a function template.
authorRichard Trieu <rtrieu@google.com>
Wed, 31 Jul 2013 00:48:10 +0000 (00:48 +0000)
committerRichard Trieu <rtrieu@google.com>
Wed, 31 Jul 2013 00:48:10 +0000 (00:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187467 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaCXX/typo-correction-pt2.cpp

index 5b0029a91f371845f744c5d2c5efbe24a9a62f83..65654b67cfbf05169c3c83063ee1da1681e756b4 100644 (file)
@@ -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(),
index ee4971709f80b811960ad4a20202bb27cf9b9894..c79a869b5a5d7374be642cb1f00aa02b18b99f4e 100644 (file)
@@ -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'?}}
+}
+}