This patch to the Go frontend fixes the handling of struct hash and equality when the struct has _ fields. Those fields should not participate in the hash and equality functions at all. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Will commit to 4.7 branch when it reopens.
Ian
diff -r 3408484e8448 go/expressions.cc --- a/go/expressions.cc Wed Sep 19 17:53:19 2012 -0700 +++ b/go/expressions.cc Wed Sep 19 21:32:53 2012 -0700 @@ -5178,6 +5178,9 @@ pf != fields->end(); ++pf, ++field_index) { + if (Gogo::is_sink_name(pf->field_name())) + continue; + if (field_index > 0) { if (left_temp == NULL) diff -r 3408484e8448 go/types.cc --- a/go/types.cc Wed Sep 19 17:53:19 2012 -0700 +++ b/go/types.cc Wed Sep 19 21:32:53 2012 -0700 @@ -579,6 +579,9 @@ p != fields->end(); ++p) { + if (Gogo::is_sink_name(p->field_name())) + continue; + if (!p->type()->is_comparable()) { if (reason != NULL) @@ -4294,6 +4297,9 @@ pf != fields->end(); ++pf) { + if (Gogo::is_sink_name(pf->field_name())) + return false; + if (!pf->type()->compare_is_identity(gogo)) return false; @@ -4767,6 +4773,9 @@ pf != fields->end(); ++pf) { + if (Gogo::is_sink_name(pf->field_name())) + continue; + if (first) first = false; else @@ -4858,6 +4867,9 @@ pf != fields->end(); ++pf, ++field_index) { + if (Gogo::is_sink_name(pf->field_name())) + continue; + // Compare one field in both P1 and P2. Expression* f1 = Expression::make_temporary_reference(p1, bloc); f1 = Expression::make_unary(OPERATOR_MULT, f1, bloc);