@@ -945,15 +945,20 @@ private FunctionDecl parseFunctionOrConstructorOrDestructor(List<CppLexerToken>
945945 private FunctionDecl .ConstructorInit parseConstructorInitEntry () {
946946 // Base class names can be qualified: "std::runtime_error(msg)"
947947 String memberName = parseQualifiedTypeName ();
948- expectPunct ("(" );
949948 List <Expr > args = new ArrayList <>();
950- if (!checkPunct (")" )) {
951- args .add (parseExpr ());
952- while (matchPunct ("," )) {
949+ if (checkPunct ("{" )) {
950+ // Brace initialization: "m{{1,0},{0,1}}"
951+ args .add (parseInitializerList ());
952+ } else {
953+ expectPunct ("(" );
954+ if (!checkPunct (")" )) {
953955 args .add (parseExpr ());
956+ while (matchPunct ("," )) {
957+ args .add (parseExpr ());
958+ }
954959 }
960+ expectPunct (")" );
955961 }
956- expectPunct (")" );
957962 return new FunctionDecl .ConstructorInit (memberName , args );
958963 }
959964
@@ -1099,7 +1104,6 @@ && looksLikeParamList()) {
10991104 }
11001105 // Constructor initializer list: ": mem(val), mem2(val2)"
11011106 if (matchPunct (":" ) && !checkPunct (":" )) {
1102- System .err .println ("[INITV] consuming init list, next=" + peek ().text ());
11031107 // consume initializer list entries until { or ;
11041108 int _d = 0 ;
11051109 while (!isAtEnd ()) {
@@ -1122,6 +1126,11 @@ && looksLikeParamList()) {
11221126 if (checkPunct (":" ) && pos + 1 < tokens .size () && tokens .get (pos + 1 ).type () == CppLexerTokenType .INT_LITERAL ) {
11231127 advance (); advance (); // consume ":" and bit width
11241128 }
1129+ // GCC __attribute__((...)): may appear after variable name
1130+ if (check (CppLexerTokenType .IDENTIFIER ) && peek ().text ().equals ("__attribute__" )) {
1131+ advance ();
1132+ if (checkPunct ("(" )) { advance (); int _ad =1 ; while (!isAtEnd ()&&_ad >0 ){if (checkPunct ("(" ))_ad ++;else if (checkPunct (")" ))_ad --;advance ();} }
1133+ }
11251134 List <TopLevelItem > result = new ArrayList <>();
11261135 result .add (parseOneTopLevelDeclarator (type , name , isConst , isStatic , templateParams , start , leadingComments ));
11271136 while (matchPunct ("," )) {
0 commit comments