[clang] [Clang] [Sema] Make -Wreturn-type an error by default (PR #131207)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 13 13:20:04 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (Sirraide)
<details>
<summary>Changes</summary>
Yet another attempt at this. Release note, tests etc are still missing since this is just to see if CI is happy with it this time round (note: warning-flags.c has proven to be very stubborn and I haven’t been able to fix that test on its own despite trying several times so it is included here).
---
Full diff: https://github.com/llvm/llvm-project/pull/131207.diff
2 Files Affected:
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+1-1)
- (modified) clang/test/Index/warning-flags.c (+1-1)
``````````diff
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8e6e6e892cdd7..113e684a53c2b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -722,7 +722,7 @@ def warn_falloff_nonvoid : Warning<
"non-void "
"%enum_select<FalloffFunctionKind>{%Function{function}|%Block{block}|%Lambda{lambda}|%Coroutine{coroutine}}0"
" does not return a value%select{| in all control paths}1">,
- InGroup<ReturnType>;
+ InGroup<ReturnType>, DefaultError;
def err_falloff_nonvoid : Error<
"non-void %select{function|block|lambda|coroutine}0 "
"does not return a value%select{| in all control paths}1">;
diff --git a/clang/test/Index/warning-flags.c b/clang/test/Index/warning-flags.c
index 1694c6abab562..3229f000c4ae0 100644
--- a/clang/test/Index/warning-flags.c
+++ b/clang/test/Index/warning-flags.c
@@ -9,7 +9,7 @@ int *bar(float *f) { return f; }
// RUN: c-index-test -test-load-source-reparse 5 all -w %s 2>&1 | FileCheck -check-prefix=NOWARNINGS %s
// RUN: c-index-test -test-load-source all -w -O4 %s 2>&1 | FileCheck -check-prefix=NOWARNINGS %s
-// CHECK-BOTH-WARNINGS: warning: non-void function does not return a value
+// CHECK-BOTH-WARNINGS: error: non-void function does not return a value
// CHECK-BOTH-WARNINGS: warning: incompatible pointer types returning 'float *' from a function with result type 'int *'
// CHECK-SECOND-WARNING-NOT:non-void function does not return a value
``````````
</details>
https://github.com/llvm/llvm-project/pull/131207
More information about the cfe-commits
mailing list