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