@@ -2328,9 +2328,6 @@ Parser::TPResult Parser::isTemplateArgumentList(unsigned TokensToSkip,
2328
2328
if (!TryConsumeToken (tok::less))
2329
2329
return TPResult::False;
2330
2330
2331
- bool IsNestedTemplateArgumentList = !GreaterThanIsOperator;
2332
- GreaterThanIsOperatorScope G (GreaterThanIsOperator, false );
2333
-
2334
2331
auto TrySkipTemplateArgument = [&]() {
2335
2332
bool NextIsTemplateId = false ;
2336
2333
unsigned TemplateDepth = 0 ;
@@ -2344,76 +2341,76 @@ Parser::TPResult Parser::isTemplateArgumentList(unsigned TokensToSkip,
2344
2341
case tok::semi:
2345
2342
return TPResult::False;
2346
2343
2347
- case tok::comma:
2348
- case tok::greater:
2349
- case tok::greatergreater:
2350
2344
case tok::greatergreatergreater:
2345
+ if (TemplateDepth)
2346
+ --TemplateDepth;
2347
+ [[fallthrough]];
2348
+ case tok::greatergreater:
2349
+ if (TemplateDepth)
2350
+ --TemplateDepth;
2351
+ [[fallthrough]];
2352
+ case tok::greater:
2353
+ if (TemplateDepth) {
2354
+ ConsumeToken ();
2355
+ --TemplateDepth;
2356
+ break ;
2357
+ }
2358
+ [[fallthrough]];
2359
+ case tok::comma:
2351
2360
return TPResult::True;
2352
2361
2353
2362
case tok::l_paren:
2354
2363
ConsumeParen ();
2355
2364
if (!SkipUntil (tok::r_paren, StopAtSemi))
2356
2365
return TPResult::Error;
2357
2366
break ;
2367
+
2358
2368
case tok::l_brace:
2359
2369
ConsumeBrace ();
2360
2370
if (!SkipUntil (tok::r_brace, StopAtSemi))
2361
2371
return TPResult::Error;
2362
2372
break ;
2373
+
2363
2374
case tok::l_square:
2364
2375
ConsumeBracket ();
2365
2376
if (!SkipUntil (tok::r_square, StopAtSemi))
2366
2377
return TPResult::Error;
2367
2378
break ;
2379
+
2368
2380
case tok::question:
2369
2381
ConsumeToken ();
2370
2382
if (!SkipUntil (tok::colon, StopAtSemi))
2371
2383
return TPResult::Error;
2372
2384
break ;
2373
2385
2374
- #if 0
2375
- case tok::kw_template:
2376
- ConsumeToken();
2377
- NextIsTemplateId = true;
2378
- continue;
2379
- #endif
2386
+ case tok::kw_template:
2387
+ ConsumeToken ();
2388
+ NextIsTemplateId = true ;
2389
+ continue ;
2390
+
2380
2391
case tok::identifier:
2381
2392
ConsumeToken ();
2382
- #if 0
2383
- if (Tok.is(tok::less)) {
2384
- if (!NextIsTemplateId)
2385
- return TPResult::Ambiguous;
2386
- ConsumeToken();
2387
- if (!SkipUntil({tok::greater, tok::greatergreater, tok::greatergreatergreater}, StopAtSemi))
2388
- return TPResult::Error;
2389
- break;
2390
- }
2391
- #else
2392
- if (Tok.is (tok::less))
2393
- return TPResult::Ambiguous;
2393
+ if (Tok.is (tok::less)) {
2394
+ if (!NextIsTemplateId)
2395
+ return TPResult::Ambiguous;
2396
+ ConsumeToken ();
2397
+ ++TemplateDepth;
2398
+ }
2394
2399
break ;
2395
- #endif
2396
2400
2397
2401
case tok::kw_operator:
2398
2402
if (TPResult TPR = TryParseNonConversionOperatorId ();
2399
2403
TPR == TPResult::Error) {
2400
2404
return TPResult::Error;
2401
2405
} else if (TPR == TPResult::True) {
2402
- if (Tok.is (tok::less))
2403
- return TPResult::Ambiguous;
2404
- }
2405
- break ;
2406
-
2407
- #if 0
2408
2406
if (Tok.is (tok::less)) {
2409
2407
if (!NextIsTemplateId)
2410
2408
return TPResult::Ambiguous;
2411
2409
ConsumeToken ();
2412
- if (!SkipUntil({tok::greater, tok::greatergreater, tok::greatergreatergreater}, StopAtSemi))
2413
- return TPResult::Error;
2410
+ ++TemplateDepth;
2414
2411
}
2415
- break;
2416
- # endif
2412
+ }
2413
+ break ;
2417
2414
2418
2415
case tok::kw_const_cast:
2419
2416
case tok::kw_dynamic_cast:
@@ -2454,6 +2451,9 @@ Parser::TPResult Parser::isTemplateArgumentList(unsigned TokensToSkip,
2454
2451
}
2455
2452
};
2456
2453
2454
+ bool IsNestedTemplateArgumentList = !GreaterThanIsOperator;
2455
+ GreaterThanIsOperatorScope G (GreaterThanIsOperator, false );
2456
+
2457
2457
while (true ) {
2458
2458
// An expression cannot be followed by a braced-init-list unless
2459
2459
// its the right operand of an assignment operator.
0 commit comments