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]

[PATCH][C/C++/Fortran] Fix some more type mismatches


This fixes some more types in the IL created catched by the
gimple type verifier.  Bootstrapping the C family languages
and Fortran is possible now...

Ok for mainline?

Thanks,
Richard.


2007-07-10  Richard Guenther  <rguenther@suse.de>
	Michael Matz  <matz@suse.de>

	* c-typeck.c (convert_for_assignment): Use the type of
	the member for the initialization.

	cp/
	* call.c (build_new_method_call): Convert initializer to
	the basetype.
	* init.c (build_aggr_init): Do not fiddle with types.
	(build_vec_delete_1): Use correct type for POINTER_PLUS_EXPR.
	* except.c (build_throw): Do not drop qualifiers for the
	pointer type.
	* typeck.c (get_member_function_from_ptrfunc): Do not
	fiddle with types, instead convert.
	(build_ptrmemfunc1): Convert to the target type for
	initialization.
	(gfc_trans_allocate): Convert result to target type.

	fortran/
	* trans-array.c (gfc_conv_array_parameter): Use correct
	types for comparison.
	* trans-intrinsic.c (gfc_conv_intrinsic_repeat): Use
	correct types for POINTER_PLUS_EXPR.
	* trans-stmt.c (gfc_trans_forall_loop): Use correct type
	for integer one constant.

Index: gcc/cp/call.c
===================================================================
*** gcc.orig/cp/call.c	2007-07-10 11:46:59.000000000 +0200
--- gcc/cp/call.c	2007-07-10 11:57:53.000000000 +0200
*************** build_new_method_call (tree instance, tr
*** 5503,5508 ****
--- 5503,5515 ----
        name = complete_dtor_identifier;
      }
  
+   if (DECL_CONSTRUCTOR_P (fn))
+     {
+       tree type = build_pointer_type (basetype);
+       if (!same_type_p (type, TREE_TYPE (instance_ptr)))
+ 	instance_ptr = build_nop (type, instance_ptr);
+     }
+ 
    class_type = (conversion_path ? BINFO_TYPE (conversion_path) : NULL_TREE);
    mem_args = tree_cons (NULL_TREE, instance_ptr, args);
  
