[Bug fortran/51991] Wrong error message with variables named "SAVE*"

2019-06-24 Thread sgk at troutmask dot apl.washington.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #19 from Steve Kargl  ---
On Mon, Jun 24, 2019 at 08:11:07AM +, bardeau at iram dot fr wrote:
> bardeau ~> cat test.f90 
> subroutine sav
>   integer :: save1
>   save1 =
> sqrt(1+2+3+4+5+6+cos(0.123)**2-asin(3*exp(12)-8*dble(sin(8)+7.56/atan2(5,6)))
> end subroutine sav
> bardeau ~> gfortran -c test.f90 
> test.f90:3:6:
> 
> 3 |   save1 =
> sqrt(1+2+3+4+5+(6.1+cos(0.123)**2)-asin(3*exp(12)-8*dble(sin(8)+7.56/atan2(5,6)))
>   |  1
> Error: Syntax error in SAVE statement at (1)
> bardeau ~>
> 

I wasn't addressing you.  I fixed your problem!
gfortran no longer generates a bogus error about
the SAVE statment.

The above code as written now generates

% gfcx -c a.f90
a.f90:3:10:

3 |save1 =
  |  1
Error: Invalid character in name at (1)

because you do not have an ampersand for continuation.

If you now add the ampersand you get,

% gfcx -c a.f90
a.f90:4:80:

4 |   
sqrt(1+2+3+4+5+6+cos(0.123)**2-asin(3*exp(12)-8*dble(sin(8)+7.56/atan2(5,6)))
  |
   1
Error: Syntax error in argument list at (1)

So, now you recognize that you wrote a long line of code and
cannot count ')' correctly, so you add the terminating ')'.  You
now get this error message.

% gfcx -c a.f90
a.f90:4:74:

4 |   
sqrt(1+2+3+4+5+6+cos(0.123)**2-asin(3*exp(12)-8*dble(sin(8)+7.56/atan2(5,6
  |
 1
Error: 'y' argument of 'atan2' intrinsic at (1) must be REAL

You now can fix your error with atan2.

I was addressing Dominique d'Humieres for wasting my time with
his comment #15, which has absolutely nothing to do with a 
bogus error message about SAVE, and the patch that I committed
to suppress the bogus error.

[Bug fortran/51991] Wrong error message with variables named "SAVE*"

2019-06-24 Thread bardeau at iram dot fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #18 from Sebastien Bardeau  ---
(In reply to kargl from comment #17)

> I just realized that your code isn't even close to conforming.
> 
> subroutine sav
>   integer :: save1
>   save1 = something wrong
> end subroutine sav
> 
> What part of "something wrong" is a valid RHS expression

This is exactly the point: when RHS is invalid, the error message do not or did
not point this precise diagnostic, at least at the time I first reported the
problem.

> Please don't waste my time with silly code.

What do you think the user experience is with this kind of diagnostic?

bardeau ~> cat test.f90 
subroutine sav
  integer :: save1
  save1 =
sqrt(1+2+3+4+5+6+cos(0.123)**2-asin(3*exp(12)-8*dble(sin(8)+7.56/atan2(5,6)))
end subroutine sav
bardeau ~> gfortran -c test.f90 
test.f90:3:6:

3 |   save1 =
sqrt(1+2+3+4+5+(6.1+cos(0.123)**2)-asin(3*exp(12)-8*dble(sin(8)+7.56/atan2(5,6)))
  |  1
Error: Syntax error in SAVE statement at (1)
bardeau ~>

(Tested with gfortran 9.1.0, not tested with your patch).

[Bug fortran/51991] Wrong error message with variables named "SAVE*"

2019-06-21 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #17 from kargl at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #15)
> Compiling the test in comment 10 gives now
> 
> pr51991_2.f90:3:7:
> 
> 3 |   save1 = something wrong
>   |   1
> Error: Invalid character in name at (1)
> pr51991_2.f90:8:6:
> 
> 8 |   data1 = something wrong
>   |  1
> Error: Syntax error in DATA statement at (1)
> 
> The first error before revision r272556 was
> 
> pr51991_2.f90:3:6:
> 
> 3 |   save1 = something wrong
>   |  1
> Error: Syntax error in SAVE statement at (1)
> 
> It seems there is a similar problem with DATA (and may be others) and the
> location of (1) is not set to the right place.

I just realized that your code isn't even close to conforming.

subroutine sav
  integer :: save1
  save1 = something wrong
end subroutine sav

What part of "something wrong" is a valid RHS expression

Please don't waste my time with silly code.

For the record, this compiles just fine

subroutine sav
  integer :: save1
  save1 = 1
end subroutine sav

[Bug fortran/51991] Wrong error message with variables named "SAVE*"

2019-06-21 Thread sgk at troutmask dot apl.washington.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #16 from Steve Kargl  ---
On Fri, Jun 21, 2019 at 06:03:42PM +, dominiq at lps dot ens.fr wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991
> 
> --- Comment #15 from Dominique d'Humieres  ---
> Compiling the test in comment 10 gives now
> 
> pr51991_2.f90:3:7:
> 
> 3 |   save1 = something wrong
>   |   1
> Error: Invalid character in name at (1)

Not my problem.  Regression tested clean.

[Bug fortran/51991] Wrong error message with variables named "SAVE*"

2019-06-21 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #15 from Dominique d'Humieres  ---
Compiling the test in comment 10 gives now

pr51991_2.f90:3:7:

3 |   save1 = something wrong
  |   1
Error: Invalid character in name at (1)
pr51991_2.f90:8:6:

8 |   data1 = something wrong
  |  1
Error: Syntax error in DATA statement at (1)

The first error before revision r272556 was

pr51991_2.f90:3:6:

3 |   save1 = something wrong
  |  1
Error: Syntax error in SAVE statement at (1)

It seems there is a similar problem with DATA (and may be others) and the
location of (1) is not set to the right place.

[Bug fortran/51991] Wrong error message with variables named "SAVE*"

2019-06-21 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

kargl at gcc dot gnu.org changed:

   What|Removed |Added

   Priority|P3  |P4
 Status|NEW |RESOLVED
 CC||kargl at gcc dot gnu.org
 Resolution|--- |FIXED
   Assignee|unassigned at gcc dot gnu.org  |kargl at gcc dot gnu.org
   Target Milestone|--- |10.0

--- Comment #14 from kargl at gcc dot gnu.org ---
Patch from comment #9 was finally committed to trunk.
I have no idea why I let it linger in bugzilla for 
so long.  Sorry about the long delay.  Thanks for the
bug report.

[Bug fortran/51991] Wrong error message with variables named "SAVE*"

2019-06-21 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #13 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Fri Jun 21 16:57:24 2019
New Revision: 272556

URL: https://gcc.gnu.org/viewcvs?rev=272556=gcc=rev
Log:
2019-06-21  Steven G. Kargl  

PR fortran/51991
* decl.c (gfc_match_save): If SAVE was not seen, return MATCH_NO
instead issuing an error message and returning MATCH_ERROR.

2019-06-21  Steven G. Kargl  

PR fortran/51991
gfortran.dg/pr51991.f90

Added:
trunk/gcc/testsuite/gfortran.dg/pr51991.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/decl.c
trunk/gcc/testsuite/ChangeLog

[Bug fortran/51991] Wrong error message with variables named SAVE*

2012-02-08 Thread bardeau at iram dot fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #10 from Sebastien Bardeau bardeau at iram dot fr 2012-02-08 
10:38:42 UTC ---
I checked the gfortran trunk revision 183991 and the bug does not seem to be
fixed. I can also add that the DATA*-named variables give also erroneous
messages.

gfortran -v:

Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/home/bardeau/Softs/gcc-4.7.0-20120208/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk-source/gcc/configure
--enable-languages=c,c++,fortran --enable-checking=release --disable-bootstrap
--disable-libmudflap --enable-libgomp --enable-lto --enable-gold
--with-plugin-ld=/usr/bin/gold --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 4.7.0 20120208 (experimental) [trunk revision 183991] (GCC)


code:

subroutine sav
  integer :: save1
  save1 = something wrong
end subroutine sav
!
subroutine dat
  integer :: data1
  data1 = something wrong
end subroutine dat

messages:

gfortran-error4.f90:3.6:

  save1 = something wrong
  1
Error: Syntax error in SAVE statement at (1)
gfortran-error4.f90:8.6:

  data1 = something wrong
  1
Error: Syntax error in DATA statement at (1)


[Bug fortran/51991] Wrong error message with variables named SAVE*

2012-02-08 Thread sgk at troutmask dot apl.washington.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #11 from Steve Kargl sgk at troutmask dot apl.washington.edu 
2012-02-08 16:15:20 UTC ---
On Wed, Feb 08, 2012 at 10:38:42AM +, bardeau at iram dot fr wrote:
 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991
 
 --- Comment #10 from Sebastien Bardeau bardeau at iram dot fr 2012-02-08 
 10:38:42 UTC ---
 I checked the gfortran trunk revision 183991 and the bug does not seem to be
 fixed. I can also add that the DATA*-named variables give also erroneous
 messages.

The patch has not been checked-in.  And, I have no idea
when I'll have time to add it.


[Bug fortran/51991] Wrong error message with variables named SAVE*

2012-02-08 Thread bardeau at iram dot fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #12 from Sebastien Bardeau bardeau at iram dot fr 2012-02-08 
16:22:47 UTC ---
Ok, I did not realize that this patch was just a fix candidate.

This bug is not a problem to me, so there is no hurry.

Thanks.


[Bug fortran/51991] Wrong error message with variables named SAVE*

2012-01-25 Thread burnus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

Tobias Burnus burnus at gcc dot gnu.org changed:

   What|Removed |Added

 CC||burnus at gcc dot gnu.org
Version|fortran-dev |4.7.0

--- Comment #1 from Tobias Burnus burnus at gcc dot gnu.org 2012-01-25 
10:46:23 UTC ---
Works for me:

With GCC 4.1, 4.3, 4.4, 4.5, 4.6 and 4.7 I get the expected diagnostic. For
4.7, I tried
  4.7.0 20120118 [trunk revision 183273]
and
  4.7.0 20120125 Rev. 183512 (with some unrelated patches)
and all gave exactly the same error:

j = a%j
   1
Error: 'j' at (1) is not a member of the 'mytyp' structure


I wonder why it does not work for you with GCC 4.7 2011-11-19.

I do not recall any issue, but it might have been some intermediate glitch.
Does a newer 4.7 work? And which platform are you on? It could also be some
target-dependent bug.


[Bug fortran/51991] Wrong error message with variables named SAVE*

2012-01-25 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

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

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2012-01-25
 Ever Confirmed|0   |1

--- Comment #2 from Dominique d'Humieres dominiq at lps dot ens.fr 2012-01-25 
11:09:19 UTC ---
It looks like the test should be

module mymod
  type :: mytyp
integer :: i
  end type mytyp
contains
  subroutine mysub
implicit none
type(mytyp) :: a
integer :: i,j
i = a%i
savej = a%j
  end subroutine mysub
end module mymod

and for the variant above I confirm that the error is 

pr51991_db.f90:11.9:

savej = a%j
 1
Error: Syntax error in SAVE statement at (1)

for gfortran 4.4.6, 4.5.3, 4.6.3, and 4.7.0 (trunk r183455).


[Bug fortran/51991] Wrong error message with variables named SAVE*

2012-01-25 Thread bardeau at iram dot fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #3 from Sebastien Bardeau bardeau at iram dot fr 2012-01-25 
12:39:59 UTC ---
(In reply to comment #1)
 I wonder why it does not work for you with GCC 4.7 2011-11-19.
 
 I do not recall any issue, but it might have been some intermediate glitch.
 Does a newer 4.7 work? And which platform are you on? It could also be some
 target-dependent bug.

Same problem with the nightly version under x86_64-unknown-linux-gnu:

pctcp27 Scripts/Fortran gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/home/bardeau/Softs/gcc-4.7.0-20120125/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk-source/gcc/configure
--enable-languages=c,c++,fortran --enable-checking=release --disable-bootstrap
--disable-libmudflap --enable-libgomp --enable-lto --enable-gold
--with-plugin-ld=/usr/bin/gold --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 4.7.0 20120125 (experimental) [trunk revision 183507] (GCC)

And also with an old gfortran I have on my system:
pctcp27 Scripts/Fortran gfortran44 -v
Using built-in specs.
Target: x86_64-redhat-linux6E
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-languages=c,c++,fortran
--disable-libgcj
--with-mpfr=/builddir/build/BUILD/gcc-4.4.0-20090514/obj-x86_64-redhat-linux6E/mpfr-install/
--with-ppl=/builddir/build/BUILD/gcc-4.4.0-20090514/obj-x86_64-redhat-linux6E/ppl-install
--with-cloog=/builddir/build/BUILD/gcc-4.4.0-20090514/obj-x86_64-redhat-linux6E/cloog-install
--with-tune=generic --with-arch_32=i586 --build=x86_64-redhat-linux6E
Thread model: posix
gcc version 4.4.0 20090514 (Red Hat 4.4.0-6) (GCC)



(In reply to comment #2)
 It looks like the test should be
 
 and for the variant above I confirm that the error is 

Well, ok, the 2 tests are just different and should raise different errors.


[Bug fortran/51991] Wrong error message with variables named SAVE*

2012-01-25 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #4 from Dominique d'Humieres dominiq at lps dot ens.fr 2012-01-25 
12:59:39 UTC ---
 Well, ok, the 2 tests are just different and should raise different errors.

Your original test gives

pr51991.f90:11.11:

j = a%j
   1
Error: 'j' at (1) is not a member of the 'mytyp' structure

for 4.4, 4.5, 4.6, and trunk.


[Bug fortran/51991] Wrong error message with variables named SAVE*

2012-01-25 Thread bardeau at iram dot fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #5 from Sebastien Bardeau bardeau at iram dot fr 2012-01-25 
13:19:21 UTC ---
(In reply to comment #4)
  Well, ok, the 2 tests are just different and should raise different errors.
 
 Your original test gives
 
 pr51991.f90:11.11:
 
 j = a%j
1
 Error: 'j' at (1) is not a member of the 'mytyp' structure
 
 for 4.4, 4.5, 4.6, and trunk.


Ok. Not sure what goes wrong, but I do observe the error reported in my first
message with gfortran trunk (I am using gfortran precompiled binaries, and
dependencies compiled by myself a while ago). I run gfortran under Scientific
Linux 5.5.

home/bardeau uname -a
Linux pctcp27 2.6.18-194.8.1.el5 #1 SMP Thu Jul 1 16:05:53 EDT 2010 x86_64
x86_64 x86_64 GNU/Linux
Scripts/Fortran gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/home/bardeau/Softs/gcc-4.7.0-20120125/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk-source/gcc/configure
--enable-languages=c,c++,fortran --enable-checking=release --disable-bootstrap
--disable-libmudflap --enable-libgomp --enable-lto --enable-gold
--with-plugin-ld=/usr/bin/gold --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 4.7.0 20120125 (experimental) [trunk revision 183507] (GCC)
Scripts/Fortran cat gfortran-error1.f90
module mymod
  type :: mytyp
integer :: i
  end type mytyp
contains
  subroutine mysub
implicit none
type(mytyp) :: a
integer :: savei,savej
savei = a%i
savej = a%j
  end subroutine mysub
end module mymod
Scripts/Fortran gfortran -c gfortran-error1.f90
gfortran-error1.f90:11.9:

savej = a%j
 1
Error: Syntax error in SAVE statement at (1)


[Bug fortran/51991] Wrong error message with variables named SAVE*

2012-01-25 Thread bardeau at iram dot fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #6 from Sebastien Bardeau bardeau at iram dot fr 2012-01-25 
13:29:41 UTC ---
Created attachment 26461
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=26461
Correct version this time.

Sorry, previous version had no problem. The symptom is the following: whatever
if savej is declared or not, the line savej = %j raise a wrong error
message.


[Bug fortran/51991] Wrong error message with variables named SAVE*

2012-01-25 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #7 from Dominique d'Humieres dominiq at lps dot ens.fr 2012-01-25 
13:32:34 UTC ---
 ... I do observe the error reported in my first message with gfortran trunk 
 ...

I am quite confused: in order to have 'savej' in the error message, you must
have it in the source, i.e., use the tests in comment #2 or in #5. 

IIUC in free-form spaces are required and 'savej' should not be parsed as 'save
j', so the error message seems bogus (Tobias?).


[Bug fortran/51991] Wrong error message with variables named SAVE*

2012-01-25 Thread bardeau at iram dot fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

--- Comment #8 from Sebastien Bardeau bardeau at iram dot fr 2012-01-25 
13:36:51 UTC ---
(In reply to comment #7)
  ... I do observe the error reported in my first message with gfortran trunk 
  ...
 
 I am quite confused: in order to have 'savej' in the error message, you must
 have it in the source, i.e., use the tests in comment #2 or in #5. 

Yes, sorry, I first uploaded the wrong version of my test file (I made more
tests between the file selection in the form and the upload).

The new attachment should show the errors now.


[Bug fortran/51991] Wrong error message with variables named SAVE*

2012-01-25 Thread kargl at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51991

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 CC||kargl at gcc dot gnu.org

--- Comment #9 from kargl at gcc dot gnu.org 2012-01-25 16:16:30 UTC ---
Index: decl.c
===
--- decl.c  (revision 183295)
+++ decl.c  (working copy)
@@ -6997,8 +6997,13 @@ gfc_match_save (void)
   return MATCH_YES;

 syntax:
-  gfc_error (Syntax error in SAVE statement at %C);
-  return MATCH_ERROR;
+  if (gfc_current_ns-seen_save)
+{
+  gfc_error (Syntax error in SAVE statement at %C);
+  return MATCH_ERROR;
+}
+   else
+  return MATCH_NO;
 }