* gcc.dg/unused-6.c: New test.
PR c/15004
* function.c (do_warn_unused_parameter): Break out form ...
(expand_function_end): ... here; warn only when not using cgraphunit.
* function.h (do_warn_unused_parameter): Declare.
* cgraphunit.c: Include function.h.
(cgraph_finalize_function): Do unused parameter warning.
* Makefile.in (cgraphunit.o): Depend on function.h
From-SVN: r81260
+2004-04-28 Jan Hubicka <jh@suse.cz>
+
+ PR c/15004
+ * function.c (do_warn_unused_parameter): Break out form ...
+ (expand_function_end): ... here; warn only when not using cgraphunit.
+ * function.h (do_warn_unused_parameter): Declare.
+ * cgraphunit.c: Include function.h.
+ (cgraph_finalize_function): Do unused parameter warning.
+ * Makefile.in (cgraphunit.o): Depend on function.h
+
2004-04-28 Joseph S. Myers <jsm@polyomino.org.uk>
* Makefile.in ($(DESTDIR)$(infodir)/%.info): Don't condition
langhooks.h toplev.h flags.h $(GGC_H) $(TARGET_H) cgraph.h gt-cgraph.h \
output.h intl.h
cgraphunit.o : cgraphunit.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
- langhooks.h tree-inline.h toplev.h flags.h $(GGC_H) $(TARGET_H) cgraph.h intl.h
+ langhooks.h tree-inline.h toplev.h flags.h $(GGC_H) $(TARGET_H) cgraph.h intl.h \
+ function.h
coverage.o : coverage.c gcov-io.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(RTL_H) $(TREE_H) flags.h output.h $(REGS_H) $(EXPR_H) function.h \
toplev.h $(GGC_H) $(TARGET_H) langhooks.h $(COVERAGE_H) libfuncs.h \
#include "fibheap.h"
#include "c-common.h"
#include "intl.h"
+#include "function.h"
#define INSNS_PER_CALL 10
early then. */
if (DECL_EXTERNAL (decl))
DECL_STRUCT_FUNCTION (decl) = NULL;
+
+ /* Possibly warn about unused parameters. */
+ if (warn_unused_parameter)
+ do_warn_unused_parameter (decl);
}
/* Walk tree and record all calls. Called via walk_tree. */
diddle_return_value (do_use_return_reg, NULL);
}
+/* Possibly warn about unused parameters. */
+void
+do_warn_unused_parameter (tree fn)
+{
+ tree decl;
+
+ for (decl = DECL_ARGUMENTS (fn);
+ decl; decl = TREE_CHAIN (decl))
+ if (!TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL
+ && DECL_NAME (decl) && !DECL_ARTIFICIAL (decl))
+ warning ("%Junused parameter '%D'", decl, decl);
+}
+
static GTY(()) rtx initial_trampoline;
/* Generate RTL for the end of the current function. */
}
}
- /* Possibly warn about unused parameters. */
- if (warn_unused_parameter)
- {
- tree decl;
-
- for (decl = DECL_ARGUMENTS (current_function_decl);
- decl; decl = TREE_CHAIN (decl))
- if (! TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL
- && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl))
- warning ("%Junused parameter '%D'", decl, decl);
- }
+ /* Possibly warn about unused parameters.
+ When frontend does unit-at-a-time, the warning is already
+ issued at finalization time. */
+ if (warn_unused_parameter
+ && !lang_hooks.callgraph.expand_function)
+ do_warn_unused_parameter (current_function_decl);
/* Delete handlers for nonlocal gotos if nothing uses them. */
if (nonlocal_goto_handler_slots != 0
/* Called once, at initialization, to initialize function.c. */
extern void init_function_once (void);
+extern void do_warn_unused_parameter (tree);
+
#endif /* GCC_FUNCTION_H */
+2004-04-28 Jan Hubicka <jh@suse.cz>
+
+ * gcc.dg/unused-6.c: New test.
+
2004-04-24 Laurent GUERBY <laurent@guerby.net>
Ulrich Weigand <uweigand@de.ibm.com>
--- /dev/null
+
+/* { dg-do compile } */
+/* { dg-options "-O3 -Wunused-parameter" } */
+static int t(int i) /* { dg-warning "unused parameter" "unused parameter warning" } */
+{
+ return 0;
+}
+int tt()
+{
+ return t(0);
+}