Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Parse/ParseInit.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- ParseInit.cpp - Initializer Parsing ------------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file implements initializer parsing as specified by C99 6.7.8.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "clang/Parse/ParseDiagnostic.h"
14
#include "clang/Parse/Parser.h"
15
#include "clang/Parse/RAIIObjectsForParser.h"
16
#include "clang/Sema/Designator.h"
17
#include "clang/Sema/Scope.h"
18
#include "llvm/ADT/SmallString.h"
19
using namespace clang;
20
21
22
/// MayBeDesignationStart - Return true if the current token might be the start
23
/// of a designator.  If we can tell it is impossible that it is a designator,
24
/// return false.
25
1.03M
bool Parser::MayBeDesignationStart() {
26
1.03M
  switch (Tok.getKind()) {
27
1.03M
  default:
28
849k
    return false;
29
1.03M
30
1.03M
  case tok::period:      // designator: '.' identifier
31
2.45k
    return true;
32
1.03M
33
1.03M
  case tok::l_square: {  // designator: array-designator
34
315
    if (!PP.getLangOpts().CPlusPlus11)
35
219
      return true;
36
96
37
96
    // C++11 lambda expressions and C99 designators can be ambiguous all the
38
96
    // way through the closing ']' and to the next character. Handle the easy
39
96
    // cases here, and fall back to tentative parsing if those fail.
40
96
    switch (PP.LookAhead(0).getKind()) {
41
96
    case tok::equal:
42
13
    case tok::r_square:
43
13
      // Definitely starts a lambda expression.
44
13
      return false;
45
13
46
50
    case tok::amp:
47
50
    case tok::kw_this:
48
50
    case tok::identifier:
49
50
      // We have to do additional analysis, because these could be the
50
50
      // start of a constant expression or a lambda capture list.
51
50
      break;
52
50
53
50
    default:
54
33
      // Anything not mentioned above cannot occur following a '[' in a
55
33
      // lambda expression.
56
33
      return true;
57
50
    }
58
50
59
50
    // Handle the complicated case below.
60
50
    break;
61
50
  }
62
180k
  case tok::identifier:  // designation: identifier ':'
63
180k
    return PP.LookAhead(0).is(tok::colon);
64
50
  }
65
50
66
50
  // Parse up to (at most) the token after the closing ']' to determine
67
50
  // whether this is a C99 designator or a lambda.
68
50
  RevertingTentativeParsingAction Tentative(*this);
69
50
70
50
  LambdaIntroducer Intro;
71
50
  LambdaIntroducerTentativeParse ParseResult;
72
50
  if (ParseLambdaIntroducer(Intro, &ParseResult)) {
73
0
    // Hit and diagnosed an error in a lambda.
74
0
    // FIXME: Tell the caller this happened so they can recover.
75
0
    return true;
76
0
  }
77
50
78
50
  switch (ParseResult) {
79
50
  case LambdaIntroducerTentativeParse::Success:
80
33
  case LambdaIntroducerTentativeParse::Incomplete:
81
33
    // Might be a lambda-expression. Keep looking.
82
33
    // FIXME: If our tentative parse was not incomplete, parse the lambda from
83
33
    // here rather than throwing away then reparsing the LambdaIntroducer.
84
33
    break;
85
33
86
33
  case LambdaIntroducerTentativeParse::MessageSend:
87
17
  case LambdaIntroducerTentativeParse::Invalid:
88
17
    // Can't be a lambda-expression. Treat it as a designator.
89
17
    // FIXME: Should we disambiguate against a message-send?
90
17
    return true;
91
33
  }
92
33
93
33
  // Once we hit the closing square bracket, we look at the next
94
33
  // token. If it's an '=', this is a designator. Otherwise, it's a
95
33
  // lambda expression. This decision favors lambdas over the older
96
33
  // GNU designator syntax, which allows one to omit the '=', but is
97
33
  // consistent with GCC.
98
33
  return Tok.is(tok::equal);
99
33
}
100
101
static void CheckArrayDesignatorSyntax(Parser &P, SourceLocation Loc,
102
68
                                       Designation &Desig) {
103
68
  // If we have exactly one array designator, this used the GNU
104
68
  // 'designation: array-designator' extension, otherwise there should be no
105
68
  // designators at all!
106
68
  if (Desig.getNumDesignators() == 1 &&
107
68
      
(12
Desig.getDesignator(0).isArrayDesignator()12
||
108
12
       
Desig.getDesignator(0).isArrayRangeDesignator()4
))
109
8
    P.Diag(Loc, diag::ext_gnu_missing_equal_designator);
110
60
  else if (Desig.getNumDesignators() > 0)
111
4
    P.Diag(Loc, diag::err_expected_equal_designator);
112
68
}
113
114
/// ParseInitializerWithPotentialDesignator - Parse the 'initializer' production
115
/// checking to see if the token stream starts with a designator.
116
///
117
///       designation:
118
///         designator-list '='
119
/// [GNU]   array-designator
120
/// [GNU]   identifier ':'
121
///
122
///       designator-list:
123
///         designator
124
///         designator-list designator
125
///
126
///       designator:
127
///         array-designator
128
///         '.' identifier
129
///
130
///       array-designator:
131
///         '[' constant-expression ']'
132
/// [GNU]   '[' constant-expression '...' constant-expression ']'
133
///
134
/// NOTE: [OBC] allows '[ objc-receiver objc-message-args ]' as an
135
/// initializer (because it is an expression).  We need to consider this case
136
/// when parsing array designators.
137
///
138
2.74k
ExprResult Parser::ParseInitializerWithPotentialDesignator() {
139
2.74k
140
2.74k
  // If this is the old-style GNU extension:
141
2.74k
  //   designation ::= identifier ':'
142
2.74k
  // Handle it as a field designator.  Otherwise, this must be the start of a
143
2.74k
  // normal expression.
144
2.74k
  if (Tok.is(tok::identifier)) {
145
10
    const IdentifierInfo *FieldName = Tok.getIdentifierInfo();
146
10
147
10
    SmallString<256> NewSyntax;
148
10
    llvm::raw_svector_ostream(NewSyntax) << '.' << FieldName->getName()
149
10
                                         << " = ";
150
10
151
10
    SourceLocation NameLoc = ConsumeToken(); // Eat the identifier.
152
10
153
10
    assert(Tok.is(tok::colon) && "MayBeDesignationStart not working properly!");
154
10
    SourceLocation ColonLoc = ConsumeToken();
155
10
156
10
    Diag(NameLoc, diag::ext_gnu_old_style_field_designator)
157
10
      << FixItHint::CreateReplacement(SourceRange(NameLoc, ColonLoc),
158
10
                                      NewSyntax);
159
10
160
10
    Designation D;
161
10
    D.AddDesignator(Designator::getField(FieldName, SourceLocation(), NameLoc));
162
10
    return Actions.ActOnDesignatedInitializer(D, ColonLoc, true,
163
10
                                              ParseInitializer());
164
10
  }
165
2.73k
166
2.73k
  // Desig - This is initialized when we see our first designator.  We may have
167
2.73k
  // an objc message send with no designator, so we don't want to create this
168
2.73k
  // eagerly.
169
2.73k
  Designation Desig;
170
2.73k
171
2.73k
  // Parse each designator in the designator list until we find an initializer.
172
5.66k
  while (Tok.is(tok::period) || 
Tok.is(tok::l_square)3.03k
) {
173
2.99k
    if (Tok.is(tok::period)) {
174
2.63k
      // designator: '.' identifier
175
2.63k
      SourceLocation DotLoc = ConsumeToken();
176
2.63k
177
2.63k
      if (Tok.isNot(tok::identifier)) {
178
0
        Diag(Tok.getLocation(), diag::err_expected_field_designator);
179
0
        return ExprError();
180
0
      }
181
2.63k
182
2.63k
      Desig.AddDesignator(Designator::getField(Tok.getIdentifierInfo(), DotLoc,
183
2.63k
                                               Tok.getLocation()));
184
2.63k
      ConsumeToken(); // Eat the identifier.
185
2.63k
      continue;
186
2.63k
    }
187
366
188
366
    // We must have either an array designator now or an objc message send.
189
366
    assert(Tok.is(tok::l_square) && "Unexpected token!");
190
366
191
366
    // Handle the two forms of array designator:
192
366
    //   array-designator: '[' constant-expression ']'
193
366
    //   array-designator: '[' constant-expression '...' constant-expression ']'
194
366
    //
195
366
    // Also, we have to handle the case where the expression after the
196
366
    // designator an an objc message send: '[' objc-message-expr ']'.
197
366
    // Interesting cases are:
198
366
    //   [foo bar]         -> objc message send
199
366
    //   [foo]             -> array designator
200
366
    //   [foo ... bar]     -> array designator
201
366
    //   [4][foo bar]      -> obsolete GNU designation with objc message send.
202
366
    //
203
366
    // We do not need to check for an expression starting with [[ here. If it
204
366
    // contains an Objective-C message send, then it is not an ill-formed
205
366
    // attribute. If it is a lambda-expression within an array-designator, then
206
366
    // it will be rejected because a constant-expression cannot begin with a
207
366
    // lambda-expression.
208
366
    InMessageExpressionRAIIObject InMessage(*this, true);
209
366
210
366
    BalancedDelimiterTracker T(*this, tok::l_square);
211
366
    T.consumeOpen();
212
366
    SourceLocation StartLoc = T.getOpenLocation();
213
366
214
366
    ExprResult Idx;
215
366
216
366
    // If Objective-C is enabled and this is a typename (class message
217
366
    // send) or send to 'super', parse this as a message send
218
366
    // expression.  We handle C++ and C separately, since C++ requires
219
366
    // much more complicated parsing.
220
366
    if  (getLangOpts().ObjC && 
getLangOpts().CPlusPlus96
) {
221
58
      // Send to 'super'.
222
58
      if (Tok.is(tok::identifier) && 
Tok.getIdentifierInfo() == Ident_super30
&&
223
58
          
NextToken().isNot(tok::period)3
&&
224
58
          
getCurScope()->isInObjcMethodScope()3
) {
225
3
        CheckArrayDesignatorSyntax(*this, StartLoc, Desig);
226
3
        return ParseAssignmentExprWithObjCMessageExprStart(
227
3
            StartLoc, ConsumeToken(), nullptr, nullptr);
228
3
      }
229
55
230
55
      // Parse the receiver, which is either a type or an expression.
231
55
      bool IsExpr;
232
55
      void *TypeOrExpr;
233
55
      if (ParseObjCXXMessageReceiver(IsExpr, TypeOrExpr)) {
234
0
        SkipUntil(tok::r_square, StopAtSemi);
235
0
        return ExprError();
236
0
      }
237
55
238
55
      // If the receiver was a type, we have a class message; parse
239
55
      // the rest of it.
240
55
      if (!IsExpr) {
241
20
        CheckArrayDesignatorSyntax(*this, StartLoc, Desig);
242
20
        return ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
243
20
                                                           SourceLocation(),
244
20
                                   ParsedType::getFromOpaquePtr(TypeOrExpr),
245
20
                                                           nullptr);
246
20
      }
247
35
248
35
      // If the receiver was an expression, we still don't know
249
35
      // whether we have a message send or an array designator; just
250
35
      // adopt the expression for further analysis below.
251
35
      // FIXME: potentially-potentially evaluated expression above?
252
35
      Idx = ExprResult(static_cast<Expr*>(TypeOrExpr));
253
308
    } else if (getLangOpts().ObjC && 
Tok.is(tok::identifier)38
) {
254
10
      IdentifierInfo *II = Tok.getIdentifierInfo();
255
10
      SourceLocation IILoc = Tok.getLocation();
256
10
      ParsedType ReceiverType;
257
10
      // Three cases. This is a message send to a type: [type foo]
258
10
      // This is a message send to super:  [super foo]
259
10
      // This is a message sent to an expr:  [super.bar foo]
260
10
      switch (Actions.getObjCMessageKind(
261
10
          getCurScope(), II, IILoc, II == Ident_super,
262
10
          NextToken().is(tok::period), ReceiverType)) {
263
10
      case Sema::ObjCSuperMessage:
264
1
        CheckArrayDesignatorSyntax(*this, StartLoc, Desig);
265
1
        return ParseAssignmentExprWithObjCMessageExprStart(
266
1
            StartLoc, ConsumeToken(), nullptr, nullptr);
267
10
268
10
      case Sema::ObjCClassMessage:
269
3
        CheckArrayDesignatorSyntax(*this, StartLoc, Desig);
270
3
        ConsumeToken(); // the identifier
271
3
        if (!ReceiverType) {
272
0
          SkipUntil(tok::r_square, StopAtSemi);
273
0
          return ExprError();
274
0
        }
275
3
276
3
        // Parse type arguments and protocol qualifiers.
277
3
        if (Tok.is(tok::less)) {
278
0
          SourceLocation NewEndLoc;
279
0
          TypeResult NewReceiverType
280
0
            = parseObjCTypeArgsAndProtocolQualifiers(IILoc, ReceiverType,
281
0
                                                     /*consumeLastToken=*/true,
282
0
                                                     NewEndLoc);
283
0
          if (!NewReceiverType.isUsable()) {
284
0
            SkipUntil(tok::r_square, StopAtSemi);
285
0
            return ExprError();
286
0
          }
287
0
288
0
          ReceiverType = NewReceiverType.get();
289
0
        }
290
3
291
3
        return ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
292
3
                                                           SourceLocation(),
293
3
                                                           ReceiverType,
294
3
                                                           nullptr);
295
3
296
6
      case Sema::ObjCInstanceMessage:
297
6
        // Fall through; we'll just parse the expression and
298
6
        // (possibly) treat this like an Objective-C message send
299
6
        // later.
300
6
        break;
301
339
      }
302
339
    }
