17 changes: 3 additions & 14 deletions src/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "init.h"
#include "import.h"
#include "id.h"
#include "hdrgen.h"

class ToJsonVisitor : public Visitor
{
Expand Down Expand Up @@ -343,21 +344,9 @@ class ToJsonVisitor : public Visitor

while (stc)
{
const size_t BUFFER_LEN = 20;
char tmp[BUFFER_LEN];
const char *p = StorageClassDeclaration::stcToChars(tmp, stc);
const char *p = stcToChars(stc);
assert(p);
assert(strlen(p) < BUFFER_LEN);
if (p[0] == '@')
{
indent();
stringStart();
buf->writestring(p);
stringEnd();
comma();
}
else
item(p);
item(p);
}

arrayEnd();
Expand Down
2 changes: 2 additions & 0 deletions src/magicport.json
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,8 @@
"function toCBufferDsymbol*OutBuffer*HdrGenState*",
"function toCBufferInstance",
"function toCBufferInitializer*OutBuffer*HdrGenState*",
"function stcToBuffer",
"function stcToChars",
"function trustToBuffer",
"function trustToChars",
"function linkageToBuffer",
Expand Down
20 changes: 5 additions & 15 deletions src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,9 +976,7 @@ StorageClass Parser::appendStorageClass(StorageClass storageClass, StorageClass
(stc & STCin && storageClass & (STCconst | STCscope)))
{
OutBuffer buf;
StorageClassDeclaration::stcToCBuffer(&buf, stc);
if (buf.data[buf.offset - 1] == ' ')
buf.data[buf.offset - 1] = '\0';
stcToBuffer(&buf, stc);
if (deprec)
deprecation("redundant attribute '%s'", buf.peekString());
else
Expand Down Expand Up @@ -1636,9 +1634,7 @@ Dsymbol *Parser::parseStaticCtor(PrefixAttributes *pAttrs)
else if (StorageClass modStc = stc & STC_TYPECTOR)
{
OutBuffer buf;
StorageClassDeclaration::stcToCBuffer(&buf, modStc);
if (buf.data[buf.offset - 1] == ' ')
buf.data[buf.offset - 1] = '\0';
stcToBuffer(&buf, modStc);
error(loc, "static constructor cannot be %s", buf.peekString());
}
stc &= ~(STCstatic | STC_TYPECTOR);
Expand Down Expand Up @@ -1676,9 +1672,7 @@ Dsymbol *Parser::parseStaticDtor(PrefixAttributes *pAttrs)
else if (StorageClass modStc = stc & STC_TYPECTOR)
{
OutBuffer buf;
StorageClassDeclaration::stcToCBuffer(&buf, modStc);
if (buf.data[buf.offset - 1] == ' ')
buf.data[buf.offset - 1] = '\0';
stcToBuffer(&buf, modStc);
error(loc, "static destructor cannot be %s", buf.peekString());
}
stc &= ~(STCstatic | STC_TYPECTOR);
Expand Down Expand Up @@ -1720,9 +1714,7 @@ Dsymbol *Parser::parseSharedStaticCtor(PrefixAttributes *pAttrs)
else if (StorageClass modStc = stc & STC_TYPECTOR)
{
OutBuffer buf;
StorageClassDeclaration::stcToCBuffer(&buf, modStc);
if (buf.data[buf.offset - 1] == ' ')
buf.data[buf.offset - 1] = '\0';
stcToBuffer(&buf, modStc);
error(loc, "shared static constructor cannot be %s", buf.peekString());
}
stc &= ~(STCstatic | STC_TYPECTOR);
Expand Down Expand Up @@ -1759,9 +1751,7 @@ Dsymbol *Parser::parseSharedStaticDtor(PrefixAttributes *pAttrs)
else if (StorageClass modStc = stc & STC_TYPECTOR)
{
OutBuffer buf;
StorageClassDeclaration::stcToCBuffer(&buf, modStc);
if (buf.data[buf.offset - 1] == ' ')
buf.data[buf.offset - 1] = '\0';
stcToBuffer(&buf, modStc);
error(loc, "shared static destructor cannot be %s", buf.peekString());
}
stc &= ~(STCstatic | STC_TYPECTOR);
Expand Down