FreeBSD/contrib/gcc/c-common.c
/* Print a warning about casts that might indicate violation
   of strict aliasing rules if -Wstrict-aliasing is used and
   strict aliasing mode is in effect. OTYPE is the original
   TREE_TYPE of EXPR, and TYPE the type we're casting to. */
Print a warning about casts that might indicate violation
of strict aliasing rules if -Wstrict-aliasing is used and
strict aliasing mode is in effect. OTYPE is the original
TREE_TYPE of EXPR, and TYPE the type we're casting to.
Print a warning about casts that might indicate violation of strict aliasing rules if - Wstrict - aliasing is used and strict aliasing mode is in effect . OTYPE is the original TREE_TYPE of EXPR and TYPE the type we ' re casting to .
bool
strict_aliasing_warning (tree otype, tree type, tree expr)
{
  if (!(flag_strict_aliasing && POINTER_TYPE_P (type) 
        && POINTER_TYPE_P (otype) && !VOID_TYPE_P (TREE_TYPE (type))))
    return false;
  if ((warn_strict_aliasing > 1) && TREE_CODE (expr) == ADDR_EXPR
      && (DECL_P (TREE_OPERAND (expr, 0))
          || handled_component_p (TREE_OPERAND (expr, 0))))
    {
      if (!COMPLETE_TYPE_P (TREE_TYPE (type)) && warn_strict_aliasing == 2)
	{
	  warning (OPT_Wstrict_aliasing, "type-punning to incomplete type "
		   "might break strict-aliasing rules");
	  return true;
	}
      else
        {
          HOST_WIDE_INT set1 =
	    get_alias_set (TREE_TYPE (TREE_OPERAND (expr, 0)));
          HOST_WIDE_INT set2 = get_alias_set (TREE_TYPE (type));
          if (!alias_sets_conflict_p (set1, set2))
	    {
	      warning (OPT_Wstrict_aliasing, "dereferencing type-punned "
		       "pointer will break strict-aliasing rules");
	      return true;
	    }
          else if (warn_strict_aliasing == 2
		   && !alias_sets_might_conflict_p (set1, set2))
	    {
	      warning (OPT_Wstrict_aliasing, "dereferencing type-punned "
		       "pointer might break strict-aliasing rules");
	      return true;
	    }
        }
    }
  else
    if ((warn_strict_aliasing == 1) && !VOID_TYPE_P (TREE_TYPE (otype)))
      {
        HOST_WIDE_INT set1 = get_alias_set (TREE_TYPE (otype));
        HOST_WIDE_INT set2 = get_alias_set (TREE_TYPE (type));
        if (!COMPLETE_TYPE_P(type)
            || !alias_sets_might_conflict_p (set1, set2))
	  {
            warning (OPT_Wstrict_aliasing, "dereferencing type-punned "
                     "pointer might break strict-aliasing rules");
            return true;
          }
      }
  return false;
}
bool strict_aliasing_warning ( tree otype , tree type , tree expr ) { if ( ! ( flag_strict_aliasing && POINTER_TYPE_P ( type ) && POINTER_TYPE_P ( otype ) && ! VOID_TYPE_P ( TREE_TYPE ( type ) ) ) ) return false ; if ( ( warn_strict_aliasing > 1 ) && TREE_CODE ( expr ) == ADDR_EXPR && ( DECL_P ( TREE_OPERAND ( expr , 0 ) ) || handled_component_p ( TREE_OPERAND ( expr , 0 ) ) ) ) { if ( ! COMPLETE_TYPE_P ( TREE_TYPE ( type ) ) && warn_strict_aliasing == 2 ) { warning ( OPT_Wstrict_aliasing , " " " " ) ; return true ; } else { HOST_WIDE_INT set1 = get_alias_set ( TREE_TYPE ( TREE_OPERAND ( expr , 0 ) ) ) ; HOST_WIDE_INT set2 = get_alias_set ( TREE_TYPE ( type ) ) ; if ( ! alias_sets_conflict_p ( set1 , set2 ) ) { warning ( OPT_Wstrict_aliasing , " " " " ) ; return true ; } else if ( warn_strict_aliasing == 2 && ! alias_sets_might_conflict_p ( set1 , set2 ) ) { warning ( OPT_Wstrict_aliasing , " " " " ) ; return true ; } } } else if ( ( warn_strict_aliasing == 1 ) && ! VOID_TYPE_P ( TREE_TYPE ( otype ) ) ) { HOST_WIDE_INT set1 = get_alias_set ( TREE_TYPE ( otype ) ) ; HOST_WIDE_INT set2 = get_alias_set ( TREE_TYPE ( type ) ) ; if ( ! COMPLETE_TYPE_P ( type ) || ! alias_sets_might_conflict_p ( set1 , set2 ) ) { warning ( OPT_Wstrict_aliasing , " " " " ) ; return true ; } } return false ; }
Print a warning about casts that might indicate violation
of strict aliasing rules if -Wstrict-aliasing is used and
strict aliasing mode is in effect.
Print a warning about casts that might indicate violation of strict aliasing rules if - Wstrict - aliasing is used and strict aliasing mode is in effect .
/* Casting the address of an object to non void pointer. Warn
         if the cast breaks type based aliasing.  */ /* warn_strict_aliasing >= 3.   This includes the default (3).  
             Only warn if the cast is dereferenced immediately.  */ /* At this level, warn for any conversions, even if an address is
           not taken in the same statement.  This will likely produce many
           false positives, but could be useful to pinpoint problems that
           are not revealed at higher levels.  */