@@ -414,7 +414,7 @@ private List<TopLevelItem> parseTopLevelItem(List<CppLexerToken> leadingComments
414414 // This is handled in parseTemplateParamName already.
415415 }
416416
417- if (checkKeyword ("class" ) || checkKeyword ("struct" )) {
417+ if (checkKeyword ("class" ) || checkKeyword ("struct" ) || checkKeyword ( "union" ) ) {
418418 // Partial specialization: "template<typename T> struct Foo<T*> { ... }"
419419 // After parsing the class/struct, check for a specialization arg list.
420420 // BUT: "struct TypeName funcName(...)" is a function with elaborated return type
@@ -777,7 +777,7 @@ private String parseTemplateParamName() {
777777 */
778778 private List <TopLevelItem > parseTypeDef (List <CppLexerToken > leadingComments , List <String > templateParams ) {
779779 CppLexerToken start = peek ();
780- String kind = checkKeyword ("class" ) ? "class" : "struct" ;
780+ String kind = checkKeyword ("class" ) ? "class" : checkKeyword ( "union" ) ? "union" : "struct" ;
781781 advance ();
782782 // alignas specifier: "struct alignas(64) CacheLine"
783783 if (checkKeyword ("alignas" ) && pos + 1 < tokens .size () && tokens .get (pos + 1 ).isPunct ("(" )) {
@@ -982,7 +982,7 @@ private List<TopLevelItem> parseClassMember(List<CppLexerToken> leadingComments,
982982 consumeLeadingComments ();
983983 }
984984 }
985- if (checkKeyword ("class" ) || checkKeyword ("struct" )) {
985+ if (checkKeyword ("class" ) || checkKeyword ("struct" ) || checkKeyword ( "union" ) ) {
986986 // Anonymous struct: "struct { float x, y; } position;"
987987 if (pos + 1 < tokens .size () && tokens .get (pos + 1 ).isPunct ("{" )) {
988988 int anonStart = pos ;
0 commit comments