diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2020-06-02 17:01:50 +0200 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2020-06-02 17:01:51 +0200 |
commit | 53c29a42d044b167f6b5f28e096c8d9e50d6edc7 (patch) | |
tree | f0a535e43541e065f7a0508f74e92527a8da1a4c /clang/unittests/Tooling/Syntax/TreeTest.cpp | |
parent | 89d9dba2c6885949887edf4b80e1aabf8d8f3f88 (diff) | |
download | llvm-53c29a42d044b167f6b5f28e096c8d9e50d6edc7.zip llvm-53c29a42d044b167f6b5f28e096c8d9e50d6edc7.tar.gz llvm-53c29a42d044b167f6b5f28e096c8d9e50d6edc7.tar.bz2 |
Reinstate the syntax tree test for 'static' in an array subscript
Reviewers: eduucaldas
Reviewed By: eduucaldas
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D81009
Diffstat (limited to 'clang/unittests/Tooling/Syntax/TreeTest.cpp')
-rw-r--r-- | clang/unittests/Tooling/Syntax/TreeTest.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp b/clang/unittests/Tooling/Syntax/TreeTest.cpp index bcfb2f7..a7de4b9 100644 --- a/clang/unittests/Tooling/Syntax/TreeTest.cpp +++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp @@ -51,6 +51,8 @@ struct TestClangConfig { TestLanguage Language; std::string Target; + bool isC99OrLater() const { return Language == Lang_C99; } + bool isCXX() const { return Language == Lang_CXX03 || Language == Lang_CXX11 || Language == Lang_CXX14 || Language == Lang_CXX17 || @@ -1903,7 +1905,6 @@ TEST_P(SyntaxTreeTest, ArraySubscriptsInDeclarators) { int a[10]; int b[1][2][3]; int c[] = {1,2,3}; -// void f(int xs[static 10]); )cpp", R"txt( *: TranslationUnit @@ -1960,6 +1961,36 @@ int c[] = {1,2,3}; `-; )txt"); } +TEST_P(SyntaxTreeTest, StaticArraySubscriptsInDeclarators) { + if (!GetParam().isC99OrLater()) { + return; + } + expectTreeDumpEqual( + R"cpp( +void f(int xs[static 10]); + )cpp", + R"txt( +*: TranslationUnit +`-SimpleDeclaration + |-void + |-SimpleDeclarator + | |-f + | `-ParametersAndQualifiers + | |-( + | |-SimpleDeclaration + | | |-int + | | `-SimpleDeclarator + | | |-xs + | | `-ArraySubscript + | | |-[ + | | |-static + | | |-UnknownExpression + | | | `-10 + | | `-] + | `-) + `-; )txt"); +} + TEST_P(SyntaxTreeTest, ParameterListsInDeclarators) { if (!GetParam().isCXX()) { // TODO: Split parts that depend on C++ into a separate test. |