[flang][cuda] Adapt ExternalNameConversion to work in gpu module (#117039)
[llvm-project.git] / clang / test / AST / ast-dump-array.cpp
blob418e4292680ee9bcd740f6ee0793abb7cecdba95
1 // Test without serialization:
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s \
3 // RUN: | FileCheck --strict-whitespace %s
4 //
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()
13 int a[10];
14 auto l = [a]{
16 // CHECK: |-ArrayInitLoopExpr 0x{{[^ ]*}} <col:15> 'int[10]'
17 // CHECK: | `-ArrayInitIndexExpr 0x{{[^ ]*}} <<invalid sloc>> 'unsigned long'
20 template<typename T, int Size>
21 class array {
22 T data[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>
30 struct V {};
31 template <typename U, typename Idx, int N>
32 void testDependentSubscript() {
33 U* a;
34 U b[5];
35 Idx i{};
36 enum E { One = 1 };
38 // Can types of subscript expressions can be determined?
39 // LHS is a type-dependent array, RHS is a known integer type.
40 a[1];
41 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} 'U'
42 b[1];
43 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} 'U'
45 // Reverse case: RHS is a type-dependent array, LHS is an integer.
46 1[a];
47 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} 'U'
48 1[b];
49 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} 'U'
51 // LHS is a type-dependent array, RHS is type-dependent.
52 a[i];
53 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} '<dependent type>'
54 b[i];
55 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} '<dependent type>'
57 V *a2;
58 V b2[5];
60 // LHS is a known array, RHS is type-dependent.
61 a2[i];
62 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} '<dependent type>'
63 b2[i];
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.
68 a2[One];
69 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} '<dependent type>'
70 b2[One];
71 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} '<dependent type>'
73 V b3[N];
74 // LHS is an array with dependent bounds but known elements.
75 // We insist on a dependent type.
76 b3[0];
77 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} '<dependent type>'
79 U b4[N];
80 // LHS is an array with dependent bounds and dependent elements.
81 b4[0];
82 // CHECK: ArraySubscriptExpr {{.*}}line:[[@LINE-1]]{{.*}} 'U'