diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog index f551debf1..73090195e 100644 --- a/gcc/d/ChangeLog +++ b/gcc/d/ChangeLog @@ -1,3 +1,8 @@ +2015-08-22 Iain Buclaw + + * toir.cc(IRVisitor::visit(TryCatchStatement)): Always emit call to + LIBCALL_BEGIN_CATCH at the start of the catch. + 2015-08-20 Iain Buclaw * toir.cc(IRVisitor::visit): Set input location in all visitors that diff --git a/gcc/d/toir.cc b/gcc/d/toir.cc index e0402a35c..c45d1d4ea 100644 --- a/gcc/d/toir.cc +++ b/gcc/d/toir.cc @@ -785,13 +785,14 @@ class IRVisitor : public Visitor this->start_scope(level_catch); tree catchtype = build_ctype(vcatch->type); + + // Get D's internal exception Object, different from the generic + // exception pointer returned from gcc runtime. + tree ehptr = d_build_call_nary(builtin_decl_explicit(BUILT_IN_EH_POINTER), + 1, integer_zero_node); + tree object = build_libcall(LIBCALL_BEGIN_CATCH, 1, &ehptr); if (vcatch->var) { - // Get D's internal exception Object, different - // from the generic exception pointer. - tree ehptr = d_build_call_nary(builtin_decl_explicit(BUILT_IN_EH_POINTER), - 1, integer_zero_node); - tree object = build_libcall(LIBCALL_BEGIN_CATCH, 1, &ehptr); object = build1(NOP_EXPR, build_ctype(build_object_type()), object); object = convert_expr(object, build_object_type(), vcatch->type); @@ -801,6 +802,12 @@ class IRVisitor : public Visitor build_local_var(vcatch->var); add_stmt(init); } + else + { + // Still need to emit a call to __gdc_begin_catch() to remove + // the object from the uncaught exceptions list. + add_stmt(object); + } if (vcatch->handler) vcatch->handler->accept(this); diff --git a/libphobos/configure b/libphobos/configure index cab2943a9..ffd0972dc 100755 --- a/libphobos/configure +++ b/libphobos/configure @@ -4570,9 +4570,11 @@ case "$d_target_os" in D_EXTRA_OBJS="$D_EXTRA_OBJS \$(OSX_OBJS)" ;; freebsd*|k*bsd*-gnu) + DRUNTIME_OBJS="$DRUNTIME_OBJS \$(RT_FREEBSD_OBJS)" D_EXTRA_OBJS="$D_EXTRA_OBJS \$(FREEBSD_OBJS)" ;; - linux*) D_EXTRA_OBJS="$D_EXTRA_OBJS \$(LINUX_OBJS)" + linux*) DRUNTIME_OBJS="$DRUNTIME_OBJS \$(RT_LINUX_OBJS)" + D_EXTRA_OBJS="$D_EXTRA_OBJS \$(LINUX_OBJS)" ;; mingw*) DRUNTIME_OBJS="$DRUNTIME_OBJS \$(RT_STDC_OBJS)" DRUNTIME_OBJS="$DRUNTIME_OBJS \$(RT_WINDOWS_OBJS)" diff --git a/libphobos/configure.ac b/libphobos/configure.ac index b84bd73ba..2c5dd4b75 100644 --- a/libphobos/configure.ac +++ b/libphobos/configure.ac @@ -320,9 +320,11 @@ case "$d_target_os" in D_EXTRA_OBJS="$D_EXTRA_OBJS \$(OSX_OBJS)" ;; freebsd*|k*bsd*-gnu) + DRUNTIME_OBJS="$DRUNTIME_OBJS \$(RT_FREEBSD_OBJS)" D_EXTRA_OBJS="$D_EXTRA_OBJS \$(FREEBSD_OBJS)" ;; - linux*) D_EXTRA_OBJS="$D_EXTRA_OBJS \$(LINUX_OBJS)" + linux*) DRUNTIME_OBJS="$DRUNTIME_OBJS \$(RT_LINUX_OBJS)" + D_EXTRA_OBJS="$D_EXTRA_OBJS \$(LINUX_OBJS)" ;; mingw*) DRUNTIME_OBJS="$DRUNTIME_OBJS \$(RT_STDC_OBJS)" DRUNTIME_OBJS="$DRUNTIME_OBJS \$(RT_WINDOWS_OBJS)" diff --git a/libphobos/libdruntime/Makefile.am b/libphobos/libdruntime/Makefile.am index 754605813..193ffb108 100644 --- a/libphobos/libdruntime/Makefile.am +++ b/libphobos/libdruntime/Makefile.am @@ -91,7 +91,7 @@ RT_STDC_OBJS=core/stdc/config.o core/stdc/ctype.o core/stdc/errno.o \ RT_LINUX_OBJS= -RT_FREEBSD_OBJS=core/sys/freebsd/execinfo.o core/sys/freebsd/sys/event.o +RT_FREEBSD_OBJS=core/sys/freebsd/sys/event.o RT_OSX_OBJS=core/sys/osx/mach/kern_return.o core/sys/osx/mach/port.o \ core/sys/osx/mach/semaphore.o core/sys/osx/mach/thread_act.o \ diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in index f3c58e656..bb9aebf17 100644 --- a/libphobos/libdruntime/Makefile.in +++ b/libphobos/libdruntime/Makefile.in @@ -258,7 +258,7 @@ RT_STDC_OBJS = core/stdc/config.o core/stdc/ctype.o core/stdc/errno.o \ core/stdc/time.o core/stdc/wchar_.o RT_LINUX_OBJS = -RT_FREEBSD_OBJS = core/sys/freebsd/execinfo.o core/sys/freebsd/sys/event.o +RT_FREEBSD_OBJS = core/sys/freebsd/sys/event.o RT_OSX_OBJS = core/sys/osx/mach/kern_return.o core/sys/osx/mach/port.o \ core/sys/osx/mach/semaphore.o core/sys/osx/mach/thread_act.o \ core/sys/osx/pthread.o diff --git a/libphobos/libdruntime/core/runtime.d b/libphobos/libdruntime/core/runtime.d index 534857941..6d817b49e 100644 --- a/libphobos/libdruntime/core/runtime.d +++ b/libphobos/libdruntime/core/runtime.d @@ -54,7 +54,10 @@ private // backtrace version(GNU) + { + import gcc.builtins; import gcc.backtrace; + } version( linux ) import core.sys.linux.execinfo; @@ -517,6 +520,8 @@ Throwable.TraceInfo defaultTraceHandler( void* ptr = null ) else version( D_InlineAsm_X86_64 ) asm { naked; mov RAX, RBP; ret; } + else version (GNU) + return cast(void**) __builtin_frame_address(0); else return null; } diff --git a/libphobos/libdruntime/core/sys/freebsd/execinfo.d b/libphobos/libdruntime/core/sys/freebsd/execinfo.d index 2c8b470db..237f02b92 100644 --- a/libphobos/libdruntime/core/sys/freebsd/execinfo.d +++ b/libphobos/libdruntime/core/sys/freebsd/execinfo.d @@ -8,6 +8,9 @@ */ module core.sys.freebsd.execinfo; +version (GNU) {} // use gcc.backtrace +else: + version (FreeBSD): extern (C): nothrow: