re PR fortran/24784 (Warning about unused routine argument should not read "unused variable")
gcc: 2007-07-08 Daniel Franke <franke.daniel@gmail.com> * function.c (do_warn_unused_parameter): Do not warn if TREE_NO_WARNING is set. gcc/fortran: 2007-07-08 Daniel Franke <franke.daniel@gmail.com> PR fortran/24784 PR fortran/28004 * trans-decl.c (generate_local_decl): Adjusted warning on unused dummy arguments, tell middle-end not to emit additional warnings. From-SVN: r126471
This commit is contained in:
parent
833be2294d
commit
534fd53491
|
@ -1,3 +1,8 @@
|
||||||
|
2007-07-08 Daniel Franke <franke.daniel@gmail.com>
|
||||||
|
|
||||||
|
* function.c (do_warn_unused_parameter): Do not warn if
|
||||||
|
TREE_NO_WARNING is set.
|
||||||
|
|
||||||
2007-07-08 Andreas Schwab <schwab@suse.de>
|
2007-07-08 Andreas Schwab <schwab@suse.de>
|
||||||
|
|
||||||
* doc/invoke.texi (DEC Alpha/VMS Options): Fix typo.
|
* doc/invoke.texi (DEC Alpha/VMS Options): Fix typo.
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
2007-07-08 Daniel Franke <franke.daniel@gmail.com>
|
||||||
|
|
||||||
|
PR fortran/24784
|
||||||
|
PR fortran/28004
|
||||||
|
* trans-decl.c (generate_local_decl): Adjusted warning on unused
|
||||||
|
dummy arguments, tell middle-end not to emit additional warnings.
|
||||||
|
|
||||||
2007-07-08 Daniel Franke <franke.daniel@gmail.com>
|
2007-07-08 Daniel Franke <franke.daniel@gmail.com>
|
||||||
Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
|
Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
|
||||||
|
|
||||||
|
|
|
@ -3000,14 +3000,21 @@ generate_local_decl (gfc_symbol * sym)
|
||||||
|
|
||||||
if (sym->attr.referenced)
|
if (sym->attr.referenced)
|
||||||
gfc_get_symbol_decl (sym);
|
gfc_get_symbol_decl (sym);
|
||||||
else if (sym->attr.dummy && warn_unused_parameter)
|
/* INTENT(out) dummy arguments are likely meant to be set. */
|
||||||
gfc_warning ("Unused parameter %s declared at %L", sym->name,
|
else if (warn_unused_variable
|
||||||
|
&& sym->attr.dummy
|
||||||
|
&& sym->attr.intent == INTENT_OUT)
|
||||||
|
gfc_warning ("dummy argument '%s' at %L was declared INTENT(OUT) but was not set",
|
||||||
|
sym->name, &sym->declared_at);
|
||||||
|
/* Specific warning for unused dummy arguments. */
|
||||||
|
else if (warn_unused_variable && sym->attr.dummy)
|
||||||
|
gfc_warning ("unused dummy argument '%s' at %L", sym->name,
|
||||||
&sym->declared_at);
|
&sym->declared_at);
|
||||||
/* Warn for unused variables, but not if they're inside a common
|
/* Warn for unused variables, but not if they're inside a common
|
||||||
block or are use-associated. */
|
block or are use-associated. */
|
||||||
else if (warn_unused_variable
|
else if (warn_unused_variable
|
||||||
&& !(sym->attr.in_common || sym->attr.use_assoc))
|
&& !(sym->attr.in_common || sym->attr.use_assoc))
|
||||||
gfc_warning ("Unused variable %s declared at %L", sym->name,
|
gfc_warning ("unused variable '%s' declared at %L", sym->name,
|
||||||
&sym->declared_at);
|
&sym->declared_at);
|
||||||
/* For variable length CHARACTER parameters, the PARM_DECL already
|
/* For variable length CHARACTER parameters, the PARM_DECL already
|
||||||
references the length variable, so force gfc_get_symbol_decl
|
references the length variable, so force gfc_get_symbol_decl
|
||||||
|
@ -3022,6 +3029,11 @@ generate_local_decl (gfc_symbol * sym)
|
||||||
sym->attr.referenced = 1;
|
sym->attr.referenced = 1;
|
||||||
gfc_get_symbol_decl (sym);
|
gfc_get_symbol_decl (sym);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sym->attr.dummy == 1)
|
if (sym->attr.dummy == 1)
|
||||||
|
|
|
@ -4287,7 +4287,8 @@ do_warn_unused_parameter (tree fn)
|
||||||
for (decl = DECL_ARGUMENTS (fn);
|
for (decl = DECL_ARGUMENTS (fn);
|
||||||
decl; decl = TREE_CHAIN (decl))
|
decl; decl = TREE_CHAIN (decl))
|
||||||
if (!TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL
|
if (!TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL
|
||||||
&& DECL_NAME (decl) && !DECL_ARTIFICIAL (decl))
|
&& DECL_NAME (decl) && !DECL_ARTIFICIAL (decl)
|
||||||
|
&& !TREE_NO_WARNING (decl))
|
||||||
warning (OPT_Wunused_parameter, "unused parameter %q+D", decl);
|
warning (OPT_Wunused_parameter, "unused parameter %q+D", decl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue