FreeBSD/contrib/gcc/cp/decl.c
/* Subroutine of reshape_init, which processes a single initializer (part of
   a CONSTRUCTOR). TYPE is the type of the variable being initialized, D is the
   iterator within the CONSTRUCTOR which points to the initializer to process.
   FIRST_INITIALIZER_P is true if this is the first initializer of the
   CONSTRUCTOR node.  */
Subroutine of reshape_init, which processes a single initializer (part of
a CONSTRUCTOR). TYPE is the type of the variable being initialized, D is the
iterator within the CONSTRUCTOR which points to the initializer to process.
FIRST_INITIALIZER_P is true if this is the first initializer of the
CONSTRUCTOR node.
Subroutine of reshape_init which processes a single initializer ( part of a CONSTRUCTOR ) . TYPE is the type of the variable being initialized D is the iterator within the CONSTRUCTOR which points to the initializer to process . FIRST_INITIALIZER_P is true if this is the first initializer of the CONSTRUCTOR node .
static tree
reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p)
{
  tree init = d->cur->value;
  if (!CP_AGGREGATE_TYPE_P (type))
    {
      if (TREE_CODE (init) == CONSTRUCTOR
	  && BRACE_ENCLOSED_INITIALIZER_P (init))  
	{
	  error ("braces around scalar initializer for type %qT", type);
	  init = error_mark_node;
	}
      d->cur++;
      return init;
    }
  if (TREE_CODE (init) != CONSTRUCTOR
      && can_convert_arg (type, TREE_TYPE (init), init, LOOKUP_NORMAL))
    {
      d->cur++;
      return init;
    }
  if (TREE_CODE (type) == ARRAY_TYPE
      && char_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (type))))
    {
      tree str_init = init;
      if (!first_initializer_p
	  && TREE_CODE (str_init) == CONSTRUCTOR
	  && VEC_length (constructor_elt, CONSTRUCTOR_ELTS (str_init)) == 1)
	{
	  str_init = VEC_index (constructor_elt,
				CONSTRUCTOR_ELTS (str_init), 0)->value;
	}
      if (TREE_CODE (str_init) == STRING_CST)
	{
	  d->cur++;
	  return str_init;
	}
    }
  if (!first_initializer_p)
    {
      if (TREE_CODE (init) == CONSTRUCTOR)
	{
	  if (TREE_TYPE (init) && TYPE_PTRMEMFUNC_P (TREE_TYPE (init)))
           ;
	  else if (COMPOUND_LITERAL_P (init))
	    gcc_assert (!BRACE_ENCLOSED_INITIALIZER_P (init));
	  else
	    {
	      ++d->cur;
	      gcc_assert (BRACE_ENCLOSED_INITIALIZER_P (init));
	      return reshape_init (type, init);
	    }
	}
      warning (OPT_Wmissing_braces, "missing braces around initializer for %qT",
	       type);
    }
  if (CLASS_TYPE_P (type))
    return reshape_init_class (type, d, first_initializer_p);
  else if (TREE_CODE (type) == ARRAY_TYPE)
    return reshape_init_array (type, d);
  else if (TREE_CODE (type) == VECTOR_TYPE)
    return reshape_init_vector (type, d);
  else
    gcc_unreachable();
}
static tree reshape_init_r ( tree type , reshape_iter * d , bool first_initializer_p ) { tree init = d -> cur -> value ; if ( ! CP_AGGREGATE_TYPE_P ( type ) ) { if ( TREE_CODE ( init ) == CONSTRUCTOR && BRACE_ENCLOSED_INITIALIZER_P ( init ) ) { error ( " " , type ) ; init = error_mark_node ; } d -> cur ++ ; return init ; } if ( TREE_CODE ( init ) != CONSTRUCTOR && can_convert_arg ( type , TREE_TYPE ( init ) , init , LOOKUP_NORMAL ) ) { d -> cur ++ ; return init ; } if ( TREE_CODE ( type ) == ARRAY_TYPE && char_type_p ( TYPE_MAIN_VARIANT ( TREE_TYPE ( type ) ) ) ) { tree str_init = init ; if ( ! first_initializer_p && TREE_CODE ( str_init ) == CONSTRUCTOR && VEC_length ( constructor_elt , CONSTRUCTOR_ELTS ( str_init ) ) == 1 ) { str_init = VEC_index ( constructor_elt , CONSTRUCTOR_ELTS ( str_init ) , 0 ) -> value ; } if ( TREE_CODE ( str_init ) == STRING_CST ) { d -> cur ++ ; return str_init ; } } if ( ! first_initializer_p ) { if ( TREE_CODE ( init ) == CONSTRUCTOR ) { if ( TREE_TYPE ( init ) && TYPE_PTRMEMFUNC_P ( TREE_TYPE ( init ) ) ) ; else if ( COMPOUND_LITERAL_P ( init ) ) gcc_assert ( ! BRACE_ENCLOSED_INITIALIZER_P ( init ) ) ; else { ++ d -> cur ; gcc_assert ( BRACE_ENCLOSED_INITIALIZER_P ( init ) ) ; return reshape_init ( type , init ) ; } } warning ( OPT_Wmissing_braces , " " , type ) ; } if ( CLASS_TYPE_P ( type ) ) return reshape_init_class ( type , d , first_initializer_p ) ; else if ( TREE_CODE ( type ) == ARRAY_TYPE ) return reshape_init_array ( type , d ) ; else if ( TREE_CODE ( type ) == VECTOR_TYPE ) return reshape_init_vector ( type , d ) ; else gcc_unreachable ( ) ; }
Subroutine of reshape_init, which processes a single initializer (part of
a CONSTRUCTOR).
Subroutine of reshape_init which processes a single initializer ( part of a CONSTRUCTOR ) .
/* A non-aggregate type is always initialized with a single
     initializer.  */ /* It is invalid to initialize a non-aggregate type with a
	 brace-enclosed initializer.
	 We need to check for BRACE_ENCLOSED_INITIALIZER_P here because
	 of g++.old-deja/g++.mike/p7626.C: a pointer-to-member constant is
	 a CONSTRUCTOR (with a record type).  */ /* p7626.C */ /* [dcl.init.aggr]

     All implicit type conversions (clause _conv_) are considered when
     initializing the aggregate member with an initializer from an
     initializer-list.  If the initializer can initialize a member,
     the member is initialized.  Otherwise, if the member is itself a
     non-empty subaggregate, brace elision is assumed and the
     initializer is considered for the initialization of the first
     member of the subaggregate.  */ /* [dcl.init.string]

      A char array (whether plain char, signed char, or unsigned char)
      can be initialized by a string-literal (optionally enclosed in
      braces); a wchar_t array can be initialized by a wide
      string-literal (optionally enclosed in braces).  */ /* Strip one level of braces if and only if they enclose a single
	 element (as allowed by [dcl.init.string]).  */ /* If it's a string literal, then it's the initializer for the array
	 as a whole. Otherwise, continue with normal initialization for
	 array types (one value per array element).  */ /* The following cases are about aggregates. If we are not within a full
     initializer already, and there is not a CONSTRUCTOR, it means that there
     is a missing set of braces (that is, we are processing the case for
     which reshape_init exists).  */ /* There is no need to reshape pointer-to-member function
	       initializers, as they are always constructed correctly
	       by the front end.  */ /* For a nested compound literal, there is no need to reshape since
	     brace elision is not allowed. Even if we decided to allow it,
	     we should add a call to reshape_init in finish_compound_literal,
	     before calling digest_init, so changing this code would still
	     not be necessary.  */ /* Dispatch to specialized routines.  */