diff options
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r-- | gcc/c-typeck.c | 386 |
1 files changed, 147 insertions, 239 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index ab3ede71f50..a16760282b4 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -37,6 +37,7 @@ Boston, MA 02111-1307, USA. */ #include "rtl.h" #include "expr.h" #include "toplev.h" +#include "intl.h" /* Nonzero if we've already printed a "missing braces around initializer" message within this initializer. */ @@ -64,9 +65,7 @@ static void push_member_name PROTO((tree)); static void push_array_bounds PROTO((int)); static int spelling_length PROTO((void)); static char *print_spelling PROTO((char *)); -static char *get_spelling PROTO((char *)); -static void warning_init PROTO((char *, char *, - char *)); +static void warning_init PROTO((char *)); static tree digest_init PROTO((tree, tree, int, int)); static void check_init_type_bitfields PROTO((tree)); static void output_init_element PROTO((tree, tree, tree, int)); @@ -101,7 +100,7 @@ incomplete_type_error (value, type) tree value; tree type; { - char *errmsg; + char *type_code_string; /* Avoid duplicate error message. */ if (TREE_CODE (type) == ERROR_MARK) @@ -119,15 +118,15 @@ incomplete_type_error (value, type) switch (TREE_CODE (type)) { case RECORD_TYPE: - errmsg = "invalid use of undefined type `struct %s'"; + type_code_string = "struct"; break; case UNION_TYPE: - errmsg = "invalid use of undefined type `union %s'"; + type_code_string = "union"; break; case ENUMERAL_TYPE: - errmsg = "invalid use of undefined type `enum %s'"; + type_code_string = "enum"; break; case VOID_TYPE: @@ -148,7 +147,8 @@ incomplete_type_error (value, type) } if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) - error (errmsg, IDENTIFIER_POINTER (TYPE_NAME (type))); + error ("invalid use of undefined type `%s %s'", + type_code_string, IDENTIFIER_POINTER (TYPE_NAME (type))); else /* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL. */ error ("invalid use of incomplete typedef `%s'", @@ -2790,7 +2790,6 @@ build_unary_op (code, xarg, noconvert) register tree arg = xarg; register tree argtype = 0; register enum tree_code typecode = TREE_CODE (TREE_TYPE (arg)); - char *errstring = NULL; tree val; if (typecode == ERROR_MARK) @@ -2806,7 +2805,10 @@ build_unary_op (code, xarg, noconvert) associativity, but won't generate any code. */ if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE || typecode == COMPLEX_TYPE)) - errstring = "wrong type argument to unary plus"; + { + error ("wrong type argument to unary plus"); + return error_mark_node; + } else if (!noconvert) arg = default_conversion (arg); break; @@ -2814,7 +2816,10 @@ build_unary_op (code, xarg, noconvert) case NEGATE_EXPR: if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE || typecode == COMPLEX_TYPE)) - errstring = "wrong type argument to unary minus"; + { + error ("wrong type argument to unary minus"); + return error_mark_node; + } else if (!noconvert) arg = default_conversion (arg); break; @@ -2827,7 +2832,10 @@ build_unary_op (code, xarg, noconvert) arg = default_conversion (arg); } else if (typecode != INTEGER_TYPE) - errstring = "wrong type argument to bit-complement"; + { + error ("wrong type argument to bit-complement"); + return error_mark_node; + } else if (!noconvert) arg = default_conversion (arg); break; @@ -2835,7 +2843,10 @@ build_unary_op (code, xarg, noconvert) case ABS_EXPR: if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE || typecode == COMPLEX_TYPE)) - errstring = "wrong type argument to abs"; + { + error ("wrong type argument to abs"); + return error_mark_node; + } else if (!noconvert) arg = default_conversion (arg); break; @@ -2844,7 +2855,10 @@ build_unary_op (code, xarg, noconvert) /* Conjugating a real value is a no-op, but allow it anyway. */ if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE || typecode == COMPLEX_TYPE)) - errstring = "wrong type argument to conjugation"; + { + error ("wrong type argument to conjugation"); + return error_mark_node; + } else if (!noconvert) arg = default_conversion (arg); break; @@ -2856,8 +2870,8 @@ build_unary_op (code, xarg, noconvert) /* These will convert to a pointer. */ && typecode != ARRAY_TYPE && typecode != FUNCTION_TYPE) { - errstring = "wrong type argument to unary exclamation mark"; - break; + error ("wrong type argument to unary exclamation mark"); + return error_mark_node; } arg = truthvalue_conversion (arg); return invert_truthvalue (arg); @@ -2910,11 +2924,10 @@ build_unary_op (code, xarg, noconvert) if (typecode != POINTER_TYPE && typecode != INTEGER_TYPE && typecode != REAL_TYPE) { - if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR) - errstring ="wrong type argument to increment"; - else - errstring ="wrong type argument to decrement"; - break; + error (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR + ? "wrong type argument to increment" + : "wrong type argument to decrement"); + return error_mark_node; } { @@ -2931,17 +2944,15 @@ build_unary_op (code, xarg, noconvert) /* If pointer target is an undefined struct, we just cannot know how to do the arithmetic. */ if (TYPE_SIZE (TREE_TYPE (result_type)) == 0) - error ("%s of pointer to unknown structure", - ((code == PREINCREMENT_EXPR - || code == POSTINCREMENT_EXPR) - ? "increment" : "decrement")); + error (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR + ? "increment of pointer to unknown structure" + : "decrement of pointer to unknown structure"); else if ((pedantic || warn_pointer_arith) && (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE || TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE)) - pedwarn ("wrong type argument to %s", - ((code == PREINCREMENT_EXPR - || code == POSTINCREMENT_EXPR) - ? "increment" : "decrement")); + pedwarn (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR + ? "wrong type argument to increment" + : "wrong type argument to decrement"); inc = c_size_in_bytes (TREE_TYPE (result_type)); } else @@ -2998,7 +3009,8 @@ build_unary_op (code, xarg, noconvert) /* Complain about anything else that is not a true lvalue. */ if (!lvalue_or_else (arg, ((code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR) - ? "increment" : "decrement"))) + ? "invalid lvalue in increment" + : "invalid lvalue in decrement"))) return error_mark_node; /* Report a read-only lvalue. */ @@ -3072,7 +3084,8 @@ build_unary_op (code, xarg, noconvert) ; /* Anything not already handled and not a true memory reference is an error. */ - else if (typecode != FUNCTION_TYPE && !lvalue_or_else (arg, "unary `&'")) + else if (typecode != FUNCTION_TYPE + && !lvalue_or_else (arg, "invalid lvalue in unary `&'")) return error_mark_node; /* Ordinary case; arg is a COMPONENT_REF or a decl. */ @@ -3140,15 +3153,9 @@ build_unary_op (code, xarg, noconvert) break; } - if (!errstring) - { - if (argtype == 0) - argtype = TREE_TYPE (arg); - return fold (build1 (code, argtype, arg)); - } - - error (errstring); - return error_mark_node; + if (argtype == 0) + argtype = TREE_TYPE (arg); + return fold (build1 (code, argtype, arg)); } #if 0 @@ -3222,13 +3229,13 @@ lvalue_p (ref) otherwise, print an error message and return zero. */ int -lvalue_or_else (ref, string) +lvalue_or_else (ref, msgid) tree ref; - char *string; + char *msgid; { int win = lvalue_p (ref); if (! win) - error ("invalid lvalue in %s", string); + error (msgid); return win; } @@ -3281,47 +3288,38 @@ pedantic_lvalue_warning (code) enum tree_code code; { if (pedantic) - pedwarn ("ANSI C forbids use of %s expressions as lvalues", - code == COND_EXPR ? "conditional" - : code == COMPOUND_EXPR ? "compound" : "cast"); + pedwarn (code == COND_EXPR + ? "ANSI C forbids use of conditional expressions as lvalues" + : code == COMPOUND_EXPR + ? "ANSI C forbids use of compound expressions as lvalues" + : "ANSI C forbids use of cast expressions as lvalues"); } /* Warn about storing in something that is `const'. */ void -readonly_warning (arg, string) +readonly_warning (arg, msgid) tree arg; - char *string; + char *msgid; { - char buf[80]; - strcpy (buf, string); - /* Forbid assignments to iterators. */ if (TREE_CODE (arg) == VAR_DECL && ITERATOR_P (arg)) - { - strcat (buf, " of iterator `%s'"); - pedwarn (buf, IDENTIFIER_POINTER (DECL_NAME (arg))); - } + pedwarn ("%s of iterator `%s'", _(msgid), + IDENTIFIER_POINTER (DECL_NAME (arg))); if (TREE_CODE (arg) == COMPONENT_REF) { if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0)))) - readonly_warning (TREE_OPERAND (arg, 0), string); + readonly_warning (TREE_OPERAND (arg, 0), msgid); else - { - strcat (buf, " of read-only member `%s'"); - pedwarn (buf, IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (arg, 1)))); - } + pedwarn ("%s of read-only member `%s'", _(msgid), + IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (arg, 1)))); } else if (TREE_CODE (arg) == VAR_DECL) - { - strcat (buf, " of read-only variable `%s'"); - pedwarn (buf, IDENTIFIER_POINTER (DECL_NAME (arg))); - } + pedwarn ("%s of read-only variable `%s'", _(msgid), + IDENTIFIER_POINTER (DECL_NAME (arg))); else - { - pedwarn ("%s of read-only location", buf); - } + pedwarn ("%s of read-only location", _(msgid)); } /* Mark EXP saying that we need to be able to take the @@ -3963,7 +3961,7 @@ build_modify_expr (lhs, modifycode, rhs) /* Now we have handled acceptable kinds of LHS that are not truly lvalues. Reject anything strange now. */ - if (!lvalue_or_else (lhs, "assignment")) + if (!lvalue_or_else (lhs, "invalid lvalue in assignment")) return error_mark_node; /* Warn about storing in something that is `const'. */ @@ -3996,7 +3994,7 @@ build_modify_expr (lhs, modifycode, rhs) /* Convert new value to destination type. */ - newrhs = convert_for_assignment (lhstype, newrhs, "assignment", + newrhs = convert_for_assignment (lhstype, newrhs, _("assignment"), NULL_TREE, NULL_TREE, 0); if (TREE_CODE (newrhs) == ERROR_MARK) return error_mark_node; @@ -4011,7 +4009,7 @@ build_modify_expr (lhs, modifycode, rhs) if (olhstype == TREE_TYPE (result)) return result; - return convert_for_assignment (olhstype, result, "assignment", + return convert_for_assignment (olhstype, result, _("assignment"), NULL_TREE, NULL_TREE, 0); } @@ -4022,9 +4020,7 @@ build_modify_expr (lhs, modifycode, rhs) for assignments that are not allowed in C. ERRTYPE is a string to use in error messages: "assignment", "return", etc. If it is null, this is parameter passing - for a function call (and different error messages are output). Otherwise, - it may be a name stored in the spelling stack and interpreted by - get_spelling. + for a function call (and different error messages are output). FUNNAME is the name of the function being called, as an IDENTIFIER_NODE, or null. @@ -4159,12 +4155,11 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum) vice-versa. */ if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr)) warn_for_assignment ("%s makes qualified function pointer from unqualified", - get_spelling (errtype), funname, - parmnum); + errtype, funname, parmnum); } else if (TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl)) warn_for_assignment ("%s discards qualifiers from pointer target type", - get_spelling (errtype), funname, + errtype, funname, parmnum); } @@ -4200,7 +4195,7 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum) && (!integer_zerop (rhs) || TREE_CODE (rhs) == NOP_EXPR) && TREE_CODE (ttl) == FUNCTION_TYPE))) warn_for_assignment ("ANSI forbids %s between function pointer and `void *'", - get_spelling (errtype), funname, parmnum); + errtype, funname, parmnum); /* Const and volatile mean something different for function types, so the usual warnings are not appropriate. */ else if (TREE_CODE (ttr) != FUNCTION_TYPE @@ -4208,7 +4203,7 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum) { if (TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl)) warn_for_assignment ("%s discards qualifiers from pointer target type", - get_spelling (errtype), funname, parmnum); + errtype, funname, parmnum); /* If this is not a case of ignoring a mismatch in signedness, no warning. */ else if (TYPE_MAIN_VARIANT (ttl) == void_type_node @@ -4218,7 +4213,7 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum) /* If there is a mismatch, do warn. */ else if (pedantic) warn_for_assignment ("pointer targets in %s differ in signedness", - get_spelling (errtype), funname, parmnum); + errtype, funname, parmnum); } else if (TREE_CODE (ttl) == FUNCTION_TYPE && TREE_CODE (ttr) == FUNCTION_TYPE) @@ -4229,12 +4224,12 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum) where an ordinary one is wanted, but not vice-versa. */ if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr)) warn_for_assignment ("%s makes qualified function pointer from unqualified", - get_spelling (errtype), funname, parmnum); + errtype, funname, parmnum); } } else warn_for_assignment ("%s from incompatible pointer type", - get_spelling (errtype), funname, parmnum); + errtype, funname, parmnum); return convert (type, rhs); } else if (codel == POINTER_TYPE && coder == INTEGER_TYPE) @@ -4250,7 +4245,7 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum) && integer_zerop (TREE_OPERAND (rhs, 0)))) { warn_for_assignment ("%s makes pointer from integer without a cast", - get_spelling (errtype), funname, parmnum); + errtype, funname, parmnum); return convert (type, rhs); } return null_pointer_node; @@ -4258,7 +4253,7 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum) else if (codel == INTEGER_TYPE && coder == POINTER_TYPE) { warn_for_assignment ("%s makes integer from pointer without a cast", - get_spelling (errtype), funname, parmnum); + errtype, funname, parmnum); return convert (type, rhs); } @@ -4280,27 +4275,24 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum) parmnum); } else - error ("incompatible types in %s", get_spelling (errtype)); + error ("incompatible types in %s", errtype); return error_mark_node; } -/* Print a warning using MSG. +/* Print a warning using MSGID. It gets OPNAME as its one parameter. If OPNAME is null, it is replaced by "passing arg ARGNUM of `FUNCTION'". FUNCTION and ARGNUM are handled specially if we are building an Objective-C selector. */ static void -warn_for_assignment (msg, opname, function, argnum) - char *msg; +warn_for_assignment (msgid, opname, function, argnum) + char *msgid; char *opname; tree function; int argnum; { - static char argstring[] = "passing arg %d of `%s'"; - static char argnofun[] = "passing arg %d"; - if (opname == 0) { tree selector = maybe_building_objc_message_expr (); @@ -4313,18 +4305,20 @@ warn_for_assignment (msg, opname, function, argnum) if (function) { /* Function name is known; supply it. */ + char *argstring = _("passing arg %d of `%s'"); opname = (char *) alloca (IDENTIFIER_LENGTH (function) - + sizeof (argstring) + 25 /*%d*/ + 1); + + strlen (argstring) + 1 + 25 /*%d*/ + 1); sprintf (opname, argstring, argnum, IDENTIFIER_POINTER (function)); } else { /* Function name unknown (call through ptr); just give arg number. */ - opname = (char *) alloca (sizeof (argnofun) + 25 /*%d*/ + 1); + char *argnofun = _("passing arg %d of pointer to function"); + opname = (char *) alloca (strlen (argnofun) + 1 + 25 /*%d*/ + 1); sprintf (opname, argnofun, argnum); } } - pedwarn (msg, opname); + pedwarn (msgid, opname); } /* Return nonzero if VALUE is a valid constant-valued expression @@ -4691,115 +4685,52 @@ print_spelling (buffer) return buffer; } -/* Provide a means to pass component names derived from the spelling stack. */ - -char initialization_message; - -/* Interpret the spelling of the given ERRTYPE message. */ - -static char * -get_spelling (errtype) - char *errtype; -{ - static char *buffer; - static int size = -1; - - if (errtype == &initialization_message) - { - /* Avoid counting chars */ - static char message[] = "initialization of `%s'"; - register int needed = sizeof (message) + spelling_length () + 1; - char *temp; - - if (size < 0) - buffer = (char *) xmalloc (size = needed); - if (needed > size) - buffer = (char *) xrealloc (buffer, size = needed); - - temp = (char *) alloca (needed); - sprintf (buffer, message, print_spelling (temp)); - return buffer; - } - - return errtype; -} - /* Issue an error message for a bad initializer component. - FORMAT describes the message. OFWHAT is the name for the component. - LOCAL is a format string for formatting the insertion of the name - into the message. - - If OFWHAT is null, the component name is stored on the spelling stack. - If the component name is a null string, then LOCAL is omitted entirely. */ + MSGID identifies the message. + The component name is taken from the spelling stack. */ void -error_init (format, local, ofwhat) - char *format, *local, *ofwhat; +error_init (msgid) + char *msgid; { - char *buffer; - - if (ofwhat == 0) - ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); - buffer = (char *) alloca (strlen (local) + strlen (ofwhat) + 2); + char *ofwhat; + error (msgid); + ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); if (*ofwhat) - sprintf (buffer, local, ofwhat); - else - buffer[0] = 0; - - error (format, buffer); + error ("(near initialization for `%s')", ofwhat); } /* Issue a pedantic warning for a bad initializer component. - FORMAT describes the message. OFWHAT is the name for the component. - LOCAL is a format string for formatting the insertion of the name - into the message. - - If OFWHAT is null, the component name is stored on the spelling stack. - If the component name is a null string, then LOCAL is omitted entirely. */ + MSGID identifies the message. + The component name is taken from the spelling stack. */ void -pedwarn_init (format, local, ofwhat) - char *format, *local, *ofwhat; +pedwarn_init (msgid) + char *msgid; { - char *buffer; - - if (ofwhat == 0) - ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); - buffer = (char *) alloca (strlen (local) + strlen (ofwhat) + 2); + char *ofwhat; + pedwarn (msgid); + ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); if (*ofwhat) - sprintf (buffer, local, ofwhat); - else - buffer[0] = 0; - - pedwarn (format, buffer); + pedwarn ("(near initialization for `%s')", ofwhat); } /* Issue a warning for a bad initializer component. - FORMAT describes the message. OFWHAT is the name for the component. - LOCAL is a format string for formatting the insertion of the name - into the message. - - If OFWHAT is null, the component name is stored on the spelling stack. - If the component name is a null string, then LOCAL is omitted entirely. */ + MSGID identifies the message. + The component name is taken from the spelling stack. */ static void -warning_init (format, local, ofwhat) - char *format, *local, *ofwhat; +warning_init (msgid) + char *msgid; { - char *buffer; - - if (ofwhat == 0) - ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); - buffer = (char *) alloca (strlen (local) + strlen (ofwhat) + 2); + char *ofwhat; + warning (msgid); + ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); if (*ofwhat) - sprintf (buffer, local, ofwhat); - else - buffer[0] = 0; - - warning (format, buffer); + warning ("(near initialization for `%s')", ofwhat); } /* Digest the parser output INIT as an initializer for type TYPE. @@ -4847,16 +4778,14 @@ digest_init (type, init, require_constant, constructor_constant) != char_type_node) && TYPE_PRECISION (typ1) == TYPE_PRECISION (char_type_node)) { - error_init ("char-array%s initialized from wide string", - " `%s'", NULL); + error_init ("char-array initialized from wide string"); return error_mark_node; } if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init))) == char_type_node) && TYPE_PRECISION (typ1) != TYPE_PRECISION (char_type_node)) { - error_init ("int-array%s initialized from non-wide string", - " `%s'", NULL); + error_init ("int-array initialized from non-wide string"); return error_mark_node; } @@ -4873,9 +4802,7 @@ digest_init (type, init, require_constant, constructor_constant) - (TYPE_PRECISION (typ1) != TYPE_PRECISION (char_type_node) ? TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT : 1)) - pedwarn_init ( - "initializer-string for array of chars%s is too long", - " `%s'", NULL); + pedwarn_init ("initializer-string for array of chars is too long"); } return inside_init; } @@ -4902,8 +4829,7 @@ digest_init (type, init, require_constant, constructor_constant) else if (code == ARRAY_TYPE && TREE_CODE (inside_init) != STRING_CST && TREE_CODE (inside_init) != CONSTRUCTOR) { - error_init ("array%s initialized from non-constant array expression", - " `%s'", NULL); + error_init ("array initialized from non-constant array expression"); return error_mark_node; } @@ -4920,25 +4846,21 @@ digest_init (type, init, require_constant, constructor_constant) = valid_compound_expr_initializer (inside_init, TREE_TYPE (inside_init)); if (inside_init == error_mark_node) - error_init ("initializer element%s is not constant", - " for `%s'", NULL); + error_init ("initializer element is not constant"); else - pedwarn_init ("initializer element%s is not constant", - " for `%s'", NULL); + pedwarn_init ("initializer element is not constant"); if (flag_pedantic_errors) inside_init = error_mark_node; } else if (require_constant && ! TREE_CONSTANT (inside_init)) { - error_init ("initializer element%s is not constant", - " for `%s'", NULL); + error_init ("initializer element is not constant"); inside_init = error_mark_node; } else if (require_constant && initializer_constant_valid_p (inside_init, TREE_TYPE (inside_init)) == 0) { - error_init ("initializer element%s is not computable at load time", - " for `%s'", NULL); + error_init ("initializer element is not computable at load time"); inside_init = error_mark_node; } @@ -4954,20 +4876,18 @@ digest_init (type, init, require_constant, constructor_constant) for arrays and functions. We must not call it in the case where inside_init is a null pointer constant. */ inside_init - = convert_for_assignment (type, init, "initialization", + = convert_for_assignment (type, init, _("initialization"), NULL_TREE, NULL_TREE, 0); if (require_constant && ! TREE_CONSTANT (inside_init)) { - error_init ("initializer element%s is not constant", - " for `%s'", NULL); + error_init ("initializer element is not constant"); inside_init = error_mark_node; } else if (require_constant && initializer_constant_valid_p (inside_init, TREE_TYPE (inside_init)) == 0) { - error_init ("initializer element%s is not computable at load time", - " for `%s'", NULL); + error_init ("initializer element is not computable at load time"); inside_init = error_mark_node; } @@ -4978,8 +4898,7 @@ digest_init (type, init, require_constant, constructor_constant) if (TYPE_SIZE (type) && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) { - error_init ("variable-sized object%s may not be initialized", - " `%s'", NULL); + error_init ("variable-sized object may not be initialized"); return error_mark_node; } @@ -5005,7 +4924,7 @@ digest_init (type, init, require_constant, constructor_constant) type = TREE_TYPE (TYPE_FIELDS (type)); else { - error_init ("invalid initializer%s", " for `%s'", NULL); + error_init ("invalid initializer"); return error_mark_node; } } @@ -5021,7 +4940,7 @@ digest_init (type, init, require_constant, constructor_constant) else return error_mark_node; } - error_init ("invalid initializer%s", " for `%s'", NULL); + error_init ("invalid initializer"); return error_mark_node; } @@ -5498,8 +5417,7 @@ push_init_level (implicit) if (constructor_type == 0) { - error_init ("extra brace group at end of initializer%s", - " for `%s'", NULL); + error_init ("extra brace group at end of initializer"); constructor_fields = 0; constructor_unfilled_fields = 0; return; @@ -5511,7 +5429,7 @@ push_init_level (implicit) if (implicit && warn_missing_braces && !missing_braces_mentioned) { missing_braces_mentioned = 1; - warning_init ("missing braces around initializer%s", " for `%s'", NULL); + warning_init ("missing braces around initializer"); } if (TREE_CODE (constructor_type) == RECORD_TYPE @@ -5542,7 +5460,7 @@ push_init_level (implicit) } else { - warning_init ("braces around scalar initializer%s", " for `%s'", NULL); + warning_init ("braces around scalar initializer"); constructor_fields = constructor_type; constructor_unfilled_fields = constructor_type; } @@ -5614,7 +5532,7 @@ pop_init_level (implicit) && constructor_unfilled_fields) { push_member_name (constructor_unfilled_fields); - warning_init ("missing initializer%s", " for `%s'", NULL); + warning_init ("missing initializer"); RESTORE_SPELLING_DEPTH (constructor_depth); } @@ -5627,7 +5545,7 @@ pop_init_level (implicit) && (TREE_CODE (constructor_type) == ARRAY_TYPE ? integer_zerop (constructor_unfilled_index) : constructor_unfilled_fields == TYPE_FIELDS (constructor_type))) - pedwarn_init ("empty braces in initializer%s", " for `%s'", NULL); + pedwarn_init ("empty braces in initializer"); #endif /* Pad out the end of the structure. */ @@ -5691,14 +5609,12 @@ pop_init_level (implicit) the element, after verifying there is just one. */ if (constructor_elements == 0) { - error_init ("empty scalar initializer%s", - " for `%s'", NULL); + error_init ("empty scalar initializer"); constructor = error_mark_node; } else if (TREE_CHAIN (constructor_elements) != 0) { - error_init ("extra elements in scalar initializer%s", - " for `%s'", NULL); + error_init ("extra elements in scalar initializer"); constructor = TREE_VALUE (constructor_elements); } else @@ -5832,20 +5748,20 @@ set_init_index (first, last) (last) = TREE_OPERAND (last, 0); if (TREE_CODE (first) != INTEGER_CST) - error_init ("nonconstant array index in initializer%s", " for `%s'", NULL); + error_init ("nonconstant array index in initializer"); else if (last != 0 && TREE_CODE (last) != INTEGER_CST) - error_init ("nonconstant array index in initializer%s", " for `%s'", NULL); + error_init ("nonconstant array index in initializer"); else if (! constructor_unfilled_index) - error_init ("array index in non-array initializer%s", " for `%s'", NULL); + error_init ("array index in non-array initializer"); else if (tree_int_cst_lt (first, constructor_unfilled_index)) - error_init ("duplicate array index in initializer%s", " for `%s'", NULL); + error_init ("duplicate array index in initializer"); else { TREE_INT_CST_LOW (constructor_index) = TREE_INT_CST_LOW (first); TREE_INT_CST_HIGH (constructor_index) = TREE_INT_CST_HIGH (first); if (last != 0 && tree_int_cst_lt (last, first)) - error_init ("empty index range in initializer%s", " for `%s'", NULL); + error_init ("empty index range in initializer"); else { if (pedantic) @@ -6176,15 +6092,13 @@ output_init_element (value, type, field, pending) if (require_constant_value && ! TREE_CONSTANT (value)) { - error_init ("initializer element%s is not constant", - " for `%s'", NULL); + error_init ("initializer element is not constant"); value = error_mark_node; } else if (require_constant_elements && initializer_constant_valid_p (value, TREE_TYPE (value)) == 0) { - error_init ("initializer element%s is not computable at load time", - " for `%s'", NULL); + error_init ("initializer element is not computable at load time"); value = error_mark_node; } @@ -6200,7 +6114,7 @@ output_init_element (value, type, field, pending) { if (pending_init_member (field)) { - error_init ("duplicate initializer%s", " for `%s'", NULL); + error_init ("duplicate initializer"); duplicate = 1; } } @@ -6553,8 +6467,7 @@ process_init_element (value) if (constructor_stack->replacement_value != 0) { - error_init ("excess elements in struct initializer%s", - " after `%s'", NULL_PTR); + error_init ("excess elements in struct initializer"); return; } @@ -6589,8 +6502,7 @@ process_init_element (value) if (constructor_fields == 0) { - pedwarn_init ("excess elements in struct initializer%s", - " after `%s'", NULL_PTR); + pedwarn_init ("excess elements in struct initializer"); break; } @@ -6654,8 +6566,7 @@ process_init_element (value) if (constructor_fields == 0) { - pedwarn_init ("excess elements in union initializer%s", - " after `%s'", NULL_PTR); + pedwarn_init ("excess elements in union initializer"); break; } @@ -6729,8 +6640,7 @@ process_init_element (value) if (constructor_max_index != 0 && tree_int_cst_lt (constructor_max_index, constructor_index)) { - pedwarn_init ("excess elements in array initializer%s", - " after `%s'", NULL_PTR); + pedwarn_init ("excess elements in array initializer"); break; } @@ -6741,8 +6651,7 @@ process_init_element (value) && tree_int_cst_lt (constructor_max_index, constructor_range_end)) { - pedwarn_init ("excess elements in array initializer%s", - " after `%s'", NULL_PTR); + pedwarn_init ("excess elements in array initializer"); TREE_INT_CST_HIGH (constructor_range_end) = TREE_INT_CST_HIGH (constructor_max_index); TREE_INT_CST_LOW (constructor_range_end) @@ -6793,8 +6702,7 @@ process_init_element (value) for a scalar variable. */ if (constructor_fields == 0) { - pedwarn_init ("excess elements in scalar initializer%s", - " after `%s'", NULL_PTR); + pedwarn_init ("excess elements in scalar initializer"); break; } @@ -6911,7 +6819,7 @@ c_expand_return (retval) } else { - tree t = convert_for_assignment (valtype, retval, "return", + tree t = convert_for_assignment (valtype, retval, _("return"), NULL_TREE, NULL_TREE, 0); tree res = DECL_RESULT (current_function_decl); tree inner; |