re PR c/25892 (-Wpointer-sign creates problems for Emacs)
authorAlexandre Oliva <aoliva@redhat.com>
Thu, 26 Jan 2006 18:50:37 +0000 (18:50 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Thu, 26 Jan 2006 18:50:37 +0000 (18:50 +0000)
gcc/ChangeLog:
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.
gcc/testsuite/ChangeLog:
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.

From-SVN: r110265

gcc/ChangeLog
gcc/c-opts.c
gcc/c.opt
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wpointer-sign-Wall-no.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wpointer-sign-Wall.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wpointer-sign-pedantic-no.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wpointer-sign-pedantic.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wpointer-sign.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/conv-2.c

index de6584822a4f562a63dbce7e00da90c262f5e698..e4902859f3b6e73f32fd63fd3499b5a4ec889e90 100644 (file)
@@ -1,3 +1,11 @@
+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
index 5bc5f5de9eae2927714672061ea2372503299a5d..d2df8605ae2422ae76d823579aecaa7135a98142 100644 (file)
@@ -417,6 +417,9 @@ c_common_handle_option (size_t scode, const char *arg, int value)
       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:
@@ -888,6 +891,8 @@ c_common_handle_option (size_t scode, const char *arg, int value)
     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:
@@ -1008,6 +1013,11 @@ c_common_post_options (const char **pfilename)
   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)
index a37f4982b73edaba6623e867ea0c91ee8e7420ba..44a47ed7cbeb07ad1d824807c117d6eb708e8139 100644 (file)
--- a/gcc/c.opt
+++ b/gcc/c.opt
@@ -420,7 +420,7 @@ C ObjC C++ ObjC++
 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
index 1a21c00105b553e62379fdc70869805e4a604548..8c48d425560fd70f9cb516b3a0fe0e17d86b6c97 100644 (file)
@@ -256,7 +256,7 @@ Objective-C and Objective-C++ Dialects}.
 @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}.
@@ -3402,11 +3402,13 @@ effectively.  Often, the problem is that your code is too big or too
 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
index 0042b363dda433726538b8923575b968f5413ae5..7b2477a1216bf63044e7f0ae71fff60bb19099d6 100644 (file)
@@ -1,3 +1,13 @@
+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
diff --git a/gcc/testsuite/gcc.dg/Wpointer-sign-Wall-no.c b/gcc/testsuite/gcc.dg/Wpointer-sign-Wall-no.c
new file mode 100644 (file)
index 0000000..23df207
--- /dev/null
@@ -0,0 +1,9 @@
+/* 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);
+}
diff --git a/gcc/testsuite/gcc.dg/Wpointer-sign-Wall.c b/gcc/testsuite/gcc.dg/Wpointer-sign-Wall.c
new file mode 100644 (file)
index 0000000..e72d37a
--- /dev/null
@@ -0,0 +1,9 @@
+/* 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" } */
+}
diff --git a/gcc/testsuite/gcc.dg/Wpointer-sign-pedantic-no.c b/gcc/testsuite/gcc.dg/Wpointer-sign-pedantic-no.c
new file mode 100644 (file)
index 0000000..d4f597f
--- /dev/null
@@ -0,0 +1,9 @@
+/* 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);
+}
diff --git a/gcc/testsuite/gcc.dg/Wpointer-sign-pedantic.c b/gcc/testsuite/gcc.dg/Wpointer-sign-pedantic.c
new file mode 100644 (file)
index 0000000..25e2520
--- /dev/null
@@ -0,0 +1,9 @@
+/* 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" } */
+}
diff --git a/gcc/testsuite/gcc.dg/Wpointer-sign.c b/gcc/testsuite/gcc.dg/Wpointer-sign.c
new file mode 100644 (file)
index 0000000..74cdbe4
--- /dev/null
@@ -0,0 +1,13 @@
+/* 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);
+}
index 349c8acceedcb42f2b1434e2605a6857bd0093b2..ac95584e3a6a09ce6426406fa86ae84542258a9f 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "" } */
+/* { dg-options "-Wpointer-sign" } */
 
 void f1(long *);
 void f2(unsigned long *);