Another verify_cgraph problem
Johannes Pfau
nospam at example.com
Sun Jan 13 08:02:55 PST 2013
Am Sat, 12 Jan 2013 11:57:10 +0100
schrieb Johannes Pfau <nospam at example.com>:
> A template's toObjFile does nothing, but all my naive attempts to call
> e.g.
> declaration->isTemplateDeclaration()>onemember->isDeclaration()->toObjFile(false)
> fail with a strange error.
OK, of course it can't work. toObjFile has to be called on the
TemplateInstance, not on the declaration...
All TemplateInstances are currently emitted by Module::genobjfile which
loops through all Dsymbols in the module. Therefore the scope for
functions in template instances is always the module scope which is
incorrect.
A simple approach to fix this is delaying emitting those templates and
emitting functions first, then change function output to emit template
instances.
Here's this simple approach: https://gist.github.com/4524721
The problem is that this can still miss cases where we have a template
nested in a template*. In this case the order is important and the top
level template instance should be output first, so I'm not sure how to
fix this.
I wonder whether the frontend should (or even already does) sort
template instances into a tree?
>
> I'll have to recheck the test case from last week, maybe it's also
> scope related.
Update: no, that test case was not related to this scoping issue.
*
------------------------------------------------------------------
struct TopLevel(T)
{
void topFunc()()
{
void level2Helper(){} //scope topFunc
void level2Func()() //scope topFunc
{
void level3Helper(){} //scope level2Func
void level3()() //scope level2Func
{
level3Helper();
}
level2Helper();
}
}
}
TopLevel!int abcd;
More information about the D.gnu
mailing list