diff options
author | Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2015-08-28 20:46:43 +0000 |
---|---|---|
committer | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2015-08-28 20:46:43 +0000 |
commit | 8b40ca6a38070686f7aea3cd661197ca879eab50 (patch) | |
tree | 0cc3b76b4a34aabc245c4c35deaea7eeae0bd64b /gcc | |
parent | 9a2b17c9ddcb00d54aae6de4a5f2367488c400ca (diff) | |
download | gcc-8b40ca6a38070686f7aea3cd661197ca879eab50.zip gcc-8b40ca6a38070686f7aea3cd661197ca879eab50.tar.gz gcc-8b40ca6a38070686f7aea3cd661197ca879eab50.tar.bz2 |
re PR fortran/53668 (Cray-pointer diagnostic enhancement)
PR fortran/53668
* intrinsic.c (add_functions, add_subroutines): Remove resolution
functions for FREE and MALLOC.
* intrinsic.h (gfc_resolve_malloc, gfc_resolve_free): Remove.
* iresolve.c (gfc_resolve_malloc, gfc_resolve_free): Remove.
* trans-intrinsic.c (conv_intrinsic_free,
gfc_conv_intrinsic_malloc): New functions.
* intrinsics/malloc.c: Adapt comments.
From-SVN: r227311
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/fortran/intrinsic.c | 4 | ||||
-rw-r--r-- | gcc/fortran/intrinsic.h | 2 | ||||
-rw-r--r-- | gcc/fortran/iresolve.c | 36 | ||||
-rw-r--r-- | gcc/fortran/trans-intrinsic.c | 46 |
5 files changed, 57 insertions, 41 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9ca5f8d..24def1b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2015-08-28 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> + + PR fortran/53668 + * intrinsic.c (add_functions, add_subroutines): Remove resolution + functions for FREE and MALLOC. + * intrinsic.h (gfc_resolve_malloc, gfc_resolve_free): Remove. + * iresolve.c (gfc_resolve_malloc, gfc_resolve_free): Remove. + * trans-intrinsic.c (conv_intrinsic_free, + gfc_conv_intrinsic_malloc): New functions. + 2015-08-24 Louis Krupp <louis.krupp@zoho.com> PR fortran/62536 diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index a80b16e..b46a5b2 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -2298,7 +2298,7 @@ add_functions (void) make_generic ("lstat", GFC_ISYM_LSTAT, GFC_STD_GNU); add_sym_1 ("malloc", GFC_ISYM_MALLOC, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER, ii, - GFC_STD_GNU, gfc_check_malloc, NULL, gfc_resolve_malloc, + GFC_STD_GNU, gfc_check_malloc, NULL, NULL, sz, BT_INTEGER, di, REQUIRED); make_generic ("malloc", GFC_ISYM_MALLOC, GFC_STD_GNU); @@ -3433,7 +3433,7 @@ add_subroutines (void) st, BT_INTEGER, di, OPTIONAL, INTENT_OUT); add_sym_1s ("free", GFC_ISYM_FREE, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU, - gfc_check_free, NULL, gfc_resolve_free, + gfc_check_free, NULL, NULL, ptr, BT_INTEGER, ii, REQUIRED, INTENT_INOUT); add_sym_4s ("fseek", GFC_ISYM_FSEEK, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU, diff --git a/gcc/fortran/intrinsic.h b/gcc/fortran/intrinsic.h index a9f16f5..4e91b82 100644 --- a/gcc/fortran/intrinsic.h +++ b/gcc/fortran/intrinsic.h @@ -522,7 +522,6 @@ void gfc_resolve_log (gfc_expr *, gfc_expr *); void gfc_resolve_log10 (gfc_expr *, gfc_expr *); void gfc_resolve_logical (gfc_expr *, gfc_expr *, gfc_expr *); void gfc_resolve_lstat (gfc_expr *, gfc_expr *, gfc_expr *); -void gfc_resolve_malloc (gfc_expr *, gfc_expr *); void gfc_resolve_matmul (gfc_expr *, gfc_expr *, gfc_expr *); void gfc_resolve_max (gfc_expr *, gfc_actual_arglist *); void gfc_resolve_maxloc (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *); @@ -605,7 +604,6 @@ void gfc_resolve_exit (gfc_code *); void gfc_resolve_fdate_sub (gfc_code *); void gfc_resolve_fe_runtime_error (gfc_code *); void gfc_resolve_flush (gfc_code *); -void gfc_resolve_free (gfc_code *); void gfc_resolve_fseek_sub (gfc_code *); void gfc_resolve_fstat_sub (gfc_code *); void gfc_resolve_ftell_sub (gfc_code *); diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c index cf79256..7503f18 100644 --- a/gcc/fortran/iresolve.c +++ b/gcc/fortran/iresolve.c @@ -1505,25 +1505,6 @@ gfc_resolve_logical (gfc_expr *f, gfc_expr *a, gfc_expr *kind) void -gfc_resolve_malloc (gfc_expr *f, gfc_expr *size) -{ - if (size->ts.kind < gfc_index_integer_kind) - { - gfc_typespec ts; - gfc_clear_ts (&ts); - - ts.type = BT_INTEGER; - ts.kind = gfc_index_integer_kind; - gfc_convert_type_warn (size, &ts, 2, 0); - } - - f->ts.type = BT_INTEGER; - f->ts.kind = gfc_index_integer_kind; - f->value.function.name = gfc_get_string (PREFIX ("malloc")); -} - - -void gfc_resolve_matmul (gfc_expr *f, gfc_expr *a, gfc_expr *b) { gfc_expr temp; @@ -3386,23 +3367,6 @@ gfc_resolve_flush (gfc_code *c) void -gfc_resolve_free (gfc_code *c) -{ - gfc_typespec ts; - gfc_expr *n; - gfc_clear_ts (&ts); - - ts.type = BT_INTEGER; - ts.kind = gfc_index_integer_kind; - n = c->ext.actual->expr; - if (n->ts.kind != ts.kind) - gfc_convert_type (n, &ts, 2); - - c->resolved_sym = gfc_get_intrinsic_sub_symbol (PREFIX ("free")); -} - - -void gfc_resolve_ctime_sub (gfc_code *c) { gfc_typespec ts; diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index f5b270f..554469e 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -2657,6 +2657,27 @@ gfc_conv_intrinsic_fdate (gfc_se * se, gfc_expr * expr) } +/* Generate a direct call to free() for the FREE subroutine. */ + +static tree +conv_intrinsic_free (gfc_code *code) +{ + stmtblock_t block; + gfc_se argse; + tree arg, call; + + gfc_init_se (&argse, NULL); + gfc_conv_expr (&argse, code->ext.actual->expr); + arg = fold_convert (ptr_type_node, argse.expr); + + gfc_init_block (&block); + call = build_call_expr_loc (input_location, + builtin_decl_explicit (BUILT_IN_FREE), 1, arg); + gfc_add_expr_to_block (&block, call); + return gfc_finish_block (&block); +} + + /* Call the SYSTEM_CLOCK library functions, handling the type and kind conversions. */ @@ -7648,6 +7669,22 @@ gfc_conv_ieee_arithmetic_function (gfc_se * se, gfc_expr * expr) } +/* Generate a direct call to malloc() for the MALLOC intrinsic. */ + +static void +gfc_conv_intrinsic_malloc (gfc_se * se, gfc_expr * expr) +{ + tree arg, res, restype; + + gfc_conv_intrinsic_function_args (se, expr, &arg, 1); + arg = fold_convert (size_type_node, arg); + res = build_call_expr_loc (input_location, + builtin_decl_explicit (BUILT_IN_MALLOC), 1, arg); + restype = gfc_typenode_for_spec (&expr->ts); + se->expr = fold_convert (restype, res); +} + + /* Generate code for an intrinsic function. Some map directly to library calls, others get special handling. In some cases the name of the function used depends on the type specifiers. */ @@ -8078,6 +8115,10 @@ gfc_conv_intrinsic_function (gfc_se * se, gfc_expr * expr) gfc_conv_intrinsic_strcmp (se, expr, LT_EXPR); break; + case GFC_ISYM_MALLOC: + gfc_conv_intrinsic_malloc (se, expr); + break; + case GFC_ISYM_MASKL: gfc_conv_intrinsic_mask (se, expr, 1); break; @@ -8267,7 +8308,6 @@ gfc_conv_intrinsic_function (gfc_se * se, gfc_expr * expr) case GFC_ISYM_JN2: case GFC_ISYM_LINK: case GFC_ISYM_LSTAT: - case GFC_ISYM_MALLOC: case GFC_ISYM_MATMUL: case GFC_ISYM_MCLOCK: case GFC_ISYM_MCLOCK8: @@ -9536,6 +9576,10 @@ gfc_conv_intrinsic_subroutine (gfc_code *code) res = conv_co_collective (code); break; + case GFC_ISYM_FREE: + res = conv_intrinsic_free (code); + break; + case GFC_ISYM_SYSTEM_CLOCK: res = conv_intrinsic_system_clock (code); break; |