OSDN Git Service

2006-06-08 Steven G. Kargl <kargls@comcat.net>
[pf3gnuchains/gcc-fork.git] / gcc / fortran / intrinsic.c
index 2aa3f29..403bf08 100644 (file)
@@ -1,6 +1,6 @@
 /* Build up a list of intrinsic subroutines and functions for the
    name-resolution stage.
-   Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation,
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation,
    Inc.
    Contributed by Andy Vaught & Katherine Holcomb
 
@@ -18,18 +18,13 @@ for more details.
 
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.  */
+Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.  */
 
 
 #include "config.h"
 #include "system.h"
 #include "flags.h"
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-
 #include "gfortran.h"
 #include "intrinsic.h"
 
@@ -42,7 +37,8 @@ int gfc_init_expr = 0;
 /* Pointers to an intrinsic function and its argument names that are being
    checked.  */
 
-char *gfc_current_intrinsic, *gfc_current_intrinsic_arg[MAX_INTRINSIC_ARGS];
+const char *gfc_current_intrinsic;
+const char *gfc_current_intrinsic_arg[MAX_INTRINSIC_ARGS];
 locus *gfc_current_intrinsic_where;
 
 static gfc_intrinsic_sym *functions, *subroutines, *conversion, *next_sym;
@@ -83,6 +79,10 @@ gfc_type_letter (bt type)
       c = 'c';
       break;
 
+    case BT_HOLLERITH:
+      c = 'h';
+      break;
+
     default:
       c = 'u';
       break;
@@ -112,7 +112,7 @@ gfc_get_intrinsic_sub_symbol (const char * name)
 /* Return a pointer to the name of a conversion function given two
    typespecs.  */
 
-static char *
+static const char *
 conv_name (gfc_typespec * from, gfc_typespec * to)
 {
   static char name[30];
@@ -120,7 +120,7 @@ conv_name (gfc_typespec * from, gfc_typespec * to)
   sprintf (name, "__convert_%c%d_%c%d", gfc_type_letter (from->type),
           from->kind, gfc_type_letter (to->type), to->kind);
 
-  return name;
+  return gfc_get_string (name);
 }
 
 
