[cfe-commits] r93584 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/warn-unreachable.c
Mike Stump
mrs at apple.com
Fri Jan 15 15:33:51 PST 2010
Author: mrs
Date: Fri Jan 15 17:33:51 2010
New Revision: 93584
URL: http://llvm.org/viewvc/llvm-project?rev=93584&view=rev
Log:
Generalize handling for unreachable code warnings to all binary operators.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/warn-unreachable.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=93584&r1=93583&r2=93584&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Jan 15 17:33:51 2010
@@ -1339,24 +1339,21 @@
switch (S->getStmtClass()) {
case Expr::BinaryOperatorClass: {
- BinaryOperator *Op = cast<BinaryOperator>(S);
- if (Op->getOpcode() == BinaryOperator::Comma) {
- if (b.size() < 2) {
- CFGBlock *n = &b;
- while (1) {
- if (n->getTerminator())
- return n->getTerminator()->getLocStart();
- if (n->succ_size() != 1)
- return SourceLocation();
- n = n[0].succ_begin()[0];
- if (n->pred_size() != 1)
- return SourceLocation();
- if (!n->empty())
- return n[0][0].getStmt()->getLocStart();
- }
+ if (b.size() < 2) {
+ CFGBlock *n = &b;
+ while (1) {
+ if (n->getTerminator())
+ return n->getTerminator()->getLocStart();
+ if (n->succ_size() != 1)
+ return SourceLocation();
+ n = n[0].succ_begin()[0];
+ if (n->pred_size() != 1)
+ return SourceLocation();
+ if (!n->empty())
+ return n[0][0].getStmt()->getLocStart();
}
- return b[1].getStmt()->getLocStart();
}
+ return b[1].getStmt()->getLocStart();
}
default: ;
}
Modified: cfe/trunk/test/Sema/warn-unreachable.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-unreachable.c?rev=93584&r1=93583&r2=93584&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-unreachable.c (original)
+++ cfe/trunk/test/Sema/warn-unreachable.c Fri Jan 15 17:33:51 2010
@@ -1,4 +1,4 @@
-// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code
+// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value
int halt() __attribute__((noreturn));
int live();
@@ -35,9 +35,9 @@
dead(); // expected-warning {{will never be executed}}
case 3:
- live(),
- halt();
- dead(); // expected-warning {{will never be executed}}
+ live()
+ + halt();
+ dead(); // expected-warning {{will never be executed}}
case 4:
a4:
More information about the cfe-commits
mailing list