[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2019-06-20 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

kargl at gcc dot gnu.org changed:

   What|Removed |Added

   Target Milestone|10.0|9.2

--- Comment #15 from kargl at gcc dot gnu.org ---
Update target milestone after backport to branch-9.

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2019-06-20 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

--- Comment #14 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Thu Jun 20 23:15:32 2019
New Revision: 272529

URL: https://gcc.gnu.org/viewcvs?rev=272529=gcc=rev
Log:
2019-06-20  Steven G. Kargl  

Backport from mainline
PR fortran/68544
* resolve.c (is_dt_name): New function to compare symbol name against
list of derived types.
(resolve_actual_arglist): Use it to find wrong code.

2019-06-20  Steven G. Kargl  

Backport from mainline
PR fortran/68544
* gfortran.dg/pr68544.f90: New test.
* gfortran.dg/pr85687.f90: Modify test for new error message.

Added:
branches/gcc-9-branch/gcc/testsuite/gfortran.dg/pr68544.f90
Modified:
branches/gcc-9-branch/gcc/fortran/ChangeLog
branches/gcc-9-branch/gcc/fortran/resolve.c
branches/gcc-9-branch/gcc/testsuite/ChangeLog
branches/gcc-9-branch/gcc/testsuite/gfortran.dg/pr85687.f90

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2019-06-15 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

--- Comment #13 from Dominique d'Humieres  ---
Note that the test z4.f90 in comment 6 is still accepted.

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2019-06-13 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED
   Assignee|unassigned at gcc dot gnu.org  |kargl at gcc dot gnu.org
   Target Milestone|--- |10.0

--- Comment #12 from kargl at gcc dot gnu.org ---
Fixed on trunk.  Thanks for bug report.  Sorry it took so long to fix.

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2019-06-13 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

--- Comment #11 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Thu Jun 13 18:40:19 2019
New Revision: 272259

URL: https://gcc.gnu.org/viewcvs?rev=272259=gcc=rev
Log:
2019-06-13  Steven G. Kargl  

PR fortran/68544
* resolve.c (is_dt_name): New function to compare symbol name against
list of derived types.
(resolve_actual_arglist): Use it to find wrong code.

2019-06-13  Steven G. Kargl  

PR fortran/68544
* gfortran.dg/pr68544.f90: New test.
* gfortran.dg/pr85687.f90: Modify test for new error message.

Added:
trunk/gcc/testsuite/gfortran.dg/pr68544.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/resolve.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/pr85687.f90

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2019-02-28 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 CC||kargl at gcc dot gnu.org

--- Comment #10 from kargl at gcc dot gnu.org ---
(In reply to Harald Anlauf from comment #9)
> (In reply to kargl from comment #8)
> > Index: gcc/fortran/resolve.c
> > ===
> > --- gcc/fortran/resolve.c   (revision 266281)
> > +++ gcc/fortran/resolve.c   (working copy)
> > @@ -1863,7 +1863,19 @@ resolve_procedure_expression (gfc_expr* expr)
> 
> Steve,
> 
> what is the status of your patch?

It no longer applies and works.  Someone (pault?)
removed the list of derived types (gfc_derived_types),
so the patch needs to be reworked to walk the list
of symbols to see if the actual argument is a 
derived type or not.  I haven't pursued doing that

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2019-02-28 Thread anlauf at gmx dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

--- Comment #9 from Harald Anlauf  ---
(In reply to kargl from comment #8)
> Index: gcc/fortran/resolve.c
> ===
> --- gcc/fortran/resolve.c (revision 266281)
> +++ gcc/fortran/resolve.c (working copy)
> @@ -1863,7 +1863,19 @@ resolve_procedure_expression (gfc_expr* expr)

Steve,

what is the status of your patch?

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2018-11-20 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 CC|kargl at gcc dot gnu.org   |

--- Comment #8 from kargl at gcc dot gnu.org ---
(In reply to Gerhard Steinmetz from comment #3)
> Update :
> 
> 
> $ cat z1.f90
> program p
>type t
>end type
>call f(t)
> end
> 
> 
> $ gfortran-7-20161120 z1.f90
> z1.f90:2:0:
> 
> type t
> 
> internal compiler error: Segmentation fault
> 0xc4265f crash_signal
> ../../gcc/toplev.c:333
> 0x74c990 gfc_sym_identifier
> ../../gcc/fortran/trans-decl.c:339
> 0x74e2e3 build_function_decl
> ../../gcc/fortran/trans-decl.c:2197
> 0x75806a gfc_get_symbol_decl(gfc_symbol*)
> ../../gcc/fortran/trans-decl.c:1622
> 0x77005f gfc_conv_variable
> ../../gcc/fortran/trans-expr.c:2494
> 0x76bcf2 gfc_conv_expr(gfc_se*, gfc_expr*)
> ../../gcc/fortran/trans-expr.c:7704
> 0x773aa6 gfc_conv_expr_reference(gfc_se*, gfc_expr*)
> ../../gcc/fortran/trans-expr.c:7804
> 0x767220 gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*,
> gfc_expr*, vec*)
> ../../gcc/fortran/trans-expr.c:5169
> 0x7b0fe4 gfc_trans_call(gfc_code*, bool, tree_node*, tree_node*, bool)
> ../../gcc/fortran/trans-stmt.c:407
> 0x72c59a trans_code
> ../../gcc/fortran/trans.c:1774
> 0x75c578 gfc_generate_function_code(gfc_namespace*)
> ../../gcc/fortran/trans-decl.c:6261
> 0x6e53e0 translate_all_program_units
> ../../gcc/fortran/parse.c:6038
> 0x6e53e0 gfc_parse_file()
> ../../gcc/fortran/parse.c:6238
> 0x729052 gfc_be_parse_file
> ../../gcc/fortran/f95-lang.c:202

Index: gcc/fortran/resolve.c
===
--- gcc/fortran/resolve.c   (revision 266281)
+++ gcc/fortran/resolve.c   (working copy)
@@ -1863,7 +1863,19 @@ resolve_procedure_expression (gfc_expr* expr)
   return true;
 }

+/* Check that name is not a derived type.  */

+static bool
+is_dt_name (const char *name)
+{
+  gfc_symbol *dt_list;
+
+  for (dt_list = gfc_derived_types; dt_list; dt_list = dt_list->dt_next)
+if (strcmp(dt_list->name, name) == 0)
+  return true;
+  return false;
+}
+
 /* Resolve an actual argument list.  Most of the time, this is just
resolving the expressions in the list.
The exception is that we sometimes have to decide whether arguments
@@ -1964,6 +1976,14 @@ resolve_actual_arglist (gfc_actual_arglist *arg, proce
  gfc_error ("ELEMENTAL non-INTRINSIC procedure %qs is not "
 "allowed as an actual argument at %L", sym->name,
 >where);
+   }
+
+ /* Check to see if the argument is actually a derived type.  */
+ if (is_dt_name (sym->name))
+   {
+ gfc_error ("Derived type %qs is used as an actual "
+"argument at %L", sym->name, >where);
+ goto cleanup;
}

  /* Check if a generic interface has a specific procedure
Index: gcc/testsuite/gfortran.dg/pr68544.f90
===
--- gcc/testsuite/gfortran.dg/pr68544.f90   (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr68544.f90   (working copy)
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! PF fortran/68544
+program p
+   real x
+   type t
+   end type
+   x = f(t) ! { dg-error "used as an actual argument" }
+end
+subroutine b
+   type t
+   end type
+   print *, shape(t)! { dg-error "used as an actual argument" }
+end
Index: gcc/testsuite/gfortran.dg/pr85687.f90
===
--- gcc/testsuite/gfortran.dg/pr85687.f90   (revision 266281)
+++ gcc/testsuite/gfortran.dg/pr85687.f90   (working copy)
@@ -1,8 +1,9 @@
 ! { dg-do compile }
 ! PR fortran/85687
 ! Code original contributed by Gerhard Steinmetz gscfq at t-oline dot de
+! Originally, error message superceded by fix for PR fortran/68544.
 program p
type t
end type
-   print *, rank(t)  ! { dg-error "must be a data object" }
+   print *, rank(t)  ! { dg-error "used as an actual argument" }
 end

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2018-06-10 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

kargl at gcc dot gnu.org changed:

   What|Removed |Added

   Priority|P3  |P4
 CC||kargl at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |kargl at gcc dot gnu.org
   Severity|minor   |normal

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2018-04-11 Thread anlauf at gmx dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

Harald Anlauf  changed:

   What|Removed |Added

 CC||anlauf at gmx dot de

--- Comment #7 from Harald Anlauf  ---
(In reply to Gerhard Steinmetz from comment #3)
> Update :
> 
> 
> $ cat z1.f90
> program p
>type t
>end type
>call f(t)
> end

Adding "implicit none" triggers a misleading error message:

pr68544.f90:3:8:

   type t
1
Error: Symbol 't' at (1) has no IMPLICIT type


I think the code is invalid.  Intel writes:

pr68544.f90(5): error #6478: A type-name must not be used as a variable.   [T]
  call f(t)
-^
compilation aborted for pr68544.f90 (code 1)

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2016-11-21 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

--- Comment #6 from Gerhard Steinmetz  
---

These snippets are silently accepted (t is not an array nor a scalar).


$ cat z3.f90
program p
   type t
   end type
   print *, shape(t)
end

$ gfortran-7-20161120 -Wall -fcheck=all z3.f90
$ a.out

$

---

$ cat z4.f90
subroutine s(t)
   type t
   end type
end

$ gfortran-7-20161120 -c z4.f90
$

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2016-11-21 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

--- Comment #5 from Gerhard Steinmetz  
---

Affects several intrinsic functions/subroutines ...

$ cat z7.f90
program p
   type t
   end type
   print *, atomic_define(t)
   print *, atomic_ref(t)
   print *, coshape(t)
   print *, cpu_time(t)
   print *, date_and_time(t)
   print *, execute_command_line(t)
   print *, findloc(t)
   print *, get_command(t)
   print *, get_command_argument(t)
   print *, get_environment_variable(t)
   print *, is_contiguous(t)
   print *, move_alloc(t)
   print *, mvbits(t)
   print *, out_of_range(t)
   print *, random_init(t)
   print *, random_number(t)
   print *, random_seed(t)
   print *, rank(t)
   print *, reduce(t)
   print *, system_clock(t)
end

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2016-11-21 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

--- Comment #4 from Gerhard Steinmetz  
---

Invalid code with a function :


$ cat z2.f90
program p
   type t
   end type
   print *, f(t)
end


$ gfortran-7-20161120 z2.f90
z2.f90:2:0:

type t

internal compiler error: Segmentation fault
0xc4265f crash_signal
../../gcc/toplev.c:333
0x74c990 gfc_sym_identifier
../../gcc/fortran/trans-decl.c:339
0x74e2e3 build_function_decl
../../gcc/fortran/trans-decl.c:2197
0x75806a gfc_get_symbol_decl(gfc_symbol*)
../../gcc/fortran/trans-decl.c:1622
0x77005f gfc_conv_variable
../../gcc/fortran/trans-expr.c:2494
0x76bcf2 gfc_conv_expr(gfc_se*, gfc_expr*)
../../gcc/fortran/trans-expr.c:7704
0x773aa6 gfc_conv_expr_reference(gfc_se*, gfc_expr*)
../../gcc/fortran/trans-expr.c:7804
0x767220 gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*,
gfc_expr*, vec*)
../../gcc/fortran/trans-expr.c:5169
0x76bcd2 gfc_conv_expr(gfc_se*, gfc_expr*)
../../gcc/fortran/trans-expr.c:7696
0x7737d8 gfc_conv_expr_reference(gfc_se*, gfc_expr*)
../../gcc/fortran/trans-expr.c:7831
0x79a586 gfc_trans_transfer(gfc_code*)
../../gcc/fortran/trans-io.c:2482
0x72c237 trans_code
../../gcc/fortran/trans.c:1902
0x7972e0 build_dt
../../gcc/fortran/trans-io.c:1980
0x72c257 trans_code
../../gcc/fortran/trans.c:1874
0x75c578 gfc_generate_function_code(gfc_namespace*)
../../gcc/fortran/trans-decl.c:6261
0x6e53e0 translate_all_program_units
../../gcc/fortran/parse.c:6038
0x6e53e0 gfc_parse_file()
../../gcc/fortran/parse.c:6238
0x729052 gfc_be_parse_file
../../gcc/fortran/f95-lang.c:202

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2016-11-21 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

Gerhard Steinmetz  changed:

   What|Removed |Added

 CC||gerhard.steinmetz.fortran@t
   ||-online.de

--- Comment #3 from Gerhard Steinmetz  
---

Update :


$ cat z1.f90
program p
   type t
   end type
   call f(t)
end


$ gfortran-7-20161120 z1.f90
z1.f90:2:0:

type t

internal compiler error: Segmentation fault
0xc4265f crash_signal
../../gcc/toplev.c:333
0x74c990 gfc_sym_identifier
../../gcc/fortran/trans-decl.c:339
0x74e2e3 build_function_decl
../../gcc/fortran/trans-decl.c:2197
0x75806a gfc_get_symbol_decl(gfc_symbol*)
../../gcc/fortran/trans-decl.c:1622
0x77005f gfc_conv_variable
../../gcc/fortran/trans-expr.c:2494
0x76bcf2 gfc_conv_expr(gfc_se*, gfc_expr*)
../../gcc/fortran/trans-expr.c:7704
0x773aa6 gfc_conv_expr_reference(gfc_se*, gfc_expr*)
../../gcc/fortran/trans-expr.c:7804
0x767220 gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*,
gfc_expr*, vec*)
../../gcc/fortran/trans-expr.c:5169
0x7b0fe4 gfc_trans_call(gfc_code*, bool, tree_node*, tree_node*, bool)
../../gcc/fortran/trans-stmt.c:407
0x72c59a trans_code
../../gcc/fortran/trans.c:1774
0x75c578 gfc_generate_function_code(gfc_namespace*)
../../gcc/fortran/trans-decl.c:6261
0x6e53e0 translate_all_program_units
../../gcc/fortran/parse.c:6038
0x6e53e0 gfc_parse_file()
../../gcc/fortran/parse.c:6238
0x729052 gfc_be_parse_file
../../gcc/fortran/f95-lang.c:202

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2015-11-25 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2015-11-25
 Ever confirmed|0   |1

--- Comment #1 from Dominique d'Humieres  ---
Confirmed from 4.8 up to trunk (6.0).

> Sun's F90 compiler rejects it, but gives a useful error message.

What is the message?

[Bug fortran/68544] ICE trying to pass derived type constructor as a function

2015-11-25 Thread jim.macarthur at codethink dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68544

--- Comment #2 from Jim MacArthur  ---
Sun f90 output:


  CALL sub(t)
   ^  
"pass-type-constructor-as-function.f", Line = 10, Column = 16: ERROR: This use
of derived type "T" is not valid.