attribs.c (decl_attributes): Use %qE for identifiers in diagnostics.

* attribs.c (decl_attributes): Use %qE for identifiers in
	diagnostics.
	* cgraphunit.c (verify_cgraph_node): Translate function names to
	locale character set in diagnostics.
	* coverage.c (get_coverage_counts): Use %qE for identifiers in
	diagnostics.
	* doc/invoke.texi (-finstrument-functions-exclude-function-list):
	Document that functions are named in UTF-8.
	* expr.c (expand_expr_real_1): Translate function names to locale
	character set in diagnostics.
	* gimplify.c (omp_notice_variable, omp_is_private,
	gimplify_scan_omp_clauses): Use %qE for identifiers in
	diagnostics.
	* langhooks.c (lhd_print_error_function): Translate function names
	to locale character set.
	* langhooks.h (decl_printable_name): Document that return value is
	in internal character set.
	* stmt.c: Include pretty-print.h
	(tree_conflicts_with_clobbers_p): Use %qE for identifiers in
	diagnostics.
	(resolve_operand_name_1): Translate named operand name to locale
	character set.
	* stor-layout.c (finalize_record_size): Use %qE for identifiers in
	diagnostics.
	* toplev.c (announce_function): Translate function names to locale
	character set.
	(warn_deprecated_use): Use %qE for identifiers in diagnostics.
	(default_tree_printer): Use pp_identifier or translate identifiers
	to locale character set.  Mark "<anonymous>" for translation.
	* tree-mudflap.c (mx_register_decls, mudflap_finish_file): Use %qE
	for identifiers in diagnostics.
	* tree.c (handle_dll_attribute): Use %qE for identifiers in
	diagnostics.
	* varasm.c (output_constructor): Use %qE for identifiers in
	diagnostics.

testsuite:
	* gcc.dg/ucnid-11.c, gcc.dg/ucnid-12.c, gcc.dg/ucnid-13.c: New
	tests.

From-SVN: r147111
This commit is contained in:
Joseph Myers 2009-05-05 00:44:36 +01:00 committed by Joseph Myers
parent 40540e682a
commit 4f1e4960a6
19 changed files with 144 additions and 70 deletions

View File

@ -1,3 +1,41 @@
2009-05-04 Joseph Myers <joseph@codesourcery.com>
* attribs.c (decl_attributes): Use %qE for identifiers in
diagnostics.
* cgraphunit.c (verify_cgraph_node): Translate function names to
locale character set in diagnostics.
* coverage.c (get_coverage_counts): Use %qE for identifiers in
diagnostics.
* doc/invoke.texi (-finstrument-functions-exclude-function-list):
Document that functions are named in UTF-8.
* expr.c (expand_expr_real_1): Translate function names to locale
character set in diagnostics.
* gimplify.c (omp_notice_variable, omp_is_private,
gimplify_scan_omp_clauses): Use %qE for identifiers in
diagnostics.
* langhooks.c (lhd_print_error_function): Translate function names
to locale character set.
* langhooks.h (decl_printable_name): Document that return value is
in internal character set.
* stmt.c: Include pretty-print.h
(tree_conflicts_with_clobbers_p): Use %qE for identifiers in
diagnostics.
(resolve_operand_name_1): Translate named operand name to locale
character set.
* stor-layout.c (finalize_record_size): Use %qE for identifiers in
diagnostics.
* toplev.c (announce_function): Translate function names to locale
character set.
(warn_deprecated_use): Use %qE for identifiers in diagnostics.
(default_tree_printer): Use pp_identifier or translate identifiers
to locale character set. Mark "<anonymous>" for translation.
* tree-mudflap.c (mx_register_decls, mudflap_finish_file): Use %qE
for identifiers in diagnostics.
* tree.c (handle_dll_attribute): Use %qE for identifiers in
diagnostics.
* varasm.c (output_constructor): Use %qE for identifiers in
diagnostics.
2009-05-04 Rafael Avila de Espindola <espindola@google.com>
* configure.ac: use ` ` instead of $()

View File

@ -280,16 +280,16 @@ decl_attributes (tree *node, tree attributes, int flags)
if (spec == NULL)
{
warning (OPT_Wattributes, "%qs attribute directive ignored",
IDENTIFIER_POINTER (name));
warning (OPT_Wattributes, "%qE attribute directive ignored",
name);
continue;
}
else if (list_length (args) < spec->min_length
|| (spec->max_length >= 0
&& list_length (args) > spec->max_length))
{
error ("wrong number of arguments specified for %qs attribute",
IDENTIFIER_POINTER (name));
error ("wrong number of arguments specified for %qE attribute",
name);
continue;
}
gcc_assert (is_attribute_p (spec->name, name));
@ -306,8 +306,8 @@ decl_attributes (tree *node, tree attributes, int flags)
}
else
{
warning (OPT_Wattributes, "%qs attribute does not apply to types",
IDENTIFIER_POINTER (name));
warning (OPT_Wattributes, "%qE attribute does not apply to types",
name);
continue;
}
}
@ -357,8 +357,8 @@ decl_attributes (tree *node, tree attributes, int flags)
&& TREE_CODE (*anode) != METHOD_TYPE)
{
warning (OPT_Wattributes,
"%qs attribute only applies to function types",
IDENTIFIER_POINTER (name));
"%qE attribute only applies to function types",
name);
continue;
}
}

View File

@ -570,7 +570,8 @@ verify_cgraph_node (struct cgraph_node *node)
if (e->aux)
{
error ("aux field set for edge %s->%s",
cgraph_node_name (e->caller), cgraph_node_name (e->callee));
identifier_to_locale (cgraph_node_name (e->caller)),
identifier_to_locale (cgraph_node_name (e->callee)));
error_found = true;
}
if (node->count < 0)
@ -696,8 +697,8 @@ verify_cgraph_node (struct cgraph_node *node)
if (!e->aux && !e->indirect_call)
{
error ("edge %s->%s has no corresponding call_stmt",
cgraph_node_name (e->caller),
cgraph_node_name (e->callee));
identifier_to_locale (cgraph_node_name (e->caller)),
identifier_to_locale (cgraph_node_name (e->callee)));
debug_gimple_stmt (e->call_stmt);
error_found = true;
}

View File

@ -347,8 +347,8 @@ get_coverage_counts (unsigned counter, unsigned expected,
entry = (counts_entry_t *) htab_find (counts_hash, &elt);
if (!entry)
{
warning (0, "no coverage for function %qs found", IDENTIFIER_POINTER
(DECL_ASSEMBLER_NAME (current_function_decl)));
warning (0, "no coverage for function %qE found",
DECL_ASSEMBLER_NAME (current_function_decl));
return NULL;
}
@ -357,14 +357,13 @@ get_coverage_counts (unsigned counter, unsigned expected,
|| entry->summary.num != expected)
{
static int warned = 0;
const char *id = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME
(current_function_decl));
tree id = DECL_ASSEMBLER_NAME (current_function_decl);
if (warn_coverage_mismatch)
warning (OPT_Wcoverage_mismatch, "coverage mismatch for function "
"%qs while reading counter %qs", id, ctr_names[counter]);
"%qE while reading counter %qs", id, ctr_names[counter]);
else
error ("coverage mismatch for function %qs while reading counter %qs",
error ("coverage mismatch for function %qE while reading counter %qs",
id, ctr_names[counter]);
if (!inhibit_warnings)

View File

@ -16124,7 +16124,9 @@ instrumentation. The function name to be matched is its user-visible
name, such as @code{vector<int> blah(const vector<int> &)}, not the
internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
match is done on substrings: if the @var{sym} parameter is a substring
of the function name, it is considered to be a match.
of the function name, it is considered to be a match. For C99 and C++
extended identifiers, the function name must be given in UTF-8, not
using universal character names.
@item -fstack-check
@opindex fstack-check

View File

@ -8055,14 +8055,14 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
&& (attr = lookup_attribute ("error",
DECL_ATTRIBUTES (fndecl))) != NULL)
error ("%Kcall to %qs declared with attribute error: %s",
exp, lang_hooks.decl_printable_name (fndecl, 1),
exp, identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 1)),
TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
if (fndecl
&& (attr = lookup_attribute ("warning",
DECL_ATTRIBUTES (fndecl))) != NULL)
warning_at (tree_nonartificial_location (exp),
0, "%Kcall to %qs declared with attribute warning: %s",
exp, lang_hooks.decl_printable_name (fndecl, 1),
exp, identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 1)),
TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
/* Check for a built-in function. */

View File

@ -5395,8 +5395,8 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code)
switch (default_kind)
{
case OMP_CLAUSE_DEFAULT_NONE:
error ("%qs not specified in enclosing parallel",
IDENTIFIER_POINTER (DECL_NAME (decl)));
error ("%qE not specified in enclosing parallel",
DECL_NAME (decl));
error ("%Henclosing parallel", &ctx->location);
/* FALLTHRU */
case OMP_CLAUSE_DEFAULT_SHARED:
@ -5502,8 +5502,8 @@ omp_is_private (struct gimplify_omp_ctx *ctx, tree decl)
{
if (ctx == gimplify_omp_ctxp)
{
error ("iteration variable %qs should be private",
IDENTIFIER_POINTER (DECL_NAME (decl)));
error ("iteration variable %qE should be private",
DECL_NAME (decl));
n->value = GOVD_PRIVATE;
return true;
}
@ -5516,11 +5516,11 @@ omp_is_private (struct gimplify_omp_ctx *ctx, tree decl)
&& gimplify_omp_ctxp->outer_context == ctx)))
{
if ((n->value & GOVD_FIRSTPRIVATE) != 0)
error ("iteration variable %qs should not be firstprivate",
IDENTIFIER_POINTER (DECL_NAME (decl)));
error ("iteration variable %qE should not be firstprivate",
DECL_NAME (decl));
else if ((n->value & GOVD_REDUCTION) != 0)
error ("iteration variable %qs should not be reduction",
IDENTIFIER_POINTER (DECL_NAME (decl)));
error ("iteration variable %qE should not be reduction",
DECL_NAME (decl));
}
return (ctx == gimplify_omp_ctxp
|| (ctx->region_type == ORT_COMBINED_PARALLEL
@ -5682,8 +5682,8 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
&& region_type == ORT_WORKSHARE
&& omp_check_private (ctx, decl))
{
error ("%s variable %qs is private in outer context",
check_non_private, IDENTIFIER_POINTER (DECL_NAME (decl)));
error ("%s variable %qE is private in outer context",
check_non_private, DECL_NAME (decl));
remove = true;
}
break;

View File

@ -380,11 +380,11 @@ lhd_print_error_function (diagnostic_context *context, const char *file,
if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
pp_printf
(context->printer, _("In member function %qs"),
lang_hooks.decl_printable_name (fndecl, 2));
identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
else
pp_printf
(context->printer, _("In function %qs"),
lang_hooks.decl_printable_name (fndecl, 2));
identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
while (abstract_origin)
{
@ -435,18 +435,18 @@ lhd_print_error_function (diagnostic_context *context, const char *file,
if (flag_show_column && s.column != 0)
pp_printf (context->printer,
_(" inlined from %qs at %s:%d:%d"),
lang_hooks.decl_printable_name (fndecl, 2),
identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
s.file, s.line, s.column);
else
pp_printf (context->printer,
_(" inlined from %qs at %s:%d"),
lang_hooks.decl_printable_name (fndecl, 2),
identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
s.file, s.line);
}
else
pp_printf (context->printer, _(" inlined from %qs"),
lang_hooks.decl_printable_name (fndecl, 2));
identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
}
}
pp_character (context->printer, ':');

View File

@ -1,5 +1,5 @@
/* The lang_hooks data structure.
Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is part of GCC.
@ -332,7 +332,10 @@ struct lang_hooks
information will be printed: 0: DECL_NAME, demangled as
necessary. 1: and scope information. 2: and any other
information that might be interesting, such as function parameter
types in C++. */
types in C++. The name is in the internal character set and
needs to be converted to the locale character set of diagnostics,
or to the execution character set for strings such as
__PRETTY_FUNCTION__. */
const char *(*decl_printable_name) (tree decl, int verbosity);
/* Computes the dwarf-2/3 name for a tree. VERBOSITY determines what

View File

@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see
#include "target.h"
#include "regs.h"
#include "alloc-pool.h"
#include "pretty-print.h"
/* Functions and data structures for expanding case statements. */
@ -600,8 +601,8 @@ tree_conflicts_with_clobbers_p (tree t, HARD_REG_SET *clobbered_regs)
if (overlap)
{
error ("asm-specifier for variable %qs conflicts with asm clobber list",
IDENTIFIER_POINTER (DECL_NAME (overlap)));
error ("asm-specifier for variable %qE conflicts with asm clobber list",
DECL_NAME (overlap));
/* Reset registerness to stop multiple errors emitted for a single
variable. */
@ -1322,7 +1323,7 @@ resolve_operand_name_1 (char *p, tree outputs, tree inputs)
}
*q = '\0';
error ("undefined named operand %qs", p + 1);
error ("undefined named operand %qs", identifier_to_locale (p + 1));
op = 0;
found:

View File

@ -1292,19 +1292,19 @@ finalize_record_size (record_layout_info rli)
if (TYPE_NAME (rli->t))
{
const char *name;
tree name;
if (TREE_CODE (TYPE_NAME (rli->t)) == IDENTIFIER_NODE)
name = IDENTIFIER_POINTER (TYPE_NAME (rli->t));
name = TYPE_NAME (rli->t);
else
name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (rli->t)));
name = DECL_NAME (TYPE_NAME (rli->t));
if (STRICT_ALIGNMENT)
warning (OPT_Wpacked, "packed attribute causes inefficient "
"alignment for %qs", name);
"alignment for %qE", name);
else
warning (OPT_Wpacked,
"packed attribute is unnecessary for %qs", name);
"packed attribute is unnecessary for %qE", name);
}
else
{

View File

@ -1,3 +1,8 @@
2009-05-04 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/ucnid-11.c, gcc.dg/ucnid-12.c, gcc.dg/ucnid-13.c: New
tests.
2009-05-04 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/ucnid-8.c, gcc.dg/ucnid-9.c, gcc.dg/ucnid-10.c: New

View File

@ -0,0 +1,5 @@
/* { dg-do run } */
/* { dg-xfail-if "" { powerpc-ibm-aix* *-*-solaris2.* } { "*" } { "" } } */
/* { dg-options "-std=c99 -fextended-identifiers -fdata-sections" } */
#include "ucnid-3.c"

View File

@ -0,0 +1,5 @@
/* { dg-do run } */
/* { dg-xfail-if "" { powerpc-ibm-aix* *-*-solaris2.* } { "*" } { "" } } */
/* { dg-options "-std=c99 -fextended-identifiers -ffunction-sections" } */
#include "ucnid-4.c"

View File

@ -0,0 +1,13 @@
/* Verify diagnostics for extended identifiers refer to UCNs (in the C
locale). Miscellaneous diagnostics. */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -fextended-identifiers -Wpacked" } */
int a __attribute__((\u00c0)); /* { dg-warning "'\\\\U000000c0' attribute directive ignored" } */
extern void \u00c1 (void) __attribute__((deprecated));
void g (void) { \u00c1 (); } /* { dg-warning "'\\\\U000000c1' is deprecated" } */
struct \u00c2 { char c; } __attribute__((packed)); /* { dg-warning "'\\\\U000000c2'" } */
void h (void) { asm ("%[\u00c3]" : : ); } /* { dg-error "undefined named operand '\\\\U000000c3'" } */

View File

@ -427,9 +427,11 @@ announce_function (tree decl)
if (!quiet_flag)
{
if (rtl_dump_and_exit)
fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
fprintf (stderr, "%s ",
identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (decl))));
else
fprintf (stderr, " %s", lang_hooks.decl_printable_name (decl, 2));
fprintf (stderr, " %s",
identifier_to_locale (lang_hooks.decl_printable_name (decl, 2)));
fflush (stderr);
pp_needs_newline (global_dc->printer) = true;
diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL);
@ -920,16 +922,16 @@ warn_deprecated_use (tree node)
}
else if (TYPE_P (node))
{
const char *what = NULL;
tree what = NULL_TREE;
tree decl = TYPE_STUB_DECL (node);
if (TYPE_NAME (node))
{
if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
what = IDENTIFIER_POINTER (TYPE_NAME (node));
what = TYPE_NAME (node);
else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
&& DECL_NAME (TYPE_NAME (node)))
what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
what = DECL_NAME (TYPE_NAME (node));
}
if (decl)
@ -938,7 +940,7 @@ warn_deprecated_use (tree node)
= expand_location (DECL_SOURCE_LOCATION (decl));
if (what)
warning (OPT_Wdeprecated_declarations,
"%qs is deprecated (declared at %s:%d)", what,
"%qE is deprecated (declared at %s:%d)", what,
xloc.file, xloc.line);
else
warning (OPT_Wdeprecated_declarations,
@ -948,7 +950,7 @@ warn_deprecated_use (tree node)
else
{
if (what)
warning (OPT_Wdeprecated_declarations, "%qs is deprecated", what);
warning (OPT_Wdeprecated_declarations, "%qE is deprecated", what);
else
warning (OPT_Wdeprecated_declarations, "type is deprecated");
}
@ -1511,7 +1513,7 @@ default_tree_printer (pretty_printer * pp, text_info *text, const char *spec,
t = va_arg (*text->args_ptr, tree);
if (TREE_CODE (t) == IDENTIFIER_NODE)
{
pp_string (pp, IDENTIFIER_POINTER (t));
pp_identifier (pp, IDENTIFIER_POINTER (t));
return true;
}
break;
@ -1537,8 +1539,8 @@ default_tree_printer (pretty_printer * pp, text_info *text, const char *spec,
if (DECL_P (t))
{
const char *n = DECL_NAME (t)
? lang_hooks.decl_printable_name (t, 2)
: "<anonymous>";
? identifier_to_locale (lang_hooks.decl_printable_name (t, 2))
: _("<anonymous>");
pp_string (pp, n);
}
else

View File

@ -1061,8 +1061,8 @@ mx_register_decls (tree decl, gimple_seq seq, location_t location)
{
if (!DECL_ARTIFICIAL (decl))
warning (OPT_Wmudflap,
"mudflap cannot track %qs in stub function",
IDENTIFIER_POINTER (DECL_NAME (decl)));
"mudflap cannot track %qE in stub function",
DECL_NAME (decl));
}
else
{
@ -1305,8 +1305,8 @@ mudflap_finish_file (void)
if (! COMPLETE_TYPE_P (TREE_TYPE (obj)))
{
warning (OPT_Wmudflap,
"mudflap cannot track unknown size extern %qs",
IDENTIFIER_POINTER (DECL_NAME (obj)));
"mudflap cannot track unknown size extern %qE",
DECL_NAME (obj));
continue;
}

View File

@ -4063,8 +4063,8 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags,
}
else
{
warning (OPT_Wattributes, "%qs attribute ignored",
IDENTIFIER_POINTER (name));
warning (OPT_Wattributes, "%qE attribute ignored",
name);
*no_add_attrs = true;
return NULL_TREE;
}
@ -4075,8 +4075,8 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags,
&& TREE_CODE (node) != TYPE_DECL)
{
*no_add_attrs = true;
warning (OPT_Wattributes, "%qs attribute ignored",
IDENTIFIER_POINTER (name));
warning (OPT_Wattributes, "%qE attribute ignored",
name);
return NULL_TREE;
}
@ -4085,8 +4085,8 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags,
&& TREE_CODE (TREE_TYPE (node)) != UNION_TYPE)
{
*no_add_attrs = true;
warning (OPT_Wattributes, "%qs attribute ignored",
IDENTIFIER_POINTER (name));
warning (OPT_Wattributes, "%qE attribute ignored",
name);
return NULL_TREE;
}
@ -4141,7 +4141,7 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags,
|| TREE_CODE (node) == FUNCTION_DECL))
{
error ("external linkage required for symbol %q+D because of "
"%qs attribute", node, IDENTIFIER_POINTER (name));
"%qE attribute", node, name);
*no_add_attrs = true;
}
@ -4154,9 +4154,9 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags,
{
if (DECL_VISIBILITY_SPECIFIED (node)
&& DECL_VISIBILITY (node) != VISIBILITY_DEFAULT)
error ("%qs implies default visibility, but %qD has already "
error ("%qE implies default visibility, but %qD has already "
"been declared with a different visibility",
IDENTIFIER_POINTER (name), node);
name, node);
DECL_VISIBILITY (node) = VISIBILITY_DEFAULT;
DECL_VISIBILITY_SPECIFIED (node) = 1;
}

View File

@ -4761,8 +4761,8 @@ output_constructor (tree exp, unsigned HOST_WIDE_INT size,
total_bytes += fieldsize;
}
else if (val != 0 && TREE_CODE (val) != INTEGER_CST)
error ("invalid initial value for member %qs",
IDENTIFIER_POINTER (DECL_NAME (field)));
error ("invalid initial value for member %qE",
DECL_NAME (field));
else
{
/* Element that is a bit-field. */