This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] intrinsic rand with an optional argument
- From: Canqun Yang <canqun at nudt dot edu dot cn>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Mon, 18 Oct 2004 17:17:50 +0800 (HKT)
- Subject: [PATCH] intrinsic rand with an optional argument
- Reply-to: Canqun Yang <canqun at nudt dot edu dot cn>
The intrinsic rand should have an optional argument,
so both cases in following example are correct.
program rand_ex
write (*, *) rand ()
write (*, *) rand (i)
end
I attached a patch to fix gfortran for such issue.
OK to commit?
Canqun Yang
Creative Compiler Research Group.
National University of Defense Technology, China.
diff -c3p ./old/ChangeLog ./fortran/ChangeLog
*** ./old/ChangeLog 2004-10-12 17:27:09.000000000 +0800
--- ./fortran/ChangeLog 2004-10-12 17:39:32.000000000 +0800
***************
*** 1,3 ****
--- 1,8 ----
+ 2004-10-12 Canqun Yang <canqun@nudt.edu.cn>
+
+ * intrinsic.c (add_functions): Set arg optional flag for rand.
+ * check.c (gfc_check_rand): Don't check missing optional argument.
+
2004-10-10 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
* module.c: Fix formatting issues.
diff -c3p ./old/check.c ./fortran/check.c
*** ./old/check.c 2004-10-12 17:43:53.000000000 +0800
--- ./fortran/check.c 2004-10-12 17:34:51.000000000 +0800
*************** gfc_check_irand (gfc_expr * x)
*** 2016,2021 ****
--- 2016,2024 ----
try
gfc_check_rand (gfc_expr * x)
{
+ if (x == NULL)
+ return SUCCESS;
+
if (scalar_check (x, 0) == FAILURE)
return FAILURE;
diff -c3p ./old/intrinsic.c ./fortran/intrinsic.c
*** ./old/intrinsic.c 2004-10-12 17:29:08.000000000 +0800
--- ./fortran/intrinsic.c 2004-10-12 17:42:36.000000000 +0800
*************** add_functions (void)
*** 1602,1608 ****
/* 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);
/* Compatibility with HP FORTRAN 77/iX Reference. Note, rand() and
ran() use slightly different shoddy multiplicative congruential
--- 1602,1608 ----
/* 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, 1);
/* Compatibility with HP FORTRAN 77/iX Reference. Note, rand() and
ran() use slightly different shoddy multiplicative congruential