OSDN Git Service

Check for errors from Gogo::call_builtin.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 16 Dec 2010 00:44:14 +0000 (00:44 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 16 Dec 2010 00:44:14 +0000 (00:44 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167891 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/expressions.cc
gcc/go/gofrontend/gogo-tree.cc
gcc/go/gofrontend/statements.cc
gcc/go/gofrontend/types.cc

index 39bbc84..6a7ba45 100644 (file)
@@ -505,6 +505,8 @@ Expression::convert_interface_to_interface(Translate_context* context,
                                     lhs_type_descriptor,
                                     TREE_TYPE(rhs_type_descriptor),
                                     rhs_type_descriptor);
+      if (call == error_mark_node)
+       return error_mark_node;
       // This will panic if the interface conversion fails.
       TREE_NOTHROW(assert_interface_decl) = 0;
       elt->value = fold_convert_loc(location, TREE_TYPE(field), call);
@@ -535,6 +537,8 @@ Expression::convert_interface_to_interface(Translate_context* context,
                                     lhs_type_descriptor,
                                     TREE_TYPE(rhs_type_descriptor),
                                     rhs_type_descriptor);
+      if (call == error_mark_node)
+       return error_mark_node;
       // This will panic if the interface conversion fails.
       TREE_NOTHROW(convert_interface_decl) = 0;
       elt->value = fold_convert_loc(location, TREE_TYPE(field), call);
@@ -599,6 +603,8 @@ Expression::convert_interface_to_type(Translate_context* context,
                                 rhs_type_descriptor,
                                 TREE_TYPE(rhs_inter_descriptor),
                                 rhs_inter_descriptor);
+  if (call == error_mark_node)
+    return error_mark_node;
   // This call will panic if the conversion is invalid.
   TREE_NOTHROW(check_interface_type_decl) = 0;
 
@@ -6012,6 +6018,8 @@ Expression::comparison_tree(Translate_context* context, Operator op,
                                         descriptor,
                                         ptr_type_node,
                                         arg);
+         if (left_tree == error_mark_node)
+           return error_mark_node;
          // This can panic if the type is not comparable.
          TREE_NOTHROW(empty_interface_value_compare_decl) = 0;
        }
@@ -6029,6 +6037,8 @@ Expression::comparison_tree(Translate_context* context, Operator op,
                                         descriptor,
                                         ptr_type_node,
                                         arg);
+         if (left_tree == error_mark_node)
+           return error_mark_node;
          // This can panic if the type is not comparable.
          TREE_NOTHROW(interface_value_compare_decl) = 0;
        }
@@ -6054,6 +6064,8 @@ Expression::comparison_tree(Translate_context* context, Operator op,
                                         left_tree,
                                         TREE_TYPE(right_tree),
                                         right_tree);
+         if (left_tree == error_mark_node)
+           return error_mark_node;
          // This can panic if the type is uncomparable.
          TREE_NOTHROW(empty_interface_compare_decl) = 0;
        }
@@ -6070,6 +6082,8 @@ Expression::comparison_tree(Translate_context* context, Operator op,
                                         left_tree,
                                         TREE_TYPE(right_tree),
                                         right_tree);
+         if (left_tree == error_mark_node)
+           return error_mark_node;
          // This can panic if the type is uncomparable.
          TREE_NOTHROW(interface_compare_decl) = 0;
        }
@@ -7415,6 +7429,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
                                                   "__go_print_space",
                                                   0,
                                                   void_type_node);
+                   if (call == error_mark_node)
+                     return error_mark_node;
                    append_to_statement_list(call, &stmt_list);
                  }
 
@@ -7513,8 +7529,9 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
                                               void_type_node,
                                               TREE_TYPE(arg),
                                               arg);
-               if (call != error_mark_node)
-                 append_to_statement_list(call, &stmt_list);
+               if (call == error_mark_node)
+                 return error_mark_node;
+               append_to_statement_list(call, &stmt_list);
              }
          }
 
