[PATCH] Instantiate incomplete class used in template method.

Serge Pavlov sepavloff at gmail.com
Mon Apr 6 12:48:33 PDT 2015


Hi Richard,

2015-04-06 6:16 GMT+06:00 Richard Smith <richard at metafoo.co.uk>:

> Please add a testcase that uses a forward declaration and then defines it,
> such as:
>
>   template<typename T> void f() {
>     void g(struct x);
>     struct x {};
>   }
>   template void f<int>();
>
> I think a case like that will still assert with your current patch
> (because `x` is not an incomplete type, but it won't have had a declaration
> instantiated when we instantiate the declaration of `g`).
>
>
Yes, you are right, this case was not handled. Added instantiation of the
type for which we see forward declaration.


> ================
> Comment at: lib/Sema/SemaTemplateInstantiate.cpp:2802
> @@ +2801,3 @@
> +  if (const TagDecl *TD = dyn_cast<TagDecl>(D))
> +    if (TD->getTypeForDecl()->isIncompleteType())
> +      return nullptr;
> ----------------
> This should use the same condition as the other change.
>
>
Fixed.

Thanks,
--Serge
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150407/df33cc69/attachment.html>


More information about the cfe-commits mailing list