Skip to content

Commit 0624465

Browse files
[SYCL][Driver] Emit an error when PCH is triggered in SYCL mode. (#9689)
Emit an error if PCH(Pre-Compiled Header) file generation is forced in -fsycl mode. --------- Co-authored-by: premanandrao <[email protected]>
1 parent c9219ce commit 0624465

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ def err_drv_expecting_fsycl_with_sycl_opt : Error<
360360
"'%0' must be used in conjunction with '-fsycl' to enable offloading">;
361361
def err_drv_fsycl_with_c_type : Error<
362362
"'%0' must not be used in conjunction with '-fsycl', which expects C++ source">;
363+
def err_drv_fsycl_with_pch : Error<
364+
"Precompiled header generation is not supported with '-fsycl'">;
363365
def err_drv_fsycl_unsupported_with_opt
364366
: Error<"'%0' is not supported with '-fsycl'">;
365367
def err_drv_sycl_missing_amdgpu_arch : Error<

clang/lib/Driver/Driver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9252,6 +9252,11 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
92529252
}
92539253
}
92549254

9255+
// Emit an error if PCH(Pre-Compiled Header) file generation is forced in
9256+
// -fsycl mode.
9257+
if (C.getArgs().hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false) &&
9258+
JA.getType() == types::TY_PCH)
9259+
Diag(clang::diag::err_drv_fsycl_with_pch);
92559260
// As an annoying special case, PCH generation doesn't strip the pathname.
92569261
if (JA.getType() == types::TY_PCH && !IsCLMode()) {
92579262
llvm::sys::path::remove_filename(BasePath);

clang/test/Driver/pch-fsycl-error.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// This test checks that an error is emitted when
2+
// PCH(Precompiled Header) file generation is forced in -fsycl mode.
3+
4+
// RUN: touch %t.h
5+
6+
// Linux
7+
// RUN: %clang -c -fsycl -x c++-header %t.h -### %s 2> %t1.txt
8+
// RUN: FileCheck %s -input-file=%t1.txt
9+
// CHECK: Precompiled header generation is not supported with '-fsycl'
10+
11+
// Windows
12+
// RUN: %clang_cl -c -fsycl -x c++-header %t.h -### -- %s 2>&1 \
13+
// RUN: | FileCheck -check-prefix=CHECK-ERROR %s
14+
// CHECK-ERROR: Precompiled header generation is not supported with '-fsycl'
15+
16+
// /Yc
17+
// RUN: %clang_cl -fsycl /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
18+
// RUN: | FileCheck -check-prefix=CHECK-YC %s
19+
// CHECK-YC: Precompiled header generation is not supported with '-fsycl'

0 commit comments

Comments
 (0)