m3-sys/m3cc/gcc-apple/gcc/c-decl.c
/* Performs sanity checks on the TYPE and WIDTH of the bit-field NAME,
   replacing with appropriate values if they are invalid.  */
Performs sanity checks on the TYPE and WIDTH of the bit-field NAME,
replacing with appropriate values if they are invalid.
Performs sanity checks on the TYPE and WIDTH of the bit - field NAME replacing with appropriate values if they are invalid .
static void
check_bitfield_type_and_width (tree *type, tree *width, const char *orig_name)
{
  tree type_mv;
  unsigned int max_width;
  unsigned HOST_WIDE_INT w;
  const char *name = orig_name ? orig_name: _("<anonymous>");
  if (!INTEGRAL_TYPE_P (TREE_TYPE (*width))
      || TREE_CODE (*width) != INTEGER_CST)
    {
      error ("bit-field %qs width not an integer constant", name);
      *width = integer_one_node;
    }
  else
    {
      constant_expression_warning (*width);
      if (tree_int_cst_sgn (*width) < 0)
	{
	  error ("negative width in bit-field %qs", name);
	  *width = integer_one_node;
	}
      else if (integer_zerop (*width) && orig_name)
	{
	  error ("zero width for bit-field %qs", name);
	  *width = integer_one_node;
	}
    }
  if (TREE_CODE (*type) != INTEGER_TYPE
      && TREE_CODE (*type) != BOOLEAN_TYPE
      && TREE_CODE (*type) != ENUMERAL_TYPE)
    {
      error ("bit-field %qs has invalid type", name);
      *type = unsigned_type_node;
    }
  type_mv = TYPE_MAIN_VARIANT (*type);
  if (pedantic
      && !in_system_header
      && type_mv != integer_type_node
      && type_mv != unsigned_type_node
      && type_mv != boolean_type_node)
    pedwarn ("type of bit-field %qs is a GCC extension", name);
  if (type_mv == boolean_type_node)
    max_width = CHAR_TYPE_SIZE;
  else
    max_width = TYPE_PRECISION (*type);
  if (0 < compare_tree_int (*width, max_width))
    {
      error ("width of %qs exceeds its type", name);
      w = max_width;
      *width = build_int_cst (NULL_TREE, w);
    }
  else
    w = tree_low_cst (*width, 1);
  if (TREE_CODE (*type) == ENUMERAL_TYPE)
    {
      struct lang_type *lt = TYPE_LANG_SPECIFIC (*type);
      if (!lt
	  || w < min_precision (lt->enum_min, TYPE_UNSIGNED (*type))
	  || w < min_precision (lt->enum_max, TYPE_UNSIGNED (*type)))
	warning (0, "%qs is narrower than values of its type", name);
    }
}
static void check_bitfield_type_and_width ( tree * type , tree * width , const char * orig_name ) { tree type_mv ; unsigned int max_width ; unsigned HOST_WIDE_INT w ; const char * name = orig_name ? orig_name : _ ( " " ) ; if ( ! INTEGRAL_TYPE_P ( TREE_TYPE ( * width ) ) || TREE_CODE ( * width ) != INTEGER_CST ) { error ( " " , name ) ; * width = integer_one_node ; } else { constant_expression_warning ( * width ) ; if ( tree_int_cst_sgn ( * width ) < 0 ) { error ( " " , name ) ; * width = integer_one_node ; } else if ( integer_zerop ( * width ) && orig_name ) { error ( " " , name ) ; * width = integer_one_node ; } } if ( TREE_CODE ( * type ) != INTEGER_TYPE && TREE_CODE ( * type ) != BOOLEAN_TYPE && TREE_CODE ( * type ) != ENUMERAL_TYPE ) { error ( " " , name ) ; * type = unsigned_type_node ; } type_mv = TYPE_MAIN_VARIANT ( * type ) ; if ( pedantic && ! in_system_header && type_mv != integer_type_node && type_mv != unsigned_type_node && type_mv != boolean_type_node ) pedwarn ( " " , name ) ; if ( type_mv == boolean_type_node ) max_width = CHAR_TYPE_SIZE ; else max_width = TYPE_PRECISION ( * type ) ; if ( 0 < compare_tree_int ( * width , max_width ) ) { error ( " " , name ) ; w = max_width ; * width = build_int_cst ( NULL_TREE , w ) ; } else w = tree_low_cst ( * width , 1 ) ; if ( TREE_CODE ( * type ) == ENUMERAL_TYPE ) { struct lang_type * lt = TYPE_LANG_SPECIFIC ( * type ) ; if ( ! lt || w < min_precision ( lt -> enum_min , TYPE_UNSIGNED ( * type ) ) || w < min_precision ( lt -> enum_max , TYPE_UNSIGNED ( * type ) ) ) warning ( 0 , " " , name ) ; } }
Performs sanity checks on the TYPE and WIDTH of the bit-field NAME,
replacing with appropriate values if they are invalid.
Performs sanity checks on the TYPE and WIDTH of the bit - field NAME replacing with appropriate values if they are invalid .
/* Detect and ignore out of range field width and process valid
     field widths.  */ /* Detect invalid bit-field type.  */