While emitting Array Constant, if the destination type is null-pointer, it will cause an assert. This patch will check if the destination type is null, and if so then it will just return nullptr as the array constant (not something that is derived from destination type).
A test case is also attached.
Details
- Reviewers
arphaman dexonsmith ahatanak rjmccall
Diff Detail
Event Timeline
I think the right fix here is to ensure that DestType is non-null at a higher level. Older branches of the compiler seem to be able to correctly emit this, probably because the initializer generated for this field ends up having type a[0]. Maybe we've just done some refactor that tries to optimize that but doesn't handle flexible array members correctly.
test/CodeGenCXX/empty-struct-init-list.cpp | ||
---|---|---|
2–5 | You should add -emit-llvm, or else CodeGen won't even run. Also, expected-no-diagnostics only means anything when -verify is included on the run line. |
test/CodeGenCXX/empty-struct-init-list.cpp | ||
---|---|---|
12 | Please make this a FileCheck test that tests the actual compiler output. |
Added FileCheck as requested by John McCall
Made comments start with "//" instead of /*
Removed expected-no-diagnostics from the test case (as requested by Erik)
John, I have updated the test case as you requested (I think). I am a bit new to Clang, so apologize if I mistook your request.
It definitely means that it's an incomplete array type, i.e. a flexible array member.