[.di generation] Show TypeCtor method attributes after parameters (#16732)

* [.di generation] Show TypeCtor method attributes after parameters

Follow up to https://github.com/dlang/dmd/pull/16708.

* Add changelog
This commit is contained in:
Nick Treleaven 2024-07-20 15:01:45 +01:00 committed by GitHub
parent ead6df018a
commit 3c13c3c548
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 29 additions and 16 deletions

View file

@ -0,0 +1,13 @@
Postfix type qualifier method attributes for `-H` and `-D`
`.di` interface file generation and Ddoc output will now have type qualifier
attributes placed after the parameter list for methods (and constructors).
This avoids confusion with the return type.
---
struct S
{
const int f(); // before
int f() const; // now
}
---

View file

@ -3927,7 +3927,7 @@ private void visitFuncIdentWithPrefix(TypeFunction t, const Identifier ident, Te
/* Use 'storage class' (prefix) style for attributes
*/
if (t.mod && !hgs.ddoc)
if (t.mod && !(hgs.ddoc || hgs.hdrgen))
{
MODtoBuffer(buf, t.mod);
buf.writeByte(' ');
@ -3977,8 +3977,8 @@ private void visitFuncIdentWithPrefix(TypeFunction t, const Identifier ident, Te
buf.writeByte(')');
}
parametersToBuffer(t.parameterList, buf, hgs);
// postfix TypeCtor attributes are more readable
if (t.mod && hgs.ddoc)
// postfix this attributes are more readable
if (t.mod && (hgs.ddoc || hgs.hdrgen))
{
buf.writeByte(' ');
MODtoBuffer(buf, t.mod);

View file

@ -359,8 +359,8 @@ int bar11(T)()
}
struct S6360
{
const pure nothrow @property long weeks1();
const pure nothrow @property long weeks2();
pure nothrow @property long weeks1() const;
pure nothrow @property long weeks2() const;
}
struct S12
{
@ -369,10 +369,10 @@ struct S12
}
struct T12
{
immutable this()(int args)
this()(int args) immutable
{
}
immutable this(A...)(A args)
this(A...)(A args) immutable
{
}
}
@ -502,7 +502,7 @@ size_t magic();
class Foo2A
{
immutable(FooA) Dummy = new immutable(FooA);
private immutable pure nothrow @nogc @safe this();
private pure nothrow @nogc @safe this() immutable;
}
struct Foo3A(T)
{
@ -560,4 +560,4 @@ interface I12344
assert(result > 0);
}
;
}
}

View file

@ -452,11 +452,11 @@ int bar11(T)()
}
struct S6360
{
const pure nothrow @property long weeks1()
pure nothrow @property long weeks1() const
{
return 0;
}
const pure nothrow @property long weeks2()
pure nothrow @property long weeks2() const
{
return 0;
}
@ -472,10 +472,10 @@ struct S12
}
struct T12
{
immutable this()(int args)
this()(int args) immutable
{
}
immutable this(A...)(A args)
this(A...)(A args) immutable
{
}
}
@ -624,7 +624,7 @@ size_t magic()
class Foo2A
{
immutable(FooA) Dummy = new immutable(FooA);
private immutable pure nothrow @nogc @safe this()
private pure nothrow @nogc @safe this() immutable
{
}
}
@ -715,4 +715,4 @@ interface I12344
assert(result > 0);
}
;
}
}

View file

@ -13,7 +13,7 @@ struct FullCaseEntry
ubyte n;
ubyte size;
ubyte entry_len;
auto const pure nothrow @nogc @property @trusted value() return
auto pure nothrow @nogc @property @trusted value() const return
{
return seq[0..entry_len];
}