According to the documentation, the handler for a TRY_CATCH_EXPR can be:

- A sequence of statements to execute.  When an exception occurs,
these statements are executed, and then the exception is rethrown.

- A sequence of CATCH_EXPR expressions.  Each CATCH_EXPR
has a list of applicable exception types and handler code.  If the
thrown exception matches one of the caught types, the associated
handler code is executed.  If the handler code falls off the bottom,
execution continues after the original TRY_CATCH_EXPR.

- An EH_FILTER_EXPR expression.  This has a list of
permitted exception types, and code to handle a match failure.  If the
thrown exception does not match one of the allowed types, the
associated match failure code is executed.  If the thrown exception
does match, it continues unwinding the stack looking for the next
handler.

However GatherTypeInfo wasn't expecting the first case, causing a crash
when building the C++ runtime.  Fix and testcase attached.

Ciao,

Duncan.
Index: gcc.llvm/gcc/llvm-convert.cpp
===================================================================
--- gcc.llvm.orig/gcc/llvm-convert.cpp	2007-05-01 16:13:22.000000000 +0200
+++ gcc.llvm/gcc/llvm-convert.cpp	2007-05-01 18:51:29.000000000 +0200
@@ -1868,11 +1868,12 @@
         TypeInfos.push_back(TypeInfo);
       }
     }
-  } else {
-    assert(TREE_CODE(exp) == STATEMENT_LIST && "Need an exp with typeinfo");
-    // Each statement in the statement list will be a catch.
+  } else if (TREE_CODE(exp) == STATEMENT_LIST) {
+    // Each statement in the statement list will be a catch, or none will.
     for (tree_stmt_iterator I = tsi_start(exp); !tsi_end_p(I); tsi_next(&I))
       GatherTypeInfo(tsi_stmt(I), TypeInfos);
+  } else {
+    assert(TypeInfos.empty() && "Need an exp with typeinfo");
   }
 }
 
// RUN: %llvmgxx -S %s -o /dev/null

#include <locale>

namespace std 
{
  codecvt<char, char, mbstate_t>::
  codecvt(size_t __refs)
  : __codecvt_abstract_base<char, char, mbstate_t>(__refs),
  _M_c_locale_codecvt(_S_get_c_locale())
  { }
}
_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to