Skip to content

Commit

Permalink
compiler: limit level of pointer-to-pointer-to-... types
Browse files Browse the repository at this point in the history
  • Loading branch information
dgryski authored and deadprogram committed Jun 9, 2023
1 parent f5f4751 commit 0212f0c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ func (c *compilerContext) getTypeCode(typ types.Type) llvm.Value {
if _, ok := typ.Elem().(*types.Pointer); ok {
// For a pointer to a pointer, we just increase the pointer by 1
ptr := c.getTypeCode(typ.Elem())
// if the type is already *****T or higher, we can't make it.
if typstr := typ.String(); strings.HasPrefix(typstr, "*****") {
c.addError(token.NoPos, fmt.Sprintf("too many levels of pointers for typecode: %s", typstr))
}
return llvm.ConstGEP(c.ctx.Int8Type(), ptr, []llvm.Value{
llvm.ConstInt(llvm.Int32Type(), 1, false),
})
Expand Down

0 comments on commit 0212f0c

Please sign in to comment.