From 33979f75a0fd85a29c3d0a70d4985a20773e8ece Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Wed, 22 Jul 2009 23:56:57 +0000 Subject: Add warning for falling off the end of a function that should return a value. This is on by default, and controlled by -Wreturn-type (-Wmost -Wall). I believe there should be very few false positives, though the most interesting case would be: int() { bar(); } when bar does: bar() { while (1) ; } Here, we assume functions return, unless they are marked with the noreturn attribute. I can envision a fixit note for functions that never return normally that don't have a noreturn attribute to add a noreturn attribute. If anyone spots other false positives, let me know! llvm-svn: 76821 --- clang/lib/Sema/Sema.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'clang/lib/Sema/Sema.h') diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index 78d64b53c09..3bb763a13f8 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -801,10 +801,14 @@ public: SourceLocation MemberLoc, IdentifierInfo &Member); - /// Helpers for dealing with function parameters. + /// Helpers for dealing with functions. + void CheckFallThroughForFunctionDef(Decl *D, Stmt *Body); bool CheckParmsForFunctionDef(FunctionDecl *FD); void CheckCXXDefaultArguments(FunctionDecl *FD); void CheckExtraCXXDefaultArguments(Declarator &D); + enum ControlFlowKind { NeverFallThrough = 0, MaybeFallThrough = 1, + AlwaysFallThrough = 2 }; + ControlFlowKind CheckFallThrough(Stmt *); Scope *getNonFieldDeclScope(Scope *S); -- cgit v1.2.3