1 // Tests that CUDA attributes are warnings when compiling C files, but not when
2 // compiling CUDA files.
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
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}}
18 // NOTE: IgnoredAttr in clang which is used for the rest of
19 // attributes ignores LangOpts, so there are no warnings.
21 // 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}}
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);
31 typedef __attribute__((device_builtin)) const void *t_device_builtin;
32 enum __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;