avoid enum constant folding problems in ast2firm
authorMatthias Braun <matze@braunis.de>
Fri, 6 Jun 2008 17:29:37 +0000 (17:29 +0000)
committerMatthias Braun <matze@braunis.de>
Fri, 6 Jun 2008 17:29:37 +0000 (17:29 +0000)
[r20016]

Makefile
ast2firm.c

index 32bd0b6..60dcb5f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -117,11 +117,11 @@ build/cpb2/%.o: %.c cparser.bootstrap
 
 cparser.bootstrap: $(CPARSEROS)
        @echo "===> LD $@"
-       $(Q)$(CC) $(CPARSEROS) $(LFLAGS) -o $@
+       $(Q)./build/cparser $(CPARSEROS) $(LFLAGS) -o $@
 
 cparser.bootstrap2: $(CPARSEROS2)
        @echo "===> LD $@"
-       $(Q)$(CC) $(CPARSEROS2) $(LFLAGS) -o $@
+       $(Q)./cparser.bootstrap $(CPARSEROS2) $(LFLAGS) -o $@
 
 build/%.o: %.c
        @echo '===> CC $<'
index 03eaf40..ba22e05 100644 (file)
@@ -62,6 +62,7 @@ static ir_node  *break_label;
 static ir_node  *current_switch_cond;
 static bool      saw_default_label;
 static ir_node **imature_blocks;
+static bool constant_folding;
 
 static const declaration_t *current_function_decl;
 static ir_node             *current_function_name;
@@ -699,6 +700,9 @@ static ir_type *create_enum_type(enum_type_t *const type)
        tarval  *const one     = get_mode_one(mode);
        tarval  *      tv_next = get_tarval_null(mode);
 
+       bool constant_folding_old = constant_folding;
+       constant_folding = true;
+
        declaration_t *declaration = type->declaration->next;
        for (; declaration != NULL; declaration = declaration->next) {
                if (declaration->storage_class != STORAGE_CLASS_ENUM_ENTRY)
@@ -718,6 +722,8 @@ static ir_type *create_enum_type(enum_type_t *const type)
                tv_next = tarval_add(tv_next, one);
        }
 
+       constant_folding = constant_folding_old;
+
        return ir_type_int;
 }
 
@@ -2485,8 +2491,6 @@ static ir_node *alignof_to_firm(const typeprop_expression_t *expression)
        return new_SymConst(mode, sym, symconst_type_align);
 }
 
-static bool constant_folding;
-
 static void init_ir_types(void);
 long fold_constant(const expression_t *expression)
 {