Index: gcc/cp/init.c
===================================================================
*** gcc.orig/cp/init.c	2007-07-10 11:46:59.000000000 +0200
--- gcc/cp/init.c	2007-07-10 11:57:53.000000000 +0200
*************** build_aggr_init (tree exp, tree init, in
*** 1135,1141 ****
      /* Just know that we've seen something for this node.  */
      TREE_USED (exp) = 1;
  
-   TREE_TYPE (exp) = TYPE_MAIN_VARIANT (type);
    is_global = begin_init_stmts (&stmt_expr, &compound_stmt);
    destroy_temps = stmts_are_full_exprs_p ();
    current_stmt_tree ()->stmts_are_full_exprs_p = 0;
--- 1135,1140 ----
*************** build_aggr_init (tree exp, tree init, in
*** 1143,1149 ****
  		      init, LOOKUP_NORMAL|flags);
    stmt_expr = finish_init_stmts (is_global, stmt_expr, compound_stmt);
    current_stmt_tree ()->stmts_are_full_exprs_p = destroy_temps;
-   TREE_TYPE (exp) = type;
    TREE_READONLY (exp) = was_const;
    TREE_THIS_VOLATILE (exp) = was_volatile;
  
--- 1142,1147 ----
*************** build_vec_delete_1 (tree base, tree maxi
*** 2322,2328 ****
    tbase = create_temporary_var (ptype);
    tbase_init = build_modify_expr (tbase, NOP_EXPR,
  				  fold_build2 (POINTER_PLUS_EXPR, ptype,
! 					       base,
  					       virtual_size));
    DECL_REGISTER (tbase) = 1;
    controller = build3 (BIND_EXPR, void_type_node, tbase,
--- 2320,2326 ----
    tbase = create_temporary_var (ptype);
    tbase_init = build_modify_expr (tbase, NOP_EXPR,
  				  fold_build2 (POINTER_PLUS_EXPR, ptype,
! 					       fold_convert (ptype, base),
  					       virtual_size));
    DECL_REGISTER (tbase) = 1;
    controller = build3 (BIND_EXPR, void_type_node, tbase,
Index: gcc/cp/except.c
===================================================================
*** gcc.orig/cp/except.c	2007-07-10 11:46:59.000000000 +0200
--- gcc/cp/except.c	2007-07-10 11:57:53.000000000 +0200
*************** build_throw (tree exp)
*** 683,689 ****
  	 respectively.  */
        temp_type = is_bitfield_expr_with_lowered_type (exp);
        if (!temp_type)
! 	temp_type = type_decays_to (TYPE_MAIN_VARIANT (TREE_TYPE (exp)));
  
        /* OK, this is kind of wacky.  The standard says that we call
  	 terminate when the exception handling mechanism, after
--- 683,689 ----
  	 respectively.  */
        temp_type = is_bitfield_expr_with_lowered_type (exp);
        if (!temp_type)
! 	temp_type = type_decays_to (TREE_TYPE (exp));
  
        /* OK, this is kind of wacky.  The standard says that we call
  	 terminate when the exception handling mechanism, after
Index: gcc/c-typeck.c
===================================================================
*** gcc.orig/c-typeck.c	2007-07-10 11:46:59.000000000 +0200
--- gcc/c-typeck.c	2007-07-10 11:57:53.000000000 +0200
*************** convert_for_assignment (tree type, tree 
*** 4028,4033 ****
--- 4028,4034 ----
  	  if (pedantic && (!fundecl || !DECL_IN_SYSTEM_HEADER (fundecl)))
  	    pedwarn ("ISO C prohibits argument conversion to union type");
  
+ 	  rhs = fold_convert (TREE_TYPE (memb), rhs);
  	  return build_constructor_single (type, memb, rhs);
  	}
      }
Index: gcc/cp/typeck.c
===================================================================
*** gcc.orig/cp/typeck.c	2007-07-10 11:46:59.000000000 +0200
--- gcc/cp/typeck.c	2007-07-10 11:57:53.000000000 +0200
*************** get_member_function_from_ptrfunc (tree *
*** 2651,2657 ****
  	e2 = build1 (NOP_EXPR, TREE_TYPE (e2),
  		     build_unary_op (ADDR_EXPR, e2, /*noconvert=*/1));
  
!       TREE_TYPE (e2) = TREE_TYPE (e3);
        e1 = build_conditional_expr (e1, e2, e3);
  
        /* Make sure this doesn't get evaluated first inside one of the
--- 2651,2657 ----
  	e2 = build1 (NOP_EXPR, TREE_TYPE (e2),
  		     build_unary_op (ADDR_EXPR, e2, /*noconvert=*/1));
  
!       e2 = fold_convert (TREE_TYPE (e3), e2);
        e1 = build_conditional_expr (e1, e2, e3);
  
        /* Make sure this doesn't get evaluated first inside one of the
*************** build_ptrmemfunc1 (tree type, tree delta
*** 6053,6058 ****
--- 6053,6061 ----
    /* Make sure DELTA has the type we want.  */
    delta = convert_and_check (delta_type_node, delta);
  
+   /* Convert to the correct target type if necessary.  */
+   pfn = fold_convert (TREE_TYPE (pfn_field), pfn);
+ 
    /* Finish creating the initializer.  */
    v = VEC_alloc(constructor_elt, gc, 2);
    CONSTRUCTOR_APPEND_ELT(v, pfn_field, pfn);
