kuang_he updated this revision to Diff 104018. https://reviews.llvm.org/D33833
Files: lib/AST/DeclCXX.cpp test/SemaTemplate/destructor-template.cpp Index: test/SemaTemplate/destructor-template.cpp =================================================================== --- test/SemaTemplate/destructor-template.cpp +++ test/SemaTemplate/destructor-template.cpp @@ -86,3 +86,9 @@ template<typename T> decltype(S<T>().~S()) f(); // expected-note {{candidate template ignored: couldn't infer template argument 'T'}} void g() { f(); } // expected-error {{no matching function for call to 'f'}} } + +class PR33189 +{ + template <class T> + ~PR33189() { } // expected-error{{destructor cannot be declared as a template}} +}; Index: lib/AST/DeclCXX.cpp =================================================================== --- lib/AST/DeclCXX.cpp +++ lib/AST/DeclCXX.cpp @@ -1417,11 +1417,8 @@ Context.getCanonicalType(ClassType)); DeclContext::lookup_result R = lookup(Name); - if (R.empty()) - return nullptr; - CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(R.front()); - return Dtor; + return R.empty() ? nullptr : dyn_cast<CXXDestructorDecl>(R.front()); } bool CXXRecordDecl::isAnyDestructorNoReturn() const {
Index: test/SemaTemplate/destructor-template.cpp =================================================================== --- test/SemaTemplate/destructor-template.cpp +++ test/SemaTemplate/destructor-template.cpp @@ -86,3 +86,9 @@ template<typename T> decltype(S<T>().~S()) f(); // expected-note {{candidate template ignored: couldn't infer template argument 'T'}} void g() { f(); } // expected-error {{no matching function for call to 'f'}} } + +class PR33189 +{ + template <class T> + ~PR33189() { } // expected-error{{destructor cannot be declared as a template}} +}; Index: lib/AST/DeclCXX.cpp =================================================================== --- lib/AST/DeclCXX.cpp +++ lib/AST/DeclCXX.cpp @@ -1417,11 +1417,8 @@ Context.getCanonicalType(ClassType)); DeclContext::lookup_result R = lookup(Name); - if (R.empty()) - return nullptr; - CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(R.front()); - return Dtor; + return R.empty() ? nullptr : dyn_cast<CXXDestructorDecl>(R.front()); } bool CXXRecordDecl::isAnyDestructorNoReturn() const {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits