mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-20 19:01:12 +08:00
re PR c/35058 (-Werror= works only with some warnings)
2008-07-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR 35058 * diagnostic.c (pedwarn): Add opt parameter. (pedwarn0): New. * c-tree.h (pedwarn_init): Add opt parameter. (pedwarn_c90): Likewise. (pedwarn_c99): Likewise. * c-errors.c (pedwarn_c99): Likewise. (pedwarn_c90): Likewise. * toplev.h (pedwarn): Update declaration. (pedwarn0): Declare. * c-lex.c: All calls to pedwarn changed. * builtins.c: All calls to pedwarn changed. * toplev.c: All calls to pedwarn changed. * c-decl.c: All calls to pedwarn changed. * c-typeck.c: All calls to pedwarn changed. * c-common.c: All calls to pedwarn changed. * c-parser.c: All calls to pedwarn changed. cp/ * typeck.c: All calls to pedwarn changed. * decl.c: All calls to pedwarn changed. * call.c: All calls to pedwarn changed. * error.c: All calls to pedwarn changed. * typeck2.c: All calls to pedwarn changed. * pt.c: All calls to pedwarn changed. * name-lookup.c: All calls to pedwarn changed. * parser.c: All calls to pedwarn changed. fortran/ * f95-lang.c (gfc_mark_addressable): All calls to pedwarn changed. testsuite/ * gcc.dg/Wdeclaration-after-statement-3.c: New. * gcc/testsuite/gcc.dg/Wpointer-arith.c: New. From-SVN: r138089
This commit is contained in:
parent
554cd17b8d
commit
fcf73884fb
@ -1,3 +1,23 @@
|
||||
2008-07-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
|
||||
|
||||
PR 35058
|
||||
* diagnostic.c (pedwarn): Add opt parameter.
|
||||
(pedwarn0): New.
|
||||
* c-tree.h (pedwarn_init): Add opt parameter.
|
||||
(pedwarn_c90): Likewise.
|
||||
(pedwarn_c99): Likewise.
|
||||
* c-errors.c (pedwarn_c99): Likewise.
|
||||
(pedwarn_c90): Likewise.
|
||||
* toplev.h (pedwarn): Update declaration.
|
||||
(pedwarn0): Declare.
|
||||
* c-lex.c: All calls to pedwarn changed.
|
||||
* builtins.c: All calls to pedwarn changed.
|
||||
* toplev.c: All calls to pedwarn changed.
|
||||
* c-decl.c: All calls to pedwarn changed.
|
||||
* c-typeck.c: All calls to pedwarn changed.
|
||||
* c-common.c: All calls to pedwarn changed.
|
||||
* c-parser.c: All calls to pedwarn changed.
|
||||
|
||||
2008-07-23 Michael Meissner <gnu@the-meissners.org>
|
||||
Karthik Kumar <karthikkumar@gmail.com>
|
||||
|
||||
|
@ -7248,7 +7248,7 @@ fold_builtin_inf (tree type, int warn)
|
||||
Thus we pedwarn to ensure this constraint violation is
|
||||
diagnosed. */
|
||||
if (!MODE_HAS_INFINITIES (TYPE_MODE (type)) && warn)
|
||||
pedwarn ("target format does not support infinity");
|
||||
pedwarn (0, "target format does not support infinity");
|
||||
|
||||
real_inf (&real);
|
||||
return build_real (type, real);
|
||||
|
@ -1047,7 +1047,7 @@ fname_decl (unsigned int rid, tree id)
|
||||
input_location = saved_location;
|
||||
}
|
||||
if (!ix && !current_function_decl)
|
||||
pedwarn ("%qD is not defined outside of function scope", decl);
|
||||
pedwarn (0, "%qD is not defined outside of function scope", decl);
|
||||
|
||||
return decl;
|
||||
}
|
||||
@ -1096,7 +1096,8 @@ fix_string_type (tree value)
|
||||
separate the %d from the 'C'. 'ISO' should not be
|
||||
translated, but it may be moved after 'C%d' in languages
|
||||
where modifiers follow nouns. */
|
||||
pedwarn ("string length %qd is greater than the length %qd "
|
||||
pedwarn (OPT_Woverlength_strings,
|
||||
"string length %qd is greater than the length %qd "
|
||||
"ISO C%d compilers are required to support",
|
||||
nchars - 1, nchars_max, relevant_std);
|
||||
}
|
||||
@ -1143,7 +1144,7 @@ constant_expression_warning (tree value)
|
||||
|| TREE_CODE (value) == VECTOR_CST
|
||||
|| TREE_CODE (value) == COMPLEX_CST)
|
||||
&& TREE_OVERFLOW (value))
|
||||
pedwarn ("overflow in constant expression");
|
||||
pedwarn (OPT_Woverflow, "overflow in constant expression");
|
||||
}
|
||||
|
||||
/* The same as above but print an unconditional error. */
|
||||
@ -1361,7 +1362,7 @@ check_main_parameter_types (tree decl)
|
||||
{
|
||||
case 1:
|
||||
if (TYPE_MAIN_VARIANT (type) != integer_type_node)
|
||||
pedwarn ("first argument of %q+D should be %<int%>", decl);
|
||||
pedwarn (0, "first argument of %q+D should be %<int%>", decl);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@ -1369,8 +1370,8 @@ check_main_parameter_types (tree decl)
|
||||
|| TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE
|
||||
|| (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type)))
|
||||
!= char_type_node))
|
||||
pedwarn ("second argument of %q+D should be %<char **%>",
|
||||
decl);
|
||||
pedwarn (0, "second argument of %q+D should be %<char **%>",
|
||||
decl);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
@ -1378,8 +1379,8 @@ check_main_parameter_types (tree decl)
|
||||
|| TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE
|
||||
|| (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type)))
|
||||
!= char_type_node))
|
||||
pedwarn ("third argument of %q+D should probably be "
|
||||
"%<char **%>", decl);
|
||||
pedwarn (0, "third argument of %q+D should probably be "
|
||||
"%<char **%>", decl);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1388,7 +1389,7 @@ check_main_parameter_types (tree decl)
|
||||
argument because it's only mentioned in an appendix of the
|
||||
standard. */
|
||||
if (argct > 0 && (argct < 2 || argct > 3))
|
||||
pedwarn ("%q+D takes only zero or two arguments", decl);
|
||||
pedwarn (0, "%q+D takes only zero or two arguments", decl);
|
||||
}
|
||||
|
||||
/* True if pointers to distinct types T1 and T2 can be converted to
|
||||
@ -3079,20 +3080,20 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop)
|
||||
|
||||
if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE)
|
||||
{
|
||||
if (pedantic || warn_pointer_arith)
|
||||
pedwarn ("pointer of type %<void *%> used in arithmetic");
|
||||
pedwarn (pedantic ? OPT_pedantic : OPT_Wpointer_arith,
|
||||
"pointer of type %<void *%> used in arithmetic");
|
||||
size_exp = integer_one_node;
|
||||
}
|
||||
else if (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE)
|
||||
{
|
||||
if (pedantic || warn_pointer_arith)
|
||||
pedwarn ("pointer to a function used in arithmetic");
|
||||
pedwarn (pedantic ? OPT_pedantic : OPT_Wpointer_arith,
|
||||
"pointer to a function used in arithmetic");
|
||||
size_exp = integer_one_node;
|
||||
}
|
||||
else if (TREE_CODE (TREE_TYPE (result_type)) == METHOD_TYPE)
|
||||
{
|
||||
if (pedantic || warn_pointer_arith)
|
||||
pedwarn ("pointer to member function used in arithmetic");
|
||||
pedwarn (pedantic ? OPT_pedantic : OPT_Wpointer_arith,
|
||||
"pointer to member function used in arithmetic");
|
||||
size_exp = integer_one_node;
|
||||
}
|
||||
else
|
||||
@ -3600,7 +3601,8 @@ c_sizeof_or_alignof_type (tree type, bool is_sizeof, int complain)
|
||||
if (is_sizeof)
|
||||
{
|
||||
if (complain && (pedantic || warn_pointer_arith))
|
||||
pedwarn ("invalid application of %<sizeof%> to a function type");
|
||||
pedwarn (pedantic ? OPT_pedantic : OPT_Wpointer_arith,
|
||||
"invalid application of %<sizeof%> to a function type");
|
||||
else if (!complain)
|
||||
return error_mark_node;
|
||||
value = size_one_node;
|
||||
@ -3612,7 +3614,8 @@ c_sizeof_or_alignof_type (tree type, bool is_sizeof, int complain)
|
||||
{
|
||||
if (type_code == VOID_TYPE
|
||||
&& complain && (pedantic || warn_pointer_arith))
|
||||
pedwarn ("invalid application of %qs to a void type", op_name);
|
||||
pedwarn (pedantic ? OPT_pedantic : OPT_Wpointer_arith,
|
||||
"invalid application of %qs to a void type", op_name);
|
||||
else if (!complain)
|
||||
return error_mark_node;
|
||||
value = size_one_node;
|
||||
@ -4478,8 +4481,9 @@ c_add_case_label (splay_tree cases, tree cond, tree orig_type,
|
||||
}
|
||||
|
||||
/* Case ranges are a GNU extension. */
|
||||
if (high_value && pedantic)
|
||||
pedwarn ("range expressions in switch statements are non-standard");
|
||||
if (high_value)
|
||||
pedwarn (OPT_pedantic,
|
||||
"range expressions in switch statements are non-standard");
|
||||
|
||||
type = TREE_TYPE (cond);
|
||||
if (low_value)
|
||||
@ -4792,8 +4796,7 @@ finish_label_address_expr (tree label)
|
||||
{
|
||||
tree result;
|
||||
|
||||
if (pedantic)
|
||||
pedwarn ("taking the address of a label is non-standard");
|
||||
pedwarn (OPT_pedantic, "taking the address of a label is non-standard");
|
||||
|
||||
if (label == error_mark_node)
|
||||
return error_mark_node;
|
||||
|
210
gcc/c-decl.c
210
gcc/c-decl.c
@ -786,7 +786,7 @@ pop_scope (void)
|
||||
&& TREE_PUBLIC (p)
|
||||
&& !DECL_INITIAL (p)
|
||||
&& !flag_gnu89_inline)
|
||||
pedwarn ("inline function %q+D declared but never defined", p);
|
||||
pedwarn (0, "inline function %q+D declared but never defined", p);
|
||||
|
||||
goto common_symbol;
|
||||
|
||||
@ -1223,7 +1223,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
|
||||
&& TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node
|
||||
&& C_FUNCTION_IMPLICIT_INT (newdecl) && !DECL_INITIAL (olddecl))
|
||||
{
|
||||
pedwarn ("conflicting types for %q+D", newdecl);
|
||||
pedwarn (0, "conflicting types for %q+D", newdecl);
|
||||
/* Make sure we keep void as the return type. */
|
||||
TREE_TYPE (newdecl) = *newtypep = newtype = oldtype;
|
||||
C_FUNCTION_IMPLICIT_INT (newdecl) = 0;
|
||||
@ -1236,7 +1236,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
|
||||
&& TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == integer_type_node
|
||||
&& C_DECL_IMPLICIT (olddecl) && !DECL_INITIAL (olddecl))
|
||||
{
|
||||
pedwarn ("conflicting types for %q+D", newdecl);
|
||||
pedwarn (0, "conflicting types for %q+D", newdecl);
|
||||
/* Make sure we keep void as the return type. */
|
||||
TREE_TYPE (olddecl) = *oldtypep = oldtype = newtype;
|
||||
pedwarned = true;
|
||||
@ -1588,7 +1588,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
|
||||
|
||||
/* Report location of previous decl/defn in a consistent manner. */
|
||||
if (warned || pedwarned)
|
||||
locate_old_decl (olddecl, pedwarned ? pedwarn : warning0);
|
||||
locate_old_decl (olddecl, pedwarned ? pedwarn0 : warning0);
|
||||
|
||||
#undef DECL_EXTERN_INLINE
|
||||
|
||||
@ -2356,7 +2356,8 @@ implicit_decl_warning (tree id, tree olddecl)
|
||||
if (warn_implicit_function_declaration)
|
||||
{
|
||||
if (flag_isoc99)
|
||||
pedwarn (G_("implicit declaration of function %qE"), id);
|
||||
pedwarn (OPT_Wimplicit_function_declaration,
|
||||
G_("implicit declaration of function %qE"), id);
|
||||
else
|
||||
warning (OPT_Wimplicit_function_declaration,
|
||||
G_("implicit declaration of function %qE"), id);
|
||||
@ -2908,7 +2909,7 @@ shadow_tag_warned (const struct c_declspecs *declspecs, int warned)
|
||||
if (warned != 1 && code != ENUMERAL_TYPE)
|
||||
/* Empty unnamed enum OK */
|
||||
{
|
||||
pedwarn ("unnamed struct/union that defines no instances");
|
||||
pedwarn (0, "unnamed struct/union that defines no instances");
|
||||
warned = 1;
|
||||
}
|
||||
}
|
||||
@ -2916,8 +2917,8 @@ shadow_tag_warned (const struct c_declspecs *declspecs, int warned)
|
||||
&& declspecs->storage_class != csc_none)
|
||||
{
|
||||
if (warned != 1)
|
||||
pedwarn ("empty declaration with storage class specifier "
|
||||
"does not redeclare tag");
|
||||
pedwarn (0, "empty declaration with storage class specifier "
|
||||
"does not redeclare tag");
|
||||
warned = 1;
|
||||
pending_xref_error ();
|
||||
}
|
||||
@ -2927,8 +2928,8 @@ shadow_tag_warned (const struct c_declspecs *declspecs, int warned)
|
||||
|| declspecs->restrict_p))
|
||||
{
|
||||
if (warned != 1)
|
||||
pedwarn ("empty declaration with type qualifier "
|
||||
"does not redeclare tag");
|
||||
pedwarn (0, "empty declaration with type qualifier "
|
||||
"does not redeclare tag");
|
||||
warned = 1;
|
||||
pending_xref_error ();
|
||||
}
|
||||
@ -2948,14 +2949,14 @@ shadow_tag_warned (const struct c_declspecs *declspecs, int warned)
|
||||
{
|
||||
if (warned != 1 && !in_system_header)
|
||||
{
|
||||
pedwarn ("useless type name in empty declaration");
|
||||
pedwarn (0, "useless type name in empty declaration");
|
||||
warned = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (warned != 1 && !in_system_header && declspecs->typedef_p)
|
||||
{
|
||||
pedwarn ("useless type name in empty declaration");
|
||||
pedwarn (0, "useless type name in empty declaration");
|
||||
warned = 1;
|
||||
}
|
||||
|
||||
@ -3002,7 +3003,7 @@ shadow_tag_warned (const struct c_declspecs *declspecs, int warned)
|
||||
if (warned != 1)
|
||||
{
|
||||
if (!found_tag)
|
||||
pedwarn ("empty declaration");
|
||||
pedwarn (0, "empty declaration");
|
||||
}
|
||||
}
|
||||
|
||||
@ -3065,13 +3066,13 @@ build_array_declarator (tree expr, struct c_declspecs *quals, bool static_p,
|
||||
}
|
||||
declarator->u.array.static_p = static_p;
|
||||
declarator->u.array.vla_unspec_p = vla_unspec_p;
|
||||
if (pedantic && !flag_isoc99)
|
||||
if (!flag_isoc99)
|
||||
{
|
||||
if (static_p || quals != NULL)
|
||||
pedwarn ("ISO C90 does not support %<static%> or type "
|
||||
pedwarn (OPT_pedantic, "ISO C90 does not support %<static%> or type "
|
||||
"qualifiers in parameter array declarators");
|
||||
if (vla_unspec_p)
|
||||
pedwarn ("ISO C90 does not support %<[*]%> array declarators");
|
||||
pedwarn (OPT_pedantic, "ISO C90 does not support %<[*]%> array declarators");
|
||||
}
|
||||
if (vla_unspec_p)
|
||||
{
|
||||
@ -3327,8 +3328,8 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
|
||||
&& !TREE_READONLY (decl)
|
||||
&& DECL_DECLARED_INLINE_P (current_function_decl)
|
||||
&& DECL_EXTERNAL (current_function_decl))
|
||||
pedwarn ("%q+D is static but declared in inline function %qD "
|
||||
"which is not static", decl, current_function_decl);
|
||||
pedwarn (0, "%q+D is static but declared in inline function %qD "
|
||||
"which is not static", decl, current_function_decl);
|
||||
|
||||
/* Add this decl to the current scope.
|
||||
TEM may equal DECL or it may be a previous decl of the same name. */
|
||||
@ -3705,7 +3706,7 @@ mark_forward_parm_decls (void)
|
||||
|
||||
if (pedantic && !current_scope->warned_forward_parm_decls)
|
||||
{
|
||||
pedwarn ("ISO C forbids forward parameter declarations");
|
||||
pedwarn (OPT_pedantic, "ISO C forbids forward parameter declarations");
|
||||
current_scope->warned_forward_parm_decls = true;
|
||||
}
|
||||
|
||||
@ -3852,12 +3853,11 @@ check_bitfield_type_and_width (tree *type, tree *width, const char *orig_name)
|
||||
}
|
||||
|
||||
type_mv = TYPE_MAIN_VARIANT (*type);
|
||||
if (pedantic
|
||||
&& !in_system_header
|
||||
if (!in_system_header
|
||||
&& type_mv != integer_type_node
|
||||
&& type_mv != unsigned_type_node
|
||||
&& type_mv != boolean_type_node)
|
||||
pedwarn ("type of bit-field %qs is a GCC extension", name);
|
||||
pedwarn (OPT_pedantic, "type of bit-field %qs is a GCC extension", name);
|
||||
|
||||
max_width = TYPE_PRECISION (*type);
|
||||
|
||||
@ -3887,28 +3887,27 @@ check_bitfield_type_and_width (tree *type, tree *width, const char *orig_name)
|
||||
static void
|
||||
warn_variable_length_array (const char *name, tree size)
|
||||
{
|
||||
int ped = !flag_isoc99 && pedantic && warn_vla != 0;
|
||||
int const_size = TREE_CONSTANT (size);
|
||||
|
||||
if (ped)
|
||||
if (!flag_isoc99 && pedantic && warn_vla != 0)
|
||||
{
|
||||
if (const_size)
|
||||
{
|
||||
if (name)
|
||||
pedwarn ("ISO C90 forbids array %qs whose size "
|
||||
pedwarn (OPT_Wvla, "ISO C90 forbids array %qs whose size "
|
||||
"can%'t be evaluated",
|
||||
name);
|
||||
else
|
||||
pedwarn ("ISO C90 forbids array whose size "
|
||||
pedwarn (OPT_Wvla, "ISO C90 forbids array whose size "
|
||||
"can%'t be evaluated");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (name)
|
||||
pedwarn ("ISO C90 forbids variable length array %qs",
|
||||
pedwarn (OPT_Wvla, "ISO C90 forbids variable length array %qs",
|
||||
name);
|
||||
else
|
||||
pedwarn ("ISO C90 forbids variable length array");
|
||||
pedwarn (OPT_Wvla, "ISO C90 forbids variable length array");
|
||||
}
|
||||
}
|
||||
else if (warn_vla > 0)
|
||||
@ -4069,8 +4068,9 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
if ((warn_implicit_int || warn_return_type || flag_isoc99)
|
||||
&& funcdef_flag)
|
||||
warn_about_return_type = 1;
|
||||
else if (warn_implicit_int || flag_isoc99)
|
||||
pedwarn_c99 ("type defaults to %<int%> in declaration of %qs", name);
|
||||
else
|
||||
pedwarn_c99 (flag_isoc99 ? 0 : OPT_Wimplicit_int,
|
||||
"type defaults to %<int%> in declaration of %qs", name);
|
||||
}
|
||||
|
||||
/* Adjust the type if a bit-field is being declared,
|
||||
@ -4098,11 +4098,11 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
if (pedantic && !flag_isoc99)
|
||||
{
|
||||
if (constp > 1)
|
||||
pedwarn ("duplicate %<const%>");
|
||||
pedwarn (OPT_pedantic, "duplicate %<const%>");
|
||||
if (restrictp > 1)
|
||||
pedwarn ("duplicate %<restrict%>");
|
||||
pedwarn (OPT_pedantic, "duplicate %<restrict%>");
|
||||
if (volatilep > 1)
|
||||
pedwarn ("duplicate %<volatile%>");
|
||||
pedwarn (OPT_pedantic, "duplicate %<volatile%>");
|
||||
}
|
||||
if (!flag_gen_aux_info && (TYPE_QUALS (element_type)))
|
||||
type = TYPE_MAIN_VARIANT (type);
|
||||
@ -4119,9 +4119,9 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
|| storage_class == csc_register
|
||||
|| storage_class == csc_typedef))
|
||||
{
|
||||
if (storage_class == csc_auto
|
||||
&& (pedantic || current_scope == file_scope))
|
||||
pedwarn ("function definition declared %<auto%>");
|
||||
if (storage_class == csc_auto)
|
||||
pedwarn ((current_scope == file_scope) ? 0 : OPT_pedantic,
|
||||
"function definition declared %<auto%>");
|
||||
if (storage_class == csc_register)
|
||||
error ("function definition declared %<register%>");
|
||||
if (storage_class == csc_typedef)
|
||||
@ -4177,7 +4177,7 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
if (storage_class == csc_auto)
|
||||
error ("file-scope declaration of %qs specifies %<auto%>", name);
|
||||
if (pedantic && storage_class == csc_register)
|
||||
pedwarn ("file-scope declaration of %qs specifies %<register%>", name);
|
||||
pedwarn (OPT_pedantic, "file-scope declaration of %qs specifies %<register%>", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4290,7 +4290,7 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
}
|
||||
|
||||
if (pedantic && !in_system_header && flexible_array_type_p (type))
|
||||
pedwarn ("invalid use of structure with flexible array member");
|
||||
pedwarn (OPT_pedantic, "invalid use of structure with flexible array member");
|
||||
|
||||
if (size == error_mark_node)
|
||||
type = error_mark_node;
|
||||
@ -4315,7 +4315,7 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
}
|
||||
|
||||
if (pedantic && integer_zerop (size))
|
||||
pedwarn ("ISO C forbids zero-size array %qs", name);
|
||||
pedwarn (OPT_pedantic, "ISO C forbids zero-size array %qs", name);
|
||||
|
||||
if (TREE_CODE (size) == INTEGER_CST)
|
||||
{
|
||||
@ -4387,7 +4387,7 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
else if (decl_context == FIELD)
|
||||
{
|
||||
if (pedantic && !flag_isoc99 && !in_system_header)
|
||||
pedwarn ("ISO C90 does not support flexible array members");
|
||||
pedwarn (OPT_pedantic, "ISO C90 does not support flexible array members");
|
||||
|
||||
/* ISO C99 Flexible array members are effectively
|
||||
identical to GCC's zero-length array extension. */
|
||||
@ -4532,7 +4532,7 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
function definitions in ISO C; GCC used to used
|
||||
them for noreturn functions. */
|
||||
if (VOID_TYPE_P (type) && really_funcdef)
|
||||
pedwarn ("function definition has qualified void return type");
|
||||
pedwarn (0, "function definition has qualified void return type");
|
||||
else
|
||||
warning (OPT_Wignored_qualifiers,
|
||||
"type qualifiers ignored on function return type");
|
||||
@ -4564,7 +4564,7 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
|
||||
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
|
||||
&& type_quals)
|
||||
pedwarn ("ISO C forbids qualified function types");
|
||||
pedwarn (OPT_pedantic, "ISO C forbids qualified function types");
|
||||
if (type_quals)
|
||||
type = c_build_qualified_type (type, type_quals);
|
||||
size_varies = 0;
|
||||
@ -4645,7 +4645,7 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
tree decl;
|
||||
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
|
||||
&& type_quals)
|
||||
pedwarn ("ISO C forbids qualified function types");
|
||||
pedwarn (OPT_pedantic, "ISO C forbids qualified function types");
|
||||
if (type_quals)
|
||||
type = c_build_qualified_type (type, type_quals);
|
||||
decl = build_decl (TYPE_DECL, declarator->u.id, type);
|
||||
@ -4653,7 +4653,7 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
if (declspecs->explicit_signed_p)
|
||||
C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
|
||||
if (declspecs->inline_p)
|
||||
pedwarn ("typedef %q+D declared %<inline%>", decl);
|
||||
pedwarn (0, "typedef %q+D declared %<inline%>", decl);
|
||||
return decl;
|
||||
}
|
||||
|
||||
@ -4668,7 +4668,7 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
&& !declspecs->inline_p);
|
||||
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
|
||||
&& type_quals)
|
||||
pedwarn ("ISO C forbids const or volatile function types");
|
||||
pedwarn (OPT_pedantic, "ISO C forbids const or volatile function types");
|
||||
if (type_quals)
|
||||
type = c_build_qualified_type (type, type_quals);
|
||||
return type;
|
||||
@ -4678,7 +4678,8 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
&& variably_modified_type_p (type, NULL_TREE))
|
||||
{
|
||||
/* C99 6.7.2.1p8 */
|
||||
pedwarn ("a member of a structure or union cannot have a variably modified type");
|
||||
pedwarn (OPT_pedantic,
|
||||
"a member of a structure or union cannot have a variably modified type");
|
||||
}
|
||||
|
||||
/* Aside from typedefs and type names (handle above),
|
||||
@ -4731,8 +4732,8 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
}
|
||||
else if (TREE_CODE (type) == FUNCTION_TYPE)
|
||||
{
|
||||
if (pedantic && type_quals)
|
||||
pedwarn ("ISO C forbids qualified function types");
|
||||
if (type_quals)
|
||||
pedwarn (OPT_pedantic, "ISO C forbids qualified function types");
|
||||
if (type_quals)
|
||||
type = c_build_qualified_type (type, type_quals);
|
||||
type = build_pointer_type (type);
|
||||
@ -4758,7 +4759,7 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
|
||||
DECL_ARG_TYPE (decl) = promoted_type;
|
||||
if (declspecs->inline_p)
|
||||
pedwarn ("parameter %q+D declared %<inline%>", decl);
|
||||
pedwarn (0, "parameter %q+D declared %<inline%>", decl);
|
||||
}
|
||||
else if (decl_context == FIELD)
|
||||
{
|
||||
@ -4804,10 +4805,7 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
GCC allows 'auto', perhaps with 'inline', to support
|
||||
nested functions. */
|
||||
if (storage_class == csc_auto)
|
||||
{
|
||||
if (pedantic)
|
||||
pedwarn ("invalid storage class for function %qs", name);
|
||||
}
|
||||
pedwarn (OPT_pedantic, "invalid storage class for function %qs", name);
|
||||
else if (storage_class == csc_static)
|
||||
{
|
||||
error ("invalid storage class for function %qs", name);
|
||||
@ -4823,7 +4821,8 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
decl = build_decl_attribute_variant (decl, decl_attr);
|
||||
|
||||
if (pedantic && type_quals && !DECL_IN_SYSTEM_HEADER (decl))
|
||||
pedwarn ("ISO C forbids qualified function types");
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C forbids qualified function types");
|
||||
|
||||
/* GNU C interprets a volatile-qualified function type to indicate
|
||||
that the function does not return. */
|
||||
@ -4865,7 +4864,7 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
if (flag_hosted && MAIN_NAME_P (declarator->u.id))
|
||||
{
|
||||
if (declspecs->inline_p)
|
||||
pedwarn ("cannot inline function %<main%>");
|
||||
pedwarn (0, "cannot inline function %<main%>");
|
||||
}
|
||||
else if (declspecs->inline_p)
|
||||
{
|
||||
@ -4918,7 +4917,7 @@ grokdeclarator (const struct c_declarator *declarator,
|
||||
C_DECL_VARIABLE_SIZE (decl) = 1;
|
||||
|
||||
if (declspecs->inline_p)
|
||||
pedwarn ("variable %q+D declared %<inline%>", decl);
|
||||
pedwarn (0, "variable %q+D declared %<inline%>", decl);
|
||||
|
||||
/* At file scope, an initialized extern declaration may follow
|
||||
a static declaration. In that case, DECL_EXTERNAL will be
|
||||
@ -5026,7 +5025,7 @@ grokparms (struct c_arg_info *arg_info, bool funcdef_flag)
|
||||
else if (arg_types && TREE_CODE (TREE_VALUE (arg_types)) == IDENTIFIER_NODE)
|
||||
{
|
||||
if (!funcdef_flag)
|
||||
pedwarn ("parameter names (without types) in function declaration");
|
||||
pedwarn (0, "parameter names (without types) in function declaration");
|
||||
|
||||
arg_info->parms = arg_info->types;
|
||||
arg_info->types = 0;
|
||||
@ -5440,11 +5439,10 @@ grokfield (struct c_declarator *declarator, struct c_declspecs *declspecs,
|
||||
}
|
||||
if (!ok)
|
||||
{
|
||||
pedwarn ("declaration does not declare anything");
|
||||
pedwarn (0, "declaration does not declare anything");
|
||||
return NULL_TREE;
|
||||
}
|
||||
if (pedantic)
|
||||
pedwarn ("ISO C doesn%'t support unnamed structs/unions");
|
||||
pedwarn (OPT_pedantic, "ISO C doesn%'t support unnamed structs/unions");
|
||||
}
|
||||
|
||||
value = grokdeclarator (declarator, declspecs, FIELD, false,
|
||||
@ -5543,16 +5541,16 @@ finish_struct (tree t, tree fieldlist, tree attributes)
|
||||
if (TREE_CODE (t) == UNION_TYPE)
|
||||
{
|
||||
if (fieldlist)
|
||||
pedwarn ("union has no named members");
|
||||
pedwarn (OPT_pedantic, "union has no named members");
|
||||
else
|
||||
pedwarn ("union has no members");
|
||||
pedwarn (OPT_pedantic, "union has no members");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fieldlist)
|
||||
pedwarn ("struct has no named members");
|
||||
pedwarn (OPT_pedantic, "struct has no named members");
|
||||
else
|
||||
pedwarn ("struct has no members");
|
||||
pedwarn (OPT_pedantic, "struct has no members");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5631,7 +5629,8 @@ finish_struct (tree t, tree fieldlist, tree attributes)
|
||||
|
||||
if (pedantic && !in_system_header && TREE_CODE (t) == RECORD_TYPE
|
||||
&& flexible_array_type_p (TREE_TYPE (x)))
|
||||
pedwarn ("%Jinvalid use of structure with flexible array member", x);
|
||||
pedwarn (OPT_pedantic,
|
||||
"%Jinvalid use of structure with flexible array member", x);
|
||||
|
||||
if (DECL_NAME (x))
|
||||
saw_named_field = 1;
|
||||
@ -6016,7 +6015,7 @@ build_enumerator (struct c_enum_contents *the_enum, tree name, tree value)
|
||||
|
||||
if (pedantic && !int_fits_type_p (value, integer_type_node))
|
||||
{
|
||||
pedwarn ("ISO C restricts enumerator values to range of %<int%>");
|
||||
pedwarn (OPT_pedantic, "ISO C restricts enumerator values to range of %<int%>");
|
||||
/* XXX This causes -pedantic to change the meaning of the program.
|
||||
Remove? -zw 2004-03-15 */
|
||||
value = convert (integer_type_node, value);
|
||||
@ -6132,7 +6131,9 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
|
||||
}
|
||||
|
||||
if (warn_about_return_type)
|
||||
pedwarn_c99 ("return type defaults to %<int%>");
|
||||
pedwarn_c99 (flag_isoc99 ? 0
|
||||
: (warn_return_type ? OPT_Wreturn_type : OPT_Wimplicit_int),
|
||||
"return type defaults to %<int%>");
|
||||
|
||||
/* Make the init_value nonzero so pushdecl knows this is not tentative.
|
||||
error_mark_node is replaced below (in pop_scope) with the BLOCK. */
|
||||
@ -6253,12 +6254,12 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
|
||||
{
|
||||
if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
|
||||
!= integer_type_node)
|
||||
pedwarn ("return type of %q+D is not %<int%>", decl1);
|
||||
pedwarn (OPT_Wmain, "return type of %q+D is not %<int%>", decl1);
|
||||
|
||||
check_main_parameter_types(decl1);
|
||||
|
||||
if (!TREE_PUBLIC (decl1))
|
||||
pedwarn ("%q+D is normally a non-static function", decl1);
|
||||
pedwarn (OPT_Wmain, "%q+D is normally a non-static function", decl1);
|
||||
}
|
||||
|
||||
/* Record the decl so that the function name is defined.
|
||||
@ -6406,7 +6407,7 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
|
||||
warn_if_shadowing (decl);
|
||||
|
||||
if (flag_isoc99)
|
||||
pedwarn ("type of %q+D defaults to %<int%>", decl);
|
||||
pedwarn (0, "type of %q+D defaults to %<int%>", decl);
|
||||
else
|
||||
warning (OPT_Wmissing_parameter_type, "type of %q+D defaults to %<int%>", decl);
|
||||
}
|
||||
@ -6517,22 +6518,19 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
|
||||
< TYPE_PRECISION (integer_type_node))
|
||||
DECL_ARG_TYPE (parm) = integer_type_node;
|
||||
|
||||
if (pedantic)
|
||||
/* ??? Is it possible to get here with a
|
||||
built-in prototype or will it always have
|
||||
been diagnosed as conflicting with an
|
||||
old-style definition and discarded? */
|
||||
if (current_function_prototype_built_in)
|
||||
warning (OPT_pedantic, "promoted argument %qD "
|
||||
"doesn%'t match built-in prototype", parm);
|
||||
else
|
||||
{
|
||||
/* ??? Is it possible to get here with a
|
||||
built-in prototype or will it always have
|
||||
been diagnosed as conflicting with an
|
||||
old-style definition and discarded? */
|
||||
if (current_function_prototype_built_in)
|
||||
warning (0, "promoted argument %qD "
|
||||
"doesn%'t match built-in prototype", parm);
|
||||
else
|
||||
{
|
||||
pedwarn ("promoted argument %qD "
|
||||
"doesn%'t match prototype", parm);
|
||||
pedwarn ("%Hprototype declaration",
|
||||
¤t_function_prototype_locus);
|
||||
}
|
||||
pedwarn (OPT_pedantic, "promoted argument %qD "
|
||||
"doesn%'t match prototype", parm);
|
||||
pedwarn (OPT_pedantic, "%Hprototype declaration",
|
||||
¤t_function_prototype_locus);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -6724,7 +6722,7 @@ finish_function (void)
|
||||
/* If warn_main is 1 (-Wmain) or 2 (-Wall), we have already warned.
|
||||
If warn_main is -1 (-Wno-main) we don't want to be warned. */
|
||||
if (!warn_main)
|
||||
pedwarn ("return type of %q+D is not %<int%>", fndecl);
|
||||
pedwarn (0, "return type of %q+D is not %<int%>", fndecl);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -7175,8 +7173,8 @@ declspecs_add_qual (struct c_declspecs *specs, tree qual)
|
||||
default:
|
||||
gcc_unreachable ();
|
||||
}
|
||||
if (dupe && pedantic && !flag_isoc99)
|
||||
pedwarn ("duplicate %qE", qual);
|
||||
if (dupe && !flag_isoc99)
|
||||
pedwarn (OPT_pedantic, "duplicate %qE", qual);
|
||||
return specs;
|
||||
}
|
||||
|
||||
@ -7224,9 +7222,8 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
|
||||
"declaration specifiers");
|
||||
break;
|
||||
}
|
||||
if (pedantic && !flag_isoc99 && !in_system_header
|
||||
&& warn_long_long)
|
||||
pedwarn ("ISO C90 does not support %<long long%>");
|
||||
if (pedantic && !flag_isoc99 && !in_system_header)
|
||||
pedwarn (OPT_Wlong_long, "ISO C90 does not support %<long long%>");
|
||||
specs->long_long_p = 1;
|
||||
break;
|
||||
}
|
||||
@ -7349,8 +7346,8 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
|
||||
break;
|
||||
case RID_COMPLEX:
|
||||
dupe = specs->complex_p;
|
||||
if (pedantic && !flag_isoc99 && !in_system_header)
|
||||
pedwarn ("ISO C90 does not support complex types");
|
||||
if (!flag_isoc99 && !in_system_header)
|
||||
pedwarn (OPT_pedantic, "ISO C90 does not support complex types");
|
||||
if (specs->typespec_word == cts_void)
|
||||
error ("both %<complex%> and %<void%> in "
|
||||
"declaration specifiers");
|
||||
@ -7380,8 +7377,7 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
|
||||
break;
|
||||
case RID_SAT:
|
||||
dupe = specs->saturating_p;
|
||||
if (pedantic)
|
||||
pedwarn ("ISO C does not support saturating types");
|
||||
pedwarn (OPT_pedantic, "ISO C does not support saturating types");
|
||||
if (specs->typespec_word == cts_void)
|
||||
error ("both %<_Sat%> and %<void%> in "
|
||||
"declaration specifiers");
|
||||
@ -7578,8 +7574,8 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
|
||||
}
|
||||
if (!targetm.decimal_float_supported_p ())
|
||||
error ("decimal floating point not supported for this target");
|
||||
if (pedantic)
|
||||
pedwarn ("ISO C does not support decimal floating point");
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C does not support decimal floating point");
|
||||
return specs;
|
||||
case RID_FRACT:
|
||||
case RID_ACCUM:
|
||||
@ -7599,8 +7595,8 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
|
||||
}
|
||||
if (!targetm.fixed_point_supported_p ())
|
||||
error ("fixed-point types not supported for this target");
|
||||
if (pedantic)
|
||||
pedwarn ("ISO C does not support fixed-point types");
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C does not support fixed-point types");
|
||||
return specs;
|
||||
default:
|
||||
/* ObjC reserved word "id", handled below. */
|
||||
@ -7786,9 +7782,9 @@ finish_declspecs (struct c_declspecs *specs)
|
||||
else if (specs->complex_p)
|
||||
{
|
||||
specs->typespec_word = cts_double;
|
||||
if (pedantic)
|
||||
pedwarn ("ISO C does not support plain %<complex%> meaning "
|
||||
"%<double complex%>");
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C does not support plain %<complex%> meaning "
|
||||
"%<double complex%>");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -7831,8 +7827,8 @@ finish_declspecs (struct c_declspecs *specs)
|
||||
specs->type = char_type_node;
|
||||
if (specs->complex_p)
|
||||
{
|
||||
if (pedantic)
|
||||
pedwarn ("ISO C does not support complex integer types");
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C does not support complex integer types");
|
||||
specs->type = build_complex_type (specs->type);
|
||||
}
|
||||
break;
|
||||
@ -7857,8 +7853,8 @@ finish_declspecs (struct c_declspecs *specs)
|
||||
: integer_type_node);
|
||||
if (specs->complex_p)
|
||||
{
|
||||
if (pedantic)
|
||||
pedwarn ("ISO C does not support complex integer types");
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C does not support complex integer types");
|
||||
specs->type = build_complex_type (specs->type);
|
||||
}
|
||||
break;
|
||||
@ -8008,7 +8004,7 @@ c_write_global_declarations_1 (tree globals)
|
||||
&& !TREE_PUBLIC (decl)
|
||||
&& C_DECL_USED (decl))
|
||||
{
|
||||
pedwarn ("%q+F used but never defined", decl);
|
||||
pedwarn (0, "%q+F used but never defined", decl);
|
||||
TREE_NO_WARNING (decl) = 1;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
/* Issue an ISO C99 pedantic warning MSGID. */
|
||||
|
||||
void
|
||||
pedwarn_c99 (const char *gmsgid, ...)
|
||||
pedwarn_c99 (int opt, const char *gmsgid, ...)
|
||||
{
|
||||
diagnostic_info diagnostic;
|
||||
va_list ap;
|
||||
@ -39,6 +39,7 @@ pedwarn_c99 (const char *gmsgid, ...)
|
||||
va_start (ap, gmsgid);
|
||||
diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
|
||||
flag_isoc99 ? pedantic_warning_kind () : DK_WARNING);
|
||||
diagnostic.option_index = opt;
|
||||
report_diagnostic (&diagnostic);
|
||||
va_end (ap);
|
||||
}
|
||||
@ -49,7 +50,7 @@ pedwarn_c99 (const char *gmsgid, ...)
|
||||
(There is no flag_c90.) */
|
||||
|
||||
void
|
||||
pedwarn_c90 (const char *gmsgid, ...)
|
||||
pedwarn_c90 (int opt, const char *gmsgid, ...)
|
||||
{
|
||||
diagnostic_info diagnostic;
|
||||
va_list ap;
|
||||
@ -57,6 +58,7 @@ pedwarn_c90 (const char *gmsgid, ...)
|
||||
va_start (ap, gmsgid);
|
||||
diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
|
||||
flag_isoc99 ? DK_WARNING : pedantic_warning_kind ());
|
||||
diagnostic.option_index = opt;
|
||||
report_diagnostic (&diagnostic);
|
||||
va_end (ap);
|
||||
}
|
||||
|
10
gcc/c-lex.c
10
gcc/c-lex.c
@ -587,8 +587,8 @@ interpret_integer (const cpp_token *token, unsigned int flags)
|
||||
if (itk > itk_unsigned_long
|
||||
&& (flags & CPP_N_WIDTH) != CPP_N_LARGE
|
||||
&& !in_system_header && !flag_isoc99)
|
||||
pedwarn ("integer constant is too large for %qs type",
|
||||
(flags & CPP_N_UNSIGNED) ? "unsigned long" : "long");
|
||||
pedwarn (0, "integer constant is too large for %qs type",
|
||||
(flags & CPP_N_UNSIGNED) ? "unsigned long" : "long");
|
||||
|
||||
value = build_int_cst_wide (type, integer.low, integer.high);
|
||||
|
||||
@ -641,8 +641,8 @@ interpret_float (const cpp_token *token, unsigned int flags)
|
||||
|
||||
return error_mark_node;
|
||||
}
|
||||
else if (pedantic)
|
||||
pedwarn ("non-standard suffix on floating constant");
|
||||
else
|
||||
pedwarn (OPT_pedantic, "non-standard suffix on floating constant");
|
||||
|
||||
type = c_common_type_for_mode (mode, 0);
|
||||
gcc_assert (type);
|
||||
@ -684,7 +684,7 @@ interpret_float (const cpp_token *token, unsigned int flags)
|
||||
if (REAL_VALUE_ISINF (real))
|
||||
{
|
||||
if (!MODE_HAS_INFINITIES (TYPE_MODE (type)))
|
||||
pedwarn ("floating constant exceeds range of %qT", type);
|
||||
pedwarn (0, "floating constant exceeds range of %qT", type);
|
||||
else
|
||||
warning (OPT_Woverflow, "floating constant exceeds range of %qT", type);
|
||||
}
|
||||
|
132
gcc/c-parser.c
132
gcc/c-parser.c
@ -960,9 +960,8 @@ c_parser_translation_unit (c_parser *parser)
|
||||
{
|
||||
if (c_parser_next_token_is (parser, CPP_EOF))
|
||||
{
|
||||
if (pedantic)
|
||||
pedwarn ("%HISO C forbids an empty translation unit",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
pedwarn (OPT_pedantic, "%HISO C forbids an empty translation unit",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1046,9 +1045,9 @@ c_parser_external_declaration (c_parser *parser)
|
||||
}
|
||||
break;
|
||||
case CPP_SEMICOLON:
|
||||
if (pedantic)
|
||||
pedwarn ("%HISO C does not allow extra %<;%> outside of a function",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
pedwarn (OPT_pedantic,
|
||||
"%HISO C does not allow extra %<;%> outside of a function",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
c_parser_consume_token (parser);
|
||||
break;
|
||||
case CPP_PRAGMA:
|
||||
@ -1162,7 +1161,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, bool empty_ok,
|
||||
else
|
||||
{
|
||||
shadow_tag_warned (specs, 1);
|
||||
pedwarn ("%Hempty declaration", &here);
|
||||
pedwarn (0, "%Hempty declaration", &here);
|
||||
}
|
||||
c_parser_consume_token (parser);
|
||||
return;
|
||||
@ -1198,8 +1197,8 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, bool empty_ok,
|
||||
if (!diagnosed_no_specs && !specs->declspecs_seen_p)
|
||||
{
|
||||
diagnosed_no_specs = true;
|
||||
pedwarn ("%Hdata definition has no type or storage class",
|
||||
&here);
|
||||
pedwarn (0, "%Hdata definition has no type or storage class",
|
||||
&here);
|
||||
}
|
||||
/* Having seen a data definition, there cannot now be a
|
||||
function definition. */
|
||||
@ -1268,8 +1267,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, bool empty_ok,
|
||||
/* Function definition (nested or otherwise). */
|
||||
if (nested)
|
||||
{
|
||||
if (pedantic)
|
||||
pedwarn ("%HISO C forbids nested functions", &here);
|
||||
pedwarn (OPT_pedantic, "%HISO C forbids nested functions", &here);
|
||||
c_push_function_context ();
|
||||
}
|
||||
if (!start_function (specs, declarator, all_prefix_attrs))
|
||||
@ -1663,8 +1661,9 @@ c_parser_enum_specifier (c_parser *parser)
|
||||
}
|
||||
if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
|
||||
{
|
||||
if (seen_comma && pedantic && !flag_isoc99)
|
||||
pedwarn ("%Hcomma at end of enumerator list", &comma_loc);
|
||||
if (seen_comma && !flag_isoc99)
|
||||
pedwarn (OPT_pedantic, "%Hcomma at end of enumerator list",
|
||||
&comma_loc);
|
||||
c_parser_consume_token (parser);
|
||||
break;
|
||||
}
|
||||
@ -1695,7 +1694,8 @@ c_parser_enum_specifier (c_parser *parser)
|
||||
if (pedantic && !COMPLETE_TYPE_P (ret.spec))
|
||||
{
|
||||
gcc_assert (ident);
|
||||
pedwarn ("%HISO C forbids forward references to %<enum%> types",
|
||||
pedwarn (OPT_pedantic,
|
||||
"%HISO C forbids forward references to %<enum%> types",
|
||||
&ident_loc);
|
||||
}
|
||||
return ret;
|
||||
@ -1820,9 +1820,9 @@ c_parser_struct_or_union_specifier (c_parser *parser)
|
||||
/* Parse any stray semicolon. */
|
||||
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
|
||||
{
|
||||
if (pedantic)
|
||||
pedwarn ("%Hextra semicolon in struct or union specified",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
pedwarn (OPT_pedantic,
|
||||
"%Hextra semicolon in struct or union specified",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
c_parser_consume_token (parser);
|
||||
continue;
|
||||
}
|
||||
@ -1850,8 +1850,8 @@ c_parser_struct_or_union_specifier (c_parser *parser)
|
||||
else
|
||||
{
|
||||
if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
|
||||
pedwarn ("%Hno semicolon at end of struct or union",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
pedwarn (0, "%Hno semicolon at end of struct or union",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
else
|
||||
{
|
||||
c_parser_error (parser, "expected %<;%>");
|
||||
@ -1942,9 +1942,9 @@ c_parser_struct_declaration (c_parser *parser)
|
||||
tree ret;
|
||||
if (!specs->type_seen_p)
|
||||
{
|
||||
if (pedantic)
|
||||
pedwarn ("%HISO C forbids member declarations with no members",
|
||||
&decl_loc);
|
||||
pedwarn (OPT_pedantic,
|
||||
"%HISO C forbids member declarations with no members",
|
||||
&decl_loc);
|
||||
shadow_tag_warned (specs, pedantic);
|
||||
ret = NULL_TREE;
|
||||
}
|
||||
@ -2997,8 +2997,8 @@ c_parser_braced_init (c_parser *parser, tree type, bool nested_p)
|
||||
really_start_incremental_init (type);
|
||||
if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
|
||||
{
|
||||
if (pedantic)
|
||||
pedwarn ("%HISO C forbids empty initializer braces", &brace_loc);
|
||||
pedwarn (OPT_pedantic, "%HISO C forbids empty initializer braces",
|
||||
&brace_loc);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3042,12 +3042,10 @@ c_parser_initelt (c_parser *parser)
|
||||
{
|
||||
/* Old-style structure member designator. */
|
||||
set_init_label (c_parser_peek_token (parser)->value);
|
||||
if (pedantic)
|
||||
{
|
||||
/* Use the colon as the error location. */
|
||||
pedwarn ("%Hobsolete use of designated initializer with %<:%>",
|
||||
&c_parser_peek_2nd_token (parser)->location);
|
||||
}
|
||||
/* Use the colon as the error location. */
|
||||
pedwarn (OPT_pedantic,
|
||||
"%Hobsolete use of designated initializer with %<:%>",
|
||||
&c_parser_peek_2nd_token (parser)->location);
|
||||
c_parser_consume_token (parser);
|
||||
c_parser_consume_token (parser);
|
||||
}
|
||||
@ -3175,8 +3173,9 @@ c_parser_initelt (c_parser *parser)
|
||||
{
|
||||
c_parser_consume_token (parser);
|
||||
set_init_index (first, second);
|
||||
if (pedantic && second)
|
||||
pedwarn ("%HISO C forbids specifying range of "
|
||||
if (second)
|
||||
pedwarn (OPT_pedantic,
|
||||
"%HISO C forbids specifying range of "
|
||||
"elements to initialize", &ellipsis_loc);
|
||||
}
|
||||
else
|
||||
@ -3188,8 +3187,9 @@ c_parser_initelt (c_parser *parser)
|
||||
{
|
||||
if (c_parser_next_token_is (parser, CPP_EQ))
|
||||
{
|
||||
if (pedantic && !flag_isoc99)
|
||||
pedwarn ("%HISO C90 forbids specifying subobject "
|
||||
if (!flag_isoc99)
|
||||
pedwarn (OPT_pedantic,
|
||||
"%HISO C90 forbids specifying subobject "
|
||||
"to initialize", &des_loc);
|
||||
c_parser_consume_token (parser);
|
||||
}
|
||||
@ -3197,10 +3197,10 @@ c_parser_initelt (c_parser *parser)
|
||||
{
|
||||
if (des_seen == 1)
|
||||
{
|
||||
if (pedantic)
|
||||
pedwarn ("%Hobsolete use of designated initializer "
|
||||
"without %<=%>",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
pedwarn (OPT_pedantic,
|
||||
"%Hobsolete use of designated initializer "
|
||||
"without %<=%>",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3351,8 +3351,7 @@ c_parser_compound_statement_nostart (c_parser *parser)
|
||||
}
|
||||
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
|
||||
}
|
||||
if (pedantic)
|
||||
pedwarn ("%HISO C forbids label declarations", &err_loc);
|
||||
pedwarn (OPT_pedantic, "%HISO C forbids label declarations", &err_loc);
|
||||
}
|
||||
/* We must now have at least one statement, label or declaration. */
|
||||
if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
|
||||
@ -3382,10 +3381,11 @@ c_parser_compound_statement_nostart (c_parser *parser)
|
||||
{
|
||||
last_label = false;
|
||||
c_parser_declaration_or_fndef (parser, true, true, true, true);
|
||||
if (last_stmt
|
||||
&& ((pedantic && !flag_isoc99)
|
||||
|| warn_declaration_after_statement))
|
||||
pedwarn_c90 ("%HISO C90 forbids mixed declarations and code",
|
||||
if (last_stmt)
|
||||
pedwarn_c90 ((pedantic && !flag_isoc99)
|
||||
? OPT_pedantic
|
||||
: OPT_Wdeclaration_after_statement,
|
||||
"%HISO C90 forbids mixed declarations and code",
|
||||
&loc);
|
||||
last_stmt = false;
|
||||
}
|
||||
@ -3410,10 +3410,11 @@ c_parser_compound_statement_nostart (c_parser *parser)
|
||||
/* Following the old parser, __extension__ does not
|
||||
disable this diagnostic. */
|
||||
restore_extension_diagnostics (ext);
|
||||
if (last_stmt
|
||||
&& ((pedantic && !flag_isoc99)
|
||||
|| warn_declaration_after_statement))
|
||||
pedwarn_c90 ("%HISO C90 forbids mixed declarations and code",
|
||||
if (last_stmt)
|
||||
pedwarn_c90 ((pedantic && !flag_isoc99)
|
||||
? OPT_pedantic
|
||||
: OPT_Wdeclaration_after_statement,
|
||||
"%HISO C90 forbids mixed declarations and code",
|
||||
&loc);
|
||||
last_stmt = false;
|
||||
}
|
||||
@ -4420,9 +4421,9 @@ c_parser_conditional_expression (c_parser *parser, struct c_expr *after)
|
||||
c_parser_consume_token (parser);
|
||||
if (c_parser_next_token_is (parser, CPP_COLON))
|
||||
{
|
||||
if (pedantic)
|
||||
pedwarn ("%HISO C forbids omitting the middle term of a ?: expression",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
pedwarn (OPT_pedantic,
|
||||
"%HISO C forbids omitting the middle term of a ?: expression",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
/* Make sure first operand is calculated only once. */
|
||||
exp1.value = save_expr (default_conversion (cond.value));
|
||||
cond.value = c_objc_common_truthvalue_conversion (exp1.value);
|
||||
@ -5124,9 +5125,8 @@ c_parser_postfix_expression (c_parser *parser)
|
||||
c_parser_compound_statement_nostart (parser);
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
|
||||
"expected %<)%>");
|
||||
if (pedantic)
|
||||
pedwarn ("%HISO C forbids braced-groups within expressions",
|
||||
&here);
|
||||
pedwarn (OPT_pedantic,
|
||||
"%HISO C forbids braced-groups within expressions", &here);
|
||||
expr.value = c_finish_stmt_expr (stmt);
|
||||
expr.original_code = ERROR_MARK;
|
||||
}
|
||||
@ -5486,8 +5486,9 @@ c_parser_postfix_expression_after_paren_type (c_parser *parser,
|
||||
finish_init ();
|
||||
maybe_warn_string_init (type, init);
|
||||
|
||||
if (pedantic && !flag_isoc99)
|
||||
pedwarn ("%HISO C90 forbids compound literals", &start_loc);
|
||||
if (!flag_isoc99)
|
||||
pedwarn (OPT_pedantic, "%HISO C90 forbids compound literals",
|
||||
&start_loc);
|
||||
expr.value = build_compound_literal (type, init.value);
|
||||
expr.original_code = ERROR_MARK;
|
||||
return c_parser_postfix_expression_after_primary (parser, expr);
|
||||
@ -5788,9 +5789,9 @@ c_parser_objc_class_instance_variables (c_parser *parser)
|
||||
/* Parse any stray semicolon. */
|
||||
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
|
||||
{
|
||||
if (pedantic)
|
||||
pedwarn ("%Hextra semicolon in struct or union specified",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
pedwarn (OPT_pedantic,
|
||||
"%Hextra semicolon in struct or union specified",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
c_parser_consume_token (parser);
|
||||
continue;
|
||||
}
|
||||
@ -6006,9 +6007,9 @@ c_parser_objc_method_definition (c_parser *parser)
|
||||
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
|
||||
{
|
||||
c_parser_consume_token (parser);
|
||||
if (pedantic)
|
||||
pedwarn ("%Hextra semicolon in method definition specified",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
pedwarn (OPT_pedantic,
|
||||
"%Hextra semicolon in method definition specified",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
}
|
||||
if (!c_parser_next_token_is (parser, CPP_OPEN_BRACE))
|
||||
{
|
||||
@ -6044,10 +6045,9 @@ c_parser_objc_methodprotolist (c_parser *parser)
|
||||
switch (c_parser_peek_token (parser)->type)
|
||||
{
|
||||
case CPP_SEMICOLON:
|
||||
if (pedantic)
|
||||
pedwarn ("%HISO C does not allow extra %<;%> "
|
||||
"outside of a function",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
pedwarn (OPT_pedantic, "%HISO C does not allow extra %<;%> "
|
||||
"outside of a function",
|
||||
&c_parser_peek_token (parser)->location);
|
||||
c_parser_consume_token (parser);
|
||||
break;
|
||||
case CPP_PLUS:
|
||||
|
@ -563,7 +563,7 @@ extern tree c_cast_expr (struct c_type_name *, tree);
|
||||
extern tree build_c_cast (tree, tree);
|
||||
extern void store_init_value (tree, tree);
|
||||
extern void error_init (const char *);
|
||||
extern void pedwarn_init (const char *);
|
||||
extern void pedwarn_init (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);
|
||||
@ -640,7 +640,7 @@ extern void c_write_global_declarations (void);
|
||||
#define ATTRIBUTE_GCC_CDIAG(m, n) ATTRIBUTE_NONNULL(m)
|
||||
#endif
|
||||
|
||||
extern void pedwarn_c90 (const char *, ...) ATTRIBUTE_GCC_CDIAG(1,2);
|
||||
extern void pedwarn_c99 (const char *, ...) ATTRIBUTE_GCC_CDIAG(1,2);
|
||||
extern void pedwarn_c90 (int opt, const char *, ...) ATTRIBUTE_GCC_CDIAG(2,3);
|
||||
extern void pedwarn_c99 (int opt, const char *, ...) ATTRIBUTE_GCC_CDIAG(2,3);
|
||||
|
||||
#endif /* ! GCC_C_TREE_H */
|
||||
|
203
gcc/c-typeck.c
203
gcc/c-typeck.c
@ -470,8 +470,8 @@ composite_type (tree t1, tree t2)
|
||||
{
|
||||
TREE_VALUE (n) = composite_type (TREE_TYPE (memb),
|
||||
TREE_VALUE (p2));
|
||||
if (pedantic)
|
||||
pedwarn ("function types not truly compatible in ISO C");
|
||||
pedwarn (OPT_pedantic,
|
||||
"function types not truly compatible in ISO C");
|
||||
goto parm_done;
|
||||
}
|
||||
}
|
||||
@ -495,8 +495,8 @@ composite_type (tree t1, tree t2)
|
||||
{
|
||||
TREE_VALUE (n) = composite_type (TREE_TYPE (memb),
|
||||
TREE_VALUE (p1));
|
||||
if (pedantic)
|
||||
pedwarn ("function types not truly compatible in ISO C");
|
||||
pedwarn (OPT_pedantic,
|
||||
"function types not truly compatible in ISO C");
|
||||
goto parm_done;
|
||||
}
|
||||
}
|
||||
@ -1039,8 +1039,8 @@ comp_target_types (tree ttl, tree ttr)
|
||||
mvr = TYPE_MAIN_VARIANT (mvr);
|
||||
val = comptypes (mvl, mvr);
|
||||
|
||||
if (val == 2 && pedantic)
|
||||
pedwarn ("types are not quite compatible");
|
||||
if (val == 2)
|
||||
pedwarn (OPT_pedantic, "types are not quite compatible");
|
||||
return val;
|
||||
}
|
||||
|
||||
@ -1363,7 +1363,7 @@ function_types_compatible_p (const_tree f1, const_tree f2)
|
||||
/* 'volatile' qualifiers on a function's return type used to mean
|
||||
the function is noreturn. */
|
||||
if (TYPE_VOLATILE (ret1) != TYPE_VOLATILE (ret2))
|
||||
pedwarn ("function return types not compatible due to %<volatile%>");
|
||||
pedwarn (0, "function return types not compatible due to %<volatile%>");
|
||||
if (TYPE_VOLATILE (ret1))
|
||||
ret1 = build_qualified_type (TYPE_MAIN_VARIANT (ret1),
|
||||
TYPE_QUALS (ret1) & ~TYPE_QUAL_VOLATILE);
|
||||
@ -2115,9 +2115,11 @@ build_array_ref (tree array, tree index)
|
||||
while (TREE_CODE (foo) == COMPONENT_REF)
|
||||
foo = TREE_OPERAND (foo, 0);
|
||||
if (TREE_CODE (foo) == VAR_DECL && C_DECL_REGISTER (foo))
|
||||
pedwarn ("ISO C forbids subscripting %<register%> array");
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C forbids subscripting %<register%> array");
|
||||
else if (!flag_isoc99 && !lvalue_p (foo))
|
||||
pedwarn ("ISO C90 forbids subscripting non-lvalue array");
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C90 forbids subscripting non-lvalue array");
|
||||
}
|
||||
|
||||
type = TREE_TYPE (TREE_TYPE (array));
|
||||
@ -2231,8 +2233,8 @@ build_external_ref (tree id, int fun, location_t loc)
|
||||
&& (TREE_CODE (ref) != VAR_DECL || TREE_STATIC (ref))
|
||||
&& ! TREE_PUBLIC (ref)
|
||||
&& DECL_CONTEXT (ref) != current_function_decl)
|
||||
pedwarn ("%H%qD is static but used in inline function %qD "
|
||||
"which is not static", &loc, ref, current_function_decl);
|
||||
pedwarn (0, "%H%qD is static but used in inline function %qD "
|
||||
"which is not static", &loc, ref, current_function_decl);
|
||||
|
||||
return ref;
|
||||
}
|
||||
@ -2456,7 +2458,7 @@ build_function_call (tree function, tree params)
|
||||
if (TREE_CONSTANT (result)
|
||||
&& (name == NULL_TREE
|
||||
|| strncmp (IDENTIFIER_POINTER (name), "__builtin_", 10) != 0))
|
||||
pedwarn_init ("initializer element is not constant");
|
||||
pedwarn_init (0, "initializer element is not constant");
|
||||
}
|
||||
else
|
||||
result = fold_build_call_array (TREE_TYPE (fntype),
|
||||
@ -2800,13 +2802,12 @@ pointer_diff (tree op0, tree op1)
|
||||
tree con0, con1, lit0, lit1;
|
||||
tree orig_op1 = op1;
|
||||
|
||||
if (pedantic || warn_pointer_arith)
|
||||
{
|
||||
if (TREE_CODE (target_type) == VOID_TYPE)
|
||||
pedwarn ("pointer of type %<void *%> used in subtraction");
|
||||
if (TREE_CODE (target_type) == FUNCTION_TYPE)
|
||||
pedwarn ("pointer to a function used in subtraction");
|
||||
}
|
||||
if (TREE_CODE (target_type) == VOID_TYPE)
|
||||
pedwarn (pedantic ? OPT_pedantic : OPT_Wpointer_arith,
|
||||
"pointer of type %<void *%> used in subtraction");
|
||||
if (TREE_CODE (target_type) == FUNCTION_TYPE)
|
||||
pedwarn (pedantic ? OPT_pedantic : OPT_Wpointer_arith,
|
||||
"pointer to a function used in subtraction");
|
||||
|
||||
/* If the conversion to ptrdiff_type does anything like widening or
|
||||
converting a partial to an integral mode, we get a convert_expression
|
||||
@ -2948,8 +2949,8 @@ build_unary_op (enum tree_code code, tree xarg, int flag)
|
||||
else if (typecode == COMPLEX_TYPE)
|
||||
{
|
||||
code = CONJ_EXPR;
|
||||
if (pedantic)
|
||||
pedwarn ("ISO C does not support %<~%> for complex conjugation");
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C does not support %<~%> for complex conjugation");
|
||||
if (!noconvert)
|
||||
arg = default_conversion (arg);
|
||||
}
|
||||
@ -3020,9 +3021,8 @@ build_unary_op (enum tree_code code, tree xarg, int flag)
|
||||
{
|
||||
tree real, imag;
|
||||
|
||||
if (pedantic)
|
||||
pedwarn ("ISO C does not support %<++%> and %<--%>"
|
||||
" on complex types");
|
||||
pedwarn (OPT_pedantic, "ISO C does not support %<++%> and %<--%>"
|
||||
" on complex types");
|
||||
|
||||
arg = stabilize_reference (arg);
|
||||
real = build_unary_op (REALPART_EXPR, arg, 1);
|
||||
@ -3067,14 +3067,15 @@ build_unary_op (enum tree_code code, tree xarg, int flag)
|
||||
else
|
||||
error ("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))
|
||||
else if (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE
|
||||
|| TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE)
|
||||
{
|
||||
if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
|
||||
pedwarn ("wrong type argument to increment");
|
||||
pedwarn (pedantic ? OPT_pedantic : OPT_Wpointer_arith,
|
||||
"wrong type argument to increment");
|
||||
else
|
||||
pedwarn ("wrong type argument to decrement");
|
||||
pedwarn (pedantic ? OPT_pedantic : OPT_Wpointer_arith,
|
||||
"wrong type argument to decrement");
|
||||
}
|
||||
|
||||
inc = c_size_in_bytes (TREE_TYPE (result_type));
|
||||
@ -3349,7 +3350,7 @@ c_mark_addressable (tree exp)
|
||||
("global register variable %qD used in nested function", x);
|
||||
return false;
|
||||
}
|
||||
pedwarn ("register variable %qD used in nested function", x);
|
||||
pedwarn (0, "register variable %qD used in nested function", x);
|
||||
}
|
||||
else if (C_DECL_REGISTER (x))
|
||||
{
|
||||
@ -3456,8 +3457,9 @@ build_conditional_expr (tree ifexp, tree op1, tree op2)
|
||||
}
|
||||
else if (code1 == VOID_TYPE || code2 == VOID_TYPE)
|
||||
{
|
||||
if (pedantic && (code1 != VOID_TYPE || code2 != VOID_TYPE))
|
||||
pedwarn ("ISO C forbids conditional expr with only one void side");
|
||||
if (code1 != VOID_TYPE || code2 != VOID_TYPE)
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C forbids conditional expr with only one void side");
|
||||
result_type = void_type_node;
|
||||
}
|
||||
else if (code1 == POINTER_TYPE && code2 == POINTER_TYPE)
|
||||
@ -3470,30 +3472,30 @@ build_conditional_expr (tree ifexp, tree op1, tree op2)
|
||||
result_type = qualify_type (type1, type2);
|
||||
else if (VOID_TYPE_P (TREE_TYPE (type1)))
|
||||
{
|
||||
if (pedantic && TREE_CODE (TREE_TYPE (type2)) == FUNCTION_TYPE)
|
||||
pedwarn ("ISO C forbids conditional expr between "
|
||||
if (TREE_CODE (TREE_TYPE (type2)) == FUNCTION_TYPE)
|
||||
pedwarn (OPT_pedantic, "ISO C forbids conditional expr between "
|
||||
"%<void *%> and function pointer");
|
||||
result_type = build_pointer_type (qualify_type (TREE_TYPE (type1),
|
||||
TREE_TYPE (type2)));
|
||||
}
|
||||
else if (VOID_TYPE_P (TREE_TYPE (type2)))
|
||||
{
|
||||
if (pedantic && TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE)
|
||||
pedwarn ("ISO C forbids conditional expr between "
|
||||
if (TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE)
|
||||
pedwarn (OPT_pedantic, "ISO C forbids conditional expr between "
|
||||
"%<void *%> and function pointer");
|
||||
result_type = build_pointer_type (qualify_type (TREE_TYPE (type2),
|
||||
TREE_TYPE (type1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
pedwarn ("pointer type mismatch in conditional expression");
|
||||
pedwarn (0, "pointer type mismatch in conditional expression");
|
||||
result_type = build_pointer_type (void_type_node);
|
||||
}
|
||||
}
|
||||
else if (code1 == POINTER_TYPE && code2 == INTEGER_TYPE)
|
||||
{
|
||||
if (!null_pointer_constant_p (orig_op2))
|
||||
pedwarn ("pointer/integer type mismatch in conditional expression");
|
||||
pedwarn (0, "pointer/integer type mismatch in conditional expression");
|
||||
else
|
||||
{
|
||||
op2 = null_pointer_node;
|
||||
@ -3503,7 +3505,7 @@ build_conditional_expr (tree ifexp, tree op1, tree op2)
|
||||
else if (code2 == POINTER_TYPE && code1 == INTEGER_TYPE)
|
||||
{
|
||||
if (!null_pointer_constant_p (orig_op1))
|
||||
pedwarn ("pointer/integer type mismatch in conditional expression");
|
||||
pedwarn (0, "pointer/integer type mismatch in conditional expression");
|
||||
else
|
||||
{
|
||||
op1 = null_pointer_node;
|
||||
@ -3614,12 +3616,10 @@ build_c_cast (tree type, tree expr)
|
||||
|
||||
if (type == TYPE_MAIN_VARIANT (TREE_TYPE (value)))
|
||||
{
|
||||
if (pedantic)
|
||||
{
|
||||
if (TREE_CODE (type) == RECORD_TYPE
|
||||
|| TREE_CODE (type) == UNION_TYPE)
|
||||
pedwarn ("ISO C forbids casting nonscalar to the same type");
|
||||
}
|
||||
if (TREE_CODE (type) == RECORD_TYPE
|
||||
|| TREE_CODE (type) == UNION_TYPE)
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C forbids casting nonscalar to the same type");
|
||||
}
|
||||
else if (TREE_CODE (type) == UNION_TYPE)
|
||||
{
|
||||
@ -3635,8 +3635,7 @@ build_c_cast (tree type, tree expr)
|
||||
{
|
||||
tree t;
|
||||
|
||||
if (pedantic)
|
||||
pedwarn ("ISO C forbids casts to union type");
|
||||
pedwarn (OPT_pedantic, "ISO C forbids casts to union type");
|
||||
t = digest_init (type,
|
||||
build_constructor_single (type, field, value),
|
||||
true, 0);
|
||||
@ -3747,7 +3746,8 @@ build_c_cast (tree type, tree expr)
|
||||
&& TREE_CODE (otype) == POINTER_TYPE
|
||||
&& TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE
|
||||
&& TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE)
|
||||
pedwarn ("ISO C forbids conversion of function pointer to object pointer type");
|
||||
pedwarn (OPT_pedantic, "ISO C forbids "
|
||||
"conversion of function pointer to object pointer type");
|
||||
|
||||
if (pedantic
|
||||
&& TREE_CODE (type) == POINTER_TYPE
|
||||
@ -3755,7 +3755,8 @@ build_c_cast (tree type, tree expr)
|
||||
&& TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
|
||||
&& TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
|
||||
&& !null_pointer_constant_p (value))
|
||||
pedwarn ("ISO C forbids conversion of object pointer to function pointer type");
|
||||
pedwarn (OPT_pedantic, "ISO C forbids "
|
||||
"conversion of object pointer to function pointer type");
|
||||
|
||||
ovalue = value;
|
||||
value = convert (type, value);
|
||||
@ -3951,19 +3952,19 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
|
||||
switch (errtype) \
|
||||
{ \
|
||||
case ic_argpass: \
|
||||
pedwarn (AR, parmnum, rname); \
|
||||
pedwarn (0, AR, parmnum, rname); \
|
||||
break; \
|
||||
case ic_argpass_nonproto: \
|
||||
warning (0, AR, parmnum, rname); \
|
||||
warning (0, AR, parmnum, rname); \
|
||||
break; \
|
||||
case ic_assign: \
|
||||
pedwarn (AS); \
|
||||
pedwarn (0, AS); \
|
||||
break; \
|
||||
case ic_init: \
|
||||
pedwarn (IN); \
|
||||
pedwarn (0, IN); \
|
||||
break; \
|
||||
case ic_return: \
|
||||
pedwarn (RE); \
|
||||
pedwarn (0, RE); \
|
||||
break; \
|
||||
default: \
|
||||
gcc_unreachable (); \
|
||||
@ -4170,8 +4171,9 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
|
||||
memb = marginal_memb;
|
||||
}
|
||||
|
||||
if (pedantic && (!fundecl || !DECL_IN_SYSTEM_HEADER (fundecl)))
|
||||
pedwarn ("ISO C prohibits argument conversion to union type");
|
||||
if (!fundecl || !DECL_IN_SYSTEM_HEADER (fundecl))
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C prohibits argument conversion to union type");
|
||||
|
||||
rhs = fold_convert (TREE_TYPE (memb), rhs);
|
||||
return build_constructor_single (type, memb, rhs);
|
||||
@ -4616,19 +4618,20 @@ error_init (const char *msgid)
|
||||
error ("(near initialization for %qs)", ofwhat);
|
||||
}
|
||||
|
||||
/* Issue a pedantic warning for a bad initializer component.
|
||||
MSGID identifies the message.
|
||||
The component name is taken from the spelling stack. */
|
||||
/* 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. MSGID identifies the message. The
|
||||
component name is taken from the spelling stack. */
|
||||
|
||||
void
|
||||
pedwarn_init (const char *msgid)
|
||||
pedwarn_init (int opt, const char *msgid)
|
||||
{
|
||||
char *ofwhat;
|
||||
|
||||
pedwarn ("%s", _(msgid));
|
||||
pedwarn (opt, "%s", _(msgid));
|
||||
ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
|
||||
if (*ofwhat)
|
||||
pedwarn ("(near initialization for %qs)", ofwhat);
|
||||
pedwarn (opt, "(near initialization for %qs)", ofwhat);
|
||||
}
|
||||
|
||||
/* Issue a warning for a bad initializer component.
|
||||
@ -4659,7 +4662,8 @@ maybe_warn_string_init (tree type, struct c_expr expr)
|
||||
&& TREE_CODE (type) == ARRAY_TYPE
|
||||
&& TREE_CODE (expr.value) == STRING_CST
|
||||
&& expr.original_code != STRING_CST)
|
||||
pedwarn_init ("array initialized from parenthesized string constant");
|
||||
pedwarn_init (OPT_pedantic,
|
||||
"array initialized from parenthesized string constant");
|
||||
}
|
||||
|
||||
/* Digest the parser output INIT as an initializer for type TYPE.
|
||||
@ -4752,7 +4756,7 @@ digest_init (tree type, tree init, bool strict_string, int require_constant)
|
||||
TREE_STRING_LENGTH (inside_init)
|
||||
- (TYPE_PRECISION (typ1)
|
||||
/ BITS_PER_UNIT)))
|
||||
pedwarn_init ("initializer-string for array of chars is too long");
|
||||
pedwarn_init (0, "initializer-string for array of chars is too long");
|
||||
|
||||
return inside_init;
|
||||
}
|
||||
@ -4867,7 +4871,7 @@ digest_init (tree type, tree init, bool strict_string, int require_constant)
|
||||
if (inside_init == error_mark_node)
|
||||
error_init ("initializer element is not constant");
|
||||
else
|
||||
pedwarn_init ("initializer element is not constant");
|
||||
pedwarn_init (OPT_pedantic, "initializer element is not constant");
|
||||
if (flag_pedantic_errors)
|
||||
inside_init = error_mark_node;
|
||||
}
|
||||
@ -5540,8 +5544,8 @@ pop_init_level (int implicit)
|
||||
|
||||
if (constructor_depth > 2)
|
||||
error_init ("initialization of flexible array member in a nested context");
|
||||
else if (pedantic)
|
||||
pedwarn_init ("initialization of a flexible array member");
|
||||
else
|
||||
pedwarn_init (OPT_pedantic, "initialization of a flexible array member");
|
||||
|
||||
/* We have already issued an error message for the existence
|
||||
of a flexible array member not at the end of the structure.
|
||||
@ -6278,7 +6282,7 @@ output_init_element (tree value, bool strict_string, tree type, tree field,
|
||||
value = error_mark_node;
|
||||
}
|
||||
else if (require_constant_elements)
|
||||
pedwarn ("initializer element is not computable at load time");
|
||||
pedwarn (0, "initializer element is not computable at load time");
|
||||
}
|
||||
|
||||
/* If this field is empty (and not at the end of structure),
|
||||
@ -6605,7 +6609,7 @@ process_init_element (struct c_expr value)
|
||||
|
||||
if (constructor_fields == 0)
|
||||
{
|
||||
pedwarn_init ("excess elements in struct initializer");
|
||||
pedwarn_init (0, "excess elements in struct initializer");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -6688,7 +6692,7 @@ process_init_element (struct c_expr value)
|
||||
|
||||
if (constructor_fields == 0)
|
||||
{
|
||||
pedwarn_init ("excess elements in union initializer");
|
||||
pedwarn_init (0, "excess elements in union initializer");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -6775,7 +6779,7 @@ process_init_element (struct c_expr value)
|
||||
&& (tree_int_cst_lt (constructor_max_index, constructor_index)
|
||||
|| integer_all_onesp (constructor_max_index)))
|
||||
{
|
||||
pedwarn_init ("excess elements in array initializer");
|
||||
pedwarn_init (0, "excess elements in array initializer");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -6805,7 +6809,7 @@ process_init_element (struct c_expr value)
|
||||
always have a fixed size derived from their type. */
|
||||
if (tree_int_cst_lt (constructor_max_index, constructor_index))
|
||||
{
|
||||
pedwarn_init ("excess elements in vector initializer");
|
||||
pedwarn_init (0, "excess elements in vector initializer");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -6829,7 +6833,7 @@ process_init_element (struct c_expr value)
|
||||
else if (constructor_type != error_mark_node
|
||||
&& constructor_fields == 0)
|
||||
{
|
||||
pedwarn_init ("excess elements in scalar initializer");
|
||||
pedwarn_init (0, "excess elements in scalar initializer");
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -7060,8 +7064,7 @@ c_finish_goto_label (tree label)
|
||||
tree
|
||||
c_finish_goto_ptr (tree expr)
|
||||
{
|
||||
if (pedantic)
|
||||
pedwarn ("ISO C forbids %<goto *expr;%>");
|
||||
pedwarn (OPT_pedantic, "ISO C forbids %<goto *expr;%>");
|
||||
expr = convert (ptr_type_node, expr);
|
||||
return add_stmt (build1 (GOTO_EXPR, void_type_node, expr));
|
||||
}
|
||||
@ -7084,7 +7087,8 @@ c_finish_return (tree retval)
|
||||
if ((warn_return_type || flag_isoc99)
|
||||
&& valtype != 0 && TREE_CODE (valtype) != VOID_TYPE)
|
||||
{
|
||||
pedwarn_c99 ("%<return%> with no value, in "
|
||||
pedwarn_c99 (flag_isoc99 ? 0 : OPT_Wreturn_type,
|
||||
"%<return%> with no value, in "
|
||||
"function returning non-void");
|
||||
no_warning = true;
|
||||
}
|
||||
@ -7093,9 +7097,10 @@ c_finish_return (tree retval)
|
||||
{
|
||||
current_function_returns_null = 1;
|
||||
if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
|
||||
pedwarn ("%<return%> with a value, in function returning void");
|
||||
else if (pedantic)
|
||||
pedwarn ("ISO C forbids %<return%> with expression, in function returning void");
|
||||
pedwarn (0, "%<return%> with a value, in function returning void");
|
||||
else
|
||||
pedwarn (OPT_pedantic, "ISO C forbids "
|
||||
"%<return%> with expression, in function returning void");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -8165,20 +8170,20 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
|
||||
whose value is 0 but which isn't a valid null ptr const. */
|
||||
if (pedantic && !null_pointer_constant_p (orig_op0)
|
||||
&& TREE_CODE (tt1) == FUNCTION_TYPE)
|
||||
pedwarn ("ISO C forbids comparison of %<void *%>"
|
||||
" with function pointer");
|
||||
pedwarn (OPT_pedantic, "ISO C forbids "
|
||||
"comparison of %<void *%> with function pointer");
|
||||
}
|
||||
else if (VOID_TYPE_P (tt1))
|
||||
{
|
||||
if (pedantic && !null_pointer_constant_p (orig_op1)
|
||||
&& TREE_CODE (tt0) == FUNCTION_TYPE)
|
||||
pedwarn ("ISO C forbids comparison of %<void *%>"
|
||||
" with function pointer");
|
||||
pedwarn (OPT_pedantic, "ISO C forbids "
|
||||
"comparison of %<void *%> with function pointer");
|
||||
}
|
||||
else
|
||||
/* Avoid warning about the volatile ObjC EH puts on decls. */
|
||||
if (!objc_ok)
|
||||
pedwarn ("comparison of distinct pointer types lacks a cast");
|
||||
pedwarn (0, "comparison of distinct pointer types lacks a cast");
|
||||
|
||||
if (result_type == NULL_TREE)
|
||||
result_type = ptr_type_node;
|
||||
@ -8202,12 +8207,12 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
|
||||
else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
|
||||
{
|
||||
result_type = type0;
|
||||
pedwarn ("comparison between pointer and integer");
|
||||
pedwarn (0, "comparison between pointer and integer");
|
||||
}
|
||||
else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
|
||||
{
|
||||
result_type = type1;
|
||||
pedwarn ("comparison between pointer and integer");
|
||||
pedwarn (0, "comparison between pointer and integer");
|
||||
}
|
||||
break;
|
||||
|
||||
@ -8228,38 +8233,42 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
|
||||
result_type = common_pointer_type (type0, type1);
|
||||
if (!COMPLETE_TYPE_P (TREE_TYPE (type0))
|
||||
!= !COMPLETE_TYPE_P (TREE_TYPE (type1)))
|
||||
pedwarn ("comparison of complete and incomplete pointers");
|
||||
else if (pedantic
|
||||
&& TREE_CODE (TREE_TYPE (type0)) == FUNCTION_TYPE)
|
||||
pedwarn ("ISO C forbids ordered comparisons of pointers to functions");
|
||||
pedwarn (0, "comparison of complete and incomplete pointers");
|
||||
else if (TREE_CODE (TREE_TYPE (type0)) == FUNCTION_TYPE)
|
||||
pedwarn (OPT_pedantic, "ISO C forbids "
|
||||
"ordered comparisons of pointers to functions");
|
||||
}
|
||||
else
|
||||
{
|
||||
result_type = ptr_type_node;
|
||||
pedwarn ("comparison of distinct pointer types lacks a cast");
|
||||
pedwarn (0, "comparison of distinct pointer types lacks a cast");
|
||||
}
|
||||
}
|
||||
else if (code0 == POINTER_TYPE && null_pointer_constant_p (orig_op1))
|
||||
{
|
||||
result_type = type0;
|
||||
if (pedantic || extra_warnings)
|
||||
pedwarn ("ordered comparison of pointer with integer zero");
|
||||
if (pedantic)
|
||||
pedwarn (OPT_pedantic,
|
||||
"ordered comparison of pointer with integer zero");
|
||||
else if (extra_warnings)
|
||||
warning (OPT_Wextra,
|
||||
"ordered comparison of pointer with integer zero");
|
||||
}
|
||||
else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0))
|
||||
{
|
||||
result_type = type1;
|
||||
if (pedantic)
|
||||
pedwarn ("ordered comparison of pointer with integer zero");
|
||||
pedwarn (OPT_pedantic,
|
||||
"ordered comparison of pointer with integer zero");
|
||||
}
|
||||
else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
|
||||
{
|
||||
result_type = type0;
|
||||
pedwarn ("comparison between pointer and integer");
|
||||
pedwarn (0, "comparison between pointer and integer");
|
||||
}
|
||||
else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
|
||||
{
|
||||
result_type = type1;
|
||||
pedwarn ("comparison between pointer and integer");
|
||||
pedwarn (0, "comparison between pointer and integer");
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1,3 +1,15 @@
|
||||
2008-07-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
|
||||
|
||||
PR 35058
|
||||
* typeck.c: All calls to pedwarn changed.
|
||||
* decl.c: All calls to pedwarn changed.
|
||||
* call.c: All calls to pedwarn changed.
|
||||
* error.c: All calls to pedwarn changed.
|
||||
* typeck2.c: All calls to pedwarn changed.
|
||||
* pt.c: All calls to pedwarn changed.
|
||||
* name-lookup.c: All calls to pedwarn changed.
|
||||
* parser.c: All calls to pedwarn changed.
|
||||
|
||||
2008-07-21 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
|
||||
|
||||
* call.c: Fix comment typos.
|
||||
|
@ -3404,8 +3404,9 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3,
|
||||
calculated only once. */
|
||||
if (!arg2)
|
||||
{
|
||||
if (pedantic && (complain & tf_error))
|
||||
pedwarn ("ISO C++ forbids omitting the middle term of a ?: expression");
|
||||
if (complain & tf_error)
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C++ forbids omitting the middle term of a ?: expression");
|
||||
|
||||
/* Make sure that lvalues remain lvalues. See g++.oliva/ext1.C. */
|
||||
if (real_lvalue_p (arg1))
|
||||
@ -6760,7 +6761,7 @@ tweak:
|
||||
{
|
||||
if (warn)
|
||||
{
|
||||
warning (0,
|
||||
pedwarn (0,
|
||||
"ISO C++ says that these are ambiguous, even "
|
||||
"though the worst conversion for the first is better than "
|
||||
"the worst conversion for the second:");
|
||||
|
@ -3813,9 +3813,8 @@ check_tag_decl (cp_decl_specifier_seq *declspecs)
|
||||
/* Anonymous unions are objects, so they can have specifiers. */;
|
||||
SET_ANON_AGGR_TYPE_P (declared_type);
|
||||
|
||||
if (TREE_CODE (declared_type) != UNION_TYPE && pedantic
|
||||
&& !in_system_header)
|
||||
pedwarn ("ISO C++ prohibits anonymous structs");
|
||||
if (TREE_CODE (declared_type) != UNION_TYPE && !in_system_header)
|
||||
pedwarn (OPT_pedantic, "ISO C++ prohibits anonymous structs");
|
||||
}
|
||||
|
||||
else
|
||||
@ -7004,8 +7003,8 @@ check_static_variable_definition (tree decl, tree type)
|
||||
error ("ISO C++ forbids in-class initialization of non-const "
|
||||
"static member %qD",
|
||||
decl);
|
||||
else if (pedantic && !INTEGRAL_TYPE_P (type))
|
||||
pedwarn ("ISO C++ forbids initialization of member constant "
|
||||
else if (!INTEGRAL_TYPE_P (type))
|
||||
pedwarn (OPT_pedantic, "ISO C++ forbids initialization of member constant "
|
||||
"%qD of non-integral type %qT", decl, type);
|
||||
|
||||
return 0;
|
||||
@ -7082,12 +7081,12 @@ compute_array_index_type (tree name, tree size)
|
||||
}
|
||||
/* As an extension we allow zero-sized arrays. We always allow
|
||||
them in system headers because glibc uses them. */
|
||||
else if (integer_zerop (size) && pedantic && !in_system_header)
|
||||
else if (integer_zerop (size) && !in_system_header)
|
||||
{
|
||||
if (name)
|
||||
pedwarn ("ISO C++ forbids zero-size array %qD", name);
|
||||
pedwarn (OPT_pedantic, "ISO C++ forbids zero-size array %qD", name);
|
||||
else
|
||||
pedwarn ("ISO C++ forbids zero-size array");
|
||||
pedwarn (OPT_pedantic, "ISO C++ forbids zero-size array");
|
||||
}
|
||||
}
|
||||
else if (TREE_CONSTANT (size))
|
||||
@ -7103,9 +7102,9 @@ compute_array_index_type (tree name, tree size)
|
||||
else if (pedantic && warn_vla != 0)
|
||||
{
|
||||
if (name)
|
||||
pedwarn ("ISO C++ forbids variable length array %qD", name);
|
||||
pedwarn (OPT_Wvla, "ISO C++ forbids variable length array %qD", name);
|
||||
else
|
||||
pedwarn ("ISO C++ forbids variable length array");
|
||||
pedwarn (OPT_Wvla, "ISO C++ forbids variable length array");
|
||||
}
|
||||
else if (warn_vla > 0)
|
||||
{
|
||||
@ -7736,7 +7735,8 @@ grokdeclarator (const cp_declarator *declarator,
|
||||
else if (! is_main)
|
||||
permerror ("ISO C++ forbids declaration of %qs with no type", name);
|
||||
else if (pedantic)
|
||||
pedwarn ("ISO C++ forbids declaration of %qs with no type", name);
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C++ forbids declaration of %qs with no type", name);
|
||||
else
|
||||
warning (OPT_Wreturn_type,
|
||||
"ISO C++ forbids declaration of %qs with no type", name);
|
||||
@ -7791,7 +7791,8 @@ grokdeclarator (const cp_declarator *declarator,
|
||||
ok = 1;
|
||||
if (!explicit_int && !defaulted_int && !explicit_char && pedantic)
|
||||
{
|
||||
pedwarn ("long, short, signed or unsigned used invalidly for %qs",
|
||||
pedwarn (OPT_pedantic,
|
||||
"long, short, signed or unsigned used invalidly for %qs",
|
||||
name);
|
||||
if (flag_pedantic_errors)
|
||||
ok = 0;
|
||||
@ -7896,7 +7897,8 @@ grokdeclarator (const cp_declarator *declarator,
|
||||
if (pedantic)
|
||||
{
|
||||
tree bad_type = build_qualified_type (type, type_quals);
|
||||
pedwarn ("ignoring %qV qualifiers added to function type %qT",
|
||||
pedwarn (OPT_pedantic,
|
||||
"ignoring %qV qualifiers added to function type %qT",
|
||||
bad_type, type);
|
||||
}
|
||||
type_quals = TYPE_UNQUALIFIED;
|
||||
@ -9124,10 +9126,12 @@ grokdeclarator (const cp_declarator *declarator,
|
||||
&& pedantic)
|
||||
{
|
||||
if (storage_class == sc_static)
|
||||
pedwarn ("%<static%> specified invalid for function %qs "
|
||||
pedwarn (OPT_pedantic,
|
||||
"%<static%> specified invalid for function %qs "
|
||||
"declared out of global scope", name);
|
||||
else
|
||||
pedwarn ("%<inline%> specifier invalid for function %qs "
|
||||
pedwarn (OPT_pedantic,
|
||||
"%<inline%> specifier invalid for function %qs "
|
||||
"declared out of global scope", name);
|
||||
}
|
||||
|
||||
@ -9215,9 +9219,9 @@ grokdeclarator (const cp_declarator *declarator,
|
||||
}
|
||||
if (storage_class == sc_extern && pedantic)
|
||||
{
|
||||
pedwarn ("cannot explicitly declare member %q#D to have "
|
||||
"extern linkage",
|
||||
decl);
|
||||
pedwarn (OPT_pedantic,
|
||||
"cannot explicitly declare member %q#D to have "
|
||||
"extern linkage", decl);
|
||||
storage_class = sc_none;
|
||||
}
|
||||
}
|
||||
@ -10104,8 +10108,8 @@ grok_op_properties (tree decl, bool complain)
|
||||
if (operator_code == POSTINCREMENT_EXPR
|
||||
|| operator_code == POSTDECREMENT_EXPR)
|
||||
{
|
||||
if (pedantic)
|
||||
pedwarn ("%qD cannot have default arguments", decl);
|
||||
pedwarn (OPT_pedantic, "%qD cannot have default arguments",
|
||||
decl);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2685,7 +2685,7 @@ maybe_warn_cpp0x (const char* str)
|
||||
/* We really want to suppress this warning in system headers,
|
||||
because libstdc++ uses variadic templates even when we aren't
|
||||
in C++0x mode. */
|
||||
pedwarn ("%s only available with -std=c++0x", str);
|
||||
pedwarn (0, "%s only available with -std=c++0x", str);
|
||||
}
|
||||
|
||||
/* Warn about the use of variadic templates when appropriate. */
|
||||
|
@ -724,10 +724,10 @@ pushdecl_maybe_friend (tree x, bool is_friend)
|
||||
/* Don't do anything just yet. */;
|
||||
else if (t == wchar_decl_node)
|
||||
{
|
||||
if (pedantic && ! DECL_IN_SYSTEM_HEADER (x))
|
||||
pedwarn ("redeclaration of %<wchar_t%> as %qT",
|
||||
if (! DECL_IN_SYSTEM_HEADER (x))
|
||||
pedwarn (OPT_pedantic, "redeclaration of %<wchar_t%> as %qT",
|
||||
TREE_TYPE (x));
|
||||
|
||||
|
||||
/* Throw away the redeclaration. */
|
||||
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
|
||||
}
|
||||
@ -796,10 +796,11 @@ pushdecl_maybe_friend (tree x, bool is_friend)
|
||||
x_exception_spec,
|
||||
true))
|
||||
{
|
||||
pedwarn ("declaration of %q#D with C language linkage", x);
|
||||
pedwarn ("conflicts with previous declaration %q+#D",
|
||||
previous);
|
||||
pedwarn ("due to different exception specifications");
|
||||
pedwarn (0, "declaration of %q#D with C language linkage",
|
||||
x);
|
||||
pedwarn (0, "conflicts with previous declaration %q+#D",
|
||||
previous);
|
||||
pedwarn (0, "due to different exception specifications");
|
||||
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
|
||||
}
|
||||
}
|
||||
|
@ -2162,7 +2162,8 @@ cp_parser_check_decl_spec (cp_decl_specifier_seq *decl_specs,
|
||||
error ("%H%<long long long%> is too long for GCC", &location);
|
||||
else if (pedantic && !in_system_header && warn_long_long
|
||||
&& cxx_dialect == cxx98)
|
||||
pedwarn ("%HISO C++ 1998 does not support %<long long%>",
|
||||
pedwarn (OPT_Wlong_long,
|
||||
"%HISO C++ 1998 does not support %<long long%>",
|
||||
&location);
|
||||
}
|
||||
else if (count > 1)
|
||||
@ -3214,9 +3215,9 @@ cp_parser_primary_expression (cp_parser *parser,
|
||||
&& cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
|
||||
{
|
||||
/* Statement-expressions are not allowed by the standard. */
|
||||
if (pedantic)
|
||||
pedwarn ("%HISO C++ forbids braced-groups within expressions",
|
||||
&token->location);
|
||||
pedwarn (OPT_pedantic,
|
||||
"%HISO C++ forbids braced-groups within expressions",
|
||||
&token->location);
|
||||
|
||||
/* And they're not allowed outside of a function-body; you
|
||||
cannot, for example, write:
|
||||
@ -4545,8 +4546,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
|
||||
{
|
||||
/* Warn the user that a compound literal is not
|
||||
allowed in standard C++. */
|
||||
if (pedantic)
|
||||
pedwarn ("ISO C++ forbids compound-literals");
|
||||
pedwarn (OPT_pedantic, "ISO C++ forbids compound-literals");
|
||||
/* For simplicity, we disallow compound literals in
|
||||
constant-expressions. We could
|
||||
allow compound literals of integer type, whose
|
||||
@ -7610,8 +7610,7 @@ cp_parser_jump_statement (cp_parser* parser)
|
||||
if (cp_lexer_next_token_is (parser->lexer, CPP_MULT))
|
||||
{
|
||||
/* Issue a warning about this use of a GNU extension. */
|
||||
if (pedantic)
|
||||
pedwarn ("%HISO C++ forbids computed gotos", &token->location);
|
||||
pedwarn (OPT_pedantic, "%HISO C++ forbids computed gotos", &token->location);
|
||||
/* Consume the '*' token. */
|
||||
cp_lexer_consume_token (parser->lexer);
|
||||
/* Parse the dependent expression. */
|
||||
@ -7750,8 +7749,8 @@ cp_parser_declaration_seq_opt (cp_parser* parser)
|
||||
/* A declaration consisting of a single semicolon is
|
||||
invalid. Allow it unless we're being pedantic. */
|
||||
cp_lexer_consume_token (parser->lexer);
|
||||
if (pedantic && !in_system_header)
|
||||
pedwarn ("extra %<;%>");
|
||||
if (!in_system_header)
|
||||
pedwarn (OPT_pedantic, "extra %<;%>");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -11734,8 +11733,8 @@ cp_parser_enumerator_list (cp_parser* parser, tree type)
|
||||
/* If the next token is a `}', there is a trailing comma. */
|
||||
if (cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_BRACE))
|
||||
{
|
||||
if (pedantic && !in_system_header)
|
||||
pedwarn ("comma at end of enumerator list");
|
||||
if (!in_system_header)
|
||||
pedwarn (OPT_pedantic, "comma at end of enumerator list");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -14369,8 +14368,8 @@ cp_parser_initializer_list (cp_parser* parser, bool* non_constant_p)
|
||||
&& cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_COLON)
|
||||
{
|
||||
/* Warn the user that they are using an extension. */
|
||||
if (pedantic)
|
||||
pedwarn ("ISO C++ does not allow designated initializers");
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C++ does not allow designated initializers");
|
||||
/* Consume the identifier. */
|
||||
identifier = cp_lexer_consume_token (parser->lexer)->u.value;
|
||||
/* Consume the `:'. */
|
||||
@ -15386,8 +15385,8 @@ cp_parser_member_declaration (cp_parser* parser)
|
||||
if (!decl_specifiers.any_specifiers_p)
|
||||
{
|
||||
cp_token *token = cp_lexer_peek_token (parser->lexer);
|
||||
if (pedantic && !in_system_header_at (token->location))
|
||||
pedwarn ("%Hextra %<;%>", &token->location);
|
||||
if (!in_system_header_at (token->location))
|
||||
pedwarn (OPT_pedantic, "%Hextra %<;%>", &token->location);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
12
gcc/cp/pt.c
12
gcc/cp/pt.c
@ -14610,8 +14610,9 @@ do_decl_instantiation (tree decl, tree storage)
|
||||
;
|
||||
else if (storage == ridpointers[(int) RID_EXTERN])
|
||||
{
|
||||
if (pedantic && !in_system_header && (cxx_dialect == cxx98))
|
||||
pedwarn ("ISO C++ 1998 forbids the use of %<extern%> on explicit "
|
||||
if (!in_system_header && (cxx_dialect == cxx98))
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C++ 1998 forbids the use of %<extern%> on explicit "
|
||||
"instantiations");
|
||||
extern_p = 1;
|
||||
}
|
||||
@ -14697,16 +14698,17 @@ do_type_instantiation (tree t, tree storage, tsubst_flags_t complain)
|
||||
|
||||
if (storage != NULL_TREE)
|
||||
{
|
||||
if (pedantic && !in_system_header)
|
||||
if (!in_system_header)
|
||||
{
|
||||
if (storage == ridpointers[(int) RID_EXTERN])
|
||||
{
|
||||
if (cxx_dialect == cxx98)
|
||||
pedwarn("ISO C++ 1998 forbids the use of %<extern%> on "
|
||||
pedwarn(OPT_pedantic,
|
||||
"ISO C++ 1998 forbids the use of %<extern%> on "
|
||||
"explicit instantiations");
|
||||
}
|
||||
else
|
||||
pedwarn("ISO C++ forbids the use of %qE on explicit "
|
||||
pedwarn(OPT_pedantic, "ISO C++ forbids the use of %qE on explicit "
|
||||
"instantiations", storage);
|
||||
}
|
||||
|
||||
|
@ -511,9 +511,10 @@ composite_pointer_type (tree t1, tree t2, tree arg1, tree arg2,
|
||||
tree attributes;
|
||||
tree result_type;
|
||||
|
||||
if (pedantic && TYPE_PTRFN_P (t2) && (complain & tf_error))
|
||||
pedwarn ("ISO C++ forbids %s between pointer of type %<void *%> "
|
||||
"and pointer-to-function", location);
|
||||
if (TYPE_PTRFN_P (t2) && (complain & tf_error))
|
||||
pedwarn (OPT_pedantic, "ISO C++ forbids %s "
|
||||
"between pointer of type %<void *%> and pointer-to-function",
|
||||
location);
|
||||
result_type
|
||||
= cp_build_qualified_type (void_type_node,
|
||||
(cp_type_quals (TREE_TYPE (t1))
|
||||
@ -1278,8 +1279,9 @@ cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool complain)
|
||||
type = non_reference (type);
|
||||
if (TREE_CODE (type) == METHOD_TYPE)
|
||||
{
|
||||
if (complain && (pedantic || warn_pointer_arith))
|
||||
pedwarn ("invalid application of %qs to a member function",
|
||||
if (complain)
|
||||
pedwarn (pedantic ? OPT_pedantic : OPT_Wpointer_arith,
|
||||
"invalid application of %qs to a member function",
|
||||
operator_name_info[(int) op].name);
|
||||
value = size_one_node;
|
||||
}
|
||||
@ -2596,8 +2598,8 @@ build_array_ref (tree array, tree idx)
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
if (pedantic && !lvalue_p (array))
|
||||
pedwarn ("ISO C++ forbids subscripting non-lvalue array");
|
||||
if (!lvalue_p (array))
|
||||
pedwarn (OPT_pedantic, "ISO C++ forbids subscripting non-lvalue array");
|
||||
|
||||
/* Note in C++ it is valid to subscript a `register' array, since
|
||||
it is valid to take the address of something with that
|
||||
@ -2822,8 +2824,9 @@ cp_build_function_call (tree function, tree params, tsubst_flags_t complain)
|
||||
fndecl = function;
|
||||
|
||||
/* Convert anything with function type to a pointer-to-function. */
|
||||
if (pedantic && DECL_MAIN_P (function) && (complain & tf_error))
|
||||
pedwarn ("ISO C++ forbids calling %<::main%> from within program");
|
||||
if (DECL_MAIN_P (function) && (complain & tf_error))
|
||||
pedwarn (OPT_pedantic,
|
||||
"ISO C++ forbids calling %<::main%> from within program");
|
||||
|
||||
/* Differs from default_conversion by not setting TREE_ADDRESSABLE
|
||||
(because calling an inline function does not mean the function
|
||||
@ -4101,15 +4104,12 @@ pointer_diff (tree op0, tree op1, tree ptrtype)
|
||||
if (!complete_type_or_else (target_type, NULL_TREE))
|
||||
return error_mark_node;
|
||||
|
||||
if (pedantic || warn_pointer_arith)
|
||||
{
|
||||
if (TREE_CODE (target_type) == VOID_TYPE)
|
||||
permerror ("ISO C++ forbids using pointer of type %<void *%> in subtraction");
|
||||
if (TREE_CODE (target_type) == FUNCTION_TYPE)
|
||||
permerror ("ISO C++ forbids using pointer to a function in subtraction");
|
||||
if (TREE_CODE (target_type) == METHOD_TYPE)
|
||||
permerror ("ISO C++ forbids using pointer to a method in subtraction");
|
||||
}
|
||||
if (TREE_CODE (target_type) == VOID_TYPE)
|
||||
permerror ("ISO C++ forbids using pointer of type %<void *%> in subtraction");
|
||||
if (TREE_CODE (target_type) == FUNCTION_TYPE)
|
||||
permerror ("ISO C++ forbids using pointer to a function in subtraction");
|
||||
if (TREE_CODE (target_type) == METHOD_TYPE)
|
||||
permerror ("ISO C++ forbids using pointer to a method in subtraction");
|
||||
|
||||
/* First do the subtraction as integers;
|
||||
then drop through to build the divide operator. */
|
||||
@ -4559,7 +4559,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert,
|
||||
arg = build1 (CONVERT_EXPR, type, arg);
|
||||
return arg;
|
||||
}
|
||||
else if (pedantic && DECL_MAIN_P (arg))
|
||||
else if (DECL_MAIN_P (arg))
|
||||
{
|
||||
/* ARM $3.4 */
|
||||
if (complain & tf_error)
|
||||
@ -4655,7 +4655,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert,
|
||||
/* Even if we're not being pedantic, we cannot allow this
|
||||
extension when we're instantiating in a SFINAE
|
||||
context. */
|
||||
if (! lvalue_p (arg) && (pedantic || complain == tf_none))
|
||||
if (! lvalue_p (arg) && complain == tf_none)
|
||||
{
|
||||
if (complain & tf_error)
|
||||
permerror ("ISO C++ forbids taking the address of a cast to a non-lvalue expression");
|
||||
@ -5443,7 +5443,8 @@ convert_member_func_to_ptr (tree type, tree expr)
|
||||
|| TREE_CODE (intype) == METHOD_TYPE);
|
||||
|
||||
if (pedantic || warn_pmf2ptr)
|
||||
pedwarn ("converting from %qT to %qT", intype, type);
|
||||
pedwarn (pedantic ? OPT_pedantic : OPT_Wpmf_conversions,
|
||||
"converting from %qT to %qT", intype, type);
|
||||
|
||||
if (TREE_CODE (intype) == METHOD_TYPE)
|
||||
expr = build_addr_func (expr);
|
||||
@ -6980,7 +6981,6 @@ check_return_expr (tree retval, bool *no_warning)
|
||||
else
|
||||
permerror ("return-statement with a value, in function "
|
||||
"returning 'void'");
|
||||
|
||||
current_function_returns_null = 1;
|
||||
|
||||
/* There's really no value to return, after all. */
|
||||
@ -7347,7 +7347,8 @@ cp_apply_type_quals_to_decl (int type_quals, tree decl)
|
||||
if (pedantic)
|
||||
{
|
||||
tree bad_type = build_qualified_type (type, type_quals);
|
||||
pedwarn ("ignoring %qV qualifiers added to function type %qT",
|
||||
pedwarn (OPT_pedantic,
|
||||
"ignoring %qV qualifiers added to function type %qT",
|
||||
bad_type, type);
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type, int diag_type
|
||||
if (diag_type == 1)
|
||||
p_msg = warning0;
|
||||
else if (diag_type == 2)
|
||||
p_msg = pedwarn;
|
||||
p_msg = pedwarn0;
|
||||
else
|
||||
p_msg = error;
|
||||
|
||||
|
@ -522,16 +522,34 @@ warning_at (location_t location, int opt, const char *gmsgid, ...)
|
||||
|
||||
Note that these diagnostics are issued independent of the setting
|
||||
of the -pedantic command-line switch. To get a warning enabled
|
||||
only with that switch, write "if (pedantic) pedwarn (...);" */
|
||||
only with that switch, use either "if (pedantic) pedwarn
|
||||
(OPT_pedantic,...)" or just "pedwarn (OPT_pedantic,..)". To get a
|
||||
pedwarn independently of the -pedantic switch use "pedwarn (0,...)". */
|
||||
|
||||
void
|
||||
pedwarn (const char *gmsgid, ...)
|
||||
pedwarn (int opt, const char *gmsgid, ...)
|
||||
{
|
||||
diagnostic_info diagnostic;
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, gmsgid);
|
||||
diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
|
||||
pedantic_warning_kind ());
|
||||
pedantic_warning_kind ());
|
||||
diagnostic.option_index = opt;
|
||||
|
||||
report_diagnostic (&diagnostic);
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
void
|
||||
pedwarn0 (const char *gmsgid, ...)
|
||||
{
|
||||
diagnostic_info diagnostic;
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, gmsgid);
|
||||
diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
|
||||
pedantic_warning_kind ());
|
||||
report_diagnostic (&diagnostic);
|
||||
va_end (ap);
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
2008-07-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
|
||||
|
||||
PR 35058
|
||||
* f95-lang.c (gfc_mark_addressable): All calls to pedwarn changed.
|
||||
|
||||
2008-07-22 Daniel Kraft <d@domob.eu>
|
||||
|
||||
PR fortran/29835
|
||||
|
@ -604,8 +604,8 @@ gfc_mark_addressable (tree exp)
|
||||
IDENTIFIER_POINTER (DECL_NAME (x)));
|
||||
return false;
|
||||
}
|
||||
pedwarn ("register variable %qs used in nested function",
|
||||
IDENTIFIER_POINTER (DECL_NAME (x)));
|
||||
pedwarn0 ("register variable %qs used in nested function",
|
||||
IDENTIFIER_POINTER (DECL_NAME (x)));
|
||||
}
|
||||
else if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x))
|
||||
{
|
||||
@ -629,7 +629,7 @@ gfc_mark_addressable (tree exp)
|
||||
}
|
||||
#endif
|
||||
|
||||
pedwarn ("address of register variable %qs requested",
|
||||
pedwarn0 ("address of register variable %qs requested",
|
||||
IDENTIFIER_POINTER (DECL_NAME (x)));
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
2008-07-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
|
||||
|
||||
PR 35058
|
||||
* gcc.dg/Wdeclaration-after-statement-3.c: New.
|
||||
* gcc/testsuite/gcc.dg/Wpointer-arith.c: New.
|
||||
|
||||
2008-07-22 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
||||
|
||||
PR libfortran/36852
|
||||
|
24
gcc/testsuite/gcc.dg/Wdeclaration-after-statement-3.c
Normal file
24
gcc/testsuite/gcc.dg/Wdeclaration-after-statement-3.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* PR 35058: -Werror= works only with some warnings. */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=c99 -pedantic -Werror=declaration-after-statement" } */
|
||||
|
||||
extern void abort (void);
|
||||
extern void exit (int);
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int i = 0;
|
||||
if (i != 0)
|
||||
abort ();
|
||||
i++;
|
||||
if (i != 1)
|
||||
abort ();
|
||||
int j = i; /* { dg-error "" "declaration-after-statement" } */
|
||||
if (j != 1)
|
||||
abort ();
|
||||
struct foo { int i0; } k = { 4 }; /* { dg-error "" "declaration-after-statement" } */
|
||||
if (k.i0 != 4)
|
||||
abort ();
|
||||
exit (0);
|
||||
}
|
10
gcc/testsuite/gcc.dg/Wpointer-arith.c
Normal file
10
gcc/testsuite/gcc.dg/Wpointer-arith.c
Normal file
@ -0,0 +1,10 @@
|
||||
/* PR 35058: -Werror= works only with some warnings. */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-Werror=pointer-arith" } */
|
||||
void *a;
|
||||
|
||||
void *test(){
|
||||
int x=5;
|
||||
if(a) a++; /* { dg-error "wrong type argument to increment" } */
|
||||
return a+x; /* { dg-error "pointer of type" } */
|
||||
}
|
@ -825,7 +825,7 @@ check_global_declaration_1 (tree decl)
|
||||
|| TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
|
||||
{
|
||||
if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
|
||||
pedwarn ("%q+F used but never defined", decl);
|
||||
pedwarn (0, "%q+F used but never defined", decl);
|
||||
else
|
||||
warning (OPT_Wunused_function, "%q+F declared %<static%> but never defined", decl);
|
||||
/* This symbol is effectively an "extern" declaration now. */
|
||||
|
@ -64,7 +64,9 @@ extern void warning_at (location_t, int, const char *, ...)
|
||||
extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
|
||||
extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
|
||||
ATTRIBUTE_NORETURN;
|
||||
extern void pedwarn (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
|
||||
extern void pedwarn0 (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
|
||||
/* Pass one of the OPT_W* from options.h as the first parameter. */
|
||||
extern void pedwarn (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
|
||||
extern void permerror (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
|
||||
extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
|
||||
extern void inform (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user