Skip to content

Commit adecfd4

Browse files
author
Igor S. Gerasimov
committed
Merge warn_falloff_nonvoid_* into warn_falloff_nonvoid
1 parent 8a87f68 commit adecfd4

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,13 @@ def err_thread_non_global : Error<
713713
def err_thread_unsupported : Error<
714714
"thread-local storage is not supported for the current target">;
715715

716-
def warn_falloff_nonvoid_function : Warning<
717-
"non-void function does not return a value%select{| in all control paths}0">,
716+
def warn_falloff_nonvoid : Warning<
717+
"non-void %select{function|block|lambda|coroutine}0 "
718+
"does not return a value%select{| in all control paths}1">,
719+
InGroup<ReturnType>;
720+
def err_falloff_nonvoid : Warning<
721+
"non-void %select{function|block|lambda|coroutine}0 "
722+
"does not return a value%select{| in all control paths}1">,
718723
InGroup<ReturnType>;
719724
def warn_const_attr_with_pure_attr : Warning<
720725
"'const' attribute imposes more restrictions; 'pure' attribute ignored">,
@@ -723,11 +728,6 @@ def warn_pure_function_returns_void : Warning<
723728
"'%select{pure|const}0' attribute on function returning 'void'; attribute ignored">,
724729
InGroup<IgnoredAttributes>;
725730

726-
def err_falloff_nonvoid_block : Error<
727-
"non-void block does not return a value%select{| in all control paths}0">;
728-
def warn_falloff_nonvoid_coroutine : Warning<
729-
"non-void coroutine does not return a value%select{| in all control paths}0">,
730-
InGroup<ReturnType>;
731731
def warn_suggest_noreturn_function : Warning<
732732
"%select{function|method}0 %1 could be declared with attribute 'noreturn'">,
733733
InGroup<MissingNoreturn>, DefaultIgnore;
@@ -8399,9 +8399,6 @@ let CategoryName = "Lambda Issue" in {
83998399
"incomplete result type %0 in lambda expression">;
84008400
def err_noreturn_lambda_has_return_expr : Error<
84018401
"lambda declared 'noreturn' should not return">;
8402-
def warn_falloff_nonvoid_lambda : Warning<
8403-
"non-void lambda does not return a value%select{| in all control paths}0">,
8404-
InGroup<ReturnType>;
84058402
def err_access_lambda_capture : Error<
84068403
// The ERRORs represent other special members that aren't constructors, in
84078404
// hopes that someone will bother noticing and reporting if they appear

clang/lib/Sema/AnalysisBasedWarnings.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -547,14 +547,14 @@ struct CheckFallThroughDiagnostics {
547547
unsigned diag_FallThrough_HasNoReturn;
548548
unsigned diag_FallThrough_ReturnsNonVoid;
549549
unsigned diag_NeverFallThroughOrReturn;
550-
enum { Function, Block, Lambda, Coroutine } funMode;
550+
enum { Function = 0, Block, Lambda, Coroutine } funMode;
551551
SourceLocation FuncLoc;
552552

553553
static CheckFallThroughDiagnostics MakeForFunction(const Decl *Func) {
554554
CheckFallThroughDiagnostics D;
555555
D.FuncLoc = Func->getLocation();
556556
D.diag_FallThrough_HasNoReturn = diag::warn_falloff_noreturn_function;
557-
D.diag_FallThrough_ReturnsNonVoid = diag::warn_falloff_nonvoid_function;
557+
D.diag_FallThrough_ReturnsNonVoid = diag::warn_falloff_nonvoid;
558558

559559
// Don't suggest that virtual functions be marked "noreturn", since they
560560
// might be overridden by non-noreturn functions.
@@ -580,7 +580,7 @@ struct CheckFallThroughDiagnostics {
580580
CheckFallThroughDiagnostics D;
581581
D.FuncLoc = Func->getLocation();
582582
D.diag_FallThrough_HasNoReturn = 0;
583-
D.diag_FallThrough_ReturnsNonVoid = diag::warn_falloff_nonvoid_coroutine;
583+
D.diag_FallThrough_ReturnsNonVoid = diag::warn_falloff_nonvoid;
584584
D.diag_NeverFallThroughOrReturn = 0;
585585
D.funMode = Coroutine;
586586
return D;
@@ -589,7 +589,7 @@ struct CheckFallThroughDiagnostics {
589589
static CheckFallThroughDiagnostics MakeForBlock() {
590590
CheckFallThroughDiagnostics D;
591591
D.diag_FallThrough_HasNoReturn = diag::err_noreturn_block_has_return_expr;
592-
D.diag_FallThrough_ReturnsNonVoid = diag::err_falloff_nonvoid_block;
592+
D.diag_FallThrough_ReturnsNonVoid = diag::err_falloff_nonvoid;
593593
D.diag_NeverFallThroughOrReturn = 0;
594594
D.funMode = Block;
595595
return D;
@@ -598,7 +598,7 @@ struct CheckFallThroughDiagnostics {
598598
static CheckFallThroughDiagnostics MakeForLambda() {
599599
CheckFallThroughDiagnostics D;
600600
D.diag_FallThrough_HasNoReturn = diag::err_noreturn_lambda_has_return_expr;
601-
D.diag_FallThrough_ReturnsNonVoid = diag::warn_falloff_nonvoid_lambda;
601+
D.diag_FallThrough_ReturnsNonVoid = diag::warn_falloff_nonvoid;
602602
D.diag_NeverFallThroughOrReturn = 0;
603603
D.funMode = Lambda;
604604
return D;
@@ -608,7 +608,7 @@ struct CheckFallThroughDiagnostics {
608608
bool HasNoReturn) const {
609609
if (funMode == Function) {
610610
return (ReturnsVoid ||
611-
D.isIgnored(diag::warn_falloff_nonvoid_function, FuncLoc)) &&
611+
D.isIgnored(diag::warn_falloff_nonvoid, FuncLoc)) &&
612612
(!HasNoReturn ||
613613
D.isIgnored(diag::warn_noreturn_function_has_return_expr,
614614
FuncLoc)) &&
@@ -617,8 +617,7 @@ struct CheckFallThroughDiagnostics {
617617
}
618618
if (funMode == Coroutine) {
619619
return (ReturnsVoid ||
620-
D.isIgnored(diag::warn_falloff_nonvoid_function, FuncLoc) ||
621-
D.isIgnored(diag::warn_falloff_nonvoid_coroutine, FuncLoc)) &&
620+
D.isIgnored(diag::warn_falloff_nonvoid, FuncLoc)) &&
622621
(!HasNoReturn);
623622
}
624623
// For blocks / lambdas.
@@ -689,13 +688,13 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,
689688
if (HasNoReturn)
690689
EmitDiag(RBrace, CD.diag_FallThrough_HasNoReturn);
691690
else if (!ReturnsVoid)
692-
S.Diag(RBrace, CD.diag_FallThrough_ReturnsNonVoid) << 1;
691+
S.Diag(RBrace, CD.diag_FallThrough_ReturnsNonVoid) << CD.funMode << 1;
693692
break;
694693
case AlwaysFallThrough:
695694
if (HasNoReturn)
696695
EmitDiag(RBrace, CD.diag_FallThrough_HasNoReturn);
697696
else if (!ReturnsVoid)
698-
S.Diag(RBrace, CD.diag_FallThrough_ReturnsNonVoid) << 0;
697+
S.Diag(RBrace, CD.diag_FallThrough_ReturnsNonVoid) << CD.funMode << 0;
699698
break;
700699
case NeverFallThroughOrReturn:
701700
if (ReturnsVoid && !HasNoReturn && CD.diag_NeverFallThroughOrReturn) {

0 commit comments

Comments
 (0)