SemaStmt.cpp (194613) | SemaStmt.cpp (195341) |
---|---|
1//===--- SemaStmt.cpp - Semantic Analysis for Statements ------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 70 unchanged lines hidden (view full) --- 79 80 // Warn about expressions with unused results if they are non-void and if 81 // this not the last stmt in a stmt expr. 82 if (E->getType()->isVoidType() || (isStmtExpr && i == NumElts-1)) 83 continue; 84 85 SourceLocation Loc; 86 SourceRange R1, R2; | 1//===--- SemaStmt.cpp - Semantic Analysis for Statements ------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 70 unchanged lines hidden (view full) --- 79 80 // Warn about expressions with unused results if they are non-void and if 81 // this not the last stmt in a stmt expr. 82 if (E->getType()->isVoidType() || (isStmtExpr && i == NumElts-1)) 83 continue; 84 85 SourceLocation Loc; 86 SourceRange R1, R2; |
87 if (!E->isUnusedResultAWarning(Loc, R1, R2, Context)) | 87 if (!E->isUnusedResultAWarning(Loc, R1, R2)) |
88 continue; 89 90 Diag(Loc, diag::warn_unused_expr) << R1 << R2; 91 } 92 93 return Owned(new (Context) CompoundStmt(Context, Elts, NumElts, L, R)); 94} 95 --- 665 unchanged lines hidden (view full) --- 761 if (CDRE->isConstQualAdded()) 762 CurBlock->ReturnType.removeConst(); 763 } 764 } else 765 CurBlock->ReturnType = Context.VoidTy; 766 } 767 QualType FnRetType = CurBlock->ReturnType; 768 | 88 continue; 89 90 Diag(Loc, diag::warn_unused_expr) << R1 << R2; 91 } 92 93 return Owned(new (Context) CompoundStmt(Context, Elts, NumElts, L, R)); 94} 95 --- 665 unchanged lines hidden (view full) --- 761 if (CDRE->isConstQualAdded()) 762 CurBlock->ReturnType.removeConst(); 763 } 764 } else 765 CurBlock->ReturnType = Context.VoidTy; 766 } 767 QualType FnRetType = CurBlock->ReturnType; 768 |
769 if (CurBlock->TheDecl->hasAttr<NoReturnAttr>(Context)) { | 769 if (CurBlock->TheDecl->hasAttr |
770 Diag(ReturnLoc, diag::err_noreturn_block_has_return_expr) 771 << getCurFunctionOrMethodDecl()->getDeclName(); 772 return StmtError(); 773 } 774 775 // Otherwise, verify that this result type matches the previous one. We are 776 // pickier with blocks than for normal functions because we don't have GCC 777 // compatibility to worry about here. --- 59 unchanged lines hidden (view full) --- 837Sema::ActOnReturnStmt(SourceLocation ReturnLoc, FullExprArg rex) { 838 Expr *RetValExp = rex->takeAs<Expr>(); 839 if (CurBlock) 840 return ActOnBlockReturnStmt(ReturnLoc, RetValExp); 841 842 QualType FnRetType; 843 if (const FunctionDecl *FD = getCurFunctionDecl()) { 844 FnRetType = FD->getResultType(); | 770 Diag(ReturnLoc, diag::err_noreturn_block_has_return_expr) 771 << getCurFunctionOrMethodDecl()->getDeclName(); 772 return StmtError(); 773 } 774 775 // Otherwise, verify that this result type matches the previous one. We are 776 // pickier with blocks than for normal functions because we don't have GCC 777 // compatibility to worry about here. --- 59 unchanged lines hidden (view full) --- 837Sema::ActOnReturnStmt(SourceLocation ReturnLoc, FullExprArg rex) { 838 Expr *RetValExp = rex->takeAs<Expr>(); 839 if (CurBlock) 840 return ActOnBlockReturnStmt(ReturnLoc, RetValExp); 841 842 QualType FnRetType; 843 if (const FunctionDecl *FD = getCurFunctionDecl()) { 844 FnRetType = FD->getResultType(); |
845 if (FD->hasAttr<NoReturnAttr>(Context)) | 845 if (FD->hasAttr |
846 Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr) 847 << getCurFunctionOrMethodDecl()->getDeclName(); 848 } else if (ObjCMethodDecl *MD = getCurMethodDecl()) 849 FnRetType = MD->getResultType(); 850 else // If we don't have a function/method context, bail. 851 return StmtError(); 852 853 if (FnRetType->isVoidType()) { --- 421 unchanged lines hidden --- | 846 Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr) 847 << getCurFunctionOrMethodDecl()->getDeclName(); 848 } else if (ObjCMethodDecl *MD = getCurMethodDecl()) 849 FnRetType = MD->getResultType(); 850 else // If we don't have a function/method context, bail. 851 return StmtError(); 852 853 if (FnRetType->isVoidType()) { --- 421 unchanged lines hidden --- |