[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 7 14:05:32 PST 2019
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall.
If a kernel template has a function as its template parameter, a device function should be
allowed as template argument since a kernel can call a device function. However,
currently if the kernel template is instantiated in a host function, clang will emit an error
message saying the device function is an invalid candidate for the template parameter.
This happens because clang checks the reference to the device function during parsing
the template arguments. At this point, the template is not instantiated yet. Clang incorrectly
assumes the device function is called by the host function and emits the error message.
This patch fixes the issue by disabling checking of device function during parsing template
arguments and deferring the check to the instantion of the template. At that point, the
template decl is already available, therefore the check can be done against the instantiated
function template decl.
https://reviews.llvm.org/D56411
Files:
include/clang/Sema/Sema.h
lib/Parse/ParseTemplate.cpp
lib/Sema/SemaCUDA.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaTemplate.cpp
test/SemaCUDA/kernel-template-with-device-func-arg.cu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56411.180555.patch
Type: text/x-patch
Size: 12013 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190107/563ab98f/attachment.bin>
More information about the cfe-commits
mailing list