Add support for enums.
This commit is contained in:
10
stmt.cpp
10
stmt.cpp
@@ -152,13 +152,14 @@ lInitSymbol(llvm::Value *lvalue, const char *symName, const Type *type,
|
||||
}
|
||||
}
|
||||
|
||||
// Atomic types can't be initialized with { ... } initializer
|
||||
// Atomic types and enums can't be initialized with { ... } initializer
|
||||
// expressions, so print an error and return if that's what we've got
|
||||
// here..
|
||||
if (dynamic_cast<const AtomicType *>(type) != NULL) {
|
||||
if (dynamic_cast<const AtomicType *>(type) != NULL ||
|
||||
dynamic_cast<const EnumType *>(type) != NULL) {
|
||||
if (dynamic_cast<ExprList *>(initExpr) != NULL)
|
||||
Error(initExpr->pos, "Expression list initializers can't be used for "
|
||||
"variable \"%s\' with atomic type \"%s\".", symName,
|
||||
"variable \"%s\' with type \"%s\".", symName,
|
||||
type->GetString().c_str());
|
||||
return;
|
||||
}
|
||||
@@ -373,7 +374,8 @@ DeclStmt::TypeCheck() {
|
||||
// the int->float type conversion is in there and we don't return
|
||||
// an int as the constValue later...
|
||||
const Type *type = decl->sym->type;
|
||||
if (dynamic_cast<const AtomicType *>(type) != NULL) {
|
||||
if (dynamic_cast<const AtomicType *>(type) != NULL ||
|
||||
dynamic_cast<const EnumType *>(type) != NULL) {
|
||||
// If it's an expr list with an atomic type, we'll later issue
|
||||
// an error. Need to leave decl->initExpr as is in that case so it
|
||||
// is in fact caught later, though.
|
||||
|
||||
Reference in New Issue
Block a user