Add error messages for structs containing nested undefined structs
This commit is contained in:
19
expr.cpp
19
expr.cpp
@@ -5143,9 +5143,18 @@ MemberExpr::create(Expr *e, const char *id, SourcePos p, SourcePos idpos,
|
||||
exprType->GetString().c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (CastType<StructType>(exprType) != NULL)
|
||||
if (CastType<StructType>(exprType) != NULL) {
|
||||
const StructType *st = CastType<StructType>(exprType);
|
||||
if (st->IsDefined()) {
|
||||
return new StructMemberExpr(e, id, p, idpos, derefLValue);
|
||||
}
|
||||
else {
|
||||
Error(p, "Member operator \"%s\" can't be applied to declared "
|
||||
"struct \"%s\" containing an undefined struct type.", derefLValue ? "->" : ".",
|
||||
exprType->GetString().c_str());
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if (CastType<VectorType>(exprType) != NULL)
|
||||
return new VectorMemberExpr(e, id, p, idpos, derefLValue);
|
||||
else if (CastType<UndefinedStructType>(exprType)) {
|
||||
@@ -8708,6 +8717,12 @@ NewExpr::TypeCheck() {
|
||||
"but not defined type \"%s\".", allocType->GetString().c_str());
|
||||
return NULL;
|
||||
}
|
||||
const StructType *st = CastType<StructType>(allocType);
|
||||
if (st != NULL && !st->IsDefined()) {
|
||||
Error(pos, "Can't dynamically allocate storage for declared "
|
||||
"type \"%s\" containing undefined member type.", allocType->GetString().c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Otherwise we only need to make sure that if we have an expression
|
||||
// giving a number of elements to allocate that it can be converted to
|
||||
|
||||
Reference in New Issue
Block a user