diff mbox

Go patch committed: Add statements to type switch even if no types

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

Commit Message

Ian Lance Taylor Dec. 15, 2010, 9:39 p.m. UTC
There was a complex crash in gccgo due to a variable defined in an
enclosing function, where the statement defining the variable had not
been lowered.  The compiler crashed trying to get the type from the
unlowered statement.  The statement was not lowered because it was in a
type switch clause where the type switch case was an invalid type.  When
that happened the parser was not adding the clause to the tree, so it
was never found in the traversal doing lowering.  This patch changes the
frontend to record the statements in that case so that they can be
lowered to avoid errors later on.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r 8d7aebdaab47 go/parse.cc
--- a/go/parse.cc	Wed Dec 15 12:34:48 2010 -0800
+++ b/go/parse.cc	Wed Dec 15 13:36:13 2010 -0800
@@ -3982,6 +3982,8 @@ 
 	clauses->add(*p, true, false, NULL, location);
       clauses->add(types.back(), false, false, statements, location);
     }
+  else
+    clauses->add(Type::make_error_type(), false, false, statements, location);
 }
 
 // TypeSwitchCase  = "case" type | "default"