arphaman added a comment.

In https://reviews.llvm.org/D25777#575564, @rjmccall wrote:

> The fact that this bug only arises when performing a *second* instantiation 
> suggests that there's a deeper bug here, because template instantiation is 
> not supposed to modify the pattern AST.  In this case, the basic problem is 
> that, when the parser processes a designator, it only has an identifier, not 
> a FieldDecl*, because it doesn't know what type is being initialized yet.  
> SemaInit eventually resolves that identifier to a FieldDecl and needs to 
> record that in the AST; typically the AST is treated as immutable, but in 
> this case, instead of cloning the expression, Sema just modifies the field 
> designator in-place.  That's not completely unreasonable, and it's definitely 
> the most space-efficient solution for non-template code-building; but in 
> template code, it does mean that we have to take care to not present the same 
> unresolved field designator to Sema twice.
>
> Fortunately, this is pretty easy: we just need to need to flag the expression 
> as needing rebuilding when there isn't a resolved field in the field 
> designator.  When there *is* a resolved field, we just need to map it using 
> TransformDecl; the expression then only needs to be rebuilt if that fails or 
> returns a different declaration.


You're right, the point that you made about modifying the pattern AST is 
correct. I will update the patch accordingly.


Repository:
  rL LLVM

https://reviews.llvm.org/D25777



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to