[pseudo] Fix noptr-abstract-declarator rule.

The const-expression in the [] can be empty.

Differential Revision: https://reviews.llvm.org/D126992
This commit is contained in:
Haojian Wu 2022-06-03 21:13:26 +02:00
parent 7fa97b473c
commit 58b33bc8c4
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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]