Skip to content

Commit

Permalink
Fix newtype init/recursion/segfault bug
Browse files Browse the repository at this point in the history
  • Loading branch information
agemogolk committed Nov 19, 2012
1 parent fb63da9 commit 02de32f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions compiler/analyzer.cpp
Expand Up @@ -869,9 +869,9 @@ MultiPValuePtr analyzeStaticObject(ObjectPtr x)
case NEW_TYPE_DECL : {
NewTypeDecl *y = (NewTypeDecl *)x.ptr();
assert(y->type->typeKind == NEW_TYPE);
initializeNewType((NewType*)y->type.ptr());
initializeNewType(y->type);

return new MultiPValue(PVData(y->type, true));
return new MultiPValue(PVData(y->type.ptr(), true));
}

case ENUM_MEMBER : {
Expand Down
2 changes: 1 addition & 1 deletion compiler/clay.hpp
Expand Up @@ -2004,7 +2004,7 @@ struct IntrinsicSymbol : public TopLevelItem {

struct NewTypeDecl : public TopLevelItem {
ExprPtr expr;
TypePtr type;
NewTypePtr type;
TypePtr baseType;
bool initialized:1;
NewTypeDecl(Module *module, IdentifierPtr name,
Expand Down
6 changes: 3 additions & 3 deletions compiler/types.cpp
Expand Up @@ -422,7 +422,7 @@ TypePtr newType(NewTypeDeclPtr newtype)
{
if (!newtype->type)
newtype->type = new NewType(newtype);
return newtype->type;
return newtype->type.ptr();
}

TypePtr newtypeReprType(NewTypePtr t)
Expand Down Expand Up @@ -967,7 +967,7 @@ static void verifyRecursionCorrectness(TypePtr t,
}
case NEW_TYPE : {
NewType *nt = (NewType *)t.ptr();
verifyRecursionCorrectness(nt->newtype->baseType, visited);
verifyRecursionCorrectness(newtypeReprType(nt), visited);
break;
}
default :
Expand Down Expand Up @@ -1052,8 +1052,8 @@ llvm::Type *CCodePointerType::getCallType() {

static void makeLLVMType(TypePtr t) {
if (t->llType == NULL) {
declareLLVMType(t);
verifyRecursionCorrectness(t);
declareLLVMType(t);
}
if (!t->defined) {
defineLLVMType(t);
Expand Down

0 comments on commit 02de32f

Please sign in to comment.