[flang-commits] [flang] [flang] Remove a warning about standards-conforming generic function references (PR #178088)
via flang-commits
flang-commits at lists.llvm.org
Tue Jan 27 10:26:11 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Katherine Rasmussen (ktras)
<details>
<summary>Changes</summary>
Remove a warning about standards-conforming generic function references, which are never ambiguous with structure constructors, as discussed in a conversation in the following [issue](https://github.com/j3-fortran/fortran_proposals/issues/348#issuecomment-3694937658).
---
Full diff: https://github.com/llvm/llvm-project/pull/178088.diff
6 Files Affected:
- (modified) flang/lib/Semantics/expression.cpp (-5)
- (modified) flang/test/Semantics/c7108.f90 (+2-4)
- (modified) flang/test/Semantics/generic09.f90 (-3)
- (modified) flang/test/Semantics/resolve11.f90 (+1-2)
- (modified) flang/test/Semantics/resolve17.f90 (+2-4)
- (modified) flang/test/Semantics/resolve18.f90 (+2-1)
``````````diff
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index e07d2ccd4f16b..d1732e727d74e 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -3061,11 +3061,6 @@ auto ExpressionAnalyzer::ResolveGeneric(const Symbol &symbol,
Warn(common::LanguageFeature::AmbiguousStructureConstructor,
"Reference to the intrinsic function '%s' is ambiguous with a structure constructor of the same name"_port_en_US,
symbol.name());
- } else {
- Warn(common::LanguageFeature::AmbiguousStructureConstructor,
- "Reference to generic function '%s' (resolving to specific '%s') is ambiguous with a structure constructor of the same name"_port_en_US,
- symbol.name(),
- nonElemental ? nonElemental->name() : elemental->name());
}
}
}
diff --git a/flang/test/Semantics/c7108.f90 b/flang/test/Semantics/c7108.f90
index 0b7148f4d6455..12b88fd0128e2 100644
--- a/flang/test/Semantics/c7108.f90
+++ b/flang/test/Semantics/c7108.f90
@@ -33,9 +33,7 @@ program p
use m
type(foo) x
x = foo(); print *, x ! ok, not ambiguous
- !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'bar0') is ambiguous with a structure constructor of the same name [-Wambiguous-structure-constructor]
- x = foo(2); print *, x ! ambigous
- !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'bar2') is ambiguous with a structure constructor of the same name [-Wambiguous-structure-constructor]
- x = foo(3.); print *, x ! ambiguous due to data conversion
+ x = foo(2); print *, x ! According to F23 C7108, not ambiguous
+ x = foo(3.); print *, x ! According to F23 C7108, not ambiguous
x = foo(.true.); print *, x ! ok, not ambigous
end
diff --git a/flang/test/Semantics/generic09.f90 b/flang/test/Semantics/generic09.f90
index d93d7453ed6dd..c3a8b49913e94 100644
--- a/flang/test/Semantics/generic09.f90
+++ b/flang/test/Semantics/generic09.f90
@@ -33,9 +33,6 @@ type(foo) function f2(a)
end
end
-!CHECK: portability: Reference to generic function 'foo' (resolving to specific 'f1') is ambiguous with a structure constructor of the same name
-!CHECK: portability: Reference to generic function 'foo' (resolving to specific 'f2') is ambiguous with a structure constructor of the same name
-
program main
use m3
type(foo) x
diff --git a/flang/test/Semantics/resolve11.f90 b/flang/test/Semantics/resolve11.f90
index 0c457f2c9f3f0..734cdcb7bafa1 100644
--- a/flang/test/Semantics/resolve11.f90
+++ b/flang/test/Semantics/resolve11.f90
@@ -66,8 +66,7 @@ subroutine s4
!ERROR: 'fun' is PRIVATE in 'm4'
use m4, only: foo, fun
type(foo) x ! ok
- !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'fun') is ambiguous with a structure constructor of the same name [-Wambiguous-structure-constructor]
- print *, foo()
+ print *, foo() ! According to F23 C7108, not ambiguous
end
module m5
diff --git a/flang/test/Semantics/resolve17.f90 b/flang/test/Semantics/resolve17.f90
index 173fb9c6c5b78..666a5a14eafcf 100644
--- a/flang/test/Semantics/resolve17.f90
+++ b/flang/test/Semantics/resolve17.f90
@@ -290,8 +290,7 @@ module m14d
contains
subroutine test
real :: y
- !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'bar') is ambiguous with a structure constructor of the same name [-Wambiguous-structure-constructor]
- y = foo(1.0)
+ y = foo(1.0) ! According to F23 C7108, not ambiguous
x = foo(2)
end subroutine
end module
@@ -302,8 +301,7 @@ module m14e
contains
subroutine test
real :: y
- !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'bar') is ambiguous with a structure constructor of the same name [-Wambiguous-structure-constructor]
- y = foo(1.0)
+ y = foo(1.0) ! According to F23 C7108, not ambiguous
x = foo(2)
end subroutine
end module
diff --git a/flang/test/Semantics/resolve18.f90 b/flang/test/Semantics/resolve18.f90
index 65c39931cc7cb..b0827f88996c7 100644
--- a/flang/test/Semantics/resolve18.f90
+++ b/flang/test/Semantics/resolve18.f90
@@ -348,7 +348,8 @@ subroutine s_21_23
use m21
use m23
type(foo) x ! Intel and NAG error
- !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'f1') is ambiguous with a structure constructor of the same name [-Wambiguous-structure-constructor]
+
+ ! According to F23 C7108, not ambiguous
print *, foo(1.) ! Intel error
print *, foo(1.,2.,3.) ! Intel error
call ext(foo) ! GNU and Intel error
``````````
</details>
https://github.com/llvm/llvm-project/pull/178088
More information about the flang-commits
mailing list