57 lines
1.9 KiB
Diff
57 lines
1.9 KiB
Diff
From ce27db2946ae2ebc2766138af451d7d981201134 Mon Sep 17 00:00:00 2001
|
|
From: Ivan Grokhotkov <igrokhotkov@gmail.com>
|
|
Date: Wed, 20 Jan 2016 12:25:18 +0300
|
|
Subject: [PATCH 08/19] c++: Properly parse C++11 override and final members
|
|
|
|
Manual cherry-pick of
|
|
- https://github.com/geany/geany/commit/95a0d4db7e2188a62cf7770496ee2a51591f1962
|
|
- https://github.com/geany/geany/commit/641863c2647c21abb36aedc40ac93e6cc478f920
|
|
---
|
|
c.c | 22 ++++++++++++++++++++--
|
|
1 file changed, 20 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/c.c b/c.c
|
|
index 0dd84d7..6e8b5aa 100644
|
|
--- a/c.c
|
|
+++ b/c.c
|
|
@@ -1986,7 +1986,13 @@ static boolean skipPostArgumentStuff (
|
|
break;
|
|
|
|
default:
|
|
- if (isType (token, TOKEN_NONE))
|
|
+ /* "override" and "final" are only keywords in the declaration of a virtual
|
|
+ * member function, so need to be handled specially, not as keywords */
|
|
+ if (isLanguage(Lang_cpp) && isType (token, TOKEN_NAME) &&
|
|
+ (strcmp ("override", vStringValue (token->name)) == 0 ||
|
|
+ strcmp ("final", vStringValue (token->name)) == 0))
|
|
+ ;
|
|
+ else if (isType (token, TOKEN_NONE))
|
|
;
|
|
else if (info->isKnrParamList && info->parameterCount > 0)
|
|
++elementCount;
|
|
@@ -2839,8 +2845,20 @@ static void tagCheck (statementInfo *const st)
|
|
st->declaration == DECL_NAMESPACE ||
|
|
st->declaration == DECL_PROGRAM)
|
|
{
|
|
- if (isType (prev, TOKEN_NAME))
|
|
+ tokenInfo *name_token = (tokenInfo *)prev;
|
|
+
|
|
+ /* C++ 11 allows class <name> final { ... } */
|
|
+ if (isLanguage (Lang_cpp) && isType (prev, TOKEN_NAME) &&
|
|
+ strcmp("final", vStringValue(prev->name)) == 0 &&
|
|
+ isType(prev2, TOKEN_NAME))
|
|
+ {
|
|
+ name_token = (tokenInfo *)prev2;
|
|
+ copyToken (st->blockName, name_token);
|
|
+ }
|
|
+ else if (isType (name_token, TOKEN_NAME))
|
|
+ {
|
|
copyToken (st->blockName, prev);
|
|
+ }
|
|
else
|
|
{
|
|
/* For an anonymous struct or union we use a unique ID
|
|
--
|
|
2.11.0
|
|
|