summaryrefslogtreecommitdiff
path: root/libgfortran/io
diff options
context:
space:
mode:
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-19 01:28:50 +0000
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-19 01:28:50 +0000
commit79dda023e156a636f6aca7f72c92dfd987504559 (patch)
tree57b515208fe72f75dd40e6e639f1fde700dcf61a /libgfortran/io
parent590de186001cbe4c43db6dd6185d264a0eaacb24 (diff)
downloadgcc-79dda023e156a636f6aca7f72c92dfd987504559.tar.gz
2010-10-18 Jerry DeLisle <jvdelisle@gcc.gnu.org>
* io/io.h: Remove definition of the BT enumerator. * libgfortran.h: Replace GFC_DTYPE enumerator with BT. * intrinsics/iso_c_generated_procs.c: Likewise * intrinsics/date_and_time.c: Likewise. * intrinsics/iso_c_binding.c: Likewise. * io/list_read.c: Likewise. * io/transfer.c: Likewise. * io/write.c: Likewise. 2010-10-18 Jerry DeLisle <jvdelisle@gcc.gnu.org> * gfortran.h: Remove definition of bt enumerator. * libgfortran.h: Add bt enumerator type alighned with defintion. Remove the dtype enumerator, no longer used. previously given in libgfortran/io.h * trans-types.c: Use new bt enumerator. * trans-io.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165675 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io')
-rw-r--r--libgfortran/io/io.h12
-rw-r--r--libgfortran/io/list_read.c51
-rw-r--r--libgfortran/io/transfer.c37
-rw-r--r--libgfortran/io/write.c22
4 files changed, 40 insertions, 82 deletions
diff --git a/libgfortran/io/io.h b/libgfortran/io/io.h
index 99553486f8b..5089b6f7877 100644
--- a/libgfortran/io/io.h
+++ b/libgfortran/io/io.h
@@ -34,14 +34,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <setjmp.h>
#include <gthr.h>
-/* Basic types used in data transfers. */
-
-typedef enum
-{ BT_NULL, BT_INTEGER, BT_LOGICAL, BT_CHARACTER, BT_REAL,
- BT_COMPLEX
-}
-bt;
-
/* Forward declarations. */
struct st_parameter_dt;
typedef struct stream stream;
@@ -114,8 +106,8 @@ format_hash_entry;
typedef struct namelist_type
{
- /* Object type, stored as GFC_DTYPE_xxxx. */
- dtype type;
+ /* Object type. */
+ bt type;
/* Object name. */
char * var_name;
diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index b3c1cf6a89d..113b469bfce 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -1668,7 +1668,7 @@ check_type (st_parameter_dt *dtp, bt type, int len)
{
char message[100];
- if (dtp->u.p.saved_type != BT_NULL && dtp->u.p.saved_type != type)
+ if (dtp->u.p.saved_type != BT_UNKNOWN && dtp->u.p.saved_type != type)
{
sprintf (message, "Read type %s where %s was expected for item %d",
type_name (dtp->u.p.saved_type), type_name (type),
@@ -1678,7 +1678,7 @@ check_type (st_parameter_dt *dtp, bt type, int len)
return 1;
}
- if (dtp->u.p.saved_type == BT_NULL || dtp->u.p.saved_type == BT_CHARACTER)
+ if (dtp->u.p.saved_type == BT_UNKNOWN || dtp->u.p.saved_type == BT_CHARACTER)
return 0;
if (dtp->u.p.saved_length != len)
@@ -1771,7 +1771,7 @@ list_formatted_read_scalar (st_parameter_dt *dtp, volatile bt type, void *p,
finish_separator (dtp);
}
- dtp->u.p.saved_type = BT_NULL;
+ dtp->u.p.saved_type = BT_UNKNOWN;
dtp->u.p.repeat_count = 1;
}
@@ -1802,7 +1802,7 @@ list_formatted_read_scalar (st_parameter_dt *dtp, volatile bt type, void *p,
internal_error (&dtp->common, "Bad type for list read");
}
- if (dtp->u.p.saved_type != BT_CHARACTER && dtp->u.p.saved_type != BT_NULL)
+ if (dtp->u.p.saved_type != BT_CHARACTER && dtp->u.p.saved_type != BT_UNKNOWN)
dtp->u.p.saved_length = size;
if ((dtp->common.flags & IOPARM_LIBRETURN_MASK) != IOPARM_LIBRETURN_OK)
@@ -1853,8 +1853,11 @@ list_formatted_read_scalar (st_parameter_dt *dtp, volatile bt type, void *p,
}
break;
- case BT_NULL:
+ case BT_UNKNOWN:
break;
+
+ default:
+ internal_error (&dtp->common, "Bad type for list read");
}
if (--dtp->u.p.repeat_count <= 0)
@@ -2362,20 +2365,20 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset,
len = nl->len;
switch (nl->type)
{
- case GFC_DTYPE_INTEGER:
- case GFC_DTYPE_LOGICAL:
+ case BT_INTEGER:
+ case BT_LOGICAL:
dlen = len;
break;
- case GFC_DTYPE_REAL:
+ case BT_REAL:
dlen = size_from_real_kind (len);
break;
- case GFC_DTYPE_COMPLEX:
+ case BT_COMPLEX:
dlen = size_from_complex_kind (len);
break;
- case GFC_DTYPE_CHARACTER:
+ case BT_CHARACTER:
dlen = chigh ? (chigh - clow + 1) : nl->string_length;
break;
@@ -2407,40 +2410,37 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset,
if (dtp->u.p.input_complete)
return SUCCESS;
- /* BT_NULL (equivalent to GFC_DTYPE_UNKNOWN) falls through
- for nulls and is detected at default: of switch block. */
-
- dtp->u.p.saved_type = BT_NULL;
+ dtp->u.p.saved_type = BT_UNKNOWN;
free_saved (dtp);
switch (nl->type)
{
- case GFC_DTYPE_INTEGER:
+ case BT_INTEGER:
read_integer (dtp, len);
break;
- case GFC_DTYPE_LOGICAL:
+ case BT_LOGICAL:
read_logical (dtp, len);
break;
- case GFC_DTYPE_CHARACTER:
+ case BT_CHARACTER:
read_character (dtp, len);
break;
- case GFC_DTYPE_REAL:
+ case BT_REAL:
/* Need to copy data back from the real location to the temp in order
to handle nml reads into arrays. */
read_real (dtp, pdata, len);
memcpy (dtp->u.p.value, pdata, dlen);
break;
- case GFC_DTYPE_COMPLEX:
+ case BT_COMPLEX:
/* Same as for REAL, copy back to temp. */
read_complex (dtp, pdata, len, dlen);
memcpy (dtp->u.p.value, pdata, dlen);
break;
- case GFC_DTYPE_DERIVED:
+ case BT_DERIVED:
obj_name_len = strlen (nl->var_name) + 1;
obj_name = get_mem (obj_name_len+1);
memcpy (obj_name, nl->var_name, obj_name_len-1);
@@ -2500,15 +2500,12 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset,
return SUCCESS;
}
- if (dtp->u.p.saved_type == BT_NULL)
+ if (dtp->u.p.saved_type == BT_UNKNOWN)
{
dtp->u.p.expanded_read = 0;
goto incr_idx;
}
- /* Note the switch from GFC_DTYPE_type to BT_type at this point.
- This comes about because the read functions return BT_types. */
-
switch (dtp->u.p.saved_type)
{
@@ -2750,7 +2747,7 @@ get_name:
if (c == '%')
{
- if (nl->type != GFC_DTYPE_DERIVED)
+ if (nl->type != BT_DERIVED)
{
snprintf (nml_err_msg, nml_err_msg_size,
"Attempt to get derived component for %s", nl->var_name);
@@ -2774,7 +2771,7 @@ get_name:
clow = 1;
chigh = 0;
- if (c == '(' && nl->type == GFC_DTYPE_CHARACTER)
+ if (c == '(' && nl->type == BT_CHARACTER)
{
descriptor_dimension chd[1] = { {1, clow, nl->string_length} };
array_loop_spec ind[1] = { {1, clow, nl->string_length, 1} };
@@ -2852,7 +2849,7 @@ get_name:
namelist_info if we have parsed a qualified derived type
component. */
- if (nl->type == GFC_DTYPE_DERIVED)
+ if (nl->type == BT_DERIVED)
nml_touch_nodes (nl);
if (first_nl)
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 41d5a42f04c..e327eea8f80 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -1977,7 +1977,7 @@ transfer_array (st_parameter_dt *dtp, gfc_array_char *desc, int kind,
index_type count[GFC_MAX_DIMENSIONS];
index_type extent[GFC_MAX_DIMENSIONS];
index_type stride[GFC_MAX_DIMENSIONS];
- index_type stride0, rank, size, type, n;
+ index_type stride0, rank, size, n;
size_t tsize;
char *data;
bt iotype;
@@ -1985,39 +1985,8 @@ transfer_array (st_parameter_dt *dtp, gfc_array_char *desc, int kind,
if ((dtp->common.flags & IOPARM_LIBRETURN_MASK) != IOPARM_LIBRETURN_OK)
return;
- type = GFC_DESCRIPTOR_TYPE (desc);
- size = GFC_DESCRIPTOR_SIZE (desc);
-
- /* FIXME: What a kludge: Array descriptors and the IO library use
- different enums for types. */
- switch (type)
- {
- case GFC_DTYPE_UNKNOWN:
- iotype = BT_NULL; /* Is this correct? */
- break;
- case GFC_DTYPE_INTEGER:
- iotype = BT_INTEGER;
- break;
- case GFC_DTYPE_LOGICAL:
- iotype = BT_LOGICAL;
- break;
- case GFC_DTYPE_REAL:
- iotype = BT_REAL;
- break;
- case GFC_DTYPE_COMPLEX:
- iotype = BT_COMPLEX;
- break;
- case GFC_DTYPE_CHARACTER:
- iotype = BT_CHARACTER;
- size = charlen;
- break;
- case GFC_DTYPE_DERIVED:
- internal_error (&dtp->common,
- "Derived type I/O should have been handled via the frontend.");
- break;
- default:
- internal_error (&dtp->common, "transfer_array(): Bad type");
- }
+ iotype = (bt) GFC_DESCRIPTOR_TYPE (desc);
+ size = iotype == BT_CHARACTER ? charlen : GFC_DESCRIPTOR_SIZE (desc);
rank = GFC_DESCRIPTOR_RANK (desc);
for (n = 0; n < rank; n++)
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index fabbaffc9e9..0a6aee1588e 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -1705,7 +1705,7 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset,
/* Write namelist variable names in upper case. If a derived type,
nothing is output. If a component, base and base_name are set. */
- if (obj->type != GFC_DTYPE_DERIVED)
+ if (obj->type != BT_DERIVED)
{
namelist_write_newline (dtp);
write_character (dtp, " ", 1, 1);
@@ -1739,15 +1739,15 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset,
switch (obj->type)
{
- case GFC_DTYPE_REAL:
+ case BT_REAL:
obj_size = size_from_real_kind (len);
break;
- case GFC_DTYPE_COMPLEX:
+ case BT_COMPLEX:
obj_size = size_from_complex_kind (len);
break;
- case GFC_DTYPE_CHARACTER:
+ case BT_CHARACTER:
obj_size = obj->string_length;
break;
@@ -1783,7 +1783,7 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset,
/* Check for repeat counts of intrinsic types. */
if ((elem_ctr < (nelem - 1)) &&
- (obj->type != GFC_DTYPE_DERIVED) &&
+ (obj->type != BT_DERIVED) &&
!memcmp (p, (void*)(p + obj_size ), obj_size ))
{
rep_ctr++;
@@ -1808,15 +1808,15 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset,
switch (obj->type)
{
- case GFC_DTYPE_INTEGER:
+ case BT_INTEGER:
write_integer (dtp, p, len);
break;
- case GFC_DTYPE_LOGICAL:
+ case BT_LOGICAL:
write_logical (dtp, p, len);
break;
- case GFC_DTYPE_CHARACTER:
+ case BT_CHARACTER:
tmp_delim = dtp->u.p.current_unit->delim_status;
if (dtp->u.p.nml_delim == '"')
dtp->u.p.current_unit->delim_status = DELIM_QUOTE;
@@ -1826,17 +1826,17 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset,
dtp->u.p.current_unit->delim_status = tmp_delim;
break;
- case GFC_DTYPE_REAL:
+ case BT_REAL:
write_real (dtp, p, len);
break;
- case GFC_DTYPE_COMPLEX:
+ case BT_COMPLEX:
dtp->u.p.no_leading_blank = 0;
num++;
write_complex (dtp, p, len, obj_size);
break;
- case GFC_DTYPE_DERIVED:
+ case BT_DERIVED:
/* To treat a derived type, we need to build two strings:
ext_name = the name, including qualifiers that prepends