Commit 8b40ca6a by Francois-Xavier Coudert Committed by François-Xavier Coudert

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
parent 9a2b17c9
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> 2015-08-24 Louis Krupp <louis.krupp@zoho.com>
PR fortran/62536 PR fortran/62536
......
...@@ -2298,7 +2298,7 @@ add_functions (void) ...@@ -2298,7 +2298,7 @@ add_functions (void)
make_generic ("lstat", GFC_ISYM_LSTAT, GFC_STD_GNU); make_generic ("lstat", GFC_ISYM_LSTAT, GFC_STD_GNU);
add_sym_1 ("malloc", GFC_ISYM_MALLOC, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER, ii, 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); sz, BT_INTEGER, di, REQUIRED);
make_generic ("malloc", GFC_ISYM_MALLOC, GFC_STD_GNU); make_generic ("malloc", GFC_ISYM_MALLOC, GFC_STD_GNU);
...@@ -3433,7 +3433,7 @@ add_subroutines (void) ...@@ -3433,7 +3433,7 @@ add_subroutines (void)
st, BT_INTEGER, di, OPTIONAL, INTENT_OUT); st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
add_sym_1s ("free", GFC_ISYM_FREE, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU, 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); ptr, BT_INTEGER, ii, REQUIRED, INTENT_INOUT);
add_sym_4s ("fseek", GFC_ISYM_FSEEK, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU, add_sym_4s ("fseek", GFC_ISYM_FSEEK, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
......
...@@ -522,7 +522,6 @@ void gfc_resolve_log (gfc_expr *, gfc_expr *); ...@@ -522,7 +522,6 @@ void gfc_resolve_log (gfc_expr *, gfc_expr *);
void gfc_resolve_log10 (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_logical (gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_lstat (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_matmul (gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_max (gfc_expr *, gfc_actual_arglist *); void gfc_resolve_max (gfc_expr *, gfc_actual_arglist *);
void gfc_resolve_maxloc (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *); void gfc_resolve_maxloc (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *);
...@@ -605,7 +604,6 @@ void gfc_resolve_exit (gfc_code *); ...@@ -605,7 +604,6 @@ void gfc_resolve_exit (gfc_code *);
void gfc_resolve_fdate_sub (gfc_code *); void gfc_resolve_fdate_sub (gfc_code *);
void gfc_resolve_fe_runtime_error (gfc_code *); void gfc_resolve_fe_runtime_error (gfc_code *);
void gfc_resolve_flush (gfc_code *); void gfc_resolve_flush (gfc_code *);
void gfc_resolve_free (gfc_code *);
void gfc_resolve_fseek_sub (gfc_code *); void gfc_resolve_fseek_sub (gfc_code *);
void gfc_resolve_fstat_sub (gfc_code *); void gfc_resolve_fstat_sub (gfc_code *);
void gfc_resolve_ftell_sub (gfc_code *); void gfc_resolve_ftell_sub (gfc_code *);
......
...@@ -1505,25 +1505,6 @@ gfc_resolve_logical (gfc_expr *f, gfc_expr *a, gfc_expr *kind) ...@@ -1505,25 +1505,6 @@ gfc_resolve_logical (gfc_expr *f, gfc_expr *a, gfc_expr *kind)
void 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_resolve_matmul (gfc_expr *f, gfc_expr *a, gfc_expr *b)
{ {
gfc_expr temp; gfc_expr temp;
...@@ -3386,23 +3367,6 @@ gfc_resolve_flush (gfc_code *c) ...@@ -3386,23 +3367,6 @@ gfc_resolve_flush (gfc_code *c)
void 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_resolve_ctime_sub (gfc_code *c)
{ {
gfc_typespec ts; gfc_typespec ts;
......
...@@ -2657,6 +2657,27 @@ gfc_conv_intrinsic_fdate (gfc_se * se, gfc_expr * expr) ...@@ -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 /* Call the SYSTEM_CLOCK library functions, handling the type and kind
conversions. */ conversions. */
...@@ -7648,6 +7669,22 @@ gfc_conv_ieee_arithmetic_function (gfc_se * se, gfc_expr * expr) ...@@ -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 /* Generate code for an intrinsic function. Some map directly to library
calls, others get special handling. In some cases the name of the function calls, others get special handling. In some cases the name of the function
used depends on the type specifiers. */ used depends on the type specifiers. */
...@@ -8078,6 +8115,10 @@ gfc_conv_intrinsic_function (gfc_se * se, gfc_expr * expr) ...@@ -8078,6 +8115,10 @@ gfc_conv_intrinsic_function (gfc_se * se, gfc_expr * expr)
gfc_conv_intrinsic_strcmp (se, expr, LT_EXPR); gfc_conv_intrinsic_strcmp (se, expr, LT_EXPR);
break; break;
case GFC_ISYM_MALLOC:
gfc_conv_intrinsic_malloc (se, expr);
break;
case GFC_ISYM_MASKL: case GFC_ISYM_MASKL:
gfc_conv_intrinsic_mask (se, expr, 1); gfc_conv_intrinsic_mask (se, expr, 1);
break; break;
...@@ -8267,7 +8308,6 @@ gfc_conv_intrinsic_function (gfc_se * se, gfc_expr * expr) ...@@ -8267,7 +8308,6 @@ gfc_conv_intrinsic_function (gfc_se * se, gfc_expr * expr)
case GFC_ISYM_JN2: case GFC_ISYM_JN2:
case GFC_ISYM_LINK: case GFC_ISYM_LINK:
case GFC_ISYM_LSTAT: case GFC_ISYM_LSTAT:
case GFC_ISYM_MALLOC:
case GFC_ISYM_MATMUL: case GFC_ISYM_MATMUL:
case GFC_ISYM_MCLOCK: case GFC_ISYM_MCLOCK:
case GFC_ISYM_MCLOCK8: case GFC_ISYM_MCLOCK8:
...@@ -9536,6 +9576,10 @@ gfc_conv_intrinsic_subroutine (gfc_code *code) ...@@ -9536,6 +9576,10 @@ gfc_conv_intrinsic_subroutine (gfc_code *code)
res = conv_co_collective (code); res = conv_co_collective (code);
break; break;
case GFC_ISYM_FREE:
res = conv_intrinsic_free (code);
break;
case GFC_ISYM_SYSTEM_CLOCK: case GFC_ISYM_SYSTEM_CLOCK:
res = conv_intrinsic_system_clock (code); res = conv_intrinsic_system_clock (code);
break; break;
......
2015-08-28 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/53668
* intrinsics/malloc.c: Adapt comments.
2015-08-28 James Greenhalgh <james.greenhalgh@arm.com> 2015-08-28 James Greenhalgh <james.greenhalgh@arm.com>
* configure.ac: Auto-detect newlib function support unless we * configure.ac: Auto-detect newlib function support unless we
......
...@@ -27,6 +27,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ...@@ -27,6 +27,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <stdlib.h> #include <stdlib.h>
/* The runtime MALLOC and FREE are kept here until the libgfortran ABI
is broken. The front-end now emits direct calls to the GCC's malloc()
and free() built-ins. */
extern void PREFIX(free) (void **); extern void PREFIX(free) (void **);
export_proto_np(PREFIX(free)); export_proto_np(PREFIX(free));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment