diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 3015ff155d38ceef28ed5605d45911f0ac709c4b..4a4b131d3acefc2f2429edb344a2f8ddc48ca1fc 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,26 @@
+2006-10-07  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+	PR fortran/16580
+	PR fortran/29288
+	* gcc/fortran/intrinsic.c (add_sym): Define the actual_ok when a
+	gfc_intrinsic_sym structure is filled.
+	(gfc_intrinsic_actual_ok): New function.
+	(add_sym_0s, add_sym_1s, add_sym_2s, add_sym_3s, add_sym_4s,
+	add_sym_5s): Intrinsic subroutines are not allowed as actual
+	arguments, so we remove argument actual_ok.
+	(add_functions): Correct the values for actual_ok of all intrinsics.
+	(add_subroutines): Remove the actual_ok argument, which was never used.
+	* gcc/fortran/intrinsic.h (gfc_intrinsic_actual_ok): New prototype.
+	* gcc/fortran/gfortran.h (gfc_resolve_index_func): New prototype.
+	* gcc/fortran/resolve.c (resolve_actual_arglist): Check whether
+	an intrinsic used as an argument list is allowed there.
+	* gcc/fortran/iresolve.c (gfc_resolve_index_func): New function.
+	(gfc_resolve_len): Change intrinsic function name to agree with
+	libgfortran.
+	* gcc/fortran/trans-decl.c (gfc_get_extern_function_decl): Add
+	new case, because some specific intrinsics take 3 arguments.
+	* gcc/fortran/intrinsic.texi: DIMAG is a GNU extension.
+
 2006-10-06  Jakub Jelinek  <jakub@redhat.com>
 
 	PR fortran/28415
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 0daa8f58888085cbb16fa5702dbb90619199c2a6..afc57dbec2ce43422cd8424d1ccc566d40a4bbfb 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -1940,6 +1940,7 @@ try gfc_convert_type_warn (gfc_expr *, gfc_typespec *, int, int);
 int gfc_generic_intrinsic (const char *);
 int gfc_specific_intrinsic (const char *);
 int gfc_intrinsic_name (const char *, int);
+int gfc_intrinsic_actual_ok (const char *, const bool);
 gfc_intrinsic_sym *gfc_find_function (const char *);
 
 match gfc_intrinsic_func_interface (gfc_expr *, int);
diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index dd1ffeb25029f9e87fa4df4cede84ea2dfde2936..f2185b532125876dd0360f960929a45acfdd0008 100644
--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -194,7 +194,7 @@ do_check (gfc_intrinsic_sym * specific, gfc_actual_arglist * arg)
    Argument list:
       char *     name of function
       int        whether function is elemental
-      int        If the function can be used as an actual argument
+      int        If the function can be used as an actual argument [1] [2]
       bt         return type of function
       int        kind of return type of function
       int        Fortran standard version
@@ -210,13 +210,20 @@ do_check (gfc_intrinsic_sym * specific, gfc_actual_arglist * arg)
 
    The sequence is terminated by a NULL name.
 
-   TODO: Are checks on actual_ok implemented elsewhere, or is that just
-   missing here?  */
+
+ [1] Whether a function can or cannot be used as an actual argument is
+     determined by its presence on the 13.6 list in Fortran 2003.  The
+     following intrinsics, which are GNU extensions, are considered allowed
+     as actual arguments: ACOSH ATANH DACOSH DASINH DATANH DCONJG DIMAG
+     ZABS ZCOS ZEXP ZLOG ZSIN ZSQRT.
+ [2] The value 2 is used in this field for CHAR, which is allowed as an
+     actual argument in F2003, but not in F95. It is the only such
+     intrinsic function.  */
 
 static void
