if (TREE_CODE (init) == NON_LVALUE_EXPR)
init = TREE_OPERAND (init, 0);
+ location_t loc = EXPR_LOC_OR_LOC (init, input_location);
+
/* Initialization of an array of chars from a string constant. The initializer
can be optionally enclosed in braces, but reshape_init has already removed
them if they were present. */
if (nested && !TYPE_DOMAIN (type))
{
/* C++ flexible array members have a null domain. */
- pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wpedantic,
+ pedwarn (loc, OPT_Wpedantic,
"initialization of a flexible array member");
}
if (char_type != char_type_node)
{
if (complain & tf_error)
- error ("char-array initialized from wide string");
+ error_at (loc, "char-array initialized from wide string");
return error_mark_node;
}
}
if (char_type == char_type_node)
{
if (complain & tf_error)
- error ("int-array initialized from non-wide string");
+ error_at (loc,
+ "int-array initialized from non-wide string");
return error_mark_node;
}
else if (char_type != typ1)
{
if (complain & tf_error)
- error ("int-array initialized from incompatible "
- "wide string");
+ error_at (loc, "int-array initialized from incompatible "
+ "wide string");
return error_mark_node;
}
}
counted in the length of the constant, but in C++ this would
be invalid. */
if (size < TREE_STRING_LENGTH (init))
- permerror (input_location, "initializer-string for array "
+ permerror (loc, "initializer-string for array "
"of chars is too long");
}
return init;
if (COMPOUND_LITERAL_P (init) && TREE_CODE (type) == ARRAY_TYPE)
{
if (complain & tf_error)
- error ("cannot initialize aggregate of type %qT with "
- "a compound literal", type);
+ error_at (loc, "cannot initialize aggregate of type %qT with "
+ "a compound literal", type);
return error_mark_node;
}
return init;
if (complain & tf_error)
- error ("array must be initialized with a brace-enclosed"
- " initializer");
+ error_at (loc, "array must be initialized with a brace-enclosed"
+ " initializer");
return error_mark_node;
}