c-common.c: Include intl.h.

* c-common.c: Include intl.h.
	(shadow_warning): Rewrite to allow better diagnostic translations.
	* c-common.h: Update prototype of shadow_warning.  Declare sw_kind enum.
	* c-decl.c (warn_if_shadowing): Update calls to shadow_warning;
	use it throughout.
	* Makefile.in (c-common.o): Add intl.h.
cp:
	* decl.c: Update calls to shadow_warning.
po:
	* gcc.pot: Regenerate.

From-SVN: r64699
This commit is contained in:
Zack Weinberg 2003-03-22 03:28:39 +00:00
parent bea4139388
commit d9b2742a3d
9 changed files with 4466 additions and 4091 deletions

View File

@ -1,3 +1,12 @@
2003-03-21 Zack Weinberg <zack@codesourcery.com>
* c-common.c: Include intl.h.
(shadow_warning): Rewrite to allow better diagnostic translations.
* c-common.h: Update prototype of shadow_warning. Declare sw_kind enum.
* c-decl.c (warn_if_shadowing): Update calls to shadow_warning;
use it throughout.
* Makefile.in (c-common.o): Add intl.h.
2003-03-21 Nathanael Nerode <neroden@gcc.gnu.org>
* config.gcc: Remove 'float_format'.

View File

@ -1302,7 +1302,7 @@ tlink.o: tlink.c $(DEMANGLE_H) $(HASHTAB_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h
# A file used by all variants of C.
c-common.o : c-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(OBSTACK_H) $(C_COMMON_H) flags.h toplev.h output.h c-pragma.h \
$(OBSTACK_H) $(C_COMMON_H) flags.h toplev.h output.h c-pragma.h intl.h \
$(GGC_H) $(EXPR_H) $(TM_P_H) builtin-types.def builtin-attrs.def \
diagnostic.h gt-c-common.h langhooks.h varray.h $(RTL_H) $(TARGET_H)
c-pretty-print.o : c-pretty-print.c c-pretty-print.h pretty-print.h \

View File

@ -23,6 +23,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "intl.h"
#include "tree.h"
#include "flags.h"
#include "toplev.h"
@ -4807,14 +4808,23 @@ c_common_insert_default_attributes (decl)
#undef DEF_FN_ATTR
}
/* Output a -Wshadow warning MSGID about NAME, an IDENTIFIER_NODE, and
additionally give the location of the previous declaration DECL. */
/* Output a -Wshadow warning MSGCODE about NAME, and give the location
of the previous declaration DECL. MANDATORY says whether this is a
mandatory warning (i.e. use pedwarn). */
void
shadow_warning (msgid, name, decl)
const char *msgid;
tree name, decl;
shadow_warning (msgcode, mandatory, name, decl)
enum sw_kind msgcode;
int mandatory; /* really bool */
const char *name;
tree decl;
{
warning ("declaration of `%s' shadows %s", IDENTIFIER_POINTER (name), msgid);
static const char *const msgs[] = {
/* SW_PARAM */ N_("declaration of \"%s\" shadows a parameter"),
/* SW_LOCAL */ N_("declaration of \"%s\" shadows a previous local"),
/* SW_GLOBAL */ N_("declaration of \"%s\" shadows a global declaration")
};
(mandatory ? pedwarn : warning) (msgs[msgcode], name);
warning_with_file_and_line (DECL_SOURCE_FILE (decl),
DECL_SOURCE_LINE (decl),
"shadowed declaration is here");

View File

@ -332,12 +332,13 @@ extern tree walk_stmt_tree PARAMS ((tree *,
void *));
extern void prep_stmt PARAMS ((tree));
extern void expand_stmt PARAMS ((tree));
extern void shadow_warning PARAMS ((const char *,
tree, tree));
extern tree c_begin_if_stmt PARAMS ((void));
extern tree c_begin_while_stmt PARAMS ((void));
extern void c_finish_while_stmt_cond PARAMS ((tree, tree));
enum sw_kind { SW_PARAM = 0, SW_LOCAL, SW_GLOBAL };
extern void shadow_warning PARAMS ((enum sw_kind, int,
const char *, tree));
/* Extra information associated with a DECL. Other C dialects extend
this structure in various ways. The C front-end only uses this

View File

@ -1599,12 +1599,14 @@ static void
warn_if_shadowing (x, oldlocal)
tree x, oldlocal;
{
tree name;
tree sym;
const char *name;
if (DECL_EXTERNAL (x))
return;
name = DECL_NAME (x);
sym = DECL_NAME (x);
name = IDENTIFIER_POINTER (sym);
/* Warn if shadowing an argument at the top level of the body. */
if (oldlocal != 0
@ -1615,14 +1617,7 @@ warn_if_shadowing (x, oldlocal)
/* Check that the decl being shadowed
comes from the parm level, one level up. */
&& chain_member (oldlocal, current_binding_level->level_chain->names))
{
if (TREE_CODE (oldlocal) == PARM_DECL)
pedwarn ("declaration of `%s' shadows a parameter",
IDENTIFIER_POINTER (name));
else
pedwarn ("declaration of `%s' shadows a symbol from the parameter list",
IDENTIFIER_POINTER (name));
}
shadow_warning (SW_PARAM, true, name, oldlocal);
/* Maybe warn if shadowing something else. */
else if (warn_shadow
/* No shadow warnings for internally generated vars. */
@ -1641,14 +1636,14 @@ warn_if_shadowing (x, oldlocal)
else if (oldlocal)
{
if (TREE_CODE (oldlocal) == PARM_DECL)
shadow_warning ("a parameter", name, oldlocal);
shadow_warning (SW_PARAM, false, name, oldlocal);
else
shadow_warning ("a previous local", name, oldlocal);
shadow_warning (SW_LOCAL, false, name, oldlocal);
}
else if (IDENTIFIER_GLOBAL_VALUE (name) != 0
&& IDENTIFIER_GLOBAL_VALUE (name) != error_mark_node)
shadow_warning ("a global declaration", name,
IDENTIFIER_GLOBAL_VALUE (name));
else if (IDENTIFIER_GLOBAL_VALUE (sym) != 0
&& IDENTIFIER_GLOBAL_VALUE (sym) != error_mark_node)
shadow_warning (SW_GLOBAL, false, name,
IDENTIFIER_GLOBAL_VALUE (sym));
}
}

