r304193 - [OpenCL] Added diagnostic for implicit declaration of function in OpenCL
Egor Churaev via cfe-commits
cfe-commits at lists.llvm.org
Mon May 29 22:57:53 PDT 2017
Author: echuraev
Date: Tue May 30 00:57:52 2017
New Revision: 304193
URL: http://llvm.org/viewvc/llvm-project?rev=304193&view=rev
Log:
[OpenCL] Added diagnostic for implicit declaration of function in OpenCL
Reviewers: Anastasia, cfe-commits
Reviewed By: Anastasia
Subscribers: bader, yaxunl
Differential Revision: https://reviews.llvm.org/D31745
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl
cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=304193&r1=304192&r2=304193&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 30 00:57:52 2017
@@ -8317,6 +8317,8 @@ def err_opencl_scalar_type_rank_greater_
"element. (%0 and %1)">;
def err_bad_kernel_param_type : Error<
"%0 cannot be used as the type of a kernel parameter">;
+def err_opencl_implicit_function_decl : Error<
+ "implicit declaration of function %0 is invalid in OpenCL">;
def err_record_with_pointers_kernel_param : Error<
"%select{struct|union}0 kernel parameters may not contain pointers">;
def note_within_field_of_type : Note<
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=304193&r1=304192&r2=304193&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue May 30 00:57:52 2017
@@ -12509,6 +12509,9 @@ NamedDecl *Sema::ImplicitlyDefineFunctio
unsigned diag_id;
if (II.getName().startswith("__builtin_"))
diag_id = diag::warn_builtin_unknown;
+ // OpenCL v2.0 s6.9.u - Implicit function declaration is not supported.
+ else if (getLangOpts().OpenCL)
+ diag_id = diag::err_opencl_implicit_function_decl;
else if (getLangOpts().C99)
diag_id = diag::ext_implicit_function_decl;
else
Modified: cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl?rev=304193&r1=304192&r2=304193&view=diff
==============================================================================
--- cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl (original)
+++ cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl Tue May 30 00:57:52 2017
@@ -4,13 +4,13 @@
kernel void dse_builtins() {
int tmp;
- enqueue_kernel(tmp, tmp, tmp, ^(void) { // expected-warning{{implicit declaration of function 'enqueue_kernel' is invalid in C99}}
+ enqueue_kernel(tmp, tmp, tmp, ^(void) { // expected-error{{implicit declaration of function 'enqueue_kernel' is invalid in OpenCL}}
return;
});
- unsigned size = get_kernel_work_group_size(^(void) { // expected-warning{{implicit declaration of function 'get_kernel_work_group_size' is invalid in C99}}
+ unsigned size = get_kernel_work_group_size(^(void) { // expected-error{{implicit declaration of function 'get_kernel_work_group_size' is invalid in OpenCL}}
return;
});
- size = get_kernel_preferred_work_group_size_multiple(^(void) { // expected-warning{{implicit declaration of function 'get_kernel_preferred_work_group_size_multiple' is invalid in C99}}
+ size = get_kernel_preferred_work_group_size_multiple(^(void) { // expected-error{{implicit declaration of function 'get_kernel_preferred_work_group_size_multiple' is invalid in OpenCL}}
return;
});
}
@@ -18,27 +18,48 @@ kernel void dse_builtins() {
void pipe_builtins() {
int tmp;
- read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'read_pipe' is invalid in C99}}
- write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'write_pipe' is invalid in C99}}
-
- reserve_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'reserve_read_pipe' is invalid in C99}}
- reserve_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'reserve_write_pipe' is invalid in C99}}
-
- work_group_reserve_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'work_group_reserve_read_pipe' is invalid in C99}}
- work_group_reserve_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'work_group_reserve_write_pipe' is invalid in C99}}
-
- sub_group_reserve_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'sub_group_reserve_write_pipe' is invalid in C99}}
- sub_group_reserve_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'sub_group_reserve_read_pipe' is invalid in C99}}
-
- commit_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'commit_read_pipe' is invalid in C99}}
- commit_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'commit_write_pipe' is invalid in C99}}
-
- work_group_commit_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'work_group_commit_read_pipe' is invalid in C99}}
- work_group_commit_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'work_group_commit_write_pipe' is invalid in C99}}
-
- sub_group_commit_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'sub_group_commit_write_pipe' is invalid in C99}}
- sub_group_commit_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'sub_group_commit_read_pipe' is invalid in C99}}
-
- get_pipe_num_packets(tmp); // expected-warning{{implicit declaration of function 'get_pipe_num_packets' is invalid in C99}}
- get_pipe_max_packets(tmp); // expected-warning{{implicit declaration of function 'get_pipe_max_packets' is invalid in C99}}
+ foo(void); // expected-error{{implicit declaration of function 'foo' is invalid in OpenCL}}
+ // expected-note at -1{{'foo' declared here}}
+ // expected-error at -2{{expected expression}}
+ boo(); // expected-error{{implicit declaration of function 'boo' is invalid in OpenCL}}
+ // expected-note at -1{{did you mean 'foo'?}}
+
+ read_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'read_pipe' is invalid in OpenCL}}
+ write_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'write_pipe' is invalid in OpenCL}}
+
+ reserve_read_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'reserve_read_pipe' is invalid in OpenCL}}
+ // expected-note at -1{{'reserve_read_pipe' declared here}}
+ reserve_write_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'reserve_write_pipe' is invalid in OpenCL}}
+ // expected-note at -1{{did you mean 'reserve_read_pipe'?}}
+
+ work_group_reserve_read_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'work_group_reserve_read_pipe' is invalid in OpenCL}}
+ // expected-note at -1 2{{'work_group_reserve_read_pipe' declared here}}
+ work_group_reserve_write_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'work_group_reserve_write_pipe' is invalid in OpenCL}}
+ // expected-note at -1{{did you mean 'work_group_reserve_read_pipe'?}}
+ // expected-note at -2{{'work_group_reserve_write_pipe' declared here}}
+
+ sub_group_reserve_write_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'sub_group_reserve_write_pipe' is invalid in OpenCL}}
+ // expected-note at -1{{did you mean 'work_group_reserve_write_pipe'?}}
+ sub_group_reserve_read_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'sub_group_reserve_read_pipe' is invalid in OpenCL}}
+
+ commit_read_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'commit_read_pipe' is invalid in OpenCL}}
+ // expected-note at -1{{'commit_read_pipe' declared here}}
+ commit_write_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'commit_write_pipe' is invalid in OpenCL}}
+ // expected-note at -1{{did you mean 'commit_read_pipe'?}}
+
+ work_group_commit_read_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'work_group_commit_read_pipe' is invalid in OpenCL}}
+ // expected-note at -1{{'work_group_commit_read_pipe' declared here}}
+ // expected-note at -2{{did you mean 'work_group_reserve_read_pipe'?}}
+ work_group_commit_write_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'work_group_commit_write_pipe' is invalid in OpenCL}}
+ // expected-note at -1{{'work_group_commit_write_pipe' declared here}}
+ // expected-note at -2{{did you mean 'work_group_commit_read_pipe'?}}
+
+ sub_group_commit_write_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'sub_group_commit_write_pipe' is invalid in OpenCL}}
+ // expected-note at -1{{did you mean 'work_group_commit_write_pipe'?}}
+ sub_group_commit_read_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'sub_group_commit_read_pipe' is invalid in OpenCL}}
+
+ get_pipe_num_packets(tmp); // expected-error{{implicit declaration of function 'get_pipe_num_packets' is invalid in OpenCL}}
+ // expected-note at -1{{'get_pipe_num_packets' declared here}}
+ get_pipe_max_packets(tmp); // expected-error{{implicit declaration of function 'get_pipe_max_packets' is invalid in OpenCL}}
+ // expected-note at -1{{did you mean 'get_pipe_num_packets'?}}
}
Modified: cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl?rev=304193&r1=304192&r2=304193&view=diff
==============================================================================
--- cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl (original)
+++ cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl Tue May 30 00:57:52 2017
@@ -10,7 +10,7 @@ void test(void) {
glob = to_global(glob, loc);
#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
- // expected-warning at -2{{implicit declaration of function 'to_global' is invalid in C99}}
+ // expected-error at -2{{implicit declaration of function 'to_global' is invalid in OpenCL}}
// expected-warning at -3{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
#else
// expected-error at -5{{invalid number of arguments to function: 'to_global'}}
More information about the cfe-commits
mailing list