aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-02-19 04:01:32 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-02-19 04:01:32 +0000
commit4a28fe2a2bda68125fbdaa605311e9f50ee661bc (patch)
tree07e4c8519c9a1f8432f88a966cc0e18b7e7dc08c /gcc/go
parent196bc4071beb8caa9897f3ffaabb7ebb472e9b3c (diff)
downloadgcc-4a28fe2a2bda68125fbdaa605311e9f50ee661bc.zip
gcc-4a28fe2a2bda68125fbdaa605311e9f50ee661bc.tar.gz
gcc-4a28fe2a2bda68125fbdaa605311e9f50ee661bc.tar.bz2
Avoid infinite loop inheriting interface methods.
From-SVN: r170303
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/types.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index 2d7312b..90bc4e1 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -5605,6 +5605,7 @@ Interface_type::finalize_methods()
{
if (this->methods_ == NULL)
return;
+ std::vector<Named_type*> seen;
bool is_recursive = false;
size_t from = 0;
size_t to = 0;
@@ -5632,6 +5633,7 @@ Interface_type::finalize_methods()
++from;
continue;
}
+
Interface_type* it = p->type()->interface_type();
if (it == NULL)
{
@@ -5649,6 +5651,27 @@ Interface_type::finalize_methods()
++from;
continue;
}
+
+ Named_type* nt = p->type()->named_type();
+ if (nt != NULL)
+ {
+ std::vector<Named_type*>::const_iterator q;
+ for (q = seen.begin(); q != seen.end(); ++q)
+ {
+ if (*q == nt)
+ {
+ error_at(p->location(), "inherited interface loop");
+ break;
+ }
+ }
+ if (q != seen.end())
+ {
+ ++from;
+ continue;
+ }
+ seen.push_back(nt);
+ }
+
const Typed_identifier_list* methods = it->methods();
if (methods == NULL)
{