Skip to content

Commit cf5a038

Browse files
committed
Add test for ast-dump
Signed-off-by: yronglin <[email protected]>
1 parent 882fd4e commit cf5a038

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

clang/test/AST/ast-dump-recovery.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,3 +460,36 @@ void RecoveryForStmtCond() {
460460
// CHECK-NEXT: `-CompoundStmt {{.*}}
461461
for (int i = 0; i < invalid; ++i) {}
462462
}
463+
464+
// Fix crash issue https://github.com/llvm/llvm-project/issues/112560.
465+
// Make sure clang compiles the following code without crashing:
466+
467+
// CHECK:NamespaceDecl {{.*}} GH112560
468+
// CHECK-NEXT: |-CXXRecordDecl {{.*}} referenced union U definition
469+
// CHECK-NEXT: | |-DefinitionData {{.*}}
470+
// CHECK-NEXT: | | |-DefaultConstructor {{.*}}
471+
// CHECK-NEXT: | | |-CopyConstructor {{.*}}
472+
// CHECK-NEXT: | | |-MoveConstructor {{.*}}
473+
// CHECK-NEXT: | | |-CopyAssignment {{.*}}
474+
// CHECK-NEXT: | | |-MoveAssignment {{.*}}
475+
// CHECK-NEXT: | | `-Destructor {{.*}}
476+
// CHECK-NEXT: | |-CXXRecordDecl {{.*}} implicit union U
477+
// CHECK-NEXT: | `-FieldDecl {{.*}} invalid f 'int'
478+
// CHECK-NEXT: | `-RecoveryExpr {{.*}} 'int' contains-errors
479+
// DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
480+
namespace GH112560 {
481+
union U {
482+
int f = ;
483+
};
484+
485+
// CHECK: FunctionDecl {{.*}} foo 'void ()'
486+
// CHECK-NEXT: `-CompoundStmt {{.*}}
487+
// CHECK-NEXT: `-DeclStmt {{.*}}
488+
// CHECK-NEXT: `-VarDecl {{.*}} g 'U':'GH112560::U' listinit
489+
// CHECK-NEXT: `-InitListExpr {{.*}} 'U':'GH112560::U' contains-errors field Field {{.*}} 'f' 'int'
490+
// CHECK-NEXT: `-RecoveryExpr {{.*}} 'int' contains-errors
491+
// DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
492+
void foo() {
493+
U g{};
494+
}
495+
} // namespace GH112560

0 commit comments

Comments
 (0)