This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, fortran] Patch for PR fortran/39352, using -fexceptions.
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org, Steve Ellcey <sje at cup dot hp dot com>, Jakub Jelinek <jakub at redhat dot com>
- Date: Wed, 13 May 2009 14:09:25 +0200
- Subject: Re: [patch, fortran] Patch for PR fortran/39352, using -fexceptions.
Jakub Jelinek wrote:
> On Tue, May 12, 2009 at 05:00:45PM -0700, Steve Ellcey wrote:
> > This patch for PR fortran/39352 initializes eh_personality_libfunc
>
> You should instead do what the C FE does, particularly only initialize
> eh_personality_libfunc if any !$omp constructs are seen
> (other than !$omp atomic)
>
I created the patch based on this (after an IRC discussion with Jakub).
> Alternatively, fix up ia64 unwind generation so that it doesn't require
> a personality function (put 0 in there?).
If this solution is prefered, I leave it to others ...
The following compiles (yeah!) and does essentially the same C is doing
in c-decl.c. I have not bootstrapped not run the full testsuite.
Is this patch OK? And does it work on i64?
Tobias
2009-05-13 Tobias Burnus <burnus@net-b.de>
PR fortran/39352
* f95-lang.c: Add gfc_maybe_initialize_eh.
* gfortran.h: Add gfc_maybe_initialize_eh prototype.
* Make-lang.in: Add new .h dendencies for f95-lang.c
* openmp.c (resolve_omp_do): Call gfc_maybe_initialize_eh.
Index: gcc/fortran/openmp.c
===================================================================
--- gcc/fortran/openmp.c (revision 147469)
+++ gcc/fortran/openmp.c (working copy)
@@ -1503,6 +1503,9 @@ resolve_omp_do (gfc_code *code)
void
gfc_resolve_omp_directive (gfc_code *code, gfc_namespace *ns ATTRIBUTE_UNUSED)
{
+ if (code->op != EXEC_OMP_ATOMIC)
+ gfc_maybe_initialize_eh ();
+
switch (code->op)
{
case EXEC_OMP_DO:
Index: gcc/fortran/gfortran.h
===================================================================
--- gcc/fortran/gfortran.h (revision 147469)
+++ gcc/fortran/gfortran.h (working copy)
@@ -2198,6 +2198,9 @@ unsigned int gfc_init_options (unsigned
int gfc_handle_option (size_t, const char *, int);
bool gfc_post_options (const char **);
+/* f95-lang.c */
+void gfc_maybe_initialize_eh (void);
+
/* iresolve.c */
const char * gfc_get_string (const char *, ...) ATTRIBUTE_PRINTF_1;
bool gfc_find_sym_in_expr (gfc_symbol *, gfc_expr *);
Index: gcc/fortran/f95-lang.c
===================================================================
--- gcc/fortran/f95-lang.c (revision 147469)
+++ gcc/fortran/f95-lang.c (working copy)
@@ -49,6 +49,14 @@ along with GCC; see the file COPYING3.
#include "trans.h"
#include "trans-types.h"
#include "trans-const.h"
+/* For gfc_maybe_initialize_eh. */
+#include "libfuncs.h"
+#define __gfortran_free_save free
+#undef free
+#include "expr.h"
+#define free __gfortran_free_save
+#undef temp
+#include "except.h"
/* Language-dependent contents of an identifier. */
@@ -165,6 +173,10 @@ static GTY(()) struct binding_level *fre
It is indexed by a RID_... value. */
tree *ridpointers = NULL;
+/* True means we've initialized exception handling. */
+bool gfc_eh_initialized_p;
+
+
/* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
or validate its data type for an `if' or `while' statement or ?..: exp.
@@ -1223,5 +1235,21 @@ gfc_init_ts (void)
tree_contains_struct[NAMESPACE_DECL][TS_DECL_MINIMAL] = 1;
}
+void
+gfc_maybe_initialize_eh (void)
+{
+ if (!flag_exceptions || gfc_eh_initialized_p)
+ return;
+
+ gfc_eh_initialized_p = true;
+ eh_personality_libfunc
+ = init_one_libfunc (USING_SJLJ_EXCEPTIONS
+ ? "__gcc_personality_sj0"
+ : "__gcc_personality_v0");
+ default_init_unwind_resume_libfunc ();
+ using_eh_for_cleanups ();
+}
+
+
#include "gt-fortran-f95-lang.h"
#include "gtype-fortran.h"
Index: gcc/fortran/Make-lang.in
===================================================================
--- gcc/fortran/Make-lang.in (revision 147469)
+++ gcc/fortran/Make-lang.in (working copy)
@@ -313,7 +313,8 @@ GFORTRAN_TRANS_DEPS = fortran/gfortran.h
fortran/f95-lang.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \
gt-fortran-f95-lang.h gtype-fortran.h $(CGRAPH_H) $(TARGET_H) fortran/cpp.h \
- $(BUILTINS_DEF) fortran/types.def
+ $(BUILTINS_DEF) fortran/types.def \
+ libfuncs.h expr.h except.h
fortran/scanner.o: toplev.h fortran/cpp.h
fortran/convert.o: $(GFORTRAN_TRANS_DEPS)
fortran/trans.o: $(GFORTRAN_TRANS_DEPS) tree-iterator.h