- fix: "typedef struct" that don't have definition of the struct is not correctly parsed.

This commit is contained in:
Roy Qu 2023-06-29 21:31:30 +08:00
parent dce377d6d2
commit d71cd7e7dc
2 changed files with 11 additions and 2 deletions

View File

@ -15,6 +15,7 @@ Red Panda C++ Version 2.23
- enhancement: Support debug executable files generated by mingw-w64 gcc 13.1 and filepath contains non-ascii chars. - enhancement: Support debug executable files generated by mingw-w64 gcc 13.1 and filepath contains non-ascii chars.
- enhancement: When deleteing files in the files/project view, try moving to the trash bin instead. - enhancement: When deleteing files in the files/project view, try moving to the trash bin instead.
- fix: GNU assembly files (.s) are not shown in the files view. - fix: GNU assembly files (.s) are not shown in the files view.
- fix: "typedef struct" that don't have definition of the struct is not correctly parsed.
Red Panda C++ Version 2.22 Red Panda C++ Version 2.22

View File

@ -3368,16 +3368,21 @@ void CppParser::handleStructs(bool isTypedef)
// typdef struct Foo Bar // typdef struct Foo Bar
if (isTypedef) { if (isTypedef) {
QString oldType = mTokenizer[mIndex]->text; QString oldType = mTokenizer[mIndex]->text;
QString tempType = "";
bool isFirstLoop=true;
while(true) { while(true) {
// Add definition statement for the synonym // Add definition statement for the synonym
if ((mIndex + 1 < tokenCount) if ((mIndex + 1 < tokenCount)
&& (mTokenizer[mIndex + 1]->text=="," && (mTokenizer[mIndex + 1]->text==","
|| mTokenizer[mIndex + 1]->text==";")) { || mTokenizer[mIndex + 1]->text==";")) {
QString newType = mTokenizer[mIndex]->text; QString newType = mTokenizer[mIndex]->text;
QString type=oldType;
if (!tempType.isEmpty())
type+=tempType;
addStatement( addStatement(
getCurrentScope(), getCurrentScope(),
mCurrentFile, mCurrentFile,
oldType, type,
newType, newType,
"", // args "", // args
"", // noname args "", // noname args
@ -3387,7 +3392,10 @@ void CppParser::handleStructs(bool isTypedef)
getScope(), getScope(),
mCurrentMemberAccessibility, mCurrentMemberAccessibility,
StatementProperty::spHasDefinition); StatementProperty::spHasDefinition);
} tempType="";
} else if (!isFirstLoop)
tempType+= mTokenizer[mIndex]->text;
isFirstLoop=false;
mIndex++; mIndex++;
if (mIndex >= tokenCount) if (mIndex >= tokenCount)
break; break;