Skip to content

Commit 441385e

Browse files
committed
[Clang] Make -Wreturn-type default to an error in all language modes
1 parent 12f78e7 commit 441385e

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ code bases.
8181
``-fno-strict-overflow`` to opt-in to a language dialect where signed integer
8282
and pointer overflow are well-defined.
8383

84+
- ``-Wreturn-type`` now defaults to an error in all language modes; like other
85+
warnings, it can be reverted to just being a warning by specifying
86+
``-Wno-error=return-type``.
87+
8488
C/C++ Language Potentially Breaking Changes
8589
-------------------------------------------
8690

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -709,10 +709,10 @@ def err_thread_unsupported : Error<
709709
// FIXME: Combine fallout warnings to just one warning.
710710
def warn_maybe_falloff_nonvoid_function : Warning<
711711
"non-void function does not return a value in all control paths">,
712-
InGroup<ReturnType>;
712+
InGroup<ReturnType>, DefaultError;
713713
def warn_falloff_nonvoid_function : Warning<
714714
"non-void function does not return a value">,
715-
InGroup<ReturnType>;
715+
InGroup<ReturnType>, DefaultError;
716716
def warn_const_attr_with_pure_attr : Warning<
717717
"'const' attribute imposes more restrictions; 'pure' attribute ignored">,
718718
InGroup<IgnoredAttributes>;
@@ -726,10 +726,10 @@ def err_falloff_nonvoid_block : Error<
726726
"non-void block does not return a value">;
727727
def warn_maybe_falloff_nonvoid_coroutine : Warning<
728728
"non-void coroutine does not return a value in all control paths">,
729-
InGroup<ReturnType>;
729+
InGroup<ReturnType>, DefaultError;
730730
def warn_falloff_nonvoid_coroutine : Warning<
731731
"non-void coroutine does not return a value">,
732-
InGroup<ReturnType>;
732+
InGroup<ReturnType>, DefaultError;
733733
def warn_suggest_noreturn_function : Warning<
734734
"%select{function|method}0 %1 could be declared with attribute 'noreturn'">,
735735
InGroup<MissingNoreturn>, DefaultIgnore;
@@ -8365,10 +8365,10 @@ let CategoryName = "Lambda Issue" in {
83658365
"lambda declared 'noreturn' should not return">;
83668366
def warn_maybe_falloff_nonvoid_lambda : Warning<
83678367
"non-void lambda does not return a value in all control paths">,
8368-
InGroup<ReturnType>;
8368+
InGroup<ReturnType>, DefaultError;
83698369
def warn_falloff_nonvoid_lambda : Warning<
83708370
"non-void lambda does not return a value">,
8371-
InGroup<ReturnType>;
8371+
InGroup<ReturnType>, DefaultError;
83728372
def err_access_lambda_capture : Error<
83738373
// The ERRORs represent other special members that aren't constructors, in
83748374
// hopes that someone will bother noticing and reporting if they appear

clang/test/Index/warning-flags.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ int *bar(float *f) { return f; }
99
// RUN: c-index-test -test-load-source-reparse 5 all -w %s 2>&1 | FileCheck -check-prefix=NOWARNINGS %s
1010
// RUN: c-index-test -test-load-source all -w -O4 %s 2>&1 | FileCheck -check-prefix=NOWARNINGS %s
1111

12-
// CHECK-BOTH-WARNINGS: warning: non-void function does not return a value
12+
// CHECK-BOTH-WARNINGS: error: non-void function does not return a value
1313
// CHECK-BOTH-WARNINGS: warning: incompatible pointer types returning 'float *' from a function with result type 'int *'
1414

1515
// CHECK-SECOND-WARNING-NOT:non-void function does not return a value

0 commit comments

Comments
 (0)