OSDN Git Service

* arith.c: Add system.h; remove string.h
[pf3gnuchains/gcc-fork.git] / gcc / fortran / check.c
index 32de055..815ee2f 100644 (file)
@@ -26,10 +26,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    has been sorted into the right order and has NULL arguments in the
    correct places for missing optional arguments.  */
 
-
-#include <stdlib.h>
-#include <stdarg.h>
-
 #include "config.h"
 #include "system.h"
 #include "flags.h"
@@ -136,7 +132,7 @@ double_check (gfc_expr * d, int n)
   if (type_check (d, n, BT_REAL) == FAILURE)
     return FAILURE;
 
-  if (d->ts.kind != gfc_default_double_kind ())
+  if (d->ts.kind != gfc_default_double_kind)
     {
       must_be (d, n, "double precision");
       return FAILURE;
@@ -525,6 +521,28 @@ gfc_check_atan2 (gfc_expr * y, gfc_expr * x)
 }
 
   
+/* BESJN and BESYN functions.  */
+
+try
+gfc_check_besn (gfc_expr * n, gfc_expr * x)
+{
+
+  if (scalar_check (n, 0) == FAILURE)
+    return FAILURE;
+
+  if (type_check (n, 0, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  if (scalar_check (x, 1) == FAILURE)
+    return FAILURE;
+
+  if (type_check (x, 1, BT_REAL) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}
+
+
 try
 gfc_check_btest (gfc_expr * i, gfc_expr * pos)
 {
@@ -728,6 +746,36 @@ gfc_check_eoshift (gfc_expr * array, gfc_expr * shift, gfc_expr * boundary,
 }
 
 
+try
+gfc_check_fnum (gfc_expr * unit)
+{
+
+  if (type_check (unit, 0, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  if (scalar_check (unit, 0) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}
+
+
+/* This is used for the g77 one-argument Bessel functions, and the
+   error function.  */
+
+try
+gfc_check_g77_math1 (gfc_expr * x)
+{
+
+  if (scalar_check (x, 0) == FAILURE)
+    return FAILURE;
+
+  if (type_check (x, 0, BT_REAL) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}
+
 
 try
 gfc_check_huge (gfc_expr * x)
@@ -757,13 +805,19 @@ try
 gfc_check_iand (gfc_expr * i, gfc_expr * j)
 {
 
-  if (type_check (i, 0, BT_INTEGER) == FAILURE
-      || type_check (j, 1, BT_INTEGER) == FAILURE)
+  if (type_check (i, 0, BT_INTEGER) == FAILURE)
     return FAILURE;
 
-  if (same_type_check (i, 0, j, 1) == FAILURE)
+  if (type_check (j, 1, BT_INTEGER) == FAILURE)
     return FAILURE;
 
+  if (i->ts.kind != j->ts.kind)
+    {
+      if (gfc_notify_std (GFC_STD_GNU, "Extension: Different type kinds at %L",
+                          &i->where) == FAILURE)
+       return FAILURE;
+    }
+
   return SUCCESS;
 }
 
@@ -772,9 +826,10 @@ try
 gfc_check_ibclr (gfc_expr * i, gfc_expr * pos)
 {
 
-  if (type_check (i, 0, BT_INTEGER) == FAILURE
-      || type_check (pos, 1, BT_INTEGER) == FAILURE
-      || kind_value_check (pos, 1, gfc_default_integer_kind ()) == FAILURE)
+  if (type_check (i, 0, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  if (type_check (pos, 1, BT_INTEGER) == FAILURE)
     return FAILURE;
 
   return SUCCESS;
@@ -785,10 +840,13 @@ try
 gfc_check_ibits (gfc_expr * i, gfc_expr * pos, gfc_expr * len)
 {
 
-  if (type_check (i, 0, BT_INTEGER) == FAILURE
-      || type_check (pos, 1, BT_INTEGER) == FAILURE
-      || kind_value_check (pos, 1, gfc_default_integer_kind ()) == FAILURE
-      || type_check (len, 2, BT_INTEGER) == FAILURE)
+  if (type_check (i, 0, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  if (type_check (pos, 1, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  if (type_check (len, 2, BT_INTEGER) == FAILURE)
     return FAILURE;
 
   return SUCCESS;
@@ -799,9 +857,10 @@ try
 gfc_check_ibset (gfc_expr * i, gfc_expr * pos)
 {
 
-  if (type_check (i, 0, BT_INTEGER) == FAILURE
-      || type_check (pos, 1, BT_INTEGER) == FAILURE
-      || kind_value_check (pos, 1, gfc_default_integer_kind ()) == FAILURE)
+  if (type_check (i, 0, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  if (type_check (pos, 1, BT_INTEGER) == FAILURE)
     return FAILURE;
 
   return SUCCESS;
@@ -823,13 +882,19 @@ try
 gfc_check_ieor (gfc_expr * i, gfc_expr * j)
 {
 
-  if (type_check (i, 0, BT_INTEGER) == FAILURE
-      || type_check (j, 1, BT_INTEGER) == FAILURE)
+  if (type_check (i, 0, BT_INTEGER) == FAILURE)
     return FAILURE;
 
-  if (same_type_check (i, 0, j, 1) == FAILURE)
+  if (type_check (j, 1, BT_INTEGER) == FAILURE)
     return FAILURE;
 
+  if (i->ts.kind != j->ts.kind)
+    {
+      if (gfc_notify_std (GFC_STD_GNU, "Extension: Different type kinds at %L",
+                          &i->where) == FAILURE)
+       return FAILURE;
+    }
+
   return SUCCESS;
 }
 
@@ -872,12 +937,18 @@ try
 gfc_check_ior (gfc_expr * i, gfc_expr * j)
 {
 
-  if (type_check (i, 0, BT_INTEGER) == FAILURE
-      || type_check (j, 1, BT_INTEGER) == FAILURE)
+  if (type_check (i, 0, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  if (type_check (j, 1, BT_INTEGER) == FAILURE)
     return FAILURE;
 
-  if (same_type_check (i, 0, j, 1) == FAILURE)
+  if (i->ts.kind != j->ts.kind)
+    {
+      if (gfc_notify_std (GFC_STD_GNU, "Extension: Different type kinds at %L",
+                          &i->where) == FAILURE)
     return FAILURE;
+    }
 
   return SUCCESS;
 }
@@ -1036,7 +1107,7 @@ try
 gfc_check_min_max_integer (gfc_actual_arglist * arg)
 {
 
-  return check_rest (BT_INTEGER, gfc_default_integer_kind (), arg);
+  return check_rest (BT_INTEGER, gfc_default_integer_kind, arg);
 }
 
 
@@ -1044,7 +1115,7 @@ try
 gfc_check_min_max_real (gfc_actual_arglist * arg)
 {
 
-  return check_rest (BT_REAL, gfc_default_real_kind (), arg);
+  return check_rest (BT_REAL, gfc_default_real_kind, arg);
 }
 
 
@@ -1052,7 +1123,7 @@ try
 gfc_check_min_max_double (gfc_actual_arglist * arg)
 {
 
-  return check_rest (BT_REAL, gfc_default_double_kind (), arg);
+  return check_rest (BT_REAL, gfc_default_double_kind, arg);
 }
 
 /* End of min/max family.  */
@@ -1545,7 +1616,7 @@ gfc_check_size (gfc_expr * array, gfc_expr * dim)
       if (type_check (dim, 1, BT_INTEGER) == FAILURE)
        return FAILURE;
 
-      if (kind_value_check (dim, 1, gfc_default_integer_kind ()) == FAILURE)
+      if (kind_value_check (dim, 1, gfc_default_integer_kind) == FAILURE)
        return FAILURE;
 
       if (dim_rank_check (dim, array, 0) == FAILURE)
@@ -1585,6 +1656,7 @@ gfc_check_spread (gfc_expr * source, gfc_expr * dim, gfc_expr * ncopies)
 
   if (type_check (ncopies, 2, BT_INTEGER) == FAILURE)
     return FAILURE;
+
   if (scalar_check (ncopies, 2) == FAILURE)
     return FAILURE;
 
@@ -1593,6 +1665,104 @@ gfc_check_spread (gfc_expr * source, gfc_expr * dim, gfc_expr * ncopies)
 
 
 try
+gfc_check_fstat (gfc_expr * unit, gfc_expr * array)
+{
+
+  if (type_check (unit, 0, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  if (scalar_check (unit, 0) == FAILURE)
+    return FAILURE;
+
+  if (type_check (array, 1, BT_INTEGER) == FAILURE
+      || kind_value_check (unit, 0, gfc_default_integer_kind) == FAILURE)
+    return FAILURE;
+
+  if (array_check (array, 1) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}
+
+
+try
+gfc_check_fstat_sub (gfc_expr * unit, gfc_expr * array, gfc_expr * status)
+{
+
+  if (type_check (unit, 0, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  if (scalar_check (unit, 0) == FAILURE)
+    return FAILURE;
+
+  if (type_check (array, 1, BT_INTEGER) == FAILURE
+      || kind_value_check (array, 1, gfc_default_integer_kind) == FAILURE)
+    return FAILURE;
+
+  if (array_check (array, 1) == FAILURE)
+    return FAILURE;
+
+  if (status == NULL)
+    return SUCCESS;
+
+  if (type_check (status, 2, BT_INTEGER) == FAILURE
+      || kind_value_check (status, 2, gfc_default_integer_kind) == FAILURE)
+    return FAILURE;
+
+  if (scalar_check (status, 2) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}
+
+
+try
+gfc_check_stat (gfc_expr * name, gfc_expr * array)
+{
+
+  if (type_check (name, 0, BT_CHARACTER) == FAILURE)
+    return FAILURE;
+
+  if (type_check (array, 1, BT_INTEGER) == FAILURE
+      || kind_value_check (array, 1, gfc_default_integer_kind) == FAILURE)
+    return FAILURE;
+
+  if (array_check (array, 1) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}
+
+
+try
+gfc_check_stat_sub (gfc_expr * name, gfc_expr * array, gfc_expr * status)
+{
+
+  if (type_check (name, 0, BT_CHARACTER) == FAILURE)
+    return FAILURE;
+
+  if (type_check (array, 1, BT_INTEGER) == FAILURE
+      || kind_value_check (array, 1, gfc_default_integer_kind) == FAILURE)
+    return FAILURE;
+
+  if (array_check (array, 1) == FAILURE)
+    return FAILURE;
+
+  if (status == NULL)
+    return SUCCESS;
+
+  if (type_check (status, 2, BT_INTEGER) == FAILURE
+      || kind_value_check (array, 1, gfc_default_integer_kind) == FAILURE)
+    return FAILURE;
+
+  if (scalar_check (status, 2) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}
+
+
+try
 gfc_check_transfer (gfc_expr * source ATTRIBUTE_UNUSED,
                    gfc_expr * mold ATTRIBUTE_UNUSED,
                    gfc_expr * size)
@@ -1834,7 +2004,7 @@ gfc_check_random_seed (gfc_expr * size, gfc_expr * put, gfc_expr * get)
       if (variable_check (size, 0) == FAILURE)
        return FAILURE;
 
-      if (kind_value_check (size, 0, gfc_default_integer_kind ()) == FAILURE)
+      if (kind_value_check (size, 0, gfc_default_integer_kind) == FAILURE)
        return FAILURE;
     }
 
@@ -1854,7 +2024,7 @@ gfc_check_random_seed (gfc_expr * size, gfc_expr * put, gfc_expr * get)
       if (type_check (put, 1, BT_INTEGER) == FAILURE)
        return FAILURE;
 
-      if (kind_value_check (put, 1, gfc_default_integer_kind ()) == FAILURE)
+      if (kind_value_check (put, 1, gfc_default_integer_kind) == FAILURE)
        return FAILURE;
     }
 
@@ -1877,7 +2047,7 @@ gfc_check_random_seed (gfc_expr * size, gfc_expr * put, gfc_expr * get)
       if (variable_check (get, 2) == FAILURE)
        return FAILURE;
 
-      if (kind_value_check (get, 2, gfc_default_integer_kind ()) == FAILURE)
+      if (kind_value_check (get, 2, gfc_default_integer_kind) == FAILURE)
        return FAILURE;
     }
 
@@ -1963,6 +2133,9 @@ gfc_check_system_clock (gfc_expr * count, gfc_expr * count_rate,
 try
 gfc_check_irand (gfc_expr * x)
 {
+  if (x == NULL)
+    return SUCCESS;
+
   if (scalar_check (x, 0) == FAILURE)
     return FAILURE;
 
@@ -1978,6 +2151,9 @@ gfc_check_irand (gfc_expr * x)
 try
 gfc_check_rand (gfc_expr * x)
 {
+  if (x == NULL)
+    return SUCCESS;
+
   if (scalar_check (x, 0) == FAILURE)
     return FAILURE;
 
@@ -2055,3 +2231,144 @@ gfc_check_etime_sub (gfc_expr * values, gfc_expr * time)
 
   return SUCCESS;
 }
+
+
+try
+gfc_check_getcwd_sub (gfc_expr * cwd, gfc_expr * status)
+{
+
+  if (type_check (cwd, 0, BT_CHARACTER) == FAILURE)
+    return FAILURE;
+
+  if (status == NULL)
+    return SUCCESS;
+
+  if (scalar_check (status, 1) == FAILURE)
+    return FAILURE;
+
+  if (type_check (status, 1, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}
+
+
+try
+gfc_check_exit (gfc_expr * status)
+{
+  
+  if (status == NULL)
+  return SUCCESS;
+
+  if (type_check (status, 0, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  if (scalar_check (status, 0) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}
+
+
+try
+gfc_check_flush (gfc_expr * unit)
+{
+  
+  if (unit == NULL)
+    return SUCCESS;
+
+  if (type_check (unit, 0, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  if (scalar_check (unit, 0) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}
+
+
+try
+gfc_check_umask (gfc_expr * mask)
+{
+
+  if (type_check (mask, 0, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  if (scalar_check (mask, 0) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}
+
+
+try
+gfc_check_umask_sub (gfc_expr * mask, gfc_expr * old)
+{
+
+  if (type_check (mask, 0, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  if (scalar_check (mask, 0) == FAILURE)
+    return FAILURE;
+
+  if (old == NULL)
+    return SUCCESS;
+
+  if (scalar_check (old, 1) == FAILURE)
+    return FAILURE;
+
+  if (type_check (old, 1, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}
+
+
+try
+gfc_check_unlink (gfc_expr * name)
+{
+
+  if (type_check (name, 0, BT_CHARACTER) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}
+
+
+try
+gfc_check_unlink_sub (gfc_expr * name, gfc_expr * status)
+{
+
+  if (type_check (name, 0, BT_CHARACTER) == FAILURE)
+    return FAILURE;
+
+  if (status == NULL)
+    return SUCCESS;
+
+  if (scalar_check (status, 1) == FAILURE)
+    return FAILURE;
+
+  if (type_check (status, 1, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}
+
+
+try
+gfc_check_system_sub (gfc_expr * cmd, gfc_expr * status)
+{
+  if (type_check (cmd, 0, BT_CHARACTER) == FAILURE)
+    return FAILURE;
+
+  if (scalar_check (status, 1) == FAILURE)
+    return FAILURE;
+
+  if (type_check (status, 1, BT_INTEGER) == FAILURE)
+    return FAILURE;
+
+  if (kind_value_check (status, 1, gfc_default_integer_kind) == FAILURE)
+    return FAILURE;
+
+  return SUCCESS;
+}