Skip to content

Commit 28a2dcf

Browse files
committed
[Driver][SYCL] Adjust default setting implementation
Modify setting implementation to be more inline with existing flow. This also allows for MSVC /std option settings to override. Signed-off-by: Michael D Toguchi <[email protected]>
1 parent 23aeaad commit 28a2dcf

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5078,13 +5078,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
50785078
options::OPT_fno_trigraphs))
50795079
if (A != Std)
50805080
A->render(Args, CmdArgs);
5081-
} else if (IsSYCL && types::isCXX(InputType)) {
5082-
// For DPC++, we default to -std=c++17 for all compilations. Use of -std
5083-
// on the command line will override.
5084-
CmdArgs.push_back("-std=c++17");
5085-
5086-
Args.AddLastArg(CmdArgs, options::OPT_ftrigraphs,
5087-
options::OPT_fno_trigraphs);
50885081
} else {
50895082
// Honor -std-default.
50905083
//
@@ -5097,6 +5090,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
50975090
/*Joined=*/true);
50985091
else if (IsWindowsMSVC)
50995092
ImplyVCPPCXXVer = true;
5093+
else if (IsSYCL)
5094+
// For DPC++, we default to -std=c++17 for all compilations. Use of -std
5095+
// on the command line will override.
5096+
CmdArgs.push_back("-std=c++17");
51005097

51015098
Args.AddLastArg(CmdArgs, options::OPT_ftrigraphs,
51025099
options::OPT_fno_trigraphs);
@@ -5665,7 +5662,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
56655662

56665663
if (LanguageStandard.empty()) {
56675664
if (IsMSVC2015Compatible)
5668-
LanguageStandard = "-std=c++14";
5665+
if (IsSYCL)
5666+
// For DPC++, C++17 is the default.
5667+
LanguageStandard = "-std=c++17";
5668+
else
5669+
LanguageStandard = "-std=c++14";
56695670
else
56705671
LanguageStandard = "-std=c++11";
56715672
}

clang/test/Driver/sycl-offload.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,5 +821,11 @@
821821
// CHECK-STD: clang{{.*}} "-fsyntax-only" {{.*}} "-std=c++17"
822822
// CHECK-STD: clang{{.*}} "-emit-obj" {{.*}} "-std=c++17"
823823

824+
// -std=c++17 override check
825+
// RUN: %clangxx -### -c -fsycl -std=c++14 -xc++ %s 2>&1 | FileCheck -check-prefix=CHECK-STD-OVR %s
826+
// RUN: %clang_cl -### -c -fsycl /std:c++14 -TP %s 2>&1 | FileCheck -check-prefix=CHECK-STD-OVR %s
827+
// CHECK-STD-OVR: clang{{.*}} "-std=c++14"
828+
// CHECK-STD-OVR-NOT: clang{{.*}} "-std=c++17"
829+
824830
// TODO: SYCL specific fail - analyze and enable
825831
// XFAIL: windows-msvc

0 commit comments

Comments
 (0)