brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 4c61570 Raw
66 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++17 -fsyntax-only -fsycl-is-device -verify %s2// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++20 -fsyntax-only -fsycl-is-device -verify %s3 4// These tests are intended to validate that a sycl_kernel_entry_point attribute5// appearing in the declaration of a function template does not affect overload6// resolution or cause spurious errors during overload resolution due to either7// a substitution failure in the attribute argument or a semantic check of the8// attribute during instantiation of a specialization unless that specialization9// is selected by overload resolution.10 11// FIXME: C++23 [temp.expl.spec]p12 states:12// FIXME:   ... Similarly, attributes appearing in the declaration of a template13// FIXME:   have no effect on an explicit specialization of that template.14// FIXME: Clang currently instantiates and propagates attributes from a function15// FIXME: template to its explicit specializations resulting in the following16// FIXME: spurious error.17struct S1; // #S1-decl18// expected-error@+4 {{incomplete type 'S1' named in nested name specifier}}19// expected-note@+5 {{in instantiation of function template specialization 'ok1<S1>' requested here}}20// expected-note@#S1-decl {{forward declaration of 'S1'}}21template<typename T>22[[clang::sycl_kernel_entry_point(typename T::invalid)]] void ok1() {}23template<>24void ok1<S1>() {}25void test_ok1() {26  // ok1<S1>() is not a call to a SYCL kernel entry point function.27  ok1<S1>();28}29 30// FIXME: The sycl_kernel_entry_point attribute should not be instantiated31// FIXME: until after overload resolution has completed.32struct S2; // #S2-decl33// expected-error@+6 {{incomplete type 'S2' named in nested name specifier}}34// expected-note@+10 {{in instantiation of function template specialization 'ok2<S2>' requested here}}35// expected-note@#S2-decl {{forward declaration of 'S2'}}36template<typename T>37[[clang::sycl_kernel_entry_point(T)]] void ok2(int) {}38template<typename T>39[[clang::sycl_kernel_entry_point(typename T::invalid)]] void ok2(long) {}40void test_ok2() {41  // ok2(int) is a better match and is therefore selected by overload42  // resolution; the attempted instantiation of ok2(long) should not produce43  // an error for the substitution failure into the attribute argument.44  ok2<S2>(2);45}46 47// FIXME: The sycl_kernel_entry_point attribute should not be instantiated48// FIXME: until after overload resolution has completed.49struct S3;50struct Select3 {51  using bad_type = int;52  using good_type = S3;53};54// expected-error@+5 {{'typename Select3::bad_type' (aka 'int') is not a valid SYCL kernel name type; a non-union class type is required}}55// expected-note@+9 {{in instantiation of function template specialization 'ok3<Select3>' requested here}}56template<typename T>57[[clang::sycl_kernel_entry_point(typename T::good_type)]] void ok3(int) {}58template<typename T>59[[clang::sycl_kernel_entry_point(typename T::bad_type)]] void ok3(long) {}60void test_ok3() {61  // ok3(int) is a better match and is therefore selected by overload62  // resolution; the attempted instantiation of ok3(long) should not produce63  // an error for the invalid kernel name provided as the attribute argument.64  ok3<Select3>(2);65}66