FreeBSD/contrib/gcc/cp/decl.c
/* Verify INIT (the initializer for DECL), and record the
   initialization in DECL_INITIAL, if appropriate.  CLEANUP is as for
   grok_reference_init.

   If the return value is non-NULL, it is an expression that must be
   evaluated dynamically to initialize DECL.  */
Verify INIT (the initializer for DECL), and record the
initialization in DECL_INITIAL, if appropriate.  CLEANUP is as for
grok_reference_init.

If the return value is non-NULL, it is an expression that must be
evaluated dynamically to initialize DECL.
Verify INIT ( the initializer for DECL ) and record the initialization in DECL_INITIAL if appropriate . CLEANUP is as for grok_reference_init . If the return value is non - NULL it is an expression that must be evaluated dynamically to initialize DECL .
static tree
check_initializer (tree decl, tree init, int flags, tree *cleanup)
{
  tree type = TREE_TYPE (decl);
  tree init_code = NULL;
  TREE_TYPE (decl) = type = complete_type (TREE_TYPE (decl));
  if (type == error_mark_node)
    return NULL_TREE;
  if (TREE_CODE (type) == ARRAY_TYPE)
    {
      tree element_type = TREE_TYPE (type);
      if (!COMPLETE_TYPE_P (complete_type (element_type)))
	{
	  error ("elements of array %q#D have incomplete type", decl);
	  return NULL_TREE;
	}
      if (init
	  && ((COMPLETE_TYPE_P (type) && !TREE_CONSTANT (TYPE_SIZE (type)))
	      || !TREE_CONSTANT (TYPE_SIZE (element_type))))
	{
	  error ("variable-sized object %qD may not be initialized", decl);
	  return NULL_TREE;
	}
    }
  else if (!COMPLETE_TYPE_P (type))
    {
      error ("%qD has incomplete type", decl);
      TREE_TYPE (decl) = error_mark_node;
      return NULL_TREE;
    }
  else
    gcc_assert (TREE_CONSTANT (TYPE_SIZE (type)));
  if (!CP_AGGREGATE_TYPE_P (type)
      && init && BRACE_ENCLOSED_INITIALIZER_P (init)
      && VEC_length (constructor_elt, CONSTRUCTOR_ELTS (init)) != 1)
    {
      error ("scalar object %qD requires one element in initializer", decl);
      TREE_TYPE (decl) = error_mark_node;
      return NULL_TREE;
    }
  if (TREE_CODE (decl) == CONST_DECL)
    {
      gcc_assert (TREE_CODE (type) != REFERENCE_TYPE);
      DECL_INITIAL (decl) = init;
      gcc_assert (init != NULL_TREE);
      init = NULL_TREE;
    }
  else if (!DECL_EXTERNAL (decl) && TREE_CODE (type) == REFERENCE_TYPE)
    init = grok_reference_init (decl, type, init, cleanup);
  else if (init)
    {
      if (TREE_CODE (init) == CONSTRUCTOR
	  && !COMPOUND_LITERAL_P (init)
	  && !TREE_TYPE (init))  
	{
	  init = reshape_init (type, init);
	  if ((*targetm.vector_opaque_p) (type))
	    {
	      error ("opaque vector types cannot be initialized");
	      init = error_mark_node;
	    }
	}
      maybe_deduce_size_from_array_init (decl, init);
      type = TREE_TYPE (decl);
      if (type == error_mark_node)
	return NULL_TREE;
      if (TYPE_HAS_CONSTRUCTOR (type) || TYPE_NEEDS_CONSTRUCTING (type))
	{
	  if (TREE_CODE (type) == ARRAY_TYPE)
	    goto initialize_aggr;
	  else if (TREE_CODE (init) == CONSTRUCTOR)
	    {
	      if (TYPE_NON_AGGREGATE_CLASS (type))
		{
		  error ("%qD must be initialized by constructor, "
			 "not by %<{...}%>",
			 decl);
		  init = error_mark_node;
		}
	      else
		goto dont_use_constructor;
	    }
	  else
	    {
	      int saved_stmts_are_full_exprs_p;
	    initialize_aggr:
	      saved_stmts_are_full_exprs_p = 0;
	      if (building_stmt_tree ())
		{
		  saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
		  current_stmt_tree ()->stmts_are_full_exprs_p = 1;
		}
	      init = build_aggr_init (decl, init, flags);
	      if (building_stmt_tree ())
		current_stmt_tree ()->stmts_are_full_exprs_p =
		  saved_stmts_are_full_exprs_p;
	      return init;
	    }
	}
      else
	{
	dont_use_constructor:
	  if (TREE_CODE (init) != TREE_VEC)
	    {
	      init_code = store_init_value (decl, init);
	      if (pedantic && TREE_CODE (type) == ARRAY_TYPE
		  && DECL_INITIAL (decl)
		  && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST
		  && PAREN_STRING_LITERAL_P (DECL_INITIAL (decl)))
		warning (0, "array %qD initialized by parenthesized string literal %qE",
			 decl, DECL_INITIAL (decl));
	      init = NULL;
	    }
	}
    }
  else if (DECL_EXTERNAL (decl))
    ;
  else if (TYPE_P (type) && TYPE_NEEDS_CONSTRUCTING (type))
    goto initialize_aggr;
  else if (IS_AGGR_TYPE (type))
    {
      tree core_type = strip_array_types (type);
      if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (core_type))
	error ("structure %qD with uninitialized const members", decl);
      if (CLASSTYPE_REF_FIELDS_NEED_INIT (core_type))
	error ("structure %qD with uninitialized reference members", decl);
      check_for_uninitialized_const_var (decl);
    }
  else
    check_for_uninitialized_const_var (decl);
  if (init && init != error_mark_node)
    init_code = build2 (INIT_EXPR, type, decl, init);
  return init_code;
}
static tree check_initializer ( tree decl , tree init , int flags , tree * cleanup ) { tree type = TREE_TYPE ( decl ) ; tree init_code = NULL ; TREE_TYPE ( decl ) = type = complete_type ( TREE_TYPE ( decl ) ) ; if ( type == error_mark_node ) return NULL_TREE ; if ( TREE_CODE ( type ) == ARRAY_TYPE ) { tree element_type = TREE_TYPE ( type ) ; if ( ! COMPLETE_TYPE_P ( complete_type ( element_type ) ) ) { error ( " " , decl ) ; return NULL_TREE ; } if ( init && ( ( COMPLETE_TYPE_P ( type ) && ! TREE_CONSTANT ( TYPE_SIZE ( type ) ) ) || ! TREE_CONSTANT ( TYPE_SIZE ( element_type ) ) ) ) { error ( " " , decl ) ; return NULL_TREE ; } } else if ( ! COMPLETE_TYPE_P ( type ) ) { error ( " " , decl ) ; TREE_TYPE ( decl ) = error_mark_node ; return NULL_TREE ; } else gcc_assert ( TREE_CONSTANT ( TYPE_SIZE ( type ) ) ) ; if ( ! CP_AGGREGATE_TYPE_P ( type ) && init && BRACE_ENCLOSED_INITIALIZER_P ( init ) && VEC_length ( constructor_elt , CONSTRUCTOR_ELTS ( init ) ) != 1 ) { error ( " " , decl ) ; TREE_TYPE ( decl ) = error_mark_node ; return NULL_TREE ; } if ( TREE_CODE ( decl ) == CONST_DECL ) { gcc_assert ( TREE_CODE ( type ) != REFERENCE_TYPE ) ; DECL_INITIAL ( decl ) = init ; gcc_assert ( init != NULL_TREE ) ; init = NULL_TREE ; } else if ( ! DECL_EXTERNAL ( decl ) && TREE_CODE ( type ) == REFERENCE_TYPE ) init = grok_reference_init ( decl , type , init , cleanup ) ; else if ( init ) { if ( TREE_CODE ( init ) == CONSTRUCTOR && ! COMPOUND_LITERAL_P ( init ) && ! TREE_TYPE ( init ) ) { init = reshape_init ( type , init ) ; if ( ( * targetm . vector_opaque_p ) ( type ) ) { error ( " " ) ; init = error_mark_node ; } } maybe_deduce_size_from_array_init ( decl , init ) ; type = TREE_TYPE ( decl ) ; if ( type == error_mark_node ) return NULL_TREE ; if ( TYPE_HAS_CONSTRUCTOR ( type ) || TYPE_NEEDS_CONSTRUCTING ( type ) ) { if ( TREE_CODE ( type ) == ARRAY_TYPE ) goto initialize_aggr ; else if ( TREE_CODE ( init ) == CONSTRUCTOR ) { if ( TYPE_NON_AGGREGATE_CLASS ( type ) ) { error ( " " " " , decl ) ; init = error_mark_node ; } else goto dont_use_constructor ; } else { int saved_stmts_are_full_exprs_p ; initialize_aggr : saved_stmts_are_full_exprs_p = 0 ; if ( building_stmt_tree ( ) ) { saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ( ) ; current_stmt_tree ( ) -> stmts_are_full_exprs_p = 1 ; } init = build_aggr_init ( decl , init , flags ) ; if ( building_stmt_tree ( ) ) current_stmt_tree ( ) -> stmts_are_full_exprs_p = saved_stmts_are_full_exprs_p ; return init ; } } else { dont_use_constructor : if ( TREE_CODE ( init ) != TREE_VEC ) { init_code = store_init_value ( decl , init ) ; if ( pedantic && TREE_CODE ( type ) == ARRAY_TYPE && DECL_INITIAL ( decl ) && TREE_CODE ( DECL_INITIAL ( decl ) ) == STRING_CST && PAREN_STRING_LITERAL_P ( DECL_INITIAL ( decl ) ) ) warning ( 0 , " " , decl , DECL_INITIAL ( decl ) ) ; init = NULL ; } } } else if ( DECL_EXTERNAL ( decl ) ) ; else if ( TYPE_P ( type ) && TYPE_NEEDS_CONSTRUCTING ( type ) ) goto initialize_aggr ; else if ( IS_AGGR_TYPE ( type ) ) { tree core_type = strip_array_types ( type ) ; if ( CLASSTYPE_READONLY_FIELDS_NEED_INIT ( core_type ) ) error ( " " , decl ) ; if ( CLASSTYPE_REF_FIELDS_NEED_INIT ( core_type ) ) error ( " " , decl ) ; check_for_uninitialized_const_var ( decl ) ; } else check_for_uninitialized_const_var ( decl ) ; if ( init && init != error_mark_node ) init_code = build2 ( INIT_EXPR , type , decl , init ) ; return init_code ; }
Verify INIT (the initializer for DECL), and record the
initialization in DECL_INITIAL, if appropriate.
Verify INIT ( the initializer for DECL ) and record the initialization in DECL_INITIAL if appropriate .
/* Things that are going to be initialized need to have complete
     type.  */ /* We will have already complained.  */ /* The array type itself need not be complete, because the
	 initializer may tell us how many elements are in the array.
	 But, the elements of the array must be complete.  */ /* It is not valid to initialize an a VLA.  */ /* There is no way to make a variable-sized class type in GNU C++.  */ /* Do not reshape constructors of vectors (they don't need to be
	 reshaped.  */ /* ptrmemfunc */ /* If DECL has an array type without a specific bound, deduce the
	 array size from the initializer.  */