TreeTransform question

I'm working on making the new labeldecl stuff instantiate properly with TreeTransform (fixing some attributes related stuff along the way) and am running into a stumbling block.

I have LabelStmt doing:

+ Decl *LD = getDerived().TransformDefinition(S->getDecl()->getLocation(),
+ S->getDecl());
+ if (!LD)
+ return StmtError();

which seems to work, and uses of labels (like goto) do this:

TreeTransform<Derived>::TransformGotoStmt(GotoStmt *S) {
+ Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
+ S->getLabel());
+ if (!LD)
+ return StmtError();

The problem is that cases where the label is used before it is defined explodes tree transform with:

Assertion failed: (D->isInvalidDecl() && "declaration was not instantiated in this scope!"), function findInstantiationOf, file SemaTemplateInstantiate.cpp, line 2206.

What is the right level to instantiate the label decl? It seems that I could just make TransformDecl do the instantiation... is this the best place to do it?

This is my patch in progress, mostly for my own benefit when I get to work tomorrow, but also perhaps useful:

-Chris

p.patch (20 KB)

You could teach TransformDecl to look into the current instantiation scope (first) to see if the LabelDecl has been instantiated already; if not, go ahead and instantiate the LabelDecl.

  - Doug

Thanks Doug, that worked!

-Chris