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

Reid Kleckner rnk at google.com
Thu Aug 21 11:15:28 PDT 2014


Feel free to land with fixes.

================
Comment at: lib/Sema/SemaDecl.cpp:155-156
@@ -154,10 +154,4 @@
       continue;
-    auto *BasePrimaryTemplate = cast<CXXRecordDecl>(TD->getTemplatedDecl());
-    // FIXME: Allow lookup into non-dependent bases of dependent bases, possibly
-    // by calling or integrating with the main LookupQualifiedName mechanism.
-    for (NamedDecl *ND : BasePrimaryTemplate->lookup(&II)) {
-      if (FoundTypeDecl)
-        return ParsedType();
-      FoundTypeDecl = isa<TypeDecl>(ND);
-      if (!FoundTypeDecl)
-        return ParsedType();
+    if (CXXRecordDecl *BasePrimaryTemplate =
+            dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl())) {
+      // FIXME: Allow lookup into non-dependent bases of dependent bases, possibly
----------------
I think this change can just be s/cast/dyn_cast_or_null/ and inserting "if (!BasePrimaryTemplate) continue;"

================
Comment at: test/SemaTemplate/ms-lookup-template-base-classes.cpp:468-470
@@ +467,5 @@
+{
+  void bar() {
+    foo();
+  }
+};
----------------
These 'foo' identifiers are getting delayed by ADL because they are function calls. I would try to use an unqualified name to try to declare a member, since I believe only a type can occur there.

http://reviews.llvm.org/D4992






More information about the cfe-commits mailing list