X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=parser.c;h=119677c7e2124b1a3193548b43cc3e4158f9f34e;hb=8f50e4997976bf4942a75b96ec8489edd4202203;hp=2e18543ca869e7a8fab4abcee728ef05fe211623;hpb=c24661b5c67e1a2c34d0fac87965f8a81a4eec66;p=cparser diff --git a/parser.c b/parser.c index 2e18543..119677c 100644 --- a/parser.c +++ b/parser.c @@ -2475,6 +2475,10 @@ finish_designator: if (type == NULL) { /* we are already outside, ... */ + if (is_type_compound(outer_type) && + !outer_type->compound.declaration->init.complete) { + goto error_parse_next; + } goto error_excess; } @@ -3584,10 +3588,8 @@ warn_about_long_long: default: /* invalid specifier combination, give an error message */ if (type_specifiers == 0) { - if (saw_error) { - specifiers->type = type_error_type; - return; - } + if (saw_error) + goto end_error; if (!strict_mode) { if (warning.implicit_int) { @@ -3606,15 +3608,13 @@ warn_about_long_long: } else { errorf(HERE, "multiple datatypes in declaration"); } - atomic_type = ATOMIC_TYPE_INVALID; + goto end_error; } - if (type_specifiers & SPECIFIER_COMPLEX && - atomic_type != ATOMIC_TYPE_INVALID) { + if (type_specifiers & SPECIFIER_COMPLEX) { type = allocate_type_zero(TYPE_COMPLEX, &builtin_source_position); type->complex.akind = atomic_type; - } else if (type_specifiers & SPECIFIER_IMAGINARY && - atomic_type != ATOMIC_TYPE_INVALID) { + } else if (type_specifiers & SPECIFIER_IMAGINARY) { type = allocate_type_zero(TYPE_IMAGINARY, &builtin_source_position); type->imaginary.akind = atomic_type; } else { @@ -3637,7 +3637,10 @@ warn_about_long_long: } specifiers->type = result; + return; + end_error: + specifiers->type = type_error_type; return; } @@ -4164,6 +4167,10 @@ static type_t *construct_declarator_type(construct_type_t *construct_list, errorf(HERE, "function returning array is not allowed"); type = type_error_type; } else { + if (skipped_return_type->base.qualifiers != 0) { + warningf(HERE, + "type qualifiers in return type of function type are meaningless"); + } type = function_type; } break; @@ -4308,7 +4315,7 @@ static void check_type_of_main(const declaration_t *const decl, const function_t warningf(&decl->source_position, "'main' is normally a non-static function"); } - if (skip_typeref(func_type->return_type) != type_int) { + if (!types_compatible(skip_typeref(func_type->return_type), type_int)) { warningf(&decl->source_position, "return type of 'main' should be 'int', but is '%T'", func_type->return_type);