Commit fee3292b by Daniel Kraft Committed by Daniel Kraft

re PR fortran/30239 (duplicate data type assignment not detected)

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.

From-SVN: r139499
parent 9b410dd0
2008-08-22 Daniel Kraft <d@domob.eu> 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. * gfortran.h (in_prefix): Removed from this header.
* match.h (gfc_matching_prefix): Moved and renamed from `in_prefix'. * match.h (gfc_matching_prefix): Moved and renamed from `in_prefix'.
* decl.c (in_prefix): Removed from here. * decl.c (in_prefix): Removed from here.
......
...@@ -757,6 +757,10 @@ A LOGICAL SELECT construct has three CASE statements. ...@@ -757,6 +757,10 @@ A LOGICAL SELECT construct has three CASE statements.
@item @item
A TRANSFER specifies a source that is shorter than the destination. 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 @end itemize
@item -Wtabs @item -Wtabs
......
...@@ -1540,9 +1540,11 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where) ...@@ -1540,9 +1540,11 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where)
gfc_error (msg, sym->name, where, gfc_basic_typename (sym->ts.type)); gfc_error (msg, sym->name, where, gfc_basic_typename (sym->ts.type));
return FAILURE; return FAILURE;
} }
else if (gfc_notify_std (GFC_STD_GNU, msg, sym->name, where, if (gfc_notify_std (GFC_STD_GNU, msg, sym->name, where,
gfc_basic_typename (sym->ts.type)) == FAILURE) gfc_basic_typename (sym->ts.type)) == FAILURE)
return FAILURE; return FAILURE;
if (gfc_option.warn_surprising)
gfc_warning (msg, sym->name, where, gfc_basic_typename (sym->ts.type));
} }
flavor = sym->attr.flavor; 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> 2008-08-22 Uros Bizjak <ubizjak@gmail.com>
* gcc.dg/tree-ssa/pr21658.c (dg-options): Use -fdump-tree-ccp1-details. * gcc.dg/tree-ssa/pr21658.c (dg-options): Use -fdump-tree-ccp1-details.
......
! { 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
! { 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment