- fix: Can't parse virtual inherit.

This commit is contained in:
Roy Qu 2023-08-08 10:40:59 +08:00
parent 30426ac58f
commit f111433ac5
2 changed files with 14 additions and 10 deletions

View File

@ -15,7 +15,8 @@ Red Panda C++ Version 2.24
- enhancement: Support optional enum type. - enhancement: Support optional enum type.
- enhancement: Support simple const expression evaluation for enum values. - enhancement: Support simple const expression evaluation for enum values.
- fix: Accessibilty for inherited members are not correct calculated in multiple inheritance. - fix: Accessibilty for inherited members are not correct calculated in multiple inheritance.
- fix: Can't handle full class name when handle inheritance. - fix: Can't parse full class name when handle inheritance.
- fix: Can't parse virtual inherit.
Red Panda C++ Version 2.23 Red Panda C++ Version 2.23

View File

@ -1520,16 +1520,19 @@ void CppParser::setInheritance(int index, const PStatement& classStatement, bool
StatementAccessibility lastInheritScopeType = StatementAccessibility::None; StatementAccessibility lastInheritScopeType = StatementAccessibility::None;
// Assemble a list of statements in text form we inherit from // Assemble a list of statements in text form we inherit from
while (true) { while (true) {
StatementAccessibility inheritScopeType = getClassMemberAccessibility(mTokenizer[index]->text);
QString currentText = mTokenizer[index]->text; QString currentText = mTokenizer[index]->text;
if (currentText=='(') { if (currentText=='(') {
//skip to matching ')' //skip to matching ')'
index=mTokenizer[index]->matchIndex; index=mTokenizer[index]->matchIndex;
} else if (inheritScopeType == StatementAccessibility::None) { } else if (currentText=="::"
if (currentText=="::" || (isIdentChar(currentText[0]))) {
|| isIdentChar(currentText[0])) { KeywordType keywordType = mCppKeywords.value(currentText, KeywordType::None);
if (keywordType!=KeywordType::None) {
StatementAccessibility inheritScopeType = getClassMemberAccessibility(mTokenizer[index]->text);
if (inheritScopeType != StatementAccessibility::None) {
lastInheritScopeType = inheritScopeType;
}
} else {
QString basename = currentText; QString basename = currentText;
bool isGlobal = false; bool isGlobal = false;
index++; index++;
@ -1565,13 +1568,13 @@ void CppParser::setInheritance(int index, const PStatement& classStatement, bool
// Find the corresponding PStatement // Find the corresponding PStatement
PStatement statement = doFindStatementOf(mCurrentFile,basename, PStatement statement = doFindStatementOf(mCurrentFile,basename,
isGlobal?PStatement():classStatement->parentScope.lock()); isGlobal?PStatement():classStatement->parentScope.lock());
if (statement && statement->kind == StatementKind::skClass) { if (statement && statement->kind == StatementKind::skClass) {
inheritClassStatement(classStatement,isStruct,statement,lastInheritScopeType); inheritClassStatement(classStatement,isStruct,statement,lastInheritScopeType);
} }
} }
} else {
lastInheritScopeType = inheritScopeType;
} }
index++; index++;
if (index >= tokenCount) if (index >= tokenCount)
break; break;
@ -1924,6 +1927,7 @@ bool CppParser::checkForKeyword(KeywordType& keywordType)
case KeywordType::For: case KeywordType::For:
case KeywordType::Public: case KeywordType::Public:
case KeywordType::Private: case KeywordType::Private:
case KeywordType::Protected:
case KeywordType::Struct: case KeywordType::Struct:
case KeywordType::Enum: case KeywordType::Enum:
case KeywordType::Inline: case KeywordType::Inline:
@ -1931,7 +1935,6 @@ bool CppParser::checkForKeyword(KeywordType& keywordType)
case KeywordType::Typedef: case KeywordType::Typedef:
case KeywordType::Using: case KeywordType::Using:
case KeywordType::Friend: case KeywordType::Friend:
case KeywordType::Protected:
case KeywordType::None: case KeywordType::None:
case KeywordType::NotKeyword: case KeywordType::NotKeyword:
case KeywordType::DeclType: case KeywordType::DeclType: