+2019-08-06 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/42546
+ * check.c(gfc_check_allocated): Add comment pointing to ...
+ * intrinsic.c(sort_actual): ... the checking done here.
+
2019-08-05 Steven g. Kargl <kargl@gcc.gnu.org>
PR fortran/91372
}
+/* Limited checking for ALLOCATED intrinsic. Additional checking
+ is performed in intrinsic.c(sort_actual), because ALLOCATED
+ has two mutually exclusive non-optional arguments. */
+
bool
gfc_check_allocated (gfc_expr *array)
{
if (f == NULL && a == NULL) /* No arguments */
return true;
+ /* ALLOCATED has two mutually exclusive keywords, but only one
+ can be present at time and neither is optional. */
+ if (strcmp (name, "allocated") == 0 && a->name)
+ {
+ if (strcmp (a->name, "scalar") == 0)
+ {
+ if (a->next)
+ goto whoops;
+ if (a->expr->rank != 0)
+ {
+ gfc_error ("Scalar entity required at %L", &a->expr->where);
+ return false;
+ }
+ return true;
+ }
+ else if (strcmp (a->name, "array") == 0)
+ {
+ if (a->next)
+ goto whoops;
+ if (a->expr->rank == 0)
+ {
+ gfc_error ("Array entity required at %L", &a->expr->where);
+ return false;
+ }
+ return true;
+ }
+ else
+ {
+ gfc_error ("Invalid keyword %qs in %qs intrinsic function at %L",
+ a->name, name, &a->expr->where);
+ return false;
+ }
+ }
+
for (;;)
{ /* Put the nonkeyword arguments in a 1:1 correspondence */
if (f == NULL)
if (a == NULL)
goto do_sort;
+whoops:
gfc_error ("Too many arguments in call to %qs at %L", name, where);
return false;
+2019-08-06 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/42546
+ * gfortran.dg/allocated_1.f90: New test.
+ * gfortran.dg/allocated_2.f90: Ditto.
+
2019-08-06 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* gcc.target/i386/avx512vp2intersect-2intersect-1b.c (AVX512F):
--- /dev/null
+! { dg-do run }
+program foo
+
+ implicit none
+
+ integer, allocatable :: x
+ integer, allocatable :: a(:)
+
+ logical a1, a2
+
+ a1 = allocated(scalar=x)
+ if (a1 .neqv. .false.) stop 1
+ a2 = allocated(array=a)
+ if (a2 .neqv. .false.) stop 2
+
+ allocate(x)
+ allocate(a(2))
+
+ a1 = allocated(scalar=x)
+ if (a1 .neqv. .true.) stop 3
+ a2 = allocated(array=a)
+ if (a2 .neqv. .true.) stop 4
+
+end program foo
--- /dev/null
+! { dg-do compile }
+program foo
+
+ implicit none
+
+ integer, allocatable :: x
+ integer, allocatable :: a(:)
+
+ logical a1, a2
+
+ a1 = allocated(scalar=a) ! { dg-error "Scalar entity required" }
+ a2 = allocated(array=x) ! { dg-error "Array entity required" }
+ a1 = allocated(scalar=x, array=a) ! { dg-error "Too many arguments" }
+ a1 = allocated(array=a, scalar=x) ! { dg-error "Too many arguments" }
+
+end program foo