This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gcc-in-cxx] Don't do enum math in tree-complex.c
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 31 Jan 2009 21:53:36 -0800
- Subject: [gcc-in-cxx] Don't do enum math in tree-complex.c
The file tree-complex.c does math on enum values, which is verboten in
C++. This patch changes the complex_lattice_t to be an integer
typedef. The enum values remain the same, in a now unnamed enum.
This patch also adds a couple of casts to enum type.
Committed to gcc-in-cxx branch.
Ian
2009-01-31 Ian Lance Taylor <iant@google.com>
* tree-complex.c (complex_lattice_t): Change to int type. Leave
enum type unnamed.
(expand_complex_libcall): Add casts to enum type.
Index: tree-complex.c
===================================================================
--- tree-complex.c (revision 143841)
+++ tree-complex.c (working copy)
@@ -37,13 +37,17 @@ along with GCC; see the file COPYING3.
out whether a complex number is degenerate in some way, having only real
or only complex parts. */
-typedef enum
+enum
{
UNINITIALIZED = 0,
ONLY_REAL = 1,
ONLY_IMAG = 2,
VARYING = 3
-} complex_lattice_t;
+};
+
+/* The type complex_lattice_t holds combinations of the above
+ constants. */
+typedef int complex_lattice_t;
#define PAIR(a, b) ((a) << 2 | (b))
@@ -963,9 +967,11 @@ expand_complex_libcall (gimple_stmt_iter
gcc_assert (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT);
if (code == MULT_EXPR)
- bcode = BUILT_IN_COMPLEX_MUL_MIN + mode - MIN_MODE_COMPLEX_FLOAT;
+ bcode = ((enum built_in_function)
+ (BUILT_IN_COMPLEX_MUL_MIN + mode - MIN_MODE_COMPLEX_FLOAT));
else if (code == RDIV_EXPR)
- bcode = BUILT_IN_COMPLEX_DIV_MIN + mode - MIN_MODE_COMPLEX_FLOAT;
+ bcode = ((enum built_in_function)
+ (BUILT_IN_COMPLEX_DIV_MIN + mode - MIN_MODE_COMPLEX_FLOAT));
else
gcc_unreachable ();
fn = built_in_decls[bcode];