Commit f4e9414e by Alexandre Oliva Committed by Alexandre Oliva

re PR c/25892 (-Wpointer-sign creates problems for Emacs)

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
parent e046a30a
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> 2006-01-26 Paolo Bonzini <bonzini@gnu.org>
* config/i386/i386.md (extendsfdf2, extendsfxf2, extenddfxf2): Emit * config/i386/i386.md (extendsfdf2, extendsfxf2, extenddfxf2): Emit
......
...@@ -417,6 +417,9 @@ c_common_handle_option (size_t scode, const char *arg, int value) ...@@ -417,6 +417,9 @@ c_common_handle_option (size_t scode, const char *arg, int value)
cpp_opts->warn_comments = value; cpp_opts->warn_comments = value;
cpp_opts->warn_num_sign_change = value; cpp_opts->warn_num_sign_change = value;
cpp_opts->warn_multichar = value; /* Was C++ only. */ cpp_opts->warn_multichar = value; /* Was C++ only. */
if (warn_pointer_sign == -1)
warn_pointer_sign = 1;
break; break;
case OPT_Wcomment: case OPT_Wcomment:
...@@ -888,6 +891,8 @@ c_common_handle_option (size_t scode, const char *arg, int value) ...@@ -888,6 +891,8 @@ c_common_handle_option (size_t scode, const char *arg, int value)
case OPT_pedantic: case OPT_pedantic:
cpp_opts->pedantic = 1; cpp_opts->pedantic = 1;
cpp_opts->warn_endif_labels = 1; cpp_opts->warn_endif_labels = 1;
if (warn_pointer_sign == -1)
warn_pointer_sign = 1;
break; break;
case OPT_print_objc_runtime_info: case OPT_print_objc_runtime_info:
...@@ -1008,6 +1013,11 @@ c_common_post_options (const char **pfilename) ...@@ -1008,6 +1013,11 @@ c_common_post_options (const char **pfilename)
if (warn_missing_field_initializers == -1) if (warn_missing_field_initializers == -1)
warn_missing_field_initializers = extra_warnings; 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 /* Special format checking options don't work without -Wformat; warn if
they are used. */ they are used. */
if (!warn_format) if (!warn_format)
......
...@@ -420,7 +420,7 @@ C ObjC C++ ObjC++ ...@@ -420,7 +420,7 @@ C ObjC C++ ObjC++
Give strings the type \"array of char\" Give strings the type \"array of char\"
Wpointer-sign 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 Warn when a pointer differs in signedness in an assignment
ansi ansi
......
...@@ -256,7 +256,7 @@ Objective-C and Objective-C++ Dialects}. ...@@ -256,7 +256,7 @@ Objective-C and Objective-C++ Dialects}.
@gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol @gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
-Wmissing-prototypes -Wnested-externs -Wold-style-definition @gol -Wmissing-prototypes -Wnested-externs -Wold-style-definition @gol
-Wstrict-prototypes -Wtraditional @gol -Wstrict-prototypes -Wtraditional @gol
-Wdeclaration-after-statement -Wno-pointer-sign} -Wdeclaration-after-statement -Wpointer-sign}
@item Debugging Options @item Debugging Options
@xref{Debugging Options,,Options for Debugging Your Program or GCC}. @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 ...@@ -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 complex; GCC will refuse to optimize programs when the optimization
itself is likely to take inordinate amounts of time. itself is likely to take inordinate amounts of time.
@item -Wno-pointer-sign @item -Wpointer-sign
@opindex Wpointer-sign
@opindex Wno-pointer-sign @opindex Wno-pointer-sign
Don't warn for pointer argument passing or assignment with different signedness. 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@. It is implied by
This option is only supported for C and Objective-C@. @option{-Wall} and by @option{-pedantic}, which can be disabled with
@option{-Wno-pointer-sign}.
@item -Werror @item -Werror
@opindex 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> 2006-01-26 Andrew Pinski <pinskia@physics.uc.edu>
PR C/25861 PR C/25861
/* 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);
}
/* 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" } */
}
/* 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);
}
/* 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" } */
}
/* 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-do compile } */
/* { dg-options "" } */ /* { dg-options "-Wpointer-sign" } */
void f1(long *); void f1(long *);
void f2(unsigned long *); void f2(unsigned long *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment