[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:19:31 PDT 2025


https://github.com/Sirraide created https://github.com/llvm/llvm-project/pull/131207

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).

>From bff3db4f6a7fdff572b662048f395c280a11d94b Mon Sep 17 00:00:00 2001
From: Sirraide <aeternalmail at gmail.com>
Date: Thu, 13 Mar 2025 21:18:14 +0100
Subject: [PATCH] [Clang] [Sema] Make -Wreturn-type an error by default

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 +-
 clang/test/Index/warning-flags.c                 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

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



More information about the cfe-commits mailing list