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(); 28 typedef __attribute__((device_builtin)) const void *t_device_builtin; 29 enum __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