Commit b9a21efd by Steven G. Kargl

re PR fortran/82992 (ICE in create_int_parameter_array, at fortran/module.c:6586)

2019-08-17  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/82992
	* module.c (gfc_match_use):  When renaming a module entity, search
	current namespace for conflicting symbol.

2019-08-17  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/82992
	* gfortran.dg/pr71649.f90: Adjust error messages.
	* gfortran.dg/use_15.f90: Ditto.
	* gfortran.dg/use_rename_8.f90: Ditto.

From-SVN: r274608
parent 716ac0fc
2019-08-17 Steven G. Kargl <kargl@gcc.gnu.org> 2019-08-17 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/82992
* module.c (gfc_match_use): When renaming a module entity, search
current namespace for conflicting symbol.
2019-08-17 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/78739 PR fortran/78739
* match.c (gfc_match_st_function): When matching a statement function, * match.c (gfc_match_st_function): When matching a statement function,
need to check if the statement function name shadows the function need to check if the statement function name shadows the function
......
...@@ -525,6 +525,8 @@ gfc_match_use (void) ...@@ -525,6 +525,8 @@ gfc_match_use (void)
gfc_intrinsic_op op; gfc_intrinsic_op op;
match m; match m;
gfc_use_list *use_list; gfc_use_list *use_list;
gfc_symtree *st;
locus loc;
use_list = gfc_get_use_list (); use_list = gfc_get_use_list ();
...@@ -632,6 +634,8 @@ gfc_match_use (void) ...@@ -632,6 +634,8 @@ gfc_match_use (void)
case INTERFACE_USER_OP: case INTERFACE_USER_OP:
case INTERFACE_GENERIC: case INTERFACE_GENERIC:
case INTERFACE_DTIO: case INTERFACE_DTIO:
loc = gfc_current_locus;
m = gfc_match (" =>"); m = gfc_match (" =>");
if (type == INTERFACE_USER_OP && m == MATCH_YES if (type == INTERFACE_USER_OP && m == MATCH_YES
...@@ -642,6 +646,18 @@ gfc_match_use (void) ...@@ -642,6 +646,18 @@ gfc_match_use (void)
if (type == INTERFACE_USER_OP) if (type == INTERFACE_USER_OP)
new_use->op = INTRINSIC_USER; new_use->op = INTRINSIC_USER;
st = gfc_find_symtree (gfc_current_ns->sym_root, name);
if (st)
{
if (m == MATCH_YES)
gfc_error ("Symbol %qs at %L conflicts with the rename symbol "
"at %L", name, &st->n.sym->declared_at, &loc);
else
gfc_error ("Symbol %qs at %L conflicts with the symbol "
"at %L", name, &st->n.sym->declared_at, &loc);
goto cleanup;
}
if (use_list->only_flag) if (use_list->only_flag)
{ {
if (m != MATCH_YES) if (m != MATCH_YES)
......
2019-08-17 Steven G. Kargl <kargl@gcc.gnu.org> 2019-08-17 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/82992
* gfortran.dg/pr71649.f90: Adjust error messages.
* gfortran.dg/use_15.f90: Ditto.
* gfortran.dg/use_rename_8.f90: Ditto.
2019-08-17 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/78739 PR fortran/78739
* fortran.dg/pr78739.f90: New test. * fortran.dg/pr78739.f90: New test.
......
! { dg-do compile } ! { dg-do compile }
! PR71649 Internal Compiler Error ! PR71649 Internal Compiler Error
SUBROUTINE Compiler_Options ( Options, Version, WriteOpt ) SUBROUTINE Compiler_Options ( Options, Version, WriteOpt ) ! { dg-error "\(1\)" }
USE ISO_FORTRAN_ENV, ONLY : Compiler_Version, Compiler_Options ! { dg-error "already declared" } USE ISO_FORTRAN_ENV, ONLY : Compiler_Version, Compiler_Options ! { dg-error "conflicts with the" }
IMPLICIT NONE IMPLICIT NONE
CHARACTER (LEN=*), INTENT(OUT) :: Options CHARACTER (LEN=*), INTENT(OUT) :: Options
CHARACTER (LEN=*), INTENT(OUT) :: Version CHARACTER (LEN=*), INTENT(OUT) :: Version
LOGICAL, INTENT(IN), OPTIONAL :: WriteOpt LOGICAL, INTENT(IN), OPTIONAL :: WriteOpt
Version = Compiler_Version() Version = Compiler_Version() ! { dg-error "has no IMPLICIT type" }
Options = Compiler_Options() ! { dg-error "Unexpected use of subroutine name" } Options = Compiler_Options() ! { dg-error "Unexpected use of subroutine name" }
RETURN RETURN
END SUBROUTINE Compiler_Options END SUBROUTINE Compiler_Options
...@@ -28,8 +28,8 @@ subroutine my_sub2 (a) ...@@ -28,8 +28,8 @@ subroutine my_sub2 (a)
end subroutine end subroutine
subroutine my_sub3 (a) subroutine my_sub3 (a) ! { dg-error "\(1\)" }
use test_mod2, my_sub3 => my_sub2 ! { dg-error "is also the name of the current program unit" } use test_mod2, my_sub3 => my_sub2 ! { dg-error "conflicts with the rename" }
real a real a
print *, a print *, a
end subroutine end subroutine
......
...@@ -19,8 +19,8 @@ SUBROUTINE T ...@@ -19,8 +19,8 @@ SUBROUTINE T
USE MOO, ONLY: X => B USE MOO, ONLY: X => B
END SUBROUTINE T END SUBROUTINE T
SUBROUTINE C SUBROUTINE C ! { dg-error "\(1\)" }
USE MOO, ONLY: C ! { dg-error "is also the name of the current program unit" } USE MOO, ONLY: C ! { dg-error "conflicts with the" }
END SUBROUTINE C END SUBROUTINE C
SUBROUTINE D SUBROUTINE D
...@@ -36,15 +36,15 @@ SUBROUTINE F ...@@ -36,15 +36,15 @@ SUBROUTINE F
USE MOO, ONLY: X => F USE MOO, ONLY: X => F
END SUBROUTINE F END SUBROUTINE F
SUBROUTINE X SUBROUTINE X ! { dg-error "\(1\)" }
USE MOO, ONLY: X => G ! { dg-error "is also the name of the current program unit" } USE MOO, ONLY: X => G ! { dg-error "conflicts with the rename" }
END SUBROUTINE X END SUBROUTINE X
SUBROUTINE Y SUBROUTINE Y ! { dg-error "\(1\)" }
USE MOO, ONLY: Y => H ! { dg-error "is also the name of the current program unit" } USE MOO, ONLY: Y => H ! { dg-error "conflicts with the rename" }
END SUBROUTINE Y END SUBROUTINE Y
SUBROUTINE Z SUBROUTINE Z ! { dg-error "\(1\)" }
USE MOO, ONLY: Z => I, Z => I ! { dg-error "is also the name of the current program unit" } USE MOO, ONLY: Z => I, Z => I ! { dg-error "conflicts with the rename" }
END SUBROUTINE Z END SUBROUTINE Z
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