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