[Bug fortran/58331] [OOP] Bogus rank checking with explicit-/assumed-size arrays and CLASS
anlauf at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Mar 6 22:13:28 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58331
--- Comment #5 from anlauf at gcc dot gnu.org ---
The previous patch would accept invalid code, as it would miss assumed-shape.
Fixed by the additional:
@@ -2650,10 +2669,14 @@ compare_parameter (gfc_symbol *formal, gfc_expr
*actual,
if (symbol_rank (formal) == actual->rank || symbol_rank (formal) == -1)
return true;
- rank_check = where != NULL && !is_elemental && formal->as
- && (formal->as->type == AS_ASSUMED_SHAPE
- || formal->as->type == AS_DEFERRED)
- && actual->expr_type != EXPR_NULL;
+ gfc_array_spec *formal_as;
+ formal_as = formal->ts.type == BT_CLASS ? CLASS_DATA (formal)->as
+ : formal->as;
+
+ rank_check = where != NULL && !is_elemental && formal_as
+ && (formal_as->type == AS_ASSUMED_SHAPE
+ || formal_as->type == AS_DEFERRED)
+ && actual->expr_type != EXPR_NULL;
/* Skip rank checks for NO_ARG_CHECK. */
if (formal->attr.ext_attr & (1 << EXT_ATTR_NO_ARG_CHECK))
More information about the Gcc-bugs
mailing list