]> gcc.gnu.org Git - gcc.git/commitdiff
compiler: don't try to get backend representation of redefinition
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 13 Oct 2016 16:21:28 +0000 (16:21 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 13 Oct 2016 16:21:28 +0000 (16:21 +0000)
    Trying to get the backend representation of a redefined name can cause a
    compiler crash as the compiler can walk over the same statements a
    second time.  It's also quite unlikely to produce any additional useful
    error messages for the user.

    Test case follows.  I'm not going to bother adding this test case to the
    testsuite--crash-on-invalid cases are worth fixing but not worth
    continually retesting.

    package p

    type A []int

    func (a A) Sum() (sum int) {
     for _, v := range a {
     sum += v
     }
     return sum
    }

    type A []int

    func (a A) Sum() (sum int) {
     for _, v := range a {
     sum += v
     }
     return sum
    }

    Reviewed-on: https://go-review.googlesource.com/30976

From-SVN: r241127

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/gogo.cc

index 0a116a835e94b856af2a18539ba77bc22c8b0e5c..6e689f464a931a162c24feb52ec901d3c72d107d 100644 (file)
@@ -1,4 +1,4 @@
-681580a3afc687ba3ff9ef240c67e8630e4306e6
+e3913d96fb024b916c87a4dc01f413523467ead9
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 30392f76b3fe11e9505d7ab4668edc6d50700c0a..9491e51258ed11a2349213000884cedf7a654e45 100644 (file)
@@ -7214,6 +7214,14 @@ Named_object::get_backend(Gogo* gogo, std::vector<Bexpression*>& const_decls,
                           std::vector<Btype*>& type_decls,
                           std::vector<Bfunction*>& func_decls)
 {
+  // If this is a definition, avoid trying to get the backend
+  // representation, as that can crash.
+  if (this->is_redefinition_)
+    {
+      go_assert(saw_errors());
+      return;
+    }
+
   switch (this->classification_)
     {
     case NAMED_OBJECT_CONST:
This page took 0.071456 seconds and 5 git commands to generate.