[Bug c/61405] New: Not emitting "enumeration value not handled in switch" warning for bit-field enums
jamborm at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jun 3 16:09:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61405
Bug ID: 61405
Summary: Not emitting "enumeration value not handled in switch"
warning for bit-field enums
Product: gcc
Version: 4.10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jamborm at gcc dot gnu.org
This a followup to PR 61340. In both C and C++ we do not emit a
warning about unhandled enumeration values in a switch if the enum is
also a bit-field (and clang does, that is how it was noticed).
Testcase:
$ cat test.c
enum ipa_ref_use
{
IPA_REF_LOAD,
IPA_REF_STORE,
IPA_REF_ADDR,
IPA_REF_ALIAS
};
/* Record of reference in callgraph or varpool. */
struct ipa_ref
{
unsigned int lto_stmt_uid;
unsigned int referred_index;
#ifndef PRODUCE_WARNING
enum ipa_ref_use use:2;
#else
enum ipa_ref_use use;
#endif
unsigned int speculative:1;
};
int blah1 (unsigned int);
int blah2 (unsigned int);
int blah3 (unsigned int);
int
foo (struct ipa_ref *ref)
{
int r;
switch (ref->use)
{
case IPA_REF_LOAD:
r = blah1 (ref->lto_stmt_uid) + 8;
break;
case IPA_REF_STORE:
r = blah2 (ref->referred_index +5) * 3;
break;
case IPA_REF_ADDR:
r = blah3 (ref->lto_stmt_uid + ref->speculative);
break;
}
return r;
}
$ ~/gcc/mine/inst/bin/gcc test.c -O -S -Wswitch
$ ~/gcc/mine/inst/bin/gcc test.c -O -S -Wswitch -DPRODUCE_WARNING
test.c: In function ‘foo’:
test.c:30:3: warning: enumeration value ‘IPA_REF_ALIAS’ not handled in switch
[-Wswitch]
switch (ref->use)
^
$ clang test.c -O -S -Wswitch -DPRODUCE_WARNING
test.c:30:11: warning: enumeration value 'IPA_REF_ALIAS' not handled in switch
[-Wswitch]
switch (ref->use)
^
1 warning generated.
More information about the Gcc-bugs
mailing list