xref: /llvm-project/clang/test/AST/ast-dump-constant-var.cu (revision 4cb42564ec4b56ef7eb4758bfa4ddf844a163687)
1 // RUN: %clang_cc1 -std=c++14 -ast-dump -x hip %s | FileCheck -check-prefixes=CHECK,HOST %s
2 // RUN: %clang_cc1 -std=c++14 -ast-dump -fcuda-is-device -x hip %s | FileCheck -check-prefixes=CHECK,DEV %s
3 
4 #include "Inputs/cuda.h"
5 
6 // CHECK-LABEL: VarDecl {{.*}} m1 'int'
7 // CHECK-NEXT: CUDAConstantAttr {{.*}}cuda.h
8 __constant__ int m1;
9 
10 // CHECK-LABEL: VarDecl {{.*}} m2 'int'
11 // CHECK-NEXT: CUDAConstantAttr {{.*}}cuda.h
12 // CHECK-NOT: CUDAConstantAttr
13 __constant__ __constant__ int m2;
14 
15 // CHECK-LABEL: VarDecl {{.*}} m3 'const int'
16 // HOST-NOT: CUDAConstantAttr
17 // DEV-NOT: CUDAConstantAttr {{.*}}cuda.h
18 // DEV: CUDAConstantAttr {{.*}}Implicit
19 // DEV-NOT: CUDAConstantAttr {{.*}}cuda.h
20 constexpr int m3 = 1;
21 
22 // CHECK-LABEL: VarDecl {{.*}} m3a 'const int'
23 // CHECK-NOT: CUDAConstantAttr {{.*}}Implicit
24 // CHECK: CUDAConstantAttr {{.*}}cuda.h
25 // CHECK-NOT: CUDAConstantAttr {{.*}}Implicit
26 constexpr __constant__ int m3a = 2;
27 
28 // CHECK-LABEL: VarDecl {{.*}} m3b 'const int'
29 // CHECK-NOT: CUDAConstantAttr {{.*}}Implicit
30 // CHECK: CUDAConstantAttr {{.*}}cuda.h
31 // CHECK-NOT: CUDAConstantAttr {{.*}}Implicit
32 __constant__ constexpr int m3b = 3;
33