Commit 88388a52 by Joseph Myers Committed by Joseph Myers

c-common.c (handle_mode_attribute): Use %qE for identifiers in diagnostics.

	* c-common.c (handle_mode_attribute): Use %qE for identifiers in
	diagnostics.
	* c-decl.c (check_bitfield_type_and_width): Make orig_name a tree
	and pass value to identifier_to_locale.
	(warn_variable_length_array): Make name a tree.
	(grokdeclarator): Separate diagnostic texts for named and unnamed
	declarators.  Use %qE for named declarators.
	* c-parser.c (c_lex_one_token): Use %qE for identifiers in
	diagnostics.
	* c-pragma.c (pop_alignment, handle_pragma_pack): Use %qE for
	identifiers in diagnostics.
	* c-typeck.c (push_member_name, start_init): Pass identifiers to
	identifier_to_locale.  Mark "anonymous" strings for translation.

testsuite:
	* gcc.dg/ucnid-8.c, gcc.dg/ucnid-9.c, gcc.dg/ucnid-10.c: New
	tests.
	* gcc.dg/declspec-9.c, gcc.dg/declspec-10.c, gcc.dg/declspec-11.c:
	Update expected errors.

From-SVN: r147108
parent 960c5c79
2009-05-04 Joseph Myers <joseph@codesourcery.com>
* c-common.c (handle_mode_attribute): Use %qE for identifiers in
diagnostics.
* c-decl.c (check_bitfield_type_and_width): Make orig_name a tree
and pass value to identifier_to_locale.
(warn_variable_length_array): Make name a tree.
(grokdeclarator): Separate diagnostic texts for named and unnamed
declarators. Use %qE for named declarators.
* c-parser.c (c_lex_one_token): Use %qE for identifiers in
diagnostics.
* c-pragma.c (pop_alignment, handle_pragma_pack): Use %qE for
identifiers in diagnostics.
* c-typeck.c (push_member_name, start_init): Pass identifiers to
identifier_to_locale. Mark "anonymous" strings for translation.
2009-05-04 Michael Eager <eager@eagercon.com> 2009-05-04 Michael Eager <eager@eagercon.com>
* config/rs6000/rs6000.c (rs6000_legitimate_address): Allow * config/rs6000/rs6000.c (rs6000_legitimate_address): Allow
......
...@@ -6379,15 +6379,16 @@ handle_mode_attribute (tree *node, tree name, tree args, ...@@ -6379,15 +6379,16 @@ handle_mode_attribute (tree *node, tree name, tree args,
int ARG_UNUSED (flags), bool *no_add_attrs) int ARG_UNUSED (flags), bool *no_add_attrs)
{ {
tree type = *node; tree type = *node;
tree ident = TREE_VALUE (args);
*no_add_attrs = true; *no_add_attrs = true;
if (TREE_CODE (TREE_VALUE (args)) != IDENTIFIER_NODE) if (TREE_CODE (ident) != IDENTIFIER_NODE)
warning (OPT_Wattributes, "%qE attribute ignored", name); warning (OPT_Wattributes, "%qE attribute ignored", name);
else else
{ {
int j; int j;
const char *p = IDENTIFIER_POINTER (TREE_VALUE (args)); const char *p = IDENTIFIER_POINTER (ident);
int len = strlen (p); int len = strlen (p);
enum machine_mode mode = VOIDmode; enum machine_mode mode = VOIDmode;
tree typefm; tree typefm;
...@@ -6427,7 +6428,7 @@ handle_mode_attribute (tree *node, tree name, tree args, ...@@ -6427,7 +6428,7 @@ handle_mode_attribute (tree *node, tree name, tree args,
if (mode == VOIDmode) if (mode == VOIDmode)
{ {
error ("unknown machine mode %qs", p); error ("unknown machine mode %qE", ident);
return NULL_TREE; return NULL_TREE;
} }
......
...@@ -222,8 +222,8 @@ c_lex_one_token (c_parser *parser, c_token *token) ...@@ -222,8 +222,8 @@ c_lex_one_token (c_parser *parser, c_token *token)
{ {
warning_at (token->location, warning_at (token->location,
OPT_Wc___compat, OPT_Wc___compat,
"identifier %qs conflicts with C++ keyword", "identifier %qE conflicts with C++ keyword",
IDENTIFIER_POINTER (token->value)); token->value);
} }
else if (c_dialect_objc ()) else if (c_dialect_objc ())
{ {
......
...@@ -112,8 +112,8 @@ pop_alignment (tree id) ...@@ -112,8 +112,8 @@ pop_alignment (tree id)
} }
if (entry == NULL) if (entry == NULL)
warning (OPT_Wpragmas, "\ warning (OPT_Wpragmas, "\
#pragma pack(pop, %s) encountered without matching #pragma pack(push, %s)" #pragma pack(pop, %E) encountered without matching #pragma pack(push, %E)"
, IDENTIFIER_POINTER (id), IDENTIFIER_POINTER (id)); , id, id);
} }
entry = alignment_stack->prev; entry = alignment_stack->prev;
...@@ -179,7 +179,7 @@ handle_pragma_pack (cpp_reader * ARG_UNUSED (dummy)) ...@@ -179,7 +179,7 @@ handle_pragma_pack (cpp_reader * ARG_UNUSED (dummy))
else if (!strcmp (op, "pop")) else if (!strcmp (op, "pop"))
action = pop; action = pop;
else else
GCC_BAD2 ("unknown action %qs for %<#pragma pack%> - ignored", op); GCC_BAD2 ("unknown action %qE for %<#pragma pack%> - ignored", x);
while ((token = pragma_lex (&x)) == CPP_COMMA) while ((token = pragma_lex (&x)) == CPP_COMMA)
{ {
......
...@@ -5146,7 +5146,9 @@ static void ...@@ -5146,7 +5146,9 @@ static void
push_member_name (tree decl) push_member_name (tree decl)
{ {
const char *const string const char *const string
= DECL_NAME (decl) ? IDENTIFIER_POINTER (DECL_NAME (decl)) : "<anonymous>"; = (DECL_NAME (decl)
? identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (decl)))
: _("<anonymous>"));
PUSH_SPELLING (SPELLING_MEMBER, string, u.s); PUSH_SPELLING (SPELLING_MEMBER, string, u.s);
} }
...@@ -5765,13 +5767,13 @@ start_init (tree decl, tree asmspec_tree ATTRIBUTE_UNUSED, int top_level) ...@@ -5765,13 +5767,13 @@ start_init (tree decl, tree asmspec_tree ATTRIBUTE_UNUSED, int top_level)
|| TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
|| TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE
|| TREE_CODE (TREE_TYPE (decl)) == QUAL_UNION_TYPE)); || TREE_CODE (TREE_TYPE (decl)) == QUAL_UNION_TYPE));
locus = IDENTIFIER_POINTER (DECL_NAME (decl)); locus = identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (decl)));
} }
else else
{ {
require_constant_value = 0; require_constant_value = 0;
require_constant_elements = 0; require_constant_elements = 0;
locus = "(anonymous)"; locus = _("(anonymous)");
} }
constructor_stack = 0; constructor_stack = 0;
......
2009-05-04 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/ucnid-8.c, gcc.dg/ucnid-9.c, gcc.dg/ucnid-10.c: New
tests.
* gcc.dg/declspec-9.c, gcc.dg/declspec-10.c, gcc.dg/declspec-11.c:
Update expected errors.
2009-05-04 Manuel Lopez-Ibanez <manu@gcc.gnu.org> 2009-05-04 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c++/28152 PR c++/28152
......
...@@ -9,11 +9,11 @@ auto void f0 (void) {} /* { dg-warning "function definition declared 'auto'" } * ...@@ -9,11 +9,11 @@ auto void f0 (void) {} /* { dg-warning "function definition declared 'auto'" } *
register void f1 (void) {} /* { dg-error "function definition declared 'register'" } */ register void f1 (void) {} /* { dg-error "function definition declared 'register'" } */
typedef void f2 (void) {} /* { dg-error "function definition declared 'typedef'" } */ typedef void f2 (void) {} /* { dg-error "function definition declared 'typedef'" } */
void f3 (auto int); /* { dg-error "storage class specified for parameter 'type name'" } */ void f3 (auto int); /* { dg-error "storage class specified for unnamed parameter" } */
void f4 (extern int); /* { dg-error "storage class specified for parameter 'type name'" } */ void f4 (extern int); /* { dg-error "storage class specified for unnamed parameter" } */
void f5 (register int); void f5 (register int);
void f6 (static int); /* { dg-error "storage class specified for parameter 'type name'" } */ void f6 (static int); /* { dg-error "storage class specified for unnamed parameter" } */
void f7 (typedef int); /* { dg-error "storage class specified for parameter 'type name'" } */ void f7 (typedef int); /* { dg-error "storage class specified for unnamed parameter" } */
auto int x; /* { dg-error "file-scope declaration of 'x' specifies 'auto'" } */ auto int x; /* { dg-error "file-scope declaration of 'x' specifies 'auto'" } */
register int y; /* { dg-warning "file-scope declaration of 'y' specifies 'register'" } */ register int y; /* { dg-warning "file-scope declaration of 'y' specifies 'register'" } */
......
...@@ -9,11 +9,11 @@ auto void f0 (void) {} /* { dg-error "function definition declared 'auto'" } */ ...@@ -9,11 +9,11 @@ auto void f0 (void) {} /* { dg-error "function definition declared 'auto'" } */
register void f1 (void) {} /* { dg-error "function definition declared 'register'" } */ register void f1 (void) {} /* { dg-error "function definition declared 'register'" } */
typedef void f2 (void) {} /* { dg-error "function definition declared 'typedef'" } */ typedef void f2 (void) {} /* { dg-error "function definition declared 'typedef'" } */
void f3 (auto int); /* { dg-error "storage class specified for parameter 'type name'" } */ void f3 (auto int); /* { dg-error "storage class specified for unnamed parameter" } */
void f4 (extern int); /* { dg-error "storage class specified for parameter 'type name'" } */ void f4 (extern int); /* { dg-error "storage class specified for unnamed parameter" } */
void f5 (register int); void f5 (register int);
void f6 (static int); /* { dg-error "storage class specified for parameter 'type name'" } */ void f6 (static int); /* { dg-error "storage class specified for unnamed parameter" } */
void f7 (typedef int); /* { dg-error "storage class specified for parameter 'type name'" } */ void f7 (typedef int); /* { dg-error "storage class specified for unnamed parameter" } */
auto int x; /* { dg-error "file-scope declaration of 'x' specifies 'auto'" } */ auto int x; /* { dg-error "file-scope declaration of 'x' specifies 'auto'" } */
register int y; /* { dg-error "file-scope declaration of 'y' specifies 'register'" } */ register int y; /* { dg-error "file-scope declaration of 'y' specifies 'register'" } */
......
...@@ -10,11 +10,11 @@ auto void f0 (void) {} /* { dg-warning "function definition declared 'auto'" } * ...@@ -10,11 +10,11 @@ auto void f0 (void) {} /* { dg-warning "function definition declared 'auto'" } *
register void f1 (void) {} /* { dg-error "function definition declared 'register'" } */ register void f1 (void) {} /* { dg-error "function definition declared 'register'" } */
typedef void f2 (void) {} /* { dg-error "function definition declared 'typedef'" } */ typedef void f2 (void) {} /* { dg-error "function definition declared 'typedef'" } */
void f3 (auto int); /* { dg-error "storage class specified for parameter 'type name'" } */ void f3 (auto int); /* { dg-error "storage class specified for unnamed parameter" } */
void f4 (extern int); /* { dg-error "storage class specified for parameter 'type name'" } */ void f4 (extern int); /* { dg-error "storage class specified for unnamed parameter" } */
void f5 (register int); void f5 (register int);
void f6 (static int); /* { dg-error "storage class specified for parameter 'type name'" } */ void f6 (static int); /* { dg-error "storage class specified for unnamed parameter" } */
void f7 (typedef int); /* { dg-error "storage class specified for parameter 'type name'" } */ void f7 (typedef int); /* { dg-error "storage class specified for unnamed parameter" } */
auto int x; /* { dg-error "file-scope declaration of 'x' specifies 'auto'" } */ auto int x; /* { dg-error "file-scope declaration of 'x' specifies 'auto'" } */
register int y; register int y;
......
/* Verify diagnostics for extended identifiers refer to UCNs (in the C
locale). Test #pragma pack diagnostics. */
/* { dg-do compile { target *-*-linux* *-*-cygwin* powerpc*-*-eabi* } } */
/* { dg-options "-std=gnu99 -fextended-identifiers" } */
#pragma pack(push)
#pragma pack(pop, \u00f3) /* { dg-warning "pop, \\\\U000000f3.*push, \\\\U000000f3" } */
#pragma pack(\u00e7) /* { dg-warning "unknown action '\\\\U000000e7'" } */
/* Verify diagnostics for extended identifiers refer to UCNs (in the C
locale). Further tests of C front-end diagnostics. */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -fextended-identifiers -Wvla" } */
int a __attribute__((__mode__(\u00e9))); /* { dg-error "unknown machine mode '\\\\U000000e9'" } */
struct s1 { int \u00e9 : 0; }; /* { dg-error "zero width for bit-field '\\\\U000000e9'" } */
void f (int b) { int \u00e9[b]; } /* { dg-warning "variable length array '\\\\U000000e9'" } */
void g (static int \u00e9); /* { dg-error "storage class specified for parameter '\\\\U000000e9'" } */
struct s2 { int \u00e1; } \u00e9 = { { 0 } }; /* { dg-warning "braces around scalar initializer" } */
/* { dg-warning "near initialization for '\\\\U000000e9\\.\\\\U000000e1'" "UCN diag" { target *-*-* } 13 } */
/* Test __func__ with extended identifiers and character set
conversions. */
/* { dg-do run } */
/* { dg-xfail-if "" { "powerpc-ibm-aix*" } { "*" } { "" } } */
/* { dg-options "-std=c99 -fextended-identifiers -fexec-charset=ISO-8859-1" } */
/* { dg-require-iconv "ISO-8859-1" } */
extern int strcmp (const char *, const char *);
extern void abort (void);
extern void exit (int);
void
\u00e9 (void)
{
if (strcmp (__func__, "\u00e9") != 0)
abort ();
}
int
main (void)
{
\u00e9 ();
exit (0);
}
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