Skip to content

[flang] Complete alignment of -x language modes with gfortran #133775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang/include/clang/Driver/Types.def
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ TYPE("assembler-with-cpp", Asm, PP_Asm, "S", phases
// modules when Flang needs to emit pre-processed files. Therefore, the
// `PP_TYPE` is set to `PP_Fortran` so that the driver is fine with
// "pre-processing a pre-processed file".
TYPE("f95", PP_Fortran, PP_Fortran, "i", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: In this line and the next could we try to preserve the "column" alignment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll post that tomorrow in the hope that the build bots have calmed down by then, since precommit seems to be failing for everyone atm

TYPE("f95-cpp-input", Fortran, PP_Fortran, nullptr, phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("f95", Fortran, PP_Fortran, nullptr, phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("f95-cpp-input", PP_Fortran, PP_Fortran, "i", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("java", Java, INVALID, nullptr, phases::Compile, phases::Backend, phases::Assemble, phases::Link)

// LLVM IR/LTO types. We define separate types for IR and LTO because LTO
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Driver/fortran.f95
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
! RUN: | FileCheck --check-prefix=CHECK-OBJECT %s
! CHECK-OBJECT: gcc
! CHECK-OBJECT: "-c"
! CHECK-OBJECT: "-x" "f95"
! CHECK-OBJECT: "-x" "f95-cpp-input"
! CHECK-OBJECT-NOT: "-cc1as"

! RUN: %clang --target=x86_64-unknown-linux-gnu -integrated-as -S %s -### 2>&1 \
! RUN: | FileCheck --check-prefix=CHECK-ASM %s
! CHECK-ASM: gcc
! CHECK-ASM: "-S"
! CHECK-ASM: "-x" "f95"
! CHECK-ASM: "-x" "f95-cpp-input"
! CHECK-ASM-NOT: "-cc1"

! RUN: %clang -Wall --target=x86_64-unknown-linux-gnu -integrated-as %s -### 2>&1 | FileCheck --check-prefix=CHECK-WARN %s
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Driver/input-from-stdin/input-from-stdin.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
! Input type is implicit
! RUN: cat %s | %flang -E -cpp - | FileCheck %s --check-prefix=PP-NOT-DEFINED
! RUN: cat %s | %flang -DNEW -E -cpp - | FileCheck %s --check-prefix=PP-DEFINED
! RUN: cat %s | %flang -DNEW -E - | FileCheck %s --check-prefix=PP-DEFINED
! RUN: cat %s | %flang -DNEW -E - | FileCheck %s --check-prefix=PP-NOT-DEFINED
! RUN: cat %s | %flang -DNEW -E -nocpp - | FileCheck %s --check-prefix=PP-NOT-DEFINED

! Input type is explicit
Expand Down
12 changes: 6 additions & 6 deletions flang/test/Driver/phases.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
! RUN: %flang -fsyntax-only -ccc-print-phases %s 2>&1 | FileCheck %s --check-prefix=COMPILE
! RUN: %flang -c -ccc-print-phases %s 2>&1 | FileCheck %s --check-prefix=EMIT_OBJ

! PP: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
! PP-NEXT: 1: preprocessor, {0}, f95
! PP: +- 0: input, "{{.*}}phases.f90", f95
! PP-NEXT: 1: preprocessor, {0}, f95-cpp-input

! COMPILE: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
! COMPILE-NEXT: 1: preprocessor, {0}, f95
! COMPILE: +- 0: input, "{{.*}}phases.f90", f95
! COMPILE-NEXT: 1: preprocessor, {0}, f95-cpp-input
! COMPILE-NEXT: 2: compiler, {1}, none

! EMIT_OBJ: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
! EMIT_OBJ-NEXT: 1: preprocessor, {0}, f95
! EMIT_OBJ: +- 0: input, "{{.*}}phases.f90", f95
! EMIT_OBJ-NEXT: 1: preprocessor, {0}, f95-cpp-input
! EMIT_OBJ-NEXT: 2: compiler, {1}, ir
! EMIT_OBJ-NEXT: +- 3: backend, {2}, assembler
! EMIT_OBJ-NEXT: 4: assembler, {3}, object
16 changes: 8 additions & 8 deletions flang/test/Driver/pp-fixed-form.f90
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
!RUN: %flang -save-temps -### %S/Inputs/free-form-test.f90 2>&1 | FileCheck %s --check-prefix=FREE
FREE: "-fc1" {{.*}} "-o" "free-form-test.i" {{.*}} "-x" "f95-cpp-input" "{{.*}}/free-form-test.f90"
FREE-NEXT: "-fc1" {{.*}} "-ffixed-form" {{.*}} "-x" "f95" "free-form-test.i"
FREE: "-fc1" {{.*}} "-o" "free-form-test.i" {{.*}} "-x" "f95" "{{.*}}/free-form-test.f90"
FREE-NEXT: "-fc1" {{.*}} "-ffixed-form" {{.*}} "-x" "f95-cpp-input" "free-form-test.i"

!RUN: %flang -save-temps -### %S/Inputs/fixed-form-test.f 2>&1 | FileCheck %s --check-prefix=FIXED
FIXED: "-fc1" {{.*}} "-o" "fixed-form-test.i" {{.*}} "-x" "f95-cpp-input" "{{.*}}/fixed-form-test.f"
FIXED-NEXT: "-fc1" {{.*}} "-ffixed-form" {{.*}} "-x" "f95" "fixed-form-test.i"
FIXED: "-fc1" {{.*}} "-o" "fixed-form-test.i" {{.*}} "-x" "f95" "{{.*}}/fixed-form-test.f"
FIXED-NEXT: "-fc1" {{.*}} "-ffixed-form" {{.*}} "-x" "f95-cpp-input" "fixed-form-test.i"

!RUN: %flang -save-temps -### -ffree-form %S/Inputs/free-form-test.f90 2>&1 | FileCheck %s --check-prefix=FREE-FLAG
FREE-FLAG: "-fc1" {{.*}} "-o" "free-form-test.i" {{.*}} "-x" "f95-cpp-input" "{{.*}}/free-form-test.f90"
FREE-FLAG: "-fc1" {{.*}} "-o" "free-form-test.i" {{.*}} "-x" "f95" "{{.*}}/free-form-test.f90"
FREE-FLAG-NEXT: "-fc1" {{.*}} "-emit-llvm-bc" "-ffree-form"
FREE-FLAG-NOT: "-ffixed-form"
FREE-FLAG-SAME: "-x" "f95" "free-form-test.i"
FREE-FLAG-SAME: "-x" "f95-cpp-input" "free-form-test.i"

!RUN: %flang -save-temps -### -ffixed-form %S/Inputs/fixed-form-test.f 2>&1 | FileCheck %s --check-prefix=FIXED-FLAG
FIXED-FLAG: "-fc1" {{.*}} "-o" "fixed-form-test.i" {{.*}} "-x" "f95-cpp-input" "{{.*}}/fixed-form-test.f"
FIXED-FLAG: "-fc1" {{.*}} "-o" "fixed-form-test.i" {{.*}} "-x" "f95" "{{.*}}/fixed-form-test.f"
FIXED-FLAG-NEXT: "-fc1" {{.*}} "-emit-llvm-bc" "-ffixed-form"
FIXED-FLAG-NOT: "-ffixed-form"
FIXED-FLAG-SAME: "-x" "f95" "fixed-form-test.i"
FIXED-FLAG-SAME: "-x" "f95-cpp-input" "fixed-form-test.i"