1 //RUN: %clang_cc1 %s -pedantic -ast-dump -verify | FileCheck %s
3 //expected-no-diagnostics
5 //CHECK: |-VarDecl {{.*}} foo 'const __global int'
8 //CHECK: |-VarDecl {{.*}} foo1 'T' cinit
9 //CHECK: `-VarTemplateSpecializationDecl {{.*}} used foo1 '__global long':'__global long' cinit
15 //CHECK: `-VarDecl {{.*}} foo2 'const __global int'
16 static constexpr int foo2 = 0;
21 // We only deduce addr space in type alias in pointer types.
22 //CHECK: TypeAliasDecl {{.*}} alias_c1 'c1'
24 //CHECK: TypeAliasDecl {{.*}} alias_c1_ptr '__generic c1 *'
25 using alias_c1_ptr = c1 *;
29 alias_c1_ptr ptr = &y;
33 // Addr spaces for pointee of dependent types are not deduced
34 // during parsing but during template instantiation instead.
38 //CHECK: -CXXMethodDecl {{.*}} operator= 'x1<T> &(const x1<T> &){{( __attribute__.*)?}} __generic'
39 //CHECK: -CXXMethodDecl {{.*}} operator= '__generic x1<int> &(const __generic x1<int> &__private){{( __attribute__.*)?}} __generic'
40 x1<T>& operator=(const x1<T>& xx) {
49 //CHECK: -CXXMethodDecl {{.*}} foo 'void (x1<T> *){{( __attribute__.*)?}} __generic'
50 //CHECK: -CXXMethodDecl {{.*}} foo 'void (__generic x1<int> *__private){{( __attribute__.*)?}} __generic'
54 //CHECK: -FieldDecl {{.*}} m 'x1<int>[2]'
58 void bar(__global x1<int> *xx, __global x2<int> *bar) {
65 //CHECK: -CXXConstructorDecl {{.*}} x3<T> 'void (const x3<T> &){{( __attribute__.*)?}} __generic'
68 //CHECK: -CXXConstructorDecl {{.*}} x3<T> 'void (const x3<T> &){{( __attribute__.*)?}} __generic'
70 x3<T>::x3(const x3<T> &t) {}
73 T xxx(T *in1, T in2) {
74 // This pointer can't be deduced to generic because addr space
75 // will be taken from the template argument.
76 //CHECK: `-VarDecl {{.*}} 'T *' cinit
77 //CHECK: `-VarDecl {{.*}} i '__private int *__private' cinit
80 __private T *ptr = ⅈ
85 __kernel void test() {
87 xxx<__private int>(&foo[0], foo[0]);
88 // FIXME: Template param deduction fails here because
89 // temporaries are not in the __private address space.
90 // It is probably reasonable to put them in __private
91 // considering that stack and function params are
92 // implicitly in __private.
93 // However, if temporaries are left in default addr
94 // space we should at least pretty print the __private
95 // addr space. Otherwise diagnostic apprears to be
97 //xxx(&foo[0], foo[0]);
100 // Addr space for pointer/reference to an array
101 //CHECK: FunctionDecl {{.*}} t1 'void (const float (__generic &__private)[2])'
102 void t1(const float (&fYZ)[2]);
103 //CHECK: FunctionDecl {{.*}} t2 'void (const float (__generic *__private)[2])'
104 void t2(const float (*fYZ)[2]);
105 //CHECK: FunctionDecl {{.*}} t3 'void (float (((__generic *__private)))[2])'
106 void t3(float(((*fYZ)))[2]);
107 //CHECK: FunctionDecl {{.*}} t4 'void (float (((__generic *__generic *__private)))[2])'
108 void t4(float(((**fYZ)))[2]);
109 //CHECK: FunctionDecl {{.*}} t5 'void (float (__generic *(__generic *__private))[2])'
110 void t5(float (*(*fYZ))[2]);
120 long f1 = foo1<long>;