forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Confusing diagnostics in module

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Suggestions
View previous topic :: View next topic  
Author Message
DanRRight



Joined: 10 Mar 2008
Posts: 1476
Location: South Pole, Antarctica

PostPosted: Wed Jul 08, 2015 7:19 am    Post subject: Confusing diagnostics in module Reply with quote

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
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 495

PostPosted: Wed Jul 08, 2015 8:48 am    Post subject: Reply with quote

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
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 1476
Location: South Pole, Antarctica

PostPosted: Wed Jul 08, 2015 8:56 am    Post subject: Reply with quote

The point is different, John. It is about better diagnostics of dumb errors by the compiler
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 495

PostPosted: Wed Jul 08, 2015 9:10 am    Post subject: Reply with quote

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
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 495

PostPosted: Wed Jul 08, 2015 9:39 am    Post subject: Reply with quote

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
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 495

PostPosted: Wed Jul 08, 2015 10:07 am    Post subject: Reply with quote

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" ? Smile
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4777
Location: Salford, UK

PostPosted: Wed Jul 08, 2015 10:55 am    Post subject: Reply with quote

I have logged this for investigation.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Suggestions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group