diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaCUDA.cpp | 9 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 12 |
2 files changed, 14 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp index 61dfdd3f720..568c765984f 100644 --- a/clang/lib/Sema/SemaCUDA.cpp +++ b/clang/lib/Sema/SemaCUDA.cpp @@ -273,12 +273,9 @@ static bool resolveCalleeCUDATargetConflict(Sema::CUDAFunctionTarget Target1, Sema::CUDAFunctionTarget Target2, Sema::CUDAFunctionTarget *ResolvedTarget) { - if (Target1 == Sema::CFT_Global && Target2 == Sema::CFT_Global) { - // TODO: this shouldn't happen, really. Methods cannot be marked __global__. - // Clang should detect this earlier and produce an error. Then this - // condition can be changed to an assertion. - return true; - } + // Only free functions and static member functions may be global. + assert(Target1 != Sema::CFT_Global); + assert(Target2 != Sema::CFT_Global); if (Target1 == Sema::CFT_HostDevice) { *ResolvedTarget = Target2; 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) { |