[PATCH] PR13788 - sema crash on add initializer

Adding cfe-dev…

depdeclinit.patch (1.38 KB)

Adding cfe-dev...

Dropping cfe-dev via bcc, you were right first time.

The attached patch needs review please!

I suspect that we may need to call RequireCompleteType() to do
instantiation *even if* the VDecl is a dependent type. I am not yet able to
reason about this though.

I'm not sure I follow how this comment relates to the patch.

The patch prevents the abort, and the test case (extended with code to
print initialized data) output looks the same in clang and gcc.

- QualType baseType = Context.getBaseElementType(var->getType());
- if (baseType->isDependentType()) return;
+ QualType type = var->getType();
+ QualType baseType = Context.getBaseElementType(type);
+ if (type->isDependentType() || baseType->isDependentType())
+ return;

You only need to check 'type' here. It will be dependent whenever 'baseType' is.

--- test/SemaCXX/PR13788.cpp (revision 0)
+++ test/SemaCXX/PR13788.cpp (revision 0)

We prefer to add tests to existing test files when that is reasonable.
test/SemaTemplate/dependent-sized_array.cpp seems like a good place
for this test (please add a comment pointing at PR13788 to the test
case, or put it in namespace PR13788, or similar).

Thanks!