ctags/0010-Parse-C-11-classed-enums.patch

49 lines
2.2 KiB
Diff
Raw Normal View History

From 688ba978ea2394eb7144c964811e2c531e5c9c19 Mon Sep 17 00:00:00 2001
From: Ivan Grokhotkov <igrokhotkov@gmail.com>
Date: Thu, 4 Feb 2016 19:40:15 +0300
Subject: [PATCH 10/19] Parse C++11 classed enums
Manual cherry-pick of https://github.com/geany/geany/commit/6c7f69578d8e142f5994cc9cf0e0abc83a606a1b
---
c.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/c.c b/c.c
index ff7aa24..40db0e5 100644
--- a/c.c
+++ b/c.c
@@ -1725,6 +1725,12 @@ static void processInterface (statementInfo *const st)
st->declaration = DECL_INTERFACE;
}
+static void checkIsClassEnum (statementInfo *const st, const declType decl)
+{
+ if (! isLanguage (Lang_cpp) || st->declaration != DECL_ENUM)
+ st->declaration = decl;
+}
+
static void processToken (tokenInfo *const token, statementInfo *const st)
{
switch (token->keyword) /* is it a reserved word? */
@@ -1740,7 +1746,7 @@ static void processToken (tokenInfo *const token, statementInfo *const st)
case KEYWORD_BIT: st->declaration = DECL_BASE; break;
case KEYWORD_CATCH: skipParens (); skipBraces (); break;
case KEYWORD_CHAR: st->declaration = DECL_BASE; break;
- case KEYWORD_CLASS: st->declaration = DECL_CLASS; break;
+ case KEYWORD_CLASS: checkIsClassEnum (st, DECL_CLASS); break;
case KEYWORD_CONST: st->declaration = DECL_BASE; break;
case KEYWORD_DOUBLE: st->declaration = DECL_BASE; break;
case KEYWORD_ENUM: st->declaration = DECL_ENUM; break;
@@ -1768,7 +1774,7 @@ static void processToken (tokenInfo *const token, statementInfo *const st)
case KEYWORD_SIGNED: st->declaration = DECL_BASE; break;
case KEYWORD_STATIC_ASSERT: skipParens(); break;
case KEYWORD_STRING: st->declaration = DECL_BASE; break;
- case KEYWORD_STRUCT: st->declaration = DECL_STRUCT; break;
+ case KEYWORD_STRUCT: checkIsClassEnum (st, DECL_STRUCT); break;
case KEYWORD_TASK: st->declaration = DECL_TASK; break;
case KEYWORD_THROWS: discardTypeList (token); break;
case KEYWORD_UNION: st->declaration = DECL_UNION; break;
--
2.11.0