@@ -7526,6 +7543,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
                                           "__go_print_nl",
                                           0,
                                           void_type_node);
+           if (call == error_mark_node)
+             return error_mark_node;
            append_to_statement_list(call, &stmt_list);
          }
 
@@ -7552,6 +7571,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
                                       void_type_node,
                                       TREE_TYPE(arg_tree),
                                       arg_tree);
+       if (call == error_mark_node)
+         return error_mark_node;
        // This function will throw an exception.
        TREE_NOTHROW(panic_fndecl) = 0;
        // This function will not return.
@@ -7604,6 +7625,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
                                      0,
                                      empty_tree);
          }
+       if (call == error_mark_node)
+         return error_mark_node;
        return fold_build3_loc(location, COND_EXPR, empty_tree, arg_tree,
                               call, empty_nil_tree);
       }
@@ -9404,6 +9427,8 @@ String_index_expression::do_get_tree(Translate_context* context)
                                    start_tree,
                                    length_type,
                                    end_tree);
+      if (ret == error_mark_node)
+       return error_mark_node;
       // This will panic if the bounds are out of range for the
       // string.
       TREE_NOTHROW(strslice_fndecl) = 0;
@@ -9573,6 +9598,8 @@ Map_index_expression::get_value_pointer(Translate_context* context,
                                 (insert
                                  ? boolean_true_node
                                  : boolean_false_node));
+  if (call == error_mark_node)
+    return error_mark_node;
   // This can panic on a map of interface type if the interface holds
   // an uncomparable or unhashable type.
   TREE_NOTHROW(map_index_fndecl) = 0;
@@ -11129,6 +11156,8 @@ Map_construction_expression::do_get_tree(Translate_context* context)
                                 TYPE_SIZE_UNIT(TREE_TYPE(val_field)),
                                 const_ptr_type_node,
                                 fold_convert(const_ptr_type_node, valaddr));
+  if (call == error_mark_node)
+    return error_mark_node;
 
   tree ret;
   if (make_tmp == NULL)
index 67f9949..e43f64d 100644 (file)
@@ -341,7 +341,8 @@ Gogo::register_gc_vars(const std::vector<Named_object*>& var_gc,
                                 void_type_node,
                                 build_pointer_type(root_list_type),
                                 build_fold_addr_expr(decl));
-  append_to_statement_list(call, init_stmt_list);
+  if (call != error_mark_node)
+    append_to_statement_list(call, init_stmt_list);
 }
 
 // Build the decl for the initialization function.
@@ -1684,7 +1685,8 @@ Function::build_defer_wrapper(Gogo* gogo, Named_object* named_function,
                                 void_type_node,
                                 ptr_type_node,
                                 this->defer_stack(end_loc));
-  append_to_statement_list(call, &stmt_list);
+  if (call != error_mark_node)
+    append_to_statement_list(call, &stmt_list);
 
   tree retval = this->return_value(gogo, named_function, end_loc, &stmt_list);
   tree set;
@@ -1723,7 +1725,8 @@ Function::build_defer_wrapper(Gogo* gogo, Named_object* named_function,
                                    void_type_node,
                                    ptr_type_node,
                                    this->defer_stack(end_loc));
-  TREE_NOTHROW(undefer_fndecl) = 0;
+  if (undefer_fndecl != NULL_TREE)
+    TREE_NOTHROW(undefer_fndecl) = 0;
 
   tree defer = Gogo::call_builtin(&check_fndecl,
                                  end_loc,
@@ -2867,6 +2870,8 @@ Gogo::runtime_error(int code, source_location location)
                                void_type_node,
                                integer_type_node,
                                build_int_cst(integer_type_node, code));
+  if (ret == error_mark_node)
+    return error_mark_node;
   // The runtime error function panics and does not return.
   TREE_NOTHROW(runtime_error_fndecl) = 0;
   TREE_THIS_VOLATILE(runtime_error_fndecl) = 1;
