From 5a0fd0fda19ab2449827853dbeddfd6e024fa080 Mon Sep 17 00:00:00 2001 From: Yashas Date: Sun, 7 Jan 2018 20:19:05 +0530 Subject: [PATCH] fixes inconsistencies with the tagof operator The standalone tagof operator tries to export tall tags which it works with. The tagof operator when used as a default argument checks if the tag is zero before exporting. As the zero tag identifier cannot be exported (even if its `PUBLICTAG` bit is set), it makes sense to use `0` as tag identifier instead of `0 | PUBLICTAG`. This commit changes the standalone tagof operator behaviour so that the zero tag identifier does not get its `PUBLICTAG` bit set. --- source/compiler/sc3.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/compiler/sc3.c b/source/compiler/sc3.c index 3421f468..adc40d9f 100644 --- a/source/compiler/sc3.c +++ b/source/compiler/sc3.c @@ -1424,10 +1424,13 @@ static int hier2(value *lval) else if (level==sym->dim.array.level+1 && idxsym!=NULL) tag=idxsym->x.tags.index; } /* if */ - exporttag(tag); + if (tag!=0) { + exporttag(tag); + tag |= PUBLICTAG; + } /* if */ clear_value(lval); lval->ident=iCONSTEXPR; - lval->constval=tag | PUBLICTAG; + lval->constval=tag; ldconst(lval->constval,sPRI); while (paranthese--) needtoken(')');