-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, ...)
+add_sym (const char *name, int elemental, int actual_ok, 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;
@@ -246,6 +253,7 @@ add_sym (const char *name, int elemental, int actual_ok ATTRIBUTE_UNUSED,
       next_sym->lib_name = gfc_get_string (buf);
 
       next_sym->elemental = elemental;
+      next_sym->actual_ok = actual_ok;
       next_sym->ts.type = type;
       next_sym->ts.kind = kind;
       next_sym->standard = standard;
@@ -327,7 +335,7 @@ add_sym_0 (const char *name, int elemental, int actual_ok, bt type,
    0 arguments.  */
 
 static void
-add_sym_0s (const char * name, int actual_ok, int standard,
+add_sym_0s (const char * name, int standard,
 	    void (*resolve)(gfc_code *))
 {
   gfc_check_f cf;
@@ -338,7 +346,7 @@ add_sym_0s (const char * name, int actual_ok, int standard,
   sf.f1 = NULL;
   rf.s1 = resolve;
 
-  add_sym (name, 1, actual_ok, BT_UNKNOWN, 0, standard, cf, sf, rf,
+  add_sym (name, 1, 0, BT_UNKNOWN, 0, standard, cf, sf, rf,
 	   (void*)0);
 }
 
@@ -372,7 +380,7 @@ add_sym_1 (const char *name, int elemental, int actual_ok, bt type,
    1 arguments.  */
 
 static void
-add_sym_1s (const char *name, int elemental, int actual_ok, bt type,
+add_sym_1s (const char *name, int elemental, bt type,
 			int kind, int standard,
 			try (*check)(gfc_expr *),
 			gfc_expr *(*simplify)(gfc_expr *),
@@ -387,7 +395,7 @@ add_sym_1s (const char *name, int elemental, int actual_ok, bt type,
   sf.f1 = simplify;
   rf.s1 = resolve;
 
-  add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
+  add_sym (name, elemental, 0, type, kind, standard, cf, sf, rf,
 	   a1, type1, kind1, optional1,
 	   (void*)0);
 }
@@ -451,7 +459,7 @@ add_sym_2 (const char *name, int elemental, int actual_ok, bt type,
    2 arguments.  */
 
 static void
-add_sym_2s (const char *name, int elemental, int actual_ok, bt type,
+add_sym_2s (const char *name, int elemental, bt type,
 			int kind, int standard,
 		       try (*check)(gfc_expr *,gfc_expr *),
 		       gfc_expr *(*simplify)(gfc_expr *,gfc_expr *),
@@ -467,7 +475,7 @@ add_sym_2s (const char *name, int elemental, int actual_ok, bt type,
   sf.f2 = simplify;
   rf.s1 = resolve;
 
-  add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
+  add_sym (name, elemental, 0, type, kind, standard, cf, sf, rf,
 	   a1, type1, kind1, optional1,
 	   a2, type2, kind2, optional2,
 	   (void*)0);
@@ -565,7 +573,7 @@ add_sym_3red (const char *name, int elemental,
    3 arguments.  */
 
 static void
-add_sym_3s (const char *name, int elemental, int actual_ok, bt type,
+add_sym_3s (const char *name, int elemental, bt type,
 			int kind, int standard,
 		       try (*check)(gfc_expr *,gfc_expr *,gfc_expr *),
 		       gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *),
@@ -582,7 +590,7 @@ add_sym_3s (const char *name, int elemental, int actual_ok, bt type,
   sf.f3 = simplify;
   rf.s1 = resolve;
 
-  add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
+  add_sym (name, elemental, 0, type, kind, standard, cf, sf, rf,
 	   a1, type1, kind1, optional1,
 	   a2, type2, kind2, optional2,
 	   a3, type3, kind3, optional3,
@@ -625,7 +633,7 @@ add_sym_4 (const char *name, int elemental, int actual_ok, bt type,
    4 arguments.  */
 
 static void
-add_sym_4s (const char *name, int elemental, int actual_ok,
+add_sym_4s (const char *name, int elemental,
 			bt type, int kind, int standard,
     try (*check)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
     gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
@@ -643,7 +651,7 @@ add_sym_4s (const char *name, int elemental, int actual_ok,
   sf.f4 = simplify;
   rf.s1 = resolve;
 
-  add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
+  add_sym (name, elemental, 0, type, kind, standard, cf, sf, rf,
 	   a1, type1, kind1, optional1,
 	   a2, type2, kind2, optional2,
 	   a3, type3, kind3, optional3,
@@ -656,7 +664,7 @@ add_sym_4s (const char *name, int elemental, int actual_ok,
    5 arguments.  */
 
 static void
-add_sym_5s (const char *name, int elemental, int actual_ok, 
+add_sym_5s (const char *name, int elemental,
  bt type, int kind, int standard,
  try (*check)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
  gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
@@ -675,7 +683,7 @@ add_sym_5s (const char *name, int elemental, int actual_ok,
   sf.f5 = simplify;
   rf.s1 = resolve;
 
-  add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
+  add_sym (name, elemental, 0, type, kind, standard, cf, sf, rf,
 	   a1, type1, kind1, optional1,
 	   a2, type2, kind2, optional2,
 	   a3, type3, kind3, optional3,
@@ -759,6 +767,24 @@ gfc_specific_intrinsic (const char *name)
 }
 
 
+/* Given a string, figure out if it is the name of an intrinsic function
+   or subroutine allowed as an actual argument or not.  */
+int
+gfc_intrinsic_actual_ok (const char *name, const bool subroutine_flag)
+{
+  gfc_intrinsic_sym *sym;
+
+  /* Intrinsic subroutines are not allowed as actual arguments.  */
+  if (subroutine_flag)
+    return 0;
+  else
+    {
+      sym = gfc_find_function (name);
+      return (sym == NULL) ? 0 : sym->actual_ok;
+    }
+}
+
+
 /* Given a string, figure out if it is the name of an intrinsic
    subroutine or function.  There are no generic intrinsic
    subroutines, they are all specific.  */
@@ -916,13 +942,13 @@ add_functions (void)
 
   make_generic ("abs", GFC_ISYM_ABS, GFC_STD_F77);
 
-  add_sym_2 ("access", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_2 ("access", 0, 0, BT_INTEGER, di, GFC_STD_GNU,
 	     gfc_check_access_func, NULL, gfc_resolve_access,
 	     nm, BT_CHARACTER, dc, REQUIRED, md, BT_CHARACTER, dc, REQUIRED);
 
   make_generic ("access", GFC_ISYM_ACCESS, GFC_STD_GNU);
 
-  add_sym_1 ("achar", 1, 1, BT_CHARACTER, dc, GFC_STD_F95,
+  add_sym_1 ("achar", 1, 0, BT_CHARACTER, dc, GFC_STD_F95,
 	     gfc_check_achar, gfc_simplify_achar, NULL,
 	     i, BT_INTEGER, di, REQUIRED);
 
@@ -948,13 +974,13 @@ add_functions (void)
 
   make_generic ("acosh", GFC_ISYM_ACOSH, GFC_STD_GNU);
 
-  add_sym_1 ("adjustl", 1, 1, BT_CHARACTER, dc, GFC_STD_F95,
+  add_sym_1 ("adjustl", 1, 0, BT_CHARACTER, dc, GFC_STD_F95,
 	     NULL, gfc_simplify_adjustl, NULL,
 	     stg, BT_CHARACTER, dc, REQUIRED);
 
   make_generic ("adjustl", GFC_ISYM_ADJUSTL, GFC_STD_F95);
 
-  add_sym_1 ("adjustr", 1, 1, BT_CHARACTER, dc, GFC_STD_F95,
+  add_sym_1 ("adjustr", 1, 0, BT_CHARACTER, dc, GFC_STD_F95,
 	     NULL, gfc_simplify_adjustr, NULL,
 	     stg, BT_CHARACTER, dc, REQUIRED);
 
@@ -971,7 +997,6 @@ add_functions (void)
 	     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,
@@ -984,13 +1009,13 @@ add_functions (void)
 
   make_generic ("aint", GFC_ISYM_AINT, GFC_STD_F77);
 
-  add_sym_2 ("all", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
+  add_sym_2 ("all", 0, 0, BT_UNKNOWN, 0, GFC_STD_F95,
 	     gfc_check_all_any, NULL, gfc_resolve_all,
 	     msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
 
   make_generic ("all", GFC_ISYM_ALL, GFC_STD_F95);
 
-  add_sym_1 ("allocated", 0, 1, BT_LOGICAL, dl, GFC_STD_F95,
+  add_sym_1 ("allocated", 0, 0, BT_LOGICAL, dl, GFC_STD_F95,
 	     gfc_check_allocated, NULL, NULL,
 	     ar, BT_UNKNOWN, 0, REQUIRED);
 
@@ -1006,7 +1031,7 @@ add_functions (void)
 
   make_generic ("anint", GFC_ISYM_ANINT, GFC_STD_F77);
 
-  add_sym_2 ("any", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
+  add_sym_2 ("any", 0, 0, BT_UNKNOWN, 0, GFC_STD_F95,
 	     gfc_check_all_any, NULL, gfc_resolve_any,
 	     msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
 
@@ -1032,7 +1057,7 @@ add_functions (void)
 
   make_generic ("asinh", GFC_ISYM_ASINH, GFC_STD_GNU);
 
-  add_sym_2 ("associated", 0, 1, BT_LOGICAL, dl, GFC_STD_F95,
+  add_sym_2 ("associated", 0, 0, BT_LOGICAL, dl, GFC_STD_F95,
 	     gfc_check_associated, NULL, NULL,
 	     pt, BT_UNKNOWN, 0, REQUIRED, tg, BT_UNKNOWN, 0, OPTIONAL);
 
@@ -1129,50 +1154,56 @@ add_functions (void)
 
   make_generic ("besyn", GFC_ISYM_YN, GFC_STD_GNU);
 
-  add_sym_1 ("bit_size", 0, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_1 ("bit_size", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_i, gfc_simplify_bit_size, NULL,
 	     i, BT_INTEGER, di, REQUIRED);
 
   make_generic ("bit_size", GFC_ISYM_NONE, GFC_STD_F95);
 
-  add_sym_2 ("btest", 1, 1, BT_LOGICAL, dl, GFC_STD_F95,
+  add_sym_2 ("btest", 1, 0, BT_LOGICAL, dl, GFC_STD_F95,
 	     gfc_check_btest, gfc_simplify_btest, gfc_resolve_btest,
 	     i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED);
 
   make_generic ("btest", GFC_ISYM_BTEST, GFC_STD_F95);
 
-  add_sym_2 ("ceiling", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_2 ("ceiling", 1, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_a_ikind, gfc_simplify_ceiling, gfc_resolve_ceiling,
 	     a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
 
   make_generic ("ceiling", GFC_ISYM_CEILING, GFC_STD_F95);
 
-  add_sym_2 ("char", 1, 0, BT_CHARACTER, dc, GFC_STD_F77,
+  add_sym_2 ("char", 1, 2, BT_CHARACTER, dc, GFC_STD_F77,
 	     gfc_check_char, gfc_simplify_char, gfc_resolve_char,
 	     i, BT_INTEGER, di, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
 
   make_generic ("char", GFC_ISYM_CHAR, GFC_STD_F77);
 
-  add_sym_1 ("chdir", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_1 ("chdir", 0, 0, 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_2 ("chmod", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_2 ("chmod", 0, 0, BT_INTEGER, di, GFC_STD_GNU,
 	     gfc_check_chmod, NULL, gfc_resolve_chmod,
 	     nm, BT_CHARACTER, dc, REQUIRED, md, BT_CHARACTER, dc, REQUIRED);
 
   make_generic ("chmod", GFC_ISYM_CHMOD, GFC_STD_GNU);
 
-  add_sym_3 ("cmplx", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
+  add_sym_3 ("cmplx", 1, 0, 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,
 	     kind, BT_INTEGER, di, OPTIONAL);
 
   make_generic ("cmplx", GFC_ISYM_CMPLX, GFC_STD_F77);
 
-  add_sym_2 ("complex", 1, 1, BT_COMPLEX, dz, GFC_STD_GNU,
+  add_sym_0 ("command_argument_count", 1, 0, BT_INTEGER, di, GFC_STD_F2003,
+	     NULL, NULL, NULL);
+
+  make_generic ("command_argument_count", GFC_ISYM_COMMAND_ARGUMENT_COUNT,
+	        GFC_STD_F2003);
+
+  add_sym_2 ("complex", 1, 0, 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);
 
@@ -1181,7 +1212,7 @@ add_functions (void)
   /* Making dcmplx a specific of cmplx causes cmplx to return a double
      complex instead of the default complex.  */
 
-  add_sym_2 ("dcmplx", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
+  add_sym_2 ("dcmplx", 1, 0, BT_COMPLEX, dd, GFC_STD_GNU,
 	     gfc_check_dcmplx, gfc_simplify_dcmplx, gfc_resolve_dcmplx,
 	     x, BT_REAL, dd, REQUIRED, y, BT_REAL, dd, OPTIONAL);
 
@@ -1227,26 +1258,26 @@ add_functions (void)
 
   make_generic ("cosh", GFC_ISYM_COSH, GFC_STD_F77);
 
-  add_sym_2 ("count", 0, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_2 ("count", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_count, NULL, gfc_resolve_count,
 	     msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
 
   make_generic ("count", GFC_ISYM_COUNT, GFC_STD_F95);
 
-  add_sym_3 ("cshift", 0, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_3 ("cshift", 0, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_cshift, NULL, gfc_resolve_cshift,
 	     ar, BT_REAL, dr, REQUIRED, sh, BT_INTEGER, di, REQUIRED,
 	     dm, BT_INTEGER, ii, OPTIONAL);
 
   make_generic ("cshift", GFC_ISYM_CSHIFT, GFC_STD_F95);
 
-  add_sym_1 ("ctime", 0, 1, BT_CHARACTER, 0, GFC_STD_GNU,
+  add_sym_1 ("ctime", 0, 0, 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,
+  add_sym_1 ("dble", 1, 0, BT_REAL, dd, GFC_STD_F77,
 	     gfc_check_dble, gfc_simplify_dble, gfc_resolve_dble,
 	     a, BT_REAL, dr, REQUIRED);
 
@@ -1254,7 +1285,7 @@ add_functions (void)
 
   make_generic ("dble", GFC_ISYM_DBLE, GFC_STD_F77);
 
-  add_sym_1 ("digits", 0, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_1 ("digits", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_digits, gfc_simplify_digits, NULL,
 	     x, BT_UNKNOWN, dr, REQUIRED);
 
@@ -1262,7 +1293,7 @@ add_functions (void)
 
   add_sym_2 ("dim", 1, 1, BT_REAL, dr, GFC_STD_F77,
 	     gfc_check_a_p, gfc_simplify_dim, gfc_resolve_dim,
-	     x, BT_UNKNOWN, dr, REQUIRED, y, BT_UNKNOWN, dr, REQUIRED);
+	     x, BT_REAL, dr, REQUIRED, y, BT_UNKNOWN, dr, REQUIRED);
 
   add_sym_2 ("idim", 1, 1, BT_INTEGER, di, GFC_STD_F77,
 	     NULL, gfc_simplify_dim, gfc_resolve_dim,
@@ -1274,7 +1305,7 @@ add_functions (void)
 
   make_generic ("dim", GFC_ISYM_DIM, GFC_STD_F77);
 
-  add_sym_2 ("dot_product", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
+  add_sym_2 ("dot_product", 0, 0, BT_UNKNOWN, 0, GFC_STD_F95,
 	     gfc_check_dot_product, NULL, gfc_resolve_dot_product,
 	     va, BT_REAL, dr, REQUIRED, vb, BT_REAL, dr, REQUIRED);
 
@@ -1292,14 +1323,14 @@ add_functions (void)
 
   make_generic ("dreal", GFC_ISYM_REAL, GFC_STD_GNU);
 
-  add_sym_4 ("eoshift", 0, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_4 ("eoshift", 0, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_eoshift, NULL, gfc_resolve_eoshift,
 	     ar, BT_REAL, dr, 0, sh, BT_INTEGER, ii, REQUIRED,
 	     bd, BT_REAL, dr, 1, dm, BT_INTEGER, ii, OPTIONAL);
 
   make_generic ("eoshift", GFC_ISYM_EOSHIFT, GFC_STD_F95);
 
-  add_sym_1 ("epsilon", 0, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_1 ("epsilon", 0, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_x, gfc_simplify_epsilon, NULL,
 	     x, BT_REAL, dr, REQUIRED);
 
@@ -1327,7 +1358,7 @@ add_functions (void)
   make_generic ("erfc", GFC_ISYM_ERFC, GFC_STD_GNU);
 
   /* G77 compatibility */
-  add_sym_1 ("etime", 0, 1, BT_REAL, 4,  GFC_STD_GNU,
+  add_sym_1 ("etime", 0, 0, BT_REAL, 4,  GFC_STD_GNU,
 	     gfc_check_etime, NULL, NULL,
 	     x, BT_REAL, 4, REQUIRED);
 
@@ -1355,7 +1386,7 @@ add_functions (void)
 
   make_generic ("exp", GFC_ISYM_EXP, GFC_STD_F77);
 
-  add_sym_1 ("exponent", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_1 ("exponent", 1, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_x, gfc_simplify_exponent, gfc_resolve_exponent,
 	     x, BT_REAL, dr, REQUIRED);
 
@@ -1366,63 +1397,63 @@ add_functions (void)
 
   make_generic ("fdate", GFC_ISYM_FDATE, GFC_STD_GNU);
 
-  add_sym_2 ("floor", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_2 ("floor", 1, 0, 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);
 
   make_generic ("floor", GFC_ISYM_FLOOR, GFC_STD_F95);
 
   /* G77 compatible fnum */
-  add_sym_1 ("fnum", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_1 ("fnum", 0, 0, BT_INTEGER, di, GFC_STD_GNU,
 	     gfc_check_fnum, NULL, gfc_resolve_fnum,
 	     ut, BT_INTEGER, di, REQUIRED);
 
   make_generic ("fnum", GFC_ISYM_FNUM, GFC_STD_GNU);
 
-  add_sym_1 ("fraction", 1, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_1 ("fraction", 1, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_x, gfc_simplify_fraction, gfc_resolve_fraction,
 	     x, BT_REAL, dr, REQUIRED);
 
   make_generic ("fraction", GFC_ISYM_FRACTION, GFC_STD_F95);
 
-  add_sym_2 ("fstat", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_2 ("fstat", 0, 0, BT_INTEGER, di, GFC_STD_GNU,
 	     gfc_check_fstat, NULL, gfc_resolve_fstat,
 	     a, BT_INTEGER, di, REQUIRED, b, BT_INTEGER, di, REQUIRED);
 
   make_generic ("fstat", GFC_ISYM_FSTAT, GFC_STD_GNU);
 
-  add_sym_1 ("ftell", 0, 1, BT_INTEGER, ii, GFC_STD_GNU,
+  add_sym_1 ("ftell", 0, 0, 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,
+  add_sym_2 ("fgetc", 0, 0, 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,
+  add_sym_1 ("fget", 0, 0, 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,
+  add_sym_2 ("fputc", 0, 0, 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,
+  add_sym_1 ("fput", 0, 0, 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,
+  add_sym_1 ("getcwd", 0, 0, BT_INTEGER, di,  GFC_STD_GNU,
 	     NULL, NULL, gfc_resolve_getcwd,
 	     c, BT_CHARACTER, dc, REQUIRED);
 
@@ -1443,25 +1474,25 @@ add_functions (void)
 
   make_generic ("getuid", GFC_ISYM_GETUID, GFC_STD_GNU);
 
-  add_sym_1 ("hostnm", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_1 ("hostnm", 0, 0, 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,
+  add_sym_1 ("huge", 0, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_huge, gfc_simplify_huge, NULL,
 	     x, BT_UNKNOWN, dr, REQUIRED);
 
   make_generic ("huge", GFC_ISYM_NONE, GFC_STD_F95);
 
-  add_sym_1 ("iachar", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_1 ("iachar", 1, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_ichar_iachar, gfc_simplify_iachar, NULL,
 	     c, BT_CHARACTER, dc, REQUIRED);
 
   make_generic ("iachar", GFC_ISYM_IACHAR, GFC_STD_F95);
 
-  add_sym_2 ("iand", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_2 ("iand", 1, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_iand, gfc_simplify_iand, gfc_resolve_iand,
 	     i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
 
@@ -1473,31 +1504,25 @@ add_functions (void)
 
   make_generic ("and", GFC_ISYM_AND, GFC_STD_GNU);
 
-  add_sym_0 ("iargc", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_0 ("iargc", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
 	     NULL, NULL, NULL);
 
   make_generic ("iargc", GFC_ISYM_IARGC, GFC_STD_GNU);
 
-  add_sym_0 ("command_argument_count", 1, 1, BT_INTEGER, di, GFC_STD_F2003,
-	     NULL, NULL, NULL);
-
-  make_generic ("command_argument_count", GFC_ISYM_COMMAND_ARGUMENT_COUNT,
-	        GFC_STD_F2003);
-
-  add_sym_2 ("ibclr", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_2 ("ibclr", 1, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_ibclr, gfc_simplify_ibclr, gfc_resolve_ibclr,
 	     i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED);
 
   make_generic ("ibclr", GFC_ISYM_IBCLR, GFC_STD_F95);
 
-  add_sym_3 ("ibits", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_3 ("ibits", 1, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_ibits, gfc_simplify_ibits, gfc_resolve_ibits,
 	     i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED,
 	     ln, BT_INTEGER, di, REQUIRED);
 
   make_generic ("ibits", GFC_ISYM_IBITS, GFC_STD_F95);
 
-  add_sym_2 ("ibset", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_2 ("ibset", 1, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_ibset, gfc_simplify_ibset, gfc_resolve_ibset,
 	     i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED);
 
@@ -1509,7 +1534,7 @@ add_functions (void)
 
   make_generic ("ichar", GFC_ISYM_ICHAR, GFC_STD_F77);
 
-  add_sym_2 ("ieor", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_2 ("ieor", 1, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_ieor, gfc_simplify_ieor, gfc_resolve_ieor,
 	     i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
 
@@ -1527,13 +1552,13 @@ add_functions (void)
   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,
+	     gfc_check_index, gfc_simplify_index, gfc_resolve_index_func,
 	     stg, BT_CHARACTER, dc, REQUIRED, ssg, BT_CHARACTER, dc, REQUIRED,
 	     bck, BT_LOGICAL, dl, OPTIONAL);
 
   make_generic ("index", GFC_ISYM_INDEX, GFC_STD_F77);
 
-  add_sym_2 ("int", 1, 1, BT_INTEGER, di, GFC_STD_F77,
+  add_sym_2 ("int", 1, 0, BT_INTEGER, di, GFC_STD_F77,
 	     gfc_check_int, gfc_simplify_int, gfc_resolve_int,
 	     a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
 
@@ -1567,7 +1592,7 @@ add_functions (void)
 
   make_generic ("long", GFC_ISYM_LONG, GFC_STD_GNU);
 
-  add_sym_2 ("ior", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_2 ("ior", 1, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_ior, gfc_simplify_ior, gfc_resolve_ior,
 	     i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
 
@@ -1580,7 +1605,7 @@ add_functions (void)
   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,
+  add_sym_1 ("irand", 0, 0, BT_INTEGER, 4, GFC_STD_GNU,
              gfc_check_irand, NULL, NULL,
 	     i, BT_INTEGER, 4, OPTIONAL);
 
@@ -1592,44 +1617,44 @@ add_functions (void)
 
   make_generic ("isatty", GFC_ISYM_ISATTY, GFC_STD_GNU);
 
-  add_sym_2 ("rshift", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_2 ("rshift", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
 	     gfc_check_ishft, NULL, gfc_resolve_rshift,
 	     i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED);
 
   make_generic ("rshift", GFC_ISYM_RSHIFT, GFC_STD_GNU);
 
-  add_sym_2 ("lshift", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_2 ("lshift", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
 	     gfc_check_ishft, NULL, gfc_resolve_lshift,
 	     i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED);
 
   make_generic ("lshift", GFC_ISYM_LSHIFT, GFC_STD_GNU);
 
-  add_sym_2 ("ishft", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_2 ("ishft", 1, 0, 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);
 
   make_generic ("ishft", GFC_ISYM_ISHFT, GFC_STD_F95);
 
-  add_sym_3 ("ishftc", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_3 ("ishftc", 1, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_ishftc, gfc_simplify_ishftc, gfc_resolve_ishftc,
 	     i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED,
 	     sz, BT_INTEGER, di, OPTIONAL);
 
   make_generic ("ishftc", GFC_ISYM_ISHFTC, GFC_STD_F95);
 
-  add_sym_2 ("kill", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_2 ("kill", 1, 0, 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,
+  add_sym_1 ("kind", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_kind, gfc_simplify_kind, NULL,
 	     x, BT_REAL, dr, REQUIRED);
 
   make_generic ("kind", GFC_ISYM_NONE, GFC_STD_F95);
 
-  add_sym_2 ("lbound", 0, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_2 ("lbound", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_lbound, gfc_simplify_lbound, gfc_resolve_lbound,
 	     ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, di, OPTIONAL);
 
@@ -1641,7 +1666,7 @@ add_functions (void)
 
   make_generic ("len", GFC_ISYM_LEN, GFC_STD_F77);
 
-  add_sym_1 ("len_trim", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_1 ("len_trim", 1, 0, BT_INTEGER, di, GFC_STD_F95,
 	     NULL, gfc_simplify_len_trim, gfc_resolve_len_trim,
 	     stg, BT_CHARACTER, dc, REQUIRED);
 
@@ -1673,13 +1698,13 @@ add_functions (void)
 
   make_generic ("llt", GFC_ISYM_LLT, GFC_STD_F77);
 
-  add_sym_2 ("link", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_2 ("link", 0, 0, 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,
+  add_sym_1 ("log", 1, 0, BT_REAL, dr, GFC_STD_F77,
 	     gfc_check_fn_rc, gfc_simplify_log, gfc_resolve_log,
 	     x, BT_REAL, dr, REQUIRED);
 
@@ -1703,7 +1728,7 @@ add_functions (void)
 
   make_generic ("log", GFC_ISYM_LOG, GFC_STD_F77);
 
-  add_sym_1 ("log10", 1, 1, BT_REAL, dr, GFC_STD_F77,
+  add_sym_1 ("log10", 1, 0, BT_REAL, dr, GFC_STD_F77,
 	     gfc_check_fn_r, gfc_simplify_log10, gfc_resolve_log10,
 	     x, BT_REAL, dr, REQUIRED);
 
@@ -1717,24 +1742,24 @@ add_functions (void)
 
   make_generic ("log10", GFC_ISYM_LOG10, GFC_STD_F77);
 
-  add_sym_2 ("logical", 1, 1, BT_LOGICAL, dl, GFC_STD_F95,
+  add_sym_2 ("logical", 1, 0, 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_2 ("lstat", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_2 ("lstat", 0, 0, BT_INTEGER, di, GFC_STD_GNU,
 	     gfc_check_stat, NULL, gfc_resolve_lstat,
 	     a, BT_CHARACTER, dc, REQUIRED, b, BT_INTEGER, di, REQUIRED);
 
   make_generic ("lstat", GFC_ISYM_LSTAT, GFC_STD_GNU);
 
-  add_sym_1 ("malloc", 0, 1, BT_INTEGER, ii, GFC_STD_GNU, gfc_check_malloc,
+  add_sym_1 ("malloc", 0, 0, 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,
+  add_sym_2 ("matmul", 0, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_matmul, NULL, gfc_resolve_matmul,
 	     ma, BT_REAL, dr, REQUIRED, mb, BT_REAL, dr, REQUIRED);
 
@@ -1769,20 +1794,20 @@ add_functions (void)
 
   make_generic ("max", GFC_ISYM_MAX, GFC_STD_F77);
 
-  add_sym_1 ("maxexponent", 0, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_1 ("maxexponent", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_x, gfc_simplify_maxexponent, NULL,
 	     x, BT_UNKNOWN, dr, REQUIRED);
 
   make_generic ("maxexponent", GFC_ISYM_NONE, GFC_STD_F95);
 
-  add_sym_3ml ("maxloc", 0, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_3ml ("maxloc", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	       gfc_check_minloc_maxloc, NULL, gfc_resolve_maxloc,
 	       ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
 	       msk, BT_LOGICAL, dl, OPTIONAL);
 
   make_generic ("maxloc", GFC_ISYM_MAXLOC, GFC_STD_F95);
 
-  add_sym_3red ("maxval", 0, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_3red ("maxval", 0, 0, BT_REAL, dr, GFC_STD_F95,
                 gfc_check_minval_maxval, NULL, gfc_resolve_maxval,
 		ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
 		msk, BT_LOGICAL, dl, OPTIONAL);
@@ -1799,7 +1824,7 @@ add_functions (void)
 
   make_generic ("mclock8", GFC_ISYM_MCLOCK8, GFC_STD_GNU);
 
-  add_sym_3 ("merge", 1, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_3 ("merge", 1, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_merge, NULL, gfc_resolve_merge,
 	     ts, BT_REAL, dr, REQUIRED, fs, BT_REAL, dr, REQUIRED,
 	     msk, BT_LOGICAL, dl, REQUIRED);
@@ -1835,20 +1860,20 @@ add_functions (void)
 
   make_generic ("min", GFC_ISYM_MIN, GFC_STD_F77);
 
-  add_sym_1 ("minexponent", 0, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_1 ("minexponent", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_x, gfc_simplify_minexponent, NULL,
 	     x, BT_UNKNOWN, dr, REQUIRED);
 
   make_generic ("minexponent", GFC_ISYM_NONE, GFC_STD_F95);
 
-  add_sym_3ml ("minloc", 0, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_3ml ("minloc", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	       gfc_check_minloc_maxloc, NULL, gfc_resolve_minloc,
 	       ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
 	       msk, BT_LOGICAL, dl, OPTIONAL);
 
   make_generic ("minloc", GFC_ISYM_MINLOC, GFC_STD_F95);
 
-  add_sym_3red ("minval", 0, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_3red ("minval", 0, 0, BT_REAL, dr, GFC_STD_F95,
                 gfc_check_minval_maxval, NULL, gfc_resolve_minval,
 		ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
 		msk, BT_LOGICAL, dl, OPTIONAL);
@@ -1875,7 +1900,7 @@ add_functions (void)
 
   make_generic ("modulo", GFC_ISYM_MODULO, GFC_STD_F95);
 
-  add_sym_2 ("nearest", 1, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_2 ("nearest", 1, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_nearest, gfc_simplify_nearest, gfc_resolve_nearest,
 	     x, BT_REAL, dr, REQUIRED, s, BT_REAL, dr, REQUIRED);
 
@@ -1891,52 +1916,52 @@ add_functions (void)
 
   make_generic ("nint", GFC_ISYM_NINT, GFC_STD_F77);
 
-  add_sym_1 ("not", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_1 ("not", 1, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_i, gfc_simplify_not, gfc_resolve_not,
 	     i, BT_INTEGER, di, REQUIRED);
 
   make_generic ("not", GFC_ISYM_NOT, GFC_STD_F95);
 
-  add_sym_1 ("null", 0, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_1 ("null", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_null, gfc_simplify_null, NULL,
 	     mo, BT_INTEGER, di, OPTIONAL);
 
   make_generic ("null", GFC_ISYM_NONE, GFC_STD_F95);
 
-  add_sym_3 ("pack", 0, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_3 ("pack", 0, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_pack, NULL, gfc_resolve_pack,
 	     ar, BT_REAL, dr, REQUIRED, msk, BT_LOGICAL, dl, REQUIRED,
 	     v, BT_REAL, dr, OPTIONAL);
 
   make_generic ("pack", GFC_ISYM_PACK, GFC_STD_F95);
 
-  add_sym_1 ("precision", 0, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_1 ("precision", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_precision, gfc_simplify_precision, NULL,
 	     x, BT_UNKNOWN, 0, REQUIRED);
 
   make_generic ("precision", GFC_ISYM_NONE, GFC_STD_F95);
 
-  add_sym_1 ("present", 0, 1, BT_LOGICAL, dl, GFC_STD_F95,
+  add_sym_1 ("present", 0, 0, BT_LOGICAL, dl, GFC_STD_F95,
 	     gfc_check_present, NULL, NULL,
 	     a, BT_REAL, dr, REQUIRED);
 
   make_generic ("present", GFC_ISYM_PRESENT, GFC_STD_F95);
 
-  add_sym_3red ("product", 0, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_3red ("product", 0, 0, BT_REAL, dr, GFC_STD_F95,
                 gfc_check_product_sum, NULL, gfc_resolve_product,
 		ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
 		msk, BT_LOGICAL, dl, OPTIONAL);
 
   make_generic ("product", GFC_ISYM_PRODUCT, GFC_STD_F95);
 
-  add_sym_1 ("radix", 0, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_1 ("radix", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_radix, gfc_simplify_radix, NULL,
 	     x, BT_UNKNOWN, 0, REQUIRED);
 
   make_generic ("radix", GFC_ISYM_NONE, GFC_STD_F95);
 
   /* The following function is for G77 compatibility.  */
-  add_sym_1 ("rand", 0, 1, BT_REAL, 4, GFC_STD_GNU,
+  add_sym_1 ("rand", 0, 0, BT_REAL, 4, GFC_STD_GNU,
              gfc_check_rand, NULL, NULL,
              i, BT_INTEGER, 4, OPTIONAL);
 
@@ -1946,7 +1971,7 @@ add_functions (void)
 
   make_generic ("rand", GFC_ISYM_RAND, GFC_STD_GNU);
 
-  add_sym_1 ("range", 0, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_1 ("range", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_range, gfc_simplify_range, NULL,
 	     x, BT_REAL, dr, REQUIRED);
 
@@ -1971,38 +1996,38 @@ add_functions (void)
 
   make_generic ("real", GFC_ISYM_REAL, GFC_STD_F77);
 
-  add_sym_2 ("rename", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_2 ("rename", 0, 0, 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,
+  add_sym_2 ("repeat", 0, 0, 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);
 
   make_generic ("repeat", GFC_ISYM_REPEAT, GFC_STD_F95);
 
-  add_sym_4 ("reshape", 0, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_4 ("reshape", 0, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_reshape, gfc_simplify_reshape, gfc_resolve_reshape,
 	     src, BT_REAL, dr, REQUIRED, shp, BT_INTEGER, ii, REQUIRED,
 	     pad, BT_REAL, dr, OPTIONAL, ord, BT_INTEGER, ii, OPTIONAL);
 
   make_generic ("reshape", GFC_ISYM_RESHAPE, GFC_STD_F95);
 
-  add_sym_1 ("rrspacing", 1, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_1 ("rrspacing", 1, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_x, gfc_simplify_rrspacing, gfc_resolve_rrspacing,
 	     x, BT_REAL, dr, REQUIRED);
 
   make_generic ("rrspacing", GFC_ISYM_RRSPACING, GFC_STD_F95);
 
-  add_sym_2 ("scale", 1, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_2 ("scale", 1, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_scale, gfc_simplify_scale, gfc_resolve_scale,
 	     x, BT_REAL, dr, REQUIRED, i, BT_INTEGER, di, REQUIRED);
 
   make_generic ("scale", GFC_ISYM_SCALE, GFC_STD_F95);
 
-  add_sym_3 ("scan", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_3 ("scan", 1, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_scan, gfc_simplify_scan, gfc_resolve_scan,
 	     stg, BT_CHARACTER, dc, REQUIRED, set, BT_CHARACTER, dc, REQUIRED,
 	     bck, BT_LOGICAL, dl, OPTIONAL);
@@ -2010,39 +2035,39 @@ add_functions (void)
   make_generic ("scan", GFC_ISYM_SCAN, GFC_STD_F95);
 
   /* Added for G77 compatibility garbage.  */
-  add_sym_0 ("second", 0, 1, BT_REAL, 4, GFC_STD_GNU,
+  add_sym_0 ("second", 0, 0, BT_REAL, 4, GFC_STD_GNU,
 	     NULL, NULL, NULL);
 
   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,
+  add_sym_1 ("secnds", 0, 0, 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,
+  add_sym_1 ("selected_int_kind", 0, 0, BT_INTEGER, di,  GFC_STD_F95,
 	     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);
 
-  add_sym_2 ("selected_real_kind", 0, 1, BT_INTEGER, di,  GFC_STD_F95,
+  add_sym_2 ("selected_real_kind", 0, 0, BT_INTEGER, di,  GFC_STD_F95,
 	     gfc_check_selected_real_kind, gfc_simplify_selected_real_kind,
 	     NULL,
 	     p, BT_INTEGER, di, OPTIONAL, r, BT_INTEGER, di, OPTIONAL);
 
   make_generic ("selected_real_kind", GFC_ISYM_SR_KIND, GFC_STD_F95);
 
-  add_sym_2 ("set_exponent", 1, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_2 ("set_exponent", 1, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_set_exponent, gfc_simplify_set_exponent,
 	     gfc_resolve_set_exponent,
 	     x, BT_REAL, dr, REQUIRED, i, BT_INTEGER, di, REQUIRED);
 
   make_generic ("set_exponent", GFC_ISYM_SET_EXPONENT, GFC_STD_F95);
 
-  add_sym_1 ("shape", 0, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_1 ("shape", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_shape, gfc_simplify_shape, gfc_resolve_shape,
 	     src, BT_REAL, dr, REQUIRED);
 
@@ -2062,7 +2087,7 @@ add_functions (void)
 
   make_generic ("sign", GFC_ISYM_SIGN, GFC_STD_F77);
 
-  add_sym_2 ("signal", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_2 ("signal", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
 	     gfc_check_signal, NULL, gfc_resolve_signal,
 	     num, BT_INTEGER, di, REQUIRED, han, BT_UNKNOWN, 0, REQUIRED);
 
@@ -2098,19 +2123,19 @@ add_functions (void)
 
   make_generic ("sinh", GFC_ISYM_SINH, GFC_STD_F77);
 
-  add_sym_2 ("size", 0, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_2 ("size", 0, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_size, gfc_simplify_size, NULL,
 	     ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
 
   make_generic ("size", GFC_ISYM_SIZE, GFC_STD_F95);
 
-  add_sym_1 ("spacing", 1, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_1 ("spacing", 1, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_x, gfc_simplify_spacing, gfc_resolve_spacing,
 	     x, BT_REAL, dr, REQUIRED);
 
   make_generic ("spacing", GFC_ISYM_SPACING, GFC_STD_F95);
 
-  add_sym_3 ("spread", 0, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_3 ("spread", 0, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_spread, NULL, gfc_resolve_spread,
 	     src, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, REQUIRED,
 	     n, BT_INTEGER, di, REQUIRED);
@@ -2137,26 +2162,26 @@ add_functions (void)
 
   make_generic ("sqrt", GFC_ISYM_SQRT, GFC_STD_F77);
 
-  add_sym_2 ("stat", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_2 ("stat", 0, 0, BT_INTEGER, di, GFC_STD_GNU,
 	     gfc_check_stat, NULL, gfc_resolve_stat,
 	     a, BT_CHARACTER, dc, REQUIRED, b, BT_INTEGER, di, REQUIRED);
 
   make_generic ("stat", GFC_ISYM_STAT, GFC_STD_GNU);
 
-  add_sym_3red ("sum", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
+  add_sym_3red ("sum", 0, 0, BT_UNKNOWN, 0, GFC_STD_F95,
                 gfc_check_product_sum, NULL, gfc_resolve_sum,
 		ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
 		msk, BT_LOGICAL, dl, OPTIONAL);
 
   make_generic ("sum", GFC_ISYM_SUM, GFC_STD_F95);
 
-  add_sym_2 ("symlnk", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_2 ("symlnk", 0, 0, 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,
+  add_sym_1 ("system", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
 	     NULL, NULL, NULL,
 	     c, BT_CHARACTER, dc, REQUIRED);
 
@@ -2192,72 +2217,72 @@ add_functions (void)
 
   make_generic ("time8", GFC_ISYM_TIME8, GFC_STD_GNU);
 
-  add_sym_1 ("tiny", 0, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_1 ("tiny", 0, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_x, gfc_simplify_tiny, NULL,
 	     x, BT_REAL, dr, REQUIRED);
 
   make_generic ("tiny", GFC_ISYM_NONE, GFC_STD_F95);
 
-  add_sym_3 ("transfer", 0, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_3 ("transfer", 0, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_transfer, gfc_simplify_transfer, gfc_resolve_transfer,
 	     src, BT_REAL, dr, REQUIRED, mo, BT_REAL, dr, REQUIRED,
 	     sz, BT_INTEGER, di, OPTIONAL);
 
   make_generic ("transfer", GFC_ISYM_TRANSFER, GFC_STD_F95);
 
-  add_sym_1 ("transpose", 0, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_1 ("transpose", 0, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_transpose, NULL, gfc_resolve_transpose,
 	     m, BT_REAL, dr, REQUIRED);
 
   make_generic ("transpose", GFC_ISYM_TRANSPOSE, GFC_STD_F95);
 
-  add_sym_1 ("trim", 0, 1, BT_CHARACTER, dc, GFC_STD_F95,
+  add_sym_1 ("trim", 0, 0, BT_CHARACTER, dc, GFC_STD_F95,
 	     gfc_check_trim, gfc_simplify_trim, gfc_resolve_trim,
 	     stg, BT_CHARACTER, dc, REQUIRED);
 
   make_generic ("trim", GFC_ISYM_TRIM, GFC_STD_F95);
 
-  add_sym_1 ("ttynam", 0, 1, BT_CHARACTER, 0, GFC_STD_GNU,
+  add_sym_1 ("ttynam", 0, 0, 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,
+  add_sym_2 ("ubound", 0, 0, 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);
 
   make_generic ("ubound", GFC_ISYM_UBOUND, GFC_STD_F95);
 
   /* g77 compatibility for UMASK.  */
-  add_sym_1 ("umask", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_1 ("umask", 0, 0, BT_INTEGER, di, GFC_STD_GNU,
 	     gfc_check_umask, NULL, gfc_resolve_umask,
 	     a, BT_INTEGER, di, REQUIRED);
 
   make_generic ("umask", GFC_ISYM_UMASK, GFC_STD_GNU);
 
   /* g77 compatibility for UNLINK.  */
-  add_sym_1 ("unlink", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+  add_sym_1 ("unlink", 0, 0, BT_INTEGER, di, GFC_STD_GNU,
 	     gfc_check_unlink, NULL, gfc_resolve_unlink,
 	     a, BT_CHARACTER, dc, REQUIRED);
 
   make_generic ("unlink", GFC_ISYM_UNLINK, GFC_STD_GNU);
 
-  add_sym_3 ("unpack", 0, 1, BT_REAL, dr, GFC_STD_F95,
+  add_sym_3 ("unpack", 0, 0, BT_REAL, dr, GFC_STD_F95,
 	     gfc_check_unpack, NULL, gfc_resolve_unpack,
 	     v, BT_REAL, dr, REQUIRED, msk, BT_LOGICAL, dl, REQUIRED,
 	     f, BT_REAL, dr, REQUIRED);
 
   make_generic ("unpack", GFC_ISYM_UNPACK, GFC_STD_F95);
 
-  add_sym_3 ("verify", 1, 1, BT_INTEGER, di, GFC_STD_F95,
+  add_sym_3 ("verify", 1, 0, BT_INTEGER, di, GFC_STD_F95,
 	     gfc_check_verify, gfc_simplify_verify, gfc_resolve_verify,
 	     stg, BT_CHARACTER, dc, REQUIRED, set, BT_CHARACTER, dc, REQUIRED,
 	     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,
+  add_sym_1 ("loc", 0, 0, BT_INTEGER, ii, GFC_STD_GNU,
 	    gfc_check_loc, NULL, gfc_resolve_loc,
 	    ar, BT_UNKNOWN, 0, REQUIRED);
 		
@@ -2290,237 +2315,237 @@ add_subroutines (void)
   dl = gfc_default_logical_kind;
   ii = gfc_index_integer_kind;
 
-  add_sym_0s ("abort", 1, GFC_STD_GNU, NULL);
+  add_sym_0s ("abort", 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,
+  add_sym_1s ("cpu_time", 0, 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,
+  add_sym_2s ("ctime", 0, 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 ("idate", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_1s ("idate", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
 	      gfc_check_itime_idate, NULL, gfc_resolve_idate,
 	      vl, BT_INTEGER, 4, REQUIRED);
 
-  add_sym_1s ("itime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_1s ("itime", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
 	      gfc_check_itime_idate, NULL, gfc_resolve_itime,
 	      vl, BT_INTEGER, 4, REQUIRED);
 
-  add_sym_2s ("ltime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_2s ("ltime", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
 	      gfc_check_ltime_gmtime, NULL, gfc_resolve_ltime,
 	      tm, BT_INTEGER, di, REQUIRED, vl, BT_INTEGER, di, REQUIRED);
 
-  add_sym_2s ("gmtime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_2s ("gmtime", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
 	      gfc_check_ltime_gmtime, NULL, gfc_resolve_gmtime,
 	      tm, BT_INTEGER, di, REQUIRED, vl, BT_INTEGER, di, REQUIRED);
 
-  add_sym_1s ("second", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_1s ("second", 0, 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,
+  add_sym_2s ("chdir", 0, 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_3s ("chmod", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_3s ("chmod", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
               gfc_check_chmod_sub, NULL, gfc_resolve_chmod_sub,
 	      name, BT_CHARACTER, dc, REQUIRED, md, BT_CHARACTER, dc, REQUIRED,
 	      st, BT_INTEGER, di, OPTIONAL);
 
-  add_sym_4s ("date_and_time", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
+  add_sym_4s ("date_and_time", 0, BT_UNKNOWN, 0, GFC_STD_F95,
 	      gfc_check_date_and_time, NULL, NULL,
 	      dt, BT_CHARACTER, dc, OPTIONAL, tm, BT_CHARACTER, dc, OPTIONAL,
 	      zn, BT_CHARACTER, dc, OPTIONAL, vl, BT_INTEGER, di, OPTIONAL);
 
   /* More G77 compatibility garbage.  */
-  add_sym_2s ("etime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_2s ("etime", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
 	     gfc_check_etime_sub, NULL, gfc_resolve_etime_sub,
 	      vl, BT_REAL, 4, REQUIRED, tm, BT_REAL, 4, REQUIRED);
 
-  add_sym_2s ("dtime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_2s ("dtime", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
 	     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,
+  add_sym_1s ("fdate", 0, 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,
+  add_sym_1s ("gerror", 0, 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,
+  add_sym_2s ("getcwd", 0, 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);
 
-  add_sym_2s ("getenv", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_2s ("getenv", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
 	      NULL, NULL, NULL,
 	      name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER, dc, REQUIRED);
 
-  add_sym_2s ("getarg", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_2s ("getarg", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
 	      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,
+  add_sym_1s ("getlog", 0, 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,
+  add_sym_3s ("get_command", 0, BT_UNKNOWN, 0, GFC_STD_F2003,
 	      NULL, NULL, gfc_resolve_get_command,
 	      com, BT_CHARACTER, dc, OPTIONAL, length, BT_INTEGER, di, OPTIONAL,
 	      st, BT_INTEGER, di, OPTIONAL);
 
-  add_sym_4s ("get_command_argument", 0, 1, BT_UNKNOWN, 0, GFC_STD_F2003,
+  add_sym_4s ("get_command_argument", 0, BT_UNKNOWN, 0, GFC_STD_F2003,
 	      NULL, NULL, gfc_resolve_get_command_argument,
 	      num, BT_INTEGER, di, REQUIRED, val, BT_CHARACTER, dc, OPTIONAL,
 	      length, BT_INTEGER, di, OPTIONAL, st, BT_INTEGER, di, OPTIONAL);
 
   /* F2003 subroutine to get environment variables.  */
 
-  add_sym_5s ("get_environment_variable", 0, 1, BT_UNKNOWN, 0, GFC_STD_F2003,
+  add_sym_5s ("get_environment_variable", 0, BT_UNKNOWN, 0, GFC_STD_F2003,
 	     NULL, NULL, gfc_resolve_get_environment_variable,
 	      name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER, dc, OPTIONAL,
 	      length, BT_INTEGER, di, OPTIONAL, st, BT_INTEGER, di, OPTIONAL,
 	      trim_name, BT_LOGICAL, dl, OPTIONAL);
 
-  add_sym_5s ("mvbits", 1, 1, BT_UNKNOWN, 0, GFC_STD_F95,
+  add_sym_5s ("mvbits", 1, BT_UNKNOWN, 0, GFC_STD_F95,
 	      gfc_check_mvbits, gfc_simplify_mvbits, gfc_resolve_mvbits,
 	      f, BT_INTEGER, di, REQUIRED, fp, BT_INTEGER, di, REQUIRED,
 	      ln, BT_INTEGER, di, REQUIRED, t, BT_INTEGER, di, REQUIRED,
 	      tp, BT_INTEGER, di, REQUIRED);
 
-  add_sym_1s ("random_number", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
+  add_sym_1s ("random_number", 0, BT_UNKNOWN, 0, GFC_STD_F95,
 	      gfc_check_random_number, NULL, gfc_resolve_random_number,
 	      h, BT_REAL, dr, REQUIRED);
 
-  add_sym_3s ("random_seed", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
+  add_sym_3s ("random_seed", 0, BT_UNKNOWN, 0, GFC_STD_F95,
 	     gfc_check_random_seed, NULL, NULL,
 	      sz, BT_INTEGER, di, OPTIONAL, pt, BT_INTEGER, di, OPTIONAL,
 	      gt, BT_INTEGER, di, OPTIONAL);
 
   /* More G77 compatibility garbage.  */
-  add_sym_3s ("alarm", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_3s ("alarm", 0, 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,
+  add_sym_1s ("srand", 0, BT_UNKNOWN, di, GFC_STD_GNU,
              gfc_check_srand, NULL, gfc_resolve_srand,
 	      c, BT_INTEGER, 4, REQUIRED);
 
-  add_sym_1s ("exit", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_1s ("exit", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
              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,
+  add_sym_3s ("fgetc", 0, 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,
+  add_sym_2s ("fget", 0, 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,
+  add_sym_1s ("flush", 0, 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,
+  add_sym_3s ("fputc", 0, 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,
+  add_sym_2s ("fput", 0, 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,
+  add_sym_1s ("free", 0, 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,
+  add_sym_2s ("ftell", 0, 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,
+  add_sym_2s ("hostnm", 0, 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,
+  add_sym_3s ("kill", 0, 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,
+  add_sym_3s ("link", 0, 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,
+  add_sym_1s ("perror", 0, 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,
+  add_sym_3s ("rename", 0, 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,
+  add_sym_1s ("sleep", 0, 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,
+  add_sym_3s ("fstat", 0, 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,
 	      st, BT_INTEGER, di, OPTIONAL);
 
-  add_sym_3s ("lstat", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_3s ("lstat", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
 	      gfc_check_stat_sub, NULL, gfc_resolve_lstat_sub,
 	      name, BT_CHARACTER, dc, REQUIRED, vl, BT_INTEGER, di, REQUIRED,
 	      st, BT_INTEGER, di, OPTIONAL);
 
-  add_sym_3s ("stat", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_3s ("stat", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
 	      gfc_check_stat_sub, NULL, gfc_resolve_stat_sub,
 	      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,
+  add_sym_3s ("signal", 0, 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,
+  add_sym_3s ("symlnk", 0, 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,
+  add_sym_2s ("system", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
 	      NULL, NULL, gfc_resolve_system_sub,
 	      c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
 
-  add_sym_3s ("system_clock", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
+  add_sym_3s ("system_clock", 0, BT_UNKNOWN, 0, GFC_STD_F95,
 	     gfc_check_system_clock, NULL, gfc_resolve_system_clock,
 	      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,
+  add_sym_2s ("ttynam", 0, 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,
+  add_sym_2s ("umask", 0, 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);
 
-  add_sym_2s ("unlink", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+  add_sym_2s ("unlink", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
           gfc_check_unlink_sub, NULL, gfc_resolve_unlink_sub,
 	      c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
 
diff --git a/gcc/fortran/intrinsic.h b/gcc/fortran/intrinsic.h
index 1f2c069a073267af716af00a592d7d6780713c3b..3e7ad393455d9a557371ced305b77127aa0b8b41 100644
--- a/gcc/fortran/intrinsic.h
+++ b/gcc/fortran/intrinsic.h
@@ -357,6 +357,7 @@ void gfc_resolve_iand (gfc_expr *, gfc_expr *, gfc_expr *);
 void gfc_resolve_ibclr (gfc_expr *, gfc_expr *, gfc_expr *);
 void gfc_resolve_ibits (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *);
 void gfc_resolve_ibset (gfc_expr *, gfc_expr *, gfc_expr *);
+void gfc_resolve_index_func (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *);
 void gfc_resolve_ierrno (gfc_expr *);
 void gfc_resolve_ieor (gfc_expr *, gfc_expr *, gfc_expr *);
 void gfc_resolve_ichar (gfc_expr *, gfc_expr *);
diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index 31d1f1fb2389a25a4124936e7204f5c951df992a..e3d8cc8eda8ad6d9ee8a451ca08a11b3eae86ad9 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -667,7 +667,7 @@ end program test_aimag
 @item @emph{Specific names}:
 @multitable @columnfractions .20 .20 .20 .40
 @item Name            @tab Argument            @tab Return type       @tab Standard
-@item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)}    @tab F95 and later
+@item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)}    @tab GNU extension
 @item @code{IMAG(Z)}  @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)}    @tab GNU extension
 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
 @end multitable
diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
index c72bf9f8b3f8985b456ebfdbc891ca1e32bf9ce0..1e57881125cfd2eb2347b0c69a72e5b66668ecee 100644
--- a/gcc/fortran/iresolve.c
+++ b/gcc/fortran/iresolve.c
@@ -876,6 +876,29 @@ gfc_resolve_ior (gfc_expr * f, gfc_expr * i, gfc_expr * j)
 }
 
 
+void
+gfc_resolve_index_func (gfc_expr * f, gfc_expr * str,
+			ATTRIBUTE_UNUSED gfc_expr * sub_str, gfc_expr * back)
+{
+  gfc_typespec ts;
+
+  f->ts.type = BT_INTEGER;
+  f->ts.kind = gfc_default_integer_kind;
+
+  if (back && back->ts.kind != gfc_default_integer_kind)
+    {
+      ts.type = BT_LOGICAL;
+      ts.kind = gfc_default_integer_kind;
+      ts.derived = NULL;
+      ts.cl = NULL;
+      gfc_convert_type (back, &ts, 2);
+    }
+
+  f->value.function.name =
+    gfc_get_string ("__index_%d_i%d", str->ts.kind, f->ts.kind);
+}
+
+
 void
 gfc_resolve_int (gfc_expr * f, gfc_expr * a, gfc_expr * kind)
 {
@@ -1022,7 +1045,8 @@ gfc_resolve_len (gfc_expr * f, gfc_expr * string)
 {
   f->ts.type = BT_INTEGER;
   f->ts.kind = gfc_default_integer_kind;
-  f->value.function.name = gfc_get_string ("__len_%d", string->ts.kind);
+  f->value.function.name = gfc_get_string ("__len_%d_i%d", string->ts.kind,
+					   gfc_default_integer_kind);
 }
 
 
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index b9653eb7eab7161cf655a2ba7145fdba62c6bf5b..3b6d3a73de742e30a7a6475b74ab777486d30e3b 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -836,6 +836,7 @@ resolve_actual_arglist (gfc_actual_arglist * arg)
 	  || sym->attr.intrinsic
 	  || sym->attr.external)
 	{
+	  int actual_ok;
 
 	  /* If a procedure is not already determined to be something else
 	     check if it is intrinsic.  */
@@ -851,6 +852,19 @@ resolve_actual_arglist (gfc_actual_arglist * arg)
 			 "actual argument", sym->name, &e->where);
 	    }
 
+	  actual_ok = gfc_intrinsic_actual_ok (sym->name, sym->attr.subroutine);
+	  if (sym->attr.intrinsic && actual_ok == 0)
+	    {
+	      gfc_error ("Intrinsic '%s' at %L is not allowed as an "
+			 "actual argument", sym->name, &e->where);
+	    }
+	  else if (sym->attr.intrinsic && actual_ok == 2)
+	  /* We need a special case for CHAR, which is the only intrinsic
+	     function allowed as actual argument in F2003 and not allowed
+	     in F95.  */
+	    gfc_notify_std (GFC_STD_F2003, "Fortran 2003: CHAR intrinsic "
+			    "allowed as actual argument at %L", &e->where);
+
 	  if (sym->attr.contained && !sym->attr.use_assoc
 	      && sym->ns->proc_name->attr.flavor != FL_MODULE)
 	    {
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index f74fcd85575084cc4b84afefc3fb09eaaa225c8d..43e27ee43e208366284693fc8a6807f4bfb21bae 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1075,9 +1075,14 @@ gfc_get_extern_function_decl (gfc_symbol * sym)
 	isym->resolve.f1 (&e, &argexpr);
       else
 	{
-	  /* All specific intrinsics take one or two arguments.  */
-	  gcc_assert (isym->formal->next->next == NULL);
-	  isym->resolve.f2 (&e, &argexpr, NULL);
+	  if (isym->formal->next->next == NULL)
+	    isym->resolve.f2 (&e, &argexpr, NULL);
+	  else
+	    {
+	      /* All specific intrinsics take less than 4 arguments.  */
+	      gcc_assert (isym->formal->next->next->next == NULL);
+	      isym->resolve.f3 (&e, &argexpr, NULL, NULL);
+	    }
 	}
 
       if (gfc_option.flag_f2c
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 83be965f88d13d20bf2cd0d1045e78f23f4d3088..44524790f8af10ef6ca759b2ef5bf4a784e73f77 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2006-10-07  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+	PR fortran/16580
+	PR fortran/29288
+	* gcc/testsuite/gfortran.fortran-torture/execute/specifics.f90:
+	Add tests for using all possible intrinsics as actual arguments.
+	* gcc/testsuite/gfortran.dg/specifics_1.f90: Add tests for using
+	all possible intrinsics as actual arguments.
+	* gcc/testsuite/gfortran.dg/specifics_2.f90: New file.
+	* gcc/testsuite/gfortran.dg/specifics_3.f90: New file.
+
 2006-10-07  Richard Sandiford  <richard@codesourcery.com>
 
 	* gcc.dg/debug/debug-1.c: Use -fno-if-conversion MIPS targets.
diff --git a/gcc/testsuite/gfortran.dg/specifics_1.f90 b/gcc/testsuite/gfortran.dg/specifics_1.f90
index c1d86938ca457d4f02e7941dd56415e32999da3a..a100df4266658ea17398a775ca17500a29fa6e29 100644
--- a/gcc/testsuite/gfortran.dg/specifics_1.f90
+++ b/gcc/testsuite/gfortran.dg/specifics_1.f90
@@ -1,9 +1,13 @@
 ! Program to test intrinsic functions as actual arguments
+!
 ! Copied from gfortran.fortran-torture/execute/specifics.f90
+! Please keep them in sync
+!
 ! It is run here with -ff2c option
 !
 ! { dg-do run }
 ! { dg-options "-ff2c" }
+! Program to test intrinsic functions as actual arguments
 subroutine test_c(fn, val, res)
   complex fn
   complex val, res
@@ -113,13 +117,56 @@ subroutine test_dprod(fn)
   if (abs (fn (2.0, 3.0) - 6d0) .gt. 0.00001) call abort
 end subroutine
 
+subroutine test_nint(fn,val,res)
+  integer fn, res
+  real val
+  if (res .ne. fn(val)) call abort
+end subroutine
+
+subroutine test_idnint(fn,val,res)
+  integer fn, res
+  double precision val
+  if (res .ne. fn(val)) call abort
+end subroutine
+
+subroutine test_idim(fn,val1,val2,res)
+  integer fn, res, val1, val2
+  if (res .ne. fn(val1,val2)) call abort
+end subroutine
+
+subroutine test_iabs(fn,val,res)
+  integer fn, res, val
+  if (res .ne. fn(val)) call abort
+end subroutine
+
+subroutine test_len(fn,val,res)
+  integer fn, res
+  character(len=*) val
+  if (res .ne. fn(val)) call abort
+end subroutine
+
+subroutine test_char(fn,val,res)
+  integer val
+  character(len=1) fn, res
+  if (res .ne. fn(val)) call abort
+end subroutine
+
+subroutine test_index(fn,val1,val2,res)
+  integer fn, res
+  character(len=*) val1, val2
+  if (fn(val1,val2) .ne. res) call abort
+end subroutine
+
 program specifics
   intrinsic abs
   intrinsic aint
   intrinsic anint
   intrinsic acos
+  intrinsic acosh
   intrinsic asin
+  intrinsic asinh
   intrinsic atan
+  intrinsic atanh
   intrinsic cos
   intrinsic sin
   intrinsic tan
@@ -127,16 +174,21 @@ program specifics
   intrinsic sinh
   intrinsic tanh
   intrinsic alog
+  intrinsic alog10
   intrinsic exp
   intrinsic sign
+  intrinsic isign
   intrinsic amod
 
   intrinsic dabs
   intrinsic dint
   intrinsic dnint
   intrinsic dacos
+  intrinsic dacosh
   intrinsic dasin
+  intrinsic dasinh
   intrinsic datan
+  intrinsic datanh
   intrinsic dcos
   intrinsic dsin
   intrinsic dtan
@@ -144,6 +196,7 @@ program specifics
   intrinsic dsinh
   intrinsic dtanh
   intrinsic dlog
+  intrinsic dlog10
   intrinsic dexp
   intrinsic dsign
   intrinsic dmod
@@ -161,18 +214,41 @@ program specifics
   intrinsic cdlog
   intrinsic cdsin
   intrinsic cdsqrt
+  intrinsic zcos
+  intrinsic zexp
+  intrinsic zlog
+  intrinsic zsin
+  intrinsic zsqrt
 
   intrinsic cabs
   intrinsic cdabs
+  intrinsic zabs
 
   intrinsic dprod
 
+  intrinsic nint
+  intrinsic idnint
+  intrinsic dim
+  intrinsic ddim
+  intrinsic idim
+  intrinsic iabs
+  intrinsic mod
+  intrinsic len
+  intrinsic index
+  intrinsic char
+
+  intrinsic aimag
+  intrinsic dimag
+
   call test_r (abs, -1.0, abs(-1.0))
-  call test_r (aint, 1.7, 1.0)
-  call test_r (anint, 1.7, 2.0)
+  call test_r (aint, 1.7, aint(1.7))
+  call test_r (anint, 1.7, anint(1.7))
   call test_r (acos, 0.5, acos(0.5))
+  call test_r (acosh, 1.5, acosh(1.5))
   call test_r (asin, 0.5, asin(0.5))
+  call test_r (asinh, 0.5, asinh(0.5))
   call test_r (atan, 0.5, atan(0.5))
+  call test_r (atanh, 0.5, atanh(0.5))
   call test_r (cos, 1.0, cos(1.0))
   call test_r (sin, 1.0, sin(1.0))
   call test_r (tan, 1.0, tan(1.0))
@@ -180,6 +256,7 @@ program specifics
   call test_r (sinh, 1.0, sinh(1.0))
   call test_r (tanh, 1.0, tanh(1.0))
   call test_r (alog, 2.0, alog(2.0))
+  call test_r (alog10, 2.0, alog10(2.0))
   call test_r (exp, 1.0, exp(1.0))
   call test_r2 (sign, 1.0, -2.0, sign(1.0, -2.0))
   call test_r2 (amod, 3.5, 2.0, amod(3.5, 2.0))
@@ -188,8 +265,11 @@ program specifics
   call test_d (dint, 1.7d0, 1d0)
   call test_d (dnint, 1.7d0, 2d0)
   call test_d (dacos, 0.5d0, dacos(0.5d0))
+  call test_d (dacosh, 1.5d0, dacosh(1.5d0))
   call test_d (dasin, 0.5d0, dasin(0.5d0))
+  call test_d (dasinh, 0.5d0, dasinh(0.5d0))
   call test_d (datan, 0.5d0, datan(0.5d0))
+  call test_d (datanh, 0.5d0, datanh(0.5d0))
   call test_d (dcos, 1d0, dcos(1d0))
   call test_d (dsin, 1d0, dsin(1d0))
   call test_d (dtan, 1d0, dtan(1d0))
@@ -197,6 +277,7 @@ program specifics
   call test_d (dsinh, 1d0, dsinh(1d0))
   call test_d (dtanh, 1d0, dtanh(1d0))
   call test_d (dlog, 2d0, dlog(2d0))
+  call test_d (dlog10, 2d0, dlog10(2d0))
   call test_d (dexp, 1d0, dexp(1d0))
   call test_d2 (dsign, 1d0, -2d0, sign(1d0, -2d0))
   call test_d2 (dmod, 3.5d0, 2d0, dmod(3.5d0, 2d0))
@@ -212,13 +293,34 @@ program specifics
 
   call test_z (dconjg, (1.2d0,-4.d0), dconjg((1.2d0,-4.d0)))
   call test_z (cdcos, (1.2d0,-4.d0), cdcos((1.2d0,-4.d0)))
+  call test_z (zcos, (1.2d0,-4.d0), zcos((1.2d0,-4.d0)))
   call test_z (cdexp, (1.2d0,-4.d0), cdexp((1.2d0,-4.d0)))
+  call test_z (zexp, (1.2d0,-4.d0), zexp((1.2d0,-4.d0)))
   call test_z (cdlog, (1.2d0,-4.d0), cdlog((1.2d0,-4.d0)))
+  call test_z (zlog, (1.2d0,-4.d0), zlog((1.2d0,-4.d0)))
   call test_z (cdsin, (1.2d0,-4.d0), cdsin((1.2d0,-4.d0)))
+  call test_z (zsin, (1.2d0,-4.d0), zsin((1.2d0,-4.d0)))
   call test_z (cdsqrt, (1.2d0,-4.d0), cdsqrt((1.2d0,-4.d0)))
+  call test_z (zsqrt, (1.2d0,-4.d0), zsqrt((1.2d0,-4.d0)))
 
   call test_cabs (cabs, (1.2,-4.), cabs((1.2,-4.)))
   call test_cdabs (cdabs, (1.2d0,-4.d0), cdabs((1.2d0,-4.d0)))
+  call test_cdabs (zabs, (1.2d0,-4.d0), zabs((1.2d0,-4.d0)))
+  call test_cabs (aimag, (1.2,-4.), aimag((1.2,-4.)))
+  call test_cdabs (dimag, (1.2d0,-4.d0), dimag((1.2d0,-4.d0)))
+
+  call test_nint (nint, -1.2, nint(-1.2))
+  call test_idnint (idnint, -1.2d0, idnint(-1.2d0))
+  call test_idim (isign, -42, 17, isign(-42, 17))
+  call test_idim (idim, -42, 17, idim(-42,17))
+  call test_idim (idim, 42, 17, idim(42,17))
+  call test_r2 (dim, 1.2, -4., dim(1.2, -4.))
+  call test_d2 (ddim, 1.2d0, -4.d0, ddim(1.2d0, -4.d0))
+  call test_iabs (iabs, -7, iabs(-7))
+  call test_idim (mod, 5, 2, mod(5,2))
+  call test_len (len, "foobar", len("foobar"))
+  call test_char (char, 47, char(47))
+  call test_index (index, "foobarfoobar", "bar", index("foobarfoobar","bar"))
 
 end program
 
diff --git a/gcc/testsuite/gfortran.dg/specifics_2.f90 b/gcc/testsuite/gfortran.dg/specifics_2.f90
new file mode 100644
index 0000000000000000000000000000000000000000..399dbd5df4b2d1ab8f1ac8b0d5de314a2321b978
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/specifics_2.f90
@@ -0,0 +1,82 @@
+! { dg-do compile }
+! This is the list of intrinsics allowed as actual arguments
+ intrinsic abs,acos,acosh,aimag,aint,alog,alog10,amod,anint,asin,asinh,atan,&
+ atan2,atanh,cabs,ccos,cexp,char,clog,conjg,cos,cosh,csin,csqrt,dabs,dacos,&
+ dacosh,dasin,dasinh,datan,datan2,datanh,dconjg,dcos,dcosh,ddim,dexp,dim,&
+ dimag,dint,dlog,dlog10,dmod,dnint,dprod,dsign,dsin,dsinh,dsqrt,dtan,dtanh,&
+ exp,iabs,idim,idnint,index,isign,len,mod,nint,sign,sin,sinh,sqrt,tan,&
+ tanh,zabs,zcos,zexp,zlog,zsin,zsqrt
+ 
+  call foo(abs)
+  call foo(acos)
+  call foo(acosh)
+  call foo(aimag)
+  call foo(aint)
+  call foo(alog)
+  call foo(alog10)
+  call foo(amod)
+  call foo(anint)
+  call foo(asin)
+  call foo(asinh)
+  call foo(atan)
+  call foo(atan2)
+  call foo(atanh)
+  call foo(cabs)
+  call foo(ccos)
+  call foo(cexp)
+  call foo(char)
+  call foo(clog)
+  call foo(conjg)
+  call foo(cos)
+  call foo(cosh)
+  call foo(csin)
+  call foo(csqrt)
+  call foo(dabs)
+  call foo(dacos)
+  call foo(dacosh)
+  call foo(dasin)
+  call foo(dasinh)
+  call foo(datan)
+  call foo(datan2)
+  call foo(datanh)
+  call foo(dconjg)
+  call foo(dcos)
+  call foo(dcosh)
+  call foo(ddim)
+  call foo(dexp)
+  call foo(dim)
+  call foo(dimag)
+  call foo(dint)
+  call foo(dlog)
+  call foo(dlog10)
+  call foo(dmod)
+  call foo(dnint)
+  call foo(dprod)
+  call foo(dsign)
+  call foo(dsin)
+  call foo(dsinh)
+  call foo(dsqrt)
+  call foo(dtan)
+  call foo(dtanh)
+  call foo(exp)
+  call foo(iabs)
+  call foo(idim)
+  call foo(idnint)
+  call foo(index)
+  call foo(isign)
+  call foo(len)
+  call foo(mod)
+  call foo(nint)
+  call foo(sign)
+  call foo(sin)
+  call foo(sinh)
+  call foo(sqrt)
+  call foo(tan)
+  call foo(tanh)
+  call foo(zabs)
+  call foo(zcos)
+  call foo(zexp)
+  call foo(zlog)
+  call foo(zsin)
+  call foo(zsqrt)
+  end
diff --git a/gcc/testsuite/gfortran.dg/specifics_3.f90 b/gcc/testsuite/gfortran.dg/specifics_3.f90
new file mode 100644
index 0000000000000000000000000000000000000000..3b5ddada4265b2cb2ae2850626f27daf38acf90e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/specifics_3.f90
@@ -0,0 +1,5 @@
+! { dg-do compile }
+! { dg-options "-std=f95" }
+  intrinsic char
+  call foo(char) ! { dg-error "Fortran 2003: CHAR intrinsic allowed as actual argument" }
+  end
diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/specifics.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/specifics.f90
index 18490ef99d1b7fcf1fe5476b5d075985c7188fc8..ec34aa5d0c91b4e4f2211ffc4e84dc760865b634 100644
--- a/gcc/testsuite/gfortran.fortran-torture/execute/specifics.f90
+++ b/gcc/testsuite/gfortran.fortran-torture/execute/specifics.f90
@@ -1,4 +1,6 @@
 ! Program to test intrinsic functions as actual arguments
+!
+! Please keep the content of this file in sync with gfortran.dg/specifics_1.f90
 subroutine test_c(fn, val, res)
   complex fn
   complex val, res
@@ -108,13 +110,56 @@ subroutine test_dprod(fn)
   if (abs (fn (2.0, 3.0) - 6d0) .gt. 0.00001) call abort
 end subroutine
 
+subroutine test_nint(fn,val,res)
+  integer fn, res
+  real val
+  if (res .ne. fn(val)) call abort
+end subroutine
+
+subroutine test_idnint(fn,val,res)
+  integer fn, res
+  double precision val
+  if (res .ne. fn(val)) call abort
+end subroutine
+
+subroutine test_idim(fn,val1,val2,res)
+  integer fn, res, val1, val2
+  if (res .ne. fn(val1,val2)) call abort
+end subroutine
+
+subroutine test_iabs(fn,val,res)
+  integer fn, res, val
+  if (res .ne. fn(val)) call abort
+end subroutine
+
+subroutine test_len(fn,val,res)
+  integer fn, res
+  character(len=*) val
+  if (res .ne. fn(val)) call abort
+end subroutine
+
+subroutine test_char(fn,val,res)
+  integer val
+  character(len=1) fn, res
+  if (res .ne. fn(val)) call abort
+end subroutine
+
+subroutine test_index(fn,val1,val2,res)
+  integer fn, res
+  character(len=*) val1, val2
+  if (fn(val1,val2) .ne. res) call abort
+end subroutine
+
 program specifics
   intrinsic abs
   intrinsic aint
   intrinsic anint
   intrinsic acos
+  intrinsic acosh
   intrinsic asin
+  intrinsic asinh
   intrinsic atan
+  intrinsic atanh
   intrinsic cos
   intrinsic sin
   intrinsic tan
@@ -122,16 +167,21 @@ program specifics
   intrinsic sinh
   intrinsic tanh
   intrinsic alog
+  intrinsic alog10
   intrinsic exp
   intrinsic sign
+  intrinsic isign
   intrinsic amod
 
   intrinsic dabs
   intrinsic dint
   intrinsic dnint
   intrinsic dacos
+  intrinsic dacosh
   intrinsic dasin
+  intrinsic dasinh
   intrinsic datan
+  intrinsic datanh
   intrinsic dcos
   intrinsic dsin
   intrinsic dtan
@@ -139,6 +189,7 @@ program specifics
   intrinsic dsinh
   intrinsic dtanh
   intrinsic dlog
+  intrinsic dlog10
   intrinsic dexp
   intrinsic dsign
   intrinsic dmod
@@ -156,18 +207,41 @@ program specifics
   intrinsic cdlog
   intrinsic cdsin
   intrinsic cdsqrt
+  intrinsic zcos
+  intrinsic zexp
+  intrinsic zlog
+  intrinsic zsin
+  intrinsic zsqrt
 
   intrinsic cabs
   intrinsic cdabs
+  intrinsic zabs
 
   intrinsic dprod
 
+  intrinsic nint
+  intrinsic idnint
+  intrinsic dim
+  intrinsic ddim
+  intrinsic idim
+  intrinsic iabs
+  intrinsic mod
+  intrinsic len
+  intrinsic index
+  intrinsic char
+
+  intrinsic aimag
+  intrinsic dimag
+
   call test_r (abs, -1.0, abs(-1.0))
-  call test_r (aint, 1.7, 1.0)
-  call test_r (anint, 1.7, 2.0)
+  call test_r (aint, 1.7, aint(1.7))
+  call test_r (anint, 1.7, anint(1.7))
   call test_r (acos, 0.5, acos(0.5))
+  call test_r (acosh, 1.5, acosh(1.5))
   call test_r (asin, 0.5, asin(0.5))
+  call test_r (asinh, 0.5, asinh(0.5))
   call test_r (atan, 0.5, atan(0.5))
+  call test_r (atanh, 0.5, atanh(0.5))
   call test_r (cos, 1.0, cos(1.0))
   call test_r (sin, 1.0, sin(1.0))
   call test_r (tan, 1.0, tan(1.0))
@@ -175,6 +249,7 @@ program specifics
   call test_r (sinh, 1.0, sinh(1.0))
   call test_r (tanh, 1.0, tanh(1.0))
   call test_r (alog, 2.0, alog(2.0))
+  call test_r (alog10, 2.0, alog10(2.0))
   call test_r (exp, 1.0, exp(1.0))
   call test_r2 (sign, 1.0, -2.0, sign(1.0, -2.0))
   call test_r2 (amod, 3.5, 2.0, amod(3.5, 2.0))
@@ -183,8 +258,11 @@ program specifics
   call test_d (dint, 1.7d0, 1d0)
   call test_d (dnint, 1.7d0, 2d0)
   call test_d (dacos, 0.5d0, dacos(0.5d0))
+  call test_d (dacosh, 1.5d0, dacosh(1.5d0))
   call test_d (dasin, 0.5d0, dasin(0.5d0))
+  call test_d (dasinh, 0.5d0, dasinh(0.5d0))
   call test_d (datan, 0.5d0, datan(0.5d0))
+  call test_d (datanh, 0.5d0, datanh(0.5d0))
   call test_d (dcos, 1d0, dcos(1d0))
   call test_d (dsin, 1d0, dsin(1d0))
   call test_d (dtan, 1d0, dtan(1d0))
@@ -192,6 +270,7 @@ program specifics
   call test_d (dsinh, 1d0, dsinh(1d0))
   call test_d (dtanh, 1d0, dtanh(1d0))
   call test_d (dlog, 2d0, dlog(2d0))
+  call test_d (dlog10, 2d0, dlog10(2d0))
   call test_d (dexp, 1d0, dexp(1d0))
   call test_d2 (dsign, 1d0, -2d0, sign(1d0, -2d0))
   call test_d2 (dmod, 3.5d0, 2d0, dmod(3.5d0, 2d0))
@@ -207,13 +286,34 @@ program specifics
 
   call test_z (dconjg, (1.2d0,-4.d0), dconjg((1.2d0,-4.d0)))
   call test_z (cdcos, (1.2d0,-4.d0), cdcos((1.2d0,-4.d0)))
+  call test_z (zcos, (1.2d0,-4.d0), zcos((1.2d0,-4.d0)))
   call test_z (cdexp, (1.2d0,-4.d0), cdexp((1.2d0,-4.d0)))
+  call test_z (zexp, (1.2d0,-4.d0), zexp((1.2d0,-4.d0)))
   call test_z (cdlog, (1.2d0,-4.d0), cdlog((1.2d0,-4.d0)))
+  call test_z (zlog, (1.2d0,-4.d0), zlog((1.2d0,-4.d0)))
   call test_z (cdsin, (1.2d0,-4.d0), cdsin((1.2d0,-4.d0)))
+  call test_z (zsin, (1.2d0,-4.d0), zsin((1.2d0,-4.d0)))
   call test_z (cdsqrt, (1.2d0,-4.d0), cdsqrt((1.2d0,-4.d0)))
+  call test_z (zsqrt, (1.2d0,-4.d0), zsqrt((1.2d0,-4.d0)))
 
   call test_cabs (cabs, (1.2,-4.), cabs((1.2,-4.)))
   call test_cdabs (cdabs, (1.2d0,-4.d0), cdabs((1.2d0,-4.d0)))
+  call test_cdabs (zabs, (1.2d0,-4.d0), zabs((1.2d0,-4.d0)))
+  call test_cabs (aimag, (1.2,-4.), aimag((1.2,-4.)))
+  call test_cdabs (dimag, (1.2d0,-4.d0), dimag((1.2d0,-4.d0)))
+
+  call test_nint (nint, -1.2, nint(-1.2))
+  call test_idnint (idnint, -1.2d0, idnint(-1.2d0))
+  call test_idim (isign, -42, 17, isign(-42, 17))
+  call test_idim (idim, -42, 17, idim(-42,17))
+  call test_idim (idim, 42, 17, idim(42,17))
+  call test_r2 (dim, 1.2, -4., dim(1.2, -4.))
+  call test_d2 (ddim, 1.2d0, -4.d0, ddim(1.2d0, -4.d0))
+  call test_iabs (iabs, -7, iabs(-7))
+  call test_idim (mod, 5, 2, mod(5,2))
+  call test_len (len, "foobar", len("foobar"))
+  call test_char (char, 47, char(47))
+  call test_index (index, "foobarfoobar", "bar", index("foobarfoobar","bar"))
 
 end program
 
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 57cee4ca147b7fdfb4b008d322d783f197ac6c74..bb7b7baff4dcd7cd8d9b6de490caa273b1133247 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,6 +1,37 @@
+2006-10-01  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+	PR fortran/16580
+	PR fortran/29288
+	* libgfortran/Makefile.am: Add the new files to the build
+	process, and rules to build them.
+	* libgfortran/Makefile.in: Regenerate.
+	* libgfortran/m4/misc_specifics.m4: New file.
+	* libgfortran/m4/specific.m4: Add new special cases for function
+	with complex argument and real result, like abs_c* and aimag_c*.
+	* libgfortran/intrinsics/f2c_specifics.F90: Add specifics for
+	AIMAG, ASINH, ACOSH and ATANH.
+	* libgfortran/generated/_aimag_c4.F90: New file.
+	* libgfortran/generated/_aimag_c8.F90: New file.
+	* libgfortran/generated/_asinh_r10.F90: New file.
+	* libgfortran/generated/_acosh_r16.F90: New file.
+	* libgfortran/generated/_aimag_c10.F90: New file.
+	* libgfortran/generated/_atanh_r16.F90: New file.
+	* libgfortran/generated/_acosh_r4.F90: New file.
+	* libgfortran/generated/_acosh_r8.F90: New file.
+	* libgfortran/generated/_asinh_r4.F90: New file.
+	* libgfortran/generated/_asinh_r8.F90: New file.
+	* libgfortran/generated/_asinh_r16.F90: New file.
+	* libgfortran/generated/_atanh_r4.F90: New file.
+	* libgfortran/generated/_atanh_r8.F90: New file.
+	* libgfortran/generated/_acosh_r10.F90: New file.
+	* libgfortran/generated/misc_specifics.F90: New file.
+	* libgfortran/generated/_aimag_c16.F90: New file.
+	* libgfortran/generated/_atanh_r10.F90: New file.
+
 2006-10-05  Danny Smith  <dannysmith@users.sourceforge.net>
 
-	* acinclude.m4 (HAVE_ATTRIBUTE_ALIAS): Remove __USER_LABEL_PREFIX__ from test.
+	* acinclude.m4 (HAVE_ATTRIBUTE_ALIAS): Remove __USER_LABEL_PREFIX__
+	from test.
 	* configure: Regenerate.
 
 2006-10-05  Steven G. Kargl  <kargl@gcc.gnu.org>
diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am
index e1c952a9d263502e71a3872fa162c9605aad582f..dd5b684c017f044cde45ba9404683a4543126681 100644
--- a/libgfortran/Makefile.am
+++ b/libgfortran/Makefile.am
@@ -419,7 +419,8 @@ m4_files= m4/iparm.m4 m4/ifunction.m4 m4/iforeach.m4 m4/all.m4 \
     m4/ctrig.m4 m4/cexp.m4 m4/chyp.m4 m4/mtype.m4 \
     m4/specific.m4 m4/specific2.m4 m4/head.m4 m4/shape.m4 m4/reshape.m4 \
     m4/transpose.m4 m4/eoshift1.m4 m4/eoshift3.m4 m4/exponent.m4 \
-    m4/fraction.m4 m4/nearest.m4 m4/set_exponent.m4 m4/pow.m4
+    m4/fraction.m4 m4/nearest.m4 m4/set_exponent.m4 m4/pow.m4 \
+    m4/misc_specifics.m4
 
 gfor_built_src= $(i_all_c) $(i_any_c) $(i_count_c) $(i_maxloc0_c) \
     $(i_maxloc1_c) $(i_maxval_c) $(i_minloc0_c) $(i_minloc1_c) $(i_minval_c) \
@@ -444,6 +445,10 @@ generated/_abs_r4.F90 \
 generated/_abs_r8.F90 \
 generated/_abs_r10.F90 \
 generated/_abs_r16.F90 \
+generated/_aimag_c4.F90 \
+generated/_aimag_c8.F90 \
+generated/_aimag_c10.F90 \
+generated/_aimag_c16.F90 \
 generated/_exp_r4.F90 \
 generated/_exp_r8.F90 \
 generated/_exp_r10.F90 \
@@ -476,14 +481,26 @@ generated/_asin_r4.F90 \
 generated/_asin_r8.F90 \
 generated/_asin_r10.F90 \
 generated/_asin_r16.F90 \
+generated/_asinh_r4.F90 \
+generated/_asinh_r8.F90 \
+generated/_asinh_r10.F90 \
+generated/_asinh_r16.F90 \
 generated/_acos_r4.F90 \
 generated/_acos_r8.F90 \
 generated/_acos_r10.F90 \
 generated/_acos_r16.F90 \
+generated/_acosh_r4.F90 \
+generated/_acosh_r8.F90 \
+generated/_acosh_r10.F90 \
+generated/_acosh_r16.F90 \
 generated/_atan_r4.F90 \
 generated/_atan_r8.F90 \
 generated/_atan_r10.F90 \
 generated/_atan_r16.F90 \
+generated/_atanh_r4.F90 \
+generated/_atanh_r8.F90 \
+generated/_atanh_r10.F90 \
+generated/_atanh_r16.F90 \
 generated/_sin_r4.F90 \
 generated/_sin_r8.F90 \
 generated/_sin_r10.F90 \
@@ -556,9 +573,12 @@ generated/_mod_r8.F90 \
 generated/_mod_r10.F90 \
 generated/_mod_r16.F90
 
+gfor_misc_specifics = generated/misc_specifics.F90
+
 gfor_specific_src= \
 $(gfor_built_specific_src) \
 $(gfor_built_specific2_src) \
+$(gfor_misc_specifics) \
 intrinsics/dprod_r8.f90 \
 intrinsics/f2c_specifics.F90
 
@@ -572,7 +592,7 @@ $(patsubst %.c,%.lo,$(notdir $(i_matmul_c))): AM_CFLAGS += -ftree-vectorize -fun
 $(patsubst %.c,%.lo,$(notdir $(i_matmull_c))): AM_CFLAGS += -funroll-loops
 
 BUILT_SOURCES=$(gfor_built_src) $(gfor_built_specific_src) \
-    $(gfor_built_specific2_src)
+    $(gfor_built_specific2_src) $(gfor_misc_specifics)
 libgfortran_la_SOURCES = $(gfor_src) $(gfor_built_src) $(gfor_io_src) \
     $(gfor_helper_src) $(gfor_io_headers) $(gfor_specific_src)
 
@@ -685,6 +705,9 @@ $(gfor_built_specific_src): m4/specific.m4 m4/head.m4
 
 $(gfor_built_specific2_src): m4/specific2.m4 m4/head.m4
 	$(M4) -Dfile=$@ -I$(srcdir)/m4 specific2.m4 > $(srcdir)/$@
+
+$(gfor_misc_specifics): m4/misc_specifics.m4 m4/head.m4
+	m4 -Dfile=$@ -I$(srcdir)/m4 misc_specifics.m4 > $(srcdir)/$@
 ## end of maintainer mode only rules
 endif
 
diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in
index c53c6dea323b09a7a602cdbd71d8d25c799b5406..77defb517a0750d192bf3f768637b23e16d7746a 100644
--- a/libgfortran/Makefile.in
+++ b/libgfortran/Makefile.in
@@ -179,15 +179,19 @@ am__objects_30 = associated.lo abort.lo access.lo args.lo bessel.lo \
 am__objects_31 =
 am__objects_32 = _abs_c4.lo _abs_c8.lo _abs_c10.lo _abs_c16.lo \
 	_abs_i4.lo _abs_i8.lo _abs_i16.lo _abs_r4.lo _abs_r8.lo \
-	_abs_r10.lo _abs_r16.lo _exp_r4.lo _exp_r8.lo _exp_r10.lo \
+	_abs_r10.lo _abs_r16.lo _aimag_c4.lo _aimag_c8.lo \
+	_aimag_c10.lo _aimag_c16.lo _exp_r4.lo _exp_r8.lo _exp_r10.lo \
 	_exp_r16.lo _exp_c4.lo _exp_c8.lo _exp_c10.lo _exp_c16.lo \
 	_log_r4.lo _log_r8.lo _log_r10.lo _log_r16.lo _log_c4.lo \
 	_log_c8.lo _log_c10.lo _log_c16.lo _log10_r4.lo _log10_r8.lo \
 	_log10_r10.lo _log10_r16.lo _sqrt_r4.lo _sqrt_r8.lo \
 	_sqrt_r10.lo _sqrt_r16.lo _sqrt_c4.lo _sqrt_c8.lo _sqrt_c10.lo \
 	_sqrt_c16.lo _asin_r4.lo _asin_r8.lo _asin_r10.lo _asin_r16.lo \
-	_acos_r4.lo _acos_r8.lo _acos_r10.lo _acos_r16.lo _atan_r4.lo \
-	_atan_r8.lo _atan_r10.lo _atan_r16.lo _sin_r4.lo _sin_r8.lo \
+	_asinh_r4.lo _asinh_r8.lo _asinh_r10.lo _asinh_r16.lo \
+	_acos_r4.lo _acos_r8.lo _acos_r10.lo _acos_r16.lo _acosh_r4.lo \
+	_acosh_r8.lo _acosh_r10.lo _acosh_r16.lo _atan_r4.lo \
+	_atan_r8.lo _atan_r10.lo _atan_r16.lo _atanh_r4.lo \
+	_atanh_r8.lo _atanh_r10.lo _atanh_r16.lo _sin_r4.lo _sin_r8.lo \
 	_sin_r10.lo _sin_r16.lo _sin_c4.lo _sin_c8.lo _sin_c10.lo \
 	_sin_c16.lo _cos_r4.lo _cos_r8.lo _cos_r10.lo _cos_r16.lo \
 	_cos_c4.lo _cos_c8.lo _cos_c10.lo _cos_c16.lo _tan_r4.lo \
@@ -203,11 +207,12 @@ am__objects_33 = _sign_i4.lo _sign_i8.lo _sign_i16.lo _sign_r4.lo \
 	_atan2_r4.lo _atan2_r8.lo _atan2_r10.lo _atan2_r16.lo \
 	_mod_i4.lo _mod_i8.lo _mod_i16.lo _mod_r4.lo _mod_r8.lo \
 	_mod_r10.lo _mod_r16.lo
-am__objects_34 = $(am__objects_32) $(am__objects_33) dprod_r8.lo \
-	f2c_specifics.lo
+am__objects_34 = misc_specifics.lo
+am__objects_35 = $(am__objects_32) $(am__objects_33) $(am__objects_34) \
+	dprod_r8.lo f2c_specifics.lo
 am_libgfortran_la_OBJECTS = $(am__objects_1) $(am__objects_28) \
 	$(am__objects_29) $(am__objects_30) $(am__objects_31) \
-	$(am__objects_34)
+	$(am__objects_35)
 libgfortran_la_OBJECTS = $(am_libgfortran_la_OBJECTS)
 libgfortranbegin_la_LIBADD =
 am_libgfortranbegin_la_OBJECTS = fmain.lo
@@ -767,7 +772,8 @@ m4_files = m4/iparm.m4 m4/ifunction.m4 m4/iforeach.m4 m4/all.m4 \
     m4/ctrig.m4 m4/cexp.m4 m4/chyp.m4 m4/mtype.m4 \
     m4/specific.m4 m4/specific2.m4 m4/head.m4 m4/shape.m4 m4/reshape.m4 \
     m4/transpose.m4 m4/eoshift1.m4 m4/eoshift3.m4 m4/exponent.m4 \
-    m4/fraction.m4 m4/nearest.m4 m4/set_exponent.m4 m4/pow.m4
+    m4/fraction.m4 m4/nearest.m4 m4/set_exponent.m4 m4/pow.m4 \
+    m4/misc_specifics.m4
 
 gfor_built_src = $(i_all_c) $(i_any_c) $(i_count_c) $(i_maxloc0_c) \
     $(i_maxloc1_c) $(i_maxval_c) $(i_minloc0_c) $(i_minloc1_c) $(i_minval_c) \
@@ -793,6 +799,10 @@ generated/_abs_r4.F90 \
 generated/_abs_r8.F90 \
 generated/_abs_r10.F90 \
 generated/_abs_r16.F90 \
+generated/_aimag_c4.F90 \
+generated/_aimag_c8.F90 \
+generated/_aimag_c10.F90 \
+generated/_aimag_c16.F90 \
 generated/_exp_r4.F90 \
 generated/_exp_r8.F90 \
 generated/_exp_r10.F90 \
@@ -825,14 +835,26 @@ generated/_asin_r4.F90 \
 generated/_asin_r8.F90 \
 generated/_asin_r10.F90 \
 generated/_asin_r16.F90 \
+generated/_asinh_r4.F90 \
+generated/_asinh_r8.F90 \
+generated/_asinh_r10.F90 \
+generated/_asinh_r16.F90 \
 generated/_acos_r4.F90 \
 generated/_acos_r8.F90 \
 generated/_acos_r10.F90 \
 generated/_acos_r16.F90 \
+generated/_acosh_r4.F90 \
+generated/_acosh_r8.F90 \
+generated/_acosh_r10.F90 \
+generated/_acosh_r16.F90 \
 generated/_atan_r4.F90 \
 generated/_atan_r8.F90 \
 generated/_atan_r10.F90 \
 generated/_atan_r16.F90 \
+generated/_atanh_r4.F90 \
+generated/_atanh_r8.F90 \
+generated/_atanh_r10.F90 \
+generated/_atanh_r16.F90 \
 generated/_sin_r4.F90 \
 generated/_sin_r8.F90 \
 generated/_sin_r10.F90 \
@@ -905,14 +927,16 @@ generated/_mod_r8.F90 \
 generated/_mod_r10.F90 \
 generated/_mod_r16.F90
 
+gfor_misc_specifics = generated/misc_specifics.F90
 gfor_specific_src = \
 $(gfor_built_specific_src) \
 $(gfor_built_specific2_src) \
+$(gfor_misc_specifics) \
 intrinsics/dprod_r8.f90 \
 intrinsics/f2c_specifics.F90
 
 BUILT_SOURCES = $(gfor_built_src) $(gfor_built_specific_src) \
-    $(gfor_built_specific2_src)
+    $(gfor_built_specific2_src) $(gfor_misc_specifics)
 
 libgfortran_la_SOURCES = $(gfor_src) $(gfor_built_src) $(gfor_io_src) \
     $(gfor_helper_src) $(gfor_io_headers) $(gfor_specific_src)
@@ -1083,6 +1107,18 @@ _abs_r10.lo: generated/_abs_r10.F90
 _abs_r16.lo: generated/_abs_r16.F90
 	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _abs_r16.lo `test -f 'generated/_abs_r16.F90' || echo '$(srcdir)/'`generated/_abs_r16.F90
 
+_aimag_c4.lo: generated/_aimag_c4.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _aimag_c4.lo `test -f 'generated/_aimag_c4.F90' || echo '$(srcdir)/'`generated/_aimag_c4.F90
+
+_aimag_c8.lo: generated/_aimag_c8.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _aimag_c8.lo `test -f 'generated/_aimag_c8.F90' || echo '$(srcdir)/'`generated/_aimag_c8.F90
+
+_aimag_c10.lo: generated/_aimag_c10.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _aimag_c10.lo `test -f 'generated/_aimag_c10.F90' || echo '$(srcdir)/'`generated/_aimag_c10.F90
+
+_aimag_c16.lo: generated/_aimag_c16.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _aimag_c16.lo `test -f 'generated/_aimag_c16.F90' || echo '$(srcdir)/'`generated/_aimag_c16.F90
+
 _exp_r4.lo: generated/_exp_r4.F90
 	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _exp_r4.lo `test -f 'generated/_exp_r4.F90' || echo '$(srcdir)/'`generated/_exp_r4.F90
 
@@ -1179,6 +1215,18 @@ _asin_r10.lo: generated/_asin_r10.F90
 _asin_r16.lo: generated/_asin_r16.F90
 	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _asin_r16.lo `test -f 'generated/_asin_r16.F90' || echo '$(srcdir)/'`generated/_asin_r16.F90
 
+_asinh_r4.lo: generated/_asinh_r4.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _asinh_r4.lo `test -f 'generated/_asinh_r4.F90' || echo '$(srcdir)/'`generated/_asinh_r4.F90
+
+_asinh_r8.lo: generated/_asinh_r8.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _asinh_r8.lo `test -f 'generated/_asinh_r8.F90' || echo '$(srcdir)/'`generated/_asinh_r8.F90
+
+_asinh_r10.lo: generated/_asinh_r10.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _asinh_r10.lo `test -f 'generated/_asinh_r10.F90' || echo '$(srcdir)/'`generated/_asinh_r10.F90
+
+_asinh_r16.lo: generated/_asinh_r16.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _asinh_r16.lo `test -f 'generated/_asinh_r16.F90' || echo '$(srcdir)/'`generated/_asinh_r16.F90
+
 _acos_r4.lo: generated/_acos_r4.F90
 	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _acos_r4.lo `test -f 'generated/_acos_r4.F90' || echo '$(srcdir)/'`generated/_acos_r4.F90
 
@@ -1191,6 +1239,18 @@ _acos_r10.lo: generated/_acos_r10.F90
 _acos_r16.lo: generated/_acos_r16.F90
 	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _acos_r16.lo `test -f 'generated/_acos_r16.F90' || echo '$(srcdir)/'`generated/_acos_r16.F90
 
+_acosh_r4.lo: generated/_acosh_r4.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _acosh_r4.lo `test -f 'generated/_acosh_r4.F90' || echo '$(srcdir)/'`generated/_acosh_r4.F90
+
+_acosh_r8.lo: generated/_acosh_r8.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _acosh_r8.lo `test -f 'generated/_acosh_r8.F90' || echo '$(srcdir)/'`generated/_acosh_r8.F90
+
+_acosh_r10.lo: generated/_acosh_r10.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _acosh_r10.lo `test -f 'generated/_acosh_r10.F90' || echo '$(srcdir)/'`generated/_acosh_r10.F90
+
+_acosh_r16.lo: generated/_acosh_r16.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _acosh_r16.lo `test -f 'generated/_acosh_r16.F90' || echo '$(srcdir)/'`generated/_acosh_r16.F90
+
 _atan_r4.lo: generated/_atan_r4.F90
 	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _atan_r4.lo `test -f 'generated/_atan_r4.F90' || echo '$(srcdir)/'`generated/_atan_r4.F90
 
@@ -1203,6 +1263,18 @@ _atan_r10.lo: generated/_atan_r10.F90
 _atan_r16.lo: generated/_atan_r16.F90
 	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _atan_r16.lo `test -f 'generated/_atan_r16.F90' || echo '$(srcdir)/'`generated/_atan_r16.F90
 
+_atanh_r4.lo: generated/_atanh_r4.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _atanh_r4.lo `test -f 'generated/_atanh_r4.F90' || echo '$(srcdir)/'`generated/_atanh_r4.F90
+
+_atanh_r8.lo: generated/_atanh_r8.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _atanh_r8.lo `test -f 'generated/_atanh_r8.F90' || echo '$(srcdir)/'`generated/_atanh_r8.F90
+
+_atanh_r10.lo: generated/_atanh_r10.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _atanh_r10.lo `test -f 'generated/_atanh_r10.F90' || echo '$(srcdir)/'`generated/_atanh_r10.F90
+
+_atanh_r16.lo: generated/_atanh_r16.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _atanh_r16.lo `test -f 'generated/_atanh_r16.F90' || echo '$(srcdir)/'`generated/_atanh_r16.F90
+
 _sin_r4.lo: generated/_sin_r4.F90
 	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _sin_r4.lo `test -f 'generated/_sin_r4.F90' || echo '$(srcdir)/'`generated/_sin_r4.F90
 
@@ -1410,6 +1482,9 @@ _mod_r10.lo: generated/_mod_r10.F90
 _mod_r16.lo: generated/_mod_r16.F90
 	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _mod_r16.lo `test -f 'generated/_mod_r16.F90' || echo '$(srcdir)/'`generated/_mod_r16.F90
 
+misc_specifics.lo: generated/misc_specifics.F90
+	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o misc_specifics.lo `test -f 'generated/misc_specifics.F90' || echo '$(srcdir)/'`generated/misc_specifics.F90
+
 f2c_specifics.lo: intrinsics/f2c_specifics.F90
 	$(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o f2c_specifics.lo `test -f 'intrinsics/f2c_specifics.F90' || echo '$(srcdir)/'`intrinsics/f2c_specifics.F90
 
@@ -2844,6 +2919,9 @@ fpu-target.h: $(srcdir)/$(FPU_HOST_HEADER)
 
 @MAINTAINER_MODE_TRUE@$(gfor_built_specific2_src): m4/specific2.m4 m4/head.m4
 @MAINTAINER_MODE_TRUE@	$(M4) -Dfile=$@ -I$(srcdir)/m4 specific2.m4 > $(srcdir)/$@
+
+@MAINTAINER_MODE_TRUE@$(gfor_misc_specifics): m4/misc_specifics.m4 m4/head.m4
+@MAINTAINER_MODE_TRUE@	m4 -Dfile=$@ -I$(srcdir)/m4 misc_specifics.m4 > $(srcdir)/$@
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/libgfortran/generated/_acosh_r10.F90 b/libgfortran/generated/_acosh_r10.F90
new file mode 100644
index 0000000000000000000000000000000000000000..07bc3327c56d7bbf9d6b47933c7f3313f3803d80
--- /dev/null
+++ b/libgfortran/generated/_acosh_r10.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_REAL_10)
+#ifdef HAVE_ACOSHL
+
+elemental function specific__acosh_r10 (parm)
+   real (kind=10), intent (in) :: parm
+   real (kind=10) :: specific__acosh_r10
+
+   specific__acosh_r10 = acosh (parm)
+end function
+
+#endif
+#endif
diff --git a/libgfortran/generated/_acosh_r16.F90 b/libgfortran/generated/_acosh_r16.F90
new file mode 100644
index 0000000000000000000000000000000000000000..295a366f61cc5a946e69d42f2933a4c46852a46f
--- /dev/null
+++ b/libgfortran/generated/_acosh_r16.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_REAL_16)
+#ifdef HAVE_ACOSHL
+
+elemental function specific__acosh_r16 (parm)
+   real (kind=16), intent (in) :: parm
+   real (kind=16) :: specific__acosh_r16
+
+   specific__acosh_r16 = acosh (parm)
+end function
+
+#endif
+#endif
diff --git a/libgfortran/generated/_acosh_r4.F90 b/libgfortran/generated/_acosh_r4.F90
new file mode 100644
index 0000000000000000000000000000000000000000..717ce409e12de936b3d5362590ec1107bc1cecdb
--- /dev/null
+++ b/libgfortran/generated/_acosh_r4.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_REAL_4)
+#ifdef HAVE_ACOSHF
+
+elemental function specific__acosh_r4 (parm)
+   real (kind=4), intent (in) :: parm
+   real (kind=4) :: specific__acosh_r4
+
+   specific__acosh_r4 = acosh (parm)
+end function
+
+#endif
+#endif
diff --git a/libgfortran/generated/_acosh_r8.F90 b/libgfortran/generated/_acosh_r8.F90
new file mode 100644
index 0000000000000000000000000000000000000000..d03c73ba246cf2b4704feffe91fff709c2460941
--- /dev/null
+++ b/libgfortran/generated/_acosh_r8.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_REAL_8)
+#ifdef HAVE_ACOSH
+
+elemental function specific__acosh_r8 (parm)
+   real (kind=8), intent (in) :: parm
+   real (kind=8) :: specific__acosh_r8
+
+   specific__acosh_r8 = acosh (parm)
+end function
+
+#endif
+#endif
diff --git a/libgfortran/generated/_aimag_c10.F90 b/libgfortran/generated/_aimag_c10.F90
new file mode 100644
index 0000000000000000000000000000000000000000..d6a6f0b863150580e19f5a42f08416c64102c16a
--- /dev/null
+++ b/libgfortran/generated/_aimag_c10.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_COMPLEX_10)
+
+
+elemental function specific__aimag_c10 (parm)
+   complex (kind=10), intent (in) :: parm
+   real (kind=10) :: specific__aimag_c10
+
+   specific__aimag_c10 = aimag (parm)
+end function
+
+
+#endif
diff --git a/libgfortran/generated/_aimag_c16.F90 b/libgfortran/generated/_aimag_c16.F90
new file mode 100644
index 0000000000000000000000000000000000000000..717f820eb6bb8286b7f34ab17165cdd27ac4eac6
--- /dev/null
+++ b/libgfortran/generated/_aimag_c16.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_COMPLEX_16)
+
+
+elemental function specific__aimag_c16 (parm)
+   complex (kind=16), intent (in) :: parm
+   real (kind=16) :: specific__aimag_c16
+
+   specific__aimag_c16 = aimag (parm)
+end function
+
+
+#endif
diff --git a/libgfortran/generated/_aimag_c4.F90 b/libgfortran/generated/_aimag_c4.F90
new file mode 100644
index 0000000000000000000000000000000000000000..241e7b97c151149faf4356d97ad1ec4186f6942e
--- /dev/null
+++ b/libgfortran/generated/_aimag_c4.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_COMPLEX_4)
+
+
+elemental function specific__aimag_c4 (parm)
+   complex (kind=4), intent (in) :: parm
+   real (kind=4) :: specific__aimag_c4
+
+   specific__aimag_c4 = aimag (parm)
+end function
+
+
+#endif
diff --git a/libgfortran/generated/_aimag_c8.F90 b/libgfortran/generated/_aimag_c8.F90
new file mode 100644
index 0000000000000000000000000000000000000000..76ad7e982cac5da5e3cd1549623cab63c7c8a001
--- /dev/null
+++ b/libgfortran/generated/_aimag_c8.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_COMPLEX_8)
+
+
+elemental function specific__aimag_c8 (parm)
+   complex (kind=8), intent (in) :: parm
+   real (kind=8) :: specific__aimag_c8
+
+   specific__aimag_c8 = aimag (parm)
+end function
+
+
+#endif
diff --git a/libgfortran/generated/_asinh_r10.F90 b/libgfortran/generated/_asinh_r10.F90
new file mode 100644
index 0000000000000000000000000000000000000000..c6a791b661cdc2ceaf6e6a40af58ff0872eb57a6
--- /dev/null
+++ b/libgfortran/generated/_asinh_r10.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_REAL_10)
+#ifdef HAVE_ASINHL
+
+elemental function specific__asinh_r10 (parm)
+   real (kind=10), intent (in) :: parm
+   real (kind=10) :: specific__asinh_r10
+
+   specific__asinh_r10 = asinh (parm)
+end function
+
+#endif
+#endif
diff --git a/libgfortran/generated/_asinh_r16.F90 b/libgfortran/generated/_asinh_r16.F90
new file mode 100644
index 0000000000000000000000000000000000000000..3b2a28b8ab321b168cd234853cf0633d4cc3c057
--- /dev/null
+++ b/libgfortran/generated/_asinh_r16.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_REAL_16)
+#ifdef HAVE_ASINHL
+
+elemental function specific__asinh_r16 (parm)
+   real (kind=16), intent (in) :: parm
+   real (kind=16) :: specific__asinh_r16
+
+   specific__asinh_r16 = asinh (parm)
+end function
+
+#endif
+#endif
diff --git a/libgfortran/generated/_asinh_r4.F90 b/libgfortran/generated/_asinh_r4.F90
new file mode 100644
index 0000000000000000000000000000000000000000..de47515bf4642c2e8839468f191c4e25980873eb
--- /dev/null
+++ b/libgfortran/generated/_asinh_r4.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_REAL_4)
+#ifdef HAVE_ASINHF
+
+elemental function specific__asinh_r4 (parm)
+   real (kind=4), intent (in) :: parm
+   real (kind=4) :: specific__asinh_r4
+
+   specific__asinh_r4 = asinh (parm)
+end function
+
+#endif
+#endif
diff --git a/libgfortran/generated/_asinh_r8.F90 b/libgfortran/generated/_asinh_r8.F90
new file mode 100644
index 0000000000000000000000000000000000000000..0a6d0bdda4a5b1cdb1360b7b66ef9110d73a633a
--- /dev/null
+++ b/libgfortran/generated/_asinh_r8.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_REAL_8)
+#ifdef HAVE_ASINH
+
+elemental function specific__asinh_r8 (parm)
+   real (kind=8), intent (in) :: parm
+   real (kind=8) :: specific__asinh_r8
+
+   specific__asinh_r8 = asinh (parm)
+end function
+
+#endif
+#endif
diff --git a/libgfortran/generated/_atanh_r10.F90 b/libgfortran/generated/_atanh_r10.F90
new file mode 100644
index 0000000000000000000000000000000000000000..75cdf993e647e6d765132e2d61c6d81886bf2e9a
--- /dev/null
+++ b/libgfortran/generated/_atanh_r10.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_REAL_10)
+#ifdef HAVE_ATANHL
+
+elemental function specific__atanh_r10 (parm)
+   real (kind=10), intent (in) :: parm
+   real (kind=10) :: specific__atanh_r10
+
+   specific__atanh_r10 = atanh (parm)
+end function
+
+#endif
+#endif
diff --git a/libgfortran/generated/_atanh_r16.F90 b/libgfortran/generated/_atanh_r16.F90
new file mode 100644
index 0000000000000000000000000000000000000000..bc6e71cb311cc62ef115dfc4a74565158fd40ae9
--- /dev/null
+++ b/libgfortran/generated/_atanh_r16.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_REAL_16)
+#ifdef HAVE_ATANHL
+
+elemental function specific__atanh_r16 (parm)
+   real (kind=16), intent (in) :: parm
+   real (kind=16) :: specific__atanh_r16
+
+   specific__atanh_r16 = atanh (parm)
+end function
+
+#endif
+#endif
diff --git a/libgfortran/generated/_atanh_r4.F90 b/libgfortran/generated/_atanh_r4.F90
new file mode 100644
index 0000000000000000000000000000000000000000..edbd4198ef04326f3ab14108bdbcde5f079d36cf
--- /dev/null
+++ b/libgfortran/generated/_atanh_r4.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_REAL_4)
+#ifdef HAVE_ATANHF
+
+elemental function specific__atanh_r4 (parm)
+   real (kind=4), intent (in) :: parm
+   real (kind=4) :: specific__atanh_r4
+
+   specific__atanh_r4 = atanh (parm)
+end function
+
+#endif
+#endif
diff --git a/libgfortran/generated/_atanh_r8.F90 b/libgfortran/generated/_atanh_r8.F90
new file mode 100644
index 0000000000000000000000000000000000000000..05dd808ff4b36666496d60ae750aa8f22fc72e6d
--- /dev/null
+++ b/libgfortran/generated/_atanh_r8.F90
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_REAL_8)
+#ifdef HAVE_ATANH
+
+elemental function specific__atanh_r8 (parm)
+   real (kind=8), intent (in) :: parm
+   real (kind=8) :: specific__atanh_r8
+
+   specific__atanh_r8 = atanh (parm)
+end function
+
+#endif
+#endif
diff --git a/libgfortran/generated/misc_specifics.F90 b/libgfortran/generated/misc_specifics.F90
new file mode 100644
index 0000000000000000000000000000000000000000..a3b103b924a1f038f0ad9121ef04013da8df1ee9
--- /dev/null
+++ b/libgfortran/generated/misc_specifics.F90
@@ -0,0 +1,211 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU libgfortran is free software; you can redistribute it and/or
+!modify it under the terms of the GNU General Public
+!License as published by the Free Software Foundation; either
+!version 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU libgfortran is distributed in the hope that it will be useful,
+!but WITHOUT ANY WARRANTY; without even the implied warranty of
+!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+!GNU General Public License for more details.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+#include "config.h"
+#include "kinds.inc"
+
+
+
+
+#if defined (HAVE_GFC_REAL_4) && defined (HAVE_GFC_INTEGER_4)
+elemental function specific__nint_4_4 (parm)
+   real (kind=4) , intent (in) :: parm
+   integer (kind=4) :: specific__nint_4_4
+   specific__nint_4_4 = nint (parm)
+end function
+#endif
+
+#if defined (HAVE_GFC_REAL_8) && defined (HAVE_GFC_INTEGER_4)
+elemental function specific__nint_4_8 (parm)
+   real (kind=8) , intent (in) :: parm
+   integer (kind=4) :: specific__nint_4_8
+   specific__nint_4_8 = nint (parm)
+end function
+#endif
+
+#if defined (HAVE_GFC_REAL_10) && defined (HAVE_GFC_INTEGER_4)
+elemental function specific__nint_4_10 (parm)
+   real (kind=10) , intent (in) :: parm
+   integer (kind=4) :: specific__nint_4_10
+   specific__nint_4_10 = nint (parm)
+end function
+#endif
+
+#if defined (HAVE_GFC_REAL_16) && defined (HAVE_GFC_INTEGER_4)
+elemental function specific__nint_4_16 (parm)
+   real (kind=16) , intent (in) :: parm
+   integer (kind=4) :: specific__nint_4_16
+   specific__nint_4_16 = nint (parm)
+end function
+#endif
+
+#if defined (HAVE_GFC_REAL_4) && defined (HAVE_GFC_INTEGER_8)
+elemental function specific__nint_8_4 (parm)
+   real (kind=4) , intent (in) :: parm
+   integer (kind=8) :: specific__nint_8_4
+   specific__nint_8_4 = nint (parm)
+end function
+#endif
+
+#if defined (HAVE_GFC_REAL_8) && defined (HAVE_GFC_INTEGER_8)
+elemental function specific__nint_8_8 (parm)
+   real (kind=8) , intent (in) :: parm
+   integer (kind=8) :: specific__nint_8_8
+   specific__nint_8_8 = nint (parm)
+end function
+#endif
+
+#if defined (HAVE_GFC_REAL_10) && defined (HAVE_GFC_INTEGER_8)
+elemental function specific__nint_8_10 (parm)
+   real (kind=10) , intent (in) :: parm
+   integer (kind=8) :: specific__nint_8_10
+   specific__nint_8_10 = nint (parm)
+end function
+#endif
+
+#if defined (HAVE_GFC_REAL_16) && defined (HAVE_GFC_INTEGER_8)
+elemental function specific__nint_8_16 (parm)
+   real (kind=16) , intent (in) :: parm
+   integer (kind=8) :: specific__nint_8_16
+   specific__nint_8_16 = nint (parm)
+end function
+#endif
+
+#if defined (HAVE_GFC_REAL_4) && defined (HAVE_GFC_INTEGER_16)
+elemental function specific__nint_16_4 (parm)
+   real (kind=4) , intent (in) :: parm
+   integer (kind=16) :: specific__nint_16_4
+   specific__nint_16_4 = nint (parm)
+end function
+#endif
+
+#if defined (HAVE_GFC_REAL_8) && defined (HAVE_GFC_INTEGER_16)
+elemental function specific__nint_16_8 (parm)
+   real (kind=8) , intent (in) :: parm
+   integer (kind=16) :: specific__nint_16_8
+   specific__nint_16_8 = nint (parm)
+end function
+#endif
+
+#if defined (HAVE_GFC_REAL_10) && defined (HAVE_GFC_INTEGER_16)
+elemental function specific__nint_16_10 (parm)
+   real (kind=10) , intent (in) :: parm
+   integer (kind=16) :: specific__nint_16_10
+   specific__nint_16_10 = nint (parm)
+end function
+#endif
+
+#if defined (HAVE_GFC_REAL_16) && defined (HAVE_GFC_INTEGER_16)
+elemental function specific__nint_16_16 (parm)
+   real (kind=16) , intent (in) :: parm
+   integer (kind=16) :: specific__nint_16_16
+   specific__nint_16_16 = nint (parm)
+end function
+#endif
+
+
+
+#if defined (HAVE_GFC_INTEGER_4)
+elemental function specific__char_1_i4 (parm)
+   integer (kind=4) , intent (in) :: parm
+   character (kind=1,len=1) :: specific__char_1_i4
+   specific__char_1_i4 = char (parm, kind=1)
+end function
+#endif
+
+#if defined (HAVE_GFC_INTEGER_8)
+elemental function specific__char_1_i8 (parm)
+   integer (kind=8) , intent (in) :: parm
+   character (kind=1,len=1) :: specific__char_1_i8
+   specific__char_1_i8 = char (parm, kind=1)
+end function
+#endif
+
+#if defined (HAVE_GFC_INTEGER_16)
+elemental function specific__char_1_i16 (parm)
+   integer (kind=16) , intent (in) :: parm
+   character (kind=1,len=1) :: specific__char_1_i16
+   specific__char_1_i16 = char (parm, kind=1)
+end function
+#endif
+
+
+
+#if defined (HAVE_GFC_INTEGER_4)
+elemental function specific__len_1_i4 (parm)
+   character (kind=1,len=*) , intent (in) :: parm
+   integer (kind=4) :: specific__len_1_i4
+   specific__len_1_i4 = len (parm)
+end function
+#endif
+
+#if defined (HAVE_GFC_INTEGER_8)
+elemental function specific__len_1_i8 (parm)
+   character (kind=1,len=*) , intent (in) :: parm
+   integer (kind=8) :: specific__len_1_i8
+   specific__len_1_i8 = len (parm)
+end function
+#endif
+
+#if defined (HAVE_GFC_INTEGER_16)
+elemental function specific__len_1_i16 (parm)
+   character (kind=1,len=*) , intent (in) :: parm
+   integer (kind=16) :: specific__len_1_i16
+   specific__len_1_i16 = len (parm)
+end function
+#endif
+
+
+
+#if defined (HAVE_GFC_INTEGER_4)
+elemental function specific__index_1_i4 (parm1, parm2)
+   character (kind=1,len=*) , intent (in) :: parm1, parm2
+   integer (kind=4) :: specific__index_1_i4
+   specific__index_1_i4 = index (parm1, parm2)
+end function
+#endif
+
+#if defined (HAVE_GFC_INTEGER_8)
+elemental function specific__index_1_i8 (parm1, parm2)
+   character (kind=1,len=*) , intent (in) :: parm1, parm2
+   integer (kind=8) :: specific__index_1_i8
+   specific__index_1_i8 = index (parm1, parm2)
+end function
+#endif
+
+#if defined (HAVE_GFC_INTEGER_16)
+elemental function specific__index_1_i16 (parm1, parm2)
+   character (kind=1,len=*) , intent (in) :: parm1, parm2
+   integer (kind=16) :: specific__index_1_i16
+   specific__index_1_i16 = index (parm1, parm2)
+end function
+#endif
+
diff --git a/libgfortran/intrinsics/f2c_specifics.F90 b/libgfortran/intrinsics/f2c_specifics.F90
index 6fdcfe9776c446313a07b933d340c0704f2c070d..c3f906d6348bc997b20f561615dfbde276ef22a1 100644
--- a/libgfortran/intrinsics/f2c_specifics.F90
+++ b/libgfortran/intrinsics/f2c_specifics.F90
@@ -69,6 +69,7 @@ end subroutine
 
 REAL_HEAD(abs)
 REAL_BODY(abs)
+
 ! abs is special in that the result is real
 elemental function f2c_specific__abs_c4 (parm) result (res)
   COMPLEX, intent(in) :: parm
@@ -76,6 +77,21 @@ elemental function f2c_specific__abs_c4 (parm) result (res)
   res = abs(parm)
 end function
 
+
+! aimag is special in that the result is real
+elemental function f2c_specific__aimag_c4 (parm)
+  complex(kind=4), intent(in) :: parm
+  double precision :: f2c_specific__aimag_c4
+  f2c_specific__aimag_c4 = aimag(parm)
+end function
+
+elemental function f2c_specific__aimag_c8 (parm)
+  complex(kind=8), intent(in) :: parm
+  double precision :: f2c_specific__aimag_c8
+  f2c_specific__aimag_c8 = aimag(parm)
+end function
+
+
 REAL_HEAD(exp)
 REAL_BODY(exp)
 COMPLEX_HEAD(exp)
@@ -109,6 +125,15 @@ REAL_BODY(acos)
 REAL_HEAD(atan)
 REAL_BODY(atan)
 
+REAL_HEAD(asinh)
+REAL_BODY(asinh)
+
+REAL_HEAD(acosh)
+REAL_BODY(acosh)
+
+REAL_HEAD(atanh)
+REAL_BODY(atanh)
+
 REAL_HEAD(sin)
 REAL_BODY(sin)
 COMPLEX_HEAD(sin)
diff --git a/libgfortran/m4/misc_specifics.m4 b/libgfortran/m4/misc_specifics.m4
new file mode 100644
index 0000000000000000000000000000000000000000..dff63d82eeac2037f418982781146539e7a261e4
--- /dev/null
+++ b/libgfortran/m4/misc_specifics.m4
@@ -0,0 +1,64 @@
+include(head.m4)dnl
+dnl
+dnl This file contains the specific functions that are not handled in the
+dnl m4/specific.m4 file.
+
+#include "config.h"
+#include "kinds.inc"
+
+dnl This is from GNU m4 examples file foreach.m4:
+divert(-1)
+# foreach(x, (item_1, item_2, ..., item_n), stmt)
+define(`foreach', `pushdef(`$1', `')_foreach(`$1', `$2',
+`$3')popdef(`$1')')
+define(`_arg1', `$1')
+define(`_foreach',
+        `ifelse(`$2', `()', ,
+                `define(`$1', _arg1$2)$3`'_foreach(`$1', (shift$2),
+`$3')')')
+# traceon(`define', `foreach', `_foreach', `ifelse')
+divert
+
+dnl   NINT specifics
+foreach(`ikind', `(4, 8, 16)', `foreach(`rkind', `(4, 8, 10, 16)', `
+`#if defined (HAVE_GFC_REAL_'rkind`) && defined (HAVE_GFC_INTEGER_'ikind`)'
+elemental function specific__nint_`'ikind`_'rkind (parm)
+   real (kind=rkind) , intent (in) :: parm
+   integer (kind=ikind) :: specific__nint_`'ikind`_'rkind
+   specific__nint_`'ikind`_'rkind = nint (parm)
+end function
+#endif
+')')
+
+dnl   CHAR specifics
+foreach(`ckind', `(1)', `foreach(`ikind', `(4, 8, 16)', `
+`#if defined (HAVE_GFC_INTEGER_'ikind`)'
+elemental function specific__char_`'ckind`_i'ikind (parm)
+   integer (kind=ikind) , intent (in) :: parm
+   character (kind=ckind,len=1) :: specific__char_`'ckind`_i'ikind
+   specific__char_`'ckind`_i'ikind` = char (parm, kind='ckind`)'
+end function
+#endif
+')')
+
+dnl   LEN specifics
+foreach(`ckind', `(1)', `foreach(`ikind', `(4, 8, 16)', `
+`#if defined (HAVE_GFC_INTEGER_'ikind`)'
+elemental function specific__len_`'ckind`_i'ikind (parm)
+   character (kind=ckind,len=*) , intent (in) :: parm
+   integer (kind=ikind) :: specific__len_`'ckind`_i'ikind
+   specific__len_`'ckind`_i'ikind` = len (parm)'
+end function
+#endif
+')')
+
+dnl   INDEX specifics
+foreach(`ckind', `(1)', `foreach(`ikind', `(4, 8, 16)', `
+`#if defined (HAVE_GFC_INTEGER_'ikind`)'
+elemental function specific__index_`'ckind`_i'ikind (parm1, parm2)
+   character (kind=ckind,len=*) , intent (in) :: parm1, parm2
+   integer (kind=ikind) :: specific__index_`'ckind`_i'ikind
+   specific__index_`'ckind`_i'ikind` = index (parm1, parm2)'
+end function
+#endif
+')')
diff --git a/libgfortran/m4/specific.m4 b/libgfortran/m4/specific.m4
index a0d03dcba9c455306fda133ce3551755628f6ff3..c8c91520d604d61de46684aa3e757bcb0e8d03c9 100644
--- a/libgfortran/m4/specific.m4
+++ b/libgfortran/m4/specific.m4
@@ -6,7 +6,7 @@ define(get_typename2, `$1 (kind=$2)')dnl
 define(get_typename, `get_typename2(ifelse($1,i,integer,ifelse($1,r,real,ifelse($1,l,logical,ifelse($1,c,complex,unknown)))),`$2')')dnl
 define(atype_name, get_typename(atype_letter,atype_kind))dnl
 define(name, regexp(regexp(file, `[^/]*$', `\&'), `^_\([^_]*\)_', `\1'))dnl
-define(rtype_name,get_typename(ifelse(name,abs,ifelse(atype_letter,c,r,atype_letter),atype_letter),atype_kind))dnl
+define(rtype_name,get_typename(ifelse(name,abs,ifelse(atype_letter,c,r,atype_letter),ifelse(name,aimag,ifelse(atype_letter,c,r,atype_letter),atype_letter)),atype_kind))dnl
 define(function_name,ifelse(name,conjg,`specific__conjg_'atype_kind,`specific__'name`_'atype_code))dnl
 
 define(type,ifelse(atype_letter,l,LOGICAL,ifelse(atype_letter,i,INTEGER,ifelse(atype_letter,r,REAL,ifelse(atype_letter,c,COMPLEX,UNKNOW)))))dnl
@@ -17,8 +17,8 @@ dnl nothing. The list is currently:
 dnl    - integer and logical specifics require no libm function
 dnl    - AINT requires the trunc() family functions
 dnl    - ANINT requires round()
-dnl    - CONJG, DIM, SIGN require no libm function
-define(needed,ifelse(atype_letter,i,`none',ifelse(atype_letter,l,`none',ifelse(name,aint,trunc,ifelse(name,anint,round,ifelse(name,conjg,none,ifelse(name,dim,none,ifelse(name,sign,none,ifelse(name,abs,fabs,name)))))))))dnl
+dnl    - AIMAG, CONJG, DIM, SIGN require no libm function
+define(needed,ifelse(atype_letter,i,`none',ifelse(atype_letter,l,`none',ifelse(name,aint,trunc,ifelse(name,anint,round,ifelse(name,aimag,none,ifelse(name,conjg,none,ifelse(name,dim,none,ifelse(name,sign,none,ifelse(name,abs,fabs,name))))))))))dnl
 define(prefix,ifelse(atype_letter,c,C,`'))dnl
 
 dnl Special case for fabs, for which the corresponding complex function