summaryrefslogtreecommitdiff
path: root/clang-tools-extra/pseudo
diff options
context:
space:
mode:
authorHaojian Wu <hokein.wu@gmail.com>2022-08-11 23:09:27 +0200
committerHaojian Wu <hokein.wu@gmail.com>2022-08-12 13:46:26 +0200
commita1a1a78ac8cf837e4c05152c9715f399b33bfb59 (patch)
tree913b3879ceb317b423f02290323699b8d62f1572 /clang-tools-extra/pseudo
parent435feefbdd6c91faf24fa5e69c4e7c3bc127568a (diff)
downloadllvm-a1a1a78ac8cf837e4c05152c9715f399b33bfb59.tar.gz
[pseudo] Eliminate an ambiguity for the empty member declaration.
We happened to introduce a `member-declaration := ;` rule when inlining the `member-declaration := decl-specifier-seq_opt member-declarator-list_opt ;`. And with the `member-declaration := empty-declaration` rule, we had two parses of `;`. This patch is to restrict the grammar to eliminate the `member-declaration := ;` rule. Differential Revision: https://reviews.llvm.org/D131724
Diffstat (limited to 'clang-tools-extra/pseudo')
-rw-r--r--clang-tools-extra/pseudo/lib/cxx/cxx.bnf3
-rw-r--r--clang-tools-extra/pseudo/test/cxx/empty-member-declaration.cpp7
2 files changed, 9 insertions, 1 deletions
diff --git a/clang-tools-extra/pseudo/lib/cxx/cxx.bnf b/clang-tools-extra/pseudo/lib/cxx/cxx.bnf
index 5f1cba450394..d5cc0a9d2c85 100644
--- a/clang-tools-extra/pseudo/lib/cxx/cxx.bnf
+++ b/clang-tools-extra/pseudo/lib/cxx/cxx.bnf
@@ -557,7 +557,8 @@ class-key := STRUCT
class-key := UNION
member-specification := member-declaration member-specification_opt
member-specification := access-specifier : member-specification_opt
-member-declaration := decl-specifier-seq_opt member-declarator-list_opt ;
+member-declaration := decl-specifier-seq member-declarator-list_opt ;
+member-declaration := member-declarator-list ;
member-declaration := function-definition
member-declaration := using-declaration
member-declaration := using-enum-declaration
diff --git a/clang-tools-extra/pseudo/test/cxx/empty-member-declaration.cpp b/clang-tools-extra/pseudo/test/cxx/empty-member-declaration.cpp
new file mode 100644
index 000000000000..2540dd010fce
--- /dev/null
+++ b/clang-tools-extra/pseudo/test/cxx/empty-member-declaration.cpp
@@ -0,0 +1,7 @@
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest --forest-abbrev=false | FileCheck %s
+class A {
+ ;
+// CHECK-NOT: member-declaration := ;
+// CHECK: member-declaration := empty-declaration
+// CHECK-NOT: member-declaration := ;
+};