# HG changeset patch # User ChristianK # Date 1216030290 -7200 # Node ID 82af71383b8a5a6199f0bb04c64b12dabf77e62b # Parent 44daf304421c1bd58fe5e54733ee48872d00a555 [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label. Fixes: nocompile/ finally_02, 03, 07, 08 goto_16_A, 16_B, 12, 13, 14 diff -r 44daf304421c -r 82af71383b8a gen/llvmhelpers.cpp --- a/gen/llvmhelpers.cpp Mon Jul 14 12:00:24 2008 +0200 +++ b/gen/llvmhelpers.cpp Mon Jul 14 12:11:30 2008 +0200 @@ -161,7 +161,7 @@ FuncDeclaration::LabelMap::iterator iter = fd->labmap.find(ident->toChars()); if (iter == fd->labmap.end()) { - if (fd->returnLabel->ident->equals(ident)) + if (fd->returnLabel && fd->returnLabel->ident->equals(ident)) { assert(fd->returnLabel->statement); return fd->returnLabel->statement; @@ -180,11 +180,16 @@ assert(!gIR->scopereturned()); LabelStatement* lblstmt = DtoLabelStatement(target); - assert(lblstmt != NULL); + if(!lblstmt) { + error(*loc, "the label %s does not exist", target->toChars()); + fatal(); + } // if the target label is inside inline asm, error - if(lblstmt->asmLabel) - error(*loc, "cannot goto into inline asm block"); + if(lblstmt->asmLabel) { + error(*loc, "cannot goto to label %s inside an inline asm block", target->toChars()); + fatal(); + } // find target basic block std::string labelname = gIR->func()->getScopedLabelName(target->toChars()); @@ -204,8 +209,10 @@ // goto into finally blocks is forbidden by the spec // though it should not be problematic to implement - if(lblstmt->tf != sourcetf) + if(lblstmt->tf != sourcetf) { error(*loc, "spec disallows goto into finally block"); + fatal(); + } // emit code for finallys between goto and label DtoEnclosingHandlers(enclosinghandler, endfinally);