[Bug fortran/93366] ICE: Invalid expression in gfc_element_size

2020-06-14 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93366

--- Comment #9 from CVS Commits  ---
The releases/gcc-10 branch has been updated by Harald Anlauf
:

https://gcc.gnu.org/g:294105192c9f6bdcebce81752fc1e64e2b7adebb

commit r10-8301-g294105192c9f6bdcebce81752fc1e64e2b7adebb
Author: Harald Anlauf 
Date:   Tue May 5 22:16:50 2020 +0200

PR fortran/93366 - ICE on invalid, reject invalid use of NULL() as argument

gcc/fortran/ChangeLog:

2020-05-05  Steve Kargl  
Harald Anlauf  

PR fortran/93366
* check.c (gfc_check_associated, invalid_null_arg): Factorize
check for presence of invalid NULL() argument.
(gfc_check_kind, gfc_check_merge, gfc_check_shape)
(gfc_check_sizeof, gfc_check_spread, gfc_check_transfer): Use this
check for presence of invalid NULL() arguments.

gcc/testsuite/ChangeLog:

2020-05-05  Harald Anlauf  

PR fortran/93366
* gfortran.dg/pr93366.f90: New test.

(cherry picked from commit 5a26ea7e0f8b9a00a2eb0a5e8f70efa04056f167)

[Bug fortran/93366] ICE: Invalid expression in gfc_element_size

2020-05-05 Thread anlauf at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93366

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #8 from anlauf at gcc dot gnu.org ---
Fixed on master for GCC 11.  Thanks for the report!

[Bug fortran/93366] ICE: Invalid expression in gfc_element_size

2020-05-05 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93366

--- Comment #7 from CVS Commits  ---
The master branch has been updated by Harald Anlauf :

https://gcc.gnu.org/g:5a26ea7e0f8b9a00a2eb0a5e8f70efa04056f167

commit r11-120-g5a26ea7e0f8b9a00a2eb0a5e8f70efa04056f167
Author: Harald Anlauf 
Date:   Tue May 5 22:16:50 2020 +0200

PR fortran/93366 - ICE on invalid, reject invalid use of NULL() as argument

gcc/fortran/ChangeLog:

2020-05-05  Steve Kargl  
Harald Anlauf  

PR fortran/93366
* check.c (gfc_check_associated, invalid_null_arg): Factorize
check for presence of invalid NULL() argument.
(gfc_check_kind, gfc_check_merge, gfc_check_shape)
(gfc_check_sizeof, gfc_check_spread, gfc_check_transfer): Use this
check for presence of invalid NULL() arguments.

gcc/testsuite/ChangeLog:

2020-05-05  Harald Anlauf  

PR fortran/93366
* gfortran.dg/pr93366.f90: New test.

[Bug fortran/93366] ICE: Invalid expression in gfc_element_size

2020-05-04 Thread anlauf at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93366

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |anlauf at gcc dot 
gnu.org

--- Comment #6 from anlauf at gcc dot gnu.org ---
Patch posted at

https://gcc.gnu.org/pipermail/gcc-patches/2020-May/545091.html

[Bug fortran/93366] ICE: Invalid expression in gfc_element_size

2020-04-30 Thread anlauf at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93366

--- Comment #5 from anlauf at gcc dot gnu.org ---
Created attachment 48427
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48427&action=edit
Update and extension of Steve's patch

I've updated Steve's patch to reflect current master before creating the
10-release branch.

My additions handle a few accepts-invalid cases for
KIND, MERGE, SHAPE, SPREAD.

If there are no objections, I will submit with a testcase after the 10 release
for the 11 master.

[Bug fortran/93366] ICE: Invalid expression in gfc_element_size

2020-04-29 Thread sgk at troutmask dot apl.washington.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93366

--- Comment #4 from Steve Kargl  ---
On Wed, Apr 29, 2020 at 08:57:44PM +, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93366
> 
> anlauf at gcc dot gnu.org changed:
> 
>What|Removed |Added
> 
>  CC||anlauf at gcc dot gnu.org
> 
> --- Comment #3 from anlauf at gcc dot gnu.org ---
> (In reply to kargl from comment #2)
> > patch against last SVN revision.
> Steve,
> 
> do you still care?
> 

It is not that I don't care.  It is that I no longer have
an ability to commit patches or checkout top-of-tree.  The
recent io.c discuss that I participated in shows that top-of-tree
and svn r280157 have started to diverge substantially.  So,
my time is done.  It is time for a younger generation to 
step up.

[Bug fortran/93366] ICE: Invalid expression in gfc_element_size

2020-04-29 Thread anlauf at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93366

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 CC||anlauf at gcc dot gnu.org

--- Comment #3 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #2)
> patch against last SVN revision.
Steve,

do you still care?

[Bug fortran/93366] ICE: Invalid expression in gfc_element_size

2020-01-21 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93366

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2020-01-21
 Ever confirmed|0   |1

[Bug fortran/93366] ICE: Invalid expression in gfc_element_size

2020-01-21 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93366

kargl at gcc dot gnu.org changed:

   What|Removed |Added

   Priority|P3  |P4
 CC||kargl at gcc dot gnu.org

--- Comment #2 from kargl at gcc dot gnu.org ---
patch against last SVN revision.

Index: gcc/fortran/check.c
===
--- gcc/fortran/check.c (revision 280157)
+++ gcc/fortran/check.c (working copy)
@@ -1426,6 +1426,18 @@ gfc_check_x_yd (gfc_expr *x, gfc_expr *y)
   return true;
 }

+static bool
+invalid_null_arg (gfc_expr *x)
+{
+  if (x->expr_type == EXPR_NULL)
+{
+  gfc_error ("NULL pointer at %L is not permitted as actual argument "
+"of %qs intrinsic function", &x->where,
+gfc_current_intrinsic);
+  return true;
+}
+  return false;
+}

 bool
 gfc_check_associated (gfc_expr *pointer, gfc_expr *target)
@@ -1433,13 +1445,10 @@ gfc_check_associated (gfc_expr *pointer, gfc_expr *tar
   symbol_attribute attr1, attr2;
   int i;
   bool t;
-  locus *where;

-  where = &pointer->where;
+  if (invalid_null_arg (pointer))
+return false;

-  if (pointer->expr_type == EXPR_NULL)
-goto null_arg;
-
   attr1 = gfc_expr_attr (pointer);

   if (!attr1.pointer && !attr1.proc_pointer)
@@ -1463,9 +1472,8 @@ gfc_check_associated (gfc_expr *pointer, gfc_expr *tar
   if (target == NULL)
 return true;

-  where = &target->where;
-  if (target->expr_type == EXPR_NULL)
-goto null_arg;
+  if (invalid_null_arg (target))
+return false;

   if (target->expr_type == EXPR_VARIABLE || target->expr_type ==
EXPR_FUNCTION)
 attr2 = gfc_expr_attr (target);
@@ -1513,13 +1521,6 @@ gfc_check_associated (gfc_expr *pointer, gfc_expr *tar
  }
 }
   return t;
-
-null_arg:
-
-  gfc_error ("NULL pointer at %L is not permitted as actual argument "
-"of %qs intrinsic function", where, gfc_current_intrinsic);
-  return false;
-
 }


@@ -5124,6 +5125,9 @@ gfc_check_size (gfc_expr *array, gfc_expr *dim, gfc_ex
 bool
 gfc_check_sizeof (gfc_expr *arg)
 {
+  if (invalid_null_arg (arg))
+return false;
+
   if (arg->ts.type == BT_PROCEDURE)
 {
   gfc_error ("%qs argument of %qs intrinsic at %L shall not be a
procedure",
@@ -6139,6 +6143,9 @@ gfc_check_transfer (gfc_expr *source, gfc_expr *mold, 
   size_t source_size;
   size_t result_size;

+  if (invalid_null_arg (source))
+return false;
+
   /* SOURCE shall be a scalar or array of any type.  */
   if (source->ts.type == BT_PROCEDURE
   && source->symtree->n.sym->attr.subroutine == 1)
@@ -6153,6 +6160,9 @@ gfc_check_transfer (gfc_expr *source, gfc_expr *mold, 
 return false;

   if (mold->ts.type == BT_BOZ && illegal_boz_arg (mold))
+return false;
+
+  if (invalid_null_arg (mold))
 return false;

   /* MOLD shall be a scalar or array of any type.  */

[Bug fortran/93366] ICE: Invalid expression in gfc_element_size

2020-01-21 Thread gs...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93366

G. Steinmetz  changed:

   What|Removed |Added

   Keywords||ice-on-invalid-code

--- Comment #1 from G. Steinmetz  ---


Similar :


$ cat z2.f90
program p
   print *, transfer(1, null())
   print *, transfer([1], null())
end


$ cat z3.f90
program p
   print *, transfer (null(), 1)
   print *, transfer (null(), [1])
end


$ cat z4.f90
program p
   print *, transfer(null(), null())
end


$ gfortran-10-20200119 -c z3.f90
f951: internal compiler error: Invalid expression in gfc_element_size.
0x647599 gfc_report_diagnostic
../../gcc/fortran/error.c:782
0x648cba gfc_internal_error(char const*, ...)
../../gcc/fortran/error.c:1402
0x6e4582 gfc_element_size(gfc_expr*, unsigned long*)
../../gcc/fortran/target-memory.c:137
0x6e45e3 gfc_target_expr_size(gfc_expr*, unsigned long*)
../../gcc/fortran/target-memory.c:166
0x623a6a gfc_calculate_transfer_sizes(gfc_expr*, gfc_expr*, gfc_expr*, unsigned
long*, unsigned long*, unsigned long*)
../../gcc/fortran/check.c:6083
0x6d971d gfc_simplify_transfer(gfc_expr*, gfc_expr*, gfc_expr*)
../../gcc/fortran/simplify.c:7926
0x65ca07 do_simplify
../../gcc/fortran/intrinsic.c:4617
0x66721a gfc_intrinsic_func_interface(gfc_expr*, int)
../../gcc/fortran/intrinsic.c:4996
0x6bea5e resolve_unknown_f
../../gcc/fortran/resolve.c:2894
0x6bea5e resolve_function
../../gcc/fortran/resolve.c:3238
0x6bea5e gfc_resolve_expr(gfc_expr*)
../../gcc/fortran/resolve.c:7000
0x6b5dec gfc_resolve_expr(gfc_expr*)
../../gcc/fortran/resolve.c:6967
0x6b5dec gfc_resolve_code(gfc_code*, gfc_namespace*)
../../gcc/fortran/resolve.c:11688
0x6c4cdf gfc_resolve_blocks(gfc_code*, gfc_namespace*)
../../gcc/fortran/resolve.c:10715
0x6b4b18 gfc_resolve_code(gfc_code*, gfc_namespace*)
../../gcc/fortran/resolve.c:11678
0x6b7397 resolve_codes
../../gcc/fortran/resolve.c:17205
0x6b745e gfc_resolve(gfc_namespace*)
../../gcc/fortran/resolve.c:17240
0x6a57bc resolve_all_program_units
../../gcc/fortran/parse.c:6241
0x6a57bc gfc_parse_file()
../../gcc/fortran/parse.c:6488
0x6f044f gfc_be_parse_file
../../gcc/fortran/f95-lang.c:210