git: 48d88a1daa6b - 2025Q1 - devel/llvm18: backport llvm19 fixes

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Mon, 17 Mar 2025 18:38:30 UTC
The branch 2025Q1 has been updated by brooks:

URL: https://cgit.FreeBSD.org/ports/commit/?id=48d88a1daa6bffcfe8cf571e69c844d3787c4d4c

commit 48d88a1daa6bffcfe8cf571e69c844d3787c4d4c
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2025-03-12 16:58:24 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2025-03-17 18:38:09 +0000

    devel/llvm18: backport llvm19 fixes
    
    Pull in the patch from llvm1[567] and manually patch fold-logical.cpp
    (there's nothing sensible to back port because the offending code was
    rewritten in a commit that doesn't apply easily between 18 and 19.)
    
    PR:             283966, 285195
    Submitted by:   milios@ccsys.com (fixed backport patch)
    
    (cherry picked from commit 092b9a234522e403db69de50bb04c34b6f12c709)
---
 devel/llvm18/files/patch-backport-7bc7672925f81    | 76 ++++++++++++++++++++++
 .../patch-flang_lib_Evaluate_fold-logical.cpp      | 29 +++++++++
 2 files changed, 105 insertions(+)

diff --git a/devel/llvm18/files/patch-backport-7bc7672925f81 b/devel/llvm18/files/patch-backport-7bc7672925f81
new file mode 100644
index 000000000000..8638a3ff4e96
--- /dev/null
+++ b/devel/llvm18/files/patch-backport-7bc7672925f81
@@ -0,0 +1,76 @@
+commit 7bc7672925f8154be3b8220365d3f269ac43621c
+Author: David Spickett <david.spickett@linaro.org>
+Date:   Mon Jun 3 15:21:26 2024 +0100
+
+    [flang] Fix compilation errors due to new clang template requirements (#94204)
+    
+    Since https://github.com/llvm/llvm-project/pull/80801 clang requires a
+    template argument list after the use of the template keyword.
+    
+    https://lab.llvm.org/buildbot/#/builders/176/builds/10230
+    
+    error: a template argument list is expected after a name prefixed by the
+    template keyword [-Wmissing-template-arg-list-after-template-kw]
+    
+    This fixes the instances found by the AArch64 Linux builds.
+
+diff --git flang/include/flang/Evaluate/integer.h flang/include/flang/Evaluate/integer.h
+index 10a13115a39e..4c7d88328a71 100644
+--- flang/include/flang/Evaluate/integer.h
++++ flang/include/flang/Evaluate/integer.h
+@@ -315,7 +315,7 @@ public:
+       }
+       result.overflow = false;
+     } else if constexpr (bits < FROM::bits) {
+-      auto back{FROM::template ConvertSigned(result.value)};
++      auto back{FROM::template ConvertSigned<Integer>(result.value)};
+       result.overflow = back.value.CompareUnsigned(that) != Ordering::Equal;
+     }
+     return result;
+diff --git flang/lib/Evaluate/fold-real.cpp flang/lib/Evaluate/fold-real.cpp
+index 238ce34adfb7..f71addcc4094 100644
+--- flang/lib/Evaluate/fold-real.cpp
++++ flang/lib/Evaluate/fold-real.cpp
+@@ -245,7 +245,7 @@
+ #ifndef _MSC_VER
+                                                            template
+ #endif
+-                                                           SCALE(y)};
++                                                           SCALE<Scalar<TBY>>(y)};
+                       if (result.flags.test(RealFlag::Overflow)) {
+                         context.messages().Say(
+                             "SCALE intrinsic folding overflow"_warn_en_US);
+diff --git flang/runtime/reduction-templates.h flang/runtime/reduction-templates.h
+index d102e5642547..a51404c96376 100644
+--- flang/runtime/reduction-templates.h
++++ flang/runtime/reduction-templates.h
+@@ -85,9 +85,9 @@
+   DoTotalReduction<CppType>(x, dim, mask, accumulator, intrinsic, terminator);
+   CppType result;
+ #ifdef _MSC_VER // work around MSVC spurious error
+-  accumulator.GetResult(&result);
++  accumulator.GetResult<CppType>(&result);
+ #else
+-  accumulator.template GetResult(&result);
++  accumulator.template GetResult<CppType>(&result);
+ #endif
+   return result;
+ }
+@@ -128,7 +128,7 @@
+ #ifdef _MSC_VER // work around MSVC spurious error
+   accumulator.GetResult(result, zeroBasedDim);
+ #else
+-  accumulator.template GetResult(result, zeroBasedDim);
++  accumulator.template GetResult<TYPE>(result, zeroBasedDim);
+ #endif
+ }
+ 
+@@ -156,7 +156,7 @@
+ #ifdef _MSC_VER // work around MSVC spurious error
+   accumulator.GetResult(result, zeroBasedDim);
+ #else
+-  accumulator.template GetResult(result, zeroBasedDim);
++  accumulator.template GetResult<TYPE>(result, zeroBasedDim);
+ #endif
+ }
+ 
diff --git a/devel/llvm18/files/patch-flang_lib_Evaluate_fold-logical.cpp b/devel/llvm18/files/patch-flang_lib_Evaluate_fold-logical.cpp
new file mode 100644
index 000000000000..019a26066246
--- /dev/null
+++ b/devel/llvm18/files/patch-flang_lib_Evaluate_fold-logical.cpp
@@ -0,0 +1,29 @@
+--- flang/lib/Evaluate/fold-logical.cpp.orig
++++ flang/lib/Evaluate/fold-logical.cpp
+@@ -255,7 +255,7 @@
+                   const auto &xConst{DEREF(UnwrapExpr<Constant<xType>>(x))};
+                   for (const auto &elt : xConst.values()) {
+                     result->emplace_back(
+-                        Scalar::template FromInteger(elt).flags.test(
++                        Scalar::FromInteger(elt).flags.test(
+                             RealFlag::Overflow));
+                   }
+                 },
+@@ -272,7 +272,7 @@
+                   const auto &xConst{DEREF(UnwrapExpr<Constant<xType>>(x))};
+                   for (const auto &elt : xConst.values()) {
+                     result->emplace_back(elt.IsFinite() &&
+-                        Scalar::template Convert(elt).flags.test(
++                        Scalar::Convert(elt).flags.test(
+                             RealFlag::Overflow));
+                   }
+                 },
+@@ -291,7 +291,7 @@
+                   const auto &xConst{DEREF(UnwrapExpr<Constant<xType>>(x))};
+                   for (const auto &elt : xConst.values()) {
+                     result->emplace_back(
+-                        Scalar::template ConvertSigned(elt).overflow);
++                        Scalar::ConvertSigned(elt).overflow);
+                   }
+                 },
+                 intMold->u, xInt->u);