Go patch committed: Remove some erroneous code that was never run

Message ID CAOyqgcUfExR3eoqeUjMnw7md6fcdcMgqxet50PgsVULmBfwPyg@mail.gmail.com
State New
Headers show
  • Go patch committed: Remove some erroneous code that was never run
Related show

Commit Message

Jonathan Wakely via Gcc-patches June 29, 2020, 9:29 p.m.
This patch to the Go frontend removes some erroneous code that was
never run.  The code accidentally called Type::type_descriptor rather
than the do_type_descriptor method.  Calling Type::type_descriptor
with a second argument of NULL would always crash.  Since that never
happened, it revealed that this code was never actually executed.
Removing this code fixes GCC PR 95970, in which a new warning triggers
for the now-removed code.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.



diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index fa3764891fb..ecef60400cc 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@ 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index d6cd326b2e2..3459a3357a3 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -11106,15 +11106,11 @@  Named_type::do_type_descriptor(Gogo* gogo, Named_type* name)
   if (this->is_error_)
     return Expression::make_error(this->location_);
-  if (name == NULL && this->is_alias_)
-    {
-      if (this->seen_alias_)
-	return Expression::make_error(this->location_);
-      this->seen_alias_ = true;
-      Expression* ret = this->type_->type_descriptor(gogo, NULL);
-      this->seen_alias_ = false;
-      return ret;
-    }
+  // We shouldn't see unnamed type aliases here.  They should have
+  // been removed by the call to unalias in Type::type_descriptor_pointer.
+  // We can see named type aliases via Type::named_type_descriptor.
+  go_assert(name != NULL || !this->is_alias_);
   // If NAME is not NULL, then we don't really want the type
   // descriptor for this type; we want the descriptor for the