Index: c-decl.c =================================================================== RCS file: /home/ncvs/src/contrib/gcc/c-decl.c,v retrieving revision 1.6 diff -u -r1.6 c-decl.c --- c-decl.c 4 Dec 2002 15:48:26 -0000 1.6 +++ c-decl.c 8 Dec 2002 03:53:16 -0000 @@ -349,6 +349,11 @@ int mesg_implicit_function_declaration = -1; +/* Nonzero means message about casts with integer/pointer size mismatches; + 1 means warning; 2 means error. */ + +int mesg_bad_pointer_cast = 1; + /* Nonzero means give string constants the type `const char *' to get extra warnings from them. These warnings will be too numerous to be useful, except in thoroughly ANSIfied programs. */ @@ -658,6 +663,12 @@ mesg_implicit_function_declaration = 1; else if (!strcmp (p, "-Wno-implicit-function-declaration")) mesg_implicit_function_declaration = 0; + else if (!strcmp (p, "-Werror-bad-pointer-cast")) + mesg_bad_pointer_cast = 2; + else if (!strcmp (p, "-Wbad-pointer-cast")) + mesg_bad_pointer_cast = 1; + else if (!strcmp (p, "-Wno-bad-pointer-cast")) + mesg_bad_pointer_cast = 0; else if (!strcmp (p, "-Wimplicit-int")) warn_implicit_int = 1; else if (!strcmp (p, "-Wno-implicit-int")) Index: c-tree.h =================================================================== RCS file: /home/ncvs/src/contrib/gcc/c-tree.h,v retrieving revision 1.8 diff -u -r1.8 c-tree.h --- c-tree.h 4 Dec 2002 16:31:45 -0000 1.8 +++ c-tree.h 8 Dec 2002 03:51:29 -0000 @@ -371,6 +371,9 @@ /* Warn about implicit declarations. 1 = warning, 2 = error. */ extern int mesg_implicit_function_declaration; +/* Warn about bad pointer casts. 1 = warning, 2 = error. */ +extern int mesg_bad_pointer_cast; + /* In c-decl.c */ extern void finish_incomplete_decl PARAMS ((tree)); Index: c-typeck.c =================================================================== RCS file: /home/ncvs/src/contrib/gcc/c-typeck.c,v retrieving revision 1.1.1.11 diff -u -r1.1.1.11 c-typeck.c --- c-typeck.c 17 Sep 2002 04:02:10 -0000 1.1.1.11 +++ c-typeck.c 8 Dec 2002 04:02:18 -0000 @@ -3767,7 +3767,13 @@ && TREE_CODE (otype) == POINTER_TYPE && TYPE_PRECISION (type) != TYPE_PRECISION (otype) && !TREE_CONSTANT (value)) - warning ("cast from pointer to integer of different size"); + { + if (mesg_bad_pointer_cast == 2) + error ("cast from pointer to integer of different size"); + else if (mesg_bad_pointer_cast == 1) + warning ("cast from pointer to integer of different size"); + } + if (warn_bad_function_cast && TREE_CODE (value) == CALL_EXPR @@ -3779,7 +3785,12 @@ && TYPE_PRECISION (type) != TYPE_PRECISION (otype) /* Don't warn about converting any constant. */ && !TREE_CONSTANT (value)) - warning ("cast to pointer from integer of different size"); + { + if (mesg_bad_pointer_cast == 2) + error ("cast to pointer from integer of different size"); + else if (mesg_bad_pointer_cast == 1) + warning ("cast to pointer from integer of different size"); + } ovalue = value; value = convert (type, value);