[llvm] [flang-rt][build] Disable build-time warning of '-Wshift-count-negative' from g++ compiler and remove unsupported floating-point data. (PR #174915)

liao jun via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 7 22:07:58 PST 2026


https://github.com/zjlcd created https://github.com/llvm/llvm-project/pull/174915

When building the flang-rt project with the g++ compiler on  Linux-X86_64 machine, the compiler gives the following warning:

```
llvm-project/flang-rt/lib/runtime/extensions.cpp:455:26: warning: left shift count is negative [-Wshift-count-negative]
   455 |     mask = ~(unsigned)0u << ((8 - digits) * 4 + 1);
       |            ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

```

All the discussion records see: https://github.com/llvm/llvm-project/pull/173955

>From a0d4a9cb8d3fa3efe436c148be42c3fc406ba29e Mon Sep 17 00:00:00 2001
From: liao jun <liaojun at ultrarisc.com>
Date: Thu, 8 Jan 2026 13:57:50 +0800
Subject: [PATCH] In flang-rt/lib/runtime/extensions.cpp

Disable warning of '-Wshift-count-negative' from g++ compiler and
remove unsupported floating-point data.

```
llvm-project/flang-rt/lib/runtime/extensions.cpp:455:26: warning: left shift count is negative [-Wshift-count-negative]
   455 |     mask = ~(unsigned)0u << ((8 - digits) * 4 + 1);
       |            ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

```
---
 flang-rt/lib/runtime/extensions.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/flang-rt/lib/runtime/extensions.cpp b/flang-rt/lib/runtime/extensions.cpp
index 100046fc7bbf7..978cc526d707a 100644
--- a/flang-rt/lib/runtime/extensions.cpp
+++ b/flang-rt/lib/runtime/extensions.cpp
@@ -449,10 +449,8 @@ float RTNAME(Rand)(int *i, const char *sourceFile, int line) {
   unsigned mask = 0;
   constexpr int radix = std::numeric_limits<float>::radix;
   constexpr int digits = std::numeric_limits<float>::digits;
-  if (radix == 2) {
+  if constexpr (radix == 2) {
     mask = ~(unsigned)0u << (32 - digits + 1);
-  } else if (radix == 16) {
-    mask = ~(unsigned)0u << ((8 - digits) * 4 + 1);
   } else {
     Terminator terminator{sourceFile, line};
     terminator.Crash("Radix unknown value.");



More information about the llvm-commits mailing list