aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2014-05-02 07:57:59 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2014-05-02 07:57:59 +0000
commit63bc4e87340a250fb1068267ce635b2da51535e5 (patch)
treedb76bc80d6ef416ebd1316c430e932a7a24ef307 /gcc
parented15c5984e10f6556dffdf397accff804bf60a7c (diff)
downloadgcc-63bc4e87340a250fb1068267ce635b2da51535e5.zip
gcc-63bc4e87340a250fb1068267ce635b2da51535e5.tar.gz
gcc-63bc4e87340a250fb1068267ce635b2da51535e5.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c/ChangeLog9
-rw-r--r--gcc/c/c-tree.h2
-rw-r--r--gcc/c/c-typeck.c132
3 files changed, 75 insertions, 68 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 4931e79..e3c13fe 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,12 @@
+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>
Revert:
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index 53768d6..a6e7327 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -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 build_c_cast (location_t, 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 start_init (tree, tree, int);
extern void finish_init (void);
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 98567b4..b95fd89 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -5542,6 +5542,72 @@ convert_to_anonymous_field (location_t location, tree type, tree rhs)
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
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
@@ -6407,72 +6473,6 @@ print_spelling (char *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.
Return a C expression of type TYPE to represent the initial value.