I just landed a bunch of declgroup stuff (yay), but there are two outstanding issues:
1) Ted, now that DeclGroups have landed, there is no need to chase the NextDeclarator chain in StmtIterator. I think it can be substantially simplified, I did a minimal hack and added a fixme. Please investigate to see if it can get even simpler.
2) Doug (and other C++ folks), I added a truly awful hack to SemaTemplate.cpp, which only works because of the current bit layout of DeclPtrTy and DeclGroupPtrTy. The basic issue is that clang currently accepts malformed code like:
template<typename X> int Y, Z;
(and similar examples with one variable, for that matter).
I am pretty sure that you can never have multiple declarators after a template specifier like this. However, the code in ParseTemplate.cpp that handles this just calls into ParseDeclarationOrFunctionDefinition, which can parse multiple declarators like the above.
I think the best thing to do here is to change ParseTemplateDeclarationOrSpecialization to call something like ParseDeclarationOrFunctionDefinition that is known to never return multiple decls. This could be typed as returning DeclPtrTy instead of DeclGroupPtrTy.
Another approach would be to call ParseDeclarationOrFunctionDefinition, then doing some sema to make sure that there is only one decl in it. The sema action would take the DeclGroup returned by ParseDeclarationOrFunctionDefinition, validate it, then returns a single Decl back.
Can you take a look?