Permalink
Browse files

Fix newtype init/recursion/segfault bug

  • Loading branch information...
1 parent fb63da9 commit 02de32f16bd5208a0b7ee7435b76a8f3e9f15afd agemogolk committed Nov 19, 2012
Showing with 6 additions and 6 deletions.
  1. +2 −2 compiler/analyzer.cpp
  2. +1 −1 compiler/clay.hpp
  3. +3 −3 compiler/types.cpp
@@ -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 : {
View
@@ -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,
View
@@ -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)
@@ -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 :
@@ -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);

0 comments on commit 02de32f

Please sign in to comment.