2012-11-26 Janus Weil <janus@gcc.gnu.org>
+ PR fortran/54997
+ * decl.c (match_procedure_decl): Don't set 'referenced' attribute
+ for PROCEDURE declarations.
+ * parse.c (gfc_fixup_sibling_symbols,parse_contained): Don't set
+ 'referenced' attribute for all contained procedures.
+ * trans-decl.c (gfc_get_symbol_decl): Allow for unreferenced procedures.
+ (build_function_decl): Set TREE_USED for referenced procedures.
+
+2012-11-26 Janus Weil <janus@gcc.gnu.org>
+
PR fortran/54881
* match.c (select_derived_set_tmp,select_class_set_tmp): Removed and
unified into ...
}
- gfc_set_sym_referenced (sym);
-
if (gfc_match_eos () == MATCH_YES)
return MATCH_YES;
if (gfc_match_char (',') != MATCH_YES)
gfc_symtree *st;
gfc_symbol *old_sym;
- sym->attr.referenced = 1;
for (ns = siblings; ns; ns = ns->sibling)
{
st = gfc_find_symtree (ns->sym_root, sym->name);
/* Mark this as a contained function, so it isn't replaced
by other module functions. */
sym->attr.contained = 1;
- sym->attr.referenced = 1;
/* Set implicit_pure so that it can be reset if any of the
tests for purity fail. This is used for some optimisation
bool intrinsic_array_parameter = false;
gcc_assert (sym->attr.referenced
- || sym->attr.use_assoc
- || sym->ns->proc_name->attr.if_source == IFSRC_IFBODY
- || (sym->module && sym->attr.if_source != IFSRC_DECL
- && sym->backend_decl));
+ || sym->attr.flavor == FL_PROCEDURE
+ || sym->attr.use_assoc
+ || sym->ns->proc_name->attr.if_source == IFSRC_IFBODY
+ || (sym->module && sym->attr.if_source != IFSRC_DECL
+ && sym->backend_decl));
if (sym->ns && sym->ns->proc_name && sym->ns->proc_name->attr.function)
byref = gfc_return_by_reference (sym->ns->proc_name);
|| sym->attr.public_used))
TREE_PUBLIC (fndecl) = 1;
+ if (sym->attr.referenced || sym->attr.entry_master)
+ TREE_USED (fndecl) = 1;
+
attributes = add_attributes_to_decl (attr, NULL_TREE);
decl_attributes (&fndecl, attributes, 0);
2012-11-26 Janus Weil <janus@gcc.gnu.org>
+ PR fortran/54997
+ * gfortran.dg/warn_unused_function_2.f90: New.
+
+2012-11-26 Janus Weil <janus@gcc.gnu.org>
+
PR fortran/54881
* gfortran.dg/associated_6.f90: New.
* gfortran.dg/select_type_30.f03: New.
--- /dev/null
+! { dg-do compile }
+! { dg-options "-Wall" }
+!
+! [4.8 Regression] PR 54997: -Wunused-function gives false warnings
+!
+! Contributed by Janus Weil <janus@gcc.gnu.org>
+
+module m
+
+ implicit none
+ private :: s1,s2,s3
+
+contains
+
+ subroutine s1 ! { dg-warning "defined but not used" }
+ call s2(s3)
+ end subroutine
+
+ subroutine s2(dummy) ! { dg-warning "Unused dummy argument" }
+ procedure() :: dummy
+ end subroutine
+
+ subroutine s3()
+ end subroutine
+
+end module
+
+
+subroutine sub
+entry en
+end subroutine
+
+
+! { dg-final { cleanup-modules "m" } }