View File

@ -1,3 +1,7 @@
2003-03-21 Zack Weinberg <zack@codesourcery.com>
* decl.c: Update calls to shadow_warning.
2003-03-21 Nathan Sidwell <nathan@codesourcery.com>
PR c++/9898
@ -22,8 +26,8 @@
(init_rtti_processing): initialize unemitted_tinfo_decls varray.
(get_tinfo_decls): push new tinfo decl on unemitted_tinfo_decls.
(emit_tinfo_decl): remove unused second parameter, add assertion
that decl hasn't already been emitted.
that decl hasn't already been emitted.
2003-03-19 Nathanael Nerode <neroden@gcc.gnu.org>
* dump.c (cp_dump_tree), cp-tree.h (cp_dump_tree): Change return
@ -47,7 +51,7 @@
2003-03-17 Jason Merrill <jason@redhat.com>
PR c++/10091
* typeck.c (build_class_member_access_expr): Compare
* typeck.c (build_class_member_access_expr): Compare
TYPE_MAIN_VARIANTs.
2003-03-17 Mark Mitchell <mark@codesourcery.com>
@ -493,14 +497,14 @@
2003-03-04 Gabriel Dos Reis <gdr@integrable-solutions.net>
* cp-tree.h (cxx_saved_binding): Declare.
(struct saved_scope): Adjust type of field 'old_binding'.
* decl.c (cxx_saved_binding_make): New macro.
(struct cxx_saved_binding): Define.
(store_bindings): Adjust prototype. Use cxx_saved_binding to save
C++ bindings.
(maybe_push_to_top_level): Adjust local variable type.
(pop_from_top_level): Likewise.
* cp-tree.h (cxx_saved_binding): Declare.
(struct saved_scope): Adjust type of field 'old_binding'.
* decl.c (cxx_saved_binding_make): New macro.
(struct cxx_saved_binding): Define.
(store_bindings): Adjust prototype. Use cxx_saved_binding to save
C++ bindings.
(maybe_push_to_top_level): Adjust local variable type.
(pop_from_top_level): Likewise.
2003-03-04 Tom Tromey <tromey@redhat.com>
@ -599,9 +603,9 @@
2003-02-28 Aldy Hernandez <aldyh@redhat.com>
* parser.c (cp_parser_init_declarator): Revert opaque
vector_opaque_p change.
Do not include target.h.
* parser.c (cp_parser_init_declarator): Revert opaque
vector_opaque_p change.
Do not include target.h.
2003-02-28 Mark Mitchell <mark@codesourcery.com>
@ -905,7 +909,7 @@
2003-02-14 Andrew Pinski <pinskia@physics.uc.edu>
* decl.c: (define_label): Fix warning for return 0 instead of NULL.
* decl.c: (define_label): Fix warning for return 0 instead of NULL.
2003-02-13 Gabriel Dos Reis <gdr@integrable-solutions.net>
@ -1109,7 +1113,7 @@
2003-01-29 Fariborz Jahanian <fjahanian@apple.com>
* pt.c (last_pending_template) Declare GTY().
* pt.c (last_pending_template) Declare GTY().
2003-01-29 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
@ -1234,7 +1238,7 @@
PR c++/9285
PR c++/9294
* parser.c (cp_parser_simple_declaration): Return quickly when
encountering errors.
encountering errors.
2003-01-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
@ -1508,10 +1512,10 @@
2003-01-09 Nathanael Nerode <neroden@gcc.gnu.org>
* cfns.gperf: ANSIfy function declarations.
* cfns.h: Regenerate.
* cp-tree.h: ANSIfy function declarations.
* parser.c: ANSIfy function declarations & definitions.
* cfns.gperf: ANSIfy function declarations.
* cfns.h: Regenerate.
* cp-tree.h: ANSIfy function declarations.
* parser.c: ANSIfy function declarations & definitions.
* decl.c (bad_specifiers): Fix parameter order error I introduced.

