Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc] Fix some warnings #66366

Merged
merged 1 commit into from
Sep 14, 2023
Merged

[libc] Fix some warnings #66366

merged 1 commit into from
Sep 14, 2023

Conversation

abrachet
Copy link
Member

Some compilers will warn about dangling else and missleading lack of parentheses.

Some compilers will warn about dangling else and missleading
lack of parentheses.
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 14, 2023

@llvm/pr-subscribers-libc

Changes Some compilers will warn about dangling else and missleading lack of parentheses. -- Full diff: https://github.com//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)
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'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 << LLONG_BIT_WIDTH - 1);
-constexpr long long LLONG_MIN = 1LL << LLONG_BIT_WIDTH - 1;
+constexpr long long LLONG_MAX = ~0LL ^ (1LL << (LLONG_BIT_WIDTH - 1));
+constexpr long long LLONG_MIN = 1LL << (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 < 255; ++ch) {
-    if (' ' <= ch && ch <= '~') // A-Z, a-z, 0-9, punctuation, space.
+    if (' ' <= ch && ch <= '~') { // A-Z, a-z, 0-9, punctuation, space.
       EXPECT_NE(__llvm_libc::isprint(ch), 0);
-    else
+    } else {
       EXPECT_EQ(__llvm_libc::isprint(ch), 0);
+    }
   }
 }

@abrachet abrachet merged commit 2ad7a06 into llvm:main Sep 14, 2023
2 of 3 checks passed
@abrachet abrachet deleted the fix-libc-warnings branch September 14, 2023 12:47
kstoimenov pushed a commit to kstoimenov/llvm-project that referenced this pull request Sep 14, 2023
Some compilers will warn about dangling else and missleading lack of
parentheses.
ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this pull request Sep 19, 2023
Some compilers will warn about dangling else and missleading lack of
parentheses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants