https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120542

--- Comment #2 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 61585
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61585&action=edit
Proposed fix which detects whether a return statement is allowed

The patch checks whether a return statement is allowed.  It also checks to see
that a return expression is allowed.

$ gm2 badreturn.mod 
badreturn.mod:4:4: error: In program module ‘badreturn’: attempting to return a
value when not in a procedure scope
    4 |    RETURN 0
      |    ^~~~~~~~

$ gm2 badreturn2.mod
badreturn2.mod:6:4: error: In procedure ‘foo’: attempting to return a value
from procedure ‘foo’ which does not have a return type
    6 |    RETURN 0
      |    ^~~~~~~~

currently bootstrap building on x86_64

Reply via email to