Skip to content

Commit ce27db2

Browse files
committed
c++: Properly parse C++11 override and final members
Manual cherry-pick of - geany/geany@95a0d4d - geany/geany@641863c
1 parent 3a84337 commit ce27db2

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

c.c

+20-2
Original file line numberDiff line numberDiff line change
@@ -1986,7 +1986,13 @@ static boolean skipPostArgumentStuff (
19861986
break;
19871987

19881988
default:
1989-
if (isType (token, TOKEN_NONE))
1989+
/* "override" and "final" are only keywords in the declaration of a virtual
1990+
* member function, so need to be handled specially, not as keywords */
1991+
if (isLanguage(Lang_cpp) && isType (token, TOKEN_NAME) &&
1992+
(strcmp ("override", vStringValue (token->name)) == 0 ||
1993+
strcmp ("final", vStringValue (token->name)) == 0))
1994+
;
1995+
else if (isType (token, TOKEN_NONE))
19901996
;
19911997
else if (info->isKnrParamList && info->parameterCount > 0)
19921998
++elementCount;
@@ -2839,8 +2845,20 @@ static void tagCheck (statementInfo *const st)
28392845
st->declaration == DECL_NAMESPACE ||
28402846
st->declaration == DECL_PROGRAM)
28412847
{
2842-
if (isType (prev, TOKEN_NAME))
2848+
tokenInfo *name_token = (tokenInfo *)prev;
2849+
2850+
/* C++ 11 allows class <name> final { ... } */
2851+
if (isLanguage (Lang_cpp) && isType (prev, TOKEN_NAME) &&
2852+
strcmp("final", vStringValue(prev->name)) == 0 &&
2853+
isType(prev2, TOKEN_NAME))
2854+
{
2855+
name_token = (tokenInfo *)prev2;
2856+
copyToken (st->blockName, name_token);
2857+
}
2858+
else if (isType (name_token, TOKEN_NAME))
2859+
{
28432860
copyToken (st->blockName, prev);
2861+
}
28442862
else
28452863
{
28462864
/* For an anonymous struct or union we use a unique ID

0 commit comments

Comments
 (0)