diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-01-30 15:57:59 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-01-30 15:57:59 +0000 |
commit | b4d216f6e206dab4c37d80bfb91b76e2776cb9ef (patch) | |
tree | 23cbad06be89198e0535231e1b38ab8482b41903 /gcc/go/gofrontend/import.cc | |
parent | 622599c6d2359ad2f43445754be185b0b177430a (diff) | |
download | gcc-b4d216f6e206dab4c37d80bfb91b76e2776cb9ef.zip gcc-b4d216f6e206dab4c37d80bfb91b76e2776cb9ef.tar.gz gcc-b4d216f6e206dab4c37d80bfb91b76e2776cb9ef.tar.bz2 |
compiler: Add pkgpath symbol information to export data.
This adds the pkgpath symbol to the export data whenever it is
needed--whenever the pkgpath symbol is not the obvious
transformation of the pkgpath. This lets us determine the
correct symbol name for indirectly imported packages compiled
with -fgo-prefix.
From-SVN: r220291
Diffstat (limited to 'gcc/go/gofrontend/import.cc')
-rw-r--r-- | gcc/go/gofrontend/import.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/import.cc b/gcc/go/gofrontend/import.cc index cfc0429..e1fba78 100644 --- a/gcc/go/gofrontend/import.cc +++ b/gcc/go/gofrontend/import.cc @@ -338,6 +338,9 @@ Import::import(Gogo* gogo, const std::string& local_name, this->package_->set_priority(prio); this->require_c_string(";\n"); + while (stream->match_c_string("package")) + this->read_one_package(); + while (stream->match_c_string("import")) this->read_one_import(); @@ -381,6 +384,25 @@ Import::import(Gogo* gogo, const std::string& local_name, return this->package_; } +// Read a package line. This let us reliably determine the pkgpath +// symbol, even if the package was compiled with a -fgo-prefix option. + +void +Import::read_one_package() +{ + this->require_c_string("package "); + std::string package_name = this->read_identifier(); + this->require_c_string(" "); + std::string pkgpath = this->read_identifier(); + this->require_c_string(" "); + std::string pkgpath_symbol = this->read_identifier(); + this->require_c_string(";\n"); + + Package* p = this->gogo_->register_package(pkgpath, pkgpath_symbol, + Linemap::unknown_location()); + p->set_package_name(package_name, this->location()); +} + // Read an import line. We don't actually care about these. void |