Go patch committed: Traverse expressions when looking for types

Submitted by Ian Taylor on Jan. 4, 2011, 6:52 p.m.

Details

Message ID mcroc7wpkl6.fsf@google.com
State New
Headers show

Commit Message

Ian Taylor Jan. 4, 2011, 6:52 p.m.
In Go there can be types which only occur in expressions.  Therefore
when we are traversing the tree looking for all types, we need to look
at expressions as well.  This patch makes that change.  Bootstrapped and
ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch hide | download patch | download mbox

diff -r 7322e6c4c3b5 go/gogo.cc
--- a/go/gogo.cc	Tue Jan 04 10:23:34 2011 -0800
+++ b/go/gogo.cc	Tue Jan 04 10:48:48 2011 -0800
@@ -4159,9 +4159,6 @@ 
 	      if (t != NULL
 		  && Type::traverse(t, traverse) == TRAVERSE_EXIT)
 		return TRAVERSE_EXIT;
-	    }
-	  if ((traverse_mask & Traverse::traverse_expressions) != 0)
-	    {
 	      if (p->const_value()->traverse_expression(traverse)
 		  == TRAVERSE_EXIT)
 		return TRAVERSE_EXIT;
@@ -4188,7 +4185,8 @@ 
 		return TRAVERSE_EXIT;
 	    }
 	  if (p->is_variable()
-	      && (traverse_mask & Traverse::traverse_expressions) != 0)
+	      && ((traverse_mask & Traverse::traverse_types) != 0
+		  || (traverse_mask & Traverse::traverse_expressions) != 0))
 	    {
 	      if (p->var_value()->traverse_expression(traverse)
 		  == TRAVERSE_EXIT)
diff -r 7322e6c4c3b5 go/statements.cc
--- a/go/statements.cc	Tue Jan 04 10:23:34 2011 -0800
+++ b/go/statements.cc	Tue Jan 04 10:48:48 2011 -0800
@@ -108,7 +108,8 @@ 
 {
   if (expr_list == NULL)
     return TRAVERSE_CONTINUE;
-  if ((traverse->traverse_mask() & Traverse::traverse_expressions) == 0)
+  if ((traverse->traverse_mask()
+       & (Traverse::traverse_types | Traverse::traverse_expressions)) == 0)
     return TRAVERSE_CONTINUE;
   return expr_list->traverse(traverse);
 }
@@ -3010,7 +3011,8 @@ 
 Case_clauses::Case_clause::traverse(Traverse* traverse)
 {
   if (this->cases_ != NULL
-      && (traverse->traverse_mask() & Traverse::traverse_expressions) != 0)
+      && (traverse->traverse_mask()
+	  & (Traverse::traverse_types | Traverse::traverse_expressions)) != 0)
     {
       if (this->cases_->traverse(traverse) == TRAVERSE_EXIT)
 	return TRAVERSE_EXIT;
@@ -3941,7 +3943,8 @@ 
 Select_clauses::Select_clause::traverse(Traverse* traverse)
 {
   if (!this->is_lowered_
-      && (traverse->traverse_mask() & Traverse::traverse_expressions) != 0)
+      && (traverse->traverse_mask()
+	  & (Traverse::traverse_types | Traverse::traverse_expressions)) != 0)
     {
       if (this->channel_ != NULL)
 	{