Clang Project

clang_source_code/test/SemaCUDA/attr-declspec.cu
1// Test the __declspec spellings of CUDA attributes.
2//
3// RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify %s
4// RUN: %clang_cc1 -fsyntax-only -fms-extensions -fcuda-is-device -verify %s
5// Now pretend that we're compiling a C file. There should be warnings.
6// RUN: %clang_cc1 -DEXPECT_WARNINGS -fms-extensions -fsyntax-only -verify -x c %s
7
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// (Currently we don't for the other attributes. They are implemented with
16// IgnoredAttr, which is ignored irrespective of any LangOpts.)
17#else
18// expected-no-diagnostics
19#endif
20
21__declspec(__device__) void f_device();
22__declspec(__global__) void f_global();
23__declspec(__constant__) int* g_constant;
24__declspec(__shared__) float *g_shared;
25__declspec(__host__) void f_host();
26__declspec(__device_builtin__) void f_device_builtin();
27typedef __declspec(__device_builtin__) const void *t_device_builtin;
28enum __declspec(__device_builtin__) e_device_builtin {E};
29__declspec(__device_builtin__) int v_device_builtin;
30__declspec(__cudart_builtin__) void f_cudart_builtin();
31__declspec(__device_builtin_surface_type__) unsigned long long surface_var;
32__declspec(__device_builtin_texture_type__) unsigned long long texture_var;
33
34// Note that there's no __declspec spelling of nv_weak.
35