diff options
| author | pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-04-07 20:20:49 +0000 |
|---|---|---|
| committer | pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-04-07 20:20:49 +0000 |
| commit | 06d9158a95b64d705ebcf5a57fefd3d4cbe96273 (patch) | |
| tree | 390ae9fd0c3cb23aef9e2c93b81cc77d712c715e | |
| parent | d0f6ad221bbc8263318fe77adbbb253924f4831a (diff) | |
| download | ppe42-gcc-06d9158a95b64d705ebcf5a57fefd3d4cbe96273.tar.gz ppe42-gcc-06d9158a95b64d705ebcf5a57fefd3d4cbe96273.zip | |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123643 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
| -rw-r--r-- | gcc/fortran/check.c | 12 | ||||
| -rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
| -rw-r--r-- | gcc/testsuite/gfortran.dg/default_numeric_type_1.f90 | 18 |
4 files changed, 41 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2079580daa7..a9a8a07f491 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,11 @@ 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 * trans-decl.c (gfc_get_symbol_decl): Allow unreferenced use associated symbols. diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 3b1a1a05f47..9806ebdf79a 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8bb09344004..df1d06aab23 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 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 * gfortran.dg/unreferenced_use_assoc_1.f90: New test. 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 index 00000000000..e8f8d350736 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/default_numeric_type_1.f90 @@ -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 |

