stricter warnings
authorMatthias Braun <matze@braunis.de>
Mon, 12 Nov 2007 19:48:04 +0000 (19:48 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 12 Nov 2007 19:48:04 +0000 (19:48 +0000)
[r18377]

Makefile
adt/hashset.c
ast.h
ast2firm.c
lexer.c
parser.c
write_fluffy.c

index fa1af5d..aeda011 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ FIRM_BUILD = $(FIRM_HOME)/build/i686-pc-linux-gnu/debug/
 FIRM_CFLAGS = -I$(FIRM_HOME)/libfirm/include -I$(FIRM_HOME)/obstack -I$(FIRM_HOME)/libcore -I$(FIRM_HOME)/libcore/libcore -I$(FIRM_HOME)
 FIRM_LIBS = -L$(FIRM_BUILD) -lfirm -llpp -lcore -lm -ldl
 
-CFLAGS += -Wall -W -Werror -std=c99 -pedantic
+CFLAGS += -Wall -W -Wstrict-prototypes -Wmissing-prototypes -Werror -std=c99 -pedantic
 CFLAGS += -DHAVE_CONFIG_H
 CFLAGS += -I .
 CFLAGS += -O0 -g3
index 108a3bc..70dce5b 100644 (file)
 #error You have to redefine hashset_remove_iterator
 #endif
 
+/* prototypes to silence warnings */
+size_t hashset_size(const HashSet *this);
+void hashset_init(HashSet *this);
+void hashset_init_size(HashSet *this, size_t size);
+void hashset_destroy(HashSet *this);
+InsertReturnValue hashset_insert(HashSet *this, KeyType key);
+ValueType hashset_find(const HashSet *this, ConstKeyType key);
+void hashset_remove(HashSet *this, ConstKeyType key);
+void hashset_iterator_init(HashSetIterator *this, const HashSet *hashset);
+ValueType hashset_iterator_next(HashSetIterator *this);
+void hashset_remove_iterator(HashSet *this, const HashSetIterator *iter);
+
 /**
  * Returns the number of elements in the hashset
  */
diff --git a/ast.h b/ast.h
index 76c7a51..7751563 100644 (file)
--- a/ast.h
+++ b/ast.h
@@ -53,7 +53,7 @@ void  ast_set_output(FILE *out);
 void  print_expression(const expression_t *expression);
 void  print_initializer(const initializer_t *initializer);
 void  print_ast(const translation_unit_t *unit);
-void  print_indent();
+void  print_indent(void);
 void  print_declaration(const declaration_t *declaration);
 void  change_indent(int delta);
 void *allocate_ast(size_t size);
index 51e80f5..f9a64e2 100644 (file)
@@ -8,6 +8,8 @@
 #include <libfirm/firm.h>
 #include <libfirm/adt/obst.h>
 
+#include "ast2firm.h"
+
 #include "adt/error.h"
 #include "token_t.h"
 #include "type_t.h"
@@ -106,21 +108,6 @@ static ident *unique_ident(const char *tag)
        return new_id_from_str(buf);
 }
 
-#if 0
-static symbol_t *unique_symbol(const char *tag)
-{
-       obstack_printf(&symbol_obstack, "%s.%d", tag, unique_id);
-       unique_id++;
-
-       const char *string = obstack_finish(&symbol_obstack);
-       symbol_t   *symbol = symbol_table_insert(string);
-
-       assert(symbol->string == string);
-
-       return symbol;
-}
-#endif
-
 static type_t *skip_typeref(type_t *type)
 {
        while(1) {
@@ -908,6 +895,49 @@ static void expression_statement_to_firm(expression_statement_t *statement)
        expression_to_firm(statement->expression);
 }
 
+static void if_statement_to_firm(if_statement_t *statement)
+{
+       dbg_info *dbgi      = get_dbg_info(&statement->statement.source_position);
+       ir_node  *condition = expression_to_firm(statement->condition);
+       assert(condition != NULL);
+       assert(get_irn_mode(condition) == mode_b);
+
+       ir_node *cond       = new_d_Cond(dbgi, condition);
+       ir_node *true_proj  = new_d_Proj(dbgi, cond, mode_X, pn_Cond_true);
+       ir_node *false_proj = new_d_Proj(dbgi, cond, mode_X, pn_Cond_false);
+
+       ir_node *fallthrough_block = new_immBlock();
+
+       /* the true (blocks) */
+       ir_node *true_block = new_immBlock();
+       add_immBlock_pred(true_block, true_proj);
+       mature_immBlock(true_block);
+
+       statement_to_firm(statement->true_statement);
+       if(get_cur_block() != NULL) {
+               ir_node *jmp = new_Jmp();
+               add_immBlock_pred(fallthrough_block, jmp);
+       }
+
+       /* the false (blocks) */
+       if(statement->false_statement != NULL) {
+               ir_node *false_block = new_immBlock();
+               add_immBlock_pred(false_block, false_proj);
+               mature_immBlock(false_block);
+
+               statement_to_firm(statement->false_statement);
+               if(get_cur_block() != NULL) {
+                       ir_node *jmp = new_Jmp();
+                       add_immBlock_pred(fallthrough_block, jmp);
+               }
+       } else {
+               add_immBlock_pred(fallthrough_block, false_proj);
+       }
+       mature_immBlock(fallthrough_block);
+
+       set_cur_block(fallthrough_block);
+}
+
 static void statement_to_firm(statement_t *statement)
 {
        switch(statement->type) {
@@ -920,6 +950,9 @@ static void statement_to_firm(statement_t *statement)
        case STATEMENT_EXPRESSION:
                expression_statement_to_firm((expression_statement_t*) statement);
                return;
+       case STATEMENT_IF:
+               if_statement_to_firm((if_statement_t*) statement);
+               return;
        default:
                break;
        }
diff --git a/lexer.c b/lexer.c
index 9ff748a..69959ef 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -804,7 +804,7 @@ static void parse_preprocessor_identifier(void)
        }
 }
 
-static void parse_preprocessor_directive()
+static void parse_preprocessor_directive(void)
 {
        next_pp_token();
 
index 520da3a..181fe9e 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -154,14 +154,14 @@ static inline const token_t *look_ahead(int num)
 
 #define eat(token_type)  do { assert(token.type == token_type); next_token(); } while(0)
 
-void error(void)
+static void error(void)
 {
 #ifdef ABORT_ON_ERROR
        abort();
 #endif
 }
 
-void parser_print_prefix_pos(const source_position_t source_position)
+static void parser_print_prefix_pos(const source_position_t source_position)
 {
     fputs(source_position.input_name, stderr);
     fputc(':', stderr);
@@ -169,14 +169,15 @@ void parser_print_prefix_pos(const source_position_t source_position)
     fputs(": ", stderr);
 }
 
-void parser_print_error_prefix_pos(const source_position_t source_position)
+static void parser_print_error_prefix_pos(
+               const source_position_t source_position)
 {
        parser_print_prefix_pos(source_position);
        fputs("error: ", stderr);
        error();
 }
 
-void parser_print_error_prefix(void)
+static void parser_print_error_prefix(void)
 {
        parser_print_prefix_pos(token.source_position);
        error();
@@ -2556,8 +2557,8 @@ static expression_t *parse_expression(void)
 
 
 
-void register_expression_parser(parse_expression_function parser,
-                                int token_type, unsigned precedence)
+static void register_expression_parser(parse_expression_function parser,
+                                       int token_type, unsigned precedence)
 {
        expression_parser_function_t *entry = &expression_parsers[token_type];
 
@@ -2571,8 +2572,9 @@ void register_expression_parser(parse_expression_function parser,
        entry->precedence = precedence;
 }
 
-void register_expression_infix_parser(parse_expression_infix_function parser,
-                                      int token_type, unsigned precedence)
+static void register_expression_infix_parser(
+               parse_expression_infix_function parser, int token_type,
+               unsigned precedence)
 {
        expression_parser_function_t *entry = &expression_parsers[token_type];
 
index 986a37d..e8ccbd7 100644 (file)
@@ -3,6 +3,7 @@
 #include <errno.h>
 #include <string.h>
 
+#include "write_fluffy.h"
 #include "ast_t.h"
 #include "type_t.h"
 #include "type.h"