changeset 357:82af71383b8a trunk

[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
author ChristianK
date Mon, 14 Jul 2008 12:11:30 +0200
parents 44daf304421c
children 051f5b550d9c
files gen/llvmhelpers.cpp
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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);