Skip to content

Commit a4f2182

Browse files
[SYCL] Allow use of function declarators with empty parentheses (#1994)
Treat foo() function as foo(void) instead of a no-prototype function when code is compiled for SYCL devices.
1 parent 2bd5dab commit a4f2182

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

clang/lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6391,8 +6391,8 @@ void Parser::ParseFunctionDeclarator(Declarator &D,
63916391
else if (RequiresArg)
63926392
Diag(Tok, diag::err_argument_required_after_attribute);
63936393

6394-
HasProto = ParamInfo.size() || getLangOpts().CPlusPlus
6395-
|| getLangOpts().OpenCL;
6394+
HasProto = ParamInfo.size() || getLangOpts().CPlusPlus ||
6395+
getLangOpts().OpenCL || getLangOpts().SYCLIsDevice;
63966396

63976397
// If we have the closing ')', eat it.
63986398
Tracker.consumeClose();

clang/lib/Sema/SemaType.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5083,8 +5083,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
50835083
FunctionType::ExtInfo EI(
50845084
getCCForDeclaratorChunk(S, D, DeclType.getAttrs(), FTI, chunkIndex));
50855085

5086-
if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus
5087-
&& !LangOpts.OpenCL) {
5086+
if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus &&
5087+
!LangOpts.OpenCL && !LangOpts.SYCLIsDevice) {
50885088
// Simple void foo(), where the incoming T is the result type.
50895089
T = Context.getFunctionNoProtoType(T, EI);
50905090
} else {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm -verify %s
2+
// expected-no-diagnostics
3+
int foo();

0 commit comments

Comments
 (0)