@@ -2904,6 +2909,8 @@ Gogo::send_on_channel(tree channel, tree val, bool blocking, bool for_select,
                                        (for_select
                                         ? boolean_true_node
                                         : boolean_false_node));
+         if (ret == error_mark_node)
+           return error_mark_node;
          // This can panic if there are too many operations on a
          // closed channel.
          TREE_NOTHROW(send_small_fndecl) = 0;
@@ -2922,6 +2929,8 @@ Gogo::send_on_channel(tree channel, tree val, bool blocking, bool for_select,
                                        channel,
                                        uint64_type_node,
                                        val);
+         if (ret == error_mark_node)
+           return error_mark_node;
          // This can panic if there are too many operations on a
          // closed channel.
          TREE_NOTHROW(send_nonblocking_small_fndecl) = 0;
@@ -2967,6 +2976,8 @@ Gogo::send_on_channel(tree channel, tree val, bool blocking, bool for_select,
                                    (for_select
                                     ? boolean_true_node
                                     : boolean_false_node));
+         if (call == error_mark_node)
+           return error_mark_node;
          // This can panic if there are too many operations on a
          // closed channel.
          TREE_NOTHROW(send_big_fndecl) = 0;
@@ -2984,6 +2995,8 @@ Gogo::send_on_channel(tree channel, tree val, bool blocking, bool for_select,
                                    channel,
                                    ptr_type_node,
                                    val);
+         if (call == error_mark_node)
+           return error_mark_node;
          // This can panic if there are too many operations on a
          // closed channel.
          TREE_NOTHROW(send_nonblocking_big_fndecl) = 0;
@@ -3025,6 +3038,8 @@ Gogo::receive_from_channel(tree type_tree, tree channel, bool for_select,
                                     (for_select
                                      ? boolean_true_node
                                      : boolean_false_node));
+      if (call == error_mark_node)
+       return error_mark_node;
       // This can panic if there are too many operations on a closed
       // channel.
       TREE_NOTHROW(receive_small_fndecl) = 0;
@@ -3057,6 +3072,8 @@ Gogo::receive_from_channel(tree type_tree, tree channel, bool for_select,
                                     (for_select
                                      ? boolean_true_node
                                      : boolean_false_node));
+      if (call == error_mark_node)
+       return error_mark_node;
       // This can panic if there are too many operations on a closed
       // channel.
       TREE_NOTHROW(receive_big_fndecl) = 0;
@@ -3114,6 +3131,8 @@ Gogo::make_trampoline(tree fnaddr, tree closure, source_location location)
                              ptr_type_node,
                              fold_convert_loc(location, ptr_type_node,
                                               closure));
+  if (x == error_mark_node)
+    return error_mark_node;
 
   x = save_expr(x);
 
index f77764f..ce389ab 100644 (file)
@@ -4216,6 +4216,8 @@ Select_clauses::get_tree(Translate_context* context,
                                 chans_arg,
                                 pointer_boolean_type_tree,
                                 is_sends_arg);
+  if (call == error_mark_node)
+    return error_mark_node;
 
   tree stmt_list = NULL_TREE;
 
index 1ed4358..bd0c7e5 100644 (file)
@@ -5094,6 +5094,8 @@ Map_type::do_make_expression_tree(Translate_context* context,
                                context->gogo()->map_descriptor(this),
                                sizetype,
                                expr_tree);
+  if (ret == error_mark_node)
+    return error_mark_node;
   // This can panic if the capacity is out of range.
   TREE_NOTHROW(new_map_fndecl) = 0;
 
@@ -5344,6 +5346,8 @@ Channel_type::do_make_expression_tree(Translate_context* context,
                                element_size_tree,
                                sizetype,
                                expr_tree);
+  if (ret == error_mark_node)
+    return error_mark_node;
   // This can panic if the capacity is out of range.
   TREE_NOTHROW(new_channel_fndecl) = 0;