@@ -132,7 +132,7 @@ static gfc_intrinsic_sym *
 find_conv (gfc_typespec * from, gfc_typespec * to)
 {
   gfc_intrinsic_sym *sym;
-  char *target;
+  const char *target;
   int i;
 
   target = conv_name (from, to);
@@ -218,13 +218,14 @@ add_sym (const char *name, int elemental, int actual_ok ATTRIBUTE_UNUSED,
         bt type, int kind, int standard, gfc_check_f check,
         gfc_simplify_f simplify, gfc_resolve_f resolve, ...)
 {
-
+  char buf[GFC_MAX_SYMBOL_LEN + 11]; /* 10 for '_gfortran_', 1 for '\0'  */
   int optional, first_flag;
   va_list argp;
 
   /* First check that the intrinsic belongs to the selected standard.
      If not, don't add it to the symbol list.  */
-  if (!(gfc_option.allow_std & standard))
+  if (!(gfc_option.allow_std & standard)
+      && gfc_option.flag_all_intrinsics == 0)
     return;
 
   switch (sizing)
@@ -238,10 +239,11 @@ add_sym (const char *name, int elemental, int actual_ok ATTRIBUTE_UNUSED,
       break;
 
     case SZ_NOTHING:
-      strcpy (next_sym->name, name);
+      next_sym->name = gfc_get_string (name);
 
-      strcpy (next_sym->lib_name, "_gfortran_");
-      strcat (next_sym->lib_name, name);
+      strcpy (buf, "_gfortran_");
+      strcat (buf, name);
+      next_sym->lib_name = gfc_get_string (buf);
 
       next_sym->elemental = elemental;
       next_sym->ts.type = type;
@@ -710,8 +712,13 @@ find_sym (gfc_intrinsic_sym * start, int n, const char *name)
 gfc_intrinsic_sym *
 gfc_find_function (const char *name)
 {
+  gfc_intrinsic_sym *sym;
+
+  sym = find_sym (functions, nfunc, name);
+  if (!sym)
+    sym = find_sym (conversion, nconv, name);
 
-  return find_sym (functions, nfunc, name);
+  return sym;
 }
 
 
@@ -776,7 +783,8 @@ make_generic (const char *name, gfc_generic_isym_id generic_id, int standard)
 {
   gfc_intrinsic_sym *g;
 
-  if (!(gfc_option.allow_std & standard))
+  if (!(gfc_option.allow_std & standard)
+      && gfc_option.flag_all_intrinsics == 0)
     return;
 
   if (sizing != SZ_NOTHING)
@@ -790,11 +798,11 @@ make_generic (const char *name, gfc_generic_isym_id generic_id, int standard)
   g->generic = 1;
   g->specific = 1;
   g->generic_id = generic_id;
-  if ((g + 1)->name[0] != '\0')
+  if ((g + 1)->name != NULL)
     g->specific_head = g + 1;
   g++;
 
-  while (g->name[0] != '\0')
+  while (g->name != NULL)
     {
       g->next = g + 1;
       g->specific = 1;
@@ -813,9 +821,15 @@ make_generic (const char *name, gfc_generic_isym_id generic_id, int standard)
    freed as a single block.  */
 
 static void
-make_alias (const char *name)
+make_alias (const char *name, int standard)
 {
 
+  /* First check that the intrinsic belongs to the selected standard.
+     If not, don't add it to the symbol list.  */
+  if (!(gfc_option.allow_std & standard)
+      && gfc_option.flag_all_intrinsics == 0)
+    return;
+
   switch (sizing)
     {
     case SZ_FUNCS:
@@ -828,7 +842,7 @@ make_alias (const char *name)
 
     case SZ_NOTHING:
       next_sym[0] = next_sym[-1];
-      strcpy (next_sym->name, name);
+      next_sym->name = gfc_get_string (name);
       next_sym++;
       break;
 
@@ -837,6 +851,14 @@ make_alias (const char *name)
     }
 }
 
+/* Make the current subroutine noreturn.  */
+
+static void
+make_noreturn(void)
+{
+  if (sizing == SZ_NOTHING)
+      next_sym[-1].noreturn = 1;
+}
 
 /* Add intrinsic functions.  */
 
@@ -857,7 +879,8 @@ add_functions (void)
     *s = "s", *dm = "dim", *kind = "kind", *msk = "mask",
     *x = "x", *sh = "shift", *stg = "string", *ssg = "substring",
     *y = "y", *sz = "size", *sta = "string_a", *stb = "string_b",
-    *z = "z", *ln = "len", *ut = "unit";
+    *z = "z", *ln = "len", *ut = "unit", *han = "handler",
+    *num = "number", *tm = "time";
 
   int di, dr, dd, dl, dc, dz, ii;
 
@@ -889,18 +912,18 @@ add_functions (void)
             NULL, gfc_simplify_abs, gfc_resolve_abs, 
             a, BT_COMPLEX, dd, REQUIRED);
 
-  make_alias ("cdabs");
+  make_alias ("cdabs", GFC_STD_GNU);
 
   make_generic ("abs", GFC_ISYM_ABS, GFC_STD_F77);
 
   add_sym_1 ("achar", 1, 1, BT_CHARACTER, dc, GFC_STD_F95,
-            NULL, gfc_simplify_achar, NULL,
+            gfc_check_achar, gfc_simplify_achar, NULL,
             i, BT_INTEGER, di, REQUIRED);
 
   make_generic ("achar", GFC_ISYM_ACHAR, GFC_STD_F95);
 
   add_sym_1 ("acos", 1, 1, BT_REAL, dr, GFC_STD_F77,
-            NULL, gfc_simplify_acos, gfc_resolve_acos,
+            gfc_check_fn_r, gfc_simplify_acos, gfc_resolve_acos,
             x, BT_REAL, dr, REQUIRED);
 
   add_sym_1 ("dacos", 1, 1, BT_REAL, dd, GFC_STD_F77,
@@ -909,6 +932,16 @@ add_functions (void)
 
   make_generic ("acos", GFC_ISYM_ACOS, GFC_STD_F77);
 
+  add_sym_1 ("acosh", 1, 1, BT_REAL, dr, GFC_STD_GNU,
+            gfc_check_fn_r, gfc_simplify_acosh, gfc_resolve_acosh,
+            x, BT_REAL, dr, REQUIRED);
+
+  add_sym_1 ("dacosh", 1, 1, BT_REAL, dd, GFC_STD_GNU,
+            NULL, gfc_simplify_acosh, gfc_resolve_acosh,
+            x, BT_REAL, dd, REQUIRED);
+
+  make_generic ("acosh", GFC_ISYM_ACOSH, GFC_STD_GNU);
+
   add_sym_1 ("adjustl", 1, 1, BT_CHARACTER, dc, GFC_STD_F95,
             NULL, gfc_simplify_adjustl, NULL,
             stg, BT_CHARACTER, dc, REQUIRED);
@@ -922,13 +955,17 @@ add_functions (void)
   make_generic ("adjustr", GFC_ISYM_ADJUSTR, GFC_STD_F95);
 
   add_sym_1 ("aimag", 1, 1, BT_REAL, dr, GFC_STD_F77,
-            NULL, gfc_simplify_aimag, gfc_resolve_aimag,
+            gfc_check_fn_c, gfc_simplify_aimag, gfc_resolve_aimag,
             z, BT_COMPLEX, dz, REQUIRED);
 
+  make_alias ("imag", GFC_STD_GNU);
+  make_alias ("imagpart", GFC_STD_GNU);
+
   add_sym_1 ("dimag", 1, 1, BT_REAL, dd, GFC_STD_GNU, 
             NULL, gfc_simplify_aimag, gfc_resolve_aimag, 
             z, BT_COMPLEX, dd, REQUIRED);
 
+
   make_generic ("aimag", GFC_ISYM_AIMAG, GFC_STD_F77);
 
   add_sym_2 ("aint", 1, 1, BT_REAL, dr, GFC_STD_F77,
@@ -970,7 +1007,7 @@ add_functions (void)
   make_generic ("any", GFC_ISYM_ANY, GFC_STD_F95);
 
   add_sym_1 ("asin", 1, 1, BT_REAL, dr, GFC_STD_F77,
-            NULL, gfc_simplify_asin, gfc_resolve_asin,
+            gfc_check_fn_r, gfc_simplify_asin, gfc_resolve_asin,
             x, BT_REAL, dr, REQUIRED);
 
   add_sym_1 ("dasin", 1, 1, BT_REAL, dd, GFC_STD_F77,
@@ -978,6 +1015,16 @@ add_functions (void)
             x, BT_REAL, dd, REQUIRED);
 
   make_generic ("asin", GFC_ISYM_ASIN, GFC_STD_F77);
+  
+  add_sym_1 ("asinh", 1, 1, BT_REAL, dr, GFC_STD_GNU,
+            gfc_check_fn_r, gfc_simplify_asinh, gfc_resolve_asinh,
+            x, BT_REAL, dr, REQUIRED);
+
+  add_sym_1 ("dasinh", 1, 1, BT_REAL, dd, GFC_STD_GNU,
+            NULL, gfc_simplify_asinh, gfc_resolve_asinh,
+            x, BT_REAL, dd, REQUIRED);
+
+  make_generic ("asinh", GFC_ISYM_ASINH, GFC_STD_GNU);
 
   add_sym_2 ("associated", 0, 1, BT_LOGICAL, dl, GFC_STD_F95,
             gfc_check_associated, NULL, NULL,
@@ -986,7 +1033,7 @@ add_functions (void)
   make_generic ("associated", GFC_ISYM_ASSOCIATED, GFC_STD_F95);
 
   add_sym_1 ("atan", 1, 1, BT_REAL, dr, GFC_STD_F77,
-            NULL, gfc_simplify_atan, gfc_resolve_atan,
+            gfc_check_fn_r, gfc_simplify_atan, gfc_resolve_atan,
             x, BT_REAL, dr, REQUIRED);
 
   add_sym_1 ("datan", 1, 1, BT_REAL, dd, GFC_STD_F77,
@@ -994,6 +1041,16 @@ add_functions (void)
             x, BT_REAL, dd, REQUIRED);
 
   make_generic ("atan", GFC_ISYM_ATAN, GFC_STD_F77);
+  
+  add_sym_1 ("atanh", 1, 1, BT_REAL, dr, GFC_STD_GNU,
+            gfc_check_fn_r, gfc_simplify_atanh, gfc_resolve_atanh,
+            x, BT_REAL, dr, REQUIRED);
+
+  add_sym_1 ("datanh", 1, 1, BT_REAL, dd, GFC_STD_GNU,
+            NULL, gfc_simplify_atanh, gfc_resolve_atanh,
+            x, BT_REAL, dd, REQUIRED);
+
+  make_generic ("atanh", GFC_ISYM_ATANH, GFC_STD_GNU);
 
   add_sym_2 ("atan2", 1, 1, BT_REAL, dr, GFC_STD_F77,
             gfc_check_atan2, gfc_simplify_atan2, gfc_resolve_atan2,
@@ -1004,7 +1061,7 @@ add_functions (void)
             y, BT_REAL, dd, REQUIRED, x, BT_REAL, dd, REQUIRED);
 
   make_generic ("atan2", GFC_ISYM_ATAN2, GFC_STD_F77);
-
+  
   /* Bessel and Neumann functions for G77 compatibility.  */
   add_sym_1 ("besj0", 1, 0, BT_REAL, dr, GFC_STD_GNU,
             gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
@@ -1090,6 +1147,12 @@ add_functions (void)
 
   make_generic ("char", GFC_ISYM_CHAR, GFC_STD_F77);
 
+  add_sym_1 ("chdir", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+            gfc_check_chdir, NULL, gfc_resolve_chdir,
+            a, BT_CHARACTER, dc, REQUIRED);
+
+  make_generic ("chdir", GFC_ISYM_CHDIR, GFC_STD_GNU);
+  
   add_sym_3 ("cmplx", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
             gfc_check_cmplx, gfc_simplify_cmplx, gfc_resolve_cmplx,
             x, BT_UNKNOWN, dr, REQUIRED, y, BT_UNKNOWN, dr, OPTIONAL,
@@ -1097,6 +1160,12 @@ add_functions (void)
 
   make_generic ("cmplx", GFC_ISYM_CMPLX, GFC_STD_F77);
 
+  add_sym_2 ("complex", 1, 1, BT_COMPLEX, dz, GFC_STD_GNU,
+            gfc_check_complex, gfc_simplify_complex, gfc_resolve_complex,
+            x, BT_UNKNOWN, dr, REQUIRED, y, BT_UNKNOWN, dr, REQUIRED);
+
+  make_generic ("complex", GFC_ISYM_COMPLEX, GFC_STD_GNU);
+
   /* Making dcmplx a specific of cmplx causes cmplx to return a double
      complex instead of the default complex.  */
 
@@ -1107,7 +1176,7 @@ add_functions (void)
   make_generic ("dcmplx", GFC_ISYM_CMPLX, GFC_STD_GNU);
 
   add_sym_1 ("conjg", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
-            NULL, gfc_simplify_conjg, gfc_resolve_conjg,
+            gfc_check_fn_c, gfc_simplify_conjg, gfc_resolve_conjg,
             z, BT_COMPLEX, dz, REQUIRED);
 
   add_sym_1 ("dconjg", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
@@ -1117,11 +1186,11 @@ add_functions (void)
   make_generic ("conjg", GFC_ISYM_CONJG, GFC_STD_F77);
 
   add_sym_1 ("cos", 1, 1, BT_REAL, dr, GFC_STD_F77,
-            NULL, gfc_simplify_cos, gfc_resolve_cos,
+            gfc_check_fn_rc, gfc_simplify_cos, gfc_resolve_cos,
             x, BT_REAL, dr, REQUIRED);
 
   add_sym_1 ("dcos", 1, 1, BT_REAL, dd, GFC_STD_F77,
-            NULL, gfc_simplify_cos, gfc_resolve_cos,
+            gfc_check_fn_rc, gfc_simplify_cos, gfc_resolve_cos,
             x, BT_REAL, dd, REQUIRED);
 
   add_sym_1 ("ccos", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
@@ -1132,12 +1201,12 @@ add_functions (void)
             NULL, gfc_simplify_cos, gfc_resolve_cos, 
             x, BT_COMPLEX, dd, REQUIRED);
 
-  make_alias ("cdcos");
+  make_alias ("cdcos", GFC_STD_GNU);
 
   make_generic ("cos", GFC_ISYM_COS, GFC_STD_F77);
 
   add_sym_1 ("cosh", 1, 1, BT_REAL, dr, GFC_STD_F77,
-            NULL, gfc_simplify_cosh, gfc_resolve_cosh,
+            gfc_check_fn_r, gfc_simplify_cosh, gfc_resolve_cosh,
             x, BT_REAL, dr, REQUIRED);
 
   add_sym_1 ("dcosh", 1, 1, BT_REAL, dd, GFC_STD_F77,
@@ -1159,11 +1228,17 @@ add_functions (void)
 
   make_generic ("cshift", GFC_ISYM_CSHIFT, GFC_STD_F95);
 
+  add_sym_1 ("ctime", 0, 1, BT_CHARACTER, 0, GFC_STD_GNU,
+              gfc_check_ctime, NULL, gfc_resolve_ctime,
+             tm, BT_INTEGER, di, REQUIRED);
+
+  make_generic ("ctime", GFC_ISYM_CTIME, GFC_STD_GNU);
+
   add_sym_1 ("dble", 1, 1, BT_REAL, dd, GFC_STD_F77,
             gfc_check_dble, gfc_simplify_dble, gfc_resolve_dble,
             a, BT_REAL, dr, REQUIRED);
 
-  make_alias ("dfloat");
+  make_alias ("dfloat", GFC_STD_GNU);
 
   make_generic ("dble", GFC_ISYM_DBLE, GFC_STD_F77);
 
@@ -1244,12 +1319,12 @@ add_functions (void)
             gfc_check_etime, NULL, NULL,
             x, BT_REAL, 4, REQUIRED);
 
-  make_alias ("dtime");
+  make_alias ("dtime", GFC_STD_GNU);
 
   make_generic ("etime", GFC_ISYM_ETIME, GFC_STD_GNU);
 
   add_sym_1 ("exp", 1, 1, BT_REAL, dr,  GFC_STD_F77,
-            NULL, gfc_simplify_exp, gfc_resolve_exp,
+            gfc_check_fn_rc, gfc_simplify_exp, gfc_resolve_exp,
             x, BT_REAL, dr, REQUIRED);
 
   add_sym_1 ("dexp", 1, 1, BT_REAL, dd, GFC_STD_F77,
@@ -1264,7 +1339,7 @@ add_functions (void)
             NULL, gfc_simplify_exp, gfc_resolve_exp, 
             x, BT_COMPLEX, dd, REQUIRED);
 
-  make_alias ("cdexp");
+  make_alias ("cdexp", GFC_STD_GNU);
 
   make_generic ("exp", GFC_ISYM_EXP, GFC_STD_F77);
 
@@ -1274,6 +1349,11 @@ add_functions (void)
 
   make_generic ("exponent", GFC_ISYM_EXPONENT, GFC_STD_F95);
 
+  add_sym_0 ("fdate", 1, 0, BT_CHARACTER, dc, GFC_STD_GNU,
+            NULL, NULL, gfc_resolve_fdate);
+
+  make_generic ("fdate", GFC_ISYM_FDATE, GFC_STD_GNU);
+
   add_sym_2 ("floor", 1, 1, BT_INTEGER, di, GFC_STD_F95,
             gfc_check_a_ikind, gfc_simplify_floor, gfc_resolve_floor,
             a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
@@ -1299,6 +1379,36 @@ add_functions (void)
 
   make_generic ("fstat", GFC_ISYM_FSTAT, GFC_STD_GNU);
 
+  add_sym_1 ("ftell", 0, 1, BT_INTEGER, ii, GFC_STD_GNU,
+            gfc_check_ftell, NULL, gfc_resolve_ftell,
+            ut, BT_INTEGER, di, REQUIRED);
+
+  make_generic ("ftell", GFC_ISYM_FTELL, GFC_STD_GNU);
+
+  add_sym_2 ("fgetc", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+            gfc_check_fgetputc, NULL, gfc_resolve_fgetc,
+            ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED);
+
+  make_generic ("fgetc", GFC_ISYM_FGETC, GFC_STD_GNU);
+
+  add_sym_1 ("fget", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+            gfc_check_fgetput, NULL, gfc_resolve_fget,
+            c, BT_CHARACTER, dc, REQUIRED);
+
+  make_generic ("fget", GFC_ISYM_FGET, GFC_STD_GNU);
+
+  add_sym_2 ("fputc", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+            gfc_check_fgetputc, NULL, gfc_resolve_fputc,
+            ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED);
+
+  make_generic ("fputc", GFC_ISYM_FPUTC, GFC_STD_GNU);
+
+  add_sym_1 ("fput", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+            gfc_check_fgetput, NULL, gfc_resolve_fput,
+            c, BT_CHARACTER, dc, REQUIRED);
+
+  make_generic ("fput", GFC_ISYM_FPUT, GFC_STD_GNU);
+
   /* Unix IDs (g77 compatibility)  */
   add_sym_1 ("getcwd", 0, 1, BT_INTEGER, di,  GFC_STD_GNU,
             NULL, NULL, gfc_resolve_getcwd,
@@ -1321,6 +1431,12 @@ add_functions (void)
 
   make_generic ("getuid", GFC_ISYM_GETUID, GFC_STD_GNU);
 
+  add_sym_1 ("hostnm", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+            gfc_check_hostnm, NULL, gfc_resolve_hostnm,
+            a, BT_CHARACTER, dc, REQUIRED);
+
+  make_generic ("hostnm", GFC_ISYM_HOSTNM, GFC_STD_GNU);
+
   add_sym_1 ("huge", 0, 1, BT_REAL, dr, GFC_STD_F95,
             gfc_check_huge, gfc_simplify_huge, NULL,
             x, BT_UNKNOWN, dr, REQUIRED);
@@ -1328,7 +1444,7 @@ add_functions (void)
   make_generic ("huge", GFC_ISYM_NONE, GFC_STD_F95);
 
   add_sym_1 ("iachar", 1, 1, BT_INTEGER, di, GFC_STD_F95,
-            NULL, gfc_simplify_iachar, NULL,
+            gfc_check_ichar_iachar, gfc_simplify_iachar, NULL,
             c, BT_CHARACTER, dc, REQUIRED);
 
   make_generic ("iachar", GFC_ISYM_IACHAR, GFC_STD_F95);
@@ -1339,6 +1455,12 @@ add_functions (void)
 
   make_generic ("iand", GFC_ISYM_IAND, GFC_STD_F95);
 
+  add_sym_2 ("and", 1, 0, BT_UNKNOWN, 0, GFC_STD_GNU,
+            gfc_check_and, gfc_simplify_and, gfc_resolve_and,
+            i, BT_UNKNOWN, 0, REQUIRED, j, BT_UNKNOWN, 0, REQUIRED);
+
+  make_generic ("and", GFC_ISYM_AND, GFC_STD_GNU);
+
   add_sym_0 ("iargc", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
             NULL, NULL, NULL);
 
@@ -1370,7 +1492,7 @@ add_functions (void)
   make_generic ("ibset", GFC_ISYM_IBSET, GFC_STD_F95);
 
   add_sym_1 ("ichar", 1, 0, BT_INTEGER, di, GFC_STD_F77,
-            NULL, gfc_simplify_ichar, gfc_resolve_ichar,
+            gfc_check_ichar_iachar, gfc_simplify_ichar, gfc_resolve_ichar,
             c, BT_CHARACTER, dc, REQUIRED);
 
   make_generic ("ichar", GFC_ISYM_ICHAR, GFC_STD_F77);
@@ -1381,6 +1503,17 @@ add_functions (void)
 
   make_generic ("ieor", GFC_ISYM_IEOR, GFC_STD_F95);
 
+  add_sym_2 ("xor", 1, 0, BT_UNKNOWN, 0, GFC_STD_GNU,
+            gfc_check_and, gfc_simplify_xor, gfc_resolve_xor,
+            i, BT_UNKNOWN, 0, REQUIRED, j, BT_UNKNOWN, 0, REQUIRED);
+
+  make_generic ("xor", GFC_ISYM_XOR, GFC_STD_GNU);
+
+  add_sym_0 ("ierrno", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
+            NULL, NULL, gfc_resolve_ierrno);
+
+  make_generic ("ierrno", GFC_ISYM_IERRNO, GFC_STD_GNU);
+
   add_sym_3 ("index", 1, 1, BT_INTEGER, di, GFC_STD_F77,
             gfc_check_index, gfc_simplify_index, NULL,
             stg, BT_CHARACTER, dc, REQUIRED, ssg, BT_CHARACTER, dc, REQUIRED,
@@ -1408,6 +1541,12 @@ add_functions (void)
 
   make_generic ("ior", GFC_ISYM_IOR, GFC_STD_F95);
 
+  add_sym_2 ("or", 1, 0, BT_UNKNOWN, 0, GFC_STD_GNU,
+            gfc_check_and, gfc_simplify_or, gfc_resolve_or,
+            i, BT_UNKNOWN, 0, REQUIRED, j, BT_UNKNOWN, 0, REQUIRED);
+
+  make_generic ("or", GFC_ISYM_OR, GFC_STD_GNU);
+
   /* The following function is for G77 compatibility.  */
   add_sym_1 ("irand", 0, 1, BT_INTEGER, 4, GFC_STD_GNU,
              gfc_check_irand, NULL, NULL,
@@ -1415,6 +1554,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);
@@ -1428,6 +1573,12 @@ add_functions (void)
 
   make_generic ("ishftc", GFC_ISYM_ISHFTC, GFC_STD_F95);
 
+  add_sym_2 ("kill", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
+            gfc_check_kill, NULL, gfc_resolve_kill,
+            a, BT_INTEGER, di, REQUIRED, b, BT_INTEGER, di, REQUIRED);
+
+  make_generic ("kill", GFC_ISYM_KILL, GFC_STD_GNU);
+
   add_sym_1 ("kind", 0, 1, BT_INTEGER, di, GFC_STD_F95,
             gfc_check_kind, gfc_simplify_kind, NULL,
             x, BT_REAL, dr, REQUIRED);
@@ -1450,6 +1601,8 @@ add_functions (void)
             NULL, gfc_simplify_len_trim, gfc_resolve_len_trim,
             stg, BT_CHARACTER, dc, REQUIRED);
 
+  make_alias ("lnblnk", GFC_STD_GNU);
+
   make_generic ("len_trim", GFC_ISYM_LEN_TRIM, GFC_STD_F95);
 
   add_sym_2 ("lge", 1, 0, BT_LOGICAL, dl, GFC_STD_F77,
@@ -1476,8 +1629,14 @@ add_functions (void)
 
   make_generic ("llt", GFC_ISYM_LLT, GFC_STD_F77);
 
+  add_sym_2 ("link", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+            gfc_check_link, NULL, gfc_resolve_link,
+            a, BT_CHARACTER, dc, REQUIRED, b, BT_CHARACTER, dc, REQUIRED);
+
+  make_generic ("link", GFC_ISYM_LINK, GFC_STD_GNU);
+  
   add_sym_1 ("log", 1, 1, BT_REAL, dr, GFC_STD_F77,
-            NULL, gfc_simplify_log, gfc_resolve_log,
+            gfc_check_fn_rc, gfc_simplify_log, gfc_resolve_log,
             x, BT_REAL, dr, REQUIRED);
 
   add_sym_1 ("alog", 1, 1, BT_REAL, dr, GFC_STD_F77,
@@ -1496,12 +1655,12 @@ add_functions (void)
             NULL, gfc_simplify_log, gfc_resolve_log,
             x, BT_COMPLEX, dd, REQUIRED);
 
-  make_alias ("cdlog");
+  make_alias ("cdlog", GFC_STD_GNU);
 
   make_generic ("log", GFC_ISYM_LOG, GFC_STD_F77);
 
   add_sym_1 ("log10", 1, 1, BT_REAL, dr, GFC_STD_F77,
-            NULL, gfc_simplify_log10, gfc_resolve_log10,
+            gfc_check_fn_r, gfc_simplify_log10, gfc_resolve_log10,
             x, BT_REAL, dr, REQUIRED);
 
   add_sym_1 ("alog10", 1, 1, BT_REAL, dr, GFC_STD_F77,
@@ -1514,12 +1673,17 @@ add_functions (void)
 
   make_generic ("log10", GFC_ISYM_LOG10, GFC_STD_F77);
 
-  add_sym_2 ("logical", 0, 1, BT_LOGICAL, dl, GFC_STD_F95,
+  add_sym_2 ("logical", 1, 1, BT_LOGICAL, dl, GFC_STD_F95,
             gfc_check_logical, gfc_simplify_logical, gfc_resolve_logical,
             l, BT_LOGICAL, dl, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
 
   make_generic ("logical", GFC_ISYM_LOGICAL, GFC_STD_F95);
 
+  add_sym_1 ("malloc", 0, 1, BT_INTEGER, ii, GFC_STD_GNU, gfc_check_malloc,
+            NULL, gfc_resolve_malloc, a, BT_INTEGER, di, REQUIRED);
+
+  make_generic ("malloc", GFC_ISYM_MALLOC, GFC_STD_GNU);
+
   add_sym_2 ("matmul", 0, 1, BT_REAL, dr, GFC_STD_F95,
             gfc_check_matmul, NULL, gfc_resolve_matmul,
             ma, BT_REAL, dr, REQUIRED, mb, BT_REAL, dr, REQUIRED);
@@ -1718,7 +1882,7 @@ add_functions (void)
 
   /* Compatibility with HP FORTRAN 77/iX Reference.  Note, rand() and ran()
      use slightly different shoddy multiplicative congruential PRNG.  */
-  make_alias ("ran");
+  make_alias ("ran", GFC_STD_GNU);
 
   make_generic ("rand", GFC_ISYM_RAND, GFC_STD_GNU);
 
@@ -1732,8 +1896,13 @@ add_functions (void)
             gfc_check_real, gfc_simplify_real, gfc_resolve_real,
             a, BT_UNKNOWN, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
 
+  /* This provides compatibility with g77.  */
+  add_sym_1 ("realpart", 1, 0, BT_REAL, dr, GFC_STD_GNU,
+            gfc_check_fn_c, gfc_simplify_realpart, gfc_resolve_realpart,
+            a, BT_UNKNOWN, dr, REQUIRED);
+
   add_sym_1 ("float", 1, 0, BT_REAL, dr, GFC_STD_F77,
-            NULL, gfc_simplify_float, NULL,
+            gfc_check_i, gfc_simplify_float, NULL,
             a, BT_INTEGER, di, REQUIRED);
 
   add_sym_1 ("sngl", 1, 0, BT_REAL, dr, GFC_STD_F77,
@@ -1742,6 +1911,12 @@ add_functions (void)
 
   make_generic ("real", GFC_ISYM_REAL, GFC_STD_F77);
 
+  add_sym_2 ("rename", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+            gfc_check_rename, NULL, gfc_resolve_rename,
+            a, BT_CHARACTER, dc, REQUIRED, b, BT_CHARACTER, dc, REQUIRED);
+
+  make_generic ("rename", GFC_ISYM_RENAME, GFC_STD_GNU);
+  
   add_sym_2 ("repeat", 0, 1, BT_CHARACTER, dc, GFC_STD_F95,
             gfc_check_repeat, gfc_simplify_repeat, gfc_resolve_repeat,
             stg, BT_CHARACTER, dc, REQUIRED, n, BT_INTEGER, di, REQUIRED);
@@ -1780,8 +1955,15 @@ add_functions (void)
 
   make_generic ("second", GFC_ISYM_SECOND, GFC_STD_GNU);
 
+  /* Added for G77 compatibility.  */
+  add_sym_1 ("secnds", 0, 1, BT_REAL, dr, GFC_STD_GNU,
+            gfc_check_secnds, NULL, gfc_resolve_secnds,
+            x, BT_REAL, dr, REQUIRED);
+
+  make_generic ("secnds", GFC_ISYM_SECNDS, GFC_STD_GNU);
+
   add_sym_1 ("selected_int_kind", 0, 1, BT_INTEGER, di,  GFC_STD_F95,
-            NULL, gfc_simplify_selected_int_kind, NULL,
+            gfc_check_selected_int_kind, gfc_simplify_selected_int_kind, NULL,
             r, BT_INTEGER, di, REQUIRED);
 
   make_generic ("selected_int_kind", GFC_ISYM_SI_KIND, GFC_STD_F95);
@@ -1820,8 +2002,14 @@ add_functions (void)
 
   make_generic ("sign", GFC_ISYM_SIGN, GFC_STD_F77);
 
+  add_sym_2 ("signal", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
+            gfc_check_signal, NULL, gfc_resolve_signal,
+            num, BT_INTEGER, di, REQUIRED, han, BT_UNKNOWN, 0, REQUIRED);
+
+  make_generic ("signal", GFC_ISYM_SIGNAL, GFC_STD_GNU);
+
   add_sym_1 ("sin", 1, 1, BT_REAL, dr, GFC_STD_F77,
-            NULL, gfc_simplify_sin, gfc_resolve_sin,
+            gfc_check_fn_rc, gfc_simplify_sin, gfc_resolve_sin,
             x, BT_REAL, dr, REQUIRED);
 
   add_sym_1 ("dsin", 1, 1, BT_REAL, dd, GFC_STD_F77,
@@ -1836,12 +2024,12 @@ add_functions (void)
             NULL, gfc_simplify_sin, gfc_resolve_sin,
             x, BT_COMPLEX, dd, REQUIRED);
 
-  make_alias ("cdsin");
+  make_alias ("cdsin", GFC_STD_GNU);
 
   make_generic ("sin", GFC_ISYM_SIN, GFC_STD_F77);
 
   add_sym_1 ("sinh", 1, 1, BT_REAL, dr, GFC_STD_F77,
-            NULL, gfc_simplify_sinh, gfc_resolve_sinh,
+            gfc_check_fn_r, gfc_simplify_sinh, gfc_resolve_sinh,
             x, BT_REAL, dr, REQUIRED);
 
   add_sym_1 ("dsinh", 1, 1, BT_REAL, dd, GFC_STD_F77,
@@ -1870,7 +2058,7 @@ add_functions (void)
   make_generic ("spread", GFC_ISYM_SPREAD, GFC_STD_F95);
 
   add_sym_1 ("sqrt", 1, 1, BT_REAL, dr, GFC_STD_F77,
-            NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
+            gfc_check_fn_rc, gfc_simplify_sqrt, gfc_resolve_sqrt,
             x, BT_REAL, dr, REQUIRED);
 
   add_sym_1 ("dsqrt", 1, 1, BT_REAL, dd, GFC_STD_F77,
@@ -1885,7 +2073,7 @@ add_functions (void)
             NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
             x, BT_COMPLEX, dd, REQUIRED);
 
-  make_alias ("cdsqrt");
+  make_alias ("cdsqrt", GFC_STD_GNU);
 
   make_generic ("sqrt", GFC_ISYM_SQRT, GFC_STD_F77);
 
@@ -1902,6 +2090,12 @@ add_functions (void)
 
   make_generic ("sum", GFC_ISYM_SUM, GFC_STD_F95);
 
+  add_sym_2 ("symlnk", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+            gfc_check_symlnk, NULL, gfc_resolve_symlnk,
+            a, BT_CHARACTER, dc, REQUIRED, b, BT_CHARACTER, dc, REQUIRED);
+
+  make_generic ("symlnk", GFC_ISYM_SYMLNK, GFC_STD_GNU);
+
   add_sym_1 ("system", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
             NULL, NULL, NULL,
             c, BT_CHARACTER, dc, REQUIRED);
@@ -1909,7 +2103,7 @@ add_functions (void)
   make_generic ("system", GFC_ISYM_SYSTEM, GFC_STD_GNU);
 
   add_sym_1 ("tan", 1, 1, BT_REAL, dr, GFC_STD_F77,
-            NULL, gfc_simplify_tan, gfc_resolve_tan,
+            gfc_check_fn_r, gfc_simplify_tan, gfc_resolve_tan,
             x, BT_REAL, dr, REQUIRED);
 
   add_sym_1 ("dtan", 1, 1, BT_REAL, dd, GFC_STD_F77,
@@ -1919,7 +2113,7 @@ add_functions (void)
   make_generic ("tan", GFC_ISYM_TAN, GFC_STD_F77);
 
   add_sym_1 ("tanh", 1, 1, BT_REAL, dr, GFC_STD_F77,
-            NULL, gfc_simplify_tanh, gfc_resolve_tanh,
+            gfc_check_fn_r, gfc_simplify_tanh, gfc_resolve_tanh,
             x, BT_REAL, dr, REQUIRED);
 
   add_sym_1 ("dtanh", 1, 1, BT_REAL, dd, GFC_STD_F77,
@@ -1928,6 +2122,16 @@ add_functions (void)
 
   make_generic ("tanh", GFC_ISYM_TANH, GFC_STD_F77);
 
+  add_sym_0 ("time", 1, 0, BT_INTEGER, di, GFC_STD_GNU, 
+            NULL, NULL, gfc_resolve_time);
+
+  make_generic ("time", GFC_ISYM_TIME, GFC_STD_GNU);
+
+  add_sym_0 ("time8", 1, 0, BT_INTEGER, di, GFC_STD_GNU, 
+            NULL, NULL, gfc_resolve_time8);
+
+  make_generic ("time8", GFC_ISYM_TIME8, GFC_STD_GNU);
+
   add_sym_1 ("tiny", 0, 1, BT_REAL, dr, GFC_STD_F95,
             gfc_check_x, gfc_simplify_tiny, NULL,
             x, BT_REAL, dr, REQUIRED);
@@ -1953,6 +2157,12 @@ add_functions (void)
 
   make_generic ("trim", GFC_ISYM_TRIM, GFC_STD_F95);
 
+  add_sym_1 ("ttynam", 0, 1, BT_CHARACTER, 0, GFC_STD_GNU,
+              gfc_check_ttynam, NULL, gfc_resolve_ttynam,
+             ut, BT_INTEGER, di, REQUIRED);
+
+  make_generic ("ttynam", GFC_ISYM_TTYNAM, GFC_STD_GNU);
+
   add_sym_2 ("ubound", 0, 1, BT_INTEGER, di, GFC_STD_F95,
             gfc_check_ubound, gfc_simplify_ubound, gfc_resolve_ubound,
             ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
@@ -1986,6 +2196,13 @@ add_functions (void)
             bck, BT_LOGICAL, dl, OPTIONAL);
 
   make_generic ("verify", GFC_ISYM_VERIFY, GFC_STD_F95);
+    
+  add_sym_1 ("loc", 0, 1, BT_INTEGER, ii, GFC_STD_GNU,
+           gfc_check_loc, NULL, gfc_resolve_loc,
+           ar, BT_UNKNOWN, 0, REQUIRED);
+               
+  make_generic ("loc", GFC_ISYM_LOC, GFC_STD_GNU);
+
 }
 
 
@@ -2002,26 +2219,39 @@ add_subroutines (void)
     *f = "from", *sz = "size", *ln = "len", *cr = "count_rate",
     *com = "command", *length = "length", *st = "status",
     *val = "value", *num = "number", *name = "name",
-    *trim_name = "trim_name", *ut = "unit";
+    *trim_name = "trim_name", *ut = "unit", *han = "handler",
+    *sec = "seconds", *res = "result", *of = "offset";
 
-  int di, dr, dc, dl;
+  int di, dr, dc, dl, ii;
 
   di = gfc_default_integer_kind;
   dr = gfc_default_real_kind;
   dc = gfc_default_character_kind;
   dl = gfc_default_logical_kind;
+  ii = gfc_index_integer_kind;
 
   add_sym_0s ("abort", 1, GFC_STD_GNU, NULL);
 
+  if ((gfc_option.allow_std & GFC_STD_GNU) || gfc_option.flag_all_intrinsics)
+    make_noreturn();
+
   add_sym_1s ("cpu_time", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
              gfc_check_cpu_time, NULL, gfc_resolve_cpu_time,
              tm, BT_REAL, dr, REQUIRED);
 
   /* More G77 compatibility garbage.  */
+  add_sym_2s ("ctime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+            gfc_check_ctime_sub, NULL, gfc_resolve_ctime_sub,
+            tm, BT_INTEGER, di, REQUIRED, res, BT_CHARACTER, dc, REQUIRED);
+
   add_sym_1s ("second", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
              gfc_check_second_sub, NULL, gfc_resolve_second_sub,
              tm, BT_REAL, dr, REQUIRED);
 
+  add_sym_2s ("chdir", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+              gfc_check_chdir_sub, NULL, gfc_resolve_chdir_sub,
+             name, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
+
   add_sym_4s ("date_and_time", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
              gfc_check_date_and_time, NULL, NULL,
              dt, BT_CHARACTER, dc, OPTIONAL, tm, BT_CHARACTER, dc, OPTIONAL,
@@ -2036,6 +2266,14 @@ add_subroutines (void)
             gfc_check_etime_sub, NULL, gfc_resolve_etime_sub,
              vl, BT_REAL, 4, REQUIRED, tm, BT_REAL, 4, REQUIRED);
 
+  add_sym_1s ("fdate", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+            gfc_check_fdate_sub, NULL, gfc_resolve_fdate_sub,
+            dt, BT_CHARACTER, dc, REQUIRED);
+
+  add_sym_1s ("gerror", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+              gfc_check_gerror, NULL, gfc_resolve_gerror, c, BT_CHARACTER,
+             dc, REQUIRED);
+
   add_sym_2s ("getcwd", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
           gfc_check_getcwd_sub, NULL, gfc_resolve_getcwd_sub,
              c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
@@ -2048,6 +2286,10 @@ add_subroutines (void)
              NULL, NULL, gfc_resolve_getarg,
              c, BT_INTEGER, di, REQUIRED, vl, BT_CHARACTER, dc, REQUIRED);
 
+  add_sym_1s ("getlog", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+              gfc_check_getlog, NULL, gfc_resolve_getlog, c, BT_CHARACTER,
+             dc, REQUIRED);
+
   /* F2003 commandline routines.  */
 
   add_sym_3s ("get_command", 0, 1, BT_UNKNOWN, 0, GFC_STD_F2003,
@@ -2084,6 +2326,11 @@ add_subroutines (void)
              gt, BT_INTEGER, di, OPTIONAL);
 
   /* More G77 compatibility garbage.  */
+  add_sym_3s ("alarm", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+             gfc_check_alarm_sub, NULL, gfc_resolve_alarm_sub,
+             sec, BT_INTEGER, di, REQUIRED, han, BT_UNKNOWN, 0, REQUIRED,
+             st, BT_INTEGER, di, OPTIONAL);
+
   add_sym_1s ("srand", 0, 1, BT_UNKNOWN, di, GFC_STD_GNU,
              gfc_check_srand, NULL, gfc_resolve_srand,
              c, BT_INTEGER, 4, REQUIRED);
@@ -2092,10 +2339,64 @@ add_subroutines (void)
              gfc_check_exit, NULL, gfc_resolve_exit,
              c, BT_INTEGER, di, OPTIONAL);
 
+  if ((gfc_option.allow_std & GFC_STD_GNU) || gfc_option.flag_all_intrinsics)
+    make_noreturn();
+
+  add_sym_3s ("fgetc", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+             gfc_check_fgetputc_sub, NULL, gfc_resolve_fgetc_sub,
+             ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED,
+             st, BT_INTEGER, di, OPTIONAL);
+
+  add_sym_2s ("fget", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+             gfc_check_fgetput_sub, NULL, gfc_resolve_fget_sub,
+             c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
+
   add_sym_1s ("flush", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
              gfc_check_flush, NULL, gfc_resolve_flush,
              c, BT_INTEGER, di, OPTIONAL);
 
+  add_sym_3s ("fputc", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+             gfc_check_fgetputc_sub, NULL, gfc_resolve_fputc_sub,
+             ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED,
+             st, BT_INTEGER, di, OPTIONAL);
+
+  add_sym_2s ("fput", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+             gfc_check_fgetput_sub, NULL, gfc_resolve_fput_sub,
+             c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
+
+  add_sym_1s ("free", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, gfc_check_free,
+             NULL, gfc_resolve_free, c, BT_INTEGER, ii, REQUIRED);
+
+  add_sym_2s ("ftell", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+             gfc_check_ftell_sub, NULL, gfc_resolve_ftell_sub,
+             ut, BT_INTEGER, di, REQUIRED, of, BT_INTEGER, ii, REQUIRED);
+
+  add_sym_2s ("hostnm", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+          gfc_check_hostnm_sub, NULL, gfc_resolve_hostnm_sub,
+             c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
+
+  add_sym_3s ("kill", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, gfc_check_kill_sub,
+             NULL, gfc_resolve_kill_sub, c, BT_INTEGER, di, REQUIRED,
+             val, BT_INTEGER, di, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
+
+  add_sym_3s ("link", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+              gfc_check_link_sub, NULL, gfc_resolve_link_sub,
+             name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER,
+             dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
+
+  add_sym_1s ("perror", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+          gfc_check_perror, NULL, gfc_resolve_perror,
+             c, BT_CHARACTER, dc, REQUIRED);
+
+  add_sym_3s ("rename", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+              gfc_check_rename_sub, NULL, gfc_resolve_rename_sub,
+             name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER,
+             dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
+
+  add_sym_1s ("sleep", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+              gfc_check_sleep_sub, NULL, gfc_resolve_sleep_sub,
+             val, BT_CHARACTER, dc, REQUIRED);
+
   add_sym_3s ("fstat", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
              gfc_check_fstat_sub, NULL, gfc_resolve_fstat_sub,
              ut, BT_INTEGER, di, REQUIRED, vl, BT_INTEGER, di, REQUIRED,
@@ -2106,6 +2407,16 @@ add_subroutines (void)
              name, BT_CHARACTER, dc, REQUIRED, vl, BT_INTEGER, di, REQUIRED,
              st, BT_INTEGER, di, OPTIONAL);
 
+  add_sym_3s ("signal", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+             gfc_check_signal_sub, NULL, gfc_resolve_signal_sub,
+             num, BT_INTEGER, di, REQUIRED, han, BT_UNKNOWN, 0, REQUIRED,
+             st, BT_INTEGER, di, OPTIONAL);
+
+  add_sym_3s ("symlnk", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+              gfc_check_symlnk_sub, NULL, gfc_resolve_symlnk_sub,
+             name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER,
+             dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
+
   add_sym_2s ("system", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
              NULL, NULL, gfc_resolve_system_sub,
              c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
@@ -2115,6 +2426,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);
@@ -2129,8 +2444,7 @@ add_subroutines (void)
 /* Add a function to the list of conversion symbols.  */
 
 static void
-add_conv (bt from_type, int from_kind, bt to_type, int to_kind,
-         gfc_expr * (*simplify) (gfc_expr *, bt, int))
+add_conv (bt from_type, int from_kind, bt to_type, int to_kind, int standard)
 {
 
   gfc_typespec from, to;
@@ -2152,9 +2466,10 @@ add_conv (bt from_type, int from_kind, bt to_type, int to_kind,
 
   sym = conversion + nconv;
 
-  strcpy (sym->name, conv_name (&from, &to));
-  strcpy (sym->lib_name, sym->name);
-  sym->simplify.cc = simplify;
+  sym->name = conv_name (&from, &to);
+  sym->lib_name = sym->name;
+  sym->simplify.cc = gfc_convert_constant;
+  sym->standard = standard;
   sym->elemental = 1;
   sym->ts = to;
   sym->generic_id = GFC_ISYM_CONVERSION;
@@ -2179,7 +2494,7 @@ add_conversions (void)
          continue;
 
        add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
-                 BT_INTEGER, gfc_integer_kinds[j].kind, gfc_convert_constant);
+                 BT_INTEGER, gfc_integer_kinds[j].kind, GFC_STD_F77);
       }
 
   /* Integer-Real/Complex conversions.  */
@@ -2187,18 +2502,43 @@ add_conversions (void)
     for (j = 0; gfc_real_kinds[j].kind != 0; j++)
       {
        add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
-                 BT_REAL, gfc_real_kinds[j].kind, gfc_convert_constant);
+                 BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77);
 
        add_conv (BT_REAL, gfc_real_kinds[j].kind,
-                 BT_INTEGER, gfc_integer_kinds[i].kind, gfc_convert_constant);
+                 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_F77);
 
        add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
-                 BT_COMPLEX, gfc_real_kinds[j].kind, gfc_convert_constant);
+                 BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77);
 
        add_conv (BT_COMPLEX, gfc_real_kinds[j].kind,
-                 BT_INTEGER, gfc_integer_kinds[i].kind, gfc_convert_constant);
+                 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_F77);
       }
 
+  if ((gfc_option.allow_std & GFC_STD_LEGACY) != 0)
+    {
+      /* Hollerith-Integer conversions.  */
+      for (i = 0; gfc_integer_kinds[i].kind != 0; i++)
+       add_conv (BT_HOLLERITH, gfc_default_character_kind,
+                 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_LEGACY);
+      /* Hollerith-Real conversions.  */
+      for (i = 0; gfc_real_kinds[i].kind != 0; i++)
+       add_conv (BT_HOLLERITH, gfc_default_character_kind,
+                 BT_REAL, gfc_real_kinds[i].kind, GFC_STD_LEGACY);
+      /* Hollerith-Complex conversions.  */
+      for (i = 0; gfc_real_kinds[i].kind != 0; i++)
+       add_conv (BT_HOLLERITH, gfc_default_character_kind,
+                 BT_COMPLEX, gfc_real_kinds[i].kind, GFC_STD_LEGACY);
+
+      /* Hollerith-Character conversions.  */
+      add_conv (BT_HOLLERITH, gfc_default_character_kind, BT_CHARACTER,
+                 gfc_default_character_kind, GFC_STD_LEGACY);
+
+      /* Hollerith-Logical conversions.  */
+      for (i = 0; gfc_logical_kinds[i].kind != 0; i++)
+       add_conv (BT_HOLLERITH, gfc_default_character_kind,
+                 BT_LOGICAL, gfc_logical_kinds[i].kind, GFC_STD_LEGACY);
+    }
+
   /* Real/Complex - Real/Complex conversions.  */
   for (i = 0; gfc_real_kinds[i].kind != 0; i++)
     for (j = 0; gfc_real_kinds[j].kind != 0; j++)
@@ -2206,17 +2546,17 @@ add_conversions (void)
        if (i != j)
          {
            add_conv (BT_REAL, gfc_real_kinds[i].kind,
-                     BT_REAL, gfc_real_kinds[j].kind, gfc_convert_constant);
+                     BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77);
 
            add_conv (BT_COMPLEX, gfc_real_kinds[i].kind,
-                     BT_COMPLEX, gfc_real_kinds[j].kind, gfc_convert_constant);
+                     BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77);
          }
 
        add_conv (BT_REAL, gfc_real_kinds[i].kind,
-                 BT_COMPLEX, gfc_real_kinds[j].kind, gfc_convert_constant);
+                 BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77);
 
        add_conv (BT_COMPLEX, gfc_real_kinds[i].kind,
-                 BT_REAL, gfc_real_kinds[j].kind, gfc_convert_constant);
+                 BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77);
       }
 
   /* Logical/Logical kind conversion.  */
@@ -2227,8 +2567,19 @@ add_conversions (void)
          continue;
 
        add_conv (BT_LOGICAL, gfc_logical_kinds[i].kind,
-                 BT_LOGICAL, gfc_logical_kinds[j].kind, gfc_convert_constant);
+                 BT_LOGICAL, gfc_logical_kinds[j].kind, GFC_STD_F77);
       }
+
+  /* Integer-Logical and Logical-Integer conversions.  */
+  if ((gfc_option.allow_std & GFC_STD_LEGACY) != 0)
+    for (i=0; gfc_integer_kinds[i].kind; i++)
+      for (j=0; gfc_logical_kinds[j].kind; j++)
+       {
+         add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
+                   BT_LOGICAL, gfc_logical_kinds[j].kind, GFC_STD_LEGACY);
+         add_conv (BT_LOGICAL, gfc_logical_kinds[j].kind,
+                   BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_LEGACY);
+       }
 }
 
 
@@ -2241,7 +2592,7 @@ gfc_intrinsic_init_1 (void)
   nargs = nfunc = nsub = nconv = 0;
 
   /* Create a namespace to hold the resolved intrinsic symbols.  */
-  gfc_intrinsic_namespace = gfc_get_namespace (NULL);
+  gfc_intrinsic_namespace = gfc_get_namespace (NULL, 0);
 
   sizing = SZ_FUNCS;
   add_functions ();
@@ -2359,7 +2710,7 @@ sort_actual (const char *name, gfc_actual_arglist ** ap,
       if (a == NULL)
        goto optional;
 
-      if (a->name[0] != '\0')
+      if (a->name != NULL)
        goto keywords;
 
       f->actual = a;
@@ -2574,6 +2925,16 @@ do_simplify (gfc_intrinsic_sym * specific, gfc_expr * e)
   gfc_expr *result, *a1, *a2, *a3, *a4, *a5;
   gfc_actual_arglist *arg;
 
+  /* Check the arguments if there are Hollerith constants. We deal with
+     them at run-time.  */
+  for (arg = e->value.function.actual; arg != NULL; arg = arg->next)
+    {
+      if (arg->expr && arg->expr->from_H)
+       {
+         result = NULL;
+         goto finish;
+       }
+    }
   /* Max and min require special handling due to the variable number
      of args.  */
   if (specific->simplify.f1 == gfc_simplify_min)
@@ -2805,7 +3166,7 @@ check_intrinsic_standard (const char *name, int standard, locus * where)
   if (!gfc_option.warn_nonstd_intrinsics)
     return;
 
-  gfc_notify_std (standard, "Intrinsic '%s' at %L is not included"
+  gfc_notify_std (standard, "Intrinsic '%s' at %L is not included "
                  "in the selected standard", name, where);
 }
 
@@ -2898,16 +3259,13 @@ got_specific:
   expr->value.function.isym = specific;
   gfc_intrinsic_symbol (expr->symtree->n.sym);
 
+  gfc_suppress_error = 0;
   if (do_simplify (specific, expr) == FAILURE)
-    {
-      gfc_suppress_error = 0;
-      return MATCH_ERROR;
-    }
+    return MATCH_ERROR;
 
   /* TODO: We should probably only allow elemental functions here.  */
   flag |= (expr->ts.type != BT_INTEGER && expr->ts.type != BT_CHARACTER);
 
-  gfc_suppress_error = 0;
   if (pedantic && gfc_init_expr
       && flag && gfc_init_expr_extensions (specific))
     {
@@ -2976,6 +3334,7 @@ gfc_intrinsic_sub_interface (gfc_code * c, int error_flag)
       return MATCH_ERROR;
     }
 
+  c->resolved_sym->attr.noreturn = isym->noreturn;
   check_intrinsic_standard (name, isym->standard, &c->loc);
 
   return MATCH_YES;
@@ -3044,7 +3403,10 @@ gfc_convert_type_warn (gfc_expr * expr, gfc_typespec * ts, int eflag,
     goto bad;
 
   /* At this point, a conversion is necessary. A warning may be needed.  */
-  if (wflag && gfc_option.warn_conversion)
+  if ((gfc_option.warn_std & sym->standard) != 0)
+    gfc_warning_now ("Extension: Conversion from %s to %s at %L",
+                    gfc_typename (&from_ts), gfc_typename (ts), &expr->where);
+  else if (wflag && gfc_option.warn_conversion)
     gfc_warning_now ("Conversion from %s to %s at %L",
                     gfc_typename (&from_ts), gfc_typename (ts), &expr->where);
 
@@ -3063,6 +3425,17 @@ gfc_convert_type_warn (gfc_expr * expr, gfc_typespec * ts, int eflag,
   new->rank = rank;
   new->shape = gfc_copy_shape (shape, rank);
 
+  gfc_get_ha_sym_tree (sym->name, &new->symtree);
+  new->symtree->n.sym->ts = *ts;
+  new->symtree->n.sym->attr.flavor = FL_PROCEDURE;
+  new->symtree->n.sym->attr.function = 1;
+  new->symtree->n.sym->attr.intrinsic = 1;
+  new->symtree->n.sym->attr.elemental = 1;
+  new->symtree->n.sym->attr.pure = 1;
+  new->symtree->n.sym->attr.referenced = 1;
+  gfc_intrinsic_symbol(new->symtree->n.sym);
+  gfc_commit_symbol (new->symtree->n.sym);
+
   *expr = *new;
 
   gfc_free (new);