1*ecbf2f5fSBruno Ricci // Test without serialization:
2009f9e82SLeonard Chan // RUN: %clang_cc1 %s -ast-dump | FileCheck %s
3*ecbf2f5fSBruno Ricci //
4*ecbf2f5fSBruno Ricci // Test with serialization:
5*ecbf2f5fSBruno Ricci // RUN: %clang_cc1 -emit-pch -o %t %s
6*ecbf2f5fSBruno Ricci // RUN: %clang_cc1 -x c++ -include-pch %t -ast-dump-all /dev/null \
7*ecbf2f5fSBruno Ricci // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
8*ecbf2f5fSBruno Ricci // RUN: | FileCheck %s
9009f9e82SLeonard Chan 
10009f9e82SLeonard Chan // Veryify the ordering of the address_space attribute still comes before the
11009f9e82SLeonard Chan // type whereas other attributes are still printed after.
12009f9e82SLeonard Chan 
13009f9e82SLeonard Chan template <int I>
func()14009f9e82SLeonard Chan void func() {
15009f9e82SLeonard Chan   // CHECK: VarDecl {{.*}} x '__attribute__((address_space(1))) int *'
16009f9e82SLeonard Chan   __attribute__((address_space(1))) int *x;
17009f9e82SLeonard Chan 
18009f9e82SLeonard Chan   // CHECK: VarDecl {{.*}} a 'int * __attribute__((noderef))'
19009f9e82SLeonard Chan   int __attribute__((noderef)) * a;
20009f9e82SLeonard Chan 
21009f9e82SLeonard Chan   // CHECK: VarDecl {{.*}} y '__attribute__((address_space(2))) int *'
22009f9e82SLeonard Chan   __attribute__((address_space(I))) int *y;
23009f9e82SLeonard Chan 
24009f9e82SLeonard Chan   // CHECK: VarDecl {{.*}} z '__attribute__((address_space(3))) int *'
25009f9e82SLeonard Chan   [[clang::address_space(3)]] int *z;
26009f9e82SLeonard Chan }
27009f9e82SLeonard Chan 
func2()28009f9e82SLeonard Chan void func2() {
29009f9e82SLeonard Chan   func<2>();
30009f9e82SLeonard Chan }
31