Commit d9b2742a by Zack Weinberg

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
parent bea41393
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'.
......
......@@ -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 \
......
......@@ -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");
......
......@@ -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
......
......@@ -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));
}
}
......
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
......
......@@ -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);
}
}
......
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.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment