From 5c6810f8f71fc36dd269bfa0a0bf776dba7578d4 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 30 Nov 2018 17:19:06 +0000 Subject: [PATCH] Adding tests for -ast-dump; NFC. This adds tests for GenericSelectionExpr; note that it points out a minor whitespace bug for selection expression cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348008 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Misc/ast-dump-stmt.c | 63 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/test/Misc/ast-dump-stmt.c b/test/Misc/ast-dump-stmt.c index 461893188a..fe90fa6b2e 100644 --- a/test/Misc/ast-dump-stmt.c +++ b/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 +} -- 2.40.0