================ @@ -0,0 +1,70 @@ +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsycl-is-device -std=c++20 -fsyntax-only -verify -DCPP20 %s +// Semantic tests for sycl_external attribute + +[[clang::sycl_external]] // expected-error {{'sycl_external' can only be applied to functions with external linkage}} +static void func1() {} + +namespace { + [[clang::sycl_external]] // expected-error {{'sycl_external' can only be applied to functions with external linkage}} + void func2() {} + + struct UnnX {}; +} + +[[clang::sycl_external]] // expected-error {{'sycl_external' can only be applied to functions with external linkage}} + void func4(UnnX) {} + +// The first declaration of a SYCL external function is required to have this attribute. +int foo(); // expected-note {{previous declaration is here}} + +[[clang::sycl_external]] int foo(); // expected-error {{'clang::sycl_external' attribute does not appear on the first declaration}} + +// Subsequent declrations of a SYCL external function may optionally specify this attribute. +[[clang::sycl_external]] int boo(); + +[[clang::sycl_external]] int boo(); // OK + +int boo(); // OK + +class C { + [[clang::sycl_external]] void member(); +}; + +[[clang::sycl_external]] int main() // expected-error {{'sycl_external' cannot be applied to the 'main' function}} +{ + return 0; +} + +class D { + [[clang::sycl_external]] void del() = delete; // expected-error {{'sycl_external' cannot be applied to an explicitly deleted function}} +}; ---------------- schittir wrote:
Surprisingly, this doesn't get diagnosed if it is not a member function! I'll look into it. https://github.com/llvm/llvm-project/pull/140282 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits