diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 859d8a73e9d48..2b99cc35e0f1d 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -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") diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 923b61cc0e61b..c46948ba79cdd 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8628,11 +8628,6 @@ def fsycl_is_native_cpu : Flag<["-"], "fsycl-is-native-cpu">, HelpText<"Perform device compilation for Native CPU.">, Visibility<[CC1Option]>, MarshallingInfoFlag>; -defm sycl_allow_all_features_in_constexpr - : BoolFOption< - "sycl-allow-all-features-in-constexpr", LangOpts<"SYCLAllowAllFeaturesInConstexpr">, - DefaultFalse, - PosFlag, NegFlag>; } // let Visibility = [CC1Option] diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index ceb89c52c985a..3a9533940f14d 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -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(D)) @@ -1850,7 +1850,7 @@ class DeferredDiagnosticsEmitter } void VisitConstantExpr(ConstantExpr *E) { - if (S.getLangOpts().SYCLAllowAllFeaturesInConstexpr) + if (S.getLangOpts().SYCLIsDevice) return; this->VisitStmt(E); } @@ -2264,7 +2264,7 @@ void Sema::checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) { CheckType(Ty); if (const auto *FD = dyn_cast_if_present(D)) { - if (LangOpts.SYCLAllowAllFeaturesInConstexpr && FD->isConsteval()) + if (LangOpts.SYCLIsDevice && FD->isConsteval()) return; if (const auto *FPTy = dyn_cast(Ty)) { for (const auto &ParamTy : FPTy->param_types()) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 1f2e3c1b93b90..bf72b9eedec18 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -18418,7 +18418,7 @@ void Sema::ActOnCXXEnterDeclInitializer(Scope *S, Decl *D) { if (auto *VD = dyn_cast(D); VD && (VD->mightBeUsableInConstantExpressions(Context))) - InConstexprVarInit = LangOpts.SYCLAllowAllFeaturesInConstexpr; + InConstexprVarInit = true; PushExpressionEvaluationContext( ExpressionEvaluationContext::PotentiallyEvaluated, D); } diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp index 99d9cbe1f4f60..9150ece385879 100644 --- a/clang/lib/Sema/SemaSYCL.cpp +++ b/clang/lib/Sema/SemaSYCL.cpp @@ -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(); } @@ -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) { diff --git a/clang/test/SemaSYCL/allow-all-features-in-constexpr.cpp b/clang/test/SemaSYCL/allow-all-features-in-constexpr.cpp index 5ba237e8401d1..6b76837b1dae5 100644 --- a/clang/test/SemaSYCL/allow-all-features-in-constexpr.cpp +++ b/clang/test/SemaSYCL/allow-all-features-in-constexpr.cpp @@ -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. diff --git a/clang/test/SemaSYCL/wrong-address-taking.cpp b/clang/test/SemaSYCL/wrong-address-taking.cpp index 90bcbd9291126..0e7547cc3aa16 100644 --- a/clang/test/SemaSYCL/wrong-address-taking.cpp +++ b/clang/test/SemaSYCL/wrong-address-taking.cpp @@ -50,7 +50,6 @@ template 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'}} templateCaller1(1); } @@ -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(); @@ -125,8 +122,7 @@ int main() { templateCaller1(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(1); }); });