diff options
author | Justin Lebar <jlebar@google.com> | 2016-01-20 00:26:57 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2016-01-20 00:26:57 +0000 |
commit | c66a10652a9404d1d196864fc1b2e9aa413307b8 (patch) | |
tree | 232fcbb0030c005f33eb22a12210d739dfc22dad /clang/lib/Sema/SemaDeclAttr.cpp | |
parent | 23c4d83aa310903484cb80d2ab8197444a96d2e0 (diff) | |
download | bcm5719-llvm-c66a10652a9404d1d196864fc1b2e9aa413307b8.tar.gz bcm5719-llvm-c66a10652a9404d1d196864fc1b2e9aa413307b8.zip |
[CUDA] Only allow __global__ on free functions and static member functions.
Summary:
Warn for NVCC compatibility if you declare a static member function or
inline function as __global__.
Reviewers: tra
Subscribers: jhen, echristo, cfe-commits
Differential Revision: http://reviews.llvm.org/D16261
llvm-svn: 258263
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 31741be618a..e0ce3adce42 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -3617,11 +3617,21 @@ static void handleGlobalAttr(Sema &S, Decl *D, const AttributeList &Attr) { : FixItHint()); return; } + if (const auto *Method = dyn_cast<CXXMethodDecl>(FD)) { + if (Method->isInstance()) { + S.Diag(Method->getLocStart(), diag::err_kern_is_nonstatic_method) + << Method; + return; + } + S.Diag(Method->getLocStart(), diag::warn_kern_is_method) << Method; + } + // Only warn for "inline" when compiling for host, to cut down on noise. + if (FD->isInlineSpecified() && !S.getLangOpts().CUDAIsDevice) + S.Diag(FD->getLocStart(), diag::warn_kern_is_inline) << FD; D->addAttr(::new (S.Context) CUDAGlobalAttr(Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex())); - } static void handleGNUInlineAttr(Sema &S, Decl *D, const AttributeList &Attr) { |