diff options
author | Michael Matloob <matloob@golang.org> | 2021-03-01 19:02:38 -0500 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-03-02 14:03:26 -0800 |
commit | d1776b7757001d9da47efcfd64d3bb20afb8d96d (patch) | |
tree | d7997fb88b53789753c231a10b79dceb040df38e /gcc/go/gofrontend/parse.cc | |
parent | df003d1e0bf2d0a8e2ed45a323d4e974b15dc95f (diff) | |
download | gcc-d1776b7757001d9da47efcfd64d3bb20afb8d96d.zip gcc-d1776b7757001d9da47efcfd64d3bb20afb8d96d.tar.gz gcc-d1776b7757001d9da47efcfd64d3bb20afb8d96d.tar.bz2 |
compiler: allow //go:embed in files underscore-importing embed
The embed spec allows for //go:embed to be used in files that
underscore-import package "embed". This is useful for embeds to
[]byte and string vars because the embed.FS type may not be referenced
if those are the only types of embeds in a file. Because the compiler
previously checked whether there were any aliases to the embed
package to decide if //go:embed could be used, it would reject
files with only underscore imports of embed. Instead, record
whether the embed import is encountered at all, similar to what
is done with unsafe, to decide whether //go:embed is allowed.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/297553
Diffstat (limited to 'gcc/go/gofrontend/parse.cc')
-rw-r--r-- | gcc/go/gofrontend/parse.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index fd81a85..e43b5f2 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -1321,7 +1321,7 @@ Parse::declaration() embeds = new(std::vector<std::string>); this->lex_->get_and_clear_embeds(embeds); - if (!this->gogo_->is_embed_imported()) + if (!this->gogo_->current_file_imported_embed()) { go_error_at(token->location(), "invalid go:embed: missing import %<embed%>"); |