compiler: Handle nil array and struct constants
This is necessary for tools 0.9.0, which started lifting those since
71ea8f168c
Этот коммит содержится в:
родитель
43d282174f
коммит
bf73516259
1 изменённых файлов: 10 добавлений и 0 удалений
|
@ -3005,6 +3005,11 @@ func (c *compilerContext) createConst(expr *ssa.Const, pos token.Pos) llvm.Value
|
|||
panic("expected nil pointer constant")
|
||||
}
|
||||
return llvm.ConstPointerNull(c.getLLVMType(typ))
|
||||
case *types.Array:
|
||||
if expr.Value != nil {
|
||||
panic("expected nil array constant")
|
||||
}
|
||||
return llvm.ConstNull(c.getLLVMType(expr.Type()))
|
||||
case *types.Slice:
|
||||
if expr.Value != nil {
|
||||
panic("expected nil slice constant")
|
||||
|
@ -3018,6 +3023,11 @@ func (c *compilerContext) createConst(expr *ssa.Const, pos token.Pos) llvm.Value
|
|||
llvmLen, // cap
|
||||
}, false)
|
||||
return slice
|
||||
case *types.Struct:
|
||||
if expr.Value != nil {
|
||||
panic("expected nil struct constant")
|
||||
}
|
||||
return llvm.ConstNull(c.getLLVMType(expr.Type()))
|
||||
case *types.Map:
|
||||
if !expr.IsNil() {
|
||||
// I believe this is not allowed by the Go spec.
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче