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]

patch to eliminate negative unsigned type warning


Hi,
egcs -Wall gives spurious warnings about passing or assigning unsigned
types with the top bit set as parameters or variables of a typedef'd
unsigned type. (http://www.cygnus.com/ml/egcs-bugs/1998-Jul/0039.html)

This patch to cp/typeck.c fixes the problem.

question. Do you need a copyright assignment for such a small (3 line)
change? My reading of the FSF guidelines suggest not, but the egcs
guidelines give no such leeway.

nathan

Wed Jul 15 16:29:07 BST 1998  Nathan Sidwell  <nathan@acm.org>
 
        * typeck.c (build_modify_expr): Coerce to lhstype main_variant.
        (convert_for_initialization): Compare with target type
        main_variant. Coerce to target type main_variant.
      

-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
      You can up the bandwidth, but you can't up the speed of light      
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk
Index: gcc/cp/typeck.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck.c,v
retrieving revision 1.87
diff -b -c -3 -p -r1.87 typeck.c
*** typeck.c	1998/07/15 04:38:45	1.87
--- typeck.c	1998/07/15 15:55:20
*************** build_modify_expr (lhs, modifycode, rhs)
*** 6178,6185 ****
  	  newrhs = convert_force (lhstype, newrhs, 0);
  	}
        else
! 	newrhs = convert_for_assignment (lhstype, newrhs, "assignment",
! 					 NULL_TREE, 0);
        if (TREE_CODE (newrhs) == CALL_EXPR
  	  && TYPE_NEEDS_CONSTRUCTING (lhstype))
  	newrhs = build_cplus_new (lhstype, newrhs);
--- 6178,6185 ----
  	  newrhs = convert_force (lhstype, newrhs, 0);
  	}
        else
! 	newrhs = convert_for_assignment (TYPE_MAIN_VARIANT (lhstype), newrhs,
! 					 "assignment", NULL_TREE, 0);
        if (TREE_CODE (newrhs) == CALL_EXPR
  	  && TYPE_NEEDS_CONSTRUCTING (lhstype))
  	newrhs = build_cplus_new (lhstype, newrhs);
*************** convert_for_initialization (exp, type, r
*** 7113,7126 ****
    if (IS_AGGR_TYPE (type))
      return ocp_convert (type, rhs, CONV_IMPLICIT|CONV_FORCE_TEMP, flags);
  
!   if (type == TREE_TYPE (rhs))
      {
        if (TREE_READONLY_DECL_P (rhs))
  	rhs = decl_constant_value (rhs);
        return rhs;
      }
  
!   return convert_for_assignment (type, rhs, errtype, fndecl, parmnum);
  }
  
  /* Expand an ASM statement with operands, handling output operands
--- 7113,7127 ----
    if (IS_AGGR_TYPE (type))
      return ocp_convert (type, rhs, CONV_IMPLICIT|CONV_FORCE_TEMP, flags);
  
!   if (TYPE_MAIN_VARIANT (type) == TREE_TYPE (rhs))
      {
        if (TREE_READONLY_DECL_P (rhs))
  	rhs = decl_constant_value (rhs);
        return rhs;
      }
  
!   return convert_for_assignment (TYPE_MAIN_VARIANT (type), rhs,
! 				 errtype, fndecl, parmnum);
  }
  
  /* Expand an ASM statement with operands, handling output operands

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