+2006-01-26 Alexandre Oliva <aoliva@redhat.com>
+
+ PR c/25892
+ * c.opt (Wpointer-sign): Init to -1.
+ * c-opts.c (c_common_handle_option): Set to 1 on OPT_Wall and
+ OPT_pedantic, to 0 otherwise.
+ * doc/invoke.texi: Update.
+
2006-01-26 Paolo Bonzini <bonzini@gnu.org>
* config/i386/i386.md (extendsfdf2, extendsfxf2, extenddfxf2): Emit
cpp_opts->warn_comments = value;
cpp_opts->warn_num_sign_change = value;
cpp_opts->warn_multichar = value; /* Was C++ only. */
+
+ if (warn_pointer_sign == -1)
+ warn_pointer_sign = 1;
break;
case OPT_Wcomment:
case OPT_pedantic:
cpp_opts->pedantic = 1;
cpp_opts->warn_endif_labels = 1;
+ if (warn_pointer_sign == -1)
+ warn_pointer_sign = 1;
break;
case OPT_print_objc_runtime_info:
if (warn_missing_field_initializers == -1)
warn_missing_field_initializers = extra_warnings;
+ /* -Wpointer_sign is disabled by default, but it is enabled if any
+ of -Wall or -pedantic are given. */
+ if (warn_pointer_sign == -1)
+ warn_pointer_sign = 0;
+
/* Special format checking options don't work without -Wformat; warn if
they are used. */
if (!warn_format)
Give strings the type \"array of char\"
Wpointer-sign
-C ObjC Var(warn_pointer_sign) Init(1)
+C ObjC Var(warn_pointer_sign) Init(-1)
Warn when a pointer differs in signedness in an assignment
ansi
@gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
-Wmissing-prototypes -Wnested-externs -Wold-style-definition @gol
-Wstrict-prototypes -Wtraditional @gol
--Wdeclaration-after-statement -Wno-pointer-sign}
+-Wdeclaration-after-statement -Wpointer-sign}
@item Debugging Options
@xref{Debugging Options,,Options for Debugging Your Program or GCC}.
complex; GCC will refuse to optimize programs when the optimization
itself is likely to take inordinate amounts of time.
-@item -Wno-pointer-sign
+@item -Wpointer-sign
+@opindex Wpointer-sign
@opindex Wno-pointer-sign
-Don't warn for pointer argument passing or assignment with different signedness.
-Only useful in the negative form since this warning is enabled by default.
-This option is only supported for C and Objective-C@.
+Warn for pointer argument passing or assignment with different signedness.
+This option is only supported for C and Objective-C@. It is implied by
+@option{-Wall} and by @option{-pedantic}, which can be disabled with
+@option{-Wno-pointer-sign}.
@item -Werror
@opindex Werror
+2006-01-26 Alexandre Oliva <aoliva@redhat.com>
+
+ PR c/25892
+ * gcc.dg/Wpointer-sign.c: New.
+ * gcc.dg/Wpointer-sign-Wall.c: New.
+ * gcc.dg/Wpointer-sign-Wall-no.c: New.
+ * gcc.dg/Wpointer-sign-pedantic.c: New.
+ * gcc.dg/Wpointer-sign-pedantic-no.c: New.
+ * gcc.dg/conv-2.c: Use -Wpointer-sign.
+
2006-01-26 Andrew Pinski <pinskia@physics.uc.edu>
PR C/25861
--- /dev/null
+/* This is from PR c/25892. See Wpointer-sign.c for more details. */
+
+/* { dg-options "-Wno-pointer-sign -Wall" } */
+
+void foo(unsigned long* ulp);
+
+void bar(long* lp) {
+ foo(lp);
+}
--- /dev/null
+/* This is from PR c/25892. See Wpointer-sign.c for more details. */
+
+/* { dg-options "-Wall" } */
+
+void foo(unsigned long* ulp);
+
+void bar(long* lp) {
+ foo(lp); /* { dg-warning "differ in signedness" } */
+}
--- /dev/null
+/* This is from PR c/25892. See Wpointer-sign.c for more details. */
+
+/* { dg-options "-Wno-pointer-sign -pedantic" } */
+
+void foo(unsigned long* ulp);
+
+void bar(long* lp) {
+ foo(lp);
+}
--- /dev/null
+/* This is from PR c/25892. See Wpointer-sign.c for more details. */
+
+/* { dg-options "-pedantic" } */
+
+void foo(unsigned long* ulp);
+
+void bar(long* lp) {
+ foo(lp); /* { dg-warning "differ in signedness" } */
+}
--- /dev/null
+/* This is from PR c/25892. The SC promised RMS that -Wpointer-sign
+ would be off by default in GCC 4.1 to avoid inconvenient warnings
+ while compiling GNU Emacs. It should be enabled with -Wall and/or
+ -pedantic, though. Make sure it's off by default in this test (so
+ use dg-options "" to avoid passing -pedantic-errors). */
+
+/* { dg-options "" } */
+
+void foo(unsigned long* ulp);
+
+void bar(long* lp) {
+ foo(lp);
+}
/* { dg-do compile } */
-/* { dg-options "" } */
+/* { dg-options "-Wpointer-sign" } */
void f1(long *);
void f2(unsigned long *);