------- Comment #4 from kargl at gcc dot gnu dot org 2009-09-10 02:43 ------- (In reply to comment #2) > (In reply to comment #1) > > Thus the question is: Why is the last expr == NULL and not EXPR_VARIABLE of > > flavour FL_PARAMETER? > > gfc_match_rvalue replaces parameters with their values: > case FL_PARAMETER: > /* A statement of the form "REAL, parameter :: a(0:10) = 1" will > end up here. Unfortunately, sym->value->expr_type is set to > EXPR_CONSTANT, and so the if () branch would be followed without > the !sym->as check. */ > if (sym->value && sym->value->expr_type != EXPR_ARRAY && !sym->as) > e = gfc_copy_expr (sym->value); > > Then why is the value a NULL expr? > Because that's how we recognise c_null(_fun)?_ptr at resolution time. > See the comment in gen_special_c_interop_ptr: > /* Create a constructor with no expr, that way we can recognize if the user > tries to call the structure constructor for one of the iso_c_binding > derived types during resolution (resolve_structure_cons). */ > tmp_sym->value->value.constructor = gfc_get_constructor (); > So, it's a feature ;) > > Tried a bit, but no idea how to fix it. >
I haven't looked at the bug yet, but I would have guessed that we could use some combination of attr->pointer and ts->iso_c_interop etc to special case this situation. There is also the possibility to encapsulate the iso_c_binding stuff in gfc_typespec into a new struct and add an entity to denote this situation. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41298