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
This commit is contained in:
Alexandre Oliva 2006-01-26 18:50:37 +00:00 committed by Alexandre Oliva
parent e046a30ab1
commit f4e9414ef8
11 changed files with 86 additions and 7 deletions

View 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

View 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)

View file

@ -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

View 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

View 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

View file

@ -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);
}

View file

@ -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" } */
}

View file

@ -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);
}

View file

@ -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" } */
}

View file

@ -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);
}

View file

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "" } */
/* { dg-options "-Wpointer-sign" } */
void f1(long *);
void f2(unsigned long *);