summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Bader <alexey.bader@intel.com>2017-10-11 11:16:31 +0000
committerAlexey Bader <alexey.bader@intel.com>2017-10-11 11:16:31 +0000
commit1f2779407e7f042ae853674f9db067263bed49bd (patch)
treed8db9bfc0cbff22d90bd707c906b9f488cdc8812
parent19d7299a8b51f62c6a3dfd91ac4bc5258db860ac (diff)
downloadbcm5719-llvm-1f2779407e7f042ae853674f9db067263bed49bd.tar.gz
bcm5719-llvm-1f2779407e7f042ae853674f9db067263bed49bd.zip
[OpenCL] Allow function declaration with empty argument list.
Treat 'f()' as 'f(void)' rather than a function w/o a prototype. Reviewers: Anastasia, yaxunl Reviewed By: Anastasia, yaxunl Subscribers: cfe-commits, echuraev, chapuni Differential Revision: https://reviews.llvm.org/D33681 Re-apply revision 306653. llvm-svn: 315453
-rw-r--r--clang/lib/Parse/ParseDecl.cpp3
-rw-r--r--clang/lib/Sema/SemaType.cpp3
-rw-r--r--clang/test/SemaOpenCL/func.cl5
-rw-r--r--clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl2
4 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 8bca7badea2..098bf9b12d7 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5989,7 +5989,8 @@ void Parser::ParseFunctionDeclarator(Declarator &D,
else if (RequiresArg)
Diag(Tok, diag::err_argument_required_after_attribute);
- HasProto = ParamInfo.size() || getLangOpts().CPlusPlus;
+ HasProto = ParamInfo.size() || getLangOpts().CPlusPlus
+ || getLangOpts().OpenCL;
// If we have the closing ')', eat it.
Tracker.consumeClose();
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index fb3f41ec0f6..8623ab0b218 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -4460,7 +4460,8 @@ 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/func.cl b/clang/test/SemaOpenCL/func.cl
index dc5b44057b1..83c3b4a6bcf 100644
--- a/clang/test/SemaOpenCL/func.cl
+++ b/clang/test/SemaOpenCL/func.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple spir-unknown-unknown
// Variadic functions
void vararg_f(int, ...); // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}}
@@ -16,6 +16,9 @@ typedef struct s
//Function pointer
void foo(void*);
+// Expect no diagnostics for an empty parameter list.
+void bar();
+
void bar()
{
// declaring a function pointer is an error
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