summaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-10 20:03:57 +0000
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-10 20:03:57 +0000
commitc9e51d2533522d8bf5e4d020295966a37708a5b2 (patch)
treefdf170b705a741473342bef1cba458b93231ff9f /gcc/c
parente34b778b1bef4239e91bada5628280750a7b1b3e (diff)
downloadgcc-c9e51d2533522d8bf5e4d020295966a37708a5b2.tar.gz
* c-parser.c (c_parser_declaration_or_fndef): Pass init_loc to
maybe_warn_string_init. (c_parser_postfix_expression_after_paren_type): Pass type_loc to maybe_warn_string_init. * c-tree.h (maybe_warn_string_init): Update declaration. * c-typeck.c (maybe_warn_string_init): Add location parameter. Call pedwarn_init with loc instead of with input_location. (digest_init): Pass init_loc to maybe_warn_string_init. (pop_init_level): Call pedwarn_init with loc instead of with input_location. (set_init_index): Likewise. (process_init_element): Likewise. * gcc.dg/pedwarn-init.c: New test. * gcc.dg/init-string-1.c: Adjust dg-error. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210300 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog15
-rw-r--r--gcc/c/c-parser.c6
-rw-r--r--gcc/c/c-tree.h2
-rw-r--r--gcc/c/c-typeck.c30
4 files changed, 34 insertions, 19 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 8c71d372bd6..919b4ff5f5f 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,18 @@
+2014-05-10 Marek Polacek <polacek@redhat.com>
+
+ * c-parser.c (c_parser_declaration_or_fndef): Pass init_loc to
+ maybe_warn_string_init.
+ (c_parser_postfix_expression_after_paren_type): Pass type_loc to
+ maybe_warn_string_init.
+ * c-tree.h (maybe_warn_string_init): Update declaration.
+ * c-typeck.c (maybe_warn_string_init): Add location parameter.
+ Call pedwarn_init with loc instead of with input_location.
+ (digest_init): Pass init_loc to maybe_warn_string_init.
+ (pop_init_level): Call pedwarn_init with loc instead of with
+ input_location.
+ (set_init_index): Likewise.
+ (process_init_element): Likewise.
+
2014-05-09 Marek Polacek <polacek@redhat.com>
PR c/61096
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 432bf965228..6e8554dc7d2 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -1777,9 +1777,9 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,
}
if (d != error_mark_node)
{
- maybe_warn_string_init (TREE_TYPE (d), init);
+ maybe_warn_string_init (init_loc, TREE_TYPE (d), init);
finish_decl (d, init_loc, init.value,
- init.original_type, asm_name);
+ init.original_type, asm_name);
}
}
else
@@ -7599,7 +7599,7 @@ c_parser_postfix_expression_after_paren_type (c_parser *parser,
}
init = c_parser_braced_init (parser, type, false);
finish_init ();
- maybe_warn_string_init (type, init);
+ maybe_warn_string_init (type_loc, type, init);
if (type != error_mark_node
&& !ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (type))
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index ae932faf808..e7dcb355e9c 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -602,7 +602,7 @@ 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 maybe_warn_string_init (tree, struct c_expr);
+extern void maybe_warn_string_init (location_t, tree, struct c_expr);
extern void start_init (tree, tree, int);
extern void finish_init (void);
extern void really_start_incremental_init (tree);
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 67988012372..4b1fe66cd6b 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -5596,13 +5596,13 @@ warning_init (location_t loc, int opt, const char *gmsgid)
object of type TYPE. */
void
-maybe_warn_string_init (tree type, struct c_expr expr)
+maybe_warn_string_init (location_t loc, 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,
+ pedwarn_init (loc, OPT_Wpedantic,
"array initialized from parenthesized string constant");
}
@@ -5657,14 +5657,14 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
/* This macro is used to emit diagnostics to ensure that all format
strings are complete sentences, visible to gettext and checked at
compile time. */
-#define WARN_FOR_ASSIGNMENT(LOCATION, OPT, AR, AS, IN, RE) \
+#define WARN_FOR_ASSIGNMENT(LOCATION, OPT, AR, AS, IN, RE) \
do { \
switch (errtype) \
{ \
case ic_argpass: \
if (pedwarn (LOCATION, OPT, AR, parmnum, rname)) \
inform ((fundecl && !DECL_IS_BUILTIN (fundecl)) \
- ? DECL_SOURCE_LOCATION (fundecl) : LOCATION, \
+ ? DECL_SOURCE_LOCATION (fundecl) : LOCATION, \
"expected %qT but argument is of type %qT", \
type, rhstype); \
break; \
@@ -5675,7 +5675,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
pedwarn_init (LOCATION, OPT, IN); \
break; \
case ic_return: \
- pedwarn (LOCATION, OPT, RE); \
+ pedwarn (LOCATION, OPT, RE); \
break; \
default: \
gcc_unreachable (); \
@@ -6541,7 +6541,7 @@ digest_init (location_t init_loc, tree type, tree init, tree origtype,
expr.value = inside_init;
expr.original_code = (strict_string ? STRING_CST : ERROR_MARK);
expr.original_type = NULL;
- maybe_warn_string_init (type, expr);
+ maybe_warn_string_init (init_loc, type, expr);
if (TYPE_DOMAIN (type) && !TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
pedwarn_init (init_loc, OPT_Wpedantic,
@@ -7430,7 +7430,7 @@ pop_init_level (location_t loc, int implicit,
if (constructor_depth > 2)
error_init (loc, "initialization of flexible array member in a nested context");
else
- pedwarn_init (input_location, OPT_Wpedantic,
+ pedwarn_init (loc, OPT_Wpedantic,
"initialization of a flexible array member");
/* We have already issued an error message for the existence
@@ -7650,7 +7650,7 @@ push_range_stack (tree range_end, struct obstack * braced_init_obstack)
void
set_init_index (location_t loc, tree first, tree last,
- struct obstack * braced_init_obstack)
+ struct obstack *braced_init_obstack)
{
if (set_designator (loc, 1, braced_init_obstack))
return;
@@ -7668,7 +7668,7 @@ set_init_index (location_t loc, tree first, tree last,
{
first = c_fully_fold (first, false, NULL);
if (TREE_CODE (first) == INTEGER_CST)
- pedwarn_init (input_location, OPT_Wpedantic,
+ pedwarn_init (loc, OPT_Wpedantic,
"array index in initializer is not "
"an integer constant expression");
}
@@ -7677,7 +7677,7 @@ set_init_index (location_t loc, tree first, tree last,
{
last = c_fully_fold (last, false, NULL);
if (TREE_CODE (last) == INTEGER_CST)
- pedwarn_init (input_location, OPT_Wpedantic,
+ pedwarn_init (loc, OPT_Wpedantic,
"array index in initializer is not "
"an integer constant expression");
}
@@ -8745,7 +8745,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit,
if (constructor_fields == 0)
{
- pedwarn_init (input_location, 0,
+ pedwarn_init (loc, 0,
"excess elements in union initializer");
break;
}
@@ -8835,7 +8835,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit,
&& (tree_int_cst_lt (constructor_max_index, constructor_index)
|| integer_all_onesp (constructor_max_index)))
{
- pedwarn_init (input_location, 0,
+ pedwarn_init (loc, 0,
"excess elements in array initializer");
break;
}
@@ -8869,7 +8869,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit,
always have a fixed size derived from their type. */
if (tree_int_cst_lt (constructor_max_index, constructor_index))
{
- pedwarn_init (input_location, 0,
+ pedwarn_init (loc, 0,
"excess elements in vector initializer");
break;
}
@@ -8901,7 +8901,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit,
else if (constructor_type != error_mark_node
&& constructor_fields == 0)
{
- pedwarn_init (input_location, 0,
+ pedwarn_init (loc, 0,
"excess elements in scalar initializer");
break;
}
@@ -9413,7 +9413,7 @@ do_case (location_t loc, tree low_value, tree high_value)
{
low_value = c_fully_fold (low_value, false, NULL);
if (TREE_CODE (low_value) == INTEGER_CST)
- pedwarn (input_location, OPT_Wpedantic,
+ pedwarn (loc, OPT_Wpedantic,
"case label is not an integer constant expression");
}