[PATCH] PR20716 - Crash when recovering from type in known dependent base (ms-compatibility)

Nikola Smiljanić popizdeh at gmail.com
Wed Aug 20 17:19:28 PDT 2014


Hi rnk,

The call to cast crashes because getTemplateDecl returns null for TemplateTemplateParmDecls.

http://reviews.llvm.org/D4992

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaTemplate/ms-lookup-template-base-classes.cpp

Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -150,7 +150,7 @@
     if (!TST || !TST->isDependentType())
       continue;
     auto *TD = TST->getTemplateName().getAsTemplateDecl();
-    if (!TD)
+	if (!TD || !TD->getTemplatedDecl())
       continue;
     auto *BasePrimaryTemplate = cast<CXXRecordDecl>(TD->getTemplatedDecl());
     // FIXME: Allow lookup into non-dependent bases of dependent bases, possibly
Index: test/SemaTemplate/ms-lookup-template-base-classes.cpp
===================================================================
--- test/SemaTemplate/ms-lookup-template-base-classes.cpp
+++ test/SemaTemplate/ms-lookup-template-base-classes.cpp
@@ -460,3 +460,19 @@
   int x = f<NameFromBase>();
 };
 }
+
+namespace PR20716 {
+template <class T>
+struct A
+{
+  void foo() {}
+};
+
+template <template <typename T> class C>
+struct B : public C<int>
+{
+  void bar() {
+    foo();
+  }
+};
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4992.12721.patch
Type: text/x-patch
Size: 1010 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140821/8415652e/attachment.bin>


More information about the cfe-commits mailing list