Index: gcc/fortran/trans-array.c
===================================================================
*** gcc.orig/fortran/trans-array.c	2007-07-10 11:47:25.000000000 +0200
--- gcc/fortran/trans-array.c	2007-07-10 16:04:59.000000000 +0200
*************** gfc_conv_array_parameter (gfc_se * se, g
*** 4924,4930 ****
           loop cleanup code.  */
        tmp = build_fold_indirect_ref (desc);
        tmp = gfc_conv_array_data (tmp);
!       tmp = build2 (NE_EXPR, boolean_type_node, ptr, tmp);
        tmp = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
  
        gfc_add_expr_to_block (&block, tmp);
--- 4924,4931 ----
           loop cleanup code.  */
        tmp = build_fold_indirect_ref (desc);
        tmp = gfc_conv_array_data (tmp);
!       tmp = build2 (NE_EXPR, boolean_type_node,
! 		    fold_convert (TREE_TYPE (tmp), ptr), tmp);
        tmp = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
  
        gfc_add_expr_to_block (&block, tmp);
Index: gcc/fortran/trans-intrinsic.c
===================================================================
*** gcc.orig/fortran/trans-intrinsic.c	2007-07-04 10:25:01.000000000 +0200
--- gcc/fortran/trans-intrinsic.c	2007-07-10 16:09:55.000000000 +0200
*************** gfc_conv_intrinsic_repeat (gfc_se * se, 
*** 3596,3602 ****
    /* Call memmove (dest + (i*slen), src, slen).  */
    tmp = fold_build2 (MULT_EXPR, gfc_charlen_type_node, slen,
  		     fold_convert (gfc_charlen_type_node, count));
!   tmp = fold_build2 (POINTER_PLUS_EXPR, pchar_type_node, dest,
  		     fold_convert (sizetype, tmp));
    tmp = build_call_expr (built_in_decls[BUILT_IN_MEMMOVE], 3,
  			 tmp, src, slen);
--- 3596,3603 ----
    /* Call memmove (dest + (i*slen), src, slen).  */
    tmp = fold_build2 (MULT_EXPR, gfc_charlen_type_node, slen,
  		     fold_convert (gfc_charlen_type_node, count));
!   tmp = fold_build2 (POINTER_PLUS_EXPR, pchar_type_node,
! 		     fold_convert (pchar_type_node, dest),
  		     fold_convert (sizetype, tmp));
    tmp = build_call_expr (built_in_decls[BUILT_IN_MEMMOVE], 3,
  			 tmp, src, slen);
Index: gcc/fortran/trans-stmt.c
===================================================================
*** gcc.orig/fortran/trans-stmt.c	2007-06-13 12:12:31.000000000 +0200
--- gcc/fortran/trans-stmt.c	2007-07-10 16:28:20.000000000 +0200
*************** gfc_trans_forall_loop (forall_info *fora
*** 1609,1615 ****
  	}
  
        /* Decrement the loop counter.  */
!       tmp = build2 (MINUS_EXPR, TREE_TYPE (var), count, gfc_index_one_node);
        gfc_add_modify_expr (&block, count, tmp);
  
        body = gfc_finish_block (&block);
--- 1609,1616 ----
  	}
  
        /* Decrement the loop counter.  */
!       tmp = build2 (MINUS_EXPR, TREE_TYPE (var), count,
! 		    build_int_cst (TREE_TYPE (var), 1));
        gfc_add_modify_expr (&block, count, tmp);
  
        body = gfc_finish_block (&block);
*************** gfc_trans_allocate (gfc_code * code)
*** 3609,3615 ****
  	    tmp = se.string_length;
  
  	  tmp = build_call_expr (gfor_fndecl_allocate, 2, tmp, pstat);
! 	  tmp = build2 (MODIFY_EXPR, void_type_node, se.expr, tmp);
  	  gfc_add_expr_to_block (&se.pre, tmp);
  
  	  if (code->expr)
--- 3610,3617 ----
  	    tmp = se.string_length;
  
  	  tmp = build_call_expr (gfor_fndecl_allocate, 2, tmp, pstat);
! 	  tmp = build2 (MODIFY_EXPR, void_type_node, se.expr,
! 			fold_convert (TREE_TYPE (se.expr), tmp));
  	  gfc_add_expr_to_block (&se.pre, tmp);
  
  	  if (code->expr)


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