2012-09-17 Tobias Burnus <burnus@net-b.de>
* error.c (error_print): Move increment out of the assert.
* interface.c (gfc_compare_derived_types): Add assert.
(get_expr_storage_size): Remove always-true logical condition.
* resolve.c (resolve_allocate_expr): Fix looping logic.
* target-memory.c (gfc_target_expr_size): Add assert.
@@ -536,23 +536,24 @@ error_print (const char *type, const char *format0, va_list argp)
if (ISDIGIT (*format))
{
/* This is a position specifier. For example, the number
12 in the format string "%12$d", which specifies the third
argument of the va_list, formatted in %d format.
For details, see "man 3 printf". */
pos = atoi(format) - 1;
gcc_assert (pos >= 0);
while (ISDIGIT(*format))
format++;
- gcc_assert (*format++ == '$');
+ gcc_assert (*format == '$');
+ format++;
}
else
pos++;
c = *format++;
if (pos > maxpos)
maxpos = pos;
switch (c)
{
@@ -388,27 +388,28 @@ gfc_match_end_interface (void)
/* Compare two derived types using the criteria in 4.4.2 of the standard,
recursing through gfc_compare_types for the components. */
int
gfc_compare_derived_types (gfc_symbol *derived1, gfc_symbol *derived2)
{
gfc_component *dt1, *dt2;
if (derived1 == derived2)
return 1;
+ gcc_assert (derived1 && derived2);
+
/* Special case for comparing derived types across namespaces. If the
true names and module names are the same and the module name is
nonnull, then they are equal. */
- if (derived1 != NULL && derived2 != NULL
- && strcmp (derived1->name, derived2->name) == 0
+ if (strcmp (derived1->name, derived2->name) == 0
&& derived1->module != NULL && derived2->module != NULL
&& strcmp (derived1->module, derived2->module) == 0)
return 1;
/* Compare type via the rules of the standard. Both types must have
the SEQUENCE or BIND(C) attribute to be equal. */
if (strcmp (derived1->name, derived2->name))
return 0;
if (derived1->component_access == ACCESS_PRIVATE
@@ -2259,24 +2260,23 @@ get_expr_storage_size (gfc_expr *e)
else
return 0;
}
else if (ref->u.ar.as->upper[i]
&& ref->u.ar.as->upper[i]->expr_type == EXPR_CONSTANT)
end = mpz_get_si (ref->u.ar.as->upper[i]->value.integer);
else
return 0;
elements *= (end - start)/stride + 1L;
}
- else if (ref->type == REF_ARRAY && ref->u.ar.type == AR_FULL
- && ref->u.ar.as->lower && ref->u.ar.as->upper)
+ else if (ref->type == REF_ARRAY && ref->u.ar.type == AR_FULL)
for (i = 0; i < ref->u.ar.as->rank; i++)
{
if (ref->u.ar.as->lower[i] && ref->u.ar.as->upper[i]
&& ref->u.ar.as->lower[i]->expr_type == EXPR_CONSTANT
&& ref->u.ar.as->upper[i]->expr_type == EXPR_CONSTANT)
elements *= mpz_get_si (ref->u.ar.as->upper[i]->value.integer)
- mpz_get_si (ref->u.ar.as->lower[i]->value.integer)
+ 1L;
else
return 0;
}
@@ -7419,23 +7419,23 @@ check_symbols:
for (i = ar->dimen; i < ar->codimen + ar->dimen; i++)
{
if (ar->dimen_type[i] == DIMEN_ELEMENT
|| ar->dimen_type[i] == DIMEN_RANGE)
{
if (i == (ar->dimen + ar->codimen - 1))
{
gfc_error ("Expected '*' in coindex specification in ALLOCATE "
"statement at %L", &e->where);
goto failure;
}
- break;
+ continue;
}
if (ar->dimen_type[i] == DIMEN_STAR && i == (ar->dimen + ar->codimen - 1)
&& ar->stride[i] == NULL)
break;
gfc_error ("Bad coarray specification in ALLOCATE statement at %L",
&e->where);
goto failure;
}
@@ -117,25 +117,28 @@ gfc_target_expr_size (gfc_expr *e)
}
else
return 0;
case BT_HOLLERITH:
return e->representation.length;
case BT_DERIVED:
{
/* Determine type size without clobbering the typespec for ISO C
binding types. */
gfc_typespec ts;
+ HOST_WIDE_INT size;
ts = e->ts;
type = gfc_typenode_for_spec (&ts);
- return int_size_in_bytes (type);
+ size = int_size_in_bytes (type);
+ gcc_assert (size >= 0);
+ return size;
}
default:
gfc_internal_error ("Invalid expression in gfc_target_expr_size.");
return 0;
}
}
/* The encode_* functions export a value into a buffer, and
return the number of bytes of the buffer that have been
used. */