@@ -863,21 +863,23 @@ else if (checkOp(">>")) {
863863 matchPunct (";" );
864864
865865 TypeDef typeDef = new TypeDef (kind , name , templateParams , baseClasses , members , start .line (), start .col (), leadingComments );
866- // Trailing declarator : "class Foo { ... } *ptr;" or "} instance ;"
866+ // Trailing declarators : "class Foo { ... } *ptr;" or "} a, b, *c ;"
867867 if (!matchPunct (";" ) && !isAtEnd () && !checkPunct ("}" )) {
868- int ptrDepth = 0 ;
869- while (matchOp ("*" ) || matchPunct ("*" )) ptrDepth ++;
870- if (peek ().type () == CppLexerTokenType .IDENTIFIER ) {
868+ List <TopLevelItem > result = new ArrayList <>();
869+ result .add (typeDef );
870+ do {
871+ int ptrDepth = 0 ;
872+ while (matchOp ("*" ) || matchPunct ("*" )) ptrDepth ++;
873+ if (peek ().type () != CppLexerTokenType .IDENTIFIER ) break ;
871874 CppLexerToken varTok = advance ();
872875 Expr init = null ;
873876 if (matchPunct ("=" )) init = parseExpr ();
874- expectPunct (";" );
875877 TypeRef varType = new NamedType (name , List .of (), ptrDepth , false , false , false );
876- VariableDecl varDecl = new VariableDecl (varType , varTok .text (), List .of (), init ,
877- false , false , varTok .line (), varTok .col (), List .of ());
878- return List . of ( typeDef , varDecl );
879- }
880- matchPunct ( ";" ) ;
878+ result . add ( new VariableDecl (varType , varTok .text (), List .of (), init ,
879+ false , false , varTok .line (), varTok .col (), List .of ())) ;
880+ } while ( matchPunct ( "," ) );
881+ expectPunct ( ";" );
882+ return result ;
881883 }
882884 return List .of (typeDef );
883885 }
0 commit comments