diff --git a/compiler/src/dmd/clone.d b/compiler/src/dmd/clone.d index 971e8020d1..d7658c68ec 100644 --- a/compiler/src/dmd/clone.d +++ b/compiler/src/dmd/clone.d @@ -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 diff --git a/compiler/test/compilable/cppmangle.d b/compiler/test/compilable/cppmangle.d index 4b9046e811..c6c921d7b0 100644 --- a/compiler/test/compilable/cppmangle.d +++ b/compiler/test/compilable/cppmangle.d @@ -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 diff --git a/compiler/test/compilable/testInference.d b/compiler/test/compilable/testInference.d index bddbaf4294..5091b99896 100644 --- a/compiler/test/compilable/testInference.d +++ b/compiler/test/compilable/testInference.d @@ -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; +}