This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gccgo] Fix type switches with multiple types in a case


I ran into a gccgo but in the handling of type switches in which there
are multiple types in a case but the case has no statements.  The code
was accidentally falling through into the next case even though there
was no fallthrough statement.  This patch fixes the problem.  Committed
to gccgo branch.

Ian

diff -r ad0e2fe0513d go/statements.cc
--- a/go/statements.cc	Wed Nov 10 17:53:27 2010 -0800
+++ b/go/statements.cc	Wed Nov 10 21:09:59 2010 -0800
@@ -3649,19 +3649,24 @@
       b->add_statement(s);
     }
 
-  if (this->statements_ != NULL)
+  if (this->statements_ != NULL
+      || (!this->is_fallthrough_
+	  && stmts_label != NULL
+	  && *stmts_label != NULL))
     {
       gcc_assert(!this->is_fallthrough_);
       if (stmts_label != NULL && *stmts_label != NULL)
 	{
 	  gcc_assert(!this->is_default_);
-	  (*stmts_label)->set_location(this->statements_->start_location());
+	  if (this->statements_ != NULL)
+	    (*stmts_label)->set_location(this->statements_->start_location());
 	  Statement* s = Statement::make_unnamed_label_statement(*stmts_label);
 	  b->add_statement(s);
 	  *stmts_label = NULL;
 	}
-      b->add_statement(Statement::make_block_statement(this->statements_,
-						       loc));
+      if (this->statements_ != NULL)
+	b->add_statement(Statement::make_block_statement(this->statements_,
+							 loc));
     }
 
   if (this->is_fallthrough_)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]