]> granicus.if.org Git - clang/commitdiff
Report errors for member functions correctly.
authorAnders Carlsson <andersca@mac.com>
Sat, 5 Sep 2009 05:38:54 +0000 (05:38 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 5 Sep 2009 05:38:54 +0000 (05:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81063 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiate.cpp
test/SemaTemplate/default-expr-arguments.cpp

index b48708305a36e206155b193f1804014d197fd95e..97b58adb06a278bfe440c41bf778030d08d4d0da 100644 (file)
@@ -293,7 +293,6 @@ void Sema::PrintInstantiationStack() {
     case ActiveTemplateInstantiation::DefaultFunctionArgumentInstantiation: {
       ParmVarDecl *Param = cast<ParmVarDecl>((Decl *)Active->Entity);
       FunctionDecl *FD = cast<FunctionDecl>(Param->getDeclContext());
-      TemplateDecl *Template = FD->getPrimaryTemplate();
       
       std::string TemplateArgsStr
         = TemplateSpecializationType::PrintTemplateArgumentList(
@@ -302,7 +301,7 @@ void Sema::PrintInstantiationStack() {
                                                       Context.PrintingPolicy);
       Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr),
                    diag::note_default_function_arg_instantiation_here)
-        << (Template->getNameAsString() + TemplateArgsStr)
+        << (FD->getNameAsString() + TemplateArgsStr)
         << Active->InstantiationRange;
       break;
     }
index 5c95e511a7fa9ae5a86bb58c903d4cbc9436b182..925d52fb19acba230023cb487194b4861713ad00 100644 (file)
@@ -21,6 +21,7 @@ void g() {
 
 template<typename T> struct F {
   F(T t = 10);
+  void f(T t = 10); // expected-error{{cannot initialize 't' with an rvalue of type 'int'}}
 };
 
 struct FD : F<int> { };
@@ -30,6 +31,11 @@ void g2() {
   FD fd;
 }
 
+void g3(F<int> f, F<struct S> s) {
+  f.f();
+  s.f(); // expected-note{{in instantiation of default function argument expression for 'f<struct S>' required here}}
+}
+
 template<typename T> struct G {
   G(T) {}
 };
@@ -37,3 +43,4 @@ template<typename T> struct G {
 void s(G<int> flags = 10) { }
 
 
+