Skip to content

Commit 4d3a785

Browse files
author
Igor S. Gerasimov
committed
Merge err_noreturn_has_return_expr
1 parent a0fdfa0 commit 4d3a785

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8396,8 +8396,6 @@ let CategoryName = "Lambda Issue" in {
83968396
"lambda expression in default argument cannot capture any entity">;
83978397
def err_lambda_incomplete_result : Error<
83988398
"incomplete result type %0 in lambda expression">;
8399-
def err_noreturn_lambda_has_return_expr : Error<
8400-
"lambda declared 'noreturn' should not return">;
84018399
def err_access_lambda_capture : Error<
84028400
// The ERRORs represent other special members that aren't constructors, in
84038401
// hopes that someone will bother noticing and reporting if they appear
@@ -10587,14 +10585,16 @@ def err_ctor_dtor_returns_void : Error<
1058710585
def warn_noreturn_function_has_return_expr : Warning<
1058810586
"function %0 declared 'noreturn' should not return">,
1058910587
InGroup<InvalidNoreturn>;
10590-
def warn_falloff_noreturn_function : Warning<
10591-
"function declared 'noreturn' should not return">,
10588+
def warn_noreturn_has_return_expr : Warning<
10589+
"%select{function|block|lambda|coroutine}0 "
10590+
"declared 'noreturn' should not return">,
1059210591
InGroup<InvalidNoreturn>;
10592+
def err_noreturn_has_return_expr : Error<
10593+
"%select{function|block|lambda|coroutine}0 "
10594+
"declared 'noreturn' should not return">;
1059310595
def warn_noreturn_coroutine : Warning<
1059410596
"coroutine %0 cannot be declared 'noreturn' as it always returns a coroutine handle">,
1059510597
InGroup<InvalidNoreturn>;
10596-
def err_noreturn_block_has_return_expr : Error<
10597-
"block declared 'noreturn' should not return">;
1059810598
def err_carries_dependency_missing_on_first_decl : Error<
1059910599
"%select{function|parameter}0 declared '[[carries_dependency]]' "
1060010600
"after its first declaration">;

clang/lib/Sema/AnalysisBasedWarnings.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ struct CheckFallThroughDiagnostics {
553553
static CheckFallThroughDiagnostics MakeForFunction(const Decl *Func) {
554554
CheckFallThroughDiagnostics D;
555555
D.FuncLoc = Func->getLocation();
556-
D.diag_FallThrough_HasNoReturn = diag::warn_falloff_noreturn_function;
556+
D.diag_FallThrough_HasNoReturn = diag::warn_noreturn_has_return_expr;
557557
D.diag_FallThrough_ReturnsNonVoid = diag::warn_falloff_nonvoid;
558558

559559
// Don't suggest that virtual functions be marked "noreturn", since they
@@ -588,7 +588,7 @@ struct CheckFallThroughDiagnostics {
588588

589589
static CheckFallThroughDiagnostics MakeForBlock() {
590590
CheckFallThroughDiagnostics D;
591-
D.diag_FallThrough_HasNoReturn = diag::err_noreturn_block_has_return_expr;
591+
D.diag_FallThrough_HasNoReturn = diag::err_noreturn_has_return_expr;
592592
D.diag_FallThrough_ReturnsNonVoid = diag::err_falloff_nonvoid;
593593
D.diag_NeverFallThroughOrReturn = 0;
594594
D.funMode = Block;
@@ -597,7 +597,7 @@ struct CheckFallThroughDiagnostics {
597597

598598
static CheckFallThroughDiagnostics MakeForLambda() {
599599
CheckFallThroughDiagnostics D;
600-
D.diag_FallThrough_HasNoReturn = diag::err_noreturn_lambda_has_return_expr;
600+
D.diag_FallThrough_HasNoReturn = diag::err_noreturn_has_return_expr;
601601
D.diag_FallThrough_ReturnsNonVoid = diag::warn_falloff_nonvoid;
602602
D.diag_NeverFallThroughOrReturn = 0;
603603
D.funMode = Lambda;
@@ -610,7 +610,7 @@ struct CheckFallThroughDiagnostics {
610610
return (ReturnsVoid ||
611611
D.isIgnored(diag::warn_falloff_nonvoid, FuncLoc)) &&
612612
(!HasNoReturn ||
613-
D.isIgnored(diag::warn_noreturn_function_has_return_expr,
613+
D.isIgnored(diag::warn_noreturn_has_return_expr,
614614
FuncLoc)) &&
615615
(!ReturnsVoid ||
616616
D.isIgnored(diag::warn_suggest_noreturn_block, FuncLoc));
@@ -668,12 +668,12 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,
668668
if (CD.checkDiagnostics(Diags, ReturnsVoid, HasNoReturn))
669669
return;
670670
SourceLocation LBrace = Body->getBeginLoc(), RBrace = Body->getEndLoc();
671-
auto EmitDiag = [&](SourceLocation Loc, unsigned DiagID) {
671+
auto EmitDiag = [&](SourceLocation Loc, unsigned DiagID, unsigned FunMode) {
672672
if (IsCoroutine) {
673673
if (DiagID != 0)
674674
S.Diag(Loc, DiagID) << FSI->CoroutinePromise->getType();
675675
} else {
676-
S.Diag(Loc, DiagID);
676+
S.Diag(Loc, DiagID) << FunMode;
677677
}
678678
};
679679

@@ -688,13 +688,13 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,
688688

689689
case MaybeFallThrough:
690690
if (HasNoReturn)
691-
EmitDiag(RBrace, CD.diag_FallThrough_HasNoReturn);
691+
EmitDiag(RBrace, CD.diag_FallThrough_HasNoReturn, CD.funMode);
692692
else if (!ReturnsVoid)
693693
S.Diag(RBrace, CD.diag_FallThrough_ReturnsNonVoid) << CD.funMode << 1;
694694
break;
695695
case AlwaysFallThrough:
696696
if (HasNoReturn)
697-
EmitDiag(RBrace, CD.diag_FallThrough_HasNoReturn);
697+
EmitDiag(RBrace, CD.diag_FallThrough_HasNoReturn, CD.funMode);
698698
else if (!ReturnsVoid)
699699
S.Diag(RBrace, CD.diag_FallThrough_ReturnsNonVoid) << CD.funMode << 0;
700700
break;

clang/lib/Sema/SemaStmt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3590,7 +3590,7 @@ StmtResult Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc,
35903590

35913591
if (auto *CurBlock = dyn_cast<BlockScopeInfo>(CurCap)) {
35923592
if (CurBlock->FunctionType->castAs<FunctionType>()->getNoReturnAttr()) {
3593-
Diag(ReturnLoc, diag::err_noreturn_block_has_return_expr);
3593+
Diag(ReturnLoc, diag::err_noreturn_has_return_expr) << 1;
35943594
return StmtError();
35953595
}
35963596
} else if (auto *CurRegion = dyn_cast<CapturedRegionScopeInfo>(CurCap)) {
@@ -3601,7 +3601,7 @@ StmtResult Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc,
36013601
if (CurLambda->CallOperator->getType()
36023602
->castAs<FunctionType>()
36033603
->getNoReturnAttr()) {
3604-
Diag(ReturnLoc, diag::err_noreturn_lambda_has_return_expr);
3604+
Diag(ReturnLoc, diag::err_noreturn_has_return_expr) << 2;
36053605
return StmtError();
36063606
}
36073607
}

0 commit comments

Comments
 (0)