- fix: parse error for definition of functions whose return type is pointer

This commit is contained in:
Roy Qu 2022-04-18 16:56:31 +08:00
parent 5743991152
commit 56c71f321f
3 changed files with 26 additions and 19 deletions

View File

@ -15,6 +15,7 @@ Red Panda C++ Version 1.0.4
- enhancement: add Traditional Chinese translation
- fix: index of the longest line not correctly updated ( which will cause selection errors)
- fix: scroll bar not correctly updated when collapse/uncollapse folders
- fix: parse error for definition of functions whose return type is pointer
Red Panda C++ Version 1.0.3
- fix: when oj problem grabbed by competitive companion received,

View File

@ -1158,11 +1158,13 @@ PStatement CppParser::addStatement(const PStatement& parent,
if (kind == StatementKind::skConstructor
|| kind == StatementKind::skFunction
|| kind == StatementKind::skDestructor
|| kind == StatementKind::skVariable) {
|| kind == StatementKind::skVariable
) {
noNameArgs = removeArgNames(args);
//find
PStatement oldStatement = findStatementInScope(command,noNameArgs,kind,parent);
if (oldStatement && isDefinition && !oldStatement->hasDefinition) {
if (isDefinition) {
PStatement oldStatement = findStatementInScope(newCommand,noNameArgs,kind,parent);
if (oldStatement && !oldStatement->hasDefinition) {
oldStatement->hasDefinition = true;
if (oldStatement->fileName!=fileName) {
PFileIncludes fileIncludes1=mPreprocessor.includesList().value(fileName);
@ -1181,6 +1183,7 @@ PStatement CppParser::addStatement(const PStatement& parent,
return oldStatement;
}
}
}
PStatement result = std::make_shared<Statement>();
result->parentScope = parent;
result->type = newType;
@ -3246,8 +3249,8 @@ void CppParser::internalParse(const QString &fileName)
//reduce memory usage
internalClear();
#ifdef QT_DEBUG
// mTokenizer.dumpTokens("r:\\tokens.txt");
// mStatementList.dump("r:\\stats.txt");
// mTokenizer.dumpTokens("z:\\tokens.txt");
//
// mStatementList.dumpAll("r:\\all-stats.txt");
#endif
//reduce memory usage

View File

@ -138,12 +138,15 @@ void StatementModel::dumpStatementMap(StatementMap &map, QTextStream &out, int l
out<<indent<<QString("%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12")
.arg(statement->command).arg(int(statement->kind))
.arg(statement->type,statement->fullName)
.arg(statement->noNameArgs)
.arg(statement->args)
.arg((size_t)(statement->parentScope.lock().get()))
.arg((int)statement->classScope)
.arg(statement->fileName)
.arg(statement->line)
.arg(statement->definitionFileName)
.arg(statement->definitionLine);
out<<endl;
if (statement->children.isEmpty())
continue;
out<<indent<<statement->command<<" {"<<endl;