brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · ee4b43a Raw
38 lines · plain
1// Tests that CUDA attributes are warnings when compiling C files, but not when2// compiling CUDA files.3//4// RUN: %clang_cc1 -fsyntax-only -verify %s5// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s6// Now pretend that we're compiling a C file. There should be warnings.7// RUN: %clang_cc1 -DEXPECT_WARNINGS -fsyntax-only -verify -x c %s8 9#if defined(EXPECT_WARNINGS)10// expected-warning@+15 {{'device' attribute ignored}}11// expected-warning@+15 {{'global' attribute ignored}}12// expected-warning@+15 {{'constant' attribute ignored}}13// expected-warning@+15 {{'shared' attribute ignored}}14// expected-warning@+15 {{'host' attribute ignored}}15// expected-warning@+21 {{'device_builtin_surface_type' attribute ignored}}16// expected-warning@+21 {{'device_builtin_texture_type' attribute ignored}}17//18// NOTE: IgnoredAttr in clang which is used for the rest of19// attributes ignores LangOpts, so there are no warnings.20#else21// expected-warning@+15 {{'device_builtin_surface_type' attribute only applies to classes}}22// expected-warning@+15 {{'device_builtin_texture_type' attribute only applies to classes}}23#endif24 25__attribute__((device)) void f_device(void);26__attribute__((global)) void f_global(void);27__attribute__((constant)) int* g_constant;28__attribute__((shared)) float *g_shared;29__attribute__((host)) void f_host(void);30__attribute__((device_builtin)) void f_device_builtin(void);31typedef __attribute__((device_builtin)) const void *t_device_builtin;32enum __attribute__((device_builtin)) e_device_builtin {E};33__attribute__((device_builtin)) int v_device_builtin;34__attribute__((cudart_builtin)) void f_cudart_builtin(void);35__attribute__((nv_weak)) void f_nv_weak(void);36__attribute__((device_builtin_surface_type)) unsigned long long surface_var;37__attribute__((device_builtin_texture_type)) unsigned long long texture_var;38