[pseudo] Fix the member-specification grammar rule.
authorHaojian Wu <hokein.wu@gmail.com>
Fri, 3 Jun 2022 19:02:25 +0000 (21:02 +0200)
committerHaojian Wu <hokein.wu@gmail.com>
Tue, 7 Jun 2022 08:18:18 +0000 (10:18 +0200)
The grammar rule is not right, doesn't match the standard one.

Differential Revision: https://reviews.llvm.org/D126991

clang-tools-extra/pseudo/lib/cxx.bnf
clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp [new file with mode: 0644]

index 3a4048f..60cf0a9 100644 (file)
@@ -537,7 +537,7 @@ class-key := CLASS
 class-key := STRUCT
 class-key := UNION
 member-specification := member-declaration member-specification_opt
-member-specification := access-specifier : member-declaration member-specification_opt
+member-specification := access-specifier : member-specification_opt
 member-declaration := decl-specifier-seq_opt member-declarator-list_opt ;
 member-declaration := function-definition
 member-declaration := using-declaration
diff --git a/clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp b/clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp
new file mode 100644 (file)
index 0000000..6d7a682
--- /dev/null
@@ -0,0 +1,13 @@
+// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | FileCheck %s
+class Foo {
+public:
+};
+// CHECK:      decl-specifier-seq~class-specifier := class-head { member-specification }
+// CHECK-NEXT: ├─class-head := class-key class-head-name
+// CHECK-NEXT: │ ├─class-key~CLASS := tok[0]
+// CHECK-NEXT: │ └─class-head-name~IDENTIFIER := tok[1]
+// CHECK-NEXT: ├─{ := tok[2]
+// CHECK-NEXT: ├─member-specification := access-specifier :
+// CHECK-NEXT: │ ├─access-specifier~PUBLIC := tok[3]
+// CHECK-NEXT: │ └─: := tok[4]
+// CHECK-NEXT: └─} := tok[5]