Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix newtype init/recursion/segfault bug

  • Loading branch information...
commit 02de32f16bd5208a0b7ee7435b76a8f3e9f15afd 1 parent fb63da9
@agemogolk agemogolk authored
View
4 compiler/analyzer.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
2  compiler/clay.hpp
@@ -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
6 compiler/types.cpp
@@ -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.
Something went wrong with that request. Please try again.