summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-13 20:32:04 +0000
committerChris Lattner <sabre@nondot.org>2003-10-13 20:32:04 +0000
commit3875657ee5eef43707b8481143df7630b689432b (patch)
tree57fb9bf163189dbea3ba9fbdca0d0e88335f76a1
parentd12fa6c1045c80e314dbc3be3a2d7b45652a62ad (diff)
downloadllvm-3875657ee5eef43707b8481143df7630b689432b.tar.gz
llvm-3875657ee5eef43707b8481143df7630b689432b.tar.bz2
llvm-3875657ee5eef43707b8481143df7630b689432b.tar.xz
Do not allow fallthroughs in switch statements. This fixes PR37,
253.perlbmk, and test/Programs/SingleSource/UnitTests/2003-10-13-SwitchTest.c! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9101 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/CBackend/CBackend.cpp4
-rw-r--r--lib/Target/CBackend/Writer.cpp4
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index dea97e92f9..a3607be8a0 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -1057,7 +1057,9 @@ void CWriter::printBranchToBlock(BasicBlock *CurBB, BasicBlock *Succ,
Out << "; /* for PHI node */\n";
}
- if (CurBB->getNext() != Succ || isa<InvokeInst>(CurBB->getTerminator())) {
+ if (CurBB->getNext() != Succ ||
+ isa<InvokeInst>(CurBB->getTerminator()) ||
+ isa<SwitchInst>(CurBB->getTerminator())) {
Out << std::string(Indent, ' ') << " goto ";
writeOperand(Succ);
Out << ";\n";
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index dea97e92f9..a3607be8a0 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -1057,7 +1057,9 @@ void CWriter::printBranchToBlock(BasicBlock *CurBB, BasicBlock *Succ,
Out << "; /* for PHI node */\n";
}
- if (CurBB->getNext() != Succ || isa<InvokeInst>(CurBB->getTerminator())) {
+ if (CurBB->getNext() != Succ ||
+ isa<InvokeInst>(CurBB->getTerminator()) ||
+ isa<SwitchInst>(CurBB->getTerminator())) {
Out << std::string(Indent, ' ') << " goto ";
writeOperand(Succ);
Out << ";\n";