brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 7fa128e Raw
52 lines · plain
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s2// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcuda-is-device -verify %s3 4__attribute__((device)) void device_fn() {}5__attribute__((host, device)) void hd_fn() {}6 7__attribute__((device)) void device_attr() {8  ([]() __attribute__((device)) { device_fn(); })();9  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after the parameter list in lambdas}}10  ([] __attribute__((device)) () { device_fn(); })();11  ([] __attribute__((device)) { device_fn(); })();12 13  ([&]() __attribute__((device)){ device_fn(); })();14  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after the parameter list in lambdas}}15  ([&] __attribute__((device)) () { device_fn(); })();16  ([&] __attribute__((device)) { device_fn(); })();17 18  ([&](int) __attribute__((device)){ device_fn(); })(0);19  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after the parameter list in lambdas}}20  ([&] __attribute__((device)) (int) { device_fn(); })(0);21 22  // test that noinline can appear anywhere.23  ([&] __attribute__((device)) __noinline__ () { device_fn(); })();24  ([&] __noinline__ __attribute__((device)) () { device_fn(); })();25}26 27__attribute__((host)) __attribute__((device)) void host_device_attrs() {28  ([]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();29  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after the parameter list in lambdas}}30  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after the parameter list in lambdas}}31  ([] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();32  ([] __attribute__((host)) __attribute__((device)) { hd_fn(); })();33 34  ([&]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();35  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after the parameter list in lambdas}}36  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after the parameter list in lambdas}}37  ([&] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();38  ([&] __attribute__((host)) __attribute__((device)) { hd_fn(); })();39 40  ([&](int) __attribute__((host)) __attribute__((device)){ hd_fn(); })(0);41  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after the parameter list in lambdas}}42  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after the parameter list in lambdas}}43  ([&] __attribute__((host)) __attribute__((device)) (int) { hd_fn(); })(0);44 45  // test that noinline can also appear anywhere.46  ([] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();47  ([] __attribute__((host)) __noinline__ __attribute__((device)) () { hd_fn(); })();48  ([] __attribute__((host)) __attribute__((device)) __noinline__ () { hd_fn(); })();49}50 51// TODO: Add tests for __attribute__((global)) once we support global lambdas.52