* [Patch] Fortran: Fix gfc_conv_gfc_desc_to_cfi_desc with NULL [PR104126]
@ 2022-03-07 14:16 Tobias Burnus
2022-03-08 21:44 ` Harald Anlauf
0 siblings, 1 reply; 4+ messages in thread
From: Tobias Burnus @ 2022-03-07 14:16 UTC (permalink / raw)
To: gcc-patches, fortran
[-- Attachment #1: Type: text/plain, Size: 507 bytes --]
Pre-remark: Related NULL, there some accepts-invalid issues, not addressed in this
patch. See https://gcc.gnu.org/PR104819
This patch fixes an ICE (12 regression) with NULL() that has no MOLD argument.
OK for mainline?
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
[-- Attachment #2: pr104126-null.diff --]
[-- Type: text/x-patch, Size: 2317 bytes --]
Fortran: Fix gfc_conv_gfc_desc_to_cfi_desc with NULL [PR104126]
PR fortran/104126
gcc/fortran/ChangeLog:
* trans-expr.cc (gfc_conv_gfc_desc_to_cfi_desc): Handle NULL
without MOLD.
gcc/testsuite/ChangeLog:
* gfortran.dg/null_actual_2.f90: New test.
gcc/fortran/trans-expr.cc | 13 +++++++++----
gcc/testsuite/gfortran.dg/null_actual_2.f90 | 16 ++++++++++++++++
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index eb6a78c3a62..e8a78ccf4e1 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -5608,8 +5608,11 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym)
itype = (e->ts.u.derived->intmod_sym_id == ISOCBINDING_FUNPTR
? CFI_type_cfunptr : CFI_type_cptr);
else
- switch (e->ts.type)
- {
+ {
+ if (e->expr_type == EXPR_NULL && e->ts.type == BT_UNKNOWN)
+ e->ts = fsym->ts;
+ switch (e->ts.type)
+ {
case BT_INTEGER:
case BT_LOGICAL:
case BT_REAL:
@@ -5647,7 +5650,8 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym)
case BT_UNKNOWN:
// FIXME: Really unreachable? Or reachable for type(*) ? If so, CFI_type_other?
gcc_unreachable ();
- }
+ }
+ }
tmp = gfc_get_cfi_desc_type (cfi);
gfc_add_modify (&block, tmp,
@@ -5700,7 +5704,8 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym)
gfc_init_block (&block2);
/* Set elem_len, which may be only known at run time. */
- if (e->ts.type == BT_CHARACTER)
+ if (e->ts.type == BT_CHARACTER
+ && (e->expr_type != EXPR_NULL || gfc_strlen != NULL_TREE))
{
gcc_assert (gfc_strlen);
tmp = gfc_strlen;
diff --git a/gcc/testsuite/gfortran.dg/null_actual_2.f90 b/gcc/testsuite/gfortran.dg/null_actual_2.f90
new file mode 100644
index 00000000000..de481f01295
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/null_actual_2.f90
@@ -0,0 +1,16 @@
+! { dg-do compile }
+!
+! PR fortran/104126
+!
+! Contributed by G. Steinmetz
+!
+program p
+ use iso_c_binding, only: c_char
+ character(len=:,kind=c_char), pointer :: d
+ call s(null(d))
+ call s(null())
+contains
+ subroutine s(x) bind(c)
+ character(len=:, kind=c_char), pointer, intent(in) :: x
+ end
+end
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch] Fortran: Fix gfc_conv_gfc_desc_to_cfi_desc with NULL [PR104126]
2022-03-07 14:16 [Patch] Fortran: Fix gfc_conv_gfc_desc_to_cfi_desc with NULL [PR104126] Tobias Burnus
@ 2022-03-08 21:44 ` Harald Anlauf
2022-03-08 21:44 ` Harald Anlauf
2022-03-08 23:34 ` Tobias Burnus
0 siblings, 2 replies; 4+ messages in thread
From: Harald Anlauf @ 2022-03-08 21:44 UTC (permalink / raw)
To: Tobias Burnus, gcc-patches, fortran
Hi Tobias,
Am 07.03.22 um 15:16 schrieb Tobias Burnus:
> Pre-remark: Related NULL, there some accepts-invalid issues, not
> addressed in this
> patch. See https://gcc.gnu.org/PR104819
>
> This patch fixes an ICE (12 regression) with NULL() that has no MOLD
> argument.
the patch does fix the ICE. But given your short pre-remark:
are you saying that the testcase is invalid, and with the patch
we silently accept it now?
(The testcase compiles with Intel, but triggers a funny bug in
crayftn, which made me read 16.9.144 to learn more about the
tricks of NULL. But I tend to think this case is valid.)
> OK for mainline?
LGTM.
Thanks for the patch!
Harald
> Tobias
> -----------------
> Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201,
> 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer:
> Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München;
> Registergericht München, HRB 106955
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch] Fortran: Fix gfc_conv_gfc_desc_to_cfi_desc with NULL [PR104126]
2022-03-08 21:44 ` Harald Anlauf
@ 2022-03-08 21:44 ` Harald Anlauf
2022-03-08 23:34 ` Tobias Burnus
1 sibling, 0 replies; 4+ messages in thread
From: Harald Anlauf @ 2022-03-08 21:44 UTC (permalink / raw)
To: fortran; +Cc: gcc-patches
Hi Tobias,
Am 07.03.22 um 15:16 schrieb Tobias Burnus:
> Pre-remark: Related NULL, there some accepts-invalid issues, not
> addressed in this
> patch. See https://gcc.gnu.org/PR104819
>
> This patch fixes an ICE (12 regression) with NULL() that has no MOLD
> argument.
the patch does fix the ICE. But given your short pre-remark:
are you saying that the testcase is invalid, and with the patch
we silently accept it now?
(The testcase compiles with Intel, but triggers a funny bug in
crayftn, which made me read 16.9.144 to learn more about the
tricks of NULL. But I tend to think this case is valid.)
> OK for mainline?
LGTM.
Thanks for the patch!
Harald
> Tobias
> -----------------
> Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201,
> 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer:
> Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München;
> Registergericht München, HRB 106955
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch] Fortran: Fix gfc_conv_gfc_desc_to_cfi_desc with NULL [PR104126]
2022-03-08 21:44 ` Harald Anlauf
2022-03-08 21:44 ` Harald Anlauf
@ 2022-03-08 23:34 ` Tobias Burnus
1 sibling, 0 replies; 4+ messages in thread
From: Tobias Burnus @ 2022-03-08 23:34 UTC (permalink / raw)
To: Harald Anlauf, gcc-patches, fortran
Hi Harald,
On 08.03.22 22:44, Harald Anlauf wrote:
> Am 07.03.22 um 15:16 schrieb Tobias Burnus:
>> Pre-remark: Related NULL, there some accepts-invalid issues, not
>> addressed in this
>> patch. See https://gcc.gnu.org/PR104819
>>
>> This patch fixes an ICE (12 regression) with NULL() that has no MOLD
>> argument.
> the patch does fix the ICE. But given your short pre-remark:
> are you saying that the testcase is invalid, and with the patch
> we silently accept it now?
Sorry for being confusing. I also believe the testcase of the just
committed patch is valid Fortran.
However, when fixing this PR, I was looking at the spec – and saw that
GCC accepts invalid code using NULL(), which is not diagnosed. Those
issues are orthogonal to this patch, except that the accepts-invalid
issues also are about NULL().
Thanks for the review!
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-03-08 23:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07 14:16 [Patch] Fortran: Fix gfc_conv_gfc_desc_to_cfi_desc with NULL [PR104126] Tobias Burnus
2022-03-08 21:44 ` Harald Anlauf
2022-03-08 21:44 ` Harald Anlauf
2022-03-08 23:34 ` Tobias Burnus
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).