Allow a combination of const static to declare constants limited to the scope of the current file

This commit is contained in:
Stanislav Gromov 2021-05-23 17:04:21 +07:00 committed by Y_Less
parent d87fb6ceb2
commit f52a4cef73

View File

@ -3016,8 +3016,10 @@ static void decl_const(int vclass)
char *str;
int tag,exprtag;
int symbolline;
int fstatic;
symbol *sym;
fstatic=(vclass==sGLOBAL && matchtoken(tSTATIC));
insert_docstring_separator(); /* see comment in newfunc() */
do {
tag=pc_addtag(NULL);
@ -3030,8 +3032,11 @@ static void decl_const(int vclass)
/* add_constant() checks for duplicate definitions */
check_tagmismatch(tag,exprtag,FALSE,symbolline);
sym=add_constant(constname,val,vclass,tag);
if (sym!=NULL)
if (sym!=NULL) {
if (fstatic)
sym->fnumber=fcurrent;
sc_attachdocumentation(sym);/* attach any documentation to the constant */
} /* if */
} while (matchtoken(',')); /* enddo */ /* more? */
needtoken(tTERM);
}