diff options
author | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-11 20:44:30 +0000 |
---|---|---|
committer | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-11 20:44:30 +0000 |
commit | 90a4a5a6078ef29b9b093bc78dac9e84cdab419d (patch) | |
tree | 207d5e05ed7e52f0e75ae49f210c3683e67ee978 | |
parent | fd23cc08b8e00c13605b9c13b35b07c8b89c7f6b (diff) | |
download | gcc-90a4a5a6078ef29b9b093bc78dac9e84cdab419d.tar.gz |
2011-12-11 Tobias Burnus <burnus@net-b.de>
PR fortran/50923
* trans-decl.c (generate_local_decl): Set TREE_NO_WARNING only
if the front end has printed a warning.
(gfc_generate_function_code): Fix unset-result warning.
2011-12-11 Tobias Burnus <burnus@net-b.de>
PR fortran/50923
* gfortran.dg/warn_function_without_result_2.f90: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182211 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/fortran/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/fortran/trans-decl.c | 35 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/warn_function_without_result_2.f90 | 19 |
4 files changed, 54 insertions, 14 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c87daeb7df1..2cab0db376c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2011-12-11 Tobias Burnus <burnus@net-b.de> + + PR fortran/50923 + * trans-decl.c (generate_local_decl): Set TREE_NO_WARNING only + if the front end has printed a warning. + (gfc_generate_function_code): Fix unset-result warning. + 2011-12-11 Paul Thomas <pault@gcc.gnu.org> Tobias Burnus <burnus@gcc.gnu.org> @@ -24,7 +31,7 @@ elemental procedure call retain the ss to provide the scalarized array reference. Moved in file. (gfc_conv_class_to_class): New function. - (gfc_conv_subref_array_arg): Use the type of the + (gfc_conv_subref_array_arg): Use the type of the class _data component as a basetype. (gfc_conv_procedure_call): Ensure that class array expressions have both the _data reference and an array reference. Use diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 1f1696feaf2..9733a6f94a0 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -4544,10 +4544,16 @@ generate_local_decl (gfc_symbol * sym) "declared INTENT(OUT) but was not set and " "does not have a default initializer", sym->name, &sym->declared_at); + if (sym->backend_decl != NULL_TREE) + TREE_NO_WARNING(sym->backend_decl) = 1; } else if (gfc_option.warn_unused_dummy_argument) - gfc_warning ("Unused dummy argument '%s' at %L", sym->name, + { + gfc_warning ("Unused dummy argument '%s' at %L", sym->name, &sym->declared_at); + if (sym->backend_decl != NULL_TREE) + TREE_NO_WARNING(sym->backend_decl) = 1; + } } /* Warn for unused variables, but not if they're inside a common @@ -4555,11 +4561,19 @@ generate_local_decl (gfc_symbol * sym) else if (warn_unused_variable && !(sym->attr.in_common || sym->attr.use_assoc || sym->mark || sym->attr.in_namelist)) - gfc_warning ("Unused variable '%s' declared at %L", sym->name, - &sym->declared_at); + { + gfc_warning ("Unused variable '%s' declared at %L", sym->name, + &sym->declared_at); + if (sym->backend_decl != NULL_TREE) + TREE_NO_WARNING(sym->backend_decl) = 1; + } else if (warn_unused_variable && sym->attr.use_only) - gfc_warning ("Unused module variable '%s' which has been explicitly " - "imported at %L", sym->name, &sym->declared_at); + { + gfc_warning ("Unused module variable '%s' which has been explicitly " + "imported at %L", sym->name, &sym->declared_at); + if (sym->backend_decl != NULL_TREE) + TREE_NO_WARNING(sym->backend_decl) = 1; + } /* For variable length CHARACTER parameters, the PARM_DECL already references the length variable, so force gfc_get_symbol_decl @@ -4595,11 +4609,6 @@ generate_local_decl (gfc_symbol * sym) mark the symbol now, as well as in traverse_ns, to prevent getting stuck in a circular dependency. */ sym->mark = 1; - - /* We do not want the middle-end to warn about unused parameters - as this was already done above. */ - if (sym->attr.dummy && sym->backend_decl != NULL_TREE) - TREE_NO_WARNING(sym->backend_decl) = 1; } else if (sym->attr.flavor == FL_PARAMETER) { @@ -5323,11 +5332,11 @@ gfc_generate_function_code (gfc_namespace * ns) if (result == NULL_TREE) { /* TODO: move to the appropriate place in resolve.c. */ - if (warn_return_type && !sym->attr.referenced && sym == sym->result) + if (warn_return_type && sym == sym->result) gfc_warning ("Return value of function '%s' at %L not set", sym->name, &sym->declared_at); - - TREE_NO_WARNING(sym->backend_decl) = 1; + if (warn_return_type) + TREE_NO_WARNING(sym->backend_decl) = 1; } else gfc_add_expr_to_block (&body, gfc_generate_return ()); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b46988bd392..750983887a6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-12-11 Tobias Burnus <burnus@net-b.de> + + PR fortran/50923 + * gfortran.dg/warn_function_without_result_2.f90: New. + 2011-12-11 Paul Thomas <pault@gcc.gnu.org> Tobias Burnus <burnus@gcc.gnu.org> diff --git a/gcc/testsuite/gfortran.dg/warn_function_without_result_2.f90 b/gcc/testsuite/gfortran.dg/warn_function_without_result_2.f90 new file mode 100644 index 00000000000..25fd0b73a75 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/warn_function_without_result_2.f90 @@ -0,0 +1,19 @@ +! { dg-do compile } +! { dg-options "-Wall" } +! +! PR fortran/50923 +! +module m +contains + integer pure function f() ! { dg-warning "Return value of function 'f' at .1. not set" } + end function f + integer pure function g() result(h) ! { dg-warning "Return value 'h' of function 'g' declared at .1. not set" } + end function g + integer pure function i() + i = 7 + end function i + integer pure function j() result(k) + k = 8 + end function j +end module m +! { dg-final { cleanup-modules "mod" } } |