[PATCH] D81009: Reinstate the syntax tree test for 'static' in an array subscript

Dmitri Gribenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 2 07:41:44 PDT 2020


gribozavr created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
gribozavr2 added a reviewer: eduucaldas.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81009

Files:
  clang/unittests/Tooling/Syntax/TreeTest.cpp


Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===================================================================
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -51,6 +51,8 @@
   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 @@
 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 @@
   `-;       )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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81009.267884.patch
Type: text/x-patch
Size: 1442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200602/bc1fc964/attachment-0001.bin>


More information about the cfe-commits mailing list