Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:11.4
libgcj43
pr27975.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File pr27975.diff of Package libgcj43
2008-05-27 Michael Matz <matz@suse.de> PR c++/27975 * c.opt (Wenum-compare): New warning option. * doc/invoke.texi (Warning Options): Document -Wenum-compare. cp/ * call.c (build_new_op): Make warning conditional on OPT_Wenum_compare. * g++.dg/warn/Wenum-compare.C: New testcase. * g++.dg/warn/Wenum-compare-no.C: Ditto. Index: gcc/doc/invoke.texi =================================================================== --- gcc/doc/invoke.texi.orig 2009-01-31 21:54:38.000000000 +0100 +++ gcc/doc/invoke.texi 2009-11-20 13:50:32.000000000 +0100 @@ -232,7 +232,7 @@ Objective-C and Objective-C++ Dialects}. -Wchar-subscripts -Wclobbered -Wcomment @gol -Wconversion -Wcoverage-mismatch -Wno-deprecated-declarations @gol -Wdisabled-optimization -Wno-div-by-zero @gol --Wempty-body -Wno-endif-labels @gol +-Wempty-body -Wenum-compare -Wno-endif-labels @gol -Werror -Werror=* @gol -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol -Wno-format-extra-args -Wformat-nonliteral @gol @@ -3626,6 +3626,11 @@ while} statement. Additionally, in C++, in a @samp{while} or @samp{for} statement with no whitespacing before the semicolon. This warning is also enabled by @option{-Wextra}. +@item -Wenum-compare @r{(C++ and Objective-C++ only)} +@opindex Wenum-compare +@opindex Wno-enum-compare +Warn about a comparison between values of different enum types. + @item -Wsign-compare @opindex Wsign-compare @opindex Wno-sign-compare Index: gcc/testsuite/g++.dg/warn/Wenum-compare-no.C =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gcc/testsuite/g++.dg/warn/Wenum-compare-no.C 2009-11-20 13:50:32.000000000 +0100 @@ -0,0 +1,10 @@ +/* Test disabling -Wenum-compare (on by default). See PR27975. */ +/* { dg-do compile } */ +/* { dg-options "-Wno-enum-compare" } */ +enum E1 { a }; +enum E2 { b }; + +int foo (E1 e1, E2 e2) +{ + return e1 == e2; /* { dg-bogus "comparison between" } */ +} Index: gcc/testsuite/g++.dg/warn/Wenum-compare.C =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gcc/testsuite/g++.dg/warn/Wenum-compare.C 2009-11-20 13:50:32.000000000 +0100 @@ -0,0 +1,10 @@ +/* Test that we get the -Wenum-compare by default. See PR27975. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +enum E1 { a }; +enum E2 { b }; + +int foo (E1 e1, E2 e2) +{ + return e1 == e2; /* { dg-warning "comparison between" } */ +} Index: gcc/cp/call.c =================================================================== --- gcc/cp/call.c.orig 2009-06-17 13:58:55.000000000 +0200 +++ gcc/cp/call.c 2009-11-20 13:50:32.000000000 +0100 @@ -3975,7 +3975,8 @@ build_new_op (enum tree_code code, int f && (TYPE_MAIN_VARIANT (TREE_TYPE (arg1)) != TYPE_MAIN_VARIANT (TREE_TYPE (arg2)))) { - warning (0, "comparison between %q#T and %q#T", + warning (OPT_Wenum_compare, + "comparison between %q#T and %q#T", TREE_TYPE (arg1), TREE_TYPE (arg2)); } break; Index: gcc/c.opt =================================================================== --- gcc/c.opt.orig 2009-11-20 13:50:25.000000000 +0100 +++ gcc/c.opt 2009-11-20 13:50:32.000000000 +0100 @@ -199,6 +199,10 @@ Wendif-labels C ObjC C++ ObjC++ Warning Warn about stray tokens after #elif and #endif +Wenum-compare +C++ ObjC++ Var(warn_enum_compare) Init(1) Warning +Warn about comparison of different enum types + Werror C ObjC C++ ObjC++ ; Documented in common.opt
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor