This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/52283] "error: case label does not reduce to an integer constant" for constant folded cast expr
- From: "joseph at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 16 Feb 2012 17:54:03 +0000
- Subject: [Bug c/52283] "error: case label does not reduce to an integer constant" for constant folded cast expr
- Auto-submitted: auto-generated
- References: <bug-52283-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52283
--- Comment #5 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2012-02-16 17:54:03 UTC ---
On Thu, 16 Feb 2012, manu at gcc dot gnu.org wrote:
> What is the problem with stripping the nops *before giving the error* and if it
> still fails, give an error?
NOPs are used to represent an intermediate expression that folded to an
integer constant but is not an integer constant expression and cannot
appear in one, as well as to carry TREE_NO_WARNING. So you need to be
careful about where you strip them to avoid making something into an
integer constant expression that should not be one; don't strip them too
early.
I think it would be OK to have a c_fully_fold_no_nop (which removes any
TREE_NO_WARNING nop from the return from c_fully_fold) that is used in the
relevant places (set_init_index, do_case, check_bitfield_type_and_width,
build_enumerator at least) which have the pedwarn-if-pedantic logic for
things folding to an integer constant where an integer constant expression
is required.