summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorAlexey Bader <alexey.bader@intel.com>2017-06-29 08:44:10 +0000
committerAlexey Bader <alexey.bader@intel.com>2017-06-29 08:44:10 +0000
commit3d0c97883a2a1aa246b90de4dfce9f62023310fa (patch)
treef363eafb474d825019c5fc1d27b3cd197933664b /clang
parent82090a7d299cbb8ed744d8c75610e309e3f77310 (diff)
downloadbcm5719-llvm-3d0c97883a2a1aa246b90de4dfce9f62023310fa.tar.gz
bcm5719-llvm-3d0c97883a2a1aa246b90de4dfce9f62023310fa.zip
[OpenCL] Allow function declaration with empty argument list.
Summary: does it make sense to enable K&R function declaration style for OpenCL? clang throws following error message for the declaration w/o arguments: ``` int my_func(); error: function with no prototype cannot use the spir_function calling convention ``` Current way to fix this issue is to specify that parameter list is empty by using 'void': ``` int my_func(void); ``` Let me know what do you think about this patch. Reviewers: Anastasia, yaxunl Reviewed By: Anastasia Subscribers: cfe-commits, echuraev Differential Revision: https://reviews.llvm.org/D33681 llvm-svn: 306653
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaType.cpp2
-rw-r--r--clang/test/SemaOpenCL/function-no-args.cl9
-rw-r--r--clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl2
3 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 8c8402e75e3..465e8d146dd 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -4355,7 +4355,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex));
- if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) {
+ if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus && !LangOpts.OpenCL) {
// Simple void foo(), where the incoming T is the result type.
T = Context.getFunctionNoProtoType(T, EI);
} else {
diff --git a/clang/test/SemaOpenCL/function-no-args.cl b/clang/test/SemaOpenCL/function-no-args.cl
new file mode 100644
index 00000000000..12070a58580
--- /dev/null
+++ b/clang/test/SemaOpenCL/function-no-args.cl
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s
+// expected-no-diagnostics
+
+global int gi;
+int my_func();
+int my_func() {
+ gi = 2;
+ return gi;
+}
diff --git a/clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl b/clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
index a50811650d2..463fd3d0dab 100644
--- a/clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ b/clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -3,7 +3,7 @@
global pipe int gp; // expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
global reserve_id_t rid; // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}
-extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int ()' can only be used as a function parameter in OpenCL}}
+extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int (void)' can only be used as a function parameter in OpenCL}}
kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error {{'reserve_id_t' cannot be used as the type of a kernel parameter}}
}
OpenPOWER on IntegriCloud