mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00
parent
1b9bc74edc
commit
cc21914461
4 changed files with 17 additions and 3 deletions
|
@ -8978,6 +8978,7 @@ struct Id final
|
||||||
static Identifier* getLocation;
|
static Identifier* getLocation;
|
||||||
static Identifier* hasPostblit;
|
static Identifier* hasPostblit;
|
||||||
static Identifier* hasCopyConstructor;
|
static Identifier* hasCopyConstructor;
|
||||||
|
static Identifier* hasMoveConstructor;
|
||||||
static Identifier* isCopyable;
|
static Identifier* isCopyable;
|
||||||
static Identifier* toType;
|
static Identifier* toType;
|
||||||
static Identifier* parameters;
|
static Identifier* parameters;
|
||||||
|
|
|
@ -519,6 +519,7 @@ immutable Msgtable[] msgtable =
|
||||||
{ "getLocation" },
|
{ "getLocation" },
|
||||||
{ "hasPostblit" },
|
{ "hasPostblit" },
|
||||||
{ "hasCopyConstructor" },
|
{ "hasCopyConstructor" },
|
||||||
|
{ "hasMoveConstructor" },
|
||||||
{ "isCopyable" },
|
{ "isCopyable" },
|
||||||
{ "toType" },
|
{ "toType" },
|
||||||
{ "parameters" },
|
{ "parameters" },
|
||||||
|
|
|
@ -544,7 +544,9 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
|
||||||
}
|
}
|
||||||
return True();
|
return True();
|
||||||
}
|
}
|
||||||
if (e.ident == Id.hasCopyConstructor || e.ident == Id.hasPostblit)
|
if (e.ident == Id.hasCopyConstructor ||
|
||||||
|
e.ident == Id.hasMoveConstructor ||
|
||||||
|
e.ident == Id.hasPostblit)
|
||||||
{
|
{
|
||||||
if (dim != 1)
|
if (dim != 1)
|
||||||
return dimError(1);
|
return dimError(1);
|
||||||
|
@ -562,8 +564,14 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
|
||||||
auto ts = tb.isTypeStruct();
|
auto ts = tb.isTypeStruct();
|
||||||
if (auto sd = ts ? ts.sym : null)
|
if (auto sd = ts ? ts.sym : null)
|
||||||
{
|
{
|
||||||
return (e.ident == Id.hasPostblit) ? (sd.postblit ? True() : False())
|
bool result;
|
||||||
: (sd.hasCopyCtor ? True() : False());
|
if (e.ident == Id.hasPostblit)
|
||||||
|
result = sd.postblit !is null;
|
||||||
|
else if (e.ident == Id. hasCopyConstructor)
|
||||||
|
result = sd.hasCopyCtor;
|
||||||
|
else
|
||||||
|
result = sd.hasMoveCtor;
|
||||||
|
return result ? True() : False();
|
||||||
}
|
}
|
||||||
return False();
|
return False();
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,6 +137,8 @@ struct DisabledPostblit
|
||||||
struct NoCpCtor { }
|
struct NoCpCtor { }
|
||||||
class C19902 { }
|
class C19902 { }
|
||||||
|
|
||||||
|
struct MoveCtor { this(MoveCtor) { } }
|
||||||
|
|
||||||
static assert(__traits(hasCopyConstructor, S));
|
static assert(__traits(hasCopyConstructor, S));
|
||||||
static assert(__traits(hasCopyConstructor, OuterS.S));
|
static assert(__traits(hasCopyConstructor, OuterS.S));
|
||||||
static assert(__traits(hasCopyConstructor, OuterS));
|
static assert(__traits(hasCopyConstructor, OuterS));
|
||||||
|
@ -147,6 +149,8 @@ static assert(__traits(hasCopyConstructor, U!S));
|
||||||
static assert(!__traits(hasPostblit, U!S));
|
static assert(!__traits(hasPostblit, U!S));
|
||||||
static assert(__traits(hasPostblit, SPostblit));
|
static assert(__traits(hasPostblit, SPostblit));
|
||||||
static assert(!__traits(hasCopyConstructor, SPostblit));
|
static assert(!__traits(hasCopyConstructor, SPostblit));
|
||||||
|
static assert(__traits(hasMoveConstructor, MoveCtor));
|
||||||
|
static assert(!__traits(hasMoveConstructor, NoCpCtor));
|
||||||
|
|
||||||
static assert(!__traits(hasCopyConstructor, NoCpCtor));
|
static assert(!__traits(hasCopyConstructor, NoCpCtor));
|
||||||
static assert(!__traits(hasCopyConstructor, C19902));
|
static assert(!__traits(hasCopyConstructor, C19902));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue