[libc-commits] [libc] [libc] Fix some warnings (PR #66366)

via libc-commits libc-commits at lists.llvm.org
Thu Sep 14 05:36:02 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc
            
<details>
<summary>Changes</summary>
Some compilers will warn about dangling else and missleading lack of parentheses.
--
Full diff: https://github.com/llvm/llvm-project/pull/66366.diff

2 Files Affected:

- (modified) libc/src/__support/CPP/limits.h (+2-2) 
- (modified) libc/test/src/ctype/isprint_test.cpp (+3-2) 


<pre>
diff --git a/libc/src/__support/CPP/limits.h b/libc/src/__support/CPP/limits.h
index e42414523a76df7..46a1172c285020c 100644
--- a/libc/src/__support/CPP/limits.h
+++ b/libc/src/__support/CPP/limits.h
@@ -17,8 +17,8 @@ namespace cpp {
 // Some older gcc distributions don&#x27;t define these for 32 bit targets.
 #ifndef LLONG_MAX
 constexpr size_t LLONG_BIT_WIDTH = sizeof(long long) * 8;
-constexpr long long LLONG_MAX = ~0LL ^ (1LL &lt;&lt; LLONG_BIT_WIDTH - 1);
-constexpr long long LLONG_MIN = 1LL &lt;&lt; LLONG_BIT_WIDTH - 1;
+constexpr long long LLONG_MAX = ~0LL ^ (1LL &lt;&lt; (LLONG_BIT_WIDTH - 1));
+constexpr long long LLONG_MIN = 1LL &lt;&lt; (LLONG_BIT_WIDTH - 1);
 constexpr unsigned long long ULLONG_MAX = ~0ULL;
 #endif
 
diff --git a/libc/test/src/ctype/isprint_test.cpp b/libc/test/src/ctype/isprint_test.cpp
index d7278fadc10fd52..08963209c1d4cb0 100644
--- a/libc/test/src/ctype/isprint_test.cpp
+++ b/libc/test/src/ctype/isprint_test.cpp
@@ -11,9 +11,10 @@
 
 TEST(LlvmLibcIsPrint, DefaultLocale) {
   for (int ch = -255; ch &lt; 255; ++ch) {
-    if (&#x27; &#x27; &lt;= ch &amp;&amp; ch &lt;= &#x27;~&#x27;) // A-Z, a-z, 0-9, punctuation, space.
+    if (&#x27; &#x27; &lt;= ch &amp;&amp; ch &lt;= &#x27;~&#x27;) { // A-Z, a-z, 0-9, punctuation, space.
       EXPECT_NE(__llvm_libc::isprint(ch), 0);
-    else
+    } else {
       EXPECT_EQ(__llvm_libc::isprint(ch), 0);
+    }
   }
 }
</pre>
</details>


https://github.com/llvm/llvm-project/pull/66366


More information about the libc-commits mailing list