From d71cd7e7dc76d38761f8d32cdefd06af8beda42d Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 29 Jun 2023 21:31:30 +0800 Subject: [PATCH] - fix: "typedef struct" that don't have definition of the struct is not correctly parsed. --- NEWS.md | 1 + RedPandaIDE/parser/cppparser.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 7cd13058..b2108880 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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: 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: "typedef struct" that don't have definition of the struct is not correctly parsed. Red Panda C++ Version 2.22 diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 9ac96af8..a6d70af5 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -3368,16 +3368,21 @@ void CppParser::handleStructs(bool isTypedef) // typdef struct Foo Bar if (isTypedef) { QString oldType = mTokenizer[mIndex]->text; + QString tempType = ""; + bool isFirstLoop=true; while(true) { // Add definition statement for the synonym if ((mIndex + 1 < tokenCount) && (mTokenizer[mIndex + 1]->text=="," || mTokenizer[mIndex + 1]->text==";")) { QString newType = mTokenizer[mIndex]->text; + QString type=oldType; + if (!tempType.isEmpty()) + type+=tempType; addStatement( getCurrentScope(), mCurrentFile, - oldType, + type, newType, "", // args "", // noname args @@ -3387,7 +3392,10 @@ void CppParser::handleStructs(bool isTypedef) getScope(), mCurrentMemberAccessibility, StatementProperty::spHasDefinition); - } + tempType=""; + } else if (!isFirstLoop) + tempType+= mTokenizer[mIndex]->text; + isFirstLoop=false; mIndex++; if (mIndex >= tokenCount) break;