type_t *const orig_type = decl->type;
assert(orig_type != NULL);
type_t *const type = skip_typeref(orig_type);
- type_t * prev_type = skip_typeref(prev_decl->type);
+ type_t *const prev_type = skip_typeref(prev_decl->type);
if (!types_compatible(type, prev_type)) {
errorf(pos,
prev_decl->type, symbol);
}
- unsigned new_storage_class = decl->storage_class;
- if (is_type_incomplete(prev_type)) {
- prev_decl->type = type;
- prev_type = type;
- }
+ storage_class_tag_t new_storage_class = decl->storage_class;
/* pretend no storage class means extern for function
* declarations (except if the previous declaration is neither
* none nor extern) */
if (entity->kind == ENTITY_FUNCTION) {
- if (prev_type->function.unspecified_parameters) {
+ if (prev_type->function.unspecified_parameters)
prev_decl->type = type;
- prev_type = type;
- }
switch (old_storage_class) {
case STORAGE_CLASS_NONE:
default:
break;
}
+ } else if (is_type_incomplete(prev_type)) {
+ prev_decl->type = type;
}
if (old_storage_class == STORAGE_CLASS_EXTERN &&
if (!is_type_incomplete(type))
return;
- /* GCC allows global arrays without size and assigns them a length of one,
- * if no different declaration follows */
- if (is_type_array(type) &&
- c_mode & _GNUC &&
- ent->base.parent_scope == file_scope) {
+ /* §6.9.2:2 and §6.9.2:5: At the end of the translation incomplete arrays
+ * are given length one. */
+ if (is_type_array(type) && ent->base.parent_scope == file_scope) {
ARR_APP1(declaration_t*, incomplete_arrays, decl);
return;
}
/**
* Check the semantic restrictions for a div/mod expression.
*/
-static void semantic_divmod_arithmetic(binary_expression_t *expression) {
+static void semantic_divmod_arithmetic(binary_expression_t *expression)
+{
semantic_binexpr_arithmetic(expression);
warn_div_by_zero(expression);
}
*
* @param statement the switch statement to check
*/
-static void check_enum_cases(const switch_statement_t *statement) {
+static void check_enum_cases(const switch_statement_t *statement)
+{
const type_t *type = skip_typeref(statement->expression->base.type);
if (! is_type_enum(type))
return;
return result;
}
-/* GCC allows global arrays without size and assigns them a length of one,
- * if no different declaration follows */
+/* §6.9.2:2 and §6.9.2:5: At the end of the translation incomplete arrays
+ * are given length one. */
static void complete_incomplete_arrays(void)
{
size_t n = ARR_LEN(incomplete_arrays);