Skip to content

Commit 83c69c6

Browse files
committed
fixup! C++ front-end: parse template parameter packs
1 parent e509402 commit 83c69c6

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

src/cpp/parse.cpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ bool Parser::rTempArgList(irept &args)
12151215
: CLASS [Identifier] {'=' type.name}
12161216
| CLASS Ellipsis [Identifier]
12171217
| type.specifier arg.declarator {'=' conditional.expr}
1218-
| template.decl2 CLASS Identifier {'=' type.name}
1218+
| template.decl2 CLASS {Identifier {'=' type.name}}
12191219
*/
12201220
bool Parser::rTempArgDeclaration(cpp_declarationt &declaration)
12211221
{
@@ -1340,9 +1340,14 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration)
13401340

13411341
cpp_tokent tk1, tk2;
13421342

1343-
if(lex.get_token(tk1) != TOK_CLASS || !is_identifier(lex.get_token(tk2)))
1343+
if(lex.get_token(tk1) != TOK_CLASS)
13441344
return false;
13451345

1346+
if(lex.LookAhead(0) == ',')
1347+
return true;
1348+
1349+
if(!is_identifier(lex.get_token(tk2)))
1350+
return false;
13461351
// Ptree cspec=new PtreeClassSpec(new LeafReserved(tk1),
13471352
// Ptree::Cons(new Leaf(tk2),nil),
13481353
// nil);
@@ -3144,6 +3149,13 @@ bool Parser::rDeclarator(
31443149
if(!rDeclaratorQualifier())
31453150
return false;
31463151

3152+
if(lex.LookAhead(0)==TOK_ELLIPSIS)
3153+
{
3154+
cpp_tokent tk;
3155+
lex.get_token(tk);
3156+
d_outer.set(ID_ellipsis, true);
3157+
}
3158+
31473159
#ifdef DEBUG
31483160
std::cout << std::string(__indent, ' ') << "Parser::rDeclarator2 2\n";
31493161
#endif
@@ -4095,6 +4107,12 @@ bool Parser::rTemplateArgs(irept &template_args)
40954107

40964108
if(!rConditionalExpr(exp, true))
40974109
return false;
4110+
4111+
if(lex.LookAhead(0)==TOK_ELLIPSIS)
4112+
{
4113+
lex.get_token(tk1);
4114+
exp.set(ID_ellipsis, true);
4115+
}
40984116
}
40994117

41004118
#ifdef DEBUG
@@ -4208,14 +4226,15 @@ bool Parser::rArgDeclList(irept &arglist)
42084226

42094227
list.get_sub().push_back(irept(irep_idt()));
42104228
list.get_sub().back().swap(declaration);
4211-
t=lex.LookAhead(0);
4212-
if(t==',')
4213-
lex.get_token(tk);
4214-
else if(t==TOK_ELLIPSIS)
4229+
if(lex.LookAhead(0)==TOK_ELLIPSIS)
42154230
{
42164231
lex.get_token(tk);
42174232
list.get_sub().push_back(irept(ID_ellipsis));
42184233
}
4234+
4235+
t=lex.LookAhead(0);
4236+
if(t==',')
4237+
lex.get_token(tk);
42194238
else if(t!=')' && t!=TOK_ELLIPSIS)
42204239
return false;
42214240
}

0 commit comments

Comments
 (0)