From 2fdf8dbed5661336059f647700e66bca1f4cd51a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 9 Jan 2010 19:20:07 +0000 Subject: [PATCH] fix PR5983, reject function bodies with no blocks per the grammar. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93067 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AsmParser/LLParser.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 3ee683f7f67..9de1ff940e8 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -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; -- 2.34.1