qualifiers.cu 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
  2. // RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -verify -fcuda-is-device %s
  3. //
  4. // We run clang_cc1 with 'not' because source file contains
  5. // intentional errors. CC1 failure is expected and must be ignored
  6. // here. We're interested in what ends up in AST and that's what
  7. // FileCheck verifies.
  8. // RUN: not %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -ast-dump %s \
  9. // RUN: | FileCheck %s --check-prefix=CHECK-ALL --check-prefix=CHECK-HOST
  10. // RUN: not %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -ast-dump -fcuda-is-device %s \
  11. // RUN: | FileCheck %s --check-prefix=CHECK-ALL --check-prefix=CHECK-DEVICE
  12. #include "Inputs/cuda.h"
  13. // Host (x86) supports TLS and device-side compilation should ignore
  14. // host variables. No errors in either case.
  15. int __thread host_tls_var;
  16. // CHECK-ALL: host_tls_var 'int' tls
  17. #if defined(__CUDA_ARCH__)
  18. // NVPTX does not support TLS
  19. __device__ int __thread device_tls_var; // expected-error {{thread-local storage is not supported for the current target}}
  20. // CHECK-DEVICE: device_tls_var 'int' tls
  21. __shared__ int __thread shared_tls_var; // expected-error {{thread-local storage is not supported for the current target}}
  22. // CHECK-DEVICE: shared_tls_var 'int' tls
  23. #else
  24. // Device-side vars should not produce any errors during host-side
  25. // compilation.
  26. __device__ int __thread device_tls_var;
  27. // CHECK-HOST: device_tls_var 'int' tls
  28. __shared__ int __thread shared_tls_var;
  29. // CHECK-HOST: shared_tls_var 'int' tls
  30. #endif
  31. __global__ void g1(int x) {}
  32. __global__ int g2(int x) { // expected-error {{must have void return type}}
  33. return 1;
  34. }