Upon instantiating function decls, we should mark visible any tag decl in the function's body.
Details
Diff Detail
Event Timeline
lib/Sema/SemaLookup.cpp | ||
---|---|---|
1546–1548 ↗ | (On Diff #67988) | This check should already do the right thing for the case of a function-scope declaration. |
test/Modules/Inputs/PR28794/Subdir/LibBHeader.h | ||
7–11 | 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. |
lib/Sema/SemaTemplateInstantiateDecl.cpp | ||
---|---|---|
3596–3597 | 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." | |
3597–3602 | 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. |
lib/Sema/SemaTemplateInstantiateDecl.cpp | ||
---|---|---|
3598–3599 | 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. | |
3652–3655 | 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. |
lib/Sema/SemaTemplateInstantiateDecl.cpp | ||
---|---|---|
3597–3602 | 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). |
lib/Sema/SemaTemplateInstantiateDecl.cpp | ||
---|---|---|
3597–3602 | 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. |
lib/Sema/SemaTemplateInstantiateDecl.cpp | ||
---|---|---|
3617 | 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. |
lib/Sema/SemaTemplateInstantiateDecl.cpp | ||
---|---|---|
3617 | 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. |
lib/Sema/SemaTemplateInstantiateDecl.cpp | ||
---|---|---|
3617 | Thanks! Otherwise, maybe creduce could help. |
Should be fixed in r279486, which also incorporates the updates to this change since it landed (sinking diagnostics into DiagnoseUninstantiableTemplate).
lib/Sema/SemaTemplate.cpp | ||
---|---|---|
494–495 | } and else on the same line please. (Here and in a couple of places below.) | |
499–501 | Sink this into the err_template_instantiate_undefined case below. | |
503–505 | Sink this into the InstantiatedFromMember case below. |
} and else on the same line please. (Here and in a couple of places below.)