check.c (gfc_check_rand): Allow missing optional argument.

2004-10-30  Canqun Yang  <canqun@nudt.edu.cn>

	* check.c (gfc_check_rand): Allow missing optional argument.
	(gfc_check_irand): Ditto.
	* intrinsic.c (add_functions): Set arg optional flag for {i,}rand.
libgfortran/
	* intrinsics/rand.c (irand): Handle NULL argument.

From-SVN: r89886
This commit is contained in:
Canqun Yang 2004-10-30 14:18:34 +00:00 committed by Paul Brook
parent cbb1cada36
commit 7a003d8e2e
5 changed files with 24 additions and 4 deletions

View File

@ -1,9 +1,15 @@
2004-10-30 Canqun Yang <canqun@nudt.edu.cn>
* check.c (gfc_check_rand): Allow missing optional argument.
(gfc_check_irand): Ditto.
* intrinsic.c (add_functions): Set arg optional flag for {i,}rand.
2004-10-28 Scott Robert Ladd <scott.ladd@coyotegulch.com>
PR fortran/13490, PR fortran/17912
* gcc/fortran/gfortran.h: Added pedantic_min_int to gfc_integer_info
* gcc/fortran/gfortran.h: Added ARITH_ASYMMETRIC to arith
* gcc/fortran/arith.c: Added support for an "asymmetric integer"
* gcc/fortran/arith.c: Added support for an "asymmetric integer"
warning when compiling with pedantic.
* gcc/fortran/arith.c: Set minimum integer values to reflect
realities of two's complement signed integers. Added

View File

@ -2001,6 +2001,9 @@ gfc_check_system_clock (gfc_expr * count, gfc_expr * count_rate,
try
gfc_check_irand (gfc_expr * x)
{
if (x == NULL)
return SUCCESS;
if (scalar_check (x, 0) == FAILURE)
return FAILURE;
@ -2016,6 +2019,9 @@ gfc_check_irand (gfc_expr * x)
try
gfc_check_rand (gfc_expr * x)
{
if (x == NULL)
return SUCCESS;
if (scalar_check (x, 0) == FAILURE)
return FAILURE;

View File

@ -1307,7 +1307,7 @@ add_functions (void)
/* The following function is for G77 compatibility. */
add_sym_1 ("irand", 0, 1, BT_INTEGER, 4,
gfc_check_irand, NULL, NULL,
i, BT_INTEGER, 4, 0);
i, BT_INTEGER, 4, 1);
make_generic ("irand", GFC_ISYM_IRAND);
@ -1602,7 +1602,7 @@ add_functions (void)
/* The following function is for G77 compatibility. */
add_sym_1 ("rand", 0, 1, BT_REAL, 4,
gfc_check_rand, NULL, NULL,
i, BT_INTEGER, 4, 0);
i, BT_INTEGER, 4, 1);
/* Compatibility with HP FORTRAN 77/iX Reference. Note, rand() and
ran() use slightly different shoddy multiplicative congruential

View File

@ -1,3 +1,7 @@
2004-10-30 Canqun Yang <canqun@nudt.edu.cn>
* intrinsics/rand.c (irand): Handle NULL argument.
2004-10-07 Paul Brook <paul@codesourcery.com>
* io/transfer.c (finalize_transfer): Free internal streams.

View File

@ -51,7 +51,11 @@ GFC_INTEGER_4
prefix(irand) (GFC_INTEGER_4 *i)
{
GFC_INTEGER_4 j = *i;
GFC_INTEGER_4 j;
if (i)
j = *i;
else
j = 0;
switch (j)
{