diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-10-17 15:44:04 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-10-17 15:44:04 +0000 |
commit | e952450aab6f37c9b15561033a09589a4870513d (patch) | |
tree | 7cbd67a2bab16dc480954a4ff6aed76fb42f2dd5 /gcc/go | |
parent | 2ed3eba129b1d094aca2565fdb49a7fdd5416d8f (diff) | |
download | gcc-e952450aab6f37c9b15561033a09589a4870513d.tar.gz |
compiler: Don't warn for unknown type when importing anonymous field.
From-SVN: r203772
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/types.cc | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index 7d808ca5d7a..395882017dc 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -5263,11 +5263,25 @@ Struct_type::do_import(Import* imp) // that an embedded builtin type is accessible from another // package (we know that all the builtin types are not // exported). - if (name.empty() && ftype->deref()->named_type() != NULL) + // This is called during parsing, before anything is + // lowered, so we have to be careful to avoid dereferencing + // an unknown type name. + if (name.empty()) { - const std::string fn(ftype->deref()->named_type()->name()); - if (fn[0] >= 'a' && fn[0] <= 'z') - name = '.' + imp->package()->pkgpath() + '.' + fn; + Type *t = ftype; + if (t->classification() == Type::TYPE_POINTER) + { + // Very ugly. + Pointer_type* ptype = static_cast<Pointer_type*>(t); + t = ptype->points_to(); + } + std::string tname; + if (t->forward_declaration_type() != NULL) + tname = t->forward_declaration_type()->name(); + else if (t->named_type() != NULL) + tname = t->named_type()->name(); + if (!tname.empty() && tname[0] >= 'a' && tname[0] <= 'z') + name = '.' + imp->package()->pkgpath() + '.' + tname; } Struct_field sf(Typed_identifier(name, ftype, imp->location())); |