From 90963413104034cd883c93e08f7b30949429b169 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Sun, 19 Sep 2010 21:21:10 +0000 Subject: Warn when an expression result in a LabelStmt is unused. llvm-svn: 114314 --- clang/lib/AST/Expr.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'clang/lib/AST/Expr.cpp') diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 4c6822c041f..b31ec2314dc 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1225,9 +1225,13 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1, // however, if the result of the stmt expr is dead, we don't want to emit a // warning. const CompoundStmt *CS = cast(this)->getSubStmt(); - if (!CS->body_empty()) + if (!CS->body_empty()) { if (const Expr *E = dyn_cast(CS->body_back())) return E->isUnusedResultAWarning(Loc, R1, R2, Ctx); + if (const LabelStmt *Label = dyn_cast(CS->body_back())) + if (const Expr *E = dyn_cast(Label->getSubStmt())) + return E->isUnusedResultAWarning(Loc, R1, R2, Ctx); + } if (getType()->isVoidType()) return false; -- cgit v1.2.3