Skip to content

Commit a0c205d

Browse files
committed
Fix bug when type name is overloaded with generic.
In the <declaration> ::= TYPE <opt type spec> <opt attr> <pgm> <id> <opt tpsl> production, if <id> is a ST_USERGENERIC, then we need to obtain a new symbol for the derived type ST_TYPEDEF object and assign it to the generic's GTYPE field. This permits a type name to be overloaded by a generic.
1 parent 570569b commit a0c205d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/flang1/flang1exe/semant.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3250,7 +3250,14 @@ semant1(int rednum, SST *top)
32503250
dtype = sem.stag_dtype = DTYPEG(sptr);
32513251
DTY(sem.stag_dtype + 2) = 1; /* size */
32523252
} else {
3253-
sptr = declsym(sptr, ST_TYPEDEF, TRUE);
3253+
if (STYPEG(sptr) == ST_USERGENERIC) {
3254+
int origSym = sptr;
3255+
sptr = insert_sym(sptr);
3256+
STYPEP(sptr, ST_TYPEDEF);
3257+
GTYPEP(origSym, sptr);
3258+
} else {
3259+
sptr = declsym(sptr, ST_TYPEDEF, TRUE);
3260+
}
32543261
dtype = sem.stag_dtype = get_type(6, TY_DERIVED, NOSYM);
32553262
DTYPEP(sptr, sem.stag_dtype);
32563263
DTY(sem.stag_dtype + 2) = 1; /* size */

0 commit comments

Comments
 (0)