Skip to content

Commit d1d952c

Browse files
authored
[flang] Interpret 'Q' exponent letter as kind=16 even on x86 (#124158)
The compiler was interpreting 'Q' as an exponent letter in a literal real constant as meaning real(kind=10) on x86-64, which is the legacy 80387 80-bit extended precision floating-point type. It turns out that 'Q' means kind=16 with all other compilers, even for x86-64 targets. Change to conform.
1 parent ec6b2c6 commit d1d952c

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

flang/lib/Common/default-kinds.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111

1212
namespace Fortran::common {
1313

14-
IntrinsicTypeDefaultKinds::IntrinsicTypeDefaultKinds() {
15-
#if __x86_64__
16-
quadPrecisionKind_ = 10;
17-
#endif
18-
}
14+
IntrinsicTypeDefaultKinds::IntrinsicTypeDefaultKinds() {}
1915

2016
IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_defaultIntegerKind(
2117
int k) {

flang/lib/Frontend/CompilerInstance.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,6 @@ bool CompilerInstance::executeAction(FrontendAction &act) {
153153
CompilerInvocation &invoc = this->getInvocation();
154154

155155
llvm::Triple targetTriple{llvm::Triple(invoc.getTargetOpts().triple)};
156-
if (targetTriple.getArch() == llvm::Triple::ArchType::x86_64) {
157-
invoc.getDefaultKinds().set_quadPrecisionKind(10);
158-
}
159156

160157
// Set some sane defaults for the frontend.
161158
invoc.setDefaultFortranOpts();

flang/test/Semantics/kinds04_q10.f90

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
! RUN: %python %S/test_errors.py %s %flang_fc1 -triple x86_64-unknown-linux-gnu
1+
! RUN: %python %S/test_errors.py %s %flang_fc1
22
! C716 If both kind-param and exponent-letter appear, exponent-letter
33
! shall be E. (As an extension we also allow an exponent-letter which matches
44
! the kind-param)
55
! C717 The value of kind-param shall specify an approximation method that
66
! exists on the processor.
7-
!
8-
! This test is for x86_64, where exponent-letter 'q' is for
9-
! 10-byte extended precision
10-
! UNSUPPORTED: system-windows, system-aix
11-
! REQUIRES: x86-registered-target
127

138
subroutine s(var)
149
real :: realvar1 = 4.0E6_4
1510
real :: realvar2 = 4.0D6
1611
real :: realvar3 = 4.0Q6
1712
!PORTABILITY: Explicit kind parameter together with non-'E' exponent letter is not standard
1813
real :: realvar4 = 4.0D6_8
19-
!PORTABILITY: Explicit kind parameter together with non-'E' exponent letter is not standard
20-
real :: realvar5 = 4.0Q6_10
2114
!WARNING: Explicit kind parameter on real constant disagrees with exponent letter 'q'
15+
real :: realvar5 = 4.0Q6_10
16+
!PORTABILITY: Explicit kind parameter together with non-'E' exponent letter is not standard
2217
real :: realvar6 = 4.0Q6_16
2318
real :: realvar7 = 4.0E6_8
2419
real :: realvar8 = 4.0E6_10
@@ -31,7 +26,7 @@ subroutine s(var)
3126
double precision :: doublevar3 = 4.0Q6
3227
!PORTABILITY: Explicit kind parameter together with non-'E' exponent letter is not standard
3328
double precision :: doublevar4 = 4.0D6_8
34-
!WARNING: Explicit kind parameter on real constant disagrees with exponent letter 'q'
29+
!PORTABILITY: Explicit kind parameter together with non-'E' exponent letter is not standard
3530
double precision :: doublevar5 = 4.0Q6_16
3631
double precision :: doublevar6 = 4.0E6_8
3732
double precision :: doublevar7 = 4.0E6_10

0 commit comments

Comments
 (0)