[flang-commits] [flang] 38853a0 - [flang][OpenMP] MSVC buildbot fix

Michael Kruse via flang-commits flang-commits at lists.llvm.org
Thu Aug 14 03:31:56 PDT 2025


Author: Michael Kruse
Date: 2025-08-14T12:30:59+02:00
New Revision: 38853a0146b1e0a7a6557a788aa1671ddaef385e

URL: https://github.com/llvm/llvm-project/commit/38853a0146b1e0a7a6557a788aa1671ddaef385e
DIFF: https://github.com/llvm/llvm-project/commit/38853a0146b1e0a7a6557a788aa1671ddaef385e.diff

LOG: [flang][OpenMP] MSVC buildbot fix

PR #153488 caused the msvc build (https://lab.llvm.org/buildbot/#/builders/166/builds/1397) to fail:
```
..\llvm-project\flang\include\flang/Evaluate/rewrite.h(78): error C2668: 'Fortran::evaluate::rewrite::Identity::operator ()': ambiguous call to overloaded function
..\llvm-project\flang\include\flang/Evaluate/rewrite.h(43): note: could be 'Fortran::evaluate::Expr<Fortran::evaluate::SomeType> Fortran::evaluate::rewrite::Identity::operator ()<Fortran::evaluate::SomeType,S>(Fortran::evaluate::Expr<Fortran::evaluate::SomeType> &&,const U &)'
        with
        [
            S=Fortran::evaluate::value::Integer<128,true,32,unsigned int,unsigned __int64,128>,
            U=Fortran::evaluate::value::Integer<128,true,32,unsigned int,unsigned __int64,128>
        ]
..\llvm-project\flang\lib\Semantics\check-omp-atomic.cpp(174): note: or       'Fortran::evaluate::Expr<Fortran::evaluate::SomeType> Fortran::semantics::ReassocRewriter::operator ()<Fortran::evaluate::SomeType,S,void>(Fortran::evaluate::Expr<Fortran::evaluate::SomeType> &&,const U &,Fortran::semantics::ReassocRewriter::NonIntegralTag)'
        with
        [
            S=Fortran::evaluate::value::Integer<128,true,32,unsigned int,unsigned __int64,128>,
            U=Fortran::evaluate::value::Integer<128,true,32,unsigned int,unsigned __int64,128>
        ]
..\llvm-project\flang\include\flang/Evaluate/rewrite.h(78): note: while trying to match the argument list '(Fortran::evaluate::Expr<Fortran::evaluate::SomeType>, const S)'
        with
        [
            S=Fortran::evaluate::value::Integer<128,true,32,unsigned int,unsigned __int64,128>
        ]
..\llvm-project\flang\include\flang/Evaluate/rewrite.h(78): note: the template instantiation context (the oldest one first) is
..\llvm-project\flang\lib\Semantics\check-omp-atomic.cpp(814): note: see reference to function template instantiation 'U Fortran::evaluate::rewrite::Mutator<Fortran::semantics::ReassocRewriter>::operator ()<const Fortran::evaluate::Expr<Fortran::evaluate::SomeType>&,Fortran::evaluate::Expr<Fortran::evaluate::SomeType>>(T)' being compiled
        with
        [
            U=Fortran::evaluate::Expr<Fortran::evaluate::SomeType>,
            T=const Fortran::evaluate::Expr<Fortran::evaluate::SomeType> &
        ]
```

The reason is that there is an ambiguity between operator() of
ReassocRewriter itself and operator() of the base class `Identity` through
`using Id::operator();`. By the C++ specification, method declarations
in ReassocRewriter hide methods with the same signature from a using
declaration, but this does not apply to
```
evaluate::Expr<T> operator()(..., NonIntegralTag = {})
```
which has a different signature due to an additional tag parameter.
Since it has a default value, it is ambiguous with operator() without
tag parameter.

GCC and Clang both accept this, but in my understanding MSVC is correct
here.

Since the overloads of ReassocRewriter cover all cases (integral and
non-integral), removing the using declaration to avoid the ambiguity.

Added: 
    

Modified: 
    flang/lib/Semantics/check-omp-atomic.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/check-omp-atomic.cpp b/flang/lib/Semantics/check-omp-atomic.cpp
index 62bb2fdc6048e..50e63d356be02 100644
--- a/flang/lib/Semantics/check-omp-atomic.cpp
+++ b/flang/lib/Semantics/check-omp-atomic.cpp
@@ -86,7 +86,6 @@ ReassocOp<T, Op0, Op1> reassocOp(const Op0 &op0, const Op1 &op1) {
 
 struct ReassocRewriter : public evaluate::rewrite::Identity {
   using Id = evaluate::rewrite::Identity;
-  using Id::operator();
   struct NonIntegralTag {};
 
   ReassocRewriter(const SomeExpr &atom) : atom_(atom) {}


        


More information about the flang-commits mailing list