re PR fortran/58009 (Elements with same value in vector subscript in variable definition context)
2013-07-28 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/58009 * expr.c (gfc_check_vardef_context): Check for same values in vector expression subscripts. 2013-07-28 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/58009 * gfortran.dg/vector_subsript_7.f90: New test. From-SVN: r201294
This commit is contained in:
parent
b698d310d8
commit
e267932318
4 changed files with 77 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
2013-07-28 Thomas Koenig <tkoenig@gcc.gnu.org>
|
||||
|
||||
PR fortran/58009
|
||||
* expr.c (gfc_check_vardef_context): Check for same values in
|
||||
vector expression subscripts.
|
||||
|
||||
2013-07-27 Tobias Burnus <burnus@net-b.de>
|
||||
|
||||
PR fortran/57991
|
||||
|
|
|
@ -4700,6 +4700,7 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj,
|
|||
bool unlimited;
|
||||
symbol_attribute attr;
|
||||
gfc_ref* ref;
|
||||
int i;
|
||||
|
||||
if (e->expr_type == EXPR_VARIABLE)
|
||||
{
|
||||
|
@ -4922,5 +4923,49 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj,
|
|||
}
|
||||
}
|
||||
|
||||
/* Check for same value in vector expression subscript. */
|
||||
|
||||
if (e->rank > 0)
|
||||
for (ref = e->ref; ref != NULL; ref = ref->next)
|
||||
if (ref->type == REF_ARRAY && ref->u.ar.type == AR_SECTION)
|
||||
for (i = 0; i < GFC_MAX_DIMENSIONS
|
||||
&& ref->u.ar.dimen_type[i] != 0; i++)
|
||||
if (ref->u.ar.dimen_type[i] == DIMEN_VECTOR)
|
||||
{
|
||||
gfc_expr *arr = ref->u.ar.start[i];
|
||||
if (arr->expr_type == EXPR_ARRAY)
|
||||
{
|
||||
gfc_constructor *c, *n;
|
||||
gfc_expr *ec, *en;
|
||||
|
||||
for (c = gfc_constructor_first (arr->value.constructor);
|
||||
c != NULL; c = gfc_constructor_next (c))
|
||||
{
|
||||
if (c == NULL || c->iterator != NULL)
|
||||
continue;
|
||||
|
||||
ec = c->expr;
|
||||
|
||||
for (n = gfc_constructor_next (c); n != NULL;
|
||||
n = gfc_constructor_next (n))
|
||||
{
|
||||
if (n->iterator != NULL)
|
||||
continue;
|
||||
|
||||
en = n->expr;
|
||||
if (gfc_dep_compare_expr (ec, en) == 0)
|
||||
{
|
||||
gfc_error_now ("Elements with the same value at %L"
|
||||
" and %L in vector subscript"
|
||||
" in a variable definition"
|
||||
" context (%s)", &(ec->where),
|
||||
&(en->where), context);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2013-07-28 Thomas Koenig <tkoenig@gcc.gnu.org>
|
||||
|
||||
PR fortran/58009
|
||||
* gfortran.dg/vector_subsript_7.f90: New test.
|
||||
|
||||
2013-07-27 Tobias Burnus <burnus@net-b.de>
|
||||
|
||||
PR fortran/57991
|
||||
|
|
21
gcc/testsuite/gfortran.dg/vector_subscript_7.f90
Normal file
21
gcc/testsuite/gfortran.dg/vector_subscript_7.f90
Normal file
|
@ -0,0 +1,21 @@
|
|||
! { dg-do compile }
|
||||
! PR 58009 - If a vector subscript has two or more elements with the
|
||||
! same value, an array section with that vector subscript
|
||||
! shall not appear in a variable definition context.
|
||||
|
||||
program main
|
||||
real, dimension(4) :: a,b
|
||||
real, dimension(1,4) :: c
|
||||
read (*,*) a([1,2,3,2]),i ! { dg-error "Elements with the same value" }
|
||||
read (*,*) c(1,[1,2,3,2]),i ! { dg-error "Elements with the same value" }
|
||||
b([1+i,1,i+1,2]) = a ! { dg-error "Elements with the same value" }
|
||||
c(1,[1+i,1,i+1,2]) = a ! { dg-error "Elements with the same value" }
|
||||
call foo (a([4,2,1,1])) ! { dg-error "Elements with the same value" }
|
||||
call foo (c(1,[4,2,1,1])) ! { dg-error "Elements with the same value" }
|
||||
print *,a,b
|
||||
contains
|
||||
subroutine foo(arg)
|
||||
real, intent(inout) :: arg(:)
|
||||
arg = arg + 1
|
||||
end subroutine foo
|
||||
end program main
|
Loading…
Add table
Reference in a new issue