+ /* Ignore if we have no data */
+ if (SI->ValBits > 0) {
+
+ /* Output the data */
+ g_defdata (CF_INT | CF_UNSIGNED | CF_CONST, SI->BitVal, 0);
+
+ /* Clear the data from SI and account for the size */
+ SI->BitVal = 0;
+ SI->ValBits = 0;
+ SI->Offs += SIZEOF_INT;
+ }
+}
+
+
+
+static void ParseScalarInitInternal (Type* T, ExprDesc* ED)
+/* Parse initializaton for scalar data types. This function will not output the
+ * data but return it in 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 (hie1, ED);
+ TypeConversion (ED, T);
+
+ /* Close eventually opening braces */
+ ClosingCurlyBraces (BraceCount);
+}
+
+
+
+static unsigned ParseScalarInit (Type* T)
+/* Parse initializaton for scalar data types. Return the number of data bytes. */
+{
+ ExprDesc ED;
+
+ /* Parse initialization */
+ ParseScalarInitInternal (T, &ED);
+
+ /* Output the data */
+ DefineData (&ED);
+
+ /* 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 (hie1, &ED);
+ 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 || CurTok.Tok == TOK_WCSCONST ||
+ (CurTok.Tok == TOK_LCURLY &&
+ (NextTok.Tok == TOK_SCONST || NextTok.Tok == TOK_WCSCONST)))) {
+
+ /* Char array initialized by string constant */
+ int NeedParen;
+
+ /* If we initializer is enclosed in brackets, remember this fact and
+ * skip the opening bracket.
+ */
+ NeedParen = (CurTok.Tok == TOK_LCURLY);
+ if (NeedParen) {
+ NextToken ();
+ }
+
+ /* Translate into target charset */
+ TranslateLiteral (CurTok.SVal);
+
+ /* If the array is one too small for the string literal, omit the
+ * trailing zero.
+ */
+ Count = GetLiteralSize (CurTok.SVal);
+ if (ElementCount != UNSPECIFIED &&
+ ElementCount != FLEXIBLE &&
+ Count == ElementCount + 1) {
+ /* Omit the trailing zero */
+ --Count;
+ }
+
+ /* Output the data */
+ g_defbytes (GetLiteralStr (CurTok.SVal), Count);
+
+ /* Skip the string */
+ NextToken ();
+
+ /* If the initializer was enclosed in curly braces, we need a closing
+ * one.
+ */
+ if (NeedParen) {
+ ConsumeRCurly ();
+ }
+
+ } 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 */
+ SetElementCount (T, 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;
+}
+
+
+
+static unsigned ParseStructInit (Type* T, int AllowFlexibleMembers)
+/* Parse initialization of a struct or union. Return the number of data bytes. */
+{
+ SymEntry* Entry;
+ SymTable* Tab;
+ StructInitData SI;
+