static ir_node *uninitialized_local_var(ir_graph *irg, ir_mode *mode, int pos)
{
const entity_t *entity = get_irg_loc_description(irg, pos);
-
- if (entity != NULL) {
- position_t const *const pos = &entity->base.pos;
- warningf(WARN_UNINITIALIZED, pos, "'%N' might be used uninitialized", entity);
- }
+ if (entity)
+ warningf(WARN_UNINITIALIZED, &entity->base.pos, "'%N' might be used uninitialized", entity);
return new_r_Unknown(irg, mode);
}
symbol_t *symbol = entry->base.symbol;
type_t *entry_type = entry->declaration.type;
- ident *ident;
+ ident *member_id;
if (symbol == NULL) {
/* anonymous bitfield member, skip */
if (entry->compound_member.bitfield)
continue;
assert(is_type_compound(entry_type));
- ident = id_unique("anon.%u");
+ member_id = id_unique("anon.%u");
} else {
- ident = new_id_from_str(symbol->string);
+ member_id = new_id_from_str(symbol->string);
}
dbg_info *dbgi = get_dbg_info(&entry->base.pos);
} else {
entry_irtype = get_ir_type(entry_type);
}
- ir_entity *entity = new_d_entity(irtype, ident, entry_irtype, dbgi);
+ ir_entity *entity = new_d_entity(irtype, member_id, entry_irtype, dbgi);
set_entity_offset(entity, entry->compound_member.offset);
set_entity_offset_bits_remainder(entity,
&& get_entity_owner(irentity) != get_tls_type()) {
add_entity_linkage(irentity, IR_LINKAGE_CONSTANT);
}
- ir_initializer_t *initializer = create_initializer_compound(2);
+ ir_initializer_t *complex_init = create_initializer_compound(2);
ir_initializer_t *reali = create_initializer_const(real);
- set_initializer_compound_value(initializer, 0, reali);
+ set_initializer_compound_value(complex_init, 0, reali);
ir_initializer_t *imagi = create_initializer_const(imag);
- set_initializer_compound_value(initializer, 1, imagi);
- set_entity_initializer(irentity, initializer);
+ set_initializer_compound_value(complex_init, 1, imagi);
+ set_entity_initializer(irentity, complex_init);
}
return;
} else if (!is_type_scalar(init_type)) {
}
case 'X': {
- unsigned int const val = va_arg(ap, unsigned int);
- char const *const fmt = flag_zero ? "%0*X" : "%*X";
- fprintf(stderr, fmt, field_width, val);
+ unsigned int const val = va_arg(ap, unsigned int);
+ char const *const xfmt = flag_zero ? "%0*X" : "%*X";
+ fprintf(stderr, xfmt, field_width, val);
break;
}
atomic_type_properties_t *props = atomic_type_properties;
/* adjust types as requested by target architecture */
- ir_type *type_long_double = be_params->type_long_double;
- if (type_long_double != NULL) {
- set_typeprops_type(&props[ATOMIC_TYPE_LONG_DOUBLE], type_long_double);
- atomic_modes[ATOMIC_TYPE_LONG_DOUBLE] = get_type_mode(type_long_double);
+ ir_type *const type_ld = be_params->type_long_double;
+ if (type_ld) {
+ set_typeprops_type(&props[ATOMIC_TYPE_LONG_DOUBLE], type_ld);
+ atomic_modes[ATOMIC_TYPE_LONG_DOUBLE] = get_type_mode(type_ld);
}
- ir_type *type_long_long = be_params->type_long_long;
- if (type_long_long != NULL)
- set_typeprops_type(&props[ATOMIC_TYPE_LONGLONG], type_long_long);
+ ir_type *const type_ll = be_params->type_long_long;
+ if (type_ll)
+ set_typeprops_type(&props[ATOMIC_TYPE_LONGLONG], type_ll);
- ir_type *type_unsigned_long_long = be_params->type_unsigned_long_long;
- if (type_unsigned_long_long != NULL)
- set_typeprops_type(&props[ATOMIC_TYPE_ULONGLONG], type_unsigned_long_long);
+ ir_type *const type_ull = be_params->type_unsigned_long_long;
+ if (type_ull)
+ set_typeprops_type(&props[ATOMIC_TYPE_ULONGLONG], type_ull);
/* operating system ABI specifics */
if (firm_is_darwin_os(target_machine)) {
props[ATOMIC_TYPE_WCHAR_T] = props[wchar_atomic_kind];
/* initialize defaults for unsupported types */
- if (type_long_long == NULL) {
+ if (!type_ll) {
copy_typeprops(&props[ATOMIC_TYPE_LONGLONG], &props[ATOMIC_TYPE_LONG]);
}
- if (type_unsigned_long_long == NULL) {
+ if (!type_ull) {
copy_typeprops(&props[ATOMIC_TYPE_ULONGLONG],
&props[ATOMIC_TYPE_ULONG]);
}
- if (type_long_double == NULL) {
+ if (!type_ld) {
copy_typeprops(&props[ATOMIC_TYPE_LONG_DOUBLE],
&props[ATOMIC_TYPE_DOUBLE]);
}
again:
switch (unit->type) {
case COMPILATION_UNIT_IR: {
- bool res = open_input(unit);
- if (!res) {
+ if (!open_input(unit)) {
result = EXIT_FAILURE;
break;
}
- res = !ir_import_file(unit->input, unit->name);
- if (!res) {
+ if (ir_import_file(unit->input, unit->name)) {
position_t const pos = { inputname, 0, 0, 0 };
errorf(&pos, "import of firm graph failed");
result = EXIT_FAILURE;
if (external_preprocessor == NULL) {
panic("preprocessed assembler not possible with internal preprocessor yet");
}
- bool res = run_external_preprocessor(unit);
- if (!res) {
+ if (!run_external_preprocessor(unit)) {
result = EXIT_FAILURE;
break;
}
case COMPILATION_UNIT_C:
case COMPILATION_UNIT_CXX:
if (external_preprocessor != NULL) {
- bool res = run_external_preprocessor(unit);
- if (!res) {
+ if (!run_external_preprocessor(unit)) {
result = EXIT_FAILURE;
break;
}
case COMPILATION_UNIT_PREPROCESSED_C:
case COMPILATION_UNIT_PREPROCESSED_CXX: {
- bool res = open_input(unit);
- if (!res) {
+ if (!open_input(unit)) {
result = EXIT_FAILURE;
break;
}
init_tokens();
if (mode == PreprocessOnly) {
- bool res = output_preprocessor_tokens(unit, out);
- if (!res) {
+ if (!output_preprocessor_tokens(unit, out)) {
result = EXIT_FAILURE;
break;
}
streq(opt, "stack-protector-all")) {
fprintf(stderr, "ignoring gcc option '-f%s'\n", orig_opt);
} else {
- int res = firm_option(orig_opt);
- if (res == 0) {
+ if (firm_option(orig_opt) == 0) {
errorf(NULL, "unknown Firm option '-f%s'", orig_opt);
argument_errors = true;
continue;
fprintf(stderr, "warning: -bhelp is deprecated (use --help-firm)\n");
help |= HELP_FIRM;
} else {
- int res = be_parse_arg(opt);
- if (res == 0) {
+ if (be_parse_arg(opt) == 0) {
errorf(NULL, "unknown Firm backend option '-b %s'", opt);
argument_errors = true;
} else if (strstart(opt, "isa=")) {
} else if (strstart(opt, "tune=")) {
GET_ARG_AFTER(opt, "-mtune=");
snprintf(arch_opt, sizeof(arch_opt), "%s-opt=%s", cpu_arch, opt);
- int res = be_parse_arg(arch_opt);
- if (res == 0)
+ if (be_parse_arg(arch_opt) == 0)
argument_errors = true;
} else if (strstart(opt, "cpu=")) {
GET_ARG_AFTER(opt, "-mcpu=");
snprintf(arch_opt, sizeof(arch_opt), "%s-arch=%s", cpu_arch, opt);
- int res = be_parse_arg(arch_opt);
- if (res == 0)
+ if (be_parse_arg(arch_opt) == 0)
argument_errors = true;
} else if (strstart(opt, "fpmath=")) {
GET_ARG_AFTER(opt, "-mfpmath=");
}
if (!argument_errors) {
snprintf(arch_opt, sizeof(arch_opt), "%s-fpunit=%s", cpu_arch, opt);
- int res = be_parse_arg(arch_opt);
- if (res == 0)
+ if (be_parse_arg(arch_opt) == 0)
argument_errors = true;
}
} else if (strstart(opt, "preferred-stack-boundary=")) {
GET_ARG_AFTER(opt, "-mpreferred-stack-boundary=");
snprintf(arch_opt, sizeof(arch_opt), "%s-stackalign=%s", cpu_arch, opt);
- int res = be_parse_arg(arch_opt);
- if (res == 0)
+ if (be_parse_arg(arch_opt) == 0)
argument_errors = true;
} else if (streq(opt, "rtd")) {
default_calling_convention = CC_STDCALL;
} else if (streq(opt, "soft-float")) {
add_flag(&ldflags_obst, "-msoft-float");
snprintf(arch_opt, sizeof(arch_opt), "%s-fpunit=softfloat", cpu_arch);
- int res = be_parse_arg(arch_opt);
- if (res == 0)
+ if (be_parse_arg(arch_opt) == 0)
argument_errors = true;
} else if (streq(opt, "sse2")) {
/* ignore for now, our x86 backend always uses sse when
/* link program file */
if (mode == CompileAssembleLink) {
- int result = link_program(units);
- if (result != EXIT_SUCCESS) {
+ int const link_result = link_program(units);
+ if (link_result != EXIT_SUCCESS) {
if (out != stdout)
unlink(outname);
- return result;
+ return link_result;
}
}
errorf(pos, "redefinition of '%N' (declared %P)", entity, &entity->base.pos);
}
-static bool is_declaration_specifier(const token_t *token)
+static bool is_declaration_specifier(token_t const *const tk)
{
- switch (token->kind) {
+ switch (tk->kind) {
DECLARATION_START
return true;
case T_IDENTIFIER:
- return is_typedef_symbol(token->base.symbol);
+ return is_typedef_symbol(tk->base.symbol);
default:
return false;
return;
}
- assert(is_declaration(ndeclaration));
- type_t *const orig_type = ndeclaration->declaration.type;
- type_t * type = skip_typeref(orig_type);
+ {
+ assert(is_declaration(ndeclaration));
+ type_t *const orig_type = ndeclaration->declaration.type;
+ type_t *const type = skip_typeref(orig_type);
- if (!is_type_function(type)) {
- if (is_type_valid(type)) {
- errorf(HERE, "declarator '%#N' has a body but is not a function type", ndeclaration);
+ if (!is_type_function(type)) {
+ if (is_type_valid(type)) {
+ errorf(HERE, "declarator '%#N' has a body but is not a function type", ndeclaration);
+ }
+ eat_block();
+ return;
}
- eat_block();
- return;
- }
- position_t const *const pos = &ndeclaration->base.pos;
- if (is_typeref(orig_type)) {
- /* §6.9.1:2 */
- errorf(pos, "type of function definition '%#N' is a typedef", ndeclaration);
- }
-
- if (is_type_compound(skip_typeref(type->function.return_type))) {
- warningf(WARN_AGGREGATE_RETURN, pos, "'%N' returns an aggregate", ndeclaration);
- }
- if (type->function.unspecified_parameters) {
- warningf(WARN_OLD_STYLE_DEFINITION, pos, "old-style definition of '%N'", ndeclaration);
- } else {
- warningf(WARN_TRADITIONAL, pos, "traditional C rejects ISO C style definition of '%N'", ndeclaration);
- }
+ position_t const *const pos = &ndeclaration->base.pos;
+ if (is_typeref(orig_type)) {
+ /* §6.9.1:2 */
+ errorf(pos, "type of function definition '%#N' is a typedef", ndeclaration);
+ }
- /* §6.7.5.3:14 a function definition with () means no
- * parameters (and not unspecified parameters) */
- if (type->function.unspecified_parameters &&
- type->function.parameters == NULL) {
- type_t *copy = duplicate_type(type);
- copy->function.unspecified_parameters = false;
- type = identify_new_type(copy);
+ if (is_type_compound(skip_typeref(type->function.return_type))) {
+ warningf(WARN_AGGREGATE_RETURN, pos, "'%N' returns an aggregate", ndeclaration);
+ }
+ if (type->function.unspecified_parameters) {
+ warningf(WARN_OLD_STYLE_DEFINITION, pos, "old-style definition of '%N'", ndeclaration);
+ } else {
+ warningf(WARN_TRADITIONAL, pos, "traditional C rejects ISO C style definition of '%N'", ndeclaration);
+ }
- ndeclaration->declaration.type = type;
+ /* §6.7.5.3:14 a function definition with () means no
+ * parameters (and not unspecified parameters) */
+ if (type->function.unspecified_parameters &&
+ type->function.parameters == NULL) {
+ type_t *copy = duplicate_type(type);
+ copy->function.unspecified_parameters = false;
+ ndeclaration->declaration.type = identify_new_type(copy);
+ }
}
entity_t *const entity = record_entity(ndeclaration, true);
walk_statements(body, check_unreachable, NULL);
if (noreturn_candidate &&
!(function->base.modifiers & DM_NORETURN)) {
- position_t const *const pos = &body->base.pos;
- warningf(WARN_MISSING_NORETURN, pos, "function '%#N' is candidate for attribute 'noreturn'", entity);
+ warningf(WARN_MISSING_NORETURN, &body->base.pos, "function '%#N' is candidate for attribute 'noreturn'", entity);
}
}
add_anchor_token(',');
do {
entity_t *entity;
-
if (token.kind == ':') {
/* anonymous bitfield */
type_t *type = specifiers->type;
- entity_t *const entity = allocate_entity_zero(ENTITY_COMPOUND_MEMBER, NAMESPACE_NORMAL, NULL, HERE);
+ entity = allocate_entity_zero(ENTITY_COMPOUND_MEMBER, NAMESPACE_NORMAL, NULL, HERE);
entity->declaration.declared_storage_class = STORAGE_CLASS_NONE;
entity->declaration.storage_class = STORAGE_CLASS_NONE;
entity->declaration.type = type;
handle_entity_attributes(attributes, entity);
}
entity->declaration.attributes = attributes;
-
- append_entity(&compound->members, entity);
} else {
- entity = parse_declarator(specifiers,
- DECL_MAY_BE_ABSTRACT | DECL_CREATE_COMPOUND_MEMBER);
+ entity = parse_declarator(specifiers, DECL_MAY_BE_ABSTRACT | DECL_CREATE_COMPOUND_MEMBER);
position_t const *const pos = &entity->base.pos;
if (entity->kind == ENTITY_TYPEDEF) {
errorf(pos, "typedef not allowed as compound member");
- } else {
- assert(entity->kind == ENTITY_COMPOUND_MEMBER);
-
- /* make sure we don't define a symbol multiple times */
- symbol_t *symbol = entity->base.symbol;
- if (symbol != NULL) {
- entity_t *prev = find_compound_entry(compound, symbol);
- if (prev != NULL) {
- position_t const *const ppos = &prev->base.pos;
- errorf(pos, "multiple declarations of '%N' (declared %P)", entity, ppos);
- }
+ continue;
+ }
+
+ assert(entity->kind == ENTITY_COMPOUND_MEMBER);
+
+ /* make sure we don't define a symbol multiple times */
+ symbol_t *symbol = entity->base.symbol;
+ if (symbol != NULL) {
+ entity_t *prev = find_compound_entry(compound, symbol);
+ if (prev != NULL) {
+ position_t const *const ppos = &prev->base.pos;
+ errorf(pos, "multiple declarations of '%N' (declared %P)", entity, ppos);
}
+ }
- if (token.kind == ':') {
- parse_bitfield_member(entity);
+ if (token.kind == ':') {
+ parse_bitfield_member(entity);
- attribute_t *attributes = parse_attributes(NULL);
- handle_entity_attributes(attributes, entity);
- } else {
- type_t *orig_type = entity->declaration.type;
- type_t *type = skip_typeref(orig_type);
- if (is_type_function(type)) {
- errorf(pos, "'%N' must not have function type '%T'", entity, orig_type);
- } else if (is_type_incomplete(type)) {
- /* §6.7.2.1:16 flexible array member */
- if (!is_type_array(type) ||
- token.kind != ';' ||
- look_ahead(1)->kind != '}') {
- errorf(pos, "'%N' has incomplete type '%T'", entity, orig_type);
- } else if (compound->members.entities == NULL) {
- errorf(pos, "flexible array member in otherwise empty struct");
- }
+ attribute_t *attributes = parse_attributes(NULL);
+ handle_entity_attributes(attributes, entity);
+ } else {
+ type_t *orig_type = entity->declaration.type;
+ type_t *type = skip_typeref(orig_type);
+ if (is_type_function(type)) {
+ errorf(pos, "'%N' must not have function type '%T'", entity, orig_type);
+ } else if (is_type_incomplete(type)) {
+ /* §6.7.2.1:16 flexible array member */
+ if (!is_type_array(type) ||
+ token.kind != ';' ||
+ look_ahead(1)->kind != '}') {
+ errorf(pos, "'%N' has incomplete type '%T'", entity, orig_type);
+ } else if (compound->members.entities == NULL) {
+ errorf(pos, "flexible array member in otherwise empty struct");
}
}
-
- append_entity(&compound->members, entity);
}
}
+
+ append_entity(&compound->members, entity);
} while (accept(','));
rem_anchor_token(',');
rem_anchor_token(';');
= size / sizeof(new_definition->parameters[0]);
new_definition->parameters = obstack_finish(&pp_obstack);
for (size_t i = 0; i < new_definition->n_parameters; ++i) {
- pp_definition_t *param = &new_definition->parameters[i];
- symbol_t *symbol = param->symbol;
- pp_definition_t *previous = symbol->pp_definition;
+ pp_definition_t *const param = &new_definition->parameters[i];
+ symbol_t *const param_sym = param->symbol;
+ pp_definition_t *const previous = param_sym->pp_definition;
if (previous != NULL
&& previous->function_definition == new_definition) {
- errorf(¶m->pos, "duplicate macro parameter '%Y'", symbol);
+ errorf(¶m->pos, "duplicate macro parameter '%Y'", param_sym);
param->symbol = sym_anonymous;
continue;
}
param->parent_expansion = previous;
param->function_definition = new_definition;
- symbol->pp_definition = param;
+ param_sym->pp_definition = param;
}
} else {
next_input_token();
bool next_must_be_param = false;
while (!info.at_line_begin) {
if (pp_token.kind == T_IDENTIFIER) {
- const symbol_t *symbol = pp_token.base.symbol;
- pp_definition_t *definition = symbol->pp_definition;
+ pp_definition_t *const definition = pp_token.base.symbol->pp_definition;
if (definition != NULL
&& definition->function_definition == new_definition) {
pp_token.kind = T_MACRO_PARAMETER;
if (new_definition->has_parameters) {
for (size_t i = 0; i < new_definition->n_parameters; ++i) {
- pp_definition_t *param = &new_definition->parameters[i];
- symbol_t *symbol = param->symbol;
- if (symbol == sym_anonymous)
+ pp_definition_t *const param = &new_definition->parameters[i];
+ symbol_t *const param_sym = param->symbol;
+ if (param_sym == sym_anonymous)
continue;
- assert(symbol->pp_definition == param);
+ assert(param_sym->pp_definition == param);
assert(param->function_definition == new_definition);
- symbol->pp_definition = param->parent_expansion;
- param->parent_expansion = NULL;
+ param_sym->pp_definition = param->parent_expansion;
+ param->parent_expansion = NULL;
}
}