diff options
author | Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2014-06-15 16:58:53 +0000 |
---|---|---|
committer | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2014-06-15 16:58:53 +0000 |
commit | a416c4c766df05b1e85dcee2fe7857e9a6e87b88 (patch) | |
tree | d08324947894c4c45c1d88bc91e42afa45a1acd2 /gcc/fortran/check.c | |
parent | 6faf47517f3a989140af3d054c75718bfcc20581 (diff) | |
download | gcc-a416c4c766df05b1e85dcee2fe7857e9a6e87b88.zip gcc-a416c4c766df05b1e85dcee2fe7857e9a6e87b88.tar.gz gcc-a416c4c766df05b1e85dcee2fe7857e9a6e87b88.tar.bz2 |
re PR fortran/28484 ([F03] system_clock with real-type count_rate does not compile)
PR fortran/28484
PR fortran/61429
* check.c (gfc_check_system_clock): Improve checking of arguments.
* intrinsic.texi: Update doc of SYSTEM_CLOCK.
* iresolve.c (gfc_resolve_system_clock): Choose library function
used depending on argument kinds.
* trans-decl.c (gfc_build_intrinsic_function_decls): Build
decls for system_clock_4 and system_clock_8.
* trans-intrinsic.c (conv_intrinsic_system_clock): New function.
(gfc_conv_intrinsic_subroutine): Call conv_intrinsic_system_clock.
* trans.h (gfor_fndecl_system_clock4, gfor_fndecl_system_clock8):
New variables.
* gfortran.dg/system_clock_1.f90: New file.
* gfortran.dg/system_clock_2.f90: New file.
From-SVN: r211686
Diffstat (limited to 'gcc/fortran/check.c')
-rw-r--r-- | gcc/fortran/check.c | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 20af75f..caf3b6c 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -5206,8 +5206,10 @@ gfc_check_second_sub (gfc_expr *time) } -/* The arguments of SYSTEM_CLOCK are scalar, integer variables. Note, - count, count_rate, and count_max are all optional arguments */ +/* COUNT and COUNT_MAX of SYSTEM_CLOCK are scalar, default-kind integer + variables in Fortran 95. In Fortran 2003 and later, they can be of any + kind, and COUNT_RATE can be of type real. Note, count, count_rate, and + count_max are all optional arguments */ bool gfc_check_system_clock (gfc_expr *count, gfc_expr *count_rate, @@ -5221,6 +5223,12 @@ gfc_check_system_clock (gfc_expr *count, gfc_expr *count_rate, if (!type_check (count, 0, BT_INTEGER)) return false; + if (count->ts.kind != gfc_default_integer_kind + && !gfc_notify_std (GFC_STD_F2003, "COUNT argument to " + "SYSTEM_CLOCK at %L has non-default kind", + &count->where)) + return false; + if (!variable_check (count, 0, false)) return false; } @@ -5230,15 +5238,26 @@ gfc_check_system_clock (gfc_expr *count, gfc_expr *count_rate, if (!scalar_check (count_rate, 1)) return false; - if (!type_check (count_rate, 1, BT_INTEGER)) - return false; - if (!variable_check (count_rate, 1, false)) return false; - if (count != NULL - && !same_type_check (count, 0, count_rate, 1)) - return false; + if (count_rate->ts.type == BT_REAL) + { + if (!gfc_notify_std (GFC_STD_F2003, "Real COUNT_RATE argument to " + "SYSTEM_CLOCK at %L", &count_rate->where)) + return false; + } + else + { + if (!type_check (count_rate, 1, BT_INTEGER)) + return false; + + if (count_rate->ts.kind != gfc_default_integer_kind + && !gfc_notify_std (GFC_STD_F2003, "COUNT_RATE argument to " + "SYSTEM_CLOCK at %L has non-default kind", + &count_rate->where)) + return false; + } } @@ -5250,15 +5269,13 @@ gfc_check_system_clock (gfc_expr *count, gfc_expr *count_rate, if (!type_check (count_max, 2, BT_INTEGER)) return false; - if (!variable_check (count_max, 2, false)) - return false; - - if (count != NULL - && !same_type_check (count, 0, count_max, 2)) + if (count_max->ts.kind != gfc_default_integer_kind + && !gfc_notify_std (GFC_STD_F2003, "COUNT_MAX argument to " + "SYSTEM_CLOCK at %L has non-default kind", + &count_max->where)) return false; - if (count_rate != NULL - && !same_type_check (count_rate, 1, count_max, 2)) + if (!variable_check (count_max, 2, false)) return false; } |