Commit 63bc4e87 by Marek Polacek Committed by Marek Polacek

c-tree.h (error_init): Remove declaration.

	* c-tree.h (error_init): Remove declaration.
	(pedwarn_init): Likewise.
	* c-typeck.c (error_init): Make static and move above.
	(pedwarn_init): Likewise.
	(warning_init): Move above.
	(maybe_warn_string_init): Likewise.

From-SVN: r210001
parent ed15c598
2014-05-02 Marek Polacek <polacek@redhat.com>
* c-tree.h (error_init): Remove declaration.
(pedwarn_init): Likewise.
* c-typeck.c (error_init): Make static and move above.
(pedwarn_init): Likewise.
(warning_init): Move above.
(maybe_warn_string_init): Likewise.
2014-05-01 Jeff Law <law@redhat.com> 2014-05-01 Jeff Law <law@redhat.com>
Revert: Revert:
......
...@@ -602,8 +602,6 @@ extern tree build_compound_expr (location_t, tree, tree); ...@@ -602,8 +602,6 @@ extern tree build_compound_expr (location_t, tree, tree);
extern tree c_cast_expr (location_t, struct c_type_name *, tree); extern tree c_cast_expr (location_t, struct c_type_name *, tree);
extern tree build_c_cast (location_t, tree, tree); extern tree build_c_cast (location_t, tree, tree);
extern void store_init_value (location_t, tree, tree, tree); extern void store_init_value (location_t, tree, tree, tree);
extern void error_init (const char *);
extern void pedwarn_init (location_t, int opt, const char *);
extern void maybe_warn_string_init (tree, struct c_expr); extern void maybe_warn_string_init (tree, struct c_expr);
extern void start_init (tree, tree, int); extern void start_init (tree, tree, int);
extern void finish_init (void); extern void finish_init (void);
......
...@@ -5542,6 +5542,72 @@ convert_to_anonymous_field (location_t location, tree type, tree rhs) ...@@ -5542,6 +5542,72 @@ convert_to_anonymous_field (location_t location, tree type, tree rhs)
return ret; return ret;
} }
/* Issue an error message for a bad initializer component.
GMSGID identifies the message.
The component name is taken from the spelling stack. */
static void
error_init (const char *gmsgid)
{
char *ofwhat;
/* The gmsgid may be a format string with %< and %>. */
error (gmsgid);
ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
if (*ofwhat)
error ("(near initialization for %qs)", ofwhat);
}
/* Issue a pedantic warning for a bad initializer component. OPT is
the option OPT_* (from options.h) controlling this warning or 0 if
it is unconditionally given. GMSGID identifies the message. The
component name is taken from the spelling stack. */
static void
pedwarn_init (location_t location, int opt, const char *gmsgid)
{
char *ofwhat;
/* The gmsgid may be a format string with %< and %>. */
pedwarn (location, opt, gmsgid);
ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
if (*ofwhat)
pedwarn (location, opt, "(near initialization for %qs)", ofwhat);
}
/* Issue a warning for a bad initializer component.
OPT is the OPT_W* value corresponding to the warning option that
controls this warning. GMSGID identifies the message. The
component name is taken from the spelling stack. */
static void
warning_init (location_t loc, int opt, const char *gmsgid)
{
char *ofwhat;
/* The gmsgid may be a format string with %< and %>. */
warning_at (loc, opt, gmsgid);
ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
if (*ofwhat)
warning_at (loc, opt, "(near initialization for %qs)", ofwhat);
}
/* If TYPE is an array type and EXPR is a parenthesized string
constant, warn if pedantic that EXPR is being used to initialize an
object of type TYPE. */
void
maybe_warn_string_init (tree type, struct c_expr expr)
{
if (pedantic
&& TREE_CODE (type) == ARRAY_TYPE
&& TREE_CODE (expr.value) == STRING_CST
&& expr.original_code != STRING_CST)
pedwarn_init (input_location, OPT_Wpedantic,
"array initialized from parenthesized string constant");
}
/* Convert value RHS to type TYPE as preparation for an assignment to /* Convert value RHS to type TYPE as preparation for an assignment to
an lvalue of type TYPE. If ORIGTYPE is not NULL_TREE, it is the an lvalue of type TYPE. If ORIGTYPE is not NULL_TREE, it is the
original type of RHS; this differs from TREE_TYPE (RHS) for enum original type of RHS; this differs from TREE_TYPE (RHS) for enum
...@@ -6407,72 +6473,6 @@ print_spelling (char *buffer) ...@@ -6407,72 +6473,6 @@ print_spelling (char *buffer)
return buffer; return buffer;
} }
/* Issue an error message for a bad initializer component.
GMSGID identifies the message.
The component name is taken from the spelling stack. */
void
error_init (const char *gmsgid)
{
char *ofwhat;
/* The gmsgid may be a format string with %< and %>. */
error (gmsgid);
ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
if (*ofwhat)
error ("(near initialization for %qs)", ofwhat);
}
/* Issue a pedantic warning for a bad initializer component. OPT is
the option OPT_* (from options.h) controlling this warning or 0 if
it is unconditionally given. GMSGID identifies the message. The
component name is taken from the spelling stack. */
void
pedwarn_init (location_t location, int opt, const char *gmsgid)
{
char *ofwhat;
/* The gmsgid may be a format string with %< and %>. */
pedwarn (location, opt, gmsgid);
ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
if (*ofwhat)
pedwarn (location, opt, "(near initialization for %qs)", ofwhat);
}
/* Issue a warning for a bad initializer component.
OPT is the OPT_W* value corresponding to the warning option that
controls this warning. GMSGID identifies the message. The
component name is taken from the spelling stack. */
static void
warning_init (location_t loc, int opt, const char *gmsgid)
{
char *ofwhat;
/* The gmsgid may be a format string with %< and %>. */
warning_at (loc, opt, gmsgid);
ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
if (*ofwhat)
warning_at (loc, opt, "(near initialization for %qs)", ofwhat);
}
/* If TYPE is an array type and EXPR is a parenthesized string
constant, warn if pedantic that EXPR is being used to initialize an
object of type TYPE. */
void
maybe_warn_string_init (tree type, struct c_expr expr)
{
if (pedantic
&& TREE_CODE (type) == ARRAY_TYPE
&& TREE_CODE (expr.value) == STRING_CST
&& expr.original_code != STRING_CST)
pedwarn_init (input_location, OPT_Wpedantic,
"array initialized from parenthesized string constant");
}
/* Digest the parser output INIT as an initializer for type TYPE. /* Digest the parser output INIT as an initializer for type TYPE.
Return a C expression of type TYPE to represent the initial value. Return a C expression of type TYPE to represent the initial value.
......
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