diff options
author | Justin Lebar <jlebar@google.com> | 2016-09-30 19:55:55 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2016-09-30 19:55:55 +0000 |
commit | cbda4956da53c248f7de961afaa0bb6bfac50b2a (patch) | |
tree | 2f97b0f6ad8e69d64ca31aebb2ba5c88afe594e2 /test/Parser/lambda-attr.cu | |
parent | 94575ae69a2e196fc9428b943967e17094bc8f4f (diff) |
[CUDA] Emit a warning if a CUDA host/device/global attribute is placed after '(...)'.
Summary:
This is probably the sane place for the attribute to go, but nvcc
specifically rejects it. Other GNU-style attributes are allowed in this
position (although judging from the warning it emits for
host/device/global, those attributes are applied to the lambda's
anonymous struct, not to the function itself).
It would be nice to have a FixIt message here, but doing so, or even
just getting the correct range for the attribute, including its '((' and
'))'s, is apparently Hard.
Reviewers: rnk
Subscribers: cfe-commits, tra
Differential Revision: https://reviews.llvm.org/D25115
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@282911 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Parser/lambda-attr.cu')
-rw-r--r-- | test/Parser/lambda-attr.cu | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/test/Parser/lambda-attr.cu b/test/Parser/lambda-attr.cu index c51e0a2b9d..dfd6fc8ecd 100644 --- a/test/Parser/lambda-attr.cu +++ b/test/Parser/lambda-attr.cu @@ -1,33 +1,42 @@ // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcuda-is-device -verify %s -// expected-no-diagnostics - __attribute__((device)) void device_fn() {} __attribute__((device)) void hd_fn() {} __attribute__((device)) void device_attr() { ([]() __attribute__((device)) { device_fn(); })(); + // expected-warning@-1 {{nvcc does not allow '__device__' to appear after '()' in lambdas}} ([] __attribute__((device)) () { device_fn(); })(); ([] __attribute__((device)) { device_fn(); })(); ([&]() __attribute__((device)){ device_fn(); })(); + // expected-warning@-1 {{nvcc does not allow '__device__' to appear after '()' in lambdas}} ([&] __attribute__((device)) () { device_fn(); })(); ([&] __attribute__((device)) { device_fn(); })(); ([&](int) __attribute__((device)){ device_fn(); })(0); + // expected-warning@-1 {{nvcc does not allow '__device__' to appear after '()' in lambdas}} ([&] __attribute__((device)) (int) { device_fn(); })(0); } __attribute__((host)) __attribute__((device)) void host_device_attrs() { ([]() __attribute__((host)) __attribute__((device)){ hd_fn(); })(); + // 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}} ([] __attribute__((host)) __attribute__((device)) () { hd_fn(); })(); ([] __attribute__((host)) __attribute__((device)) { hd_fn(); })(); ([&]() __attribute__((host)) __attribute__((device)){ hd_fn(); })(); + // 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}} ([&] __attribute__((host)) __attribute__((device)) () { hd_fn(); })(); ([&] __attribute__((host)) __attribute__((device)) { hd_fn(); })(); ([&](int) __attribute__((host)) __attribute__((device)){ hd_fn(); })(0); + // 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}} ([&] __attribute__((host)) __attribute__((device)) (int) { hd_fn(); })(0); } + +// TODO: Add tests for __attribute__((global)) once we support global lambdas. |