[clang] [NFC][clang][Driver] Add tests for --driver-mode=flang (PR #207658)

Tarun Prabhu via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 14 06:38:55 PDT 2026


================
@@ -5,3 +5,10 @@
 ! CHECK-SYNTAX-ONLY: "{{[^"]*}}/Inputs/one.f90"
 ! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}clang{{[^"/]*}}" "-cc1"
 ! CHECK-SYNTAX-ONLY: "{{[^"]*}}/Inputs/other.c"
+
+! RUN: not %clang --driver-mode=flang -### -Xflang -std=f2018 %S/Inputs/one.f90 -Xclang -std=c17 %S/Inputs/other.c 2>&1 | FileCheck --check-prefixes=MIXED-OPT %s
+! MIXED-OPT: clang: error: unknown argument '-Xclang'
+! MIXED-OPT-NOT: "{{[^"]*}}flang{{[^"/]*}}" "-fc1"
+! MIXED-OPT-NOT: "-std=f2018"
+! MIXED-OPT-NOT: "{{[^"]*}}clang{{[^"/]*}}" "-cc1"
+! MIXED-OPT-NOT: "-std=c17"
----------------
tarunprabhu wrote:

>> Are you saying that you want to make sure that, the flang-only options make it to the -fc1 invocation, but not to the -cc1 invocation?
>
> My apologies for confusing you. Yes, that is what I'm saying.

That sounds like a different test. It's probably one that's worth having. 

But the one you have here errors out if `-Xclang` is passed when `--driver-mode=flang`. This is a good test too, and it is sufficient to check for the error message in this case.

My recommendation would be to check only for the error with the test you have. It would be good to have a separate test to check that the options are forwarded to the correct underlying compiler.

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


More information about the cfe-commits mailing list