diff mbox

[Fortran] PR69397 and PR6844 Internal Compiler Errors2

Message ID 56A51DDC.1050508@charter.net
State New
Headers show

Commit Message

Jerry DeLisle Jan. 24, 2016, 6:54 p.m. UTC
Ha all,

The attached patch with new test cases fixes these by replacing gcc_assert and
updating the error message depending on whether resolving an initialization
expression or not.

Regression tested on x86-64.

OK for trunk?

Jerry


2016-01-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/69397
	PR fortran/68442
	* interface.c (gfc_arglist_matches_symbol): Replace assert with
	a return false if not a procedure.
	* resolve.c (resolve_generic_f): Test if we are resolving an
	initialization expression and adjust error message accordingly.

Comments

Thomas Koenig Jan. 24, 2016, 8:13 p.m. UTC | #1
Hi Jerry,

> The attached patch with new test cases fixes these by replacing gcc_assert and
> updating the error message depending on whether resolving an initialization
> expression or not.
>
> Regression tested on x86-64.
>
> OK for trunk?

OK.

Thanks for the patch!

	Thomas
diff mbox

Patch

diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index f5e8d0d..5c66c6e 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -3506,7 +3506,8 @@  gfc_arglist_matches_symbol (gfc_actual_arglist** args, gfc_symbol* sym)
   gfc_formal_arglist *dummy_args;
   bool r;
 
-  gcc_assert (sym->attr.flavor == FL_PROCEDURE);
+  if (sym->attr.flavor != FL_PROCEDURE)
+    return false;
 
   dummy_args = gfc_sym_get_dummy_args (sym);
 
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 64d59ce..f197ca0 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -2565,8 +2565,13 @@  generic:
      that possesses a matching interface.  14.1.2.4  */
   if (sym  && !intr && !gfc_is_intrinsic (sym, 0, expr->where))
     {
-      gfc_error ("There is no specific function for the generic %qs "
-		 "at %L", expr->symtree->n.sym->name, &expr->where);
+      if (gfc_init_expr_flag)
+	gfc_error ("Function %qs in initialization expression at %L "
+		   "must be an intrinsic function",
+		   expr->symtree->n.sym->name, &expr->where);
+      else
+	gfc_error ("There is no specific function for the generic %qs "
+		   "at %L", expr->symtree->n.sym->name, &expr->where);
       return false;
     }
 
diff --git a/gcc/testsuite/gfortran.dg/interface_38.f90 b/gcc/testsuite/gfortran.dg/interface_38.f90
new file mode 100644
index 0000000..d8f42ee
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/interface_38.f90
@@ -0,0 +1,16 @@ 
+! { dg-do compile }
+! PR69397
+program p
+   interface f
+      procedure f1 ! { dg-error "neither function nor subroutine" }
+      !... more
+   end interface
+   integer, allocatable :: z
+   print *, f(z) ! { dg-error "no specific function" }
+contains
+   integer function f2 (x)
+      integer, allocatable :: x
+      f2 = 1
+   end
+end
+
diff --git a/gcc/testsuite/gfortran.dg/interface_39.f90 b/gcc/testsuite/gfortran.dg/interface_39.f90
new file mode 100644
index 0000000..0d6a38e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/interface_39.f90
@@ -0,0 +1,14 @@ 
+! { dg-do compile }
+! PR68442
+module m
+   interface gkind
+      procedure g
+   end interface
+contains
+   subroutine f(x)
+      character(kind=gkind()) :: x ! { dg-error "must be an intrinsic" }
+   end
+   integer function g()
+      g = 1
+   end
+end