Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang/include/clang/Basic/LangOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ LANGOPT(SYCLAllowFuncPtr , 1, 0, "Allow function pointers in SYCL device code")
LANGOPT(SYCLStdLayoutKernelParams, 1, 0, "Enable standard layout requirement for SYCL kernel parameters")
LANGOPT(SYCLUnnamedLambda , 1, 0, "Allow unnamed lambda SYCL kernels")
LANGOPT(SYCLForceInlineKernelLambda , 1, 0, "Force inline SYCL kernel lambdas in entry point")
LANGOPT(SYCLAllowAllFeaturesInConstexpr, 1, 0, "Allow all C++ features in SYCL device code in manifestly constant-evaluated expressions")
LANGOPT(SYCLESIMDForceStatelessMem, 1, 0, "Make accessors use USM memory in ESIMD kernels")
LANGOPT(SYCLESIMDBuildHostCode, 1, 1, "Build the host implementation of ESIMD functions")
ENUM_LANGOPT(SYCLVersion , SYCLMajorVersion, 2, SYCL_None, "Version of the SYCL standard used")
Expand Down
5 changes: 0 additions & 5 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -8628,11 +8628,6 @@ def fsycl_is_native_cpu : Flag<["-"], "fsycl-is-native-cpu">,
HelpText<"Perform device compilation for Native CPU.">,
Visibility<[CC1Option]>,
MarshallingInfoFlag<LangOpts<"SYCLIsNativeCPU">>;
defm sycl_allow_all_features_in_constexpr
: BoolFOption<
"sycl-allow-all-features-in-constexpr", LangOpts<"SYCLAllowAllFeaturesInConstexpr">,
DefaultFalse,
PosFlag<SetTrue, [], [CC1Option], "Allow all C++ features in SYCL device code in manifestly constant-evaluated expressions">, NegFlag<SetFalse>>;

} // let Visibility = [CC1Option]

Expand Down
6 changes: 3 additions & 3 deletions clang/lib/Sema/Sema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ class DeferredDiagnosticsEmitter
}

void VisitDeclStmt(DeclStmt *DS) {
if (S.getLangOpts().SYCLAllowAllFeaturesInConstexpr) {
if (S.getLangOpts().SYCLIsDevice) {
if (DS->isSingleDecl()) {
Decl *D = DS->getSingleDecl();
if (auto *VD = dyn_cast<VarDecl>(D))
Expand All @@ -1850,7 +1850,7 @@ class DeferredDiagnosticsEmitter
}

void VisitConstantExpr(ConstantExpr *E) {
if (S.getLangOpts().SYCLAllowAllFeaturesInConstexpr)
if (S.getLangOpts().SYCLIsDevice)
return;
this->VisitStmt(E);
}
Expand Down Expand Up @@ -2264,7 +2264,7 @@ void Sema::checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) {

CheckType(Ty);
if (const auto *FD = dyn_cast_if_present<FunctionDecl>(D)) {
if (LangOpts.SYCLAllowAllFeaturesInConstexpr && FD->isConsteval())
if (LangOpts.SYCLIsDevice && FD->isConsteval())
return;
if (const auto *FPTy = dyn_cast<FunctionProtoType>(Ty)) {
for (const auto &ParamTy : FPTy->param_types())
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18418,7 +18418,7 @@ void Sema::ActOnCXXEnterDeclInitializer(Scope *S, Decl *D) {

if (auto *VD = dyn_cast<VarDecl>(D);
VD && (VD->mightBeUsableInConstantExpressions(Context)))
InConstexprVarInit = LangOpts.SYCLAllowAllFeaturesInConstexpr;
InConstexprVarInit = true;
PushExpressionEvaluationContext(
ExpressionEvaluationContext::PotentiallyEvaluated, D);
}
Expand Down
11 changes: 4 additions & 7 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,7 @@ class DeviceFunctionTracker {

public:
DeviceFunctionTracker(SemaSYCL &S) : SemaSYCLRef(S) {
if (S.getLangOpts().SYCLAllowAllFeaturesInConstexpr)
CG.setSkipConstantExpressions(S.getASTContext());
CG.setSkipConstantExpressions(S.getASTContext());
CG.addToCallGraph(S.getASTContext().getTranslationUnitDecl());
CollectSyclExternalFuncs();
}
Expand Down Expand Up @@ -5594,14 +5593,12 @@ SemaSYCL::DiagIfDeviceCode(SourceLocation Loc, unsigned DiagID,
return SemaDiagnosticBuilder::K_ImmediateWithCallStack;
if (!FD)
return SemaDiagnosticBuilder::K_Nop;
if (SemaRef.getLangOpts().SYCLAllowAllFeaturesInConstexpr &&
(SemaRef.isConstantEvaluatedContext() ||
SemaRef.currentEvaluationContext().isDiscardedStatementContext()))
if (SemaRef.isConstantEvaluatedContext() ||
SemaRef.currentEvaluationContext().isDiscardedStatementContext())
return SemaDiagnosticBuilder::K_Nop;
// Defer until we know that the variable's intializer is actually a
// manifestly constant-evaluated expression.
if (SemaRef.getLangOpts().SYCLAllowAllFeaturesInConstexpr &&
SemaRef.InConstexprVarInit)
if (SemaRef.InConstexprVarInit)
return SemaDiagnosticBuilder::K_Deferred;
if (SemaRef.getEmissionStatus(FD) ==
Sema::FunctionEmissionStatus::Emitted) {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaSYCL/allow-all-features-in-constexpr.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -fcxx-exceptions -verify -fsyntax-only -std=c++23 -triple spir64 -aux-triple x86_64 -fsycl-allow-all-features-in-constexpr %s
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -fcxx-exceptions -verify -fsyntax-only -std=c++23 -triple spir64 -aux-triple x86_64 %s

// The test checks that all SYCL device code limitations are lifted in
// manifestly constant-evaluated expressions under an option.
Expand Down
6 changes: 1 addition & 5 deletions clang/test/SemaSYCL/wrong-address-taking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ template <typename T> void templatedContext() {
// expected-error@+1 {{taking address of a function not marked with 'intel::device_indirectly_callable' attribute is not allowed in SYCL device code}}
auto p1 = &ForMembers::badMember;

// expected-error@+2 {{taking address of a function not marked with 'intel::device_indirectly_callable' attribute is not allowed in SYCL device code}}
// expected-note@+1 {{called by 'templatedContext<int>'}}
templateCaller1<badFoo>(1);
}
Expand Down Expand Up @@ -84,9 +83,7 @@ int main() {
a = goodFoo;
a = &goodFoo;

// expected-error@+1 {{taking address of a function not marked with 'intel::device_indirectly_callable' attribute is not allowed in SYCL device code}}
constexpr auto b = badFoo;
// expected-error@+1 {{taking address of a function not marked with 'intel::device_indirectly_callable' attribute is not allowed in SYCL device code}}
constexpr auto c = &badFoo;
// expected-note@+1 {{called by 'operator()'}}
basicUsage();
Expand Down Expand Up @@ -125,8 +122,7 @@ int main() {

templateCaller1<goodFoo>(1);

// expected-note@+2 {{called by 'operator()'}}
// expected-error@+1 {{taking address of a function not marked with 'intel::device_indirectly_callable' attribute is not allowed in SYCL device code}}
// expected-note@+1 {{called by 'operator()'}}
templateCaller1<badFoo>(1);
});
});
Expand Down
Loading