[PATCH] Instantiate incomplete class used in template method.

Richard Smith richard at metafoo.co.uk
Mon Mar 23 13:57:26 PDT 2015


This looks like a good approach to me.


================
Comment at: lib/Sema/SemaTemplateInstantiate.cpp:2797-2798
@@ +2796,4 @@
+  // may not have a chance to instantiate it.
+  if (const TypeDecl *TD = dyn_cast<TypeDecl>(D))
+    if (TD->getTypeForDecl()->isIncompleteType())
+      return nullptr;
----------------
I think this should only apply to `TagDecl`s. You should then instantiate if `!TD->isThisDeclarationADefiinition() && !TD->isFreeStanding()`. Ideally, the freestanding check would instead check `isEmbeddedInDeclarator`, but it looks like we don't instantiate the tag early enough for that to work in cases like

    template<typename T> void f() { void g(struct x); }
    template void f<int>();

http://reviews.llvm.org/D8281

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list