diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-01-22 17:11:36 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-01-22 17:11:36 +0000 |
commit | 6e436286338333f42a87c418764476baf456740c (patch) | |
tree | 8fc27c0bfd0169b2ea8916f14713dd5192b913f7 /gcc/go | |
parent | f77107e8141ed85ea5f35a9dd840e4431a27d763 (diff) | |
download | gcc-6e436286338333f42a87c418764476baf456740c.zip gcc-6e436286338333f42a87c418764476baf456740c.tar.gz gcc-6e436286338333f42a87c418764476baf456740c.tar.bz2 |
compiler: Avoid infinite recursion when describing initialization loops.
Fixes infinite recursion from golang/go#7558.
From-SVN: r220009
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/gogo.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index 7bc54fc..252560d 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -1089,6 +1089,7 @@ sort_var_inits(Gogo* gogo, Var_inits* var_inits) // variable initializations that depend on it. typedef std::map<Var_init, std::set<Var_init*> > Init_deps; Init_deps init_deps; + bool init_loop = false; for (Var_inits::iterator p1 = var_inits->begin(); p1 != var_inits->end(); ++p1) @@ -1137,14 +1138,15 @@ sort_var_inits(Gogo* gogo, Var_inits* var_inits) p2var->message_name().c_str()); inform(p2->var()->location(), "%qs defined here", p2var->message_name().c_str()); - p2 = var_inits->end(); + init_loop = true; + break; } } } } // If there are no dependencies then the declaration order is sorted. - if (!init_deps.empty()) + if (!init_deps.empty() && !init_loop) { // Otherwise, sort variable initializations by emitting all variables with // no dependencies in declaration order. VAR_INITS is already in |