public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "anlauf at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/109575] Implement runtime check for valid function result Date: Fri, 21 Apr 2023 20:24:45 +0000 [thread overview] Message-ID: <bug-109575-4-ziJ0ecvIwW@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-109575-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109575 --- Comment #2 from anlauf at gcc dot gnu.org --- I have some idea how (and where) the runtime checks need to be implemented, but I am confused by the following observations on the occurence of an explicit RETURN statement and the use of a RESULT variable: function f() integer :: f end function f1() integer :: f1 f1 = 1 end function q() result (f) integer :: f end function q2() result (f) integer :: f f = 2 end function g() integer :: g return end function g3() integer :: g3 g3 = 3 return end function r() result (f) integer :: f return end function r4() result (f) integer :: f f = 4 return end While the dump-fortran-original does not show any surprises, the tree-dump looks somewhat irregular: __attribute__((fn spec (". "))) integer(kind=4) f () { (void) 0; } __attribute__((fn spec (". "))) integer(kind=4) f1 () { integer(kind=4) __result_f1; __result_f1 = 1; return __result_f1; } __attribute__((fn spec (". "))) integer(kind=4) q () { (void) 0; } __attribute__((fn spec (". "))) integer(kind=4) q2 () { integer(kind=4) f; f = 2; return f; } __attribute__((fn spec (". "))) integer(kind=4) g () { integer(kind=4) __result_g; return __result_g; return __result_g; } __attribute__((fn spec (". "))) integer(kind=4) g3 () { integer(kind=4) __result_g3; __result_g3 = 3; return __result_g3; return __result_g3; } __attribute__((fn spec (". "))) integer(kind=4) r () { return; } __attribute__((fn spec (". "))) integer(kind=4) r4 () { integer(kind=4) f; f = 4; return f; return f; } This seems to correspond to two different paths to gfc_generate_return().
next prev parent reply other threads:[~2023-04-21 20:24 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-04-20 19:36 [Bug fortran/109575] New: " anlauf at gcc dot gnu.org 2023-04-20 21:10 ` [Bug fortran/109575] " kargl at gcc dot gnu.org 2023-04-21 20:24 ` anlauf at gcc dot gnu.org [this message] 2023-04-21 21:32 ` sgk at troutmask dot apl.washington.edu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-109575-4-ziJ0ecvIwW@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).