re PR fortran/31222 (Rejected: implicitly-typed dummys used in initialization express...
authorPaul Thomas <pault@gcc.gnu.org>
Sat, 7 Apr 2007 20:20:49 +0000 (20:20 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Sat, 7 Apr 2007 20:20:49 +0000 (20:20 +0000)
2007-04-07  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/31222
* check.c (numeric_check): If an expresson has not got a type,
see if it is a symbol for which a default type applies.

2007-04-07  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/31222
* gfortran.dg/default_numeric_type_1.f90: New test.

From-SVN: r123643

gcc/fortran/ChangeLog
gcc/fortran/check.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/default_numeric_type_1.f90 [new file with mode: 0644]

index 2079580daa7d2877c1a1167ac900f22dfcb6115b..a9a8a07f4915ae02022a04680232444de675ea1d 100644 (file)
@@ -1,3 +1,9 @@
+2007-04-07  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/31222
+       * check.c (numeric_check): If an expresson has not got a type,
+       see if it is a symbol for which a default type applies.
+
 2007-04-07  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/31214
index 3b1a1a05f47b8dfdc54bf29719aab2707488c76e..9806ebdf79aacecd7d410e20fe69520bfd2d1aca 100644 (file)
@@ -58,6 +58,18 @@ numeric_check (gfc_expr *e, int n)
   if (gfc_numeric_ts (&e->ts))
     return SUCCESS;
 
+  /* If the expression has not got a type, check if its namespace can
+     offer a default type.  */
+  if ((e->expr_type == EXPR_VARIABLE || e->expr_type == EXPR_VARIABLE)
+       && e->symtree->n.sym->ts.type == BT_UNKNOWN
+       && gfc_set_default_type (e->symtree->n.sym, 0,
+                                e->symtree->n.sym->ns) == SUCCESS
+       && gfc_numeric_ts (&e->symtree->n.sym->ts))
+    {
+      e->ts = e->symtree->n.sym->ts;
+      return SUCCESS;
+    }
+
   gfc_error ("'%s' argument of '%s' intrinsic at %L must be a numeric type",
             gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &e->where);
 
index 8bb09344004e1e6bc80c2d3344ab84aa399681c7..df1d06aab2364a12e92aeb1d6daf7ad4349eaf23 100644 (file)
@@ -1,3 +1,8 @@
+2007-04-07  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/31222
+       * gfortran.dg/default_numeric_type_1.f90: New test.
+
 2007-04-07  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/31424
diff --git a/gcc/testsuite/gfortran.dg/default_numeric_type_1.f90 b/gcc/testsuite/gfortran.dg/default_numeric_type_1.f90
new file mode 100644 (file)
index 0000000..e8f8d35
--- /dev/null
@@ -0,0 +1,18 @@
+! { dg-do compile}
+! { dg-options "-fdump-tree-original" }
+! Tests the fix for PR 31222, in which the type of the arguments of abs
+! and int below were not detected to be of default numeric type..
+!
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+!
+subroutine mysub1(a,b,mode,dis)
+!  integer :: mode
+!  real :: dis
+  dimension a(abs(mode)),b(int(dis))
+  print *, mod
+  write (*,*) abs(mode), nint(dis)
+end subroutine
+
+program testprog
+  call mysub1((/1.,2./),(/1.,2.,3./),-2, 3.2)
+end