FreeBSD/contrib/gcc/c-common.c
/* Compute the value of 'sizeof (TYPE)' or '__alignof__ (TYPE)', where the
   second parameter indicates which OPERATOR is being applied.  The COMPLAIN
   flag controls whether we should diagnose possibly ill-formed
   constructs or not.  */
Compute the value of 'sizeof (TYPE)' or '__alignof__ (TYPE)', where the
second parameter indicates which OPERATOR is being applied.  The COMPLAIN
flag controls whether we should diagnose possibly ill-formed
constructs or not.
Compute the value of ' sizeof ( TYPE ) ' or ' __alignof__ ( TYPE ) ' where the second parameter indicates which OPERATOR is being applied . The COMPLAIN flag controls whether we should diagnose possibly ill - formed constructs or not .
tree
c_sizeof_or_alignof_type (tree type, bool is_sizeof, int complain)
{
  const char *op_name;
  tree value = NULL;
  enum tree_code type_code = TREE_CODE (type);
  op_name = is_sizeof ? "sizeof" : "__alignof__";
  if (type_code == FUNCTION_TYPE)
    {
      if (is_sizeof)
	{
	  if (complain && (pedantic || warn_pointer_arith))
	    pedwarn ("invalid application of %<sizeof%> to a function type");
	  value = size_one_node;
	}
      else
	value = size_int (FUNCTION_BOUNDARY / BITS_PER_UNIT);
    }
  else if (type_code == VOID_TYPE || type_code == ERROR_MARK)
    {
      if (type_code == VOID_TYPE
	  && complain && (pedantic || warn_pointer_arith))
	pedwarn ("invalid application of %qs to a void type", op_name);
      value = size_one_node;
    }
  else if (!COMPLETE_TYPE_P (type))
    {
      if (complain)
	error ("invalid application of %qs to incomplete type %qT ",
	       op_name, type);
      value = size_zero_node;
    }
  else
    {
      if (is_sizeof)
	value = size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
			    size_int (TYPE_PRECISION (char_type_node)
				      / BITS_PER_UNIT));
      else
	value = size_int (TYPE_ALIGN_UNIT (type));
    }
  value = fold_convert (size_type_node, value);
  gcc_assert (!TYPE_IS_SIZETYPE (TREE_TYPE (value)));
  return value;
}
tree c_sizeof_or_alignof_type ( tree type , bool is_sizeof , int complain ) { const char * op_name ; tree value = NULL ; enum tree_code type_code = TREE_CODE ( type ) ; op_name = is_sizeof ? " " : " " ; if ( type_code == FUNCTION_TYPE ) { if ( is_sizeof ) { if ( complain && ( pedantic || warn_pointer_arith ) ) pedwarn ( " " ) ; value = size_one_node ; } else value = size_int ( FUNCTION_BOUNDARY / BITS_PER_UNIT ) ; } else if ( type_code == VOID_TYPE || type_code == ERROR_MARK ) { if ( type_code == VOID_TYPE && complain && ( pedantic || warn_pointer_arith ) ) pedwarn ( " " , op_name ) ; value = size_one_node ; } else if ( ! COMPLETE_TYPE_P ( type ) ) { if ( complain ) error ( " " , op_name , type ) ; value = size_zero_node ; } else { if ( is_sizeof ) value = size_binop ( CEIL_DIV_EXPR , TYPE_SIZE_UNIT ( type ) , size_int ( TYPE_PRECISION ( char_type_node ) / BITS_PER_UNIT ) ) ; else value = size_int ( TYPE_ALIGN_UNIT ( type ) ) ; } value = fold_convert ( size_type_node , value ) ; gcc_assert ( ! TYPE_IS_SIZETYPE ( TREE_TYPE ( value ) ) ) ; return value ; }
Compute the value of 'sizeof (TYPE)' or '__alignof__ (TYPE)', where the
second parameter indicates which OPERATOR is being applied.
Compute the value of ' sizeof ( TYPE ) ' or ' __alignof__ ( TYPE ) ' where the second parameter indicates which OPERATOR is being applied .
/* Convert in case a char is more than one unit.  */ /* VALUE will have an integer type with TYPE_IS_SIZETYPE set.
     TYPE_IS_SIZETYPE means that certain things (like overflow) will
     never happen.  However, this node should really have type
     `size_t', which is just a typedef for an ordinary integer type.  */