FreeBSD/contrib/gcc/c-decl.c
/* Check the declarations given in a for-loop for satisfying the C99
   constraints.  If exactly one such decl is found, return it.  */
Check the declarations given in a for-loop for satisfying the C99
constraints.  If exactly one such decl is found, return it.
Check the declarations given in a for - loop for satisfying the C99 constraints . If exactly one such decl is found return it .
tree
check_for_loop_decls (void)
{
  struct c_binding *b;
  tree one_decl = NULL_TREE;
  int n_decls = 0;
  if (!flag_isoc99)
    {
      error ("%<for%> loop initial declaration used outside C99 mode");
      return NULL_TREE;
    }
  for (b = current_scope->bindings; b; b = b->prev)
    {
      tree id = b->id;
      tree decl = b->decl;
      if (!id)
	continue;
      switch (TREE_CODE (decl))
	{
	case VAR_DECL:
	  if (TREE_STATIC (decl))
	    error ("declaration of static variable %q+D in %<for%> loop "
		   "initial declaration", decl);
	  else if (DECL_EXTERNAL (decl))
	    error ("declaration of %<extern%> variable %q+D in %<for%> loop "
		   "initial declaration", decl);
	  break;
	case RECORD_TYPE:
	  error ("%<struct %E%> declared in %<for%> loop initial declaration",
		 id);
	  break;
	case UNION_TYPE:
	  error ("%<union %E%> declared in %<for%> loop initial declaration",
		 id);
	  break;
	case ENUMERAL_TYPE:
	  error ("%<enum %E%> declared in %<for%> loop initial declaration",
		 id);
	  break;
	 case FUNCTION_DECL:
	if (BLOCK_SYNTHESIZED_FUNC (decl))
		break;
	default:
	  error ("declaration of non-variable %q+D in %<for%> loop "
		 "initial declaration", decl);
	}
      n_decls++;
      one_decl = decl;
    }
  return n_decls == 1 ? one_decl : NULL_TREE;
}
tree check_for_loop_decls ( void ) { struct c_binding * b ; tree one_decl = NULL_TREE ; int n_decls = 0 ; if ( ! flag_isoc99 ) { error ( " " ) ; return NULL_TREE ; } for ( b = current_scope -> bindings ; b ; b = b -> prev ) { tree id = b -> id ; tree decl = b -> decl ; if ( ! id ) continue ; switch ( TREE_CODE ( decl ) ) { case VAR_DECL : if ( TREE_STATIC ( decl ) ) error ( " " " " , decl ) ; else if ( DECL_EXTERNAL ( decl ) ) error ( " " " " , decl ) ; break ; case RECORD_TYPE : error ( " " , id ) ; break ; case UNION_TYPE : error ( " " , id ) ; break ; case ENUMERAL_TYPE : error ( " " , id ) ; break ; case FUNCTION_DECL : if ( BLOCK_SYNTHESIZED_FUNC ( decl ) ) break ; default : error ( " " " " , decl ) ; } n_decls ++ ; one_decl = decl ; } return n_decls == 1 ? one_decl : NULL_TREE ; }
Check the declarations given in a for-loop for satisfying the C99
constraints.
Check the declarations given in a for - loop for satisfying the C99 constraints .
/* If we get here, declarations have been used in a for loop without
	 the C99 for loop scope.  This doesn't make much sense, so don't
	 allow it.  */ /* C99 subclause 6.8.5 paragraph 3:

       [#3]  The  declaration  part  of  a for statement shall only
       declare identifiers for objects having storage class auto or
       register.

     It isn't clear whether, in this sentence, "identifiers" binds to
     "shall only declare" or to "objects" - that is, whether all identifiers
     declared must be identifiers for objects, or whether the restriction
     only applies to those that are.  (A question on this in comp.std.c
     in November 2000 received no answer.)  We implement the strictest
     interpretation, to avoid creating an extension which later causes
     problems.  */ /* APPLE LOCAL begin radar 6268817 */ /* Block helper function can be declared in the statement block
	 for the for-loop declarations. */ /* APPLE LOCAL end radar 6268817 */