File tree 5 files changed +46
-4
lines changed 5 files changed +46
-4
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,9 @@ Deprecated Compiler Flags
183
183
184
184
Modified Compiler Flags
185
185
-----------------------
186
+ - Added a new diagnostic flag ``-Wreturn-mismatch `` which is grouped under
187
+ ``-Wreturn-type ``, and moved some of the diagnostics previously controlled by
188
+ ``-Wreturn-type `` under this new flag. Fixes #GH72116.
186
189
187
190
Removed Compiler Flags
188
191
-------------------------
Original file line number Diff line number Diff line change @@ -617,7 +617,9 @@ def GNURedeclaredEnum : DiagGroup<"gnu-redeclared-enum">;
617
617
def RedundantMove : DiagGroup<"redundant-move">;
618
618
def Register : DiagGroup<"register", [DeprecatedRegister]>;
619
619
def ReturnTypeCLinkage : DiagGroup<"return-type-c-linkage">;
620
- def ReturnType : DiagGroup<"return-type", [ReturnTypeCLinkage]>;
620
+ def ReturnMismatch : DiagGroup<"return-mismatch">;
621
+ def ReturnType : DiagGroup<"return-type", [ReturnTypeCLinkage, ReturnMismatch]>;
622
+
621
623
def BindToTemporaryCopy : DiagGroup<"bind-to-temporary-copy",
622
624
[CXX98CompatBindToTemporaryCopy]>;
623
625
def SelfAssignmentField : DiagGroup<"self-assign-field">;
Original file line number Diff line number Diff line change @@ -10248,14 +10248,14 @@ def warn_second_parameter_to_va_arg_never_compatible : Warning<
10248
10248
10249
10249
def warn_return_missing_expr : Warning<
10250
10250
"non-void %select{function|method}1 %0 should return a value">, DefaultError,
10251
- InGroup<ReturnType >;
10251
+ InGroup<ReturnMismatch >;
10252
10252
def ext_return_missing_expr : ExtWarn<
10253
10253
"non-void %select{function|method}1 %0 should return a value">, DefaultError,
10254
- InGroup<ReturnType >;
10254
+ InGroup<ReturnMismatch >;
10255
10255
def ext_return_has_expr : ExtWarn<
10256
10256
"%select{void function|void method|constructor|destructor}1 %0 "
10257
10257
"should not return a value">,
10258
- DefaultError, InGroup<ReturnType >;
10258
+ DefaultError, InGroup<ReturnMismatch >;
10259
10259
def ext_return_has_void_expr : Extension<
10260
10260
"void %select{function|method|block}1 %0 should not return void expression">;
10261
10261
def err_return_init_list : Error<
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ CHECK-NEXT: -Wreorder-ctor
44
44
CHECK - NEXT : - Wreorder - init - list
45
45
CHECK - NEXT : - Wreturn - type
46
46
CHECK - NEXT : - Wreturn - type - c - linkage
47
+ CHECK - NEXT : - Wreturn - mismatch
47
48
CHECK - NEXT : - Wself - assign
48
49
CHECK - NEXT : - Wself - assign - overloaded
49
50
CHECK - NEXT : - Wself - assign - field
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -Wreturn-type -Wno-return-mismatch -fsyntax-only -verify=return-type %s
2
+ // RUN: %clang_cc1 -Wno-return-type -Wreturn-mismatch -fsyntax-only -verify=return-mismatch %s
3
+
4
+ int foo (void ) __attribute__((noreturn ));
5
+ int bar (void );
6
+
7
+ void test1 (void ) {
8
+ return 1 ; // return-mismatch-warning{{void function 'test1' should not return a value}}
9
+ }
10
+
11
+ int test2 (void ) {
12
+ return ; // return-mismatch-warning{{non-void function 'test2' should return a value}}
13
+ }
14
+
15
+ int test3 (void ) {
16
+ // return-type-warning@+1 {{non-void function does not return a value}}
17
+ }
18
+
19
+ int test4 (void ) {
20
+ (void )(bar () || foo ()); // return-type-warning@+1 {{non-void function does not return a value in all control paths}}
21
+ }
22
+
23
+ void test5 (void ) {
24
+ } // no-warning
25
+
26
+ int test6 (void ) {
27
+ return 0 ; // no-warning
28
+ }
29
+
30
+ int test7 (void ) {
31
+ foo (); // no warning
32
+ }
33
+
34
+ int test8 (void ) {
35
+ bar (); // return-type-warning@+1 {{non-void function does not return a value}}
36
+ }
You can’t perform that action at this time.
0 commit comments