[Bug fortran/56850] Diagnostic of REAL*8 is odd: Accepted with -std=f95, -pedantic prints warning only with -std=gnu

2019-02-05 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56850

Jerry DeLisle  changed:

   What|Removed |Added

 CC||jvdelisle at gcc dot gnu.org

--- Comment #4 from Jerry DeLisle  ---
The reason it is called twice is because of the way the matchers work. Attempts
are made to match a particular feature or pattern. In each situation if an
error is found it is buffered in a list so that if a following matching attempt
is successful, the previous error condition can be dropped. My guess is when
-Werror is used, the first pass through the matchers returns a solid error and
even though the second is also an error one is treated as the first one and
acted on to emit the message. The case of the Syntax error is because the
matcher returned to the top of the hunt with no good match so, must be 'Syntax'
vs the other path giving the warning.

I also have been hitting the debugger on this. ne of the paths is via
gfc_match_data_decl and the other through gfc_match_prefix.

I have gotten as far as confirming, I think, that the code:

  const bool warning = (wstd != 0) && !inhibit_warnings;
  const bool error = (estd != 0);

is correct.

I am still digging on this so stand by for next round depending on how much
time I can find.

[Bug fortran/56850] Diagnostic of REAL*8 is odd: Accepted with -std=f95, -pedantic prints warning only with -std=gnu

2019-02-05 Thread dominiq at lps dot ens.fr
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  

[Bug fortran/56850] Diagnostic of REAL*8 is odd: Accepted with -std=f95, -pedantic prints warning only with -std=gnu

2013-04-05 Thread burnus at gcc dot gnu.org


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



Tobias Burnus burnus at gcc dot gnu.org changed:



   What|Removed |Added



 CC||burnus at gcc dot gnu.org



--- Comment #1 from Tobias Burnus burnus at gcc dot gnu.org 2013-04-05 
20:30:13 UTC ---

On a related note: As

http://www.open-mpi.org/community/lists/users/2013/04/21684.php shows, the

following error is misleading:



 real*16, intent(in) :: x

 1

 Error: Old-style type declaration  REAL*16 not supported at (1)



The problem is not the old-style type declaration but that kind=16 is not

supported. We should improve the error message.



[Bug fortran/56850] Diagnostic of REAL*8 is odd: Accepted with -std=f95, -pedantic prints warning only with -std=gnu

2013-04-05 Thread dominiq at lps dot ens.fr


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



Dominique d'Humieres dominiq at lps dot ens.fr changed:



   What|Removed |Added



 Status|UNCONFIRMED |NEW

   Last reconfirmed||2013-04-05

 Ever Confirmed|0   |1



--- Comment #2 from Dominique d'Humieres dominiq at lps dot ens.fr 2013-04-05 
20:31:56 UTC ---

Confirmed.