fix PR5983, reject function bodies with no blocks per the grammar.
authorChris Lattner <sabre@nondot.org>
Sat, 9 Jan 2010 19:20:07 +0000 (19:20 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 9 Jan 2010 19:20:07 +0000 (19:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93067 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/LLParser.cpp

index 3ee683f7f67e8853c5d71daf897b036ec692ffd6..9de1ff940e867c5c5118dbfaab7a1f8cb36d4355 100644 (file)
@@ -2779,6 +2779,10 @@ bool LLParser::ParseFunctionBody(Function &Fn) {
   
   PerFunctionState PFS(*this, Fn, FunctionNumber);
 
+  // We need at least one basic block.
+  if (Lex.getKind() == lltok::rbrace || Lex.getKind() == lltok::kw_end)
+    return TokError("function body requires at least one basic block");
+  
   while (Lex.getKind() != lltok::rbrace && Lex.getKind() != lltok::kw_end)
     if (ParseBasicBlock(PFS)) return true;