[clang] [llvm] Enable fexec-charset option (PR #138895)

Hubert Tong via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 16 16:55:02 PDT 2025


================
@@ -217,8 +217,14 @@
 // RUN: not %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s
 // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1'
 
-// RUN: not %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
-// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1'
+// RUN: %clang -### -S -fexec-charset=invalid-charset -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
+// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'invalid-charset' in '-fexec-charset=invalid-charset'
+
+// Test that we support the following exec charsets.
+// RUN: %clang -### -S -fexec-charset=UTF-8 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: %clang -### -S -fexec-charset=ISO8859-1 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: %clang -### -S -fexec-charset=IBM-1047 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// INVALID-NOT: error: invalid value
----------------
hubert-reinterpretcast wrote:

On top of fixing the FileCheck prefixes to be more correct/descriptive, actually check the non-error cases for the `-cc1` invocation (and expect an error return code for the error case).

Additionally, test with the preferred MIME names.

```suggestion
// RUN: not %clang -### -S -fexec-charset=invalid-charset -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-EXEC-CHARSET %s
// CHECK-INVALID-EXEC-CHARSET: error: invalid value 'invalid-charset' in '-fexec-charset=invalid-charset'

// Test that we support the following exec charsets. The preferred MIME name is
// `IBM1047`, but `IBM-1047` is the name used by z/OS USS utilities such as
// `chtag`.
// RUN: %clang -### -S -fexec-charset=UTF-8 -o /dev/null %s 2>&1 | FileCheck --check-prefix=CHECK-EXEC-CHARSET-UTF-8 %s
// RUN: %clang -### -S -fexec-charset=ISO-8859-1 -o /dev/null %s 2>&1 | FileCheck --check-prefix=CHECK-EXEC-CHARSET-ISO-8859-1 %s
// RUN: %clang -### -S -fexec-charset=IBM-1047 -o /dev/null %s 2>&1 | FileCheck --check-prefix=CHECK-EXEC-CHARSET-IBM-1047 %s
// RUN: %clang -### -S -fexec-charset=IBM1047 -o /dev/null %s 2>&1 | FileCheck --check-prefix=CHECK-EXEC-CHARSET-IBM1047 %s
// CHECK-EXEC-CHARSET-UTF-8: "-fexec-charset" "UTF-8"
// CHECK-EXEC-CHARSET-ISO-8859-1: "-fexec-charset" "ISO-8859-1"
// CHECK-EXEC-CHARSET-IBM-1047: "-fexec-charset" "IBM-1047"
// CHECK-EXEC-CHARSET-IBM1047: "-fexec-charset" "IBM1047"
```

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


More information about the cfe-commits mailing list