compiler: detect failure to set init priority for package
This would have caught the problem fixed by https://golang.org/cl/43610.
Change-Id: I357f6618cbe8c034f64512bbb83bb740f0149c2f
Reviewed-on: https://go-review.googlesource.com/43999
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/go/gogo.cc b/go/gogo.cc
index daf2ba4..26f6441 100644
--- a/go/gogo.cc
+++ b/go/gogo.cc
@@ -689,7 +689,13 @@
this->imported_init_fns_.begin();
p != this->imported_init_fns_.end();
++p)
- v.push_back(*p);
+ {
+ if ((*p)->priority() < 0)
+ go_error_at(Linemap::unknown_location(),
+ "internal error: failed to set init priority for %s",
+ (*p)->package_name().c_str());
+ v.push_back(*p);
+ }
std::sort(v.begin(), v.end(), priority_compare);
// We build calls to the init functions, which take no arguments.