https://github.com/Sirraide updated https://github.com/llvm/llvm-project/pull/131207
>From bff3db4f6a7fdff572b662048f395c280a11d94b Mon Sep 17 00:00:00 2001 From: Sirraide <aeternalm...@gmail.com> Date: Thu, 13 Mar 2025 21:18:14 +0100 Subject: [PATCH 1/3] [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 >From a8523d15a4c790fe1fb58a6fe41da571cb11ba47 Mon Sep 17 00:00:00 2001 From: Sirraide <aeternalm...@gmail.com> Date: Tue, 18 Mar 2025 17:52:36 +0100 Subject: [PATCH 2/3] Fix clang-tidy warning --- .../test/clang-tidy/checkers/misc/unused-using-decls.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp index 62aa17b0b1c22..40451167c5809 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp @@ -233,7 +233,7 @@ namespace my_literals { using my_literals::operator"" _r; -int foo() { +void foo() { auto x2 = 123_r; } >From f830db193424913aec7e355d39af68de8560adfb Mon Sep 17 00:00:00 2001 From: Sirraide <aeternalm...@gmail.com> Date: Wed, 19 Mar 2025 19:13:01 +0100 Subject: [PATCH 3/3] Add release note --- clang/docs/ReleaseNotes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 8989124611e66..1d81b5e191e89 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -38,6 +38,7 @@ Potentially Breaking Changes - Fix missing diagnostics for uses of declarations when performing typename access, such as when performing member access on a '[[deprecated]]' type alias. (#GH58547) +- The `-Wreturn-type` warning now defaults to an error in all language modes. C/C++ Language Potentially Breaking Changes ------------------------------------------- _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits