Skip to content

Commit

Permalink
Merge pull request #17105 from dkorpel/hdrgen-ctor-scope
Browse files Browse the repository at this point in the history
Fix bugzilla 24891 - Two scope attributes emitted as part of .di gene…
  • Loading branch information
dkorpel authored Dec 5, 2024
2 parents 6877e10 + 869ed9c commit 92bee16
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/src/dmd/hdrgen.d
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,10 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
void visitFuncDeclaration(FuncDeclaration f)
{
//printf("FuncDeclaration::toCBuffer() '%s'\n", f.toChars());
if (stcToBuffer(buf, f.storage_class))

// https://issues.dlang.org/show_bug.cgi?id=24891
// return/scope storage classes are printed as part of function type
if (stcToBuffer(buf, f.storage_class & ~(STC.scope_ | STC.return_ | STC.returnScope)))
buf.writeByte(' ');
typeToBuffer(f.type, f.ident, buf, hgs);
auto tf = f.type.isTypeFunction();
Expand Down
5 changes: 5 additions & 0 deletions compiler/test/compilable/extra-files/header1.d
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,11 @@ ref int* foo(scope return ref int* a) @safe

struct SafeS
{
this(int[1] x) scope {}
this(int[2] x) return scope {}
this(int[3] x) scope return {}
this(int[4] x) return {}

@safe:
ref SafeS foo() return
{
Expand Down
4 changes: 4 additions & 0 deletions compiler/test/compilable/extra-files/header1.di
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ ref @safe int foo(return ref int a);
ref @safe int* foo(return ref scope int* a);
struct SafeS
{
this(int[1] x) scope;
this(int[2] x) return scope;
this(int[3] x) scope return;
this(int[4] x) return;
@safe
{
ref SafeS foo() return;
Expand Down
12 changes: 12 additions & 0 deletions compiler/test/compilable/extra-files/header1i.di
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,18 @@ ref @safe int* foo(return ref scope int* a)
}
struct SafeS
{
this(int[1] x) scope
{
}
this(int[2] x) return scope
{
}
this(int[3] x) scope return
{
}
this(int[4] x) return
{
}
@safe
{
ref SafeS foo() return
Expand Down

0 comments on commit 92bee16

Please sign in to comment.