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][NFC] Couple of small warning fixes #67847

Merged
merged 3 commits into from
Oct 2, 2023

Conversation

mikhailramalho
Copy link
Member

This patch fixes a couple of warning when compiling with gcc 13:

  • CPP/type_traits_test.cpp: 'apply' overrides a member function but is not marked 'override'

  • UnitTest/LibcTest.cpp:98: control reaches end of non-void function

  • MPFRWrapper/MPFRUtils.cpp:75: control reaches end of non-void function

  • smoke/FrexpTest.h:92: backslash-newline at end of file

This patch fixes a couple of warning when compiling with gcc 13:

* CPP/type_traits_test.cpp: 'apply' overrides a member function but is not marked 'override'

* UnitTest/LibcTest.cpp:98: control reaches end of non-void function
* MPFRWrapper/MPFRUtils.cpp:75: control reaches end of non-void function

* smoke/FrexpTest.h:92: backslash-newline at end of file
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 29, 2023

@llvm/pr-subscribers-libc

Changes

This patch fixes a couple of warning when compiling with gcc 13:

  • CPP/type_traits_test.cpp: 'apply' overrides a member function but is not marked 'override'

  • UnitTest/LibcTest.cpp:98: control reaches end of non-void function

  • MPFRWrapper/MPFRUtils.cpp:75: control reaches end of non-void function

  • smoke/FrexpTest.h:92: backslash-newline at end of file


Full diff: https://github.com/llvm/llvm-project/pull/67847.diff

4 Files Affected:

  • (modified) libc/test/UnitTest/LibcTest.cpp (+1)
  • (modified) libc/test/src/__support/CPP/type_traits_test.cpp (+1-1)
  • (modified) libc/test/src/math/smoke/FrexpTest.h (+1-1)
  • (modified) libc/utils/MPFRWrapper/MPFRUtils.cpp (+1)
diff --git a/libc/test/UnitTest/LibcTest.cpp b/libc/test/UnitTest/LibcTest.cpp
index 2f18d5778e71d84..b01f40f0526461f 100644
--- a/libc/test/UnitTest/LibcTest.cpp
+++ b/libc/test/UnitTest/LibcTest.cpp
@@ -95,6 +95,7 @@ bool test(RunContext *Ctx, TestCond Cond, ValType LHS, ValType RHS,
   case TestCond::GE:
     return ExplainDifference(LHS >= RHS, "greater than or equal to");
   }
+  __builtin_unreachable();
 }
 
 } // namespace internal
diff --git a/libc/test/src/__support/CPP/type_traits_test.cpp b/libc/test/src/__support/CPP/type_traits_test.cpp
index 0e5f4a1f738b7aa..a2051f380275326 100644
--- a/libc/test/src/__support/CPP/type_traits_test.cpp
+++ b/libc/test/src/__support/CPP/type_traits_test.cpp
@@ -157,7 +157,7 @@ struct A {
 
 struct B : public A {
   virtual ~B() {}
-  virtual void apply() { state = B_APPLY_CALLED; }
+  virtual void apply() override { state = B_APPLY_CALLED; }
 };
 
 void free_function() {}
diff --git a/libc/test/src/math/smoke/FrexpTest.h b/libc/test/src/math/smoke/FrexpTest.h
index 1740770fd6c4787..3ff169091cc9a38 100644
--- a/libc/test/src/math/smoke/FrexpTest.h
+++ b/libc/test/src/math/smoke/FrexpTest.h
@@ -93,4 +93,4 @@ template <typename T> class FrexpTest : public LIBC_NAMESPACE::testing::Test {
   using LlvmLibcFrexpTest = FrexpTest<T>;                                      \
   TEST_F(LlvmLibcFrexpTest, SpecialNumbers) { testSpecialNumbers(&func); }     \
   TEST_F(LlvmLibcFrexpTest, PowersOfTwo) { testPowersOfTwo(&func); }           \
-  TEST_F(LlvmLibcFrexpTest, SomeIntegers) { testSomeIntegers(&func); }\
+  TEST_F(LlvmLibcFrexpTest, SomeIntegers) { testSomeIntegers(&func); }
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index e23a3c2034cb283..0818955f14de7d3 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -72,6 +72,7 @@ static inline mpfr_rnd_t get_mpfr_rounding_mode(RoundingMode mode) {
     return MPFR_RNDN;
     break;
   }
+  __builtin_unreachable();
 }
 
 class MPFRNumber {

* __support/float_to_string.h:118: comparison of unsigned expression in ‘>= 0’ is always true
* __support/wctype_utils.h:31: comparison of unsigned expression in ‘< 0’ is always false
* test/src/__support/CPP/bitset_test.cpp:197: comparison of unsigned expression in ‘>= 0’ is always true
Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one fix

libc/src/__support/wctype_utils.h Show resolved Hide resolved
Signed-off-by: Mikhail R. Gadelha <mikhail@igalia.com>
Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mikhailramalho mikhailramalho merged commit 8fc87f5 into llvm:main Oct 2, 2023
3 checks passed
@mikhailramalho mikhailramalho deleted the libc-couple-warning-fixes branch October 2, 2023 23:29
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.

4 participants