105 lines · cpp
1// Test that SYCL kernel name conflicts that occur across module boundaries are2// properly diagnosed and that declarations are properly merged so that spurious3// conflicts are not reported.4 5// RUN: rm -rf %t6// RUN: split-file %s %t7// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \8// RUN: -std=c++17 -fsycl-is-host %t/test.cpp -verify9// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \10// RUN: -std=c++17 -fsycl-is-device %t/test.cpp -verify11 12#--- module.modulemap13module M1 { header "m1.h" }14module M2 { header "m2.h" }15 16 17#--- common.h18template<int> struct KN;19 20[[clang::sycl_kernel_entry_point(KN<1>)]]21void common_test1() {}22 23template<typename T>24[[clang::sycl_kernel_entry_point(T)]]25void common_test2() {}26template void common_test2<KN<2>>();27 28 29#--- m1.h30#include "common.h"31 32[[clang::sycl_kernel_entry_point(KN<3>)]]33void m1_test3() {} // << expected previous declaration note here.34 35template<typename T>36[[clang::sycl_kernel_entry_point(T)]]37void m1_test4() {} // << expected previous declaration note here.38template void m1_test4<KN<4>>();39 40[[clang::sycl_kernel_entry_point(KN<5>)]]41void m1_test5() {} // << expected previous declaration note here.42 43template<typename T>44[[clang::sycl_kernel_entry_point(T)]]45void m1_test6() {} // << expected previous declaration note here.46template void m1_test6<KN<6>>();47 48 49#--- m2.h50#include "common.h"51 52[[clang::sycl_kernel_entry_point(KN<3>)]]53void m2_test3() {} // << expected kernel name conflict here.54 55template<typename T>56[[clang::sycl_kernel_entry_point(T)]]57void m2_test4() {} // << expected kernel name conflict here.58template void m2_test4<KN<4>>();59 60[[clang::sycl_kernel_entry_point(KN<7>)]]61void m2_test7() {} // << expected previous declaration note here.62 63template<typename T>64[[clang::sycl_kernel_entry_point(T)]]65void m2_test8() {} // << expected previous declaration note here.66template void m2_test8<KN<8>>();67 68 69#--- test.cpp70#include "m1.h"71#include "m2.h"72 73// Expected diagnostics for m1_test3() and m2_test3():74// expected-error@m2.h:4 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}75// expected-note@m1.h:12 {{previous declaration is here}}76 77// Expected diagnostics for m1_test4<KN<4>>() and m2_test4<KN<4>>():78// expected-error@m2.h:8 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}79// expected-note@m1.h:16 {{previous declaration is here}}80 81// expected-error@+3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}82// expected-note@m1.h:4 {{previous declaration is here}}83[[clang::sycl_kernel_entry_point(KN<5>)]]84void test5() {}85 86// expected-error@+3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}87// expected-note@m1.h:8 {{previous declaration is here}}88[[clang::sycl_kernel_entry_point(KN<6>)]]89void test6() {}90 91// expected-error@+3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}92// expected-note@m2.h:12 {{previous declaration is here}}93[[clang::sycl_kernel_entry_point(KN<7>)]]94void test7() {}95 96// expected-error@+3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}97// expected-note@m2.h:16 {{previous declaration is here}}98[[clang::sycl_kernel_entry_point(KN<8>)]]99void test8() {}100 101void f() {102 common_test1();103 common_test2<KN<2>>();104}105