-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[flang][driver] Add options -fdefault-integer-4 and -fdefault-real-4 #172323
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
+155
−39
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,114 @@ | ||
| ! Ensure argument -fdefault* work as expected. | ||
| ! TODO: Add checks when actual codegen is possible for this family | ||
|
|
||
| !-------------------------- | ||
| ! FLANG DRIVER (flang) | ||
| !-------------------------- | ||
| ! RUN: rm -rf %t/dir-flang && mkdir -p %t/dir-flang && %flang -fsyntax-only -module-dir %t/dir-flang %s 2>&1 | ||
| ! RUN: cat %t/dir-flang/m.mod | FileCheck %s --check-prefix=NOOPTION | ||
| ! RUN: rm -rf %t/dir-flang && mkdir -p %t/dir-flang && %flang -fsyntax-only -fdefault-real-8 -module-dir %t/dir-flang %s 2>&1 | ||
| ! RUN: cat %t/dir-flang/m.mod | FileCheck %s --check-prefix=REAL8 | ||
| ! RUN: rm -rf %t/dir-flang && mkdir -p %t/dir-flang && %flang -fsyntax-only -fdefault-real-8 -fdefault-double-8 -module-dir %t/dir-flang %s 2>&1 | ||
| ! RUN: cat %t/dir-flang/m.mod | FileCheck %s --check-prefix=DOUBLE8 | ||
| ! RUN: not %flang -fsyntax-only -fdefault-double-8 %s 2>&1 | FileCheck %s --check-prefix=ERROR | ||
|
|
||
| !----------------------------------------- | ||
| ! FRONTEND FLANG DRIVER (flang -fc1) | ||
| !----------------------------------------- | ||
| ! RUN: rm -rf %t/dir-flang && mkdir -p %t/dir-flang && %flang_fc1 -fsyntax-only -module-dir %t/dir-flang %s 2>&1 | ||
| ! RUN: cat %t/dir-flang/m.mod | FileCheck %s --check-prefix=NOOPTION | ||
| ! RUN: rm -rf %t/dir-flang && mkdir -p %t/dir-flang && %flang_fc1 -fsyntax-only -fdefault-real-8 -module-dir %t/dir-flang %s 2>&1 | ||
| ! RUN: cat %t/dir-flang/m.mod | FileCheck %s --check-prefix=REAL8 | ||
| ! RUN: rm -rf %t/dir-flang && mkdir -p %t/dir-flang && %flang_fc1 -fsyntax-only -fdefault-real-8 -fdefault-double-8 -module-dir %t/dir-flang %s 2>&1 | ||
| ! RUN: cat %t/dir-flang/m.mod | FileCheck %s --check-prefix=DOUBLE8 | ||
| ! RUN: not %flang_fc1 -fsyntax-only -fdefault-double-8 %s 2>&1 | FileCheck %s --check-prefix=ERROR | ||
|
|
||
| ! NOOPTION: integer(4),parameter::real_kind=4_4 | ||
| ! | ||
| ! RUN: rm -rf %t && mkdir -p %t && \ | ||
| ! RUN: %flang_fc1 -fsyntax-only -module-dir %t %s | ||
| ! RUN: cat %t/m.mod | FileCheck %s --check-prefix=NOOPTION | ||
| ! | ||
| ! RUN: rm -rf %t && mkdir -p %t && \ | ||
| ! RUN: %flang_fc1 -fsyntax-only -fdefault-integer-4 -module-dir %t %s | ||
| ! RUN: cat %t/m.mod | FileCheck %s --check-prefix=INTEGER4 | ||
| ! | ||
| ! RUN: rm -rf %t && mkdir -p %t && \ | ||
| ! RUN: %flang_fc1 -fsyntax-only -fdefault-real-4 -module-dir %t %s | ||
| ! RUN: cat %t/m.mod | FileCheck %s --check-prefix=REAL4 | ||
| ! | ||
| ! RUN: rm -rf %t && mkdir -p %t && \ | ||
| ! RUN: %flang_fc1 -fsyntax-only -fdefault-integer-4 -fdefault-real-4 \ | ||
| ! RUN: -module-dir %t %s | ||
| ! RUN: cat %t/m.mod | FileCheck %s --check-prefix=BOTH4 | ||
| ! | ||
| ! RUN: rm -rf %t && mkdir -p %t && \ | ||
| ! RUN: %flang_fc1 -fsyntax-only -fdefault-integer-8 -module-dir %t %s | ||
| ! RUN: cat %t/m.mod | FileCheck %s --check-prefix=INTEGER8 | ||
| ! | ||
| ! RUN: rm -rf %t && mkdir -p %t && \ | ||
| ! RUN: %flang -fsyntax-only -fdefault-real-8 -module-dir %t %s | ||
| ! RUN: cat %t/m.mod | FileCheck %s --check-prefix=REAL8 | ||
| ! | ||
| ! RUN: rm -rf %t && mkdir -p %t && \ | ||
| ! RUN: %flang_fc1 -fsyntax-only -fdefault-integer-8 -fdefault-real-8 \ | ||
| ! RUN: -module-dir %t %s | ||
| ! RUN: cat %t/m.mod | FileCheck %s --check-prefix=BOTH8 | ||
| ! | ||
| ! RUN: rm -rf %t && mkdir -p %t && \ | ||
| ! RUN: %flang_fc1 -fsyntax-only -fdefault-real-8 -fdefault-double-8 \ | ||
| ! RUN: -module-dir %t %s | ||
| ! RUN: cat %t/m.mod | FileCheck %s --check-prefix=DOUBLE8 | ||
| ! | ||
| ! RUN: not %flang_fc1 -fsyntax-only -fdefault-double-8 %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=ERROR | ||
| ! | ||
| ! The last occurrence of -fdefault-* "wins" | ||
| ! | ||
| ! RUN: rm -rf %t && mkdir -p %t && \ | ||
| ! RUN: %flang_fc1 -fsyntax-only -fdefault-integer-4 -fdefault-integer-8 \ | ||
| ! RUN: -module-dir %t %s | ||
| ! RUN: cat %t/m.mod | FileCheck %s --check-prefix=INTEGER8 | ||
| ! | ||
| ! RUN: rm -rf %t && mkdir -p %t && \ | ||
| ! RUN: %flang_fc1 -fsyntax-only -fdefault-integer-8 -fdefault-integer-4 \ | ||
| ! RUN: -module-dir %t %s | ||
| ! RUN: cat %t/m.mod | FileCheck %s --check-prefix=INTEGER4 | ||
| ! | ||
| ! RUN: rm -rf %t && mkdir -p %t && \ | ||
| ! RUN: %flang_fc1 -fsyntax-only -fdefault-real-4 -fdefault-real-8 \ | ||
| ! RUN: -module-dir %t %s | ||
| ! RUN: cat %t/m.mod | FileCheck %s --check-prefix=REAL8 | ||
| ! | ||
| ! RUN: rm -rf %t && mkdir -p %t && \ | ||
| ! RUN: %flang_fc1 -fsyntax-only -fdefault-real-8 -fdefault-real-4 \ | ||
| ! RUN: -module-dir %t %s | ||
| ! RUN: cat %t/m.mod | FileCheck %s --check-prefix=REAL4 | ||
| ! | ||
| ! NOOPTION: integer(4),parameter::integer_kind=4_4 | ||
| ! NOOPTION-NEXT: intrinsic::kind | ||
| ! NOOPTION-NEXT: integer(4),parameter::real_kind=4_4 | ||
| ! NOOPTION-NEXT: integer(4),parameter::double_kind=8_4 | ||
|
|
||
| ! REAL8: integer(4),parameter::real_kind=8_4 | ||
| ! | ||
| ! INTEGER4: integer(4),parameter::integer_kind=4_4 | ||
| ! INTEGER4-NEXT: intrinsic::kind | ||
| ! INTEGER4-NEXT: integer(4),parameter::real_kind=4_4 | ||
| ! INTEGER4-NEXT: integer(4),parameter::double_kind=8_4 | ||
| ! | ||
| ! REAL4: integer(4),parameter::integer_kind=4_4 | ||
| ! REAL4-NEXT: intrinsic::kind | ||
| ! REAL4-NEXT: integer(4),parameter::real_kind=4_4 | ||
| ! REAL4-NEXT: integer(4),parameter::double_kind=8_4 | ||
| ! | ||
| ! BOTH4: integer(4),parameter::integer_kind=4_4 | ||
| ! BOTH4-NEXT: intrinsic::kind | ||
| ! BOTH4-NEXT: integer(4),parameter::real_kind=4_4 | ||
| ! BOTH4-NEXT: integer(4),parameter::double_kind=8_4 | ||
| ! | ||
| ! INTEGER8: integer(8),parameter::integer_kind=8_8 | ||
| ! INTEGER8-NEXT: intrinsic::kind | ||
| ! INTEGER8-NEXT: integer(8),parameter::real_kind=4_8 | ||
| ! INTEGER8-NEXT: integer(8),parameter::double_kind=8_8 | ||
| ! | ||
| ! REAL8: integer(4),parameter::integer_kind=4_4 | ||
| ! REAL8-NEXT: intrinsic::kind | ||
| ! REAL8-NEXT: integer(4),parameter::real_kind=8_4 | ||
| ! REAL8-NEXT: integer(4),parameter::double_kind=16_4 | ||
|
|
||
| ! DOUBLE8: integer(4),parameter::real_kind=8_4 | ||
| ! | ||
| ! BOTH8: integer(8),parameter::integer_kind=8_8 | ||
| ! BOTH8-NEXT: intrinsic::kind | ||
| ! BOTH8-NEXT: integer(8),parameter::real_kind=8_8 | ||
| ! BOTH8-NEXT: integer(8),parameter::double_kind=16_8 | ||
| ! | ||
| ! DOUBLE8: integer(4),parameter::integer_kind=4_4 | ||
| ! DOUBLE8-NEXT: intrinsic::kind | ||
| ! DOUBLE8-NEXT: integer(4),parameter::real_kind=8_4 | ||
| ! DOUBLE8-NEXT: integer(4),parameter::double_kind=8_4 | ||
|
|
||
| ! | ||
| ! ERROR: Use of `-fdefault-double-8` requires `-fdefault-real-8` | ||
|
|
||
| module m | ||
| implicit none | ||
| integer :: i | ||
| real :: x | ||
| double precision :: y | ||
| integer, parameter :: real_kind = kind(x) !-fdefault-real-8 | ||
| integer, parameter :: double_kind = kind(y) !-fdefault-double-8 | ||
| integer, parameter :: integer_kind = kind(i) !-fdefault-integer-* | ||
| integer, parameter :: real_kind = kind(x) !-fdefault-real-* | ||
| integer, parameter :: double_kind = kind(y) !-fdefault-double-* | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, what if the target platform doesn't support real16?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There PR does not change the behavior of
-fdefault-real-8, soflangwill continue to behave as it would have before.If I compile the code above on a machine without support for
real(16), I get this:It may be a better user experience to emit a warning - or even an error -
-fdefault-real-8is used on a target that does not supportreal(16). IMO, that is an unrelated change that should be deferred to a different PR.