aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2021-04-09 00:32:58 +0200
committerRon Evans <[email protected]>2021-04-09 14:05:44 +0200
commitb61751e4298401150661a20bf689c45e6065b58a (patch)
tree80f2b4c8b75b55ed5d498928fb301fa0e0b3436d
parent25dac32a88eb8260ed4ceeb0c4b32c888c1896c7 (diff)
downloadtinygo-b61751e4298401150661a20bf689c45e6065b58a.tar.gz
tinygo-b61751e4298401150661a20bf689c45e6065b58a.zip
compiler: check for errors
Some errors were generated but never returned or never checked in the test function. That's a problem. Therefore this commit fixes this oversight (by me).
-rw-r--r--compiler/compiler.go2
-rw-r--r--compiler/compiler_test.go7
2 files changed, 7 insertions, 2 deletions
diff --git a/compiler/compiler.go b/compiler/compiler.go
index d652f5404..acf85cd88 100644
--- a/compiler/compiler.go
+++ b/compiler/compiler.go
@@ -298,7 +298,7 @@ func CompilePackage(moduleName string, pkg *loader.Package, ssaPkg *ssa.Package,
c.dibuilder.Finalize()
}
- return c.mod, nil
+ return c.mod, c.diagnostics
}
// getLLVMRuntimeType obtains a named type from the runtime package and returns
diff --git a/compiler/compiler_test.go b/compiler/compiler_test.go
index 5f2d18f45..202ed16fd 100644
--- a/compiler/compiler_test.go
+++ b/compiler/compiler_test.go
@@ -84,11 +84,16 @@ func TestCompiler(t *testing.T) {
mod, errs := CompilePackage(testCase, pkg, program.Package(pkg.Pkg), machine, compilerConfig, false)
if errs != nil {
for _, err := range errs {
- t.Log("error:", err)
+ t.Error(err)
}
return
}
+ err = llvm.VerifyModule(mod, llvm.PrintMessageAction)
+ if err != nil {
+ t.Error(err)
+ }
+
// Optimize IR a little.
funcPasses := llvm.NewFunctionPassManagerForModule(mod)
defer funcPasses.Dispose()