attributes-on-non-cuda.cu 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Tests that CUDA attributes are warnings when compiling C files, but not when
  2. // compiling CUDA files.
  3. //
  4. // RUN: %clang_cc1 -fsyntax-only -verify %s
  5. // RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s
  6. // Now pretend that we're compiling a C file. There should be warnings.
  7. // RUN: %clang_cc1 -DEXPECT_WARNINGS -fsyntax-only -verify -x c %s
  8. #if defined(EXPECT_WARNINGS)
  9. // expected-warning@+12 {{'device' attribute ignored}}
  10. // expected-warning@+12 {{'global' attribute ignored}}
  11. // expected-warning@+12 {{'constant' attribute ignored}}
  12. // expected-warning@+12 {{'shared' attribute ignored}}
  13. // expected-warning@+12 {{'host' attribute ignored}}
  14. //
  15. // NOTE: IgnoredAttr in clang which is used for the rest of
  16. // attributes ignores LangOpts, so there are no warnings.
  17. #else
  18. // expected-no-diagnostics
  19. #endif
  20. __attribute__((device)) void f_device();
  21. __attribute__((global)) void f_global();
  22. __attribute__((constant)) int* g_constant;
  23. __attribute__((shared)) float *g_shared;
  24. __attribute__((host)) void f_host();
  25. __attribute__((device_builtin)) void f_device_builtin();
  26. typedef __attribute__((device_builtin)) const void *t_device_builtin;
  27. enum __attribute__((device_builtin)) e_device_builtin {E};
  28. __attribute__((device_builtin)) int v_device_builtin;
  29. __attribute__((cudart_builtin)) void f_cudart_builtin();
  30. __attribute__((nv_weak)) void f_nv_weak();
  31. __attribute__((device_builtin_surface_type)) unsigned long long surface_var;
  32. __attribute__((device_builtin_texture_type)) unsigned long long texture_var;