compiler: avoid knock-on errors from invalid interfaces
authorIan Lance Taylor <iant@golang.org>
Tue, 15 Dec 2020 06:50:18 +0000 (22:50 -0800)
committerIan Lance Taylor <iant@golang.org>
Tue, 15 Dec 2020 21:00:54 +0000 (13:00 -0800)
The test case for this is issue11614.go.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/278192

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/expressions.cc
gcc/go/gofrontend/types.cc

index a596b241a4e8d02f76696ea2a5eb7e1d46a90010..a28294c594f26d3fb4f712d54788f37b1f0eb667 100644 (file)
@@ -1,4 +1,4 @@
-85c390ec75c6c3f3fbfe08f6dac58585588c6211
+10d3dd939d4cea7f40b76f8ff82c16aa12c01188
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 79ed44510a9a9ff75572ec998cf4649557c498f5..adc1ebb46437d5d687a0365984944d3c2f7afc48 100644 (file)
@@ -174,7 +174,13 @@ Expression::export_name(Export_function_body* efb, const Named_object* no)
 void
 Expression::unused_value_error()
 {
-  this->report_error(_("value computed is not used"));
+  if (this->type()->is_error())
+    {
+      go_assert(saw_errors());
+      this->set_is_error();
+    }
+  else
+    this->report_error(_("value computed is not used"));
 }
 
 // Note that this expression is an error.  This is called by children
@@ -888,8 +894,7 @@ Type_expression : public Expression
   { }
 
   void
-  do_check_types(Gogo*)
-  { this->report_error(_("invalid use of type")); }
+  do_check_types(Gogo*);
 
   Expression*
   do_copy()
@@ -906,6 +911,18 @@ Type_expression : public Expression
   Type* type_;
 };
 
+void
+Type_expression::do_check_types(Gogo*)
+{
+  if (this->type_->is_error())
+    {
+      go_assert(saw_errors());
+      this->set_is_error();
+    }
+  else
+    this->report_error(_("invalid use of type"));
+}
+
 void
 Type_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
 {
index f9097d5e130d57011955c31b849b1ecbced9cd0b..ecb93b099dbc5b063d507aa2092a426202292ba9 100644 (file)
@@ -8984,8 +8984,11 @@ Interface_type::finalize_methods()
       else if (this->find_method(p->name()) == NULL)
        this->all_methods_->push_back(*p);
       else
-       go_error_at(p->location(), "duplicate method %qs",
-                Gogo::message_name(p->name()).c_str());
+       {
+         go_error_at(p->location(), "duplicate method %qs",
+                     Gogo::message_name(p->name()).c_str());
+         this->set_is_error();
+       }
     }
 
   std::vector<Named_type*> seen;
@@ -9001,7 +9004,10 @@ Interface_type::finalize_methods()
       if (it == NULL)
        {
          if (!t->is_error())
-           go_error_at(tl, "interface contains embedded non-interface");
+           {
+             go_error_at(tl, "interface contains embedded non-interface");
+             this->set_is_error();
+           }
          continue;
        }
       if (it == this)
@@ -9009,6 +9015,7 @@ Interface_type::finalize_methods()
          if (!issued_recursive_error)
            {
              go_error_at(tl, "invalid recursive interface");
+             this->set_is_error();
              issued_recursive_error = true;
            }
          continue;
@@ -9027,6 +9034,7 @@ Interface_type::finalize_methods()
              if (*q == nt)
                {
                  go_error_at(tl, "inherited interface loop");
+                 this->set_is_error();
                  break;
                }
            }
@@ -9049,8 +9057,11 @@ Interface_type::finalize_methods()
                                                               q->type(), tl));
              else if (!Type::are_identical(q->type(), oldm->type(),
                                            Type::COMPARE_TAGS, NULL))
-               go_error_at(tl, "duplicate method %qs",
-                           Gogo::message_name(q->name()).c_str());
+               {
+                 go_error_at(tl, "duplicate method %qs",
+                             Gogo::message_name(q->name()).c_str());
+                 this->set_is_error();
+               }
            }
        }