array.c (gfc_match_array_constructor): Support [ ...

fortran/
	* array.c (gfc_match_array_constructor): Support [ ... ]
	style array constructors.
testsuite/
	* gfortran.dg/array_constructor_1.f90: New test.
	* gfortran.dg/array_constructor_2.f90: New test.

From-SVN: r99919
This commit is contained in:
Erik Edelmann 2005-05-18 22:20:31 +03:00 committed by Tobias Schlüter
parent c0fb94d725
commit acc75ae36e
5 changed files with 51 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2005-05-18 Erik Edelmann <erik.edelmann@iki.fi>
* array.c (gfc_match_array_constructor): Support [ ... ]
style array constructors.
2005-05-18 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
* f95-lang.c (gfc_init_builtin_functions): Define BUILT_IN_TRUNC

View File

@ -866,14 +866,27 @@ gfc_match_array_constructor (gfc_expr ** result)
gfc_expr *expr;
locus where;
match m;
const char *end_delim;
if (gfc_match (" (/") == MATCH_NO)
return MATCH_NO;
{
if (gfc_match (" [") == MATCH_NO)
return MATCH_NO;
else
{
if (gfc_notify_std (GFC_STD_F2003, "New in Fortran 2003: [...] "
"style array constructors at %C") == FAILURE)
return MATCH_ERROR;
end_delim = " ]";
}
}
else
end_delim = " /)";
where = gfc_current_locus;
head = tail = NULL;
if (gfc_match (" /)") == MATCH_YES)
if (gfc_match (end_delim) == MATCH_YES)
goto empty; /* Special case */
for (;;)
@ -895,7 +908,7 @@ gfc_match_array_constructor (gfc_expr ** result)
break;
}
if (gfc_match (" /)") == MATCH_NO)
if (gfc_match (end_delim) == MATCH_NO)
goto syntax;
empty:

View File

@ -1,3 +1,8 @@
2005-05-12 Erik Edelmann <erik.edelmann@iki.fi>
* gfortran.dg/array_constructor_1.f90: New test.
* gfortran.dg/array_constructor_2.f90: New test.
2005-05-18 Feng Wang <fengwang@nudt.edu.cn>
PR fortran/20954

View File

@ -0,0 +1,17 @@
! { dg-do run }
! Check that [...] style array constructors work
program bracket_array_constructor
implicit none
integer :: a(4), i
a = [ 1, 2, 3, 4 ] ! { dg-warning "array constructor" }
do i = 1, size(a)
if (a(i) /= i) call abort()
end do
a = [ (/ 1, 2, 3, 4 /) ] ! { dg-warning "array constructor" }
do i = 1, size(a)
if (a(i) /= i) call abort()
end do
end program bracket_array_constructor

View File

@ -0,0 +1,8 @@
! { dg-do compile }
! Check that array constructor delimiters match
program bracket_array_constr_2
implicit none
integer :: a(4)
a = (/ 1, 2, 3, 4 ] ! { dg-error "array constructor" }
a = (/ [ 1, 2, 3, 4 /) ] ! { dg-error "array constructor" }
end program bracket_array_constr_2