Commit c4aa95f8 by Janus Weil

re PR fortran/44595 (INTENT of arguments to intrinsic procedures not checked)

2010-08-11  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/44595
	* intrinsic.c (gfc_current_intrinsic_arg): Change type from 'char' to
	'gfc_intrinsic_arg'.
	(check_arglist,check_specific): Add reference to 'name' field.
	(init_arglist): Remove reference to 'name' field.
	* intrinsic.h (gfc_current_intrinsic_arg): Modify prototype.
	* check.c (variable_check): Reverse order of checks. Respect intent of
	formal arg.
	(int_or_proc_check): New function.
	(coarray_check): New function.
	(allocatable_check): New function.
	(gfc_check_allocated,gfc_check_move_alloc): Use 'allocatable_check'.
	(gfc_check_complex): Use 'int_or_real_check'.
	(gfc_check_lcobound,gfc_check_image_index,gfc_check_this_image,
	gfc_check_ucobound): Use 'coarray_check'.
	(gfc_check_pack): Use 'real_or_complex_check'.
	(gfc_check_alarm_sub,gfc_check_signal,gfc_check_signal_sub): Use
	'int_or_proc_check'.
	(scalar_check,type_check,numeric_check,int_or_real_check,
	real_or_complex_check,kind_check,double_check,logical_array_check,
	array_check,same_type_check,rank_check,nonoptional_check,
	kind_value_check,gfc_check_a_p,gfc_check_associated,gfc_check_cmplx,
	gfc_check_cshift,gfc_check_dcmplx,gfc_check_dot_product,gfc_check_dprod,
	gfc_check_eoshift,gfc_check_fn_rc2008,gfc_check_index,gfc_check_kind,
	gfc_check_matmul,gfc_check_minloc_maxloc,check_reduction,gfc_check_null,
	gfc_check_present,gfc_check_reshape,gfc_check_same_type_as,
	gfc_check_spread,gfc_check_unpack,gfc_check_random_seed,
	gfc_check_getarg,gfc_check_and,gfc_check_storage_size): Add reference
	to 'name' field.

2010-08-11  Janus Weil  <janus@gcc.gnu.org>
	    Steve Kargl <kargl@gcc.gnu.org>

	PR fortran/44595
	* gfortran.dg/move_alloc_3.f90: New.
	* gfortran.dg/random_seed_2.f90: New.

Co-Authored-By: Steve Kargl <kargl@gcc.gnu.org>

