]> granicus.if.org Git - clang/commit
Add warning for falling off the end of a function that should return a
authorMike Stump <mrs@apple.com>
Wed, 22 Jul 2009 23:56:57 +0000 (23:56 +0000)
committerMike Stump <mrs@apple.com>
Wed, 22 Jul 2009 23:56:57 +0000 (23:56 +0000)
commitb1682c50d26e0f12130d35b7b9b77d40542c4540
treeed86f089a9ffe00991472e1c15cb78c8664e4680
parent7cdbc5832084f45721693dfb1d93284c3e08efee
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!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76821 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/Sema.h
lib/Sema/SemaDecl.cpp
test/Sema/return.c
test/SemaCXX/return.cpp [new file with mode: 0644]
test/SemaObjC/return.m [new file with mode: 0644]