[clang-tools-extra] 58b33bc - [pseudo] Fix noptr-abstract-declarator rule.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 7 01:22:45 PDT 2022
Author: Haojian Wu
Date: 2022-06-07T10:22:23+02:00
New Revision: 58b33bc8c48ab1640e93bbad5d2c5b80504f67b5
URL: https://github.com/llvm/llvm-project/commit/58b33bc8c48ab1640e93bbad5d2c5b80504f67b5
DIFF: https://github.com/llvm/llvm-project/commit/58b33bc8c48ab1640e93bbad5d2c5b80504f67b5.diff
LOG: [pseudo] Fix noptr-abstract-declarator rule.
The const-expression in the [] can be empty.
Differential Revision: https://reviews.llvm.org/D126992
Added:
clang-tools-extra/pseudo/test/cxx/unsized-array.cpp
Modified:
clang-tools-extra/pseudo/lib/cxx.bnf
Removed:
################################################################################
diff --git a/clang-tools-extra/pseudo/lib/cxx.bnf b/clang-tools-extra/pseudo/lib/cxx.bnf
index 60cf0a99d419e..16d639bc7770d 100644
--- a/clang-tools-extra/pseudo/lib/cxx.bnf
+++ b/clang-tools-extra/pseudo/lib/cxx.bnf
@@ -429,7 +429,7 @@ abstract-declarator := abstract-pack-declarator
ptr-abstract-declarator := noptr-abstract-declarator
ptr-abstract-declarator := ptr-operator ptr-abstract-declarator_opt
noptr-abstract-declarator := noptr-abstract-declarator_opt parameters-and-qualifiers
-noptr-abstract-declarator := noptr-abstract-declarator_opt [ constant-expression ]
+noptr-abstract-declarator := noptr-abstract-declarator_opt [ constant-expression_opt ]
noptr-abstract-declarator := ( ptr-abstract-declarator )
abstract-pack-declarator := noptr-abstract-pack-declarator
abstract-pack-declarator := ptr-operator abstract-pack-declarator
diff --git a/clang-tools-extra/pseudo/test/cxx/unsized-array.cpp b/clang-tools-extra/pseudo/test/cxx/unsized-array.cpp
new file mode 100644
index 0000000000000..16d4da94039ce
--- /dev/null
+++ b/clang-tools-extra/pseudo/test/cxx/unsized-array.cpp
@@ -0,0 +1,7 @@
+// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | FileCheck %s
+void s(int[]);
+// CHECK: parameter-declaration-list~parameter-declaration := decl-specifier-seq abstract-declarator
+// CHECK-NEXT: ├─decl-specifier-seq~INT := tok[3]
+// CHECK-NEXT: └─abstract-declarator~noptr-abstract-declarator := [ ]
+// CHECK-NEXT: ├─[ := tok[4]
+// CHECK-NEXT: └─] := tok[5]
More information about the cfe-commits
mailing list