https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56850

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Using GCC 4.1 with -std=f95 (but not GCC >=4.3) shows:
>   real*8
>        1
>  Error: Nonstandard type declaration REAL*8 at (1)

While /opt/gcc/gcc4.3.1/bin/gfortran pr56850_red.f90 -std=f95 does not give any
error.

I have looked at the mailing list, but did not find anything related to this
change (finite time indeed).

However I am wondering if the change was not made to allow to compile codes
using TYPE*KIND with -std=f9*: this PR is a feature not a bug.

I have used two tests to investigate the gfortran behavior:

(1) cat gnu_ext_red.f90

print *, kind(min(1_2,2_4))
end

% gfc gnu_ext_red.f90 -pedantic
gnu_ext_red.f90:1:22:

    1 | print *, kind(min(1_2,2_4))
      |                      1
Warning: GNU Extension: Different type kinds at (1)
% gfc gnu_ext_red.f90 -std=f95
gnu_ext_red.f90:1:22:

    1 | print *, kind(min(1_2,2_4))
      |                      1
Error: GNU Extension: Different type kinds at (1)

which is the behavior I expect from my understanding of gfc_notify_std:

-pedantic with -std=gnu (default) or -std=legacy leads to a warning,
while it gives an error with -std=f*.

(2) cat pr56850_red.f90

  real*8 r
  end

% gfc pr56850_red.f90 -pedantic
pr56850_red.f90:1:8:

    1 |   real*8 r
      |        1
Warning: GNU Extension: Nonstandard type declaration REAL*8 at (1)
% gfc pr56850_red.f90 -std=f95
%

The debug session for (1) is

(lldb) run gnu_ext_red.f90 -std=f95
Process 71989 launched:
'/opt/gcc/gcc9p-268475p2/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.1/f951'
(x86_64)
Process 71989 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 3.1
    frame #0: 0x00000001000366c0 f951`gfc_notify_std(std=32, gmsgid="Different
type kinds at %L") at error.c:890
   887    char *buffer;
   888  
   889    /* Determine whether an error or a warning is needed.  */
-> 890    const int wstd = std & gfc_option.warn_std;    /* Standard to warn
about.  */
   891    const int estd = std & ~gfc_option.allow_std;  /* Standard to error
about.  */
   892    const bool warning = (wstd != 0) && !inhibit_warnings;
   893    const bool error = (estd != 0);
Target 0: (f951) stopped.
(lldb) c
Process 71989 resuming
gnu_ext_red.f90:1:22:

    1 | print *, kind(min(1_2,2_4))
      |                      1
Error: GNU Extension: Different type kinds at (1)
Process 71989 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 4.1
    frame #0: 0x0000000100036877 f951`gfc_notify_std(std=<unavailable>,
gmsgid=<unavailable>) at error.c:919
   916    va_end (argp);
   917  
   918    if (error)
-> 919      return false;
   920    else
   921      return (warning && !warnings_are_errors);
   922  }
Target 0: (f951) stopped.
(lldb) c
...

The error is emitted between entering gfc_notify_std and line 918.

For (2) I get

(lldb) run pr56850_red.f90 -std=f95
Process 45611 launched:
'/opt/gcc/gcc9p-268475p2/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.1/f951'
(x86_64)
Process 45611 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x00000001000366c0 f951`gfc_notify_std(std=32,
gmsgid="Nonstandard type declaration %s*%d at %C") at error.c:890
   887    char *buffer;
   888  
   889    /* Determine whether an error or a warning is needed.  */
-> 890    const int wstd = std & gfc_option.warn_std;    /* Standard to warn
about.  */
   891    const int estd = std & ~gfc_option.allow_std;  /* Standard to error
about.  */
   892    const bool warning = (wstd != 0) && !inhibit_warnings;
   893    const bool error = (estd != 0);
Target 0: (f951) stopped.
(lldb) c
Process 45611 resuming
Process 45611 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 3.1
    frame #0: 0x0000000100036877 f951`gfc_notify_std(std=<unavailable>,
gmsgid=<unavailable>) at error.c:919
   916    va_end (argp);
   917  
   918    if (error)
-> 919      return false;
   920    else
   921      return (warning && !warnings_are_errors);
   922  }
Target 0: (f951) stopped.
(lldb) c
Process 45611 resuming
Process 45611 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x00000001000366c0 f951`gfc_notify_std(std=32,
gmsgid="Nonstandard type declaration %s*%d at %C") at error.c:890
   887    char *buffer;
   888  
   889    /* Determine whether an error or a warning is needed.  */
-> 890    const int wstd = std & gfc_option.warn_std;    /* Standard to warn
about.  */
   891    const int estd = std & ~gfc_option.allow_std;  /* Standard to error
about.  */
   892    const bool warning = (wstd != 0) && !inhibit_warnings;
   893    const bool error = (estd != 0);
Target 0: (f951) stopped.
(lldb) c
Process 45611 resuming
Process 45611 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 3.1
    frame #0: 0x0000000100036877 f951`gfc_notify_std(std=<unavailable>,
gmsgid=<unavailable>) at error.c:919
   916    va_end (argp);
   917  
   918    if (error)
-> 919      return false;
   920    else
   921      return (warning && !warnings_are_errors);
   922  }
Target 0: (f951) stopped.
(lldb) c
...

gfc_notify_std is called twice and no error is emitted. I don't see why and
where the error was suppressed.

Reply via email to