PR fortran/30239
* symbol.c (gfc_add_type): Warn on -Wsurprising if a function-result
type is re-declared but neither -pedantic nor -std=f* is given and so
this is no error.
* invoke.texi (-Wsurprising): Document this new behaviour.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139499
138bc75d-0d04-0410-961f-
82ee72b054a4
2008-08-22 Daniel Kraft <d@domob.eu>
+ PR fortran/30239
+ * symbol.c (gfc_add_type): Warn on -Wsurprising if a function-result
+ type is re-declared but neither -pedantic nor -std=f* is given and so
+ this is no error.
+ * invoke.texi (-Wsurprising): Document this new behaviour.
+
+2008-08-22 Daniel Kraft <d@domob.eu>
+
* gfortran.h (in_prefix): Removed from this header.
* match.h (gfc_matching_prefix): Moved and renamed from `in_prefix'.
* decl.c (in_prefix): Removed from here.
@item
A TRANSFER specifies a source that is shorter than the destination.
+
+@item
+The type of a function result is declared more than once with the same type. If
+@option{-pedantic} or standard-conforming mode is enabled, this is an error.
@end itemize
@item -Wtabs
gfc_error (msg, sym->name, where, gfc_basic_typename (sym->ts.type));
return FAILURE;
}
- else if (gfc_notify_std (GFC_STD_GNU, msg, sym->name, where,
- gfc_basic_typename (sym->ts.type)) == FAILURE)
+ if (gfc_notify_std (GFC_STD_GNU, msg, sym->name, where,
+ gfc_basic_typename (sym->ts.type)) == FAILURE)
return FAILURE;
+ if (gfc_option.warn_surprising)
+ gfc_warning (msg, sym->name, where, gfc_basic_typename (sym->ts.type));
}
flavor = sym->attr.flavor;
+2008-08-22 Daniel Kraft <d@domob.eu>
+
+ PR fortran/30239
+ * gfortran.dg/duplicate_type_1.f90: New test.
+ * gfortran.dg/duplicate_type_2.f90: New test.
+
2008-08-22 Uros Bizjak <ubizjak@gmail.com>
* gcc.dg/tree-ssa/pr21658.c (dg-options): Use -fdump-tree-ccp1-details.
--- /dev/null
+! { dg-do compile }
+! { dg-options "-std=f95" }
+
+! PR fortran/30239
+! Check for errors when a symbol gets declared a type twice, even if it
+! is the same.
+
+INTEGER FUNCTION foo ()
+ IMPLICIT NONE
+ INTEGER :: foo ! { dg-error "basic type of" }
+ INTEGER :: foo ! { dg-error "basic type of" }
+ foo = 42
+END FUNCTION foo
+
+INTEGER FUNCTION bar () RESULT (x)
+ IMPLICIT NONE
+ INTEGER :: x ! { dg-error "basic type of" }
+
+ INTEGER :: y
+ INTEGER :: y ! { dg-error "basic type of" }
+
+ x = 42
+END FUNCTION bar
--- /dev/null
+! { dg-do compile }
+! { dg-options "-std=gnu -Wsurprising" }
+
+! PR fortran/30239
+! Check for errors when a symbol gets declared a type twice, even if it
+! is the same.
+
+INTEGER FUNCTION foo ()
+ IMPLICIT NONE
+ INTEGER :: foo ! { dg-warning "basic type of" }
+ INTEGER :: foo ! { dg-warning "basic type of" }
+ foo = 42
+END FUNCTION foo
+
+INTEGER FUNCTION bar () RESULT (x)
+ IMPLICIT NONE
+ INTEGER :: x ! { dg-warning "basic type of" }
+
+ INTEGER :: y
+ INTEGER :: y ! { dg-error "basic type of" }
+
+ x = 42
+END FUNCTION bar