The error-bit was missing, if a DeclRefExpr (which refers to a VarDecl
with a contains-errors initializer).
It could cause different violations in clang -- the DeclRefExpr is value-dependent,
but not contains-errors, decltype(DeclRefExpr) could produce a non-error
dependent type in non-template context.
The current fix (by invalidating the member decl) is probably suboptimal.
The crash is caused by the fact that we escape the dependent-type guard in HandleSizeOf -- the recordType T is not type-dependent, because the implementation TagDecl::isDependentType just checks isDependentContext().
This is incorrect after recovery-expr is introduced -- in this example, ABC<N> abc is type-dependent because the template argument DeclRefExpr is value-dependent,
so the recordType T should be type-dependent.
I think right fix is to make the recordType T type-dependent, but there are a few tricky things in clang making it harder:
To set the type-dependent, we need to see class body, by that time, the TagType is created, and cached, I'm not sure it is reasonable to rewrite the dependence-bits when we complete a class definition. Any suggestions?