-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new flag -Wreturn-mismatch (#82872)
This pull request fixes #72116 where a new flag is introduced for compatibility with GCC 14, the functionality of -Wreturn-type is modified to split some of its behaviors into -Wreturn-mismatch Fixes #72116
- Loading branch information
Showing
5 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// RUN: %clang_cc1 -Wreturn-type -Wno-return-mismatch -fsyntax-only -verify=return-type %s | ||
// RUN: %clang_cc1 -Wno-return-type -Wreturn-mismatch -fsyntax-only -verify=return-mismatch %s | ||
|
||
int foo(void) __attribute__((noreturn)); | ||
int bar(void); | ||
|
||
void test1(void) { | ||
return 1; // return-mismatch-warning{{void function 'test1' should not return a value}} | ||
} | ||
|
||
int test2(void) { | ||
return; // return-mismatch-warning{{non-void function 'test2' should return a value}} | ||
} | ||
|
||
int test3(void) { | ||
// return-type-warning@+1 {{non-void function does not return a value}} | ||
} | ||
|
||
int test4(void) { | ||
(void)(bar() || foo()); // return-type-warning@+1 {{non-void function does not return a value in all control paths}} | ||
} | ||
|
||
void test5(void) { | ||
} // no-warning | ||
|
||
int test6(void) { | ||
return 0; // no-warning | ||
} | ||
|
||
int test7(void) { | ||
foo(); // no warning | ||
} | ||
|
||
int test8(void) { | ||
bar(); // return-type-warning@+1 {{non-void function does not return a value}} | ||
} |