https://github.com/yus3710-fj updated https://github.com/llvm/llvm-project/pull/207658
>From 8bc4dcbfbb148733cede4e395240c7cf9e2cd261 Mon Sep 17 00:00:00 2001 From: Yusuke MINATO <[email protected]> Date: Fri, 26 Jun 2026 13:08:04 +0900 Subject: [PATCH 1/6] [NFC][clang] Add tests for --driver-mode=flang This patch intends to clarify the current behaviors, not to state the expected/desirable behaviors. --- clang/test/Driver/flang/multiple-inputs-mixed.f90 | 7 +++++++ clang/test/Driver/flang/runtimes.f90 | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 clang/test/Driver/flang/runtimes.f90 diff --git a/clang/test/Driver/flang/multiple-inputs-mixed.f90 b/clang/test/Driver/flang/multiple-inputs-mixed.f90 index 98d8cab00bdfd..25321cd1fcf02 100644 --- a/clang/test/Driver/flang/multiple-inputs-mixed.f90 +++ b/clang/test/Driver/flang/multiple-inputs-mixed.f90 @@ -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" diff --git a/clang/test/Driver/flang/runtimes.f90 b/clang/test/Driver/flang/runtimes.f90 new file mode 100644 index 0000000000000..7300bba75e2da --- /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: clang: error: unknown argument: '-stdlib=libc++' >From 93ef4e5648e8588fab5002d37dbd0acfd1c1d7ca Mon Sep 17 00:00:00 2001 From: Yusuke MINATO <[email protected]> Date: Wed, 15 Jul 2026 12:10:37 +0900 Subject: [PATCH 2/6] Add separate tests and comments for them --- .../Driver/flang/multiple-inputs-mixed.f90 | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/clang/test/Driver/flang/multiple-inputs-mixed.f90 b/clang/test/Driver/flang/multiple-inputs-mixed.f90 index 25321cd1fcf02..73259e6454189 100644 --- a/clang/test/Driver/flang/multiple-inputs-mixed.f90 +++ b/clang/test/Driver/flang/multiple-inputs-mixed.f90 @@ -6,9 +6,21 @@ ! 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" +! 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 differ between the two. +! 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-NOT: "{{[^"]*}}clang{{[^"/]*}}" "-cc1" -! MIXED-OPT-NOT: "-std=c17" +! 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: clang: error: unknown argument '-Xclang' >From dd77a781d8d703c192ed780eabfefefbc559a07f Mon Sep 17 00:00:00 2001 From: Yusuke MINATO <[email protected]> Date: Wed, 15 Jul 2026 13:14:25 +0900 Subject: [PATCH 3/6] small improvement for readability --- clang/test/Driver/flang/multiple-inputs-mixed.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/Driver/flang/multiple-inputs-mixed.f90 b/clang/test/Driver/flang/multiple-inputs-mixed.f90 index 73259e6454189..64a1037a14020 100644 --- a/clang/test/Driver/flang/multiple-inputs-mixed.f90 +++ b/clang/test/Driver/flang/multiple-inputs-mixed.f90 @@ -16,11 +16,11 @@ ! The -std= option is accepted by both clang and flang, but its acceptable values differ between the two. ! 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 +! 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: clang: error: unknown argument '-Xclang' ! 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: clang: error: unknown argument '-Xclang' >From eb2fe42ea2fa72729126e7ac678a2ee25c1a6db3 Mon Sep 17 00:00:00 2001 From: Yusuke MINATO <[email protected]> Date: Wed, 15 Jul 2026 19:00:34 +0900 Subject: [PATCH 4/6] remove the check for `clang:` before `error:` --- clang/test/Driver/flang/multiple-inputs-mixed.f90 | 2 +- clang/test/Driver/flang/runtimes.f90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/Driver/flang/multiple-inputs-mixed.f90 b/clang/test/Driver/flang/multiple-inputs-mixed.f90 index 64a1037a14020..6f9d7573e94c9 100644 --- a/clang/test/Driver/flang/multiple-inputs-mixed.f90 +++ b/clang/test/Driver/flang/multiple-inputs-mixed.f90 @@ -17,7 +17,7 @@ ! 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 ! 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: clang: error: unknown argument '-Xclang' +! SEPARATE-MIXED-OPT: error: unknown argument '-Xclang' ! MIXED-OPT-LABEL: "{{[^"]*}}flang{{[^"/]*}}" "-fc1" ! MIXED-OPT: "-std=f2018" ! MIXED-OPT: "-std=c17" diff --git a/clang/test/Driver/flang/runtimes.f90 b/clang/test/Driver/flang/runtimes.f90 index 7300bba75e2da..b979a86c2f7c6 100644 --- a/clang/test/Driver/flang/runtimes.f90 +++ b/clang/test/Driver/flang/runtimes.f90 @@ -5,4 +5,4 @@ ! CHECK-DAG: flang_rt.{{[^ "]}} ! RUN: not %clang --driver-mode=flang -stdlib=libc++ -### %s 2>&1 | FileCheck --check-prefix=LIBCXX %s -! LIBCXX: clang: error: unknown argument: '-stdlib=libc++' +! LIBCXX: error: unknown argument: '-stdlib=libc++' >From 15100daa57a5bdbe1dd0eb10b6dff2ad6e6e081f Mon Sep 17 00:00:00 2001 From: Yusuke MINATO <[email protected]> Date: Wed, 15 Jul 2026 22:39:59 +0900 Subject: [PATCH 5/6] Update clang/test/Driver/flang/multiple-inputs-mixed.f90 Co-authored-by: Tarun Prabhu <[email protected]> --- clang/test/Driver/flang/multiple-inputs-mixed.f90 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/test/Driver/flang/multiple-inputs-mixed.f90 b/clang/test/Driver/flang/multiple-inputs-mixed.f90 index 6f9d7573e94c9..dafa927324276 100644 --- a/clang/test/Driver/flang/multiple-inputs-mixed.f90 +++ b/clang/test/Driver/flang/multiple-inputs-mixed.f90 @@ -15,12 +15,14 @@ ! The -std= option is accepted by both clang and flang, but its acceptable values differ between the two. ! 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 -! 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' ! 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' >From c9cd790b23b310f26130ea79a567679b5636deea Mon Sep 17 00:00:00 2001 From: Yusuke MINATO <[email protected]> Date: Wed, 15 Jul 2026 23:00:05 +0900 Subject: [PATCH 6/6] add a comment about an issue with forwarding `-std=` --- clang/test/Driver/flang/multiple-inputs-mixed.f90 | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/test/Driver/flang/multiple-inputs-mixed.f90 b/clang/test/Driver/flang/multiple-inputs-mixed.f90 index dafa927324276..f6910f3dd9997 100644 --- a/clang/test/Driver/flang/multiple-inputs-mixed.f90 +++ b/clang/test/Driver/flang/multiple-inputs-mixed.f90 @@ -14,6 +14,7 @@ ! CHECK-FLANG-OPT-NOT: "-fstack-arrays" ! The -std= option is accepted by both clang and flang, but its acceptable values differ 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 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
