Commit 837c4b78 by Janus Weil

re PR fortran/46060 ([F03] procedure pointer component referenced without argument list)

2010-10-21  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/46060
	* match.h (gfc_matching_ptr_assignment): New global variable to indicate
	we're currently matching a (non-proc-)pointer assignment.
	* decl.c (match_pointer_init): Set it.
	* match.c (gfc_match_pointer_assignment): Ditto.
	* primary.c (matching_actual_arglist): New global variable to indicate
	we're currently matching an actual argument list.
	(gfc_match_actual_arglist): Set it.
	(gfc_match_varspec): Reject procedure pointer component calls with
	missing argument list.


2010-10-21  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/46060
	* gfortran.dg/proc_ptr_comp_25.f90: New.

From-SVN: r165769
parent 46241ea9
2010-10-21 Janus Weil <janus@gcc.gnu.org> 2010-10-21 Janus Weil <janus@gcc.gnu.org>
PR fortran/46060
* match.h (gfc_matching_ptr_assignment): New global variable to indicate
we're currently matching a (non-proc-)pointer assignment.
* decl.c (match_pointer_init): Set it.
* match.c (gfc_match_pointer_assignment): Ditto.
* primary.c (matching_actual_arglist): New global variable to indicate
we're currently matching an actual argument list.
(gfc_match_actual_arglist): Set it.
(gfc_match_varspec): Reject procedure pointer component calls with
missing argument list.
2010-10-21 Janus Weil <janus@gcc.gnu.org>
PR fortran/46067 PR fortran/46067
* interface.c (gfc_compare_interfaces): Switch arguments of type * interface.c (gfc_compare_interfaces): Switch arguments of type
comparison (important for polymorphic variables). comparison (important for polymorphic variables).
......
...@@ -1673,8 +1673,10 @@ match_pointer_init (gfc_expr **init, int procptr) ...@@ -1673,8 +1673,10 @@ match_pointer_init (gfc_expr **init, int procptr)
return m; return m;
/* Match non-NULL initialization. */ /* Match non-NULL initialization. */
gfc_matching_ptr_assignment = !procptr;
gfc_matching_procptr_assignment = procptr; gfc_matching_procptr_assignment = procptr;
m = gfc_match_rvalue (init); m = gfc_match_rvalue (init);
gfc_matching_ptr_assignment = 0;
gfc_matching_procptr_assignment = 0; gfc_matching_procptr_assignment = 0;
if (m == MATCH_ERROR) if (m == MATCH_ERROR)
return MATCH_ERROR; return MATCH_ERROR;
......
...@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see
#include "match.h" #include "match.h"
#include "parse.h" #include "parse.h"
int gfc_matching_ptr_assignment = 0;
int gfc_matching_procptr_assignment = 0; int gfc_matching_procptr_assignment = 0;
bool gfc_matching_prefix = false; bool gfc_matching_prefix = false;
...@@ -1331,6 +1332,7 @@ gfc_match_pointer_assignment (void) ...@@ -1331,6 +1332,7 @@ gfc_match_pointer_assignment (void)
old_loc = gfc_current_locus; old_loc = gfc_current_locus;
lvalue = rvalue = NULL; lvalue = rvalue = NULL;
gfc_matching_ptr_assignment = 0;
gfc_matching_procptr_assignment = 0; gfc_matching_procptr_assignment = 0;
m = gfc_match (" %v =>", &lvalue); m = gfc_match (" %v =>", &lvalue);
...@@ -1343,8 +1345,11 @@ gfc_match_pointer_assignment (void) ...@@ -1343,8 +1345,11 @@ gfc_match_pointer_assignment (void)
if (lvalue->symtree->n.sym->attr.proc_pointer if (lvalue->symtree->n.sym->attr.proc_pointer
|| gfc_is_proc_ptr_comp (lvalue, NULL)) || gfc_is_proc_ptr_comp (lvalue, NULL))
gfc_matching_procptr_assignment = 1; gfc_matching_procptr_assignment = 1;
else
gfc_matching_ptr_assignment = 1;
m = gfc_match (" %e%t", &rvalue); m = gfc_match (" %e%t", &rvalue);
gfc_matching_ptr_assignment = 0;
gfc_matching_procptr_assignment = 0; gfc_matching_procptr_assignment = 0;
if (m != MATCH_YES) if (m != MATCH_YES)
goto cleanup; goto cleanup;
......
...@@ -31,6 +31,7 @@ extern gfc_symbol *gfc_new_block; ...@@ -31,6 +31,7 @@ extern gfc_symbol *gfc_new_block;
separate. */ separate. */
extern gfc_st_label *gfc_statement_label; extern gfc_st_label *gfc_statement_label;
extern int gfc_matching_ptr_assignment;
extern int gfc_matching_procptr_assignment; extern int gfc_matching_procptr_assignment;
extern bool gfc_matching_prefix; extern bool gfc_matching_prefix;
......
...@@ -28,6 +28,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -28,6 +28,8 @@ along with GCC; see the file COPYING3. If not see
#include "parse.h" #include "parse.h"
#include "constructor.h" #include "constructor.h"
int matching_actual_arglist = 0;
/* Matches a kind-parameter expression, which is either a named /* Matches a kind-parameter expression, which is either a named
symbolic constant or a nonnegative integer constant. If symbolic constant or a nonnegative integer constant. If
successful, sets the kind value to the correct integer. */ successful, sets the kind value to the correct integer. */
...@@ -1610,6 +1612,8 @@ gfc_match_actual_arglist (int sub_flag, gfc_actual_arglist **argp) ...@@ -1610,6 +1612,8 @@ gfc_match_actual_arglist (int sub_flag, gfc_actual_arglist **argp)
return MATCH_YES; return MATCH_YES;
head = NULL; head = NULL;
matching_actual_arglist++;
for (;;) for (;;)
{ {
if (head == NULL) if (head == NULL)
...@@ -1684,6 +1688,7 @@ gfc_match_actual_arglist (int sub_flag, gfc_actual_arglist **argp) ...@@ -1684,6 +1688,7 @@ gfc_match_actual_arglist (int sub_flag, gfc_actual_arglist **argp)
} }
*argp = head; *argp = head;
matching_actual_arglist--;
return MATCH_YES; return MATCH_YES;
syntax: syntax:
...@@ -1692,7 +1697,7 @@ syntax: ...@@ -1692,7 +1697,7 @@ syntax:
cleanup: cleanup:
gfc_free_actual_arglist (head); gfc_free_actual_arglist (head);
gfc_current_locus = old_loc; gfc_current_locus = old_loc;
matching_actual_arglist--;
return MATCH_ERROR; return MATCH_ERROR;
} }
...@@ -1883,10 +1888,20 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, ...@@ -1883,10 +1888,20 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag,
if (component->attr.proc_pointer && ppc_arg if (component->attr.proc_pointer && ppc_arg
&& !gfc_matching_procptr_assignment) && !gfc_matching_procptr_assignment)
{ {
/* Procedure pointer component call: Look for argument list. */
m = gfc_match_actual_arglist (sub_flag, m = gfc_match_actual_arglist (sub_flag,
&primary->value.compcall.actual); &primary->value.compcall.actual);
if (m == MATCH_ERROR) if (m == MATCH_ERROR)
return MATCH_ERROR; return MATCH_ERROR;
if (m == MATCH_NO && !gfc_matching_ptr_assignment
&& !matching_actual_arglist)
{
gfc_error ("Procedure pointer component '%s' requires an "
"argument list at %C", component->name);
return MATCH_ERROR;
}
if (m == MATCH_YES) if (m == MATCH_YES)
primary->expr_type = EXPR_PPC; primary->expr_type = EXPR_PPC;
......
2010-10-21 Janus Weil <janus@gcc.gnu.org>
PR fortran/46060
* gfortran.dg/proc_ptr_comp_25.f90: New.
2010-10-21 Richard Guenther <rguenther@suse.de> 2010-10-21 Richard Guenther <rguenther@suse.de>
Michael Matz <matz@suse.de> Michael Matz <matz@suse.de>
......
! { dg-do compile }
!
! PR 46060: [F03] procedure pointer component referenced without argument list
!
! Contributed by Stephen J. Bespalko <sjbespa@comcast.net>
implicit none
abstract interface
function name_func (ivar) result (res)
integer, intent(in) :: ivar
character(len=8) :: res
end function name_func
end interface
type var_type
procedure(name_func), nopass, pointer :: name
end type var_type
type(var_type) :: vars
character(len=8) name
name = vars%name ! { dg-error "requires an argument list" }
end
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