View previous topic :: View next topic |
Author |
Message |
DanRRight

Joined: 10 Mar 2008 Posts: 2774 Location: South Pole, Antarctica
|
Posted: Wed Jul 08, 2015 7:19 am Post subject: Confusing diagnostics in module |
|
|
Compile this program which has wrong line marked with the arrow
Code: | module Mo
CONTAINS
integer function f()
f=1
end function
subroutine abracadabra ! <--- wrong line
end module
!--------------------------
Program Pro
use Mo
Print*,' Nothing to print'
End program |
The diagnostics is pretty confusing in this case because points at the wrong line as if something wrong is with integer function F or this function does not have END statement
Code: | PROCESSING MODULE [<MO> FTN95/Win32 v7.10.0]
0004) integer function f()
*** INTEGER cannot be declared inside SUBROUTINE block (perhaps missing
CONTAINS or END statement?) |
If you change this wrong line with something else like
CALL abracadabra
or
abracadabra
the diagnostics is correct and points at the exact offending place. |
|
Back to top |
|
 |
John-Silver

Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Wed Jul 08, 2015 8:48 am Post subject: |
|
|
Dan, have you tried putting an 'end subroutine ' line in, maybe that's throwing it into confusion ?
Last edited by John-Silver on Wed Jul 08, 2015 9:08 am; edited 1 time in total |
|
Back to top |
|
 |
DanRRight

Joined: 10 Mar 2008 Posts: 2774 Location: South Pole, Antarctica
|
Posted: Wed Jul 08, 2015 8:56 am Post subject: |
|
|
The point is different, John. It is about better diagnostics of dumb errors by the compiler |
|
Back to top |
|
 |
John-Silver

Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Wed Jul 08, 2015 9:10 am Post subject: |
|
|
yep I understood that, but if the (so-called) subroutine definition is amiss there could be a link to that
I note that the error message is wrong too.
"INTEGER cannot be declared inside SUBROUTINE block"
a) an integer can be declared inside a subroutine block of course !
b) You haven't defined the integer function inside the (half) subroutine block, but it thinks you have ! |
|
Back to top |
|
 |
John-Silver

Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Wed Jul 08, 2015 9:39 am Post subject: |
|
|
it works after putting 'end subroutine ' in (only warning that nothing in there !)
It would be useful to have a FATAL error that there's no end subroutine, although it does mention in error message MAYBE there is a missing 'end' but as you said it's not referring to any subroutine but to the function.
Looks like x2 mixed up messages to me.
One for Paul&Co to trace
- NOTE -
i) if you move the subroutine definition ABOVE the function definition you get the error message.
*** SUBROUTINE cannot be declared inside PROGRAM block (perhaps missing CONTAINS or END statement?)
Which is a logical error message !
AND
ii) if you remove (comment out) the function you get:
*** SUBROUTINE cannot be declared inside SUBROUTINE block (perhaps missing CONTAINS or END statement?)
!iii) if you remove the module and put the function defn in the main program only then you get:
*** SUBROUTINE cannot be declared inside PROGRAM block (perhaps missing CONTAINS or END statement?)
which are both logical messages.
Seems to be the presence of the INTEGER function being before the subroutine which is throwing it.
Maybe subroutines are processed first ? Still doesn't explain why it thinks the function is INSIDE the Subroutine, which s the crux of the matter. |
|
Back to top |
|
 |
John-Silver

Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Wed Jul 08, 2015 10:07 am Post subject: |
|
|
Just realised you've posted this in 'Suggestions' forum Dan, not Support.
I assume the suggestion, not made, is "get some better diagnostic messages sorted pdq" ?  |
|
Back to top |
|
 |
PaulLaidler Site Admin

Joined: 21 Feb 2005 Posts: 7765 Location: Salford, UK
|
Posted: Wed Jul 08, 2015 10:55 am Post subject: |
|
|
I have logged this for investigation. |
|
Back to top |
|
 |
|