mirror of
https://github.com/cc65/cc65.git
synced 2025-01-18 11:29:45 +00:00
Fixed regression: array element of incomplete type.
This commit is contained in:
parent
94ef5856d0
commit
85e63e99a6
@ -511,7 +511,7 @@ void Compile (const char* FileName)
|
|||||||
|
|
||||||
/* Mark as defined; so that it will be exported, not imported */
|
/* Mark as defined; so that it will be exported, not imported */
|
||||||
Entry->Flags |= SC_DEF;
|
Entry->Flags |= SC_DEF;
|
||||||
} else {
|
} else if (!IsTypeArray (Entry->Type)) {
|
||||||
/* Tentative declared variable is still of incomplete type */
|
/* Tentative declared variable is still of incomplete type */
|
||||||
Error ("Definition of '%s' has type '%s' that is never completed",
|
Error ("Definition of '%s' has type '%s' that is never completed",
|
||||||
Entry->Name,
|
Entry->Name,
|
||||||
|
@ -493,33 +493,35 @@ static void FixQualifiers (Type* DataType)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void CheckArrayElementType (Type* DataType)
|
static void CheckArrayElementType (const Type* T)
|
||||||
/* Check if data type consists of arrays of incomplete element types */
|
/* Check if data type consists of arrays of incomplete element types */
|
||||||
{
|
{
|
||||||
Type* T = DataType;
|
|
||||||
|
|
||||||
while (T->C != T_END) {
|
while (T->C != T_END) {
|
||||||
if (IsTypeArray (T)) {
|
if (IsTypeArray (T)) {
|
||||||
++T;
|
/* If the array is multi-dimensional, keep going until we get the
|
||||||
if (IsIncompleteESUType (T)) {
|
** true element type.
|
||||||
/* We cannot have an array of incomplete elements */
|
|
||||||
Error ("Array of incomplete element type '%s'", GetFullTypeName (T));
|
|
||||||
} else if (SizeOf (T) == 0) {
|
|
||||||
/* If the array is multi-dimensional, try to get the true
|
|
||||||
** element type.
|
|
||||||
*/
|
*/
|
||||||
if (IsTypeArray (T)) {
|
++T;
|
||||||
continue;
|
if (SizeOf (T) == 0) {
|
||||||
|
if (IsTypeArray (T) || IsIncompleteESUType (T)) {
|
||||||
|
/* We cannot have an array of incomplete elements */
|
||||||
|
if (!IsTypeArray (T) || GetElementCount (T) == UNSPECIFIED) {
|
||||||
|
Error ("Array of incomplete element type '%s'",
|
||||||
|
GetFullTypeName (T));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (!IsTypeVoid (T) || IS_Get (&Standard) != STD_CC65) {
|
||||||
/* We could support certain 0-size element types as an extension */
|
/* We could support certain 0-size element types as an extension */
|
||||||
if (!IsTypeVoid (T) || IS_Get (&Standard) != STD_CC65) {
|
Error ("Array of 0-size element type '%s'",
|
||||||
Error ("Array of 0-size element type '%s'", GetFullTypeName (T));
|
GetFullTypeName (T));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (IsTypeStruct (T)) {
|
if (IsTypeStruct (T)) {
|
||||||
SymEntry* TagEntry = GetESUTagSym (T);
|
SymEntry* TagEntry = GetESUTagSym (T);
|
||||||
if (TagEntry && SymHasFlexibleArrayMember (TagEntry)) {
|
if (TagEntry && SymHasFlexibleArrayMember (TagEntry)) {
|
||||||
Error ("Invalid use of struct with flexible array member");
|
Error ("Invalid use of struct with flexible array member");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
test/err/zero-size.c
Normal file
6
test/err/zero-size.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
char a[][] = { 0, 0 }; /* Error: Array type has incomplete element type 'char[]' */
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user