Clang Project

clang_source_code/test/SemaCUDA/attributes-on-non-cuda.cu
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
9#if defined(EXPECT_WARNINGS)
10// expected-warning@+12 {{'device' attribute ignored}}
11// expected-warning@+12 {{'global' attribute ignored}}
12// expected-warning@+12 {{'constant' attribute ignored}}
13// expected-warning@+12 {{'shared' attribute ignored}}
14// expected-warning@+12 {{'host' attribute ignored}}
15//
16// NOTE: IgnoredAttr in clang which is used for the rest of
17// attributes ignores LangOpts, so there are no warnings.
18#else
19// expected-no-diagnostics
20#endif
21
22__attribute__((device)) void f_device();
23__attribute__((global)) void f_global();
24__attribute__((constant)) int* g_constant;
25__attribute__((shared)) float *g_shared;
26__attribute__((host)) void f_host();
27__attribute__((device_builtin)) void f_device_builtin();
28typedef __attribute__((device_builtin)) const void *t_device_builtin;
29enum __attribute__((device_builtin)) e_device_builtin {E};
30__attribute__((device_builtin)) int v_device_builtin;
31__attribute__((cudart_builtin)) void f_cudart_builtin();
32__attribute__((nv_weak)) void f_nv_weak();
33__attribute__((device_builtin_surface_type)) unsigned long long surface_var;
34__attribute__((device_builtin_texture_type)) unsigned long long texture_var;
35