Skip to content

Commit

Permalink
[Driver][SYCL] Adjust default setting implementation
Browse files Browse the repository at this point in the history
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 <michael.d.toguchi@intel.com>
  • Loading branch information
mdtoguchi committed May 14, 2020
1 parent 23aeaad commit 28a2dcf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 9 additions & 8 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5078,13 +5078,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
options::OPT_fno_trigraphs))
if (A != Std)
A->render(Args, CmdArgs);
} else if (IsSYCL && types::isCXX(InputType)) {
// For DPC++, we default to -std=c++17 for all compilations. Use of -std
// on the command line will override.
CmdArgs.push_back("-std=c++17");

Args.AddLastArg(CmdArgs, options::OPT_ftrigraphs,
options::OPT_fno_trigraphs);
} else {
// Honor -std-default.
//
Expand All @@ -5097,6 +5090,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
/*Joined=*/true);
else if (IsWindowsMSVC)
ImplyVCPPCXXVer = true;
else if (IsSYCL)
// For DPC++, we default to -std=c++17 for all compilations. Use of -std
// on the command line will override.
CmdArgs.push_back("-std=c++17");

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

if (LanguageStandard.empty()) {
if (IsMSVC2015Compatible)
LanguageStandard = "-std=c++14";
if (IsSYCL)
// For DPC++, C++17 is the default.
LanguageStandard = "-std=c++17";
else
LanguageStandard = "-std=c++14";
else
LanguageStandard = "-std=c++11";
}
Expand Down
6 changes: 6 additions & 0 deletions clang/test/Driver/sycl-offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,5 +821,11 @@
// CHECK-STD: clang{{.*}} "-fsyntax-only" {{.*}} "-std=c++17"
// CHECK-STD: clang{{.*}} "-emit-obj" {{.*}} "-std=c++17"

// -std=c++17 override check
// RUN: %clangxx -### -c -fsycl -std=c++14 -xc++ %s 2>&1 | FileCheck -check-prefix=CHECK-STD-OVR %s
// RUN: %clang_cl -### -c -fsycl /std:c++14 -TP %s 2>&1 | FileCheck -check-prefix=CHECK-STD-OVR %s
// CHECK-STD-OVR: clang{{.*}} "-std=c++14"
// CHECK-STD-OVR-NOT: clang{{.*}} "-std=c++17"

// TODO: SYCL specific fail - analyze and enable
// XFAIL: windows-msvc

0 comments on commit 28a2dcf

Please sign in to comment.