aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2005-08-09 17:33:17 +0000
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2005-08-09 17:33:17 +0000
commitae8b87895f3ae2557674aad472f58efc2274440b (patch)
treec536f14d5c459cba9c9c7a629d3857e4fb6248ec /gcc
parent0ed414a4f6aa5a2d5fb5e2b6b3e508333cea047e (diff)
downloadgcc-ae8b87895f3ae2557674aad472f58efc2274440b.zip
gcc-ae8b87895f3ae2557674aad472f58efc2274440b.tar.gz
gcc-ae8b87895f3ae2557674aad472f58efc2274440b.tar.bz2
check.c (gfc_check_ttynam_sub, [...]): Add check functions for new intrinsics TTYNAM and ISATTY.
* check.c (gfc_check_ttynam_sub, gfc_check_isatty): Add check functions for new intrinsics TTYNAM and ISATTY. * intrinsic.c (add_functions, add_subroutines): Add new intrinsics. * intrinsic.h: Add prototypes for new check and resolve functions. * iresolve.c (gfc_resolve_isatty, gfc_resolve_ttynam_sub): New resolve functions for intrinsics TTYNAM and ISATTY. * gfortran.h (gfc_generic_isym_id): Add symbol for ISATTY. * trans-intrinsic.c: Add case for GFC_ISYM_ISATTY. * Makefile.am: Add file intrinsics/tty.c to Makefile process. * Makefile.in: Regenerate. * io/io.h: Prototypes for new functions stream_isatty and stream_ttyname. * io/unix (stream_isatty, stream_ttyname): New functions to call isatty() and ttyname() on a given unit. * intrinsics/tty.c: New file to implement g77 intrinsics TTYNAM and ISATTY. From-SVN: r102915
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog13
-rw-r--r--gcc/fortran/check.c32
-rw-r--r--gcc/fortran/gfortran.h1
-rw-r--r--gcc/fortran/intrinsic.c10
-rw-r--r--gcc/fortran/intrinsic.h4
-rw-r--r--gcc/fortran/iresolve.c39
-rw-r--r--gcc/fortran/trans-intrinsic.c1
7 files changed, 100 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 5257714..e19247f 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,16 @@
+2005-08-09 Francois-Xavier Coudert <coudert@clipper.ens.fr>
+
+ * check.c (gfc_check_ttynam_sub, gfc_check_isatty): Add check
+ functions for new intrinsics TTYNAM and ISATTY.
+ * intrinsic.c (add_functions, add_subroutines): Add new
+ intrinsics.
+ * intrinsic.h: Add prototypes for new check and resolve
+ functions.
+ * iresolve.c (gfc_resolve_isatty, gfc_resolve_ttynam_sub): New
+ resolve functions for intrinsics TTYNAM and ISATTY.
+ * gfortran.h (gfc_generic_isym_id): Add symbol for ISATTY.
+ * trans-intrinsic.c: Add case for GFC_ISYM_ISATTY.
+
2005-08-09 Jakub Jelinek <jakub@redhat.com>
* scanner.c (preprocessor_line): Don't write beyond the end of flag
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 57b9068..fbbc96b 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -2574,6 +2574,38 @@ gfc_check_hostnm_sub (gfc_expr * name, gfc_expr * status)
try
+gfc_check_ttynam_sub (gfc_expr * unit, gfc_expr * name)
+{
+ if (scalar_check (unit, 0) == FAILURE)
+ return FAILURE;
+
+ if (type_check (unit, 0, BT_INTEGER) == FAILURE)
+ return FAILURE;
+
+ if (type_check (name, 1, BT_CHARACTER) == FAILURE)
+ return FAILURE;
+
+ return SUCCESS;
+}
+
+
+try
+gfc_check_isatty (gfc_expr * unit)
+{
+ if (unit == NULL)
+ return FAILURE;
+
+ if (type_check (unit, 0, BT_INTEGER) == FAILURE)
+ return FAILURE;
+
+ if (scalar_check (unit, 0) == FAILURE)
+ return FAILURE;
+
+ return SUCCESS;
+}
+
+
+try
gfc_check_perror (gfc_expr * string)
{
if (type_check (string, 0, BT_CHARACTER) == FAILURE)
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 83e71c4..ac27105 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -335,6 +335,7 @@ enum gfc_generic_isym_id
GFC_ISYM_INT,
GFC_ISYM_IOR,
GFC_ISYM_IRAND,
+ GFC_ISYM_ISATTY,
GFC_ISYM_ISHFT,
GFC_ISYM_ISHFTC,
GFC_ISYM_KILL,
diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index 67d95df..a304fbd 100644
--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -1468,6 +1468,12 @@ add_functions (void)
make_generic ("irand", GFC_ISYM_IRAND, GFC_STD_GNU);
+ add_sym_1 ("isatty", 0, 0, BT_LOGICAL, dl, GFC_STD_GNU,
+ gfc_check_isatty, NULL, gfc_resolve_isatty,
+ ut, BT_INTEGER, di, REQUIRED);
+
+ make_generic ("isatty", GFC_ISYM_ISATTY, GFC_STD_GNU);
+
add_sym_2 ("ishft", 1, 1, BT_INTEGER, di, GFC_STD_F95,
gfc_check_ishft, gfc_simplify_ishft, gfc_resolve_ishft,
i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED);
@@ -2247,6 +2253,10 @@ add_subroutines (void)
c, BT_INTEGER, di, OPTIONAL, cr, BT_INTEGER, di, OPTIONAL,
cm, BT_INTEGER, di, OPTIONAL);
+ add_sym_2s ("ttynam", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+ gfc_check_ttynam_sub, NULL, gfc_resolve_ttynam_sub,
+ ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED);
+
add_sym_2s ("umask", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
gfc_check_umask_sub, NULL, gfc_resolve_umask_sub,
val, BT_INTEGER, di, REQUIRED, num, BT_INTEGER, di, OPTIONAL);
diff --git a/gcc/fortran/intrinsic.h b/gcc/fortran/intrinsic.h
index 9c7a844..a10e844 100644
--- a/gcc/fortran/intrinsic.h
+++ b/gcc/fortran/intrinsic.h
@@ -70,6 +70,7 @@ try gfc_check_index (gfc_expr *, gfc_expr *, gfc_expr *);
try gfc_check_int (gfc_expr *, gfc_expr *);
try gfc_check_ior (gfc_expr *, gfc_expr *);
try gfc_check_irand (gfc_expr *);
+try gfc_check_isatty (gfc_expr *);
try gfc_check_ishft (gfc_expr *, gfc_expr *);
try gfc_check_ishftc (gfc_expr *, gfc_expr *, gfc_expr *);
try gfc_check_kill (gfc_expr *, gfc_expr *);
@@ -148,6 +149,7 @@ try gfc_check_symlnk_sub (gfc_expr *, gfc_expr *, gfc_expr *);
try gfc_check_sleep_sub (gfc_expr *);
try gfc_check_stat_sub (gfc_expr *, gfc_expr *, gfc_expr *);
try gfc_check_system_sub (gfc_expr *, gfc_expr *);
+try gfc_check_ttynam_sub (gfc_expr *, gfc_expr *);
try gfc_check_umask_sub (gfc_expr *, gfc_expr *);
try gfc_check_unlink_sub (gfc_expr *, gfc_expr *);
@@ -316,6 +318,7 @@ void gfc_resolve_ichar (gfc_expr *, gfc_expr *);
void gfc_resolve_idnint (gfc_expr *, gfc_expr *);
void gfc_resolve_int (gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_ior (gfc_expr *, gfc_expr *, gfc_expr *);
+void gfc_resolve_isatty (gfc_expr *, gfc_expr *);
void gfc_resolve_ishft (gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_ishftc (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_kill (gfc_expr *, gfc_expr *, gfc_expr *);
@@ -402,6 +405,7 @@ void gfc_resolve_sleep_sub (gfc_code *);
void gfc_resolve_stat_sub (gfc_code *);
void gfc_resolve_system_clock (gfc_code *);
void gfc_resolve_system_sub (gfc_code *);
+void gfc_resolve_ttynam_sub (gfc_code *);
void gfc_resolve_umask_sub (gfc_code *);
void gfc_resolve_unlink_sub (gfc_code *);
diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
index 1b14515..a6f7f27 100644
--- a/gcc/fortran/iresolve.c
+++ b/gcc/fortran/iresolve.c
@@ -712,6 +712,26 @@ gfc_resolve_int (gfc_expr * f, gfc_expr * a, gfc_expr * kind)
void
+gfc_resolve_isatty (gfc_expr * f, gfc_expr * u)
+{
+ gfc_typespec ts;
+
+ f->ts.type = BT_LOGICAL;
+ f->ts.kind = gfc_default_integer_kind;
+ if (u->ts.kind != gfc_c_int_kind)
+ {
+ ts.type = BT_INTEGER;
+ ts.kind = gfc_c_int_kind;
+ ts.derived = NULL;
+ ts.cl = NULL;
+ gfc_convert_type (u, &ts, 2);
+ }
+
+ f->value.function.name = gfc_get_string (PREFIX("isatty_l%d"), f->ts.kind);
+}
+
+
+void
gfc_resolve_ishft (gfc_expr * f, gfc_expr * i, gfc_expr * shift)
{
f->ts = i->ts;
@@ -1939,6 +1959,25 @@ gfc_resolve_fstat_sub (gfc_code * c)
c->resolved_sym = gfc_get_intrinsic_sub_symbol (name);
}
+
+void
+gfc_resolve_ttynam_sub (gfc_code * c)
+{
+ gfc_typespec ts;
+
+ if (c->ext.actual->expr->ts.kind != gfc_c_int_kind)
+ {
+ ts.type = BT_INTEGER;
+ ts.kind = gfc_c_int_kind;
+ ts.derived = NULL;
+ ts.cl = NULL;
+ gfc_convert_type (c->ext.actual->expr, &ts, 2);
+ }
+
+ c->resolved_sym = gfc_get_intrinsic_sub_symbol (PREFIX("ttynam_sub"));
+}
+
+
/* Resolve the UMASK intrinsic subroutine. */
void
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 4e34430..f7907ec 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -2996,6 +2996,7 @@ gfc_conv_intrinsic_function (gfc_se * se, gfc_expr * expr)
case GFC_ISYM_KILL:
case GFC_ISYM_IERRNO:
case GFC_ISYM_IRAND:
+ case GFC_ISYM_ISATTY:
case GFC_ISYM_LINK:
case GFC_ISYM_MATMUL:
case GFC_ISYM_RAND: