kuang_he created this revision.

This patch aim to fix bug reported at 
https://bugs.llvm.org/show_bug.cgi?id=33189. Clang hit assertion on template 
destructor declaration


https://reviews.llvm.org/D33833

Files:
  lib/AST/DeclCXX.cpp
  test/SemaCXX/PR33189.cpp


Index: test/SemaCXX/PR33189.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/PR33189.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+class U
+{
+  template <class T>
+  ~U() { } // expected-error{{destructor cannot be declared as a template}}
+};
Index: lib/AST/DeclCXX.cpp
===================================================================
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1417,7 +1417,7 @@
                                           Context.getCanonicalType(ClassType));
 
   DeclContext::lookup_result R = lookup(Name);
-  if (R.empty())
+  if (R.empty() || !isa<CXXDestructorDecl>(R.front()))
     return nullptr;
 
   CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(R.front());


Index: test/SemaCXX/PR33189.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/PR33189.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+class U
+{
+  template <class T>
+  ~U() { } // expected-error{{destructor cannot be declared as a template}}
+};
Index: lib/AST/DeclCXX.cpp
===================================================================
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1417,7 +1417,7 @@
                                           Context.getCanonicalType(ClassType));
 
   DeclContext::lookup_result R = lookup(Name);
-  if (R.empty())
+  if (R.empty() || !isa<CXXDestructorDecl>(R.front()))
     return nullptr;
 
   CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(R.front());
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to