+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
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 (;;)
break;
}
- if (gfc_match (" /)") == MATCH_NO)
+ if (gfc_match (end_delim) == MATCH_NO)
goto syntax;
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>
PR fortran/20954
--- /dev/null
+! { 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
--- /dev/null
+! { 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