2016-10-01 01:14:48 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
|
|
|
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcuda-is-device -verify %s
|
|
|
|
|
|
|
|
__attribute__((device)) void device_fn() {}
|
[CUDA] Emit deferred diagnostics during Sema rather than during codegen.
Summary:
Emitting deferred diagnostics during codegen was a hack. It did work,
but usability was poor, both for us as compiler devs and for users. We
don't codegen if there are any sema errors, so for users this meant that
they wouldn't see deferred errors if there were any non-deferred errors.
For devs, this meant that we had to carefully split up our tests so that
when we tested deferred errors, we didn't emit any non-deferred errors.
This change moves checking for deferred errors into Sema. See the big
comment in SemaCUDA.cpp for an overview of the idea.
This checking adds overhead to compilation, because we have to maintain
a partial call graph. As a result, this change makes deferred errors a
CUDA-only concept (whereas before they were a general concept). If
anyone else wants to use this framework for something other than CUDA,
we can generalize at that time.
This patch makes the minimal set of test changes -- after this lands,
I'll go back through and do a cleanup of the tests that we no longer
have to split up.
Reviewers: rnk
Subscribers: cfe-commits, rsmith, tra
Differential Revision: https://reviews.llvm.org/D25541
llvm-svn: 284158
2016-10-14 04:52:12 +08:00
|
|
|
__attribute__((host, device)) void hd_fn() {}
|
2016-10-01 01:14:48 +08:00
|
|
|
|
|
|
|
__attribute__((device)) void device_attr() {
|
|
|
|
([]() __attribute__((device)) { device_fn(); })();
|
2016-10-01 03:55:55 +08:00
|
|
|
// expected-warning@-1 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
|
2016-10-01 01:14:48 +08:00
|
|
|
([] __attribute__((device)) () { device_fn(); })();
|
|
|
|
([] __attribute__((device)) { device_fn(); })();
|
|
|
|
|
|
|
|
([&]() __attribute__((device)){ device_fn(); })();
|
2016-10-01 03:55:55 +08:00
|
|
|
// expected-warning@-1 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
|
2016-10-01 01:14:48 +08:00
|
|
|
([&] __attribute__((device)) () { device_fn(); })();
|
|
|
|
([&] __attribute__((device)) { device_fn(); })();
|
|
|
|
|
|
|
|
([&](int) __attribute__((device)){ device_fn(); })(0);
|
2016-10-01 03:55:55 +08:00
|
|
|
// expected-warning@-1 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
|
2016-10-01 01:14:48 +08:00
|
|
|
([&] __attribute__((device)) (int) { device_fn(); })(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((host)) __attribute__((device)) void host_device_attrs() {
|
|
|
|
([]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
|
2016-10-01 03:55:55 +08:00
|
|
|
// expected-warning@-1 {{nvcc does not allow '__host__' to appear after '()' in lambdas}}
|
|
|
|
// expected-warning@-2 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
|
2016-10-01 01:14:48 +08:00
|
|
|
([] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
|
|
|
|
([] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
|
|
|
|
|
|
|
|
([&]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
|
2016-10-01 03:55:55 +08:00
|
|
|
// expected-warning@-1 {{nvcc does not allow '__host__' to appear after '()' in lambdas}}
|
|
|
|
// expected-warning@-2 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
|
2016-10-01 01:14:48 +08:00
|
|
|
([&] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
|
|
|
|
([&] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
|
|
|
|
|
|
|
|
([&](int) __attribute__((host)) __attribute__((device)){ hd_fn(); })(0);
|
2016-10-01 03:55:55 +08:00
|
|
|
// expected-warning@-1 {{nvcc does not allow '__host__' to appear after '()' in lambdas}}
|
|
|
|
// expected-warning@-2 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
|
2016-10-01 01:14:48 +08:00
|
|
|
([&] __attribute__((host)) __attribute__((device)) (int) { hd_fn(); })(0);
|
|
|
|
}
|
2016-10-01 03:55:55 +08:00
|
|
|
|
|
|
|
// TODO: Add tests for __attribute__((global)) once we support global lambdas.
|