FreeBSD/contrib/gcc/c-decl.c
/* Generate an implicit declaration for identifier FUNCTIONID as a
   function of type int ().  */
Generate an implicit declaration for identifier FUNCTIONID as a
function of type int ().
Generate an implicit declaration for identifier FUNCTIONID as a function of type int () .
tree
implicitly_declare (tree functionid)
{
  struct c_binding *b;
  tree decl = 0;
  tree asmspec_tree;
  for (b = I_SYMBOL_BINDING (functionid); b; b = b->shadowed)
    {
      if (B_IN_SCOPE (b, external_scope))
	{
	  decl = b->decl;
	  break;
	}
    }
  if (decl)
    {
      if (decl == error_mark_node)
	return decl;
      if (!DECL_BUILT_IN (decl) && DECL_IS_BUILTIN (decl))
	{
	  bind (functionid, decl, file_scope,
		false, true);
	  return decl;
	}
      else
	{
	  tree newtype = default_function_type;
	  if (b->type)
	    TREE_TYPE (decl) = b->type;
	  if (!C_DECL_IMPLICIT (decl))
	    {
	      implicit_decl_warning (functionid, decl);
	      C_DECL_IMPLICIT (decl) = 1;
	    }
	  if (DECL_BUILT_IN (decl))
	    {
	      newtype = build_type_attribute_variant (newtype,
						      TYPE_ATTRIBUTES
						      (TREE_TYPE (decl)));
	      if (!comptypes (newtype, TREE_TYPE (decl)))
		{
		  warning (0, "incompatible implicit declaration of built-in"
			   " function %qD", decl);
		  newtype = TREE_TYPE (decl);
		}
	    }
	  else
	    {
	      if (!comptypes (newtype, TREE_TYPE (decl)))
		{
		  error ("incompatible implicit declaration of function %qD",
			 decl);
		  locate_old_decl (decl, error);
		}
	    }
	  b->type = TREE_TYPE (decl);
	  TREE_TYPE (decl) = newtype;
	  bind (functionid, decl, current_scope,
		false, true);
	  return decl;
	}
    }
  decl = build_decl (FUNCTION_DECL, functionid, default_function_type);
  DECL_EXTERNAL (decl) = 1;
  TREE_PUBLIC (decl) = 1;
  C_DECL_IMPLICIT (decl) = 1;
  implicit_decl_warning (functionid, 0);
  asmspec_tree = maybe_apply_renaming_pragma (decl, NULL);
  if (asmspec_tree)
    set_user_assembler_name (decl, TREE_STRING_POINTER (asmspec_tree));
  decl = pushdecl (decl);
  rest_of_decl_compilation (decl, 0, 0);
  gen_aux_info_record (decl, 0, 1, 0);
  decl_attributes (&decl, NULL_TREE, 0);
  return decl;
}
tree implicitly_declare ( tree functionid ) { struct c_binding * b ; tree decl = 0 ; tree asmspec_tree ; for ( b = I_SYMBOL_BINDING ( functionid ) ; b ; b = b -> shadowed ) { if ( B_IN_SCOPE ( b , external_scope ) ) { decl = b -> decl ; break ; } } if ( decl ) { if ( decl == error_mark_node ) return decl ; if ( ! DECL_BUILT_IN ( decl ) && DECL_IS_BUILTIN ( decl ) ) { bind ( functionid , decl , file_scope , false , true ) ; return decl ; } else { tree newtype = default_function_type ; if ( b -> type ) TREE_TYPE ( decl ) = b -> type ; if ( ! C_DECL_IMPLICIT ( decl ) ) { implicit_decl_warning ( functionid , decl ) ; C_DECL_IMPLICIT ( decl ) = 1 ; } if ( DECL_BUILT_IN ( decl ) ) { newtype = build_type_attribute_variant ( newtype , TYPE_ATTRIBUTES ( TREE_TYPE ( decl ) ) ) ; if ( ! comptypes ( newtype , TREE_TYPE ( decl ) ) ) { warning ( 0 , " " " " , decl ) ; newtype = TREE_TYPE ( decl ) ; } } else { if ( ! comptypes ( newtype , TREE_TYPE ( decl ) ) ) { error ( " " , decl ) ; locate_old_decl ( decl , error ) ; } } b -> type = TREE_TYPE ( decl ) ; TREE_TYPE ( decl ) = newtype ; bind ( functionid , decl , current_scope , false , true ) ; return decl ; } } decl = build_decl ( FUNCTION_DECL , functionid , default_function_type ) ; DECL_EXTERNAL ( decl ) = 1 ; TREE_PUBLIC ( decl ) = 1 ; C_DECL_IMPLICIT ( decl ) = 1 ; implicit_decl_warning ( functionid , 0 ) ; asmspec_tree = maybe_apply_renaming_pragma ( decl , NULL ) ; if ( asmspec_tree ) set_user_assembler_name ( decl , TREE_STRING_POINTER ( asmspec_tree ) ) ; decl = pushdecl ( decl ) ; rest_of_decl_compilation ( decl , 0 , 0 ) ; gen_aux_info_record ( decl , 0 , 1 , 0 ) ; decl_attributes ( & decl , NULL_TREE , 0 ) ; return decl ; }
Generate an implicit declaration for identifier FUNCTIONID as a
function of type int ().
Generate an implicit declaration for identifier FUNCTIONID as a function of type int () .
/* FIXME: Objective-C has weird not-really-builtin functions
	 which are supposed to be visible automatically.  They wind up
	 in the external scope because they're pushed before the file
	 scope gets created.  Catch this here and rebind them into the
	 file scope.  */ /*invisible=*/ /*nested=*/ /* Implicit declaration of a function already declared
	     (somehow) in a different scope, or as a built-in.
	     If this is the first time this has happened, warn;
	     then recycle the old declaration but with the new type.  */ /*invisible=*/ /*nested=*/ /* Not seen before.  */ /*asmname=*/ /* C89 says implicit declarations are in the innermost block.
     So we record the decl in the standard fashion.  */ /* No need to call objc_check_decl here - it's a function type.  */ /* Write a record describing this implicit function declaration
     to the prototypes file (if requested).  */ /* Possibly apply some default attributes to this implicit declaration.  */