From-SVN: r163096
parent 481e1176
2010-08-11 Janus Weil <janus@gcc.gnu.org>
PR fortran/44595
* intrinsic.c (gfc_current_intrinsic_arg): Change type from 'char' to
'gfc_intrinsic_arg'.
(check_arglist,check_specific): Add reference to 'name' field.
(init_arglist): Remove reference to 'name' field.
* intrinsic.h (gfc_current_intrinsic_arg): Modify prototype.
* check.c (variable_check): Reverse order of checks. Respect intent of
formal arg.
(int_or_proc_check): New function.
(coarray_check): New function.
(allocatable_check): New function.
(gfc_check_allocated,gfc_check_move_alloc): Use 'allocatable_check'.
(gfc_check_complex): Use 'int_or_real_check'.
(gfc_check_lcobound,gfc_check_image_index,gfc_check_this_image,
gfc_check_ucobound): Use 'coarray_check'.
(gfc_check_pack): Use 'real_or_complex_check'.
(gfc_check_alarm_sub,gfc_check_signal,gfc_check_signal_sub): Use
'int_or_proc_check'.
(scalar_check,type_check,numeric_check,int_or_real_check,
real_or_complex_check,kind_check,double_check,logical_array_check,
array_check,same_type_check,rank_check,nonoptional_check,
kind_value_check,gfc_check_a_p,gfc_check_associated,gfc_check_cmplx,
gfc_check_cshift,gfc_check_dcmplx,gfc_check_dot_product,gfc_check_dprod,
gfc_check_eoshift,gfc_check_fn_rc2008,gfc_check_index,gfc_check_kind,
gfc_check_matmul,gfc_check_minloc_maxloc,check_reduction,gfc_check_null,
gfc_check_present,gfc_check_reshape,gfc_check_same_type_as,
gfc_check_spread,gfc_check_unpack,gfc_check_random_seed,
gfc_check_getarg,gfc_check_and,gfc_check_storage_size): Add reference
to 'name' field.
2010-08-10 Daniel Kraft <d@domob.eu> 2010-08-10 Daniel Kraft <d@domob.eu>
* gfortran.texi (Interoperability with C): Fix ordering in menu * gfortran.texi (Interoperability with C): Fix ordering in menu
......
...@@ -36,7 +36,7 @@ bool gfc_init_expr_flag = false; ...@@ -36,7 +36,7 @@ bool gfc_init_expr_flag = false;
checked. */ checked. */
const char *gfc_current_intrinsic; const char *gfc_current_intrinsic;
const char *gfc_current_intrinsic_arg[MAX_INTRINSIC_ARGS]; gfc_intrinsic_arg *gfc_current_intrinsic_arg[MAX_INTRINSIC_ARGS];
locus *gfc_current_intrinsic_where; locus *gfc_current_intrinsic_where;
static gfc_intrinsic_sym *functions, *subroutines, *conversion, *next_sym; static gfc_intrinsic_sym *functions, *subroutines, *conversion, *next_sym;
...@@ -3390,7 +3390,7 @@ check_arglist (gfc_actual_arglist **ap, gfc_intrinsic_sym *sym, ...@@ -3390,7 +3390,7 @@ check_arglist (gfc_actual_arglist **ap, gfc_intrinsic_sym *sym,
{ {
if (error_flag) if (error_flag)
gfc_error ("Type of argument '%s' in call to '%s' at %L should " gfc_error ("Type of argument '%s' in call to '%s' at %L should "
"be %s, not %s", gfc_current_intrinsic_arg[i], "be %s, not %s", gfc_current_intrinsic_arg[i]->name,
gfc_current_intrinsic, &actual->expr->where, gfc_current_intrinsic, &actual->expr->where,
gfc_typename (&formal->ts), gfc_typename (&formal->ts),
gfc_typename (&actual->expr->ts)); gfc_typename (&actual->expr->ts));
...@@ -3609,7 +3609,7 @@ init_arglist (gfc_intrinsic_sym *isym) ...@@ -3609,7 +3609,7 @@ init_arglist (gfc_intrinsic_sym *isym)
{ {
if (i >= MAX_INTRINSIC_ARGS) if (i >= MAX_INTRINSIC_ARGS)
gfc_internal_error ("init_arglist(): too many arguments"); gfc_internal_error ("init_arglist(): too many arguments");
gfc_current_intrinsic_arg[i++] = formal->name; gfc_current_intrinsic_arg[i++] = formal;
} }
} }
...@@ -3678,8 +3678,8 @@ check_specific (gfc_intrinsic_sym *specific, gfc_expr *expr, int error_flag) ...@@ -3678,8 +3678,8 @@ check_specific (gfc_intrinsic_sym *specific, gfc_expr *expr, int error_flag)
if (gfc_check_conformance (first_expr, arg->expr, if (gfc_check_conformance (first_expr, arg->expr,
"arguments '%s' and '%s' for " "arguments '%s' and '%s' for "
"intrinsic '%s'", "intrinsic '%s'",
gfc_current_intrinsic_arg[0], gfc_current_intrinsic_arg[0]->name,
gfc_current_intrinsic_arg[n], gfc_current_intrinsic_arg[n]->name,
gfc_current_intrinsic) == FAILURE) gfc_current_intrinsic) == FAILURE)
return FAILURE; return FAILURE;
} }
......
...@@ -573,5 +573,5 @@ void gfc_resolve_unlink_sub (gfc_code *); ...@@ -573,5 +573,5 @@ void gfc_resolve_unlink_sub (gfc_code *);
#define MAX_INTRINSIC_ARGS 5 #define MAX_INTRINSIC_ARGS 5
extern const char *gfc_current_intrinsic; extern const char *gfc_current_intrinsic;
extern const char *gfc_current_intrinsic_arg[MAX_INTRINSIC_ARGS]; extern gfc_intrinsic_arg *gfc_current_intrinsic_arg[MAX_INTRINSIC_ARGS];
extern locus *gfc_current_intrinsic_where; extern locus *gfc_current_intrinsic_where;
2010-08-11 Janus Weil <janus@gcc.gnu.org>
Steve Kargl <kargl@gcc.gnu.org>
PR fortran/44595
* gfortran.dg/move_alloc_3.f90: New.
* gfortran.dg/random_seed_2.f90: New.
2010-08-10 John David Anglin <dave.anglin@nrc-cnrc.gc.ca> 2010-08-10 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* lib/target-supports.exp (check_effective_target_sync_int_long): * lib/target-supports.exp (check_effective_target_sync_int_long):
......
! { dg-do compile }
!
! PR 44595: INTENT of arguments to intrinsic procedures not checked
!
! Contributed by Janus Weil <janus@gcc.gnu.org>
subroutine test(f)
implicit none
integer, allocatable, intent(in) :: f
integer, allocatable :: t
call move_alloc(f,t) ! { dg-error "cannot be INTENT.IN." }
end subroutine
! { dg-do compile }
!
! PR 44595: INTENT of arguments to intrinsic procedures not checked
!
! Contributed by Steve Kargl <kargl@gcc.gnu.org>
subroutine reset_seed(iseed)
implicit none
integer, intent(in) :: iseed
call random_seed(iseed) ! { dg-error "cannot be INTENT.IN." }
end subroutine reset_seed
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