Upon instantiating function decls, we should mark visible any tag decl in the function's body.
|1546–1548 ↗||(On Diff #67988)|
This check should already do the right thing for the case of a function-scope declaration.
We should not be instantiating this template in the first place: the template definition should not be visible within pr28794.cpp because the LibBHeader.h submodule is never imported. I would guess the bug is that we're missing a visibility check for the template definition when we trigger the instantiation here.
Please update this FIXME to just "We need to track the instantiation stack in order to know which definitions should be visible within this instantiation."
I think this should be checked before we deal with late-parsed templates -- if the template definition isn't visible, an attempt to instantiate it shouldn't trigger it being parsed.
If you can do that, it would be preferable. You'll presumably need to change the PatternDecl argument to PatternDecl->isThisDeclarationADefinition() || PatternDecl->isDefaulted() ? PatternDecl : nullptr or similar.
Yes, let's do this. It's not quite right, but the same is true for the InstantiateClass and InstantiateEnum cases, and it makes sense to handle all those cases the same way.
If I am to sink the diags under the // TODO: this might change behavior. The diagnostics may not kick-in properly in case of late template parsing (see around line 3594).
As long as we treat a late-parsed template as being defined, it should be fine (and looking at FunctionDecl::isThisDeclarationADefinition, we do). It's not correct to parse a late-parsed template that's not visible, so we need to move this check to before we handle late-parsed templates for correctness.
Line 3619 to 3623 breaks the compilation of some of our targets. I am not sure if it is because of a mistake in our code or if there is something bad in this patch.
I tried to create a simple example, but those simple cases worked fine. So I am not sure what is going on in the more complex cases. I have asked Richard for help. Since Richard has access to that broken code, I hope he will figure it out.
Should be fixed in r279486, which also incorporates the updates to this change since it landed (sinking diagnostics into DiagnoseUninstantiableTemplate).
} and else on the same line please. (Here and in a couple of places below.)
Sink this into the err_template_instantiate_undefined case below.
Sink this into the InstantiatedFromMember case below.