gfc_check_system_clock (gfc_expr *count, gfc_expr *count_rate,
gfc_expr *count_max)
{
+ int first_int_kind = -1;
+
if (count != NULL)
{
if (!scalar_check (count, 0))
&count->where))
return false;
+ if (count->ts.kind < gfc_default_integer_kind
+ && !gfc_notify_std (GFC_STD_F2023_DEL,
+ "COUNT argument to SYSTEM_CLOCK at %L "
+ "with kind smaller than default integer",
+ &count->where))
+ return false;
+
if (!variable_check (count, 0, false))
return false;
+
+ first_int_kind = count->ts.kind;
}
if (count_rate != NULL)
"SYSTEM_CLOCK at %L has non-default kind",
&count_rate->where))
return false;
+
+ if (count_rate->ts.kind < gfc_default_integer_kind
+ && !gfc_notify_std (GFC_STD_F2023_DEL,
+ "COUNT_RATE argument to SYSTEM_CLOCK at %L "
+ "with kind smaller than default integer",
+ &count_rate->where))
+ return false;
+
+ if (first_int_kind < 0)
+ first_int_kind = count_rate->ts.kind;
}
}
if (!variable_check (count_max, 2, false))
return false;
+
+ if (count_max->ts.kind < gfc_default_integer_kind
+ && !gfc_notify_std (GFC_STD_F2023_DEL,
+ "COUNT_MAX argument to SYSTEM_CLOCK at %L "
+ "with kind smaller than default integer",
+ &count_max->where))
+ return false;
+
+ if (first_int_kind < 0)
+ first_int_kind = count_max->ts.kind;
+ }
+
+ if (first_int_kind > 0)
+ {
+ if (count_rate
+ && count_rate->ts.type == BT_INTEGER
+ && count_rate->ts.kind != first_int_kind
+ && !gfc_notify_std (GFC_STD_F2023_DEL,
+ "integer arguments to SYSTEM_CLOCK at %L "
+ "with different kind parameters",
+ &count_rate->where))
+ return false;
+
+ if (count_max && count_max->ts.kind != first_int_kind
+ && !gfc_notify_std (GFC_STD_F2023_DEL,
+ "integer arguments to SYSTEM_CLOCK at %L "
+ "with different kind parameters",
+ &count_max->where))
+ return false;
}
return true;
notify_std_msg(int std)
{
- if (std & GFC_STD_F2018_DEL)
+ if (std & GFC_STD_F2023_DEL)
+ return _("Prohibited in Fortran 2023:");
+ else if (std & GFC_STD_F2023)
+ return _("Fortran 2023:");
+ else if (std & GFC_STD_F2018_DEL)
return _("Fortran 2018 deleted feature:");
else if (std & GFC_STD_F2018_OBS)
return _("Fortran 2018 obsolescent feature:");
@code{GFC_STD_F95_OBS} (2), @code{GFC_STD_F95_DEL} (4),
@code{GFC_STD_F95} (8), @code{GFC_STD_F2003} (16), @code{GFC_STD_GNU}
(32), @code{GFC_STD_LEGACY} (64), @code{GFC_STD_F2008} (128),
-@code{GFC_STD_F2008_OBS} (256), @code{GFC_STD_F2008_TS} (512),
-@code{GFC_STD_F2018} (1024), @code{GFC_STD_F2018_OBS} (2048),
-@code{GFC_STD=F2018_DEL} (4096), and @code{GFC_STD=F2023} (8192).
+@code{GFC_STD_F2008_OBS} (256), @code{GFC_STD_F2018} (512),
+@code{GFC_STD_F2018_OBS} (1024), @code{GFC_STD_F2018_DEL} (2048),
+@code{GFC_STD_F2023} (4096), and @code{GFC_STD_F2023_DEL} (8192).
Default: @code{GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_F95 |
-GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F2008_TS | GFC_STD_F2008_OBS
+GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F2008_OBS
| GFC_STD_F77 | GFC_STD_F2018 | GFC_STD_F2018_OBS | GFC_STD_F2018_DEL
-| GFC_STD_F2023 | GFC_STD_GNU | GFC_STD_LEGACY}.
+| GFC_STD_F2023 | GFC_STD_F2023_DEL | GFC_STD_GNU | GFC_STD_LEGACY}.
@item @var{option}[1] @tab Standard-warning flag; prints a warning to
standard error. Default: @code{GFC_STD_F95_DEL | GFC_STD_LEGACY}.
@item @var{option}[2] @tab If non zero, enable pedantic checking.
/* Flags to specify which standard/extension contains a feature.
Note that no features were obsoleted nor deleted in F2003 nor in F2023.
+ Nevertheless, some features available in F2018 are prohibited in F2023.
Please remember to keep those definitions in sync with
gfortran.texi. */
+#define GFC_STD_F2023_DEL (1<<13) /* Prohibited in F2023. */
#define GFC_STD_F2023 (1<<12) /* New in F2023. */
#define GFC_STD_F2018_DEL (1<<11) /* Deleted in F2018. */
#define GFC_STD_F2018_OBS (1<<10) /* Obsolescent in F2018. */
* are allowed with a certain -std option. */
#define GFC_STD_OPT_F95 (GFC_STD_F77 | GFC_STD_F95 | GFC_STD_F95_OBS \
| GFC_STD_F2008_OBS | GFC_STD_F2018_OBS \
- | GFC_STD_F2018_DEL)
+ | GFC_STD_F2018_DEL | GFC_STD_F2023_DEL)
#define GFC_STD_OPT_F03 (GFC_STD_OPT_F95 | GFC_STD_F2003)
#define GFC_STD_OPT_F08 (GFC_STD_OPT_F03 | GFC_STD_F2008)
#define GFC_STD_OPT_F18 ((GFC_STD_OPT_F08 | GFC_STD_F2018) \
& (~GFC_STD_F2018_DEL))
-#define GFC_STD_OPT_F23 (GFC_STD_OPT_F18 | GFC_STD_F2023)
+#define GFC_STD_OPT_F23 ((GFC_STD_OPT_F18 | GFC_STD_F2023) \
+ & (~GFC_STD_F2023_DEL))
/* Bitmasks for the various FPE that can be enabled. These need to be straight integers
e.g., 8 instead of (1<<3), because they will be included in Fortran source. */
gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
| GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
| GFC_STD_F2008_OBS | GFC_STD_GNU | GFC_STD_LEGACY
- | GFC_STD_F2018 | GFC_STD_F2018_DEL | GFC_STD_F2018_OBS | GFC_STD_F2023;
- gfc_option.warn_std = GFC_STD_F2018_DEL | GFC_STD_F95_DEL | GFC_STD_LEGACY;
+ | GFC_STD_F2018 | GFC_STD_F2018_DEL | GFC_STD_F2018_OBS | GFC_STD_F2023
+ | GFC_STD_F2023_DEL;
+ gfc_option.warn_std = GFC_STD_F2018_DEL | GFC_STD_F95_DEL | GFC_STD_LEGACY
+ | GFC_STD_F2023_DEL;
}
/* Set (or unset) the DEC extension flags. */
! { dg-do run }
+! { dg-options "-std=f2003" }
integer :: i, j, k
integer(kind=8) :: i8, j8, k8
! { dg-do run }
+! { dg-options "-std=f2008" }
! PR64432
program countem
implicit none
--- /dev/null
+! { dg-do compile }
+! { dg-options "-std=f2023" }
+! PR fortran/112609 - F2023 restrictions on integer arguments to SYSTEM_CLOCK
+
+program p
+ implicit none
+ integer :: i, j, k
+ integer(2) :: i2, j2, k2
+ integer(8) :: i8, j8, k8
+ real :: x
+
+ call system_clock(count=i2) ! { dg-error "kind smaller than default integer" }
+ call system_clock(count_rate=j2) ! { dg-error "kind smaller than default integer" }
+ call system_clock(count_max=k2) ! { dg-error "kind smaller than default integer" }
+
+ call system_clock(count=i8,count_rate=x,count_max=k8)
+ call system_clock(count=i, count_rate=j8) ! { dg-error "different kind" }
+ call system_clock(count=i8,count_rate=j) ! { dg-error "different kind" }
+ call system_clock(count=i, count_max=k8) ! { dg-error "different kind" }
+ call system_clock(count=i8,count_max=k) ! { dg-error "different kind" }
+ call system_clock(count_rate=j, count_max=k8) ! { dg-error "different kind" }
+ call system_clock(count_rate=j8,count_max=k) ! { dg-error "different kind" }
+ call system_clock(i,x,k8) ! { dg-error "different kind" }
+end