OSDN Git Service

2006-12-31 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 31 Dec 2006 07:51:47 +0000 (07:51 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 31 Dec 2006 07:51:47 +0000 (07:51 +0000)
PR fortran/27900
* resolve.c (resolve_actual_arglist): If all else fails and a
procedure actual argument has no type, see if a specific
intrinsic matches.

PR fortran/24325
* resolve.c (resolve_function): If the function reference is
FL_VARIABLE this is an error.

2006-12-31  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/27900
* gfortran.dg/intrinsic_actual_4.f90: New test.

PR fortran/24325
* gfortran.dg/func_decl_3.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120296 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/func_decl_3.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/intrinsic_actual_4.f90 [new file with mode: 0644]

index 7aa22fe..de32f26 100644 (file)
@@ -1,5 +1,16 @@
 2006-12-31  Paul Thomas  <pault@gcc.gnu.org>
 
+       PR fortran/27900
+       * resolve.c (resolve_actual_arglist): If all else fails and a
+       procedure actual argument has no type, see if a specific
+       intrinsic matches.
+
+       PR fortran/24325
+       * resolve.c (resolve_function): If the function reference is
+       FL_VARIABLE this is an error.
+
+2006-12-31  Paul Thomas  <pault@gcc.gnu.org>
+
        PR fortran/23060
        * intrinsic.c (compare_actual_formal ): Distinguish argument
        list functions from keywords.
index 1b46a10..ba547f2 100644 (file)
@@ -140,6 +140,21 @@ resolve_formal_arglist (gfc_symbol * proc)
              continue;
            }
 
+         if (sym->attr.function
+               && sym->ts.type == BT_UNKNOWN
+               && sym->attr.intrinsic)
+           {
+             gfc_intrinsic_sym *isym;
+             isym = gfc_find_function (sym->name);
+             if (isym == NULL || !isym->specific)
+               {
+                 gfc_error ("Unable to find a specific INTRINSIC procedure "
+                            "for the reference '%s' at %L", sym->name,
+                            &sym->declared_at);
+               }
+             sym->ts = isym->ts;
+           }
+
          continue;
        }
 
@@ -937,6 +952,21 @@ resolve_actual_arglist (gfc_actual_arglist * arg, procedure_type ptype)
                      && sym->ns->parent->proc_name == sym)))
            goto got_variable;
 
+         /* If all else fails, see if we have a specific intrinsic.  */
+         if (sym->attr.function
+               && sym->ts.type == BT_UNKNOWN
+               && sym->attr.intrinsic)
+           {
+             gfc_intrinsic_sym *isym;
+             isym = gfc_find_function (sym->name);
+             if (isym == NULL || !isym->specific)
+               {
+                 gfc_error ("Unable to find a specific INTRINSIC procedure "
+                            "for the reference '%s' at %L", sym->name,
+                            &e->where);
+               }
+             sym->ts = isym->ts;
+           }
          goto argument_list;
        }
 
@@ -1512,6 +1542,13 @@ resolve_function (gfc_expr * expr)
   if (expr->symtree)
     sym = expr->symtree->n.sym;
 
+  if (sym && sym->attr.flavor == FL_VARIABLE)
+    {
+      gfc_error ("'%s' at %L is not a function",
+                sym->name, &expr->where);
+      return FAILURE;
+    }
+
   /* If the procedure is not internal, a statement function or a module
      procedure,it must be external and should be checked for usage.  */
   if (sym && !sym->attr.dummy && !sym->attr.contained
index 5ba52ba..564312d 100644 (file)
@@ -1,5 +1,13 @@
 2006-12-31  Paul Thomas  <pault@gcc.gnu.org>
 
+       PR fortran/27900
+       * gfortran.dg/intrinsic_actual_4.f90: New test.
+
+       PR fortran/24325
+       * gfortran.dg/func_decl_3.f90: New test.
+
+2006-12-31  Paul Thomas  <pault@gcc.gnu.org>
+
        PR fortran/23060
        * gfortran.dg/c_by_val.c: Called by c_by_val_1.f.
        * gfortran.dg/c_by_val_1.f: New test.
diff --git a/gcc/testsuite/gfortran.dg/func_decl_3.f90 b/gcc/testsuite/gfortran.dg/func_decl_3.f90
new file mode 100644 (file)
index 0000000..4e458f4
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! Tests the fix for PR24325 in which the lack of any declaration
+! that foo is a function or even a procedure was not detected.
+!
+! Contributed by Jakub Jelinek <jakub@gcc.gnu.org>
+!
+  integer foo
+  call test
+contains
+  subroutine test
+    integer :: i
+    i = foo () ! { dg-error "is not a function" }
+  end subroutine test
+end
+
diff --git a/gcc/testsuite/gfortran.dg/intrinsic_actual_4.f90 b/gcc/testsuite/gfortran.dg/intrinsic_actual_4.f90
new file mode 100644 (file)
index 0000000..4ba4b79
--- /dev/null
@@ -0,0 +1,18 @@
+! { dg-do run }
+! Tests the fix for PR27900, in which an ICE would be caused because
+! the actual argument LEN had no type.
+!
+! Contributed by Klaus Ramstöck <klra67@freenet.de>
+!
+      subroutine sub (proc, chr)
+      external proc
+      integer proc
+      character*(*) chr
+      if (proc (chr) .ne. 6) call abort ()
+      end subroutine sub
+
+      implicit none
+      integer i
+      i = len ("123")
+      call sub (len, "abcdef")
+      end