mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-05 00:31:30 +08:00
Check for illegal reference in function.
This commit is contained in:
parent
2589beb1d1
commit
52354dadb8
@ -1,3 +1,10 @@
|
||||
2020-01-19 Thomas König <tkoenig@gcc.gnu.org>
|
||||
|
||||
PR fortran/44960
|
||||
* primary.c (gfc_match_rvalue): Break after setting MATCH_ERROR.
|
||||
* resolve.c (resolve_function): Issue error when a
|
||||
function call contains a reference.
|
||||
|
||||
2020-01-17 Mark Eggleston <mark.eggleston@codethink.com>
|
||||
|
||||
PR fortran/93236
|
||||
|
@ -3661,6 +3661,7 @@ gfc_match_rvalue (gfc_expr **result)
|
||||
gfc_error ("The leftmost part-ref in a data-ref cannot be a "
|
||||
"function reference at %C");
|
||||
m = MATCH_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
m = MATCH_YES;
|
||||
|
@ -3129,6 +3129,13 @@ resolve_function (gfc_expr *expr)
|
||||
|| sym->intmod_sym_id == GFC_ISYM_CAF_SEND))
|
||||
return true;
|
||||
|
||||
if (expr->ref)
|
||||
{
|
||||
gfc_error ("Unexpected junk after %qs at %L", expr->symtree->n.sym->name,
|
||||
&expr->where);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sym && sym->attr.intrinsic
|
||||
&& !gfc_resolve_intrinsic (sym, &expr->where))
|
||||
return false;
|
||||
|
@ -1,3 +1,9 @@
|
||||
2020-01-19 Thomas König <tkoenig@gcc.gnu.org>
|
||||
|
||||
PR fortran/44960
|
||||
* gfortran.dg/function_reference_1.f90: New test.
|
||||
* gfortran.dg/function_reference_2.f90: New test.
|
||||
|
||||
2020-01-18 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c/92833
|
||||
|
11
gcc/testsuite/gfortran.dg/function_reference_1.f90
Normal file
11
gcc/testsuite/gfortran.dg/function_reference_1.f90
Normal file
@ -0,0 +1,11 @@
|
||||
! { dg-do compile }
|
||||
! PR 44960 - this was erroneusly accepted.
|
||||
! Original test case by Daniel Franke.
|
||||
|
||||
type t
|
||||
integer :: a
|
||||
end type t
|
||||
type(t) :: foo
|
||||
print *, foo(1)%a ! { dg-error "Unexpected junk" }
|
||||
end
|
||||
|
10
gcc/testsuite/gfortran.dg/function_reference_2.f90
Normal file
10
gcc/testsuite/gfortran.dg/function_reference_2.f90
Normal file
@ -0,0 +1,10 @@
|
||||
! { dg-do compile }
|
||||
! PR 44960 - improve the error message
|
||||
program main
|
||||
type t
|
||||
integer :: a
|
||||
end type t
|
||||
type(t) :: foo
|
||||
external foo
|
||||
i = foo(1)%1 ! { dg-error "leftmost part-ref in a data-ref cannot be a function reference" }
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user