+static unsigned ParseScalarInit (type* T)
+/* Parse initializaton for scalar data types. Return the number of data bytes. */
+{
+ ExprDesc ED;
+
+ /* Optional opening brace */
+ unsigned BraceCount = OpeningCurlyBraces (0);
+
+ /* We warn if an initializer for a scalar contains braces, because this is
+ * quite unusual and often a sign for some problem in the input.
+ */
+ if (BraceCount > 0) {
+ Warning ("Braces around scalar initializer");
+ }
+
+ /* Get the expression and convert it to the target type */
+ ConstExpr (&ED);
+ TypeConversion (&ED, T);
+
+ /* Output the data */
+ DefineData (&ED);
+
+ /* Close eventually opening braces */
+ ClosingCurlyBraces (BraceCount);
+
+ /* Done */
+ return SizeOf (T);
+}
+
+
+
+static unsigned ParsePointerInit (type* T)
+/* Parse initializaton for pointer data types. Return the number of data bytes. */
+{
+ /* Optional opening brace */
+ unsigned BraceCount = OpeningCurlyBraces (0);
+
+ /* Expression */
+ ExprDesc ED;
+ ConstExpr (&ED);
+ if ((ED.Flags & E_MCTYPE) == E_TCONST) {
+ /* Make the const value the correct size */
+ ED.ConstVal &= 0xFFFF;
+ }
+ TypeConversion (&ED, T);
+
+ /* Output the data */
+ DefineData (&ED);
+
+ /* Close eventually opening braces */
+ ClosingCurlyBraces (BraceCount);
+
+ /* Done */
+ return SIZEOF_PTR;
+}
+
+
+
+static unsigned ParseArrayInit (type* T, int AllowFlexibleMembers)
+/* Parse initializaton for arrays. Return the number of data bytes. */
+{
+ int Count;
+
+ /* Get the array data */
+ type* ElementType = GetElementType (T);
+ unsigned ElementSize = CheckedSizeOf (ElementType);
+ long ElementCount = GetElementCount (T);
+
+ /* Special handling for a character array initialized by a literal */
+ if (IsTypeChar (ElementType) && CurTok.Tok == TOK_SCONST) {
+
+ /* Char array initialized by string constant */
+ const char* Str = GetLiteral (CurTok.IVal);
+ Count = GetLiteralPoolOffs () - CurTok.IVal;
+
+ /* Translate into target charset */
+ TranslateLiteralPool (CurTok.IVal);
+
+ /* If the array is one too small for the string literal, omit the
+ * trailing zero.
+ */
+ if (ElementCount != UNSPECIFIED &&
+ ElementCount != FLEXIBLE &&
+ Count == ElementCount + 1) {
+ /* Omit the trailing zero */
+ --Count;
+ }
+
+ /* Output the data */
+ g_defbytes (Str, Count);
+
+ /* Remove string from pool */
+ ResetLiteralPoolOffs (CurTok.IVal);
+ NextToken ();
+
+ } else {
+
+ /* Curly brace */
+ ConsumeLCurly ();
+
+ /* Initialize the array members */
+ Count = 0;
+ while (CurTok.Tok != TOK_RCURLY) {
+ /* Flexible array members may not be initialized within
+ * an array (because the size of each element may differ
+ * otherwise).
+ */
+ ParseInitInternal (ElementType, 0);
+ ++Count;
+ if (CurTok.Tok != TOK_COMMA)
+ break;
+ NextToken ();
+ }
+
+ /* Closing curly braces */
+ ConsumeRCurly ();
+ }
+
+
+ if (ElementCount == UNSPECIFIED) {
+ /* Number of elements determined by initializer */
+ Encode (T + 1, Count);
+ ElementCount = Count;
+ } else if (ElementCount == FLEXIBLE && AllowFlexibleMembers) {
+ /* In non ANSI mode, allow initialization of flexible array
+ * members.
+ */
+ ElementCount = Count;
+ } else if (Count < ElementCount) {
+ g_zerobytes ((ElementCount - Count) * ElementSize);
+ } else if (Count > ElementCount) {
+ Error ("Too many initializers");
+ }
+ return ElementCount * ElementSize;