gcc/
	* gimplify.c (gimplify_switch_expr): Expect NULL_TREE type, as
	documented in tree.def.

fortran/
	* trans-decl.c (gfc_trans_entry_master_switch): Build SWITCH_EXPR
	with NULL_TREE type instead of void_type_node.
	* trans-io.c (io_result): Likewise.
	* trans-stmt.c (gfc_trans_integer_select,
	gfc_trans_character_select): Likewise.

go/
	* go-gcc.cc (Gcc_backend::switch_statement): Build SWITCH_EXPR
	with NULL_TREE type instead of void_type_node.

Index: gimplify.c
===================================================================
--- gimplify.c	(revision 186526)
+++ gimplify.c	(working copy)
@@ -1575,6 +1575,9 @@ gimplify_switch_expr (tree *expr_p, gimple_seq *pr
   tree switch_expr = *expr_p;
   gimple_seq switch_body_seq = NULL;
   enum gimplify_status ret;
+  tree index_type = TREE_TYPE (switch_expr);
+  if (index_type == NULL_TREE)
+    index_type = TREE_TYPE (SWITCH_COND (switch_expr));
 
   ret = gimplify_expr (&SWITCH_COND (switch_expr), pre_p, NULL, is_gimple_val,
                        fb_rvalue);
Index: fortran/trans-decl.c
===================================================================
--- fortran/trans-decl.c	(revision 186526)
+++ fortran/trans-decl.c	(working copy)
@@ -4749,7 +4749,8 @@ gfc_trans_entry_master_switch (gfc_entry_list * el
   tmp = gfc_finish_block (&block);
   /* The first argument selects the entry point.  */
   val = DECL_ARGUMENTS (current_function_decl);
-  tmp = build3_v (SWITCH_EXPR, val, tmp, NULL_TREE);
+  tmp = fold_build3_loc (input_location, SWITCH_EXPR, NULL_TREE,
+			 val, tmp, NULL_TREE);
   return tmp;
 }
 
Index: fortran/trans-io.c
===================================================================
--- fortran/trans-io.c	(revision 186526)
+++ fortran/trans-io.c	(working copy)
@@ -882,7 +882,8 @@ io_result (stmtblock_t * block, tree var, gfc_st_l
 			rc, build_int_cst (TREE_TYPE (rc),
 					   IOPARM_common_libreturn_mask));
 
-  tmp = build3_v (SWITCH_EXPR, rc, tmp, NULL_TREE);
+  tmp = fold_build3_loc (input_location, SWITCH_EXPR, NULL_TREE,
+			 rc, tmp, NULL_TREE);
 
   gfc_add_expr_to_block (block, tmp);
 }
Index: fortran/trans-stmt.c
===================================================================
--- fortran/trans-stmt.c	(revision 186526)
+++ fortran/trans-stmt.c	(working copy)
@@ -1918,7 +1918,8 @@ gfc_trans_integer_select (gfc_code * code)
     }
 
   tmp = gfc_finish_block (&body);
-  tmp = build3_v (SWITCH_EXPR, se.expr, tmp, NULL_TREE);
+  tmp = fold_build3_loc (input_location, SWITCH_EXPR, NULL_TREE,
+			 se.expr, tmp, NULL_TREE);
   gfc_add_expr_to_block (&block, tmp);
 
   tmp = build1_v (LABEL_EXPR, end_label);
@@ -2203,7 +2204,8 @@ gfc_trans_character_select (gfc_code *code)
 	  gfc_add_block_to_block (&block, &expr1se.post);
 
 	  tmp = gfc_finish_block (&body);
-	  tmp = build3_v (SWITCH_EXPR, case_num, tmp, NULL_TREE);
+	  tmp = fold_build3_loc (input_location, SWITCH_EXPR, NULL_TREE,
+				 case_num, tmp, NULL_TREE);
 	  gfc_add_expr_to_block (&block, tmp);
 
 	  tmp = build1_v (LABEL_EXPR, end_label);
@@ -2349,7 +2351,8 @@ gfc_trans_character_select (gfc_code *code)
   gfc_add_block_to_block (&block, &expr1se.post);
 
   tmp = gfc_finish_block (&body);
-  tmp = build3_v (SWITCH_EXPR, case_num, tmp, NULL_TREE);
+  tmp = fold_build3_loc (input_location, SWITCH_EXPR, NULL_TREE,
+			 case_num, tmp, NULL_TREE);
   gfc_add_expr_to_block (&block, tmp);
 
   tmp = build1_v (LABEL_EXPR, end_label);
Index: go/go-gcc.cc
===================================================================
--- go/go-gcc.cc	(revision 186526)
+++ go/go-gcc.cc	(working copy)
@@ -1087,7 +1087,7 @@ Gcc_backend::switch_statement(
   if (tv == error_mark_node)
     return this->error_statement();
   tree t = build3_loc(switch_location.gcc_location(), SWITCH_EXPR,
-                      void_type_node, tv, stmt_list, NULL_TREE);
+                      NULL_TREE, tv, stmt_list, NULL_TREE);
   return this->make_statement(t);
 }
 
