https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41922
--- Comment #3 from kargl at gcc dot gnu.org --- Index: target-memory.h =================================================================== --- target-memory.h (revision 237855) +++ target-memory.h (working copy) @@ -44,7 +44,7 @@ int gfc_interpret_derived (unsigned char int gfc_target_interpret_expr (unsigned char *, size_t, gfc_expr *, bool); /* Merge overlapping equivalence initializers for trans-common.c. */ -size_t gfc_merge_initializers (gfc_typespec, gfc_expr *, +size_t gfc_merge_initializers (gfc_typespec, gfc_expr *, locus *, unsigned char *, unsigned char *, size_t); Index: target-memory.c =================================================================== --- target-memory.c (revision 237855) +++ target-memory.c (working copy) @@ -639,7 +639,8 @@ gfc_target_interpret_expr (unsigned char error. */ static size_t -expr_to_char (gfc_expr *e, unsigned char *data, unsigned char *chk, size_t len) +expr_to_char (gfc_expr *e, locus *loc, + unsigned char *data, unsigned char *chk, size_t len) { int i; int ptr; @@ -663,7 +664,7 @@ expr_to_char (gfc_expr *e, unsigned char continue; ptr = TREE_INT_CST_LOW(DECL_FIELD_OFFSET(cmp->backend_decl)) + TREE_INT_CST_LOW(DECL_FIELD_BIT_OFFSET(cmp->backend_decl))/8; - expr_to_char (c->expr, &data[ptr], &chk[ptr], len); + expr_to_char (c->expr, loc, &data[ptr], &chk[ptr], len); } return len; } @@ -674,12 +675,16 @@ expr_to_char (gfc_expr *e, unsigned char buffer = (unsigned char*)alloca (len); len = gfc_target_encode_expr (e, buffer, len); - for (i = 0; i < (int)len; i++) + for (i = 0; i < (int)len; i++) { if (chk[i] && (buffer[i] != data[i])) { - gfc_error ("Overlapping unequal initializers in EQUIVALENCE " - "at %L", &e->where); + if (loc) + gfc_error ("Overlapping unequal initializers in EQUIVALENCE " + "at %L", loc); + else + gfc_error ("Overlapping unequal initializers in EQUIVALENCE " + "at %C"); return 0; } chk[i] = 0xFF; @@ -695,7 +700,8 @@ expr_to_char (gfc_expr *e, unsigned char the union declaration. */ size_t -gfc_merge_initializers (gfc_typespec ts, gfc_expr *e, unsigned char *data, +gfc_merge_initializers (gfc_typespec ts, gfc_expr *e, locus *loc, + unsigned char *data, unsigned char *chk, size_t length) { size_t len = 0; @@ -705,8 +711,7 @@ gfc_merge_initializers (gfc_typespec ts, { case EXPR_CONSTANT: case EXPR_STRUCTURE: - len = expr_to_char (e, &data[0], &chk[0], length); - + len = expr_to_char (e, loc, &data[0], &chk[0], length); break; case EXPR_ARRAY: @@ -718,7 +723,7 @@ gfc_merge_initializers (gfc_typespec ts, if (mpz_cmp_si (c->offset, 0) != 0) len = elt_size * (size_t)mpz_get_si (c->offset); - len = len + gfc_merge_initializers (ts, c->expr, &data[len], + len = len + gfc_merge_initializers (ts, c->expr, loc, &data[len], &chk[len], length - len); } break; Index: trans-common.c =================================================================== --- trans-common.c (revision 237855) +++ trans-common.c (working copy) @@ -532,10 +532,15 @@ get_init_field (segment_info *head, tree memset (chk, '\0', (size_t)length); for (s = head; s; s = s->next) if (s->sym->value) - gfc_merge_initializers (s->sym->ts, s->sym->value, + { + locus *loc = NULL; + if (s->sym->ns->equiv && s->sym->ns->equiv->eq) + loc = &s->sym->ns->equiv->eq->expr->where; + gfc_merge_initializers (s->sym->ts, s->sym->value, loc, &data[s->offset], &chk[s->offset], (size_t)s->length); + } for (i = 0; i < length; i++) CONSTRUCTOR_APPEND_ELT (v, NULL, build_int_cst (type, data[i]));