File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
c/common/src/codingstandards/c Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -169,10 +169,16 @@ class CEmptyStructExtension extends CCompilerExtension, Struct {
169169}
170170
171171// Reference: https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html#Variable-Length
172- class CVariableLengthArraysExtension extends CCompilerExtension , DeclarationEntry {
172+ class CVariableLengthArraysExtension extends CCompilerExtension , Field {
173173 CVariableLengthArraysExtension ( ) {
174174 getType ( ) instanceof ArrayType and
175- not getType ( ) .( ArrayType ) .hasArraySize ( )
175+ not getType ( ) .( ArrayType ) .hasArraySize ( ) and
176+ // Not the final member of the struct, which is allowed to be variably sized
177+ not exists ( int lastIndex , Class declaringStruct |
178+ declaringStruct = getDeclaringType ( ) and
179+ lastIndex = count ( declaringStruct .getACanonicalMember ( ) ) - 1 and
180+ this = declaringStruct .getCanonicalMember ( lastIndex )
181+ )
176182 }
177183
178184 override string getMessage ( ) {
You can’t perform that action at this time.
0 commit comments