1 // Test without serialization:
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s \
3 // RUN: | FileCheck --strict-whitespace %s
5 // Test with serialization:
6 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t %s
7 // RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -include-pch %t -ast-dump-all /dev/null \
8 // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
9 // RUN: | FileCheck --strict-whitespace %s
11 void testArrayInitExpr()
16 // CHECK: |-ArrayInitLoopExpr 0x{{[^ ]*}} <col:15> 'int[10]'
17 // CHECK: | `-ArrayInitIndexExpr 0x{{[^ ]*}} <<invalid sloc>> 'unsigned long'
20 template<typename T
, int Size
>
24 using array_T_size
= T
[Size
];
25 // CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'T[Size]' dependent <col:25, col:30>
26 using const_array_T_size
= const T
[Size
];
27 // CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'const T[Size]' dependent <col:37, col:42>
31 template <typename U
, typename Idx
, int N
>
32 void testDependentSubscript() {
38 // Can types of subscript expressions can be determined?
39 // LHS is a type-dependent array, RHS is a known integer type.
41 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} 'U'
43 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} 'U'
45 // Reverse case: RHS is a type-dependent array, LHS is an integer.
47 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} 'U'
49 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} 'U'
51 // LHS is a type-dependent array, RHS is type-dependent.
53 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} '<dependent type>'
55 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} '<dependent type>'
60 // LHS is a known array, RHS is type-dependent.
62 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} '<dependent type>'
64 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} '<dependent type>'
66 // LHS is a known array, RHS is a type-dependent index.
67 // We know the element type is V, but insist on some dependent type.
69 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} '<dependent type>'
71 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} '<dependent type>'
74 // LHS is an array with dependent bounds but known elements.
75 // We insist on a dependent type.
77 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} '<dependent type>'
80 // LHS is an array with dependent bounds and dependent elements.
82 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} 'U'