Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Tue, 30 Jun 2015 21:22:08 UTC Commit: 641863c2647c21abb36aedc40ac93e6cc478f920 https://github.com/geany/geany/commit/641863c2647c21abb36aedc40ac93e6cc478f9...
Log Message: ----------- c++: Fix handling of the `final` contextual keyword
`final` is not a normal keyword, as it only have a special meaning in some specific context. So, use a special case instead of a keyword not to break identifiers of that name.
Modified Paths: -------------- tagmanager/ctags/c.c tests/ctags/Makefile.am tests/ctags/cxx11-final.cpp tests/ctags/cxx11-final.cpp.tags
Modified: tagmanager/ctags/c.c 19 lines changed, 10 insertions(+), 9 deletions(-) =================================================================== @@ -425,7 +425,7 @@ static const keywordDesc KeywordTable [] = { { "extends", KEYWORD_EXTENDS, { 0, 0, 0, 1, 1, 0, 0 } }, { "extern", KEYWORD_EXTERN, { 1, 1, 1, 0, 1, 1, 0 } }, { "extern", KEYWORD_NAMESPACE, { 0, 0, 0, 0, 0, 0, 1 } }, /* parse block */ - { "final", KEYWORD_FINAL, { 0, 1, 0, 1, 0, 0, 1 } }, + { "final", KEYWORD_FINAL, { 0, 0, 0, 1, 0, 0, 1 } }, { "finally", KEYWORD_FINALLY, { 0, 0, 0, 0, 0, 1, 1 } }, { "float", KEYWORD_FLOAT, { 1, 1, 1, 1, 0, 1, 1 } }, { "for", KEYWORD_FOR, { 1, 1, 1, 1, 0, 1, 1 } }, @@ -2969,7 +2969,15 @@ static void tagCheck (statementInfo *const st) tokenInfo *name_token = (tokenInfo *)prev; boolean free_name_token = FALSE;
- if (isType (name_token, TOKEN_NAME)) + /* 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)) { if (!isLanguage (Lang_vala)) copyToken (st->blockName, name_token); @@ -2994,13 +3002,6 @@ static void tagCheck (statementInfo *const st) } } } - /* C++ 11 allows class <name> final { ... } */ - else if (isLanguage (Lang_cpp) && isType (prev, TOKEN_KEYWORD) && - prev->keyword == KEYWORD_FINAL && isType(prev2, TOKEN_NAME)) - { - name_token = (tokenInfo *)prev2; - copyToken (st->blockName, name_token); - } else if (isLanguage (Lang_csharp)) makeTag (prev, st, FALSE, TAG_PROPERTY); else
Modified: tests/ctags/Makefile.am 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -132,6 +132,7 @@ test_sources = \ cython_sample.pyx \ cython_sample2.pyx \ cxx11enum.cpp \ + cxx11-final.cpp \ db-trig.sql \ debian_432872.f90 \ directives.c \
Modified: tests/ctags/cxx11-final.cpp 23 lines changed, 23 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,23 @@ +class Base +{ +public: + virtual void foo() = 0; +}; + +class Derived final : public Base +{ + virtual void foo(); + virtual void final(); +}; + +void Base::foo() +{ +} + +void Derived::foo() +{ +} + +void Derived::final() +{ +}
Modified: tests/ctags/cxx11-final.cpp.tags 9 lines changed, 9 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,9 @@ +# format=tagmanager +Base�1�0 +Derived�1�0 +final�16�()�Derived�0�void +final�1024�()�Derived�0�virtual void +foo�16�()�Base�0�void +foo�16�()�Derived�0�void +foo�1024�()�Base�0�virtual void +foo�1024�()�Derived�0�virtual void
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).