https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56850
--- Comment #3 from Dominique d'Humieres ---
> 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: 0x0001000366c0 f951`gfc_notify_std(std=32, gmsgid="Different
type kinds at %L") at error.c:890
887char *buffer;
888
889/* Determine whether an error or a warning is needed. */
-> 890const int wstd = std & gfc_option.warn_std;/* Standard to warn
about. */
891const int estd = std & ~gfc_option.allow_std; /* Standard to error
about. */
892const bool warning = (wstd != 0) && !inhibit_warnings;
893const 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: 0x000100036877 f951`gfc_notify_std(std=,
gmsgid=) at error.c:919
916va_end (argp);
917
918if (error)
-> 919 return false;
920else
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: 0x0001000366c0 f951`gfc_notify_std(std=32,
gmsgid="Nonstandard type declaration %s*%d at %C") at error.c:890
887char *buffer;
888
889/* Determine whether an error or a warning is needed. */
-> 890const int wstd = std & gfc_option.warn_std;/* Standard to warn
about. */
891const int estd = std & ~gfc_option.allow_std; /* Standard to error
about. */
892const bool warning = (wstd != 0) && !inhibit_warnings;
893const 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: 0x000100036877 f951`gfc_notify_std(std=,
gmsgid=) at error.c:919
916va_end (argp);
917
918if (error)
-> 919 return false;
920else
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: 0x0001000366c0 f951`gfc_notify_std(std=32,
gmsgid="Nonstandard type declaration %s*%d at %C") at error.c:890
887char *buffer;
888
889/* Determine whether an error or a warning is needed. */
-> 890const int wstd = std & gfc_option.warn_std;/* Standard to warn
about. */
891const int estd = std & ~gfc_option.allow_std; /* Standard to error
about. */
892const bool warning = (wstd != 0) && !inhibit_warnings;
893const 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: 0x000100036877 f951`gfc_notify_std(std=,
gmsgid=) at error.c:919
916va_end (argp);
917
918if (error)
-> 919