From: Aaron Ballman Date: Fri, 30 Nov 2018 17:19:06 +0000 (+0000) Subject: Adding tests for -ast-dump; NFC. X-Git-Tag: llvmorg-8.0.0-rc1~3186 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e47b3669002affb663f76e4a43453b56d3839ec7;p=platform%2Fupstream%2Fllvm.git Adding tests for -ast-dump; NFC. This adds tests for GenericSelectionExpr; note that it points out a minor whitespace bug for selection expression cases. llvm-svn: 348008 --- diff --git a/clang/test/Misc/ast-dump-stmt.c b/clang/test/Misc/ast-dump-stmt.c index 4618931..fe90fa6 100644 --- a/clang/test/Misc/ast-dump-stmt.c +++ b/clang/test/Misc/ast-dump-stmt.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s +// RUN: %clang_cc1 -std=c11 -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s int TestLocation = 0; // CHECK: VarDecl{{.*}}TestLocation @@ -65,3 +65,64 @@ void TestUnaryOperatorExpr(void) { // CHECK-NEXT: ImplicitCastExpr // CHECK-NEXT: DeclRefExpr{{.*}}'T2' 'int' } + +void TestGenericSelectionExpressions(int i) { + _Generic(i, int : 12); + // CHECK: GenericSelectionExpr 0x{{[^ ]*}} 'int' + // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int' + // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int' + // FIXME: note that the following test line has a spurious whitespace. + // CHECK-NEXT: case 'int' selected + // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int' + // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 12 + _Generic(i, int : 12, default : 0); + // CHECK: GenericSelectionExpr 0x{{[^ ]*}} 'int' + // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int' + // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int' + // FIXME: note that the following test line has a spurious whitespace. + // CHECK-NEXT: case 'int' selected + // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int' + // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 12 + // CHECK-NEXT: default + // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 0 + _Generic(i, default : 0, int : 12); + // CHECK: GenericSelectionExpr 0x{{[^ ]*}} 'int' + // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int' + // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int' + // CHECK-NEXT: default + // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 0 + // FIXME: note that the following test line has a spurious whitespace. + // CHECK-NEXT: case 'int' selected + // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int' + // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 12 + _Generic(i, int : 12, float : 10, default : 100); + // CHECK: GenericSelectionExpr 0x{{[^ ]*}} 'int' + // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int' + // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int' + // FIXME: note that the following test line has a spurious whitespace. + // CHECK-NEXT: case 'int' selected + // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int' + // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 12 + // FIXME: note that the following test line has a spurious whitespace. + // CHECK-NEXT: case 'float' + // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'float' + // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 10 + // CHECK-NEXT: default + // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 100 + + int j = _Generic(i, int : 12); + // CHECK: DeclStmt 0x{{[^ ]*}} + // CHECK-NEXT: VarDecl 0x{{[^ ]*}} col:7 j 'int' cinit + // CHECK-NEXT: GenericSelectionExpr 0x{{[^ ]*}} 'int' + // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int' + // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int' + // FIXME: note that the following test line has a spurious whitespace. + // CHECK-NEXT: case 'int' selected + // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int' + // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 12 +}