================
@@ -5,3 +5,22 @@
 ! 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 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"
----------------
tarunprabhu wrote:

The `-std=c17` being passed to `-fc1` is behavior that should be fixed, 
correct? If so, please add a comment indicating that this is something that 
ought to be fixed. If you can, please also open an issue.

nit: I'd suggest grouping the two tests just so it is easier to see which is 
which.

```suggestion
! 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: "-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'
```

https://github.com/llvm/llvm-project/pull/207658
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to