From f52a4cef73d7e4ce2d0f5d2a1446001c2a7588be Mon Sep 17 00:00:00 2001 From: Stanislav Gromov Date: Sun, 23 May 2021 17:04:21 +0700 Subject: [PATCH] Allow a combination of `const static` to declare constants limited to the scope of the current file --- source/compiler/sc1.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 8f2dea2..cedcbcb 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -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); }