303
339
304
339
    // Parse the index expression, if we haven't already gotten one
305
339
    // above (which can only happen in Objective-C++).
306
339
    // Note that we parse this as an assignment expression, not a constant
307
339
    // expression (allowing *=, =, etc) to handle the objc case.  Sema needs
308
339
    // to validate that the expression is a constant.
309
339
    // FIXME: We also need to tell Sema that we're in a
310
339
    // potentially-potentially evaluated context.
311
339
    if (!Idx.get()) {
312
304
      Idx = ParseAssignmentExpression();
313
304
      if (Idx.isInvalid()) {
314
0
        SkipUntil(tok::r_square, StopAtSemi);
315
0
        return Idx;
316
0
      }
317
339
    }
318
339
319
339
    // Given an expression, we could either have a designator (if the next
320
339
    // tokens are '...' or ']' or an objc message send.  If this is an objc
321
339
    // message send, handle it now.  An objc-message send is the start of
322
339
    // an assignment-expression production.
323
339
    if (getLangOpts().ObjC && 
Tok.isNot(tok::ellipsis)69
&&
324
339
        
Tok.isNot(tok::r_square)69
) {
325
41
      CheckArrayDesignatorSyntax(*this, Tok.getLocation(), Desig);
326
41
      return ParseAssignmentExprWithObjCMessageExprStart(
327
41
          StartLoc, SourceLocation(), nullptr, Idx.get());
328
41
    }
329
298
330
298
    // If this is a normal array designator, remember it.
331
298
    if (Tok.isNot(tok::ellipsis)) {
332
279
      Desig.AddDesignator(Designator::getArray(Idx.get(), StartLoc));
333
279
    } else {
334
19
      // Handle the gnu array range extension.
335
19
      Diag(Tok, diag::ext_gnu_array_range);
336
19
      SourceLocation EllipsisLoc = ConsumeToken();
337
19
338
19
      ExprResult RHS(ParseConstantExpression());
339
19
      if (RHS.isInvalid()) {
340
0
        SkipUntil(tok::r_square, StopAtSemi);
341
0
        return RHS;
342
0
      }
343
19
      Desig.AddDesignator(Designator::getArrayRange(Idx.get(),
344
19
                                                    RHS.get(),
345
19
                                                    StartLoc, EllipsisLoc));
346
19
    }
347
298
348
298
    T.consumeClose();
349
298
    Desig.getDesignator(Desig.getNumDesignators() - 1).setRBracketLoc(
350
298
                                                        T.getCloseLocation());
351
298
  }
352
2.73k
353
2.73k
  // Okay, we're done with the designator sequence.  We know that there must be
354
2.73k
  // at least one designator, because the only case we can get into this method
355
2.73k
  // without a designator is when we have an objc message send.  That case is
356
2.73k
  // handled and returned from above.
357
2.73k
  assert(!Desig.empty() && "Designator is empty?");
358
2.67k
359
2.67k
  // Handle a normal designator sequence end, which is an equal.
360
2.67k
  if (Tok.is(tok::equal)) {
361
2.66k
    SourceLocation EqualLoc = ConsumeToken();
362
2.66k
    return Actions.ActOnDesignatedInitializer(Desig, EqualLoc, false,
363
2.66k
                                              ParseInitializer());
364
2.66k
  }
365
8
366
8
  // We read some number of designators and found something that isn't an = or
367
8
  // an initializer.  If we have exactly one array designator, this
368
8
  // is the GNU 'designation: array-designator' extension.  Otherwise, it is a
369
8
  // parse error.
370
8
  if (Desig.getNumDesignators() == 1 &&
371
8
      
(7
Desig.getDesignator(0).isArrayDesignator()7
||
372
7
       
Desig.getDesignator(0).isArrayRangeDesignator()0
)) {
373
7
    Diag(Tok, diag::ext_gnu_missing_equal_designator)
374
7
      << FixItHint::CreateInsertion(Tok.getLocation(), "= ");
375
7
    return Actions.ActOnDesignatedInitializer(Desig, Tok.getLocation(),
376
7
                                              true, ParseInitializer());
377
7
  }
378
1
379
1
  Diag(Tok, diag::err_expected_equal_designator);
380
1
  return ExprError();
381
1
}
382
383
384
/// ParseBraceInitializer - Called when parsing an initializer that has a
385
/// leading open brace.
386
///
387
///       initializer: [C99 6.7.8]
388
///         '{' initializer-list '}'
389
///         '{' initializer-list ',' '}'
390
/// [GNU]   '{' '}'
391
///
392
///       initializer-list:
393
///         designation[opt] initializer ...[opt]
394
///         initializer-list ',' designation[opt] initializer ...[opt]
395
///
396
116k
ExprResult Parser::ParseBraceInitializer() {
397
116k
  InMessageExpressionRAIIObject InMessage(*this, false);
398
116k
399
116k
  BalancedDelimiterTracker T(*this, tok::l_brace);
400
116k
  T.consumeOpen();
401
116k
  SourceLocation LBraceLoc = T.getOpenLocation();
402
116k
403
116k
  /// InitExprs - This is the actual list of expressions contained in the
404
116k
  /// initializer.
405
116k
  ExprVector InitExprs;
406
116k
407
116k
  if (Tok.is(tok::r_brace)) {
408
10.9k
    // Empty initializers are a C++ feature and a GNU extension to C.
409
10.9k
    if (!getLangOpts().CPlusPlus)
410
639
      Diag(LBraceLoc, diag::ext_gnu_empty_initializer);
411
10.9k
    // Match the '}'.
412
10.9k
    return Actions.ActOnInitList(LBraceLoc, None, ConsumeBrace());
413
10.9k
  }
414
106k
415
106k
  // Enter an appropriate expression evaluation context for an initializer list.
416
106k
  EnterExpressionEvaluationContext EnterContext(
417
106k
      Actions, EnterExpressionEvaluationContext::InitList);
418
106k
419
106k
  bool InitExprsOk = true;
420
106k
421
1.03M
  while (1) {
422
1.03M
    // Handle Microsoft __if_exists/if_not_exists if necessary.
423
1.03M
    if (getLangOpts().MicrosoftExt && 
(7.26k
Tok.is(tok::kw___if_exists)7.26k
||
424
7.26k
        
Tok.is(tok::kw___if_not_exists)7.26k
)) {
425
9
      if (ParseMicrosoftIfExistsBraceInitializer(InitExprs, InitExprsOk)) {
426
0
        if (Tok.isNot(tok::comma)) break;
427
0
        ConsumeToken();
428
0
      }
429
9
      if (Tok.is(tok::r_brace)) 
break0
;
430
9
      continue;
431
9
    }
432
1.03M
433
1.03M
    // Parse: designation[opt] initializer
434
1.03M
435
1.03M
    // If we know that this cannot be a designation, just parse the nested
436
1.03M
    // initializer directly.
437
1.03M
    ExprResult SubElt;
438
1.03M
    if (MayBeDesignationStart())
439
2.74k
      SubElt = ParseInitializerWithPotentialDesignator();
440
1.02M
    else
441
1.02M
      SubElt = ParseInitializer();
442
1.03M
443
1.03M
    if (Tok.is(tok::ellipsis))
444
165
      SubElt = Actions.ActOnPackExpansion(SubElt.get(), ConsumeToken());
445
1.03M
446
1.03M
    SubElt = Actions.CorrectDelayedTyposInExpr(SubElt.get());
447
1.03M
448
1.03M
    // If we couldn't parse the subelement, bail out.
449
1.03M
    if (SubElt.isUsable()) {
450
1.03M
      InitExprs.push_back(SubElt.get());
451
1.03M
    } else {
452
30
      InitExprsOk = false;
453
30
454
30
      // We have two ways to try to recover from this error: if the code looks
455
30
      // grammatically ok (i.e. we have a comma coming up) try to continue
456
30
      // parsing the rest of the initializer.  This allows us to emit
457
30
      // diagnostics for later elements that we find.  If we don't see a comma,
458
30
      // assume there is a parse error, and just skip to recover.
459
30
      // FIXME: This comment doesn't sound right. If there is a r_brace
460
30
      // immediately, it can't be an error, since there is no other way of
461
30
      // leaving this loop except through this if.
462
30
      if (Tok.isNot(tok::comma)) {
463
25
        SkipUntil(tok::r_brace, StopBeforeMatch);
464
25
        break;
465
25
      }
466
1.03M
    }
467
1.03M
468
1.03M
    // If we don't have a comma continued list, we're done.
469
1.03M
    if (Tok.isNot(tok::comma)) 
break101k
;
470
930k
471
930k
    // TODO: save comma locations if some client cares.
472
930k
    ConsumeToken();
473
930k
474
930k
    // Handle trailing comma.
475
930k
    if (Tok.is(tok::r_brace)) 
break4.41k
;
476
930k
  }
477
106k
478
106k
  bool closed = !T.consumeClose();
479
106k
480
106k
  if (InitExprsOk && 
closed105k
)
481
105k
    return Actions.ActOnInitList(LBraceLoc, InitExprs,
482
105k
                                 T.getCloseLocation());
483
27
484
27
  return ExprError(); // an error occurred.
485
27
}
486
487
488
// Return true if a comma (or closing brace) is necessary after the
489
// __if_exists/if_not_exists statement.
490
bool Parser::ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
491
9
                                                    bool &InitExprsOk) {
492
9
  bool trailingComma = false;
493
9
  IfExistsCondition Result;
494
9
  if (ParseMicrosoftIfExistsCondition(Result))
495
0
    return false;
496
9
497
9
  BalancedDelimiterTracker Braces(*this, tok::l_brace);
498
9
  if (Braces.consumeOpen()) {
499
0
    Diag(Tok, diag::err_expected) << tok::l_brace;
500
0
    return false;
501
0
  }
502
9
503
9
  switch (Result.Behavior) {
504
9
  case IEB_Parse:
505
4
    // Parse the declarations below.
506
4
    break;
507
9
508
9
  case IEB_Dependent:
509
1
    Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
510
1
      << Result.IsIfExists;
511
1
    // Fall through to skip.
512
1
    LLVM_FALLTHROUGH;
513
1
514
5
  case IEB_Skip:
515
5
    Braces.skipToEnd();
516
5
    return false;
517
4
  }
518
4
519
4
  while (!isEofOrEom()) {
520
4
    trailingComma = false;
521
4
    // If we know that this cannot be a designation, just parse the nested
522
4
    // initializer directly.
523
4
    ExprResult SubElt;
524
4
    if (MayBeDesignationStart())
525
0
      SubElt = ParseInitializerWithPotentialDesignator();
526
4
    else
527
4
      SubElt = ParseInitializer();
528
4
529
4
    if (Tok.is(tok::ellipsis))
530
0
      SubElt = Actions.ActOnPackExpansion(SubElt.get(), ConsumeToken());
531
4
532
4
    // If we couldn't parse the subelement, bail out.
533
4
    if (!SubElt.isInvalid())
534
4
      InitExprs.push_back(SubElt.get());
535
0
    else
536
0
      InitExprsOk = false;
537
4
538
4
    if (Tok.is(tok::comma)) {
539
4
      ConsumeToken();
540
4
      trailingComma = true;
541
4
    }
542
4
543
4
    if (Tok.is(tok::r_brace))
544
4
      break;
545
4
  }
546
4
547
4
  Braces.consumeClose();
548
4
549
4
  return !trailingComma;
550
4
}