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++] Fix some type mismatches in the C/C++ frontends


Caught by the gimple type verifier.  Bootstrapped and tested on
x86_64-unknown-linux-gnu.

Ok for mainline?

Thanks,
Richard.

2007-07-05  Richard Guenther  <rguenther@suse.de>

	* c-common.c (boolean_increment): Use correctly typed
	constant.

	cp/
	* init.c (build_new_1): Use the correct pointer type.
	* typeck2.c (build_m_component_ref): Likewise.

Index: c-common.c
===================================================================
*** c-common.c	(revision 126357)
--- c-common.c	(working copy)
*************** tree
*** 4348,4354 ****
  boolean_increment (enum tree_code code, tree arg)
  {
    tree val;
!   tree true_res = boolean_true_node;
  
    arg = stabilize_reference (arg);
    switch (code)
--- 4348,4354 ----
  boolean_increment (enum tree_code code, tree arg)
  {
    tree val;
!   tree true_res = build_int_cst (TREE_TYPE (arg), 1);
  
    arg = stabilize_reference (arg);
    switch (code)
Index: cp/init.c
===================================================================
*** cp/init.c	(revision 126357)
--- cp/init.c	(working copy)
*************** build_new_1 (tree placement, tree type, 
*** 1915,1920 ****
--- 1915,1921 ----
      {
        tree cookie;
        tree cookie_ptr;
+       tree size_ptr_type;
  
        /* Adjust so we're pointing to the start of the object.  */
        data_addr = get_target_expr (build2 (POINTER_PLUS_EXPR, full_pointer_type,
*************** build_new_1 (tree placement, tree type, 
*** 1924,1931 ****
  	 many elements to destroy later.  We use the last sizeof
  	 (size_t) bytes to store the number of elements.  */
        cookie_ptr = fold_build1 (NEGATE_EXPR, sizetype, size_in_bytes (sizetype));
!       cookie_ptr = build2 (POINTER_PLUS_EXPR, build_pointer_type (sizetype),
! 			   data_addr, cookie_ptr);
        cookie = build_indirect_ref (cookie_ptr, NULL);
  
        cookie_expr = build2 (MODIFY_EXPR, sizetype, cookie, nelts);
--- 1925,1933 ----
  	 many elements to destroy later.  We use the last sizeof
  	 (size_t) bytes to store the number of elements.  */
        cookie_ptr = fold_build1 (NEGATE_EXPR, sizetype, size_in_bytes (sizetype));
!       size_ptr_type = build_pointer_type (sizetype);
!       cookie_ptr = build2 (POINTER_PLUS_EXPR, size_ptr_type,
! 			   fold_convert (size_ptr_type, data_addr), cookie_ptr);
        cookie = build_indirect_ref (cookie_ptr, NULL);
  
        cookie_expr = build2 (MODIFY_EXPR, sizetype, cookie, nelts);
Index: cp/typeck2.c
===================================================================
*** cp/typeck2.c	(revision 126357)
--- cp/typeck2.c	(working copy)
*************** build_m_component_ref (tree datum, tree 
*** 1261,1266 ****
--- 1261,1268 ----
  
    if (TYPE_PTRMEM_P (ptrmem_type))
      {
+       tree ptype;
+ 
        /* Compute the type of the field, as described in [expr.ref].
  	 There's no such thing as a mutable pointer-to-member, so
  	 things are not as complex as they are for references to
*************** build_m_component_ref (tree datum, tree 
*** 1277,1284 ****
  
        /* Build an expression for "object + offset" where offset is the
  	 value stored in the pointer-to-data-member.  */
!       datum = build2 (POINTER_PLUS_EXPR, build_pointer_type (type),
! 		      datum, build_nop (sizetype, component));
        return build_indirect_ref (datum, 0);
      }
    else
--- 1279,1288 ----
  
        /* Build an expression for "object + offset" where offset is the
  	 value stored in the pointer-to-data-member.  */
!       ptype = build_pointer_type (type);
!       datum = build2 (POINTER_PLUS_EXPR, ptype,
! 		      fold_convert (ptype, datum),
! 		      build_nop (sizetype, component));
        return build_indirect_ref (datum, 0);
      }
    else


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