1// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
2
3// Verify that we don't form a complete `::` nested-name-specifier if there is
4// an identifier preceding it.
5Foo::Foo() {} // No "Foo ::Foo()" false parse
6// CHECK: ├─declaration-seq~function-definition := function-declarator function-body
7// CHECK-NEXT: │ ├─function-declarator~noptr-declarator := noptr-declarator parameters-and-qualifiers
8
9int ::x;
10// CHECK: declaration~simple-declaration := decl-specifier-seq init-declarator-list ;
11// CHECK-NEXT: ├─decl-specifier-seq~INT
12
13void test() {
14 X::Y::Z; // No false qualified-declarator parses "X ::Y::Z" and "X::Y ::Z".
15// CHECK: statement-seq~statement := <ambiguous>
16// CHECK: statement~expression-statement := expression ;
17// CHECK: statement~simple-declaration := decl-specifier-seq ;
18// CHECK-NOT: simple-declaration := decl-specifier-seq init-declarator-list ;
19
20 // FIXME: eliminate the false `a<b> ::c` declaration parse.
21 a<b>::c;
22// CHECK: statement := <ambiguous>
23// CHECK-NEXT: ├─statement~expression-statement := expression ;
24// CHECK-NEXT: │ ├─expression~relational-expression :=
25// CHECK: └─statement~simple-declaration := <ambiguous>
26// CHECK-NEXT: ├─simple-declaration := decl-specifier-seq ;
27// CHECK: └─simple-declaration := decl-specifier-seq init-declarator-list ;
28}
29

source code of clang-tools-extra/pseudo/test/cxx/nested-name-specifier.cpp