X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=format_check.c;h=4fad47a48df09adc1471d5dd458f142d7df84d5e;hb=d70f5307ecc25394fc2da35bf4167fea5ac4b9ec;hp=51548eb4cc78b08bab78d5937d226f7fb03d02a0;hpb=4a15d610cb1ad5b2710c1467c1437b42d48abe84;p=cparser diff --git a/format_check.c b/format_check.c index 51548eb..4fad47a 100644 --- a/format_check.c +++ b/format_check.c @@ -142,7 +142,7 @@ break_fmt_flags: warningf(pos, "missing argument for '*' field width in conversion specification"); return; } - const type_t *const arg_type = arg->expression->base.datatype; + const type_t *const arg_type = arg->expression->base.type; if (arg_type != type_int) { warningf(pos, "argument for '*' field width in conversion specification is not an 'int', but an '%T'", arg_type); } @@ -162,7 +162,7 @@ break_fmt_flags: warningf(pos, "missing argument for '*' precision in conversion specification"); return; } - const type_t *const arg_type = arg->expression->base.datatype; + const type_t *const arg_type = arg->expression->base.type; if (arg_type != type_int) { warningf(pos, "argument for '*' precision in conversion specification is not an 'int', but an '%T'", arg_type); } @@ -314,7 +314,7 @@ eval_fmt_mod_unsigned: case 's': switch (fmt_mod) { - case FMT_MOD_NONE: expected_type = type_string; break; + case FMT_MOD_NONE: expected_type = type_char_ptr; break; case FMT_MOD_l: expected_type = type_wchar_t_ptr; break; default: @@ -367,28 +367,29 @@ eval_fmt_mod_unsigned: return; } - type_t *const arg_type = arg->expression->base.datatype; - if (is_type_pointer(expected_type)) { - type_t *const arg_skip = skip_typeref(arg_type); - if (is_type_pointer(arg_skip)) { - type_t *const exp_to = skip_typeref(expected_type->pointer.points_to); - type_t *const arg_to = skip_typeref(arg_skip->pointer.points_to); - if ((arg_to->base.qualifiers & ~expected_qual) == 0 && - get_unqualified_type(arg_to) == exp_to) { + { /* create a scope here to prevent warning about the jump to next_arg */ + type_t *const arg_type = arg->expression->base.type; + if (is_type_pointer(expected_type)) { + type_t *const arg_skip = skip_typeref(arg_type); + if (is_type_pointer(arg_skip)) { + type_t *const exp_to = skip_typeref(expected_type->pointer.points_to); + type_t *const arg_to = skip_typeref(arg_skip->pointer.points_to); + if ((arg_to->base.qualifiers & ~expected_qual) == 0 && + get_unqualified_type(arg_to) == exp_to) { + goto next_arg; + } + } + } else { + if (get_unqualified_type(skip_typeref(arg_type)) == expected_type) { goto next_arg; } } - } else { - if (get_unqualified_type(skip_typeref(arg_type)) == expected_type) { - goto next_arg; + if (is_type_valid(arg_type)) { + warningf(pos, + "argument type '%T' does not match conversion specifier '%%%s%c'", + arg_type, get_length_modifier_name(fmt_mod), (char)*fmt); } } - if (is_type_valid(arg_type)) { - warningf(pos, - "argument type '%T' does not match conversion specifier '%%%s%c'", - arg_type, get_length_modifier_name(fmt_mod), (char)*fmt); - } - next_arg: arg = arg->next; }