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/102368] Failure to compile program using the C_SIZEOF function in ISO_C_BINDING
Date: Thu, 11 Nov 2021 22:53:22 +0000	[thread overview]
Message-ID: <bug-102368-4-H30fqSkpZ1@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102368-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from anlauf at gcc dot gnu.org ---
Testing the following patch:

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index ffa07b510cd..f325e5e4d5f 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -5272,13 +5272,18 @@ is_c_interoperable (gfc_expr *expr, const char **msg,
bool c_loc, bool c_f_ptr)
        && !gfc_simplify_expr (expr->ts.u.cl->length, 0))
       gfc_internal_error ("is_c_interoperable(): gfc_simplify_expr failed");

-    if (!c_loc && expr->ts.u.cl
-       && (!expr->ts.u.cl->length
-           || expr->ts.u.cl->length->expr_type != EXPR_CONSTANT
-           || mpz_cmp_si (expr->ts.u.cl->length->value.integer, 1) != 0))
+    if (!c_loc && expr->ts.u.cl)
       {
-       *msg = "Type shall have a character length of 1";
-       return false;
+       bool len_ok = (expr->ts.u.cl->length
+                      && expr->ts.u.cl->length->expr_type == EXPR_CONSTANT);
+       /* F2008: character variable of constant length is interoperable.  */
+       if (len_ok && !(gfc_option.allow_std & GFC_STD_F2008))
+         len_ok = mpz_cmp_si (expr->ts.u.cl->length->value.integer, 1) != 0;
+       if (!len_ok)
+         {
+           *msg = "Type shall have a character length of 1";
+           return false;
+         }
       }
     }

  parent reply	other threads:[~2021-11-11 22:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16 14:49 [Bug fortran/102368] New: " longb at cray dot com
2021-11-11 22:21 ` [Bug fortran/102368] " anlauf at gcc dot gnu.org
2021-11-11 22:53 ` anlauf at gcc dot gnu.org [this message]
2021-11-12 17:41 ` anlauf at gcc dot gnu.org
2021-11-12 21:36 ` anlauf at gcc dot gnu.org
2021-11-13 21:15 ` anlauf at gcc dot gnu.org

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-102368-4-H30fqSkpZ1@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: link
Be 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).