View File

@ -4123,7 +4123,8 @@ pushdecl (tree x)
}
if (warn_shadow && !err)
shadow_warning ("a parameter", name, oldlocal);
shadow_warning (SW_PARAM, false,
IDENTIFIER_POINTER (name), oldlocal);
}
/* Maybe warn if shadowing something else. */
@ -4140,11 +4141,13 @@ pushdecl (tree x)
IDENTIFIER_POINTER (name));
else if (oldlocal != NULL_TREE
&& TREE_CODE (oldlocal) == VAR_DECL)
shadow_warning ("a previous local", name, oldlocal);
shadow_warning (SW_LOCAL, false,
IDENTIFIER_POINTER (name), oldlocal);
else if (oldglobal != NULL_TREE
&& TREE_CODE (oldglobal) == VAR_DECL)
/* XXX shadow warnings in outer-more namespaces */
shadow_warning ("a global declaration", name, oldglobal);
shadow_warning (SW_GLOBAL, false,
IDENTIFIER_POINTER (name), oldglobal);
}
}

View File

@ -1,3 +1,7 @@
2003-03-21 Zack Weinberg <zack@codesourcery.com>
* gcc.pot: Regenerate.
2003-02-04 Joseph S. Myers <jsm@polyomino.org.uk>
* be.po, de.po: New files.
@ -15,7 +19,7 @@
* tr.po, es.po, fr.po: Update to version for 20020415
snapshot.
2002-04-23 Philipp Thomas <pthomas@suse.de>
* gcc.pot: Regenerate.

File diff suppressed because it is too large Load Diff