Commit 7e4d7898 by Gabriel Dos Reis Committed by Gabriel Dos Reis

decl2.c (lang_decode_option): Set default line-wrap length to 72.

2000-01-19  Gabriel Dos Reis  <gdr@codesourcery>

        * decl2.c (lang_decode_option): Set default line-wrap length to 72.

        * typeck.c (composite_pointer_type, common_type,
        comp_target_parms, c_sizeof, expr_sizeof, build_array_ref,
        build_function_call_real, convert_arguments,
        build_binary_op_nodefault, pointer_int_sum, pointer_diff,
        build_unary_op, mark_addressable, build_compound_expr,
        build_static_cast, build_reinterpret_cast, build_const_cast,
        build_c_cast, build_modify_expr, get_delta_difference,
        build_ptrmemfunc, check_return_expr): Replace 'ANSI C++' with
        'ISO C++'.  Fusion consecutive calls to diagnotic message routines
        into a single one.
        * typeck2.c (readonly_error, abstract_virtuals_error,
        process_init_constructor, check_for_new_type): Likewise.

From-SVN: r31502
parent cfef86e4
2000-01-19 Gabriel Dos Reis <gdr@codesourcery>
* decl2.c (lang_decode_option): Set default line-wrap length to 72.
* typeck.c (composite_pointer_type, common_type,
comp_target_parms, c_sizeof, expr_sizeof, build_array_ref,
build_function_call_real, convert_arguments,
build_binary_op_nodefault, pointer_int_sum, pointer_diff,
build_unary_op, mark_addressable, build_compound_expr,
build_static_cast, build_reinterpret_cast, build_const_cast,
build_c_cast, build_modify_expr, get_delta_difference,
build_ptrmemfunc, check_return_expr): Replace 'ANSI C++' with
'ISO C++'. Fusion consecutive calls to diagnotic message routines
into a single one.
* typeck2.c (readonly_error, abstract_virtuals_error,
process_init_constructor, check_for_new_type): Likewise.
2000-01-19 Mark Mitchell <mark@codesourcery.com> 2000-01-19 Mark Mitchell <mark@codesourcery.com>
* tree.c (bot_manip): Set DECL_CONTEXT for newly created * tree.c (bot_manip): Set DECL_CONTEXT for newly created
......
...@@ -633,7 +633,9 @@ lang_decode_option (argc, argv) ...@@ -633,7 +633,9 @@ lang_decode_option (argc, argv)
name_mangling_version name_mangling_version
= read_integral_parameter (p + 22, p - 2, name_mangling_version); = read_integral_parameter (p + 22, p - 2, name_mangling_version);
else if (!strncmp (p, "message-length=", 15)) else if (!strncmp (p, "message-length=", 15))
set_message_length (read_integral_parameter (p + 15, p -2, 0)); set_message_length
(read_integral_parameter (p + 15, p -2,
/* default line-wrap length */ 72));
else if (!strncmp (p, "dump-translation-unit-", 22)) else if (!strncmp (p, "dump-translation-unit-", 22))
{ {
if (p[22] == '\0') if (p[22] == '\0')
......
...@@ -452,15 +452,15 @@ composite_pointer_type (t1, t2, arg1, arg2, location) ...@@ -452,15 +452,15 @@ composite_pointer_type (t1, t2, arg1, arg2, location)
else if (TYPE_MAIN_VARIANT (TREE_TYPE (t1)) == void_type_node) else if (TYPE_MAIN_VARIANT (TREE_TYPE (t1)) == void_type_node)
{ {
if (pedantic && TREE_CODE (t2) == FUNCTION_TYPE) if (pedantic && TREE_CODE (t2) == FUNCTION_TYPE)
pedwarn ("ANSI C++ forbids %s between `void *' and function pointer", pedwarn ("ISO C++ forbids %s between pointer of type `void *'"
location); " and pointer-to-function", location);
result_type = qualify_type (t1, t2); result_type = qualify_type (t1, t2);
} }
else if (TYPE_MAIN_VARIANT (TREE_TYPE (t2)) == void_type_node) else if (TYPE_MAIN_VARIANT (TREE_TYPE (t2)) == void_type_node)
{ {
if (pedantic && TREE_CODE (t1) == FUNCTION_TYPE) if (pedantic && TREE_CODE (t1) == FUNCTION_TYPE)
pedwarn ("ANSI C++ forbids %s between `void *' and function pointer", pedwarn ("ISO C++ forbids %s between pointer of type `void *'"
location); " and pointer-to-function", location);
result_type = qualify_type (t2, t1); result_type = qualify_type (t2, t1);
} }
/* C++ */ /* C++ */
...@@ -482,7 +482,7 @@ composite_pointer_type (t1, t2, arg1, arg2, location) ...@@ -482,7 +482,7 @@ composite_pointer_type (t1, t2, arg1, arg2, location)
if (pedantic if (pedantic
&& result_type != TREE_TYPE (t1) && result_type != TREE_TYPE (t1)
&& result_type != TREE_TYPE (t2)) && result_type != TREE_TYPE (t2))
cp_pedwarn ("`%T' and `%T' converted to `%T *' in %s", cp_pedwarn ("types `%T' and `%T' converted to `%T *' in %s",
t1, t2, result_type, location); t1, t2, result_type, location);
result_type = build_pointer_type (result_type); result_type = build_pointer_type (result_type);
...@@ -583,7 +583,7 @@ common_type (t1, t2) ...@@ -583,7 +583,7 @@ common_type (t1, t2)
/* For two pointers, do this recursively on the target type, /* For two pointers, do this recursively on the target type,
and combine the qualifiers of the two types' targets. */ and combine the qualifiers of the two types' targets. */
/* This code was turned off; I don't know why. /* This code was turned off; I don't know why.
But ANSI C++ specifies doing this with the qualifiers. But ISO C++ specifies doing this with the qualifiers.
So I turned it on again. */ So I turned it on again. */
{ {
tree tt1 = TREE_TYPE (t1); tree tt1 = TREE_TYPE (t1);
...@@ -1466,7 +1466,7 @@ comp_target_parms (parms1, parms2, strict) ...@@ -1466,7 +1466,7 @@ comp_target_parms (parms1, parms2, strict)
declared to take (), which we fudged to (...). Don't make the declared to take (), which we fudged to (...). Don't make the
user pay for our mistake. */; user pay for our mistake. */;
else else
cp_pedwarn ("ANSI C++ prohibits conversion from `%#T' to `(...)'", cp_pedwarn ("ISO C++ prohibits conversion from `%#T' to `(...)'",
parms2); parms2);
return self_promoting_args_p (t2); return self_promoting_args_p (t2);
} }
...@@ -1548,19 +1548,20 @@ c_sizeof (type) ...@@ -1548,19 +1548,20 @@ c_sizeof (type)
if (code == FUNCTION_TYPE) if (code == FUNCTION_TYPE)
{ {
if (pedantic || warn_pointer_arith) if (pedantic || warn_pointer_arith)
pedwarn ("ANSI C++ forbids taking the sizeof a function type"); pedwarn ("ISO C++ forbids applying `sizeof' to a function type");
return size_int (1); return size_int (1);
} }
if (code == METHOD_TYPE) if (code == METHOD_TYPE)
{ {
if (pedantic || warn_pointer_arith) if (pedantic || warn_pointer_arith)
pedwarn ("ANSI C++ forbids taking the sizeof a method type"); pedwarn ("ISO C++ forbids applying `sizeof' to a member function");
return size_int (1); return size_int (1);
} }
if (code == VOID_TYPE) if (code == VOID_TYPE)
{ {
if (pedantic || warn_pointer_arith) if (pedantic || warn_pointer_arith)
pedwarn ("ANSI C++ forbids taking the sizeof a void type"); pedwarn ("ISO C++ forbids applying `sizeof' to type `void' which is"
" an incomplete type");
return size_int (1); return size_int (1);
} }
if (code == ERROR_MARK) if (code == ERROR_MARK)
...@@ -1605,7 +1606,8 @@ expr_sizeof (e) ...@@ -1605,7 +1606,8 @@ expr_sizeof (e)
error ("sizeof applied to a bit-field"); error ("sizeof applied to a bit-field");
if (is_overloaded_fn (e)) if (is_overloaded_fn (e))
{ {
pedwarn ("ANSI C++ forbids taking the sizeof a function type"); pedwarn ("ISO C++ forbids applying `sizeof' to an expression"
" of function type");
return size_int (1); return size_int (1);
} }
else if (type_unknown_p (e)) else if (type_unknown_p (e))
...@@ -2458,7 +2460,7 @@ build_array_ref (array, idx) ...@@ -2458,7 +2460,7 @@ build_array_ref (array, idx)
} }
if (pedantic && !lvalue_p (array)) if (pedantic && !lvalue_p (array))
pedwarn ("ANSI C++ forbids subscripting non-lvalue array"); pedwarn ("ISO C++ forbids subscripting non-lvalue array");
/* Note in C++ it is valid to subscript a `register' array, since /* Note in C++ it is valid to subscript a `register' array, since
it is valid to take the address of something with that it is valid to take the address of something with that
...@@ -2947,7 +2949,7 @@ build_function_call_real (function, params, require_complete, flags) ...@@ -2947,7 +2949,7 @@ build_function_call_real (function, params, require_complete, flags)
/* Convert anything with function type to a pointer-to-function. */ /* Convert anything with function type to a pointer-to-function. */
if (pedantic && DECL_MAIN_P (function)) if (pedantic && DECL_MAIN_P (function))
pedwarn ("ANSI C++ forbids calling `main' from within program"); pedwarn ("ISO C++ forbids calling `::main' from within program");
/* Differs from default_conversion by not setting TREE_ADDRESSABLE /* Differs from default_conversion by not setting TREE_ADDRESSABLE
(because calling an inline function does not mean the function (because calling an inline function does not mean the function
...@@ -3118,11 +3120,8 @@ convert_arguments (typelist, values, fndecl, flags) ...@@ -3118,11 +3120,8 @@ convert_arguments (typelist, values, fndecl, flags)
if (type == void_type_node) if (type == void_type_node)
{ {
if (fndecl) if (fndecl)
{ cp_error_at ("too many arguments to %s `%+#D' at this point",
cp_error_at ("too many arguments to %s `%+#D'", called_thing, called_thing, fndecl);
fndecl);
error ("at this point in file");
}
else else
error ("too many arguments to function"); error ("too many arguments to function");
/* In case anybody wants to know if this argument /* In case anybody wants to know if this argument
...@@ -3220,11 +3219,8 @@ convert_arguments (typelist, values, fndecl, flags) ...@@ -3220,11 +3219,8 @@ convert_arguments (typelist, values, fndecl, flags)
else else
{ {
if (fndecl) if (fndecl)
{ cp_error_at ("too few arguments to %s `%+#D' at this point",
cp_error_at ("too few arguments to %s `%+#D'",
called_thing, fndecl); called_thing, fndecl);
error ("at this point in file");
}
else else
error ("too few arguments to function"); error ("too few arguments to function");
return error_mark_list; return error_mark_list;
...@@ -3353,7 +3349,7 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code) ...@@ -3353,7 +3349,7 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code)
tree t = instantiate_type (TREE_TYPE (op1), op0, 0); tree t = instantiate_type (TREE_TYPE (op1), op0, 0);
if (t != error_mark_node) if (t != error_mark_node)
{ {
cp_pedwarn ("assuming cast to `%T' from overloaded function", cp_pedwarn ("assuming cast to type `%T' from overloaded function",
TREE_TYPE (t)); TREE_TYPE (t));
op0 = t; op0 = t;
} }
...@@ -3363,7 +3359,7 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code) ...@@ -3363,7 +3359,7 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code)
tree t = instantiate_type (TREE_TYPE (op0), op1, 0); tree t = instantiate_type (TREE_TYPE (op0), op1, 0);
if (t != error_mark_node) if (t != error_mark_node)
{ {
cp_pedwarn ("assuming cast to `%T' from overloaded function", cp_pedwarn ("assuming cast to type `%T' from overloaded function",
TREE_TYPE (t)); TREE_TYPE (t));
op1 = t; op1 = t;
} }
...@@ -3604,15 +3600,15 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code) ...@@ -3604,15 +3600,15 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code)
{ {
if (pedantic && TREE_CODE (tt1) == FUNCTION_TYPE if (pedantic && TREE_CODE (tt1) == FUNCTION_TYPE
&& tree_int_cst_lt (TYPE_SIZE (type0), TYPE_SIZE (type1))) && tree_int_cst_lt (TYPE_SIZE (type0), TYPE_SIZE (type1)))
pedwarn ("ANSI C++ forbids comparison of `void *' with function pointer"); pedwarn ("ISO C++ forbids comparison of `void *' with function pointer");
else if (TREE_CODE (tt1) == OFFSET_TYPE) else if (TREE_CODE (tt1) == OFFSET_TYPE)
pedwarn ("ANSI C++ forbids conversion of a pointer to member to `void *'"); pedwarn ("ISO C++ forbids conversion of a pointer to member to `void *'");
} }
else if (tt1 == void_type_node) else if (tt1 == void_type_node)
{ {
if (pedantic && TREE_CODE (tt0) == FUNCTION_TYPE if (pedantic && TREE_CODE (tt0) == FUNCTION_TYPE
&& tree_int_cst_lt (TYPE_SIZE (type1), TYPE_SIZE (type0))) && tree_int_cst_lt (TYPE_SIZE (type1), TYPE_SIZE (type0)))
pedwarn ("ANSI C++ forbids comparison of `void *' with function pointer"); pedwarn ("ISO C++ forbids comparison of `void *' with function pointer");
} }
else else
cp_pedwarn ("comparison of distinct pointer types `%T' and `%T' lacks a cast", cp_pedwarn ("comparison of distinct pointer types `%T' and `%T' lacks a cast",
...@@ -3628,12 +3624,12 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code) ...@@ -3628,12 +3624,12 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code)
else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE) else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
{ {
result_type = type0; result_type = type0;
error ("ANSI C++ forbids comparison between pointer and integer"); error ("ISO C++ forbids comparison between pointer and integer");
} }
else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE) else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
{ {
result_type = type1; result_type = type1;
error ("ANSI C++ forbids comparison between pointer and integer"); error ("ISO C++ forbids comparison between pointer and integer");
} }
else if (TYPE_PTRMEMFUNC_P (type0) && null_ptr_cst_p (op1)) else if (TYPE_PTRMEMFUNC_P (type0) && null_ptr_cst_p (op1))
{ {
...@@ -3781,12 +3777,12 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code) ...@@ -3781,12 +3777,12 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code)
else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE) else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
{ {
result_type = type0; result_type = type0;
pedwarn ("ANSI C++ forbids comparison between pointer and integer"); pedwarn ("ISO C++ forbids comparison between pointer and integer");
} }
else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE) else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
{ {
result_type = type1; result_type = type1;
pedwarn ("ANSI C++ forbids comparison between pointer and integer"); pedwarn ("ISO C++ forbids comparison between pointer and integer");
} }
break; break;
...@@ -3950,7 +3946,7 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code) ...@@ -3950,7 +3946,7 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code)
&& TYPE_MAIN_VARIANT (TREE_TYPE (orig_op0)) && TYPE_MAIN_VARIANT (TREE_TYPE (orig_op0))
!= TYPE_MAIN_VARIANT (TREE_TYPE (orig_op1))) != TYPE_MAIN_VARIANT (TREE_TYPE (orig_op1)))
{ {
cp_warning ("comparison between `%#T' and `%#T'", cp_warning ("comparison between types `%#T' and `%#T'",
TREE_TYPE (orig_op0), TREE_TYPE (orig_op1)); TREE_TYPE (orig_op0), TREE_TYPE (orig_op1));
} }
...@@ -3987,7 +3983,8 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code) ...@@ -3987,7 +3983,8 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code)
signed_type (result_type))))) signed_type (result_type)))))
/* OK */; /* OK */;
else else
warning ("comparison between signed and unsigned"); warning ("comparison between a signed and an unsigned"
" integer expressions");
/* Warn if two unsigned values are being compared in a size /* Warn if two unsigned values are being compared in a size
larger than their original size, and one (and only one) is the larger than their original size, and one (and only one) is the
...@@ -4053,7 +4050,7 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code) ...@@ -4053,7 +4050,7 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code)
if (!result_type) if (!result_type)
{ {
cp_error ("invalid operands `%T' and `%T' to binary `%O'", cp_error ("invalid operands of types `%T' and `%T' to binary `%O'",
TREE_TYPE (orig_op0), TREE_TYPE (orig_op1), error_code); TREE_TYPE (orig_op0), TREE_TYPE (orig_op1), error_code);
return error_mark_node; return error_mark_node;
} }
...@@ -4127,25 +4124,25 @@ pointer_int_sum (resultcode, ptrop, intop) ...@@ -4127,25 +4124,25 @@ pointer_int_sum (resultcode, ptrop, intop)
if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE) if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE)
{ {
if (pedantic || warn_pointer_arith) if (pedantic || warn_pointer_arith)
pedwarn ("ANSI C++ forbids using pointer of type `void *' in arithmetic"); pedwarn ("ISO C++ forbids using pointer of type `void *' in pointer arithmetic");
size_exp = integer_one_node; size_exp = integer_one_node;
} }
else if (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE) else if (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE)
{ {
if (pedantic || warn_pointer_arith) if (pedantic || warn_pointer_arith)
pedwarn ("ANSI C++ forbids using pointer to a function in arithmetic"); pedwarn ("ISO C++ forbids using a pointer-to-function in pointer arithmetic");
size_exp = integer_one_node; size_exp = integer_one_node;
} }
else if (TREE_CODE (TREE_TYPE (result_type)) == METHOD_TYPE) else if (TREE_CODE (TREE_TYPE (result_type)) == METHOD_TYPE)
{ {
if (pedantic || warn_pointer_arith) if (pedantic || warn_pointer_arith)
pedwarn ("ANSI C++ forbids using pointer to a method in arithmetic"); pedwarn ("ISO C++ forbids using a pointer to member function in pointer arithmetic");
size_exp = integer_one_node; size_exp = integer_one_node;
} }
else if (TREE_CODE (TREE_TYPE (result_type)) == OFFSET_TYPE) else if (TREE_CODE (TREE_TYPE (result_type)) == OFFSET_TYPE)
{ {
if (pedantic || warn_pointer_arith) if (pedantic || warn_pointer_arith)
pedwarn ("ANSI C++ forbids using pointer to a member in arithmetic"); pedwarn ("ISO C++ forbids using pointer to a member in pointer arithmetic");
size_exp = integer_one_node; size_exp = integer_one_node;
} }
else else
...@@ -4218,13 +4215,13 @@ pointer_diff (op0, op1, ptrtype) ...@@ -4218,13 +4215,13 @@ pointer_diff (op0, op1, ptrtype)
if (pedantic || warn_pointer_arith) if (pedantic || warn_pointer_arith)
{ {
if (TREE_CODE (target_type) == VOID_TYPE) if (TREE_CODE (target_type) == VOID_TYPE)
pedwarn ("ANSI C++ forbids using pointer of type `void *' in subtraction"); pedwarn ("ISO C++ forbids using pointer of type `void *' in subtraction");
if (TREE_CODE (target_type) == FUNCTION_TYPE) if (TREE_CODE (target_type) == FUNCTION_TYPE)
pedwarn ("ANSI C++ forbids using pointer to a function in subtraction"); pedwarn ("ISO C++ forbids using pointer to a function in subtraction");
if (TREE_CODE (target_type) == METHOD_TYPE) if (TREE_CODE (target_type) == METHOD_TYPE)
pedwarn ("ANSI C++ forbids using pointer to a method in subtraction"); pedwarn ("ISO C++ forbids using pointer to a method in subtraction");
if (TREE_CODE (target_type) == OFFSET_TYPE) if (TREE_CODE (target_type) == OFFSET_TYPE)
pedwarn ("ANSI C++ forbids using pointer to a member in subtraction"); pedwarn ("ISO C++ forbids using pointer to a member in subtraction");
} }
/* First do the subtraction as integers; /* First do the subtraction as integers;
...@@ -4235,7 +4232,7 @@ pointer_diff (op0, op1, ptrtype) ...@@ -4235,7 +4232,7 @@ pointer_diff (op0, op1, ptrtype)
/* This generates an error if op1 is a pointer to an incomplete type. */ /* This generates an error if op1 is a pointer to an incomplete type. */
if (TYPE_SIZE (TREE_TYPE (TREE_TYPE (op1))) == 0) if (TYPE_SIZE (TREE_TYPE (TREE_TYPE (op1))) == 0)
error ("arithmetic on pointer to an incomplete type"); error ("invalid use of a pointer to an incomplete type in pointer arithmetic");
op1 = ((TREE_CODE (target_type) == VOID_TYPE op1 = ((TREE_CODE (target_type) == VOID_TYPE
|| TREE_CODE (target_type) == FUNCTION_TYPE || TREE_CODE (target_type) == FUNCTION_TYPE
...@@ -4520,7 +4517,7 @@ build_unary_op (code, xarg, noconvert) ...@@ -4520,7 +4517,7 @@ build_unary_op (code, xarg, noconvert)
/* ARM $5.2.5 last annotation says this should be forbidden. */ /* ARM $5.2.5 last annotation says this should be forbidden. */
if (TREE_CODE (argtype) == ENUMERAL_TYPE) if (TREE_CODE (argtype) == ENUMERAL_TYPE)
pedwarn ("ANSI C++ forbids %sing an enum", pedwarn ("ISO C++ forbids %sing an enum",
(code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR) (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
? "increment" : "decrement"); ? "increment" : "decrement");
...@@ -4537,7 +4534,7 @@ build_unary_op (code, xarg, noconvert) ...@@ -4537,7 +4534,7 @@ build_unary_op (code, xarg, noconvert)
else if ((pedantic || warn_pointer_arith) else if ((pedantic || warn_pointer_arith)
&& (tmp == FUNCTION_TYPE || tmp == METHOD_TYPE && (tmp == FUNCTION_TYPE || tmp == METHOD_TYPE
|| tmp == VOID_TYPE || tmp == OFFSET_TYPE)) || tmp == VOID_TYPE || tmp == OFFSET_TYPE))
cp_pedwarn ("ANSI C++ forbids %sing a pointer of type `%T'", cp_pedwarn ("ISO C++ forbids %sing a pointer of type `%T'",
((code == PREINCREMENT_EXPR ((code == PREINCREMENT_EXPR
|| code == POSTINCREMENT_EXPR) || code == POSTINCREMENT_EXPR)
? "increment" : "decrement"), argtype); ? "increment" : "decrement"), argtype);
...@@ -4640,7 +4637,7 @@ build_unary_op (code, xarg, noconvert) ...@@ -4640,7 +4637,7 @@ build_unary_op (code, xarg, noconvert)
} }
else if (pedantic && DECL_MAIN_P (arg)) else if (pedantic && DECL_MAIN_P (arg))
/* ARM $3.4 */ /* ARM $3.4 */
pedwarn ("taking address of function `main'"); pedwarn ("ISO C++ forbids taking address of function `::main'");
/* Let &* cancel out to simplify resulting code. */ /* Let &* cancel out to simplify resulting code. */
if (TREE_CODE (arg) == INDIRECT_REF) if (TREE_CODE (arg) == INDIRECT_REF)
...@@ -4704,13 +4701,13 @@ build_unary_op (code, xarg, noconvert) ...@@ -4704,13 +4701,13 @@ build_unary_op (code, xarg, noconvert)
if (current_class_type if (current_class_type
&& TREE_OPERAND (arg, 0) == current_class_ref) && TREE_OPERAND (arg, 0) == current_class_ref)
/* An expression like &memfn. */ /* An expression like &memfn. */
pedwarn ("taking the address of a non-static member function"); pedwarn ("ISO C++ forbids taking the address of a"
" non-static member function to form a pointer"
" to member function. Say `&%T::%D'", base, name);
else else
pedwarn ("taking the address of a bound member function"); pedwarn ("ISO C++ forbids taking the address of a bound"
" member function to form a pointer to member"
cp_pedwarn " function", base, name);
(" to form a pointer to member function, say `&%T::%D'",
base, name);
} }
arg = build_offset_ref (base, name); arg = build_offset_ref (base, name);
...@@ -4735,7 +4732,8 @@ build_unary_op (code, xarg, noconvert) ...@@ -4735,7 +4732,8 @@ build_unary_op (code, xarg, noconvert)
case FIX_ROUND_EXPR: case FIX_ROUND_EXPR:
case FIX_CEIL_EXPR: case FIX_CEIL_EXPR:
if (! lvalue_p (arg) && pedantic) if (! lvalue_p (arg) && pedantic)
pedwarn ("taking the address of a cast to non-reference type"); pedwarn ("ISO C++ forbids taking the address of a cast to a "
"non-lvalue expression");
break; break;
default: default:
...@@ -4973,7 +4971,7 @@ mark_addressable (exp) ...@@ -4973,7 +4971,7 @@ mark_addressable (exp)
if (x == current_class_ptr) if (x == current_class_ptr)
{ {
if (! flag_this_is_variable) if (! flag_this_is_variable)
error ("address of `this' not available"); error ("cannot take the address of `this', which is an ravlue expression");
TREE_ADDRESSABLE (x) = 1; /* so compiler doesn't die later */ TREE_ADDRESSABLE (x) = 1; /* so compiler doesn't die later */
put_var_into_stack (x); put_var_into_stack (x);
return 1; return 1;
...@@ -5121,7 +5119,7 @@ build_compound_expr (list) ...@@ -5121,7 +5119,7 @@ build_compound_expr (list)
} }
first = TREE_VALUE (list); first = TREE_VALUE (list);
first = convert_to_void (first, "lhs of comma"); first = convert_to_void (first, "left-hand operand of comma");
if (first == error_mark_node) if (first == error_mark_node)
return error_mark_node; return error_mark_node;
...@@ -5220,7 +5218,7 @@ build_static_cast (type, expr) ...@@ -5220,7 +5218,7 @@ build_static_cast (type, expr)
constness. */ constness. */
if (ok && casts_away_constness (intype, type)) if (ok && casts_away_constness (intype, type))
{ {
cp_error ("static_cast from `%T' to `%T' casts away constness", cp_error ("static_cast from type `%T' to type `%T' casts away constness",
intype, type); intype, type);
return error_mark_node; return error_mark_node;
} }
...@@ -5228,7 +5226,7 @@ build_static_cast (type, expr) ...@@ -5228,7 +5226,7 @@ build_static_cast (type, expr)
if (ok) if (ok)
return build_c_cast (type, expr); return build_c_cast (type, expr);
cp_error ("static_cast from `%T' to `%T'", intype, type); cp_error ("invalid static_cast from type `%T' to type `%T'", intype, type);
return error_mark_node; return error_mark_node;
} }
...@@ -5267,7 +5265,8 @@ build_reinterpret_cast (type, expr) ...@@ -5267,7 +5265,8 @@ build_reinterpret_cast (type, expr)
{ {
if (! real_lvalue_p (expr)) if (! real_lvalue_p (expr))
{ {
cp_error ("reinterpret_cast from `%T' rvalue to `%T'", intype, type); cp_error ("invalid reinterpret_cast of an rvalue expression of type"
" `%T' to type `%T'", intype, type);
return error_mark_node; return error_mark_node;
} }
expr = build_unary_op (ADDR_EXPR, expr, 0); expr = build_unary_op (ADDR_EXPR, expr, 0);
...@@ -5312,14 +5311,15 @@ build_reinterpret_cast (type, expr) ...@@ -5312,14 +5311,15 @@ build_reinterpret_cast (type, expr)
else if ((TYPE_PTRFN_P (type) && TYPE_PTROBV_P (intype)) else if ((TYPE_PTRFN_P (type) && TYPE_PTROBV_P (intype))
|| (TYPE_PTRFN_P (intype) && TYPE_PTROBV_P (type))) || (TYPE_PTRFN_P (intype) && TYPE_PTROBV_P (type)))
{ {
pedwarn ("ANSI C++ forbids casting between pointers to functions and objects"); pedwarn ("ISO C++ forbids casting between pointer-to-function and pointer-to-object");
if (TREE_READONLY_DECL_P (expr)) if (TREE_READONLY_DECL_P (expr))
expr = decl_constant_value (expr); expr = decl_constant_value (expr);
return fold (build1 (NOP_EXPR, type, expr)); return fold (build1 (NOP_EXPR, type, expr));
} }
else else
{ {
cp_error ("reinterpret_cast from `%T' to `%T'", intype, type); cp_error ("invalid reinterpret_cast from type `%T' to type `%T'",
intype, type);
return error_mark_node; return error_mark_node;
} }
...@@ -5345,16 +5345,12 @@ build_const_cast (type, expr) ...@@ -5345,16 +5345,12 @@ build_const_cast (type, expr)
} }
if (!POINTER_TYPE_P (type)) if (!POINTER_TYPE_P (type))
{ cp_error ("invalid use of const_cast with type `%T', which is not a"
cp_error ("`%T' is not a pointer, reference, or pointer-to-data-member type", " pointer, reference, nor a pointer-to-data-member type", type);
type);
cp_error ("as required by const_cast");
}
else if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE) else if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
{ {
cp_error ("`%T' is a pointer or reference to a function type", cp_error ("invalid use of const_cast with type `%T', which is a pointer"
type); " or reference to a function type", type);
cp_error ("which is forbidden by const_cast");
return error_mark_node; return error_mark_node;
} }
...@@ -5377,7 +5373,7 @@ build_const_cast (type, expr) ...@@ -5377,7 +5373,7 @@ build_const_cast (type, expr)
{ {
if (! real_lvalue_p (expr)) if (! real_lvalue_p (expr))
{ {
cp_error ("const_cast from `%T' rvalue to `%T'", intype, type); cp_error ("invalid const_cast of an rvalue of type `%T' to type `%T'", intype, type);
return error_mark_node; return error_mark_node;
} }
...@@ -5393,7 +5389,7 @@ build_const_cast (type, expr) ...@@ -5393,7 +5389,7 @@ build_const_cast (type, expr)
&& comp_ptr_ttypes_const (TREE_TYPE (type), TREE_TYPE (intype))) && comp_ptr_ttypes_const (TREE_TYPE (type), TREE_TYPE (intype)))
return cp_convert (type, expr); return cp_convert (type, expr);
cp_error ("const_cast from `%T' to `%T'", intype, type); cp_error ("invalid const_cast from type `%T' to type `%T'", intype, type);
return error_mark_node; return error_mark_node;
} }
...@@ -5430,12 +5426,12 @@ build_c_cast (type, expr) ...@@ -5430,12 +5426,12 @@ build_c_cast (type, expr)
if (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE) if (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE)
{ {
if (pedantic) if (pedantic)
pedwarn ("ANSI C++ forbids casting to an array type"); pedwarn ("ISO C++ forbids casting to an array type");
type = build_pointer_type (TREE_TYPE (type)); type = build_pointer_type (TREE_TYPE (type));
} }
else else
{ {
error ("ANSI C++ forbids casting to an array type"); error ("ISO C++ forbids casting to an array type");
return error_mark_node; return error_mark_node;
} }
} }
...@@ -5443,7 +5439,7 @@ build_c_cast (type, expr) ...@@ -5443,7 +5439,7 @@ build_c_cast (type, expr)
if (TREE_CODE (type) == FUNCTION_TYPE if (TREE_CODE (type) == FUNCTION_TYPE
|| TREE_CODE (type) == METHOD_TYPE) || TREE_CODE (type) == METHOD_TYPE)
{ {
cp_error ("casting to function type `%T'", type); cp_error ("invalid cast to function type `%T'", type);
return error_mark_node; return error_mark_node;
} }
...@@ -5768,7 +5764,7 @@ build_modify_expr (lhs, modifycode, rhs) ...@@ -5768,7 +5764,7 @@ build_modify_expr (lhs, modifycode, rhs)
/* WP 5.4.1: The result is an lvalue if T is a reference type, /* WP 5.4.1: The result is an lvalue if T is a reference type,
otherwise the result is an rvalue. */ otherwise the result is an rvalue. */
if (! lvalue_p (lhs)) if (! lvalue_p (lhs))
pedwarn ("ANSI C++ forbids cast to non-reference type used as lvalue"); pedwarn ("ISO C++ forbids cast to non-reference type used as lvalue");
result = build_modify_expr (inner_lhs, NOP_EXPR, result = build_modify_expr (inner_lhs, NOP_EXPR,
cp_convert (TREE_TYPE (inner_lhs), cp_convert (TREE_TYPE (inner_lhs),
...@@ -5874,7 +5870,7 @@ build_modify_expr (lhs, modifycode, rhs) ...@@ -5874,7 +5870,7 @@ build_modify_expr (lhs, modifycode, rhs)
/* Allow array assignment in compiler-generated code. */ /* Allow array assignment in compiler-generated code. */
if (pedantic && ! DECL_ARTIFICIAL (current_function_decl)) if (pedantic && ! DECL_ARTIFICIAL (current_function_decl))
pedwarn ("ANSI C++ forbids assignment of arrays"); pedwarn ("ISO C++ forbids assignment of arrays");
from_array = TREE_CODE (TREE_TYPE (newrhs)) == ARRAY_TYPE from_array = TREE_CODE (TREE_TYPE (newrhs)) == ARRAY_TYPE
? 1 + (modifycode != INIT_EXPR): 0; ? 1 + (modifycode != INIT_EXPR): 0;
...@@ -6051,9 +6047,8 @@ get_delta_difference (from, to, force) ...@@ -6051,9 +6047,8 @@ get_delta_difference (from, to, force)
if (binfo_from_vbase (binfo)) if (binfo_from_vbase (binfo))
{ {
binfo = BINFO_FOR_VBASE (BINFO_TYPE (binfo), from); binfo = BINFO_FOR_VBASE (BINFO_TYPE (binfo), from);
cp_warning ("pointer to member cast to virtual base `%T'", cp_warning ("pointer to member cast to virtual base `%T' will only"
BINFO_TYPE (binfo)); " work if you are very careful", BINFO_TYPE (binfo));
warning (" will only work if you are very careful");
} }
delta = BINFO_OFFSET (binfo); delta = BINFO_OFFSET (binfo);
delta = cp_convert (ptrdiff_type_node, delta); delta = cp_convert (ptrdiff_type_node, delta);
...@@ -6067,9 +6062,8 @@ get_delta_difference (from, to, force) ...@@ -6067,9 +6062,8 @@ get_delta_difference (from, to, force)
{ {
if (force) if (force)
{ {
cp_warning ("pointer to member cast from virtual base `%T'", cp_warning ("pointer to member cast from virtual base `%T' will "
BINFO_TYPE (binfo)); "only wokr if you are very careful", BINFO_TYPE (binfo));
warning (" will only work if you are very careful");
} }
else else
cp_error ("pointer to member conversion from virtual base `%T'", cp_error ("pointer to member conversion from virtual base `%T'",
...@@ -6184,7 +6178,7 @@ build_ptrmemfunc (type, pfn, force) ...@@ -6184,7 +6178,7 @@ build_ptrmemfunc (type, pfn, force)
if (!force if (!force
&& !can_convert_arg (to_type, TREE_TYPE (pfn), pfn)) && !can_convert_arg (to_type, TREE_TYPE (pfn), pfn))
cp_error ("conversion to `%T' from `%T'", cp_error ("invalid conversion to type `%T' from type `%T'",
to_type, pfn_type); to_type, pfn_type);
if (TREE_CODE (pfn) == PTRMEM_CST) if (TREE_CODE (pfn) == PTRMEM_CST)
...@@ -6764,7 +6758,8 @@ check_return_expr (retval) ...@@ -6764,7 +6758,8 @@ check_return_expr (retval)
that's supposed to return a value. */ that's supposed to return a value. */
if (!retval && fn_returns_value_p) if (!retval && fn_returns_value_p)
{ {
pedwarn ("`return' with no value, in function returning non-void"); pedwarn ("return-statement with no value, in function declared with"
" a non-void return type");
/* Clear this, so finish_function won't say that we reach the /* Clear this, so finish_function won't say that we reach the
end of a non-void function (which we don't, we gave a end of a non-void function (which we don't, we gave a
return!). */ return!). */
...@@ -6780,7 +6775,8 @@ check_return_expr (retval) ...@@ -6780,7 +6775,8 @@ check_return_expr (retval)
its side-effects. */ its side-effects. */
finish_expr_stmt (retval); finish_expr_stmt (retval);
else else
pedwarn ("`return' with a value, in function returning void"); pedwarn ("return-statement with a value, in function declared with"
" a void return type");
current_function_returns_null = 1; current_function_returns_null = 1;
...@@ -6797,7 +6793,7 @@ check_return_expr (retval) ...@@ -6797,7 +6793,7 @@ check_return_expr (retval)
|| DECL_NAME (current_function_decl) == ansi_opname[(int) VEC_NEW_EXPR]) || DECL_NAME (current_function_decl) == ansi_opname[(int) VEC_NEW_EXPR])
&& !TYPE_NOTHROW_P (TREE_TYPE (current_function_decl)) && !TYPE_NOTHROW_P (TREE_TYPE (current_function_decl))
&& null_ptr_cst_p (retval)) && null_ptr_cst_p (retval))
cp_warning ("operator new should throw an exception, not return NULL"); cp_warning ("`operator new' should throw an exception, not return NULL");
/* Effective C++ rule 15. See also start_function. */ /* Effective C++ rule 15. See also start_function. */
if (warn_ecpp if (warn_ecpp
......
...@@ -93,9 +93,9 @@ readonly_error (arg, string, soft) ...@@ -93,9 +93,9 @@ readonly_error (arg, string, soft)
if (TREE_CODE (arg) == COMPONENT_REF) if (TREE_CODE (arg) == COMPONENT_REF)
{ {
if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0)))) if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0))))
fmt = "%s of member `%D' in read-only structure"; fmt = "%s of data-member `%D' in read-only structure";
else else
fmt = "%s of read-only member `%D'"; fmt = "%s of read-only data-member `%D'";
(*fn) (fmt, string, TREE_OPERAND (arg, 1)); (*fn) (fmt, string, TREE_OPERAND (arg, 1));
} }
else if (TREE_CODE (arg) == VAR_DECL) else if (TREE_CODE (arg) == VAR_DECL)
...@@ -156,7 +156,7 @@ abstract_virtuals_error (decl, type) ...@@ -156,7 +156,7 @@ abstract_virtuals_error (decl, type)
decl, type); decl, type);
else if (TREE_CODE (decl) == FUNCTION_DECL else if (TREE_CODE (decl) == FUNCTION_DECL
&& TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE) && TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
cp_error ("invalid return type for method `%#D'", decl); cp_error ("invalid return type for member function `%#D'", decl);
else if (TREE_CODE (decl) == FUNCTION_DECL) else if (TREE_CODE (decl) == FUNCTION_DECL)
cp_error ("invalid return type for function `%#D'", decl); cp_error ("invalid return type for function `%#D'", decl);
} }
...@@ -199,8 +199,8 @@ retry: ...@@ -199,8 +199,8 @@ retry:
case RECORD_TYPE: case RECORD_TYPE:
case UNION_TYPE: case UNION_TYPE:
case ENUMERAL_TYPE: case ENUMERAL_TYPE:
cp_error ("invalid use of undefined type `%#T'", type); cp_error_at
cp_error_at ("forward declaration of `%#T'", type); ("invalid use of a forward-declared, but not defined type `%#T'", type);
break; break;
case VOID_TYPE: case VOID_TYPE:
...@@ -821,13 +821,13 @@ process_init_constructor (type, init, elts) ...@@ -821,13 +821,13 @@ process_init_constructor (type, init, elts)
{ {
if (TYPE_USES_VIRTUAL_BASECLASSES (type)) if (TYPE_USES_VIRTUAL_BASECLASSES (type))
{ {
sorry ("initializer list for object of class with virtual baseclasses"); sorry ("initializer list for object of class with virtual base classes");
return error_mark_node; return error_mark_node;
} }
if (TYPE_BINFO_BASETYPES (type)) if (TYPE_BINFO_BASETYPES (type))
{ {
sorry ("initializer list for object of class with baseclasses"); sorry ("initializer list for object of class with base classes");
return error_mark_node; return error_mark_node;
} }
...@@ -1462,7 +1462,7 @@ check_for_new_type (string, inptree) ...@@ -1462,7 +1462,7 @@ check_for_new_type (string, inptree)
{ {
if (inptree.new_type_flag if (inptree.new_type_flag
&& (pedantic || strcmp (string, "cast") != 0)) && (pedantic || strcmp (string, "cast") != 0))
pedwarn ("ANSI C++ forbids defining types within %s",string); pedwarn ("ISO C++ forbids defining types within %s",string);
} }
/* Add new exception specifier SPEC, to the LIST we currently have. /* Add new exception specifier SPEC, to the LIST we currently have.
......
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