diff options
author | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-26 18:50:37 +0000 |
---|---|---|
committer | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-26 18:50:37 +0000 |
commit | 06bc8842b3810f96cfde29bf73fe108c735c29d2 (patch) | |
tree | 5f651bd0ed5cebb8605697501f8758fbcf305fb8 /gcc | |
parent | eb6e0f89020fbe1457af2af310cb6dd51f813f22 (diff) | |
download | gcc-06bc8842b3810f96cfde29bf73fe108c735c29d2.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@110265 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/c-opts.c | 10 | ||||
-rw-r--r-- | gcc/c.opt | 2 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wpointer-sign-Wall-no.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wpointer-sign-Wall.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wpointer-sign-pedantic-no.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wpointer-sign-pedantic.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wpointer-sign.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/conv-2.c | 2 |
11 files changed, 86 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index de6584822a4..e4902859f3b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 5bc5f5de9ea..d2df8605ae2 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -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) diff --git a/gcc/c.opt b/gcc/c.opt index a37f4982b73..44a47ed7cbe 100644 --- 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 diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 1a21c00105b..8c48d425560 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0042b363dda..7b2477a1216 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 00000000000..23df20721c8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wpointer-sign-Wall-no.c @@ -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 index 00000000000..e72d37a18ce --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wpointer-sign-Wall.c @@ -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 index 00000000000..d4f597fe79e --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wpointer-sign-pedantic-no.c @@ -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 index 00000000000..25e25209e52 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wpointer-sign-pedantic.c @@ -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 index 00000000000..74cdbe4bc9f --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wpointer-sign.c @@ -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); +} diff --git a/gcc/testsuite/gcc.dg/conv-2.c b/gcc/testsuite/gcc.dg/conv-2.c index 349c8acceed..ac95584e3a6 100644 --- a/gcc/testsuite/gcc.dg/conv-2.c +++ b/gcc/testsuite/gcc.dg/conv-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "" } */ +/* { dg-options "-Wpointer-sign" } */ void f1(long *); void f2(unsigned long *); |