[clang-tools-extra] 0a6a17a - [pseudo] Fix the member-specification grammar rule.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 7 01:19:58 PDT 2022


Author: Haojian Wu
Date: 2022-06-07T10:18:18+02:00
New Revision: 0a6a17a4f9fd7bb14ca263893922bb56ac0887e8

URL: https://github.com/llvm/llvm-project/commit/0a6a17a4f9fd7bb14ca263893922bb56ac0887e8
DIFF: https://github.com/llvm/llvm-project/commit/0a6a17a4f9fd7bb14ca263893922bb56ac0887e8.diff

LOG: [pseudo] Fix the member-specification grammar rule.

The grammar rule is not right, doesn't match the standard one.

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

Added: 
    clang-tools-extra/pseudo/test/cxx/empty-member-spec.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 3a4048f657570..60cf0a99d419e 100644
--- a/clang-tools-extra/pseudo/lib/cxx.bnf
+++ b/clang-tools-extra/pseudo/lib/cxx.bnf
@@ -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
index 0000000000000..6d7a6823d0bf0
--- /dev/null
+++ b/clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp
@@ -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]


        


More information about the cfe-commits mailing list