Commit acc75ae3 by Erik Edelmann Committed by Tobias Schlüter

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
parent c0fb94d7
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> 2005-05-18 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
* f95-lang.c (gfc_init_builtin_functions): Define BUILT_IN_TRUNC * f95-lang.c (gfc_init_builtin_functions): Define BUILT_IN_TRUNC
......
...@@ -866,14 +866,27 @@ gfc_match_array_constructor (gfc_expr ** result) ...@@ -866,14 +866,27 @@ gfc_match_array_constructor (gfc_expr ** result)
gfc_expr *expr; gfc_expr *expr;
locus where; locus where;
match m; match m;
const char *end_delim;
if (gfc_match (" (/") == MATCH_NO) 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; where = gfc_current_locus;
head = tail = NULL; head = tail = NULL;
if (gfc_match (" /)") == MATCH_YES) if (gfc_match (end_delim) == MATCH_YES)
goto empty; /* Special case */ goto empty; /* Special case */
for (;;) for (;;)
...@@ -895,7 +908,7 @@ gfc_match_array_constructor (gfc_expr ** result) ...@@ -895,7 +908,7 @@ gfc_match_array_constructor (gfc_expr ** result)
break; break;
} }
if (gfc_match (" /)") == MATCH_NO) if (gfc_match (end_delim) == MATCH_NO)
goto syntax; goto syntax;
empty: empty:
......
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> 2005-05-18 Feng Wang <fengwang@nudt.edu.cn>
PR fortran/20954 PR fortran/20954
......
! { 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
! { 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
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