Author: Yusuke MINATO Date: 2026-07-23T11:03:15Z New Revision: d814be1bb794baf0650158a6bd1dda23f4f86e99
URL: https://github.com/llvm/llvm-project/commit/d814be1bb794baf0650158a6bd1dda23f4f86e99 DIFF: https://github.com/llvm/llvm-project/commit/d814be1bb794baf0650158a6bd1dda23f4f86e99.diff LOG: [NFC][clang][Driver] Add tests for --driver-mode=flang (#207658) This patch intends to clarify the current behaviors, not to state the expected/desirable behaviors. --------- Co-authored-by: Tarun Prabhu <[email protected]> Added: clang/test/Driver/flang/runtimes.f90 Modified: clang/test/Driver/flang/multiple-inputs-mixed.f90 Removed: ################################################################################ diff --git a/clang/test/Driver/flang/multiple-inputs-mixed.f90 b/clang/test/Driver/flang/multiple-inputs-mixed.f90 index 98d8cab00bdfd..f6910f3dd9997 100644 --- a/clang/test/Driver/flang/multiple-inputs-mixed.f90 +++ b/clang/test/Driver/flang/multiple-inputs-mixed.f90 @@ -5,3 +5,25 @@ ! CHECK-SYNTAX-ONLY: "{{[^"]*}}/Inputs/one.f90" ! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}clang{{[^"/]*}}" "-cc1" ! CHECK-SYNTAX-ONLY: "{{[^"]*}}/Inputs/other.c" + +! Check that flang-only options are not passed to clang. +! RUN: %clang --driver-mode=flang -### -fstack-arrays %S/Inputs/one.f90 %S/Inputs/other.c 2>&1 | FileCheck --check-prefixes=CHECK-FLANG-OPT %s +! CHECK-FLANG-OPT-LABEL: "{{[^"]*}}flang{{[^"/]*}}" "-fc1" +! CHECK-FLANG-OPT: "-fstack-arrays" +! CHECK-FLANG-OPT-LABEL: "{{[^"]*}}clang{{[^"/]*}}" "-cc1" +! CHECK-FLANG-OPT-NOT: "-fstack-arrays" + +! The -std= option is accepted by both clang and flang, but its acceptable values diff er between the two. +! Currently, -std=c17 is passed to flang, which rejects it. This should be fixed in the future. +! A potential solution is to use -Xflang and -Xclang to pass the option to the right frontend; however, -Xclang is rejected. + +! RUN: %clang --driver-mode=flang -### -std=f2018 %S/Inputs/one.f90 -std=c17 %S/Inputs/other.c 2>&1 | FileCheck --check-prefixes=MIXED-OPT %s +! MIXED-OPT-LABEL: "{{[^"]*}}flang{{[^"/]*}}" "-fc1" +! MIXED-OPT: "-std=f2018" +! MIXED-OPT: "-std=c17" +! MIXED-OPT-LABEL: "{{[^"]*}}clang{{[^"/]*}}" "-cc1" +! MIXED-OPT-NOT: "-std=f2018" +! MIXED-OPT: "-std=c17" + +! 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=SEPARATE-MIXED-OPT %s +! SEPARATE-MIXED-OPT: error: unknown argument '-Xclang' diff --git a/clang/test/Driver/flang/runtimes.f90 b/clang/test/Driver/flang/runtimes.f90 new file mode 100644 index 0000000000000..b979a86c2f7c6 --- /dev/null +++ b/clang/test/Driver/flang/runtimes.f90 @@ -0,0 +1,8 @@ +! Check that Flang runtimes are passed to the linker in --driver-mode=flang. + +! RUN: %clang --driver-mode=flang --rtlib=compiler-rt -### %s 2>&1 | FileCheck %s +! CHECK-DAG: clang_rt.{{[^ "]}} +! CHECK-DAG: flang_rt.{{[^ "]}} + +! RUN: not %clang --driver-mode=flang -stdlib=libc++ -### %s 2>&1 | FileCheck --check-prefix=LIBCXX %s +! LIBCXX: error: unknown argument: '-stdlib=libc++' _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
