Skip to content

[SYCL] Allow use of function declarators with empty parentheses while trying to compile code for SYCL devices #1994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 7, 2020
Merged
4 changes: 2 additions & 2 deletions clang/lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6539,8 +6539,8 @@ void Parser::ParseFunctionDeclarator(Declarator &D,
else if (RequiresArg)
Diag(Tok, diag::err_argument_required_after_attribute);

HasProto = ParamInfo.size() || getLangOpts().CPlusPlus
|| getLangOpts().OpenCL;
HasProto = ParamInfo.size() || getLangOpts().CPlusPlus ||
getLangOpts().OpenCL || getLangOpts().SYCLIsDevice;

// If we have the closing ')', eat it.
Tracker.consumeClose();
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5078,8 +5078,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
FunctionType::ExtInfo EI(
getCCForDeclaratorChunk(S, D, DeclType.getAttrs(), FTI, chunkIndex));

if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus
&& !LangOpts.OpenCL) {
if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus &&
!LangOpts.OpenCL && !LangOpts.SYCLIsDevice) {
// Simple void foo(), where the incoming T is the result type.
T = Context.getFunctionNoProtoType(T, EI);
} else {
Expand Down
3 changes: 3 additions & 0 deletions clang/test/SemaSYCL/no-prototype-func.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm -verify %s
// expected-no-diagnostics
int foo();