-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang] Don't emit redundant warnings for 'return;'
when the function declaration's return type is already invalid for some reason. This is relevant to #49188 because another way that the declaration's return type could become invalid is that it might be `C auto` where `C<void>` is false. Differential Revision: https://reviews.llvm.org/D119094
- Loading branch information
Arthur O'Dwyer
committed
Feb 14, 2022
1 parent
528deed
commit 3c8d2aa
Showing
2 changed files
with
26 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s | ||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s | ||
|
||
// Check that we don't get any extra warning for "return" without an | ||
// expression, in a function that might have been intended to return | ||
// void all along. | ||
auto f1() { | ||
return 1; | ||
return; // expected-error {{deduced as 'void' here but deduced as 'int' in earlier return statement}} | ||
} | ||
|
||
decltype(auto) f2() { | ||
return 1; | ||
return; // expected-error {{deduced as 'void' here but deduced as 'int' in earlier return statement}} | ||
} | ||
|
||
auto *g() { | ||
return; // expected-error {{cannot deduce return type 'auto *' from omitted return expression}} | ||
} | ||
|
||
decltype(h1) h1() { // expected-error {{use of undeclared identifier 'h1'}} | ||
return; | ||
} |