]> git.ipfire.org Git - people/ms/gcc.git/commitdiff
PR 81552 Improve and document -flag-init-integer
authorJanne Blomqvist <jb@gcc.gnu.org>
Thu, 14 Feb 2019 21:33:29 +0000 (23:33 +0200)
committerJanne Blomqvist <jb@gcc.gnu.org>
Thu, 14 Feb 2019 21:33:29 +0000 (23:33 +0200)
Make the option handling code parse the -flag-init-integer value as a
C long type, allowing a larger range on systems where long is a larger
type than int.  Document the behavior.

Regtested on x86_64-pc-linux-gnu, committed as obvious.

2019-02-14  Janne Blomqvist  <jb@gcc.gnu.org>

        PR fortran/81552
        * gfortran.h (gfc_option_t): Make flag_init_integer_value a long.
        * options.c (gfc_handle_option): Use strtol instead of atoi.
        * invoke.texi: Document -finit-integer behavior in more detail

From-SVN: r268906

gcc/fortran/ChangeLog
gcc/fortran/gfortran.h
gcc/fortran/invoke.texi
gcc/fortran/options.c

index bcf885e729ddec7ed9831fe4978b2ee607dcba49..3a8c00d4a3b27fd8e43b347940d21516cf3426ea 100644 (file)
@@ -1,3 +1,10 @@
+2019-02-14  Janne Blomqvist  <jb@gcc.gnu.org>
+
+       PR fortran/81552
+       * gfortran.h (gfc_option_t): Make flag_init_integer_value a long.
+       * options.c (gfc_handle_option): Use strtol instead of atoi.
+       * invoke.texi: Document -finit-integer behavior in more detail.
+
 2019-02-14  Harald Anlauf  <anlauf@gmx.de>
 
        PR fortran/88248
index 0a0fef81d9fb7ee0820e88108e2541e042405ede..526897c417059295851bc5f2620341b143134b22 100644 (file)
@@ -2681,7 +2681,7 @@ typedef struct
   int flag_preprocessed;
   int flag_d_lines;
   int flag_init_integer;
-  int flag_init_integer_value;
+  long flag_init_integer_value;
   int flag_init_logical;
   int flag_init_character;
   char flag_init_character_value;
index 0e0c2bcb20da1c2a5ec3b575e5f1cf1915a3c5ae..a5d81960a611a0cbd51211fbcfee61f0bf6a103b 100644 (file)
@@ -1779,6 +1779,11 @@ use @option{-finit-real=snan}; note, however, that compile-time
 optimizations may convert them into quiet NaN and that trapping
 needs to be enabled (e.g. via @option{-ffpe-trap}).
 
+The @option{-finit-integer} option will parse the value into an
+integer of type @code{INTEGER(kind=C_LONG)} on the host.  Said value
+is then assigned to the integer variables in the Fortran code, which
+might result in wraparound if the value is too large for the kind.
+
 Finally, note that enabling any of the @option{-finit-*} options will
 silence warnings that would have been emitted by @option{-Wuninitialized}
 for the affected local variables.
index 4e55adec6fe3845253050be3400f3418fa236767..f2a0151670e950597803aef3c5083c2b360c4521 100644 (file)
@@ -708,7 +708,7 @@ gfc_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
 
     case OPT_finit_integer_:
       gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
-      gfc_option.flag_init_integer_value = atoi (arg);
+      gfc_option.flag_init_integer_value = strtol (arg, NULL, 10);
       break;
 
     case OPT_finit_character_: