Author: Yusuke MINATO
Date: 2026-07-31T09:56:12+09:00
New Revision: 0142992aea1df89fec8c20bf77520e37bfb69e2a

URL: 
https://github.com/llvm/llvm-project/commit/0142992aea1df89fec8c20bf77520e37bfb69e2a
DIFF: 
https://github.com/llvm/llvm-project/commit/0142992aea1df89fec8c20bf77520e37bfb69e2a.diff

LOG: Reapply "[NFC][clang][Driver] Add tests for --driver-mode=flang" (#211724)

This reapplies #207658.

Some targets do not support flang_rt or clang_rt.
It seems difficult to create a blocklist, so the tests are now
configured to explicitly specify the known-working targets.
The specified targets are extracted from tests in flang/test/Driver.

-----
The original commit message:
This patch intends to clarify the current behaviors, not to state the
expected/desirable behaviors.

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..a76d75e05a9c2
--- /dev/null
+++ b/clang/test/Driver/flang/runtimes.f90
@@ -0,0 +1,13 @@
+! Check that Flang runtimes are passed to the linker in --driver-mode=flang.
+
+! RUN: %clang --driver-mode=flang --rtlib=compiler-rt 
--target=x86_64-linux-gnu -### %s 2>&1 | FileCheck %s
+! RUN: %clang --driver-mode=flang --rtlib=compiler-rt 
--target=x86_64-pc-windows-msvc -### %s 2>&1 | FileCheck %s
+! RUN: %clang --driver-mode=flang --rtlib=compiler-rt 
--target=aarch64-linux-none -### %s 2>&1 | FileCheck %s
+! RUN: %clang --driver-mode=flang --rtlib=compiler-rt 
--target=ppc64le-linux-gnu -### %s 2>&1 | FileCheck %s
+! RUN: %clang --driver-mode=flang --rtlib=compiler-rt 
--target=powerpc64-ibm-aix -### %s 2>&1 | FileCheck %s
+! RUN: %clang --driver-mode=flang --rtlib=compiler-rt 
--target=sparc-sun-solaris2.11 -### %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

Reply via email to