Skip to content

Commit

Permalink
hdrgen: remove trailing whitespace on attribute declarations
Browse files Browse the repository at this point in the history
Fixes Issue 22353.

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
  • Loading branch information
ljmf00 authored and dlang-bot committed Oct 5, 2021
1 parent 72c288b commit 5394ae6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/dmd/hdrgen.d
Expand Up @@ -909,6 +909,12 @@ public:

override void visit(AttribDeclaration d)
{
bool hasSTC;
if (auto stcd = d.isStorageClassDeclaration)
{
hasSTC = stcToBuffer(buf, stcd.stc);
}

if (!d.decl)
{
buf.writeByte(';');
Expand All @@ -918,10 +924,12 @@ public:
if (d.decl.dim == 0 || (hgs.hdrgen && d.decl.dim == 1 && (*d.decl)[0].isUnitTestDeclaration()))
{
// hack for bugzilla 8081
if (hasSTC) buf.writeByte(' ');
buf.writestring("{}");
}
else if (d.decl.dim == 1)
{
if (hasSTC) buf.writeByte(' ');
(*d.decl)[0].accept(this);
return;
}
Expand All @@ -941,8 +949,6 @@ public:

override void visit(StorageClassDeclaration d)
{
if (stcToBuffer(buf, d.stc))
buf.writeByte(' ');
visit(cast(AttribDeclaration)d);
}

Expand Down
2 changes: 1 addition & 1 deletion test/compilable/extra-files/header1.di
Expand Up @@ -511,7 +511,7 @@ ref @safe int foo(return ref int a);
ref @safe int* foo(return ref scope int* a);
struct SafeS
{
@safe
@safe
{
ref SafeS foo() return;
scope SafeS foo2() return;
Expand Down
2 changes: 1 addition & 1 deletion test/compilable/extra-files/header1i.di
Expand Up @@ -647,7 +647,7 @@ ref @safe int* foo(return ref scope int* a)
}
struct SafeS
{
@safe
@safe
{
ref SafeS foo() return
{
Expand Down

0 comments on commit 5394ae6

Please sign in to comment.