From 60db5a894bebf7025b05aceb9c472dc68d58a385 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 20 Feb 2023 17:52:42 +0800 Subject: [PATCH] - Enhancement: Support C11 ano --- NEWS.md | 1 + RedPandaIDE/parser/cppparser.cpp | 38 ++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/NEWS.md b/NEWS.md index 05a8ca42..7aa4128f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ Red Panda C++ Version 2.13 - fix: Only C/C++/GAS files can set breakpoints. - Enhancement: Don't show breakpoints/watch related menuitems in context menu for non-C/C++/GAS files. - Enhancement: Disable reformat code for non-C/C++ files. + - Enhancement: Support C11 ano Red Panda C++ Version 2.12 diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 06edb7c2..3a8c42ae 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -3398,20 +3398,30 @@ void CppParser::handleStructs(bool isTypedef) } } if (!firstSynonym) { - //anonymous union/struct/class, add as a block - firstSynonym=addStatement( - getCurrentScope(), - mCurrentFile, - "", - "", - "", - "", - "", - mTokenizer[mIndex]->line, - StatementKind::skBlock, - getScope(), - mClassScope, - StatementProperty::spHasDefinition); + PStatement scope = getCurrentScope(); + if (scope && scope->kind == StatementKind::skClass + && mIndextext=="{") { + //C11 anonymous union/struct + addSoloScopeLevel(scope, mTokenizer[mIndex]->line); + //skip { + mIndex++; + return; + } else { + //anonymous union/struct/class, add as a block + firstSynonym=addStatement( + getCurrentScope(), + mCurrentFile, + "", + "", + "", + "", + "", + mTokenizer[mIndex]->line, + StatementKind::skBlock, + getScope(), + mClassScope, + StatementProperty::spHasDefinition); + } } if (mIndex < mTokenizer.tokenCount()) addSoloScopeLevel(firstSynonym,mTokenizer[mIndex]->line);