Skip to content

Commit 28d294e

Browse files
authored
[flang] Let -fdisable-real-10 affect only user code (llvm#183870)
Don't let -fdisable-real-10 elicit errors from intrinsic modules.
1 parent d723d14 commit 28d294e

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

flang/lib/Semantics/expression.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4427,8 +4427,17 @@ bool ExpressionAnalyzer::CheckIntrinsicKind(
44274427
return true;
44284428
} else if (foldingContext_.targetCharacteristics().CanSupportType(
44294429
category, kind)) {
4430-
Say("%s(KIND=%jd) is not an enabled type for this target"_err_en_US,
4431-
ToUpperCase(EnumToString(category)), kind);
4430+
if (const semantics::Scope *modFileScope{
4431+
semantics::FindModuleFileContaining(
4432+
context_.FindScope(GetContextualMessages().at()))};
4433+
modFileScope && modFileScope->parent().IsIntrinsicModules()) {
4434+
// Ignore usage of unsupported intrinsic type kinds in intrinsic module
4435+
// files. They might be USE'd into a cross-compilation or into a
4436+
// compilation with a disabled REAL kind.
4437+
} else {
4438+
Say("%s(KIND=%jd) is not an enabled type for this target"_err_en_US,
4439+
ToUpperCase(EnumToString(category)), kind);
4440+
}
44324441
return true;
44334442
} else {
44344443
Say("%s(KIND=%jd) is not a supported type"_err_en_US,

flang/test/Semantics/bug2236.f90

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
!RUN: flang -c -Xflang -fdisable-real-10 %s 2>&1 | FileCheck --allow-empty %s
2+
!REQUIRES: x86-registered-target
3+
!CHECK-NOT: error
4+
!Ensure ieee_arithmetic.mod can be used even when REAL(10) is disabled.
5+
use ieee_arithmetic
6+
end

0 commit comments

Comments
 (0)