summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2019-03-12 13:55:51 +0100
committerIvan Donchevskii <ivan.donchevskii@qt.io>2019-03-12 14:19:48 +0000
commit1b0cba38dd6d5e72104354bb77ce4ba8f1f9d681 (patch)
treed42275c80118e621854e1cf43273eddb12878761 /tests/unit
parenta78bbe48cccf87877ef988cc145e58e64543573b (diff)
downloadqt-creator-1b0cba38dd6d5e72104354bb77ce4ba8f1f9d681.tar.gz
Clang: Fix access specifier for variables
Static members have a variable declaration kind so we need to check their access specifiers in order to provide proper information about tokens. Fixes: QTCREATORBUG-22082 Change-Id: If455174bd346398a2df3499fa6cf1ea2b4e26965 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/unittest/data/highlightingmarks.cpp9
-rw-r--r--tests/unit/unittest/tokenprocessor-test.cpp18
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/unit/unittest/data/highlightingmarks.cpp b/tests/unit/unittest/data/highlightingmarks.cpp
index e1a48903ca..a703e89a11 100644
--- a/tests/unit/unittest/data/highlightingmarks.cpp
+++ b/tests/unit/unittest/data/highlightingmarks.cpp
@@ -686,3 +686,12 @@ class NonConstParameterConstructor
NonConstParameterConstructor bar(foo);
}
};
+
+class StaticMembersAccess
+{
+protected:
+ static int protectedValue;
+
+private:
+ static int privateValue;
+};
diff --git a/tests/unit/unittest/tokenprocessor-test.cpp b/tests/unit/unittest/tokenprocessor-test.cpp
index 3383c9a3b9..8d79bc95cb 100644
--- a/tests/unit/unittest/tokenprocessor-test.cpp
+++ b/tests/unit/unittest/tokenprocessor-test.cpp
@@ -1704,6 +1704,24 @@ TEST_F(TokenProcessor, LambdaLocalVariableCapture)
ASSERT_THAT(infos[4], HasOnlyType(HighlightingType::LocalVariable));
}
+TEST_F(TokenProcessor, StaticProtectedMember)
+{
+ const auto infos = translationUnit.fullTokenInfosInRange(sourceRange(693, 31));
+
+ ClangBackEnd::TokenInfoContainer container(infos[2]);
+
+ ASSERT_THAT(container.extraInfo.accessSpecifier, ClangBackEnd::AccessSpecifier::Protected);
+}
+
+TEST_F(TokenProcessor, StaticPrivateMember)
+{
+ const auto infos = translationUnit.fullTokenInfosInRange(sourceRange(696, 29));
+
+ ClangBackEnd::TokenInfoContainer container(infos[2]);
+
+ ASSERT_THAT(container.extraInfo.accessSpecifier, ClangBackEnd::AccessSpecifier::Private);
+}
+
Data *TokenProcessor::d;
void TokenProcessor::SetUpTestCase()