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