Skip to content

Commit ed43c1b

Browse files
committed
updated diagnostics - sycl version aware, diff messaging
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
1 parent c87f7b7 commit ed43c1b

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10969,8 +10969,8 @@ def warn_boolean_attribute_argument_is_not_valid: Warning<
1096910969
def err_sycl_attibute_cannot_be_applied_here
1097010970
: Error<"%0 attribute cannot be applied to a "
1097110971
"static function or function in an anonymous namespace">;
10972-
def warn_sycl_old_version
10973-
: Warning<"Older version of SYCL headers encountered.">,
10972+
def warn_sycl_pass_by_value_deprecated
10973+
: Warning<"Pass-by-value of kernel functions is deprecated in SYCL 2020.">,
1097410974
InGroup<SyclStrict>;
1097510975
def warn_sycl_attibute_function_raw_ptr
1097610976
: Warning<"SYCL 1.2.1 specification does not allow %0 attribute applied "

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2582,6 +2582,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
25822582
if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
25832583
Opts.SYCLVersion = llvm::StringSwitch<unsigned>(A->getValue())
25842584
.Cases("2017", "1.2.1", "121", "sycl-1.2.1", 2017)
2585+
.Case("2020", 2020)
25852586
.Default(0U);
25862587

25872588
if (Opts.SYCLVersion == 0U) {

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,10 @@ static const CXXRecordDecl *getKernelObjectType(Sema &SemaRef,
736736
return KernelParamTy->getPointeeCXXRecordDecl();
737737

738738
// SYCL 1.2
739-
SemaRef.Diag(Caller->getLocation(), diag::warn_sycl_old_version);
739+
if (SemaRef.LangOpts.SYCLVersion > 2017)
740+
SemaRef.Diag(Caller->getLocation(),
741+
diag::warn_sycl_pass_by_value_deprecated);
742+
740743
return KernelParamTy->getAsCXXRecordDecl();
741744
}
742745

clang/test/CodeGenSYCL/kernel-by-reference.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only %s
1+
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only -sycl-std=2017 -DNODIAG %s
2+
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only -sycl-std=2020 -DSYCL2020 %s
3+
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only -Wno-sycl-strict -DNODIAG %s
4+
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only -sycl-std=2020 -Wno-sycl-strict -DNODIAG %s
25

3-
// SYCL 1.2 - kernel functions passed directly. (Also no const requirement, though mutable lambdas never supported)
6+
// SYCL 1.2/2017 - kernel functions passed directly. (Also no const requirement, though mutable lambdas never supported)
47
template <typename name, typename Func>
5-
// expected-warning@+1 {{Older version of SYCL headers encountered.}}
6-
__attribute__((sycl_kernel)) void sycl_12_single_task(Func kernelFunc) {
8+
#if defined(SYCL2020)
9+
// expected-warning@+2 {{Pass-by-value of kernel functions is deprecated in SYCL 2020.}}
10+
#endif
11+
__attribute__((sycl_kernel)) void sycl_2017_single_task(Func kernelFunc) {
712
kernelFunc();
813
}
914

@@ -19,7 +24,7 @@ int do_nothing(int i) {
1924

2025
// ensure both compile.
2126
int main() {
22-
sycl_12_single_task<class sycl12>([]() {
27+
sycl_2017_single_task<class sycl12>([]() {
2328
do_nothing(10);
2429
});
2530

@@ -28,4 +33,7 @@ int main() {
2833
});
2934

3035
return 0;
31-
}
36+
}
37+
#if defined(NODIAG)
38+
// expected-no-diagnostics
39+
#endif

0 commit comments

Comments
 (0)