re PR libfortran/91593 (Implicit enum conversions in libgfortran/io/transfer.c)
[platform/upstream/gcc.git] / libgfortran / intrinsics / date_and_time.c
index 5d8973e..d536404 100644 (file)
@@ -1,6 +1,5 @@
 /* Implementation of the DATE_AND_TIME intrinsic.
-   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012
-   Free Software Foundation, Inc.
+   Copyright (C) 2003-2019 Free Software Foundation, Inc.
    Contributed by Steven Bosscher.
 
 This file is part of the GNU Fortran runtime library (libgfortran).
@@ -27,7 +26,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #include "libgfortran.h"
 #include <string.h>
 #include <assert.h>
-#include <stdlib.h>
 
 #include "time_1.h"
 
@@ -269,13 +267,14 @@ secnds (GFC_REAL_4 *x)
   GFC_INTEGER_4 values[VALUES_SIZE];
   GFC_REAL_4 temp1, temp2;
 
-  /* Make the INTEGER*4 array for passing to date_and_time.  */
-  gfc_array_i4 *avalues = xmalloc (sizeof (gfc_array_i4));
+  /* Make the INTEGER*4 array for passing to date_and_time, with enough space
+   for a rank-one array.  */
+  gfc_array_i4 *avalues = xmalloc (sizeof (gfc_array_i4)
+                                  + sizeof (descriptor_dimension));
   avalues->base_addr = &values[0];
-  GFC_DESCRIPTOR_DTYPE (avalues) = ((BT_REAL << GFC_DTYPE_TYPE_SHIFT)
-                                       & GFC_DTYPE_TYPE_MASK) +
-                                   (4 << GFC_DTYPE_SIZE_SHIFT);
-
+  GFC_DESCRIPTOR_DTYPE (avalues).type = BT_REAL;
+  GFC_DESCRIPTOR_DTYPE (avalues).elem_len = 4;
+  GFC_DESCRIPTOR_DTYPE (avalues).rank = 1;
   GFC_DIMENSION_SET(avalues->dim[0], 0, 7, 1);
 
   date_and_time (NULL, NULL, NULL, avalues, 0, 0, 0);
@@ -457,11 +456,11 @@ idate_i8 (gfc_array_i8 *__values)
       1. Seconds after the minute, range 0-59 or 0-61 to allow for leap seconds
       2. Minutes after the hour, range 0-59
       3. Hours past midnight, range 0-23
-      4. Day of month, range 0-31
+      4. Day of month, range 1-31
       5. Number of months since January, range 0-11
       6. Years since 1900
       7. Number of days since Sunday, range 0-6
-      8. Days since January 1
+      8. Days since January 1, range 0-365
       9. Daylight savings indicator: positive if daylight savings is in effect,
          zero if not, and negative if the information isn't available.  */
 
@@ -549,11 +548,11 @@ gmtime_i8 (GFC_INTEGER_8 * t, gfc_array_i8 * tarray)
       1. Seconds after the minute, range 0-59 or 0-61 to allow for leap seconds
       2. Minutes after the hour, range 0-59
       3. Hours past midnight, range 0-23
-      4. Day of month, range 0-31
+      4. Day of month, range 1-31
       5. Number of months since January, range 0-11
       6. Years since 1900
       7. Number of days since Sunday, range 0-6
-      8. Days since January 1
+      8. Days since January 1, range 0-365
       9. Daylight savings indicator: positive if daylight savings is in effect,
          zero if not, and negative if the information isn't available.  */