Commit a387d636 by Ian Lance Taylor

compiler: suppress type descriptor generation for aliases

    
    Change Named_object::get_backend to ignore aliases when creating type
    descriptors for types, to be consistent with
    Type::needs_specific_type_functions and the Specific_type_functions
    traversal class. For example, when compiling a package that creates an
    alias to an an externally defined type, e.g.
    
       import "foo"
       type MyFoo = foo.Foo
    
    it makes sense to skip the alias (not try to generate type specific
    functions for it) and let the normal mechanisms take care of the alias
    target, depending on whether the target is defined locally or defined
    elsewhere.
    
    Testcase for this problen can be found in CL 193261.
    
    Fixes golang/go#33866.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191961

From-SVN: r275651
parent debae523
27b2311fa460b1dd76fb3a796c7c05ebedc64df2 0950e905939f88c1421f8667ac4dc9e14528471c
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -8718,7 +8718,13 @@ Named_object::get_backend(Gogo* gogo, std::vector<Bexpression*>& const_decls, ...@@ -8718,7 +8718,13 @@ Named_object::get_backend(Gogo* gogo, std::vector<Bexpression*>& const_decls,
case NAMED_OBJECT_TYPE: case NAMED_OBJECT_TYPE:
{ {
Named_type* named_type = this->u_.type_value; Named_type* named_type = this->u_.type_value;
if (!Gogo::is_erroneous_name(this->name_) && !named_type->is_alias())
// No need to do anything for aliases-- whatever has to be done
// can be done for the alias target.
if (named_type->is_alias())
break;
if (!Gogo::is_erroneous_name(this->name_))
type_decls.push_back(named_type->get_backend(gogo)); type_decls.push_back(named_type->get_backend(gogo));
// We need to produce a type descriptor for every named // We need to produce a type descriptor for every named
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment