aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2010-01-21 19:51:34 +0000
committerMike Stump <mrs@apple.com>2010-01-21 19:51:34 +0000
commit44582300b63ac128989643adcd12b6349b67abe4 (patch)
tree94bedf3ceefa7ae12f7b38aeb2f568202a417971
parente5fba7058ce34cc3d75e16e777ec6fc8096183f8 (diff)
Improve unreachable code warnings for with respect to c-style casts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94094 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaChecking.cpp5
-rw-r--r--test/Sema/warn-unreachable.c3
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 9fadd45fbb..018132c368 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -2116,6 +2116,11 @@ static SourceLocation GetUnreachableLoc(CFGBlock &b, SourceRange &R1,
const ConditionalOperator *CO = cast<ConditionalOperator>(S);
return CO->getQuestionLoc();
}
+ case Expr::CStyleCastExprClass: {
+ const CStyleCastExpr *CSC = cast<CStyleCastExpr>(S);
+ R1 = CSC->getSubExpr()->getSourceRange();
+ return CSC->getLParenLoc();
+ }
case Expr::ImplicitCastExprClass:
++sn;
goto top;
diff --git a/test/Sema/warn-unreachable.c b/test/Sema/warn-unreachable.c
index 7c913cafb2..b569b18159 100644
--- a/test/Sema/warn-unreachable.c
+++ b/test/Sema/warn-unreachable.c
@@ -87,5 +87,8 @@ void test2() {
halt()
? // expected-warning {{will never be executed}}
dead() : dead();
+ case 10:
+ ( // expected-warning {{will never be executed}}
+ float)halt();
}
}