This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] Fix excess errors with missing implicit types
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: GCC Fortran mailing list <fortran at gcc dot gnu dot org>,patch <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 12 Feb 2005 16:17:35 +0100
- Subject: [gfortran] Fix excess errors with missing implicit types
If there's no implicit type for a symbol, we'd give an error everytime the
symbol is accessed. This small patch fixes this by recording the fact that no
implicit type could be determined for a symbol and checking for this before
issuing an error.
Bubblestrapped and regtested on i686-pc-linux, inspired by similar code in
g95. I will add the attached testcase to the testsuite alongside with this. Ok?
Before the patch the testcase gives:
---------
In file deftype.f90:3
dimension i(10) ! { dg-error "has no IMPLICIT type" }
1
Error: Symbol 'i' at (1) has no IMPLICIT type
In file deftype.f90:3
dimension i(10) ! { dg-error "has no IMPLICIT type" }
1
Error: Symbol 'i' at (1) has no IMPLICIT type
---------
With the patch, the error is only issued a single time.
- Tobi
2005-02-12 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
* gfortran.h (symbol_attribute): New 'untyped' field, fix comment
formatting.
* symbol.c (gfc_set_default_type): Issue error only once, by setting
and checking 'untyped' attribute.
Index: gfortran.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/gfortran.h,v
retrieving revision 1.52
diff -u -p -r1.52 gfortran.h
--- gfortran.h 7 Feb 2005 22:16:13 -0000 1.52
+++ gfortran.h 12 Feb 2005 15:11:01 -0000
@@ -408,7 +408,8 @@ typedef struct
unsigned in_namelist:1, in_common:1;
unsigned function:1, subroutine:1, generic:1;
- unsigned implicit_type:1; /* Type defined via implicit rules */
+ unsigned implicit_type:1; /* Type defined via implicit rules. */
+ unsigned untyped:1; /* No implicit type could be found. */
/* Function/subroutine attributes */
unsigned sequence:1, elemental:1, pure:1, recursive:1;
Index: symbol.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/symbol.c,v
retrieving revision 1.19
diff -u -p -r1.19 symbol.c
--- symbol.c 7 Feb 2005 22:16:13 -0000 1.19
+++ symbol.c 12 Feb 2005 15:11:02 -0000
@@ -214,9 +214,12 @@ gfc_set_default_type (gfc_symbol * sym,
if (ts->type == BT_UNKNOWN)
{
- if (error_flag)
- gfc_error ("Symbol '%s' at %L has no IMPLICIT type", sym->name,
- &sym->declared_at);
+ if (error_flag && !sym->attr.untyped)
+ {
+ gfc_error ("Symbol '%s' at %L has no IMPLICIT type",
+ sym->name, &sym->declared_at);
+ sym->attr.untyped = 1; /* Ensure we only give an error once. */
+ }
return FAILURE;
}
! { dg-do compile }
! Checks for excess errors.
implicit none
dimension i(10) ! { dg-error "has no IMPLICIT type" }
i = 2
end