FreeBSD/contrib/gcc/c-common.c
/* Implement the __alignof keyword: Return the minimum required
   alignment of EXPR, measured in bytes.  For VAR_DECLs,
   FUNCTION_DECLs and FIELD_DECLs return DECL_ALIGN (which can be set
   from an "aligned" __attribute__ specification).  */
Implement the __alignof keyword: Return the minimum required
alignment of EXPR, measured in bytes.
Implement the __alignof keyword : Return the minimum required alignment of EXPR measured in bytes .
tree
c_alignof_expr (tree expr)
{
  tree t;
  if (VAR_OR_FUNCTION_DECL_P (expr))
    t = size_int (DECL_ALIGN_UNIT (expr));
  else if (TREE_CODE (expr) == COMPONENT_REF
	   && DECL_C_BIT_FIELD (TREE_OPERAND (expr, 1)))
    {
      error ("%<__alignof%> applied to a bit-field");
      t = size_one_node;
    }
  else if (TREE_CODE (expr) == COMPONENT_REF
	   && TREE_CODE (TREE_OPERAND (expr, 1)) == FIELD_DECL)
    t = size_int (DECL_ALIGN_UNIT (TREE_OPERAND (expr, 1)));
  else if (TREE_CODE (expr) == INDIRECT_REF)
    {
      tree t = TREE_OPERAND (expr, 0);
      tree best = t;
      int bestalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t)));
      while ((TREE_CODE (t) == NOP_EXPR || TREE_CODE (t) == CONVERT_EXPR)
	     && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == POINTER_TYPE)
	{
	  int thisalign;
	  t = TREE_OPERAND (t, 0);
	  thisalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t)));
	  if (thisalign > bestalign)
	    best = t, bestalign = thisalign;
	}
      return c_alignof (TREE_TYPE (TREE_TYPE (best)));
    }
  else
    return c_alignof (TREE_TYPE (expr));
  return fold_convert (size_type_node, t);
}
tree c_alignof_expr ( tree expr ) { tree t ; if ( VAR_OR_FUNCTION_DECL_P ( expr ) ) t = size_int ( DECL_ALIGN_UNIT ( expr ) ) ; else if ( TREE_CODE ( expr ) == COMPONENT_REF && DECL_C_BIT_FIELD ( TREE_OPERAND ( expr , 1 ) ) ) { error ( " " ) ; t = size_one_node ; } else if ( TREE_CODE ( expr ) == COMPONENT_REF && TREE_CODE ( TREE_OPERAND ( expr , 1 ) ) == FIELD_DECL ) t = size_int ( DECL_ALIGN_UNIT ( TREE_OPERAND ( expr , 1 ) ) ) ; else if ( TREE_CODE ( expr ) == INDIRECT_REF ) { tree t = TREE_OPERAND ( expr , 0 ) ; tree best = t ; int bestalign = TYPE_ALIGN ( TREE_TYPE ( TREE_TYPE ( t ) ) ) ; while ( ( TREE_CODE ( t ) == NOP_EXPR || TREE_CODE ( t ) == CONVERT_EXPR ) && TREE_CODE ( TREE_TYPE ( TREE_OPERAND ( t , 0 ) ) ) == POINTER_TYPE ) { int thisalign ; t = TREE_OPERAND ( t , 0 ) ; thisalign = TYPE_ALIGN ( TREE_TYPE ( TREE_TYPE ( t ) ) ) ; if ( thisalign > bestalign ) best = t , bestalign = thisalign ; } return c_alignof ( TREE_TYPE ( TREE_TYPE ( best ) ) ) ; } else return c_alignof ( TREE_TYPE ( expr ) ) ; return fold_convert ( size_type_node , t ) ; }
Implement the __alignof keyword: Return the minimum required
alignment of EXPR, measured in bytes.
Implement the __alignof keyword : Return the minimum required alignment of EXPR measured in bytes .