Skip to content

Commit adda31f

Browse files
authored
[Driver][SYCL] Fix -fsycl-targets validatoin when using -Xsycl-target-frontend (#6025)
We were improperly requiring at least one -fsycl-targets when using -Xsycl-target-*. We should allow no -fsycl-targets is specified when using -Xsycl-target-frontend. Signed-off-by: Qichao Gu <qichao.gu@intel.com>
1 parent 8b3c8c4 commit adda31f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

clang/lib/Driver/ToolChain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ llvm::opt::DerivedArgList *ToolChain::TranslateOffloadTargetArgs(
12861286
// improved upon
12871287
auto SingleTargetTripleCount = [&Args](OptSpecifier Opt) {
12881288
const Arg *TargetArg = Args.getLastArg(Opt);
1289-
if (TargetArg && TargetArg->getValues().size() == 1)
1289+
if (!TargetArg || TargetArg->getValues().size() == 1)
12901290
return true;
12911291
return false;
12921292
};

clang/test/Driver/sycl-offload.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,11 @@
671671
// RUN: | FileCheck -check-prefix=CHK-FSYCL-TARGET-2X-ERROR %s
672672
// CHK-FSYCL-TARGET-2X-ERROR-NOT: clang{{.*}} error: cannot deduce implicit triple value for '-Xsycl-target{{.*}}', specify triple using '-Xsycl-target{{.*}}=<triple>'
673673

674+
/// Check -Xsycl-target-frontend does not trigger an error when no -fsycl-targets is specified
675+
// RUN: %clang -### -fsycl -Xsycl-target-frontend -DFOO %s 2>&1 \
676+
// RUN: | FileCheck -check-prefix=CHK-NO-FSYCL-TARGET-ERROR %s
677+
// CHK-NO-FSYCL-TARGET-ERROR-NOT: clang{{.*}} error: cannot deduce implicit triple value for '-Xsycl-target-frontend', specify triple using '-Xsycl-target-frontend=<triple>'
678+
674679
/// ###########################################################################
675680

676681
/// Ahead of Time compilation for fpga, gen, cpu

0 commit comments

Comments
 (0)