mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00
fix #20686 infer attributes for generated functions
This commit is contained in:
parent
aa56a318eb
commit
10eb368c1b
3 changed files with 29 additions and 3 deletions
|
@ -269,7 +269,7 @@ FuncDeclaration buildOpAssign(StructDeclaration sd, Scope* sc)
|
|||
return null;
|
||||
|
||||
//printf("StructDeclaration::buildOpAssign() %s\n", sd.toChars());
|
||||
StorageClass stc = STC.safe | STC.nothrow_ | STC.pure_ | STC.nogc;
|
||||
StorageClass stc = STC.safe;
|
||||
Loc declLoc = sd.loc;
|
||||
Loc loc; // internal code should have no loc to prevent coverage
|
||||
|
||||
|
@ -1278,7 +1278,7 @@ FuncDeclaration buildPostBlit(StructDeclaration sd, Scope* sc)
|
|||
const hasUserDefinedPosblit = sd.postblits.length && !sd.postblits[0].isDisabled ? true : false;
|
||||
|
||||
// by default, the storage class of the created postblit
|
||||
StorageClass stc = STC.safe | STC.nothrow_ | STC.pure_ | STC.nogc;
|
||||
StorageClass stc = STC.safe;
|
||||
Loc declLoc = sd.postblits.length ? sd.postblits[0].loc : sd.loc;
|
||||
Loc loc; // internal code should have no loc to prevent coverage
|
||||
|
||||
|
@ -1380,6 +1380,7 @@ FuncDeclaration buildPostBlit(StructDeclaration sd, Scope* sc)
|
|||
// perform semantic on the member postblit in order to
|
||||
// be able to aggregate it later on with the rest of the
|
||||
// postblits
|
||||
sdv.postblit.isGenerated = true;
|
||||
functionSemantic(sdv.postblit);
|
||||
|
||||
stc = mergeFuncAttrs(stc, sdv.postblit);
|
||||
|
@ -1445,6 +1446,7 @@ FuncDeclaration buildPostBlit(StructDeclaration sd, Scope* sc)
|
|||
*/
|
||||
if (sdv.dtor)
|
||||
{
|
||||
sdv.dtor.isGenerated = true;
|
||||
functionSemantic(sdv.dtor);
|
||||
|
||||
// keep a list of fields that need to be destroyed in case
|
||||
|
|
|
@ -666,6 +666,8 @@ extern (C++) class C18890_2
|
|||
Agg s;
|
||||
}
|
||||
|
||||
void test18890()
|
||||
{
|
||||
version (CppMangle_Itanium)
|
||||
{
|
||||
static assert(C18890.__dtor.mangleof == "_ZN6C18890D1Ev");
|
||||
|
@ -690,6 +692,7 @@ version (CppMangle_MSVC)
|
|||
static assert(C18890_2.__xdtor.mangleof == "??_GC18890_2@@UEAAPEAXI@Z");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************/
|
||||
// https://issues.dlang.org/show_bug.cgi?id=18891
|
||||
|
@ -704,6 +707,8 @@ extern (C++) class C18891
|
|||
Agg s;
|
||||
}
|
||||
|
||||
void test18891()
|
||||
{
|
||||
version (CppMangle_Itanium)
|
||||
{
|
||||
static assert(C18891.__dtor.mangleof == "_ZN6C18891D1Ev");
|
||||
|
@ -722,6 +727,7 @@ version (CppMangle_MSVC)
|
|||
static assert(C18891.__xdtor.mangleof == "??_GC18891@@UEAAPEAXI@Z");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************/
|
||||
// Test C++ operator mangling
|
||||
|
|
|
@ -817,4 +817,22 @@ void test13840() nothrow
|
|||
{}
|
||||
}
|
||||
|
||||
// Add more tests regarding inferences later.
|
||||
/***************************************************/
|
||||
// https://github.com/dlang/dmd/pull/20685
|
||||
|
||||
struct T1
|
||||
{
|
||||
int a;
|
||||
inout this(ref inout T1 t) @nogc nothrow pure { a = t.a; }
|
||||
}
|
||||
|
||||
struct S1
|
||||
{
|
||||
T1 t; // generate copy constructor, infer @nogc nothrow pure
|
||||
}
|
||||
|
||||
void test1() @nogc nothrow pure
|
||||
{
|
||||
S1 s;
|
||||
S1 t = s;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue