[clang] [SYCL] Error on C inputs when compiling with -fsycl (PR #200318)

Srividya Sundaram via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 6 17:05:18 PDT 2026


================
@@ -0,0 +1,7 @@
+// Verify that a .c file compiled with -fsycl is an error.
+// RUN: not %clang -### -fsycl %s 2>&1 | FileCheck -check-prefix ERR %s
+// ERR: error: invalid argument '{{.*}}sycl-c-warn.c' not allowed with '-fsycl'
+
+// Verify that explicitly forcing -x c with -fsycl is also an error.
----------------
srividya-sundaram wrote:

I moved the C-input rejection into the frontend based on the feedback. But that caused a handful of existing tests to fail.

I looked through the failures and none of them are actually testing C-language behavior. Most are using .c files for historical reasons. I fixed most of them by adding `-x c++`.

The two tricky cases are `SemaSPIRV/BuiltIns/ids_and_ranges.c` and `SemaSPIRV/BuiltIns/subgroup-errors.c`. 

These are SPIR-V builtin tests that seem to use `-fsycl-is-device` mainly as a convenient way to get a SPIR-V compilation environment. They already have equivalent `-x cl` RUN lines that exercise the same builtins.

Adding `-x c++` to the `-fsycl-is-device` RUN lines changes the diagnostics because the existing // expected-error annotations were written against C-mode diagnostics, which differ from C++ mode.

Can we just remove the `-fsycl-is-device` RUN lines from those two tests given the `-x cl` lines already cover the same SPIRV builtin validation or
Or keep `-fsycl-is-device` but add `-x c++` and update the expected diagnostics to the correct C++ wording?

https://github.com/llvm/llvm-project/pull/200318


More information about the cfe-commits mailing list