llvm-project/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-pch.cpp
Tom Honermann 9de4e062d7
[SYCL] Restrict the sycl_kernel_entry_point attribute spelling to C++11 style. (#151405)
Previously, the `sycl_kernel_entry_point` attribute could be specified
using either the GNU or C++11 spelling styles. Future SYCL attributes
are expected to support only the C++11 spelling style, so support for
the GNU style is being removed.

In order to ensure consistent presentation of the attribute in
diagnostic messages, diagnostics specific to this attribute now require
the attribute to be provided as an argument. This delegates formatting
of the attribute name to the diagnostic engine.

As an additional nicety, "the" is added to some diagnostic messages so
that they read more like proper sentences.
2025-07-31 19:25:05 -04:00

37 lines
1.4 KiB
C++

// Test that SYCL kernel name conflicts that occur across PCH boundaries are
// properly diagnosed.
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: %clang_cc1 -std=c++17 -fsycl-is-host -emit-pch -x c++-header \
// RUN: %t/pch.h -o %t/pch.h.host.pch
// RUN: %clang_cc1 -std=c++17 -fsycl-is-host -verify \
// RUN: -include-pch %t/pch.h.host.pch %t/test.cpp
// RUN: %clang_cc1 -std=c++17 -fsycl-is-device -emit-pch -x c++-header \
// RUN: %t/pch.h -o %t/pch.h.device.pch
// RUN: %clang_cc1 -std=c++17 -fsycl-is-device -verify \
// RUN: -include-pch %t/pch.h.device.pch %t/test.cpp
#--- pch.h
template<int> struct KN;
[[clang::sycl_kernel_entry_point(KN<1>)]]
void pch_test1() {} // << expected previous declaration note here.
template<typename T>
[[clang::sycl_kernel_entry_point(T)]]
void pch_test2() {} // << expected previous declaration note here.
template void pch_test2<KN<2>>();
#--- test.cpp
// expected-error@+3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
// expected-note@pch.h:4 {{previous declaration is here}}
[[clang::sycl_kernel_entry_point(KN<1>)]]
void test1() {}
// expected-error@+3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
// expected-note@pch.h:8 {{previous declaration is here}}
[[clang::sycl_kernel_entry_point(KN<2>)]]
void test2() {}