FreeBSD/contrib/gcc/c-common.c
/* Check that the Nth argument of a function call (counting backwards
   from the end) is a (pointer)0.  */
Check that the Nth argument of a function call (counting backwards
from the end) is a (pointer)0.
Check that the Nth argument of a function call ( counting backwards from the end ) is a ( pointer ) 0 .
static void
check_function_sentinel (tree attrs, tree params, tree typelist)
{
  tree attr = lookup_attribute ("sentinel", attrs);
  if (attr)
    {
      while (typelist && params)
      {
	typelist = TREE_CHAIN (typelist);
	params = TREE_CHAIN (params);
      }
      if (typelist || !params)
	warning (OPT_Wformat,
		 "not enough variable arguments to fit a sentinel");
      else
	{
	  tree sentinel, end;
	  unsigned pos = 0;
	  if (TREE_VALUE (attr))
	    {
	      tree p = TREE_VALUE (TREE_VALUE (attr));
	      pos = TREE_INT_CST_LOW (p);
	    }
	  sentinel = end = params;
	  while (pos > 0 && TREE_CHAIN (end))
	    {
	      pos--;
	      end = TREE_CHAIN (end);
	    }
	  if (pos > 0)
	    {
	      warning (OPT_Wformat,
		       "not enough variable arguments to fit a sentinel");
	      return;
	    }
	  while (TREE_CHAIN (end))
	    {
	      end = TREE_CHAIN (end);
	      sentinel = TREE_CHAIN (sentinel);
	    }
	  if ((!POINTER_TYPE_P (TREE_TYPE (TREE_VALUE (sentinel)))
	       || !integer_zerop (TREE_VALUE (sentinel)))
	      && (warn_strict_null_sentinel
		  || null_node != TREE_VALUE (sentinel)))
	    warning (OPT_Wformat, "missing sentinel in function call");
	}
    }
}
static void check_function_sentinel ( tree attrs , tree params , tree typelist ) { tree attr = lookup_attribute ( " " , attrs ) ; if ( attr ) { while ( typelist && params ) { typelist = TREE_CHAIN ( typelist ) ; params = TREE_CHAIN ( params ) ; } if ( typelist || ! params ) warning ( OPT_Wformat , " " ) ; else { tree sentinel , end ; unsigned pos = 0 ; if ( TREE_VALUE ( attr ) ) { tree p = TREE_VALUE ( TREE_VALUE ( attr ) ) ; pos = TREE_INT_CST_LOW ( p ) ; } sentinel = end = params ; while ( pos > 0 && TREE_CHAIN ( end ) ) { pos -- ; end = TREE_CHAIN ( end ) ; } if ( pos > 0 ) { warning ( OPT_Wformat , " " ) ; return ; } while ( TREE_CHAIN ( end ) ) { end = TREE_CHAIN ( end ) ; sentinel = TREE_CHAIN ( sentinel ) ; } if ( ( ! POINTER_TYPE_P ( TREE_TYPE ( TREE_VALUE ( sentinel ) ) ) || ! integer_zerop ( TREE_VALUE ( sentinel ) ) ) && ( warn_strict_null_sentinel || null_node != TREE_VALUE ( sentinel ) ) ) warning ( OPT_Wformat , " " ) ; } } }
Check that the Nth argument of a function call (counting backwards
from the end) is a (pointer)0.
Check that the Nth argument of a function call ( counting backwards from the end ) is a ( pointer ) 0 .
/* Skip over the named arguments.  */ /* Advance `end' ahead of `sentinel' by `pos' positions.  */ /* Now advance both until we find the last parameter.  */ /* Validate the sentinel.  */ /* Although __null (in C++) is only an integer we allow it
		 nevertheless, as we are guaranteed that it's exactly
		 as wide as a pointer, and we don't want to force
		 users to cast the NULL they have written there.
		 We warn with -Wstrict-null-sentinel, though.  */