@@ -225,6 +225,7 @@ static const char *stateToString(int state);
225
225
static inline int computeIndent (const char *s,int startIndent);
226
226
static inline void initMethodProtection (yyscan_t yyscanner,Protection prot);
227
227
static QCString stripQuotes (const char *s);
228
+ static QCString stripFuncPtr (const QCString &type);
228
229
static bool nameIsOperator (QCString &name);
229
230
void fixArgumentListForJavaScript (ArgumentList &al);
230
231
static bool startOfRequiresExpression (const QCString &req);
@@ -3660,9 +3661,7 @@ NONLopt [^\n]*
3660
3661
yyextra->current->doc.resize(0);
3661
3662
yyextra->current->initializer.str(std::string());
3662
3663
yyextra->current->bitfields.resize(0);
3663
- int i=oldType.length();
3664
- while (i>0 && (oldType[i-1]==' *' || oldType[i-1]==' &' || oldType[i-1]==' ' )) i--;
3665
- yyextra->current->type = oldType.left(i);
3664
+ yyextra->current->type = stripFuncPtr(oldType);
3666
3665
}
3667
3666
else
3668
3667
{
@@ -4547,7 +4546,10 @@ NONLopt [^\n]*
4547
4546
}
4548
4547
<EndFuncPtr>")"{BNopt}/"(" { // a function pointer
4549
4548
lineCount(yyscanner);
4550
- yyextra->current->type+=yyextra->funcPtrType+")";
4549
+ if (yyextra->funcPtrType!="(") // not just redundant braces
4550
+ {
4551
+ yyextra->current->type+=yyextra->funcPtrType+")";
4552
+ }
4551
4553
BEGIN(FindMembers);
4552
4554
}
4553
4555
<EndFuncPtr>")"{BNopt}/"[" { // an array of variables
@@ -5445,11 +5447,7 @@ NONLopt [^\n]*
5445
5447
yyextra->lastCurlyContext = FindMembers;
5446
5448
if ( *yytext == ',' )
5447
5449
{
5448
- yyextra->current->type = yyextra->previous->type;
5449
- // we need to strip any trailing * and & (see bugs 623023 and 649103 for test cases)
5450
- int i=yyextra->current->type.length();
5451
- while (i>0 && (yyextra->current->type[i-1]=='*' || yyextra->current->type[i-1]=='&' || yyextra->current->type[i-1]==' ')) i--;
5452
- yyextra->current->type = yyextra->current->type.left(i);
5450
+ yyextra->current->type = stripFuncPtr(yyextra->previous->type);
5453
5451
}
5454
5452
if ( *yytext == '{' )
5455
5453
{
@@ -7441,6 +7439,18 @@ static QCString stripQuotes(const char *s)
7441
7439
return name;
7442
7440
}
7443
7441
7442
+ static QCString stripFuncPtr(const QCString &type)
7443
+ {
7444
+ // we need to strip any trailing * and & (see bugs 623023 and 649103 for test cases)
7445
+ // also needed to reset the type for 'arr' to 'int' in 'typedef int (&fp)(), arr[2]'
7446
+ int i=type.length();
7447
+ bool funcPtr = i>0 && type[i-1]==')';
7448
+ if (funcPtr) i--;
7449
+ while (i>0 && (type[i-1]=='*' || type[i-1]=='&' || type[i-1]==' ')) i--;
7450
+ if (funcPtr && i>0 && type[i-1]=='(') i--;
7451
+ return type.left(i);
7452
+ }
7453
+
7444
7454
//-----------------------------------------------------------------
7445
7455
7446
7456
// return TRUE iff req holds the start of a requires expression
0 commit comments