cgo: don't crash on import "C"
without comment
This doesn't make a lot of sense, but we shouldn't crash on it.
Этот коммит содержится в:
родитель
99587fe073
коммит
4619207f99
2 изменённых файлов: 8 добавлений и 2 удалений
|
@ -145,8 +145,12 @@ func (p *Package) processCgo(filename string, f *ast.File, cflags []string) []er
|
|||
// source location.
|
||||
info.importCPos = spec.Path.ValuePos
|
||||
|
||||
pos := info.fset.PositionFor(genDecl.Doc.Pos(), true)
|
||||
errs := info.parseFragment(cgoComment+cgoTypes, cflags, pos.Filename, pos.Line)
|
||||
pos := genDecl.Pos()
|
||||
if genDecl.Doc != nil {
|
||||
pos = genDecl.Doc.Pos()
|
||||
}
|
||||
position := info.fset.PositionFor(pos, true)
|
||||
errs := info.parseFragment(cgoComment+cgoTypes, cflags, position.Filename, position.Line)
|
||||
if errs != nil {
|
||||
return errs
|
||||
}
|
||||
|
|
2
testdata/cgo/main.go
предоставленный
2
testdata/cgo/main.go
предоставленный
|
@ -7,6 +7,8 @@ int mul(int, int);
|
|||
*/
|
||||
import "C"
|
||||
|
||||
import "C"
|
||||
|
||||
import "unsafe"
|
||||
|
||||
func main() {
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче