print_char(border);
const char *end = string->begin + string->size - skip;
for (const char *c = string->begin; c != end; ++c) {
- unsigned char const tc = *c;
+ const char tc = *c;
if (tc == border) {
print_string("\\");
}
}
/* FALLTHROUGH */
default:
- if (tc < 0x80 && !isprint(tc)) {
+ if ((unsigned)tc < 0x80 && !isprint(tc)) {
print_format("\\%03o", (unsigned)tc);
} else {
print_char(tc);
} declaration_kind_t;
static ir_mode *get_ir_mode_storage(type_t *type);
-/*
- * get arithmetic mode for a type. This is different from get_ir_mode_storage,
- * int that it returns bigger modes for floating point on some platforms
- * (x87 internally does arithemtic with 80bits)
- */
-static ir_mode *get_ir_mode_arithmetic(type_t *type);
static ir_type *get_ir_type_incomplete(type_t *type);
return mode;
}
+/*
+ * get arithmetic mode for a type. This is different from get_ir_mode_storage,
+ * int that it returns bigger modes for floating point on some platforms
+ * (x87 internally does arithemtic with 80bits)
+ */
static ir_mode *get_ir_mode_arithmetic(type_t *type)
{
ir_mode *mode = get_ir_mode_storage(type);
return res;
}
- expression_t *con;
+ expression_t *con = NULL;
if (is_local_variable(op1) && is_constant_expression(op2) == EXPR_CLASS_CONSTANT) {
var = op1->reference.entity;
con = op2;
break;
case ENTITY_STRUCT:
case ENTITY_UNION:
- if (alignment > entity->compound.alignment) {
+ if (alignment > (int)entity->compound.alignment) {
entity->compound.alignment = alignment;
}
break;
};
/* optimization settings */
-struct a_firm_opt firm_opt = {
+static struct a_firm_opt firm_opt = {
.const_folding = true,
.cse = true,
.confirm = true,
};
/* dumping options */
-struct a_firm_dump firm_dump = {
+static struct a_firm_dump firm_dump = {
.debug_print = false,
.all_types = false,
.no_blocks = false,
#undef IRG
};
static const int n_opts = sizeof(opts) / sizeof(opts[0]);
-ir_timer_t *timers[sizeof(opts)/sizeof(opts[0])];
+static ir_timer_t *timers[sizeof(opts)/sizeof(opts[0])];
static opt_config_t *get_opt(const char *name)
{
ir_timer_t *timer;
} timer_info_t;
-timer_info_t *infos;
-timer_info_t *last_info;
+static timer_info_t *infos;
+static timer_info_t *last_info;
void timer_register(ir_timer_t *timer, const char *description)
{
[FMT_MOD_I32] = "I32",
[FMT_MOD_I64] = "I64"
};
- assert(mod < lengthof(names));
+ assert((size_t)mod < lengthof(names));
return names[mod];
}
const entity_t *const entity = func_expr->reference.entity;
const call_argument_t * arg = call->arguments;
- if (false) {
- /* the declaration has a GNU format attribute, check it */
- } else {
- /*
- * For some functions we always check the format, even if it was not
- * specified. This allows to check format even in MS mode or without
- * header included.
- */
- const char *const name = entity->base.symbol->string;
- for (size_t i = 0; i < lengthof(builtin_table); ++i) {
- if (strcmp(name, builtin_table[i].name) == 0) {
- switch (builtin_table[i].fmt_kind) {
- case FORMAT_PRINTF:
- check_printf_format(arg, &builtin_table[i]);
- break;
- case FORMAT_SCANF:
- check_scanf_format(arg, &builtin_table[i]);
- break;
- case FORMAT_STRFTIME:
- case FORMAT_STRFMON:
- /* TODO: implement other cases */
- break;
- }
+ /*
+ * For some functions we always check the format, even if it was not
+ * specified. This allows to check format even in MS mode or without
+ * header included.
+ */
+ const char *const name = entity->base.symbol->string;
+ for (size_t i = 0; i < lengthof(builtin_table); ++i) {
+ if (strcmp(name, builtin_table[i].name) == 0) {
+ switch (builtin_table[i].fmt_kind) {
+ case FORMAT_PRINTF:
+ check_printf_format(arg, &builtin_table[i]);
+ break;
+ case FORMAT_SCANF:
+ check_scanf_format(arg, &builtin_table[i]);
+ break;
+ case FORMAT_STRFTIME:
+ case FORMAT_STRFMON:
+ /* TODO: implement other cases */
break;
}
+ break;
}
}
}
static utf32 c;
static source_position_t lexer_pos;
token_t lexer_token;
-symbol_t *symbol_L;
+static symbol_t *symbol_L;
static FILE *input;
static utf32 buf[BUF_SIZE + MAX_PUTBACK];
static const utf32 *bufend;
#define ELSE_CODE(code) \
default: \
code \
+ return; \
} \
} /* end of while (true) */ \
- break;
#define ELSE(set_type) \
ELSE_CODE( \
lexer_token.type = set_type; \
- return; \
)
void lexer_next_preprocessing_token(void)
put_back(c);
c = '.';
lexer_token.type = '.';
- return;
)
ELSE('.')
case '&':
put_back(c);
c = '%';
lexer_token.type = '#';
- return;
)
ELSE('#')
ELSE('%')
bool byte_order_big_endian = false;
bool char_is_signed = true;
bool strict_mode = false;
-bool use_builtins = false;
atomic_type_kind_t wchar_atomic_kind = ATOMIC_TYPE_INT;
unsigned long_double_size = 0;
bool enable_main_collect2_hack = false;
static machine_triple_t *target_machine;
static const char *target_triple;
static int verbose;
+static bool use_builtins;
static struct obstack cppflags_obst;
static struct obstack ldflags_obst;
static struct obstack asflags_obst;
obstack_init(&file_obst);
#define GET_ARG_AFTER(def, args) \
+ do { \
def = &arg[sizeof(args)-1]; \
- if (def[0] == '\0') { \
+ if (def[0] == '\0') { \
++i; \
- if (i >= argc) { \
+ if (i >= argc) { \
fprintf(stderr, "error: expected argument after '" args "'\n"); \
argument_errors = true; \
break; \
} \
def = argv[i]; \
- if (def[0] == '-' && def[1] != '\0') { \
+ if (def[0] == '-' && def[1] != '\0') { \
fprintf(stderr, "error: expected argument after '" args "'\n"); \
argument_errors = true; \
continue; \
} \
- }
+ } \
+ } while (0)
#define SINGLE_OPTION(ch) (option[0] == (ch) && option[1] == '\0')
[STATEMENT_MS_TRY] = sizeof(ms_try_statement_t),
[STATEMENT_LEAVE] = sizeof(leave_statement_t)
};
- assert(kind < lengthof(sizes));
+ assert((size_t)kind < lengthof(sizes));
assert(sizes[kind] != 0);
return sizes[kind];
}
if (kind >= EXPR_BINARY_FIRST && kind <= EXPR_BINARY_LAST) {
return sizes[EXPR_BINARY_FIRST];
}
- assert(kind < lengthof(sizes));
+ assert((size_t)kind < lengthof(sizes));
assert(sizes[kind] != 0);
return sizes[kind];
}
[INITIALIZER_LIST] = sizeof(initializer_list_t),
[INITIALIZER_DESIGNATOR] = sizeof(initializer_designator_t)
};
- assert(kind < lengthof(sizes));
+ assert((size_t)kind < lengthof(sizes));
assert(sizes[kind] != 0);
return sizes[kind];
}
assert(namespc != NAMESPACE_INVALID);
entity_t *entity = symbol->entity;
for (; entity != NULL; entity = entity->base.symbol_next) {
- if (entity->base.namespc == namespc)
+ if ((namespace_tag_t)entity->base.namespc == namespc)
return entity;
}
entity_kind_tag_t const kind)
{
entity_t *entity = get_entity(symbol, NAMESPACE_TAG);
- if (entity != NULL && entity->kind != kind) {
+ if (entity != NULL && (entity_kind_tag_t)entity->kind != kind) {
errorf(HERE,
"'%Y' defined as wrong kind of tag (previous definition %P)",
symbol, &entity->base.source_position);
break;
#define CHECK_DOUBLE_TYPE() \
+ do { \
if ( type != NULL) \
- errorf(HERE, "multiple data types in declaration specifiers");
+ errorf(HERE, "multiple data types in declaration specifiers"); \
+ } while(0)
case T_struct:
CHECK_DOUBLE_TYPE();
parse_expression_infix_function infix_parser;
};
-expression_parser_function_t expression_parsers[T_LAST_TOKEN];
+static expression_parser_function_t expression_parsers[T_LAST_TOKEN];
/**
* Prints an error message if an expression was expected but not read
construct a hashmap here... */
entity_t *entity = scope->entities;
for ( ; entity != NULL; entity = entity->base.next) {
- if (entity->base.symbol == symbol && entity->base.namespc == namespc)
+ if (entity->base.symbol == symbol
+ && (namespace_tag_t)entity->base.namespc == namespc)
break;
}
while (token.type != T_EOF && token.type != '}') {
#ifndef NDEBUG
- bool anchor_leak = false;
for (int i = 0; i < T_LAST_TOKEN; ++i) {
unsigned char count = token_anchor_set[i] - token_anchor_copy[i];
if (count != 0) {
/* the anchor set and its copy differs */
internal_errorf(HERE, "Leaked anchor token %k %d times", i, count);
- anchor_leak = true;
}
}
if (in_gcc_extension) {
/* an gcc extension scope was not closed */
internal_errorf(HERE, "Leaked __extension__");
- anchor_leak = true;
}
-
- if (anchor_leak)
- abort();
#endif
parse_external();
pp_input_t *parent;
};
-pp_input_t input;
+static pp_input_t input;
#define CC input.c
static pp_input_t *input_stack;
static pp_conditional_t *conditional_stack;
-token_t pp_token;
+static token_t pp_token;
static bool resolve_escape_sequences = false;
static bool do_print_spaces = true;
static bool do_expansions;
#define ELSE_CODE(code) \
default: \
- code; \
+ code \
+ return; \
} \
} /* end of while(1) */ \
- break;
#define ELSE(set_type) \
ELSE_CODE( \
pp_token.type = set_type; \
- return; \
)
static void next_preprocessing_token(void)
put_back(CC);
CC = '.';
pp_token.type = '.';
- return;
)
ELSE('.')
case '&':
put_back(CC);
CC = '%';
pp_token.type = '#';
- return;
)
ELSE('#')
ELSE('%')
case '\?': fputs("\\?", out); break;
default:
if(!isprint(*c)) {
- fprintf(out, "\\%03o", *c);
+ fprintf(out, "\\%03o", (unsigned)*c);
break;
}
fputc(*c, out);
copy = duplicate_type(type);
copy->array.element_type = qual_element_type;
} else if (is_type_valid(type)) {
- if ((type->base.qualifiers & qual) == qual)
+ if ((type->base.qualifiers & qual) == (int)qual)
return orig_type;
copy = duplicate_type(type);
extern type_t *type_short_ptr;
extern type_t *type_signed_char_ptr;
extern type_t *type_void_ptr;
+extern type_t *type_const_void;
extern type_t *type_const_void_ptr;
extern type_t *type_void_ptr_restrict;
extern type_t *type_const_void_ptr_restrict;
static output_limit *output_limits;
static const char *libname;
-static void write_type(type_t *type);
-
static bool is_system_header(const char *fname)
{
if (strncmp(fname, "/usr/include", 12) == 0)