diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-06-07 05:49:44 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-06-07 05:49:44 +0000 |
commit | c59a4d0fa63a385f9769bd24d7e19090d3dcd85c (patch) | |
tree | 83161edbd0e07b14980d8811a9ed7055a095ef5c /gcc | |
parent | cba0366cac405bdcea5395f970718593a18ee456 (diff) | |
download | gcc-c59a4d0fa63a385f9769bd24d7e19090d3dcd85c.zip gcc-c59a4d0fa63a385f9769bd24d7e19090d3dcd85c.tar.gz gcc-c59a4d0fa63a385f9769bd24d7e19090d3dcd85c.tar.bz2 |
compiler: Fix unsafe.Sizeof for named structs with named struct fields.
From-SVN: r188295
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/types.cc | 9 | ||||
-rw-r--r-- | gcc/go/gofrontend/types.h | 7 |
2 files changed, 14 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index 3f6e97a..c2e5ed8 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -7863,6 +7863,10 @@ Find_type_use::type(Type* type) bool Named_type::do_verify() { + if (this->is_verified_) + return true; + this->is_verified_ = true; + Find_type_use find(this); Type::traverse(this->type_, &find); if (find.found()) @@ -7973,6 +7977,11 @@ Named_type::convert(Gogo* gogo) this->create_placeholder(gogo); + // If we are called to turn unsafe.Sizeof into a constant, we may + // not have verified the type yet. We have to make sure it is + // verified, since that sets the list of dependencies. + this->verify(); + // Convert all the dependencies. If they refer indirectly back to // this type, they will pick up the intermediate tree we just // created. diff --git a/gcc/go/gofrontend/types.h b/gcc/go/gofrontend/types.h index edc46b7..a542bf7 100644 --- a/gcc/go/gofrontend/types.h +++ b/gcc/go/gofrontend/types.h @@ -2628,8 +2628,9 @@ class Named_type : public Type interface_method_tables_(NULL), pointer_interface_method_tables_(NULL), location_(location), named_btype_(NULL), dependencies_(), is_visible_(true), is_error_(false), is_placeholder_(false), - is_converted_(false), is_circular_(false), seen_(false), - seen_in_compare_is_identity_(false), seen_in_get_backend_(false) + is_converted_(false), is_circular_(false), is_verified_(false), + seen_(false), seen_in_compare_is_identity_(false), + seen_in_get_backend_(false) { } // Return the associated Named_object. This holds the actual name. @@ -2908,6 +2909,8 @@ class Named_type : public Type // Whether this is a pointer or function type which refers to the // type itself. bool is_circular_; + // Whether this type has been verified. + bool is_verified_; // In a recursive operation such as has_hidden_fields, this flag is // used to prevent infinite recursion when a type refers to itself. // This is mutable because it is always reset to false when the |