mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 02:33:28 +00:00
cgo: don't crash on import "C" without comment
This doesn't make a lot of sense, but we shouldn't crash on it.
This commit is contained in:
committed by
Ron Evans
parent
99587fe073
commit
4619207f99
+6
-2
@@ -145,8 +145,12 @@ func (p *Package) processCgo(filename string, f *ast.File, cflags []string) []er
|
|||||||
// source location.
|
// source location.
|
||||||
info.importCPos = spec.Path.ValuePos
|
info.importCPos = spec.Path.ValuePos
|
||||||
|
|
||||||
pos := info.fset.PositionFor(genDecl.Doc.Pos(), true)
|
pos := genDecl.Pos()
|
||||||
errs := info.parseFragment(cgoComment+cgoTypes, cflags, pos.Filename, pos.Line)
|
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 {
|
if errs != nil {
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
@@ -7,6 +7,8 @@ int mul(int, int);
|
|||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
|
import "C"
|
||||||
|
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
Reference in New Issue
Block a user