From 0fcb66e7d2b8d91da452dfbc64e5c695b0f6e7ae Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Thu, 2 Oct 2025 01:48:16 +1300 Subject: [PATCH 001/440] Fix null dereference in optional methods for objective-c test. (dlang/dmd!21926) --- tests/dmd/unit/objc/protocols/optional_methods.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dmd/unit/objc/protocols/optional_methods.d b/tests/dmd/unit/objc/protocols/optional_methods.d index 3a55bbcf7e..7350a9004a 100644 --- a/tests/dmd/unit/objc/protocols/optional_methods.d +++ b/tests/dmd/unit/objc/protocols/optional_methods.d @@ -216,7 +216,7 @@ unittest void main() { - Foo f; + Foo f = new Foo; f.foo(); } }.stripDelimited; From cb98ac6feac20c13de0c7cf2c51c176936aac9a0 Mon Sep 17 00:00:00 2001 From: ProgramGamer Date: Wed, 1 Oct 2025 13:19:00 -0400 Subject: [PATCH 002/440] Slightly improved description of `dup` and `idup` It's now easier to tell that idup stands for *immutable* duplicate from reading these descriptions if this is how you first encounter these function names. --- runtime/druntime/src/object.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/druntime/src/object.d b/runtime/druntime/src/object.d index f1f54bf283..96fd06b59e 100644 --- a/runtime/druntime/src/object.d +++ b/runtime/druntime/src/object.d @@ -3822,7 +3822,7 @@ private size_t getArrayHash(const scope TypeInfo element, const scope void* ptr, return hash; } -/// Provide the .dup array property. +/// Provide the .dup array property, which creates a duplicate. @property auto dup(T)(T[] a) if (!is(const(T) : T)) { @@ -3854,7 +3854,7 @@ private size_t getArrayHash(const scope TypeInfo element, const scope void* ptr, } -/// Provide the .idup array property. +/// Provide the .idup array property, which creates an immutable duplicate. @property immutable(T)[] idup(T)(T[] a) { import core.internal.array.duplication : _dup; From 6c2c0c4969ee3829c6052a5f4df13cd4484059d6 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Thu, 2 Oct 2025 11:01:20 +0300 Subject: [PATCH 003/440] Move `ClassReferenceExp.getFieldIndex` and `StructLiteralExp.getFieldIndex` to `dmd/expressionsem.d` (dlang/dmd!21931) --- dmd/ctfeexpr.d | 2 +- dmd/cxxfrontend.d | 6 +++++ dmd/expression.d | 55 +-------------------------------------------- dmd/expression.h | 1 + dmd/expressionsem.d | 53 +++++++++++++++++++++++++++++++++++++++++++ dmd/frontend.h | 1 - 6 files changed, 62 insertions(+), 56 deletions(-) diff --git a/dmd/ctfeexpr.d b/dmd/ctfeexpr.d index 367300bafa..1e7d0a4c71 100644 --- a/dmd/ctfeexpr.d +++ b/dmd/ctfeexpr.d @@ -25,7 +25,7 @@ import dmd.dstruct; import dmd.dtemplate; import dmd.errors; import dmd.expression; -import dmd.expressionsem : isIdentical; +import dmd.expressionsem : isIdentical, getFieldIndex; import dmd.func; import dmd.globals : dinteger_t, sinteger_t, uinteger_t; import dmd.location; diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 81d387d502..85edc1c8ac 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -398,6 +398,12 @@ bool equals(const Expression exp, const Expression e) return dmd.expressionsem.equals(exp, e); } +int getFieldIndex(ClassReferenceExp cre, Type fieldtype, uint fieldoffset) +{ + import dmd.expressionsem; + return dmd.expressionsem.getFieldIndex(cre, fieldtype, fieldoffset); +} + /*********************************************************** * func.d */ diff --git a/dmd/expression.d b/dmd/expression.d index cabf4533d5..818d2c2df1 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -51,7 +51,7 @@ import dmd.root.string; import dmd.root.utf; import dmd.target; import dmd.tokens; -import dmd.typesem : size, mutableOf, unSharedOf; +import dmd.typesem : mutableOf, unSharedOf; import dmd.visitor; enum LOGSEMANTIC = false; @@ -1994,38 +1994,6 @@ extern (C++) final class StructLiteralExp : Expression return exp; } - /************************************ - * Get index of field. - * Returns -1 if not found. - */ - extern (D) int getFieldIndex(Type type, uint offset) - { - /* Find which field offset is by looking at the field offsets - */ - if (!elements.length) - return -1; - - const sz = type.size(); - if (sz == SIZE_INVALID) - return -1; - foreach (i, v; sd.fields) - { - if (offset != v.offset) - continue; - if (sz != v.type.size()) - continue; - /* context fields might not be filled. */ - if (i >= sd.nonHiddenFields()) - return cast(int)i; - if (auto e = (*elements)[i]) - { - return cast(int)i; - } - return -1; - } - assert(0); - } - override void accept(Visitor v) { v.visit(this); @@ -4667,27 +4635,6 @@ extern (C++) final class ClassReferenceExp : Expression return value.sd.isClassDeclaration(); } - // Return index of the field, or -1 if not found - int getFieldIndex(Type fieldtype, uint fieldoffset) - { - ClassDeclaration cd = originalClass(); - uint fieldsSoFar = 0; - for (size_t j = 0; j < value.elements.length; j++) - { - while (j - fieldsSoFar >= cd.fields.length) - { - fieldsSoFar += cd.fields.length; - cd = cd.baseClass; - } - VarDeclaration v2 = cd.fields[j - fieldsSoFar]; - if (fieldoffset == v2.offset && fieldtype.size() == v2.type.size()) - { - return cast(int)(value.elements.length - fieldsSoFar - cd.fields.length + (j - fieldsSoFar)); - } - } - return -1; - } - // Return index of the field, or -1 if not found // Same as getFieldIndex, but checks for a direct match with the VarDeclaration int findFieldIndexByName(VarDeclaration v) diff --git a/dmd/expression.h b/dmd/expression.h index bb5a24eabe..a89076feee 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -61,6 +61,7 @@ namespace dmd Expression *optimize(Expression *exp, int result, bool keepLvalue = false); bool isIdentical(const Expression *exp, const Expression *e); bool equals(const Expression *exp, const Expression *e); + int32_t getFieldIndex(ClassReferenceExp *cre, Type *fieldtype, uint32_t fieldoffset); } typedef unsigned char OwnedBy; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 0f9752a000..870ad52d46 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -96,6 +96,59 @@ import dmd.visitor.postorder; enum LOGSEMANTIC = false; +// Return index of the field, or -1 if not found +int getFieldIndex(ClassReferenceExp _this, Type fieldtype, uint fieldoffset) +{ + ClassDeclaration cd = _this.originalClass(); + uint fieldsSoFar = 0; + for (size_t j = 0; j < _this.value.elements.length; j++) + { + while (j - fieldsSoFar >= cd.fields.length) + { + fieldsSoFar += cd.fields.length; + cd = cd.baseClass; + } + VarDeclaration v2 = cd.fields[j - fieldsSoFar]; + if (fieldoffset == v2.offset && fieldtype.size() == v2.type.size()) + { + return cast(int)( _this.value.elements.length - fieldsSoFar - cd.fields.length + (j - fieldsSoFar)); + } + } + return -1; +} + +/************************************ + * Get index of field. + * Returns -1 if not found. + */ +int getFieldIndex(StructLiteralExp _this, Type type, uint offset) +{ + /* Find which field offset is by looking at the field offsets + */ + if (!_this.elements.length) + return -1; + + const sz = type.size(); + if (sz == SIZE_INVALID) + return -1; + foreach (i, v; _this.sd.fields) + { + if (offset != v.offset) + continue; + if (sz != v.type.size()) + continue; + /* context fields might not be filled. */ + if (i >= _this.sd.nonHiddenFields()) + return cast(int)i; + if (auto e = (*_this.elements)[i]) + { + return cast(int)i; + } + return -1; + } + assert(0); +} + bool equals(const Expression _this, const Expression e) { static bool intExpEquals(const IntegerExp _this, const IntegerExp e) diff --git a/dmd/frontend.h b/dmd/frontend.h index 148811ce3a..bb33b880f3 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2731,7 +2731,6 @@ class ClassReferenceExp final : public Expression public: StructLiteralExp* value; ClassDeclaration* originalClass(); - int32_t getFieldIndex(Type* fieldtype, uint32_t fieldoffset); int32_t findFieldIndexByName(VarDeclaration* v); void accept(Visitor* v) override; }; From 4f92c1d6932ee13c5e176a513a2712f861ff62b9 Mon Sep 17 00:00:00 2001 From: Emmanuel Nyarko <57257441+Emmankoko@users.noreply.github.com> Date: Sat, 4 Oct 2025 08:09:34 +0000 Subject: [PATCH 004/440] fix dlang/dmd!20433: ImportC:typeof in initializer expression at function scope errors with "circular typeof definition" (dlang/dmd!21934) --- dmd/dsymbolsem.d | 9 +++++++++ tests/dmd/runnable/fix20433.c | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/dmd/runnable/fix20433.c diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 0adccf8ec3..ba61f4dd08 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -2245,6 +2245,15 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor // Preset the required type to fail in FuncLiteralDeclaration::semantic3 ei.exp = inferType(ei.exp, dsym.type); + /* + * https://issues.dlang.org/show_bug.cgi?id=24474 + * at function scope, the compiler thinks the type of the variable is not known yet + * (semantically complete) so looks like typeof gets locked in a cyclic situation + * semantics is actually done. just set it for importc + */ + if (sc.func && dsym.type && dsym.type.deco && sc.inCfile) + dsym.semanticRun = PASS.semanticdone; + // If inside function, there is no semantic3() call if (sc.func || sc.intypeof == 1) { diff --git a/tests/dmd/runnable/fix20433.c b/tests/dmd/runnable/fix20433.c new file mode 100644 index 0000000000..0930db7491 --- /dev/null +++ b/tests/dmd/runnable/fix20433.c @@ -0,0 +1,15 @@ +//ImportC: typeof in initializer expression at function scope errors with "circular typeof definition" #20433 + + +#include +#include + +int x = sizeof(typeof(typeof(x))); // supported in C +int main() +{ + + int y = sizeof(typeof(y)); + assert(y == 4); + assert(x == 4); + +} From 3a53c4ea84044ba86aa6147ec1bfbbd3dfab88ad Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 4 Oct 2025 11:10:57 +0300 Subject: [PATCH 005/440] Break semantic dependency of `dmd/expression.d` on `dmd/typesem.d` (dlang/dmd!21935) --- dmd/canthrow.d | 2 +- dmd/cxxfrontend.d | 6 ++ dmd/expression.d | 164 -------------------------------------------- dmd/expression.h | 25 +------ dmd/expressionsem.d | 99 ++++++++++++++++++++++++++ dmd/frontend.h | 22 ------ 6 files changed, 107 insertions(+), 211 deletions(-) diff --git a/dmd/canthrow.d b/dmd/canthrow.d index bd4aa197ab..78c7ec6c01 100644 --- a/dmd/canthrow.d +++ b/dmd/canthrow.d @@ -23,7 +23,7 @@ import dmd.dsymbol; import dmd.dsymbolsem : include, toAlias; import dmd.errorsink; import dmd.expression; -import dmd.expressionsem : errorSupplementalInferredAttr; +import dmd.expressionsem : errorSupplementalInferredAttr, isLvalue; import dmd.func; import dmd.globals; import dmd.init; diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 85edc1c8ac..5e8e5e3417 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -398,6 +398,12 @@ bool equals(const Expression exp, const Expression e) return dmd.expressionsem.equals(exp, e); } +bool isLvalue(Expression exp) +{ + import dmd.expressionsem; + return dmd.expressionsem.isLvalue(exp); +} + int getFieldIndex(ClassReferenceExp cre, Type fieldtype, uint fieldoffset) { import dmd.expressionsem; diff --git a/dmd/expression.d b/dmd/expression.d index 818d2c2df1..64860e2250 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -51,7 +51,6 @@ import dmd.root.string; import dmd.root.utf; import dmd.target; import dmd.tokens; -import dmd.typesem : mutableOf, unSharedOf; import dmd.visitor; enum LOGSEMANTIC = false; @@ -508,14 +507,6 @@ extern (C++) abstract class Expression : ASTNode return null; } - /*************************************** - * Return !=0 if expression is an lvalue. - */ - bool isLvalue() - { - return false; - } - /**************************************** * Check that the expression has a valid type. * If not, generates an error "... has no type". @@ -1114,11 +1105,6 @@ extern (C++) class IdentifierExp : Expression return new IdentifierExp(loc, ident); } - override final bool isLvalue() - { - return !this.rvalue; - } - override void accept(Visitor v) { v.visit(this); @@ -1158,11 +1144,6 @@ extern (C++) final class DsymbolExp : Expression this.hasOverloads = hasOverloads; } - override bool isLvalue() - { - return !rvalue; - } - override void accept(Visitor v) { v.visit(this); @@ -1203,12 +1184,6 @@ extern (C++) class ThisExp : Expression return typeof(return)(true); } - override final bool isLvalue() - { - // Class `this` should be an rvalue; struct `this` should be an lvalue. - return !rvalue && type.toBasetype().ty != Tclass; - } - override void accept(Visitor v) { v.visit(this); @@ -1563,14 +1538,6 @@ extern (C++) final class StringExp : Expression return typeof(return)(true); } - override bool isLvalue() - { - /* string literal is rvalue in default, but - * conversion to reference of static array is only allowed. - */ - return !rvalue && (type && type.toBasetype().ty == Tsarray); - } - /******************************** * Convert string contents to a 0 terminated string, * allocated by mem.xmalloc(). @@ -2120,11 +2087,6 @@ extern (C++) final class TemplateExp : Expression this.fd = fd; } - override bool isLvalue() - { - return fd !is null; - } - override bool checkType() { error(loc, "%s `%s` has no type", td.kind(), toChars()); @@ -2303,13 +2265,6 @@ extern (C++) final class VarExp : SymbolExp return new VarExp(loc, var, hasOverloads); } - override bool isLvalue() - { - if (rvalue || var.storage_class & (STC.lazy_ | STC.rvalue | STC.manifest)) - return false; - return true; - } - override void accept(Visitor v) { v.visit(this); @@ -2331,11 +2286,6 @@ extern (C++) final class OverExp : Expression type = Type.tvoid; } - override bool isLvalue() - { - return true; - } - override void accept(Visitor v) { v.visit(this); @@ -2637,11 +2587,6 @@ extern (C++) class BinAssignExp : BinExp super(loc, op, e1, e2); } - override final bool isLvalue() - { - return !rvalue; - } - override void accept(Visitor v) { v.visit(this); @@ -2813,16 +2758,6 @@ extern (C++) final class DotVarExp : UnaExp this.hasOverloads = hasOverloads; } - override bool isLvalue() - { - if (rvalue) - return false; - if (e1.op != EXP.structLiteral) - return true; - auto vd = var.isVarDeclaration(); - return !(vd && vd.isField()); - } - override void accept(Visitor v) { v.visit(this); @@ -3038,24 +2973,6 @@ extern (C++) final class CallExp : UnaExp return new CallExp(loc, e1.syntaxCopy(), arraySyntaxCopy(arguments), names ? names.copy() : null); } - override bool isLvalue() - { - if (rvalue) - return false; - Type tb = e1.type.toBasetype(); - if (tb.ty == Tdelegate || tb.ty == Tpointer) - tb = tb.nextOf(); - auto tf = tb.isTypeFunction(); - if (tf && tf.isRef) - { - if (auto dve = e1.isDotVarExp()) - if (dve.var.isCtorDeclaration()) - return false; - return true; // function returns a reference - } - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -3164,11 +3081,6 @@ extern (C++) final class PtrExp : UnaExp type = t; } - override bool isLvalue() - { - return !rvalue; - } - override void accept(Visitor v) { v.visit(this); @@ -3295,16 +3207,6 @@ extern (C++) final class CastExp : UnaExp return to ? new CastExp(loc, e1.syntaxCopy(), to.syntaxCopy()) : new CastExp(loc, e1.syntaxCopy(), mod); } - override bool isLvalue() - { - //printf("e1.type = %s, to.type = %s\n", e1.type.toChars(), to.toChars()); - if (rvalue || !e1.isLvalue()) - return false; - return (to.ty == Tsarray && (e1.type.ty == Tvector || e1.type.ty == Tsarray)) || - (to.ty == Taarray && e1.type.ty == Taarray) || - e1.type.mutableOf.unSharedOf().equals(to.mutableOf().unSharedOf()); - } - override void accept(Visitor v) { v.visit(this); @@ -3354,11 +3256,6 @@ extern (C++) final class VectorArrayExp : UnaExp super(loc, EXP.vectorArray, e1); } - override bool isLvalue() - { - return !rvalue && e1.isLvalue(); - } - override void accept(Visitor v) { v.visit(this); @@ -3408,14 +3305,6 @@ extern (C++) final class SliceExp : UnaExp return se; } - override bool isLvalue() - { - /* slice expression is rvalue in default, but - * conversion to reference of static array is only allowed. - */ - return !rvalue && (type && type.toBasetype().ty == Tsarray); - } - override Optional!bool toBool() { return e1.toBool(); @@ -3477,15 +3366,6 @@ extern (C++) final class ArrayExp : UnaExp return ae; } - override bool isLvalue() - { - if (rvalue) - return false; - if (type && type.toBasetype().ty == Tvoid) - return false; - return true; - } - override void accept(Visitor v) { v.visit(this); @@ -3537,11 +3417,6 @@ extern (C++) final class CommaExp : BinExp originalExp = oe; } - override bool isLvalue() - { - return !rvalue && e2.isLvalue(); - } - override Optional!bool toBool() { return e2.toBool(); @@ -3612,11 +3487,6 @@ extern (C++) final class DelegatePtrExp : UnaExp super(loc, EXP.delegatePointer, e1); } - override bool isLvalue() - { - return !rvalue && e1.isLvalue(); - } - override void accept(Visitor v) { v.visit(this); @@ -3635,11 +3505,6 @@ extern (C++) final class DelegateFuncptrExp : UnaExp super(loc, EXP.delegateFunctionPointer, e1); } - override bool isLvalue() - { - return !rvalue && e1.isLvalue(); - } - override void accept(Visitor v) { v.visit(this); @@ -3676,19 +3541,6 @@ extern (C++) final class IndexExp : BinExp return ie; } - override bool isLvalue() - { - if (rvalue) - return false; - auto t1b = e1.type.toBasetype(); - if (t1b.isTypeAArray() || t1b.isTypeSArray() || - (e1.isIndexExp() && t1b != t1b.isTypeDArray())) - { - return e1.isLvalue(); - } - return true; - } - override void accept(Visitor v) { v.visit(this); @@ -3757,17 +3609,6 @@ extern (C++) class AssignExp : BinExp super(loc, tok, e1, e2); } - override final bool isLvalue() - { - // Array-op 'x[] = y[]' should make an rvalue. - // Setting array length 'x.length = v' should make an rvalue. - if (e1.op == EXP.slice || e1.op == EXP.arrayLength) - { - return false; - } - return !rvalue; - } - override void accept(Visitor v) { v.visit(this); @@ -4490,11 +4331,6 @@ extern (C++) final class CondExp : BinExp return new CondExp(loc, econd.syntaxCopy(), e1.syntaxCopy(), e2.syntaxCopy()); } - override bool isLvalue() - { - return !rvalue && e1.isLvalue() && e2.isLvalue(); - } - override void accept(Visitor v) { v.visit(this); diff --git a/dmd/expression.h b/dmd/expression.h index a89076feee..0855747326 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -61,6 +61,7 @@ namespace dmd Expression *optimize(Expression *exp, int result, bool keepLvalue = false); bool isIdentical(const Expression *exp, const Expression *e); bool equals(const Expression *exp, const Expression *e); + bool isLvalue(const Expression *exp); int32_t getFieldIndex(ClassReferenceExp *cre, Type *fieldtype, uint32_t fieldoffset); } @@ -103,7 +104,6 @@ class Expression : public ASTNode virtual real_t toImaginary(); virtual complex_t toComplex(); virtual StringExp *toStringExp(); - virtual bool isLvalue(); virtual bool checkType(); Expression *addressOf(); Expression *deref(); @@ -292,7 +292,6 @@ class IdentifierExp : public Expression Identifier *ident; static IdentifierExp *create(Loc loc, Identifier *ident); - bool isLvalue() override final; void accept(Visitor *v) override { v->visit(this); } }; @@ -309,7 +308,6 @@ class DsymbolExp final : public Expression d_bool hasOverloads; DsymbolExp *syntaxCopy() override; - bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -320,7 +318,6 @@ class ThisExp : public Expression ThisExp *syntaxCopy() override; Optional toBool() override; - bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -357,7 +354,6 @@ class StringExp final : public Expression dinteger_t getIndex(d_size_t i) const; StringExp *toStringExp() override; Optional toBool() override; - bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } size_t numberOfCodeUnits(int tynto = 0) const; void writeTo(void* dest, bool zero, int tyto = 0) const; @@ -499,7 +495,6 @@ class TemplateExp final : public Expression TemplateDeclaration *td; FuncDeclaration *fd; - bool isLvalue() override; bool checkType() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -572,7 +567,6 @@ class VarExp final : public SymbolExp public: d_bool delegateWasExtracted; static VarExp *create(Loc loc, Declaration *var, bool hasOverloads = true); - bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -584,7 +578,6 @@ class OverExp final : public Expression public: OverloadSet *vars; - bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -688,7 +681,6 @@ class BinExp : public Expression class BinAssignExp : public BinExp { public: - bool isLvalue() override final; void accept(Visitor *v) override { v->visit(this); } }; @@ -751,7 +743,6 @@ class DotVarExp final : public UnaExp Declaration *var; d_bool hasOverloads; - bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -833,7 +824,6 @@ class CallExp final : public UnaExp static CallExp *create(Loc loc, FuncDeclaration *fd, Expression *earg1); CallExp *syntaxCopy() override; - bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -848,8 +838,6 @@ class AddrExp final : public UnaExp class PtrExp final : public UnaExp { public: - bool isLvalue() override; - void accept(Visitor *v) override { v->visit(this); } }; @@ -895,7 +883,6 @@ class CastExp final : public UnaExp Expression* lowering; CastExp *syntaxCopy() override; - bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -915,7 +902,6 @@ class VectorExp final : public UnaExp class VectorArrayExp final : public UnaExp { public: - bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -937,7 +923,6 @@ class SliceExp final : public UnaExp public: SliceExp *syntaxCopy() override; - bool isLvalue() override; Optional toBool() override; void accept(Visitor *v) override { v->visit(this); } @@ -963,14 +948,12 @@ class IntervalExp final : public Expression class DelegatePtrExp final : public UnaExp { public: - bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } }; class DelegateFuncptrExp final : public UnaExp { public: - bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -985,7 +968,6 @@ class ArrayExp final : public UnaExp d_bool modifiable; ArrayExp *syntaxCopy() override; - bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -1004,7 +986,6 @@ class CommaExp final : public BinExp d_bool isGenerated; d_bool allowCommaExp; Expression* originalExp; - bool isLvalue() override; Optional toBool() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -1018,7 +999,6 @@ class IndexExp final : public BinExp d_bool indexIsInBounds; // true if 0 <= e2 && e2 <= e1.length - 1 IndexExp *syntaxCopy() override; - bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -1051,8 +1031,6 @@ class AssignExp : public BinExp public: MemorySet memset; - bool isLvalue() override final; - void accept(Visitor *v) override { v->visit(this); } }; @@ -1298,7 +1276,6 @@ class CondExp final : public BinExp Expression *econd; CondExp *syntaxCopy() override; - bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } }; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 870ad52d46..61246d4dfa 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -96,6 +96,105 @@ import dmd.visitor.postorder; enum LOGSEMANTIC = false; +bool isLvalue(Expression _this) +{ + static bool dotVarExpIsLvalue(DotVarExp _this) + { + if (_this.rvalue) + return false; + if (_this.e1.op != EXP.structLiteral) + return true; + auto vd = _this.var.isVarDeclaration(); + return !(vd && vd.isField()); + } + + static bool callExpIsLvalue(CallExp _this) + { + if (_this.rvalue) + return false; + Type tb = _this.e1.type.toBasetype(); + if (tb.ty == Tdelegate || tb.ty == Tpointer) + tb = tb.nextOf(); + auto tf = tb.isTypeFunction(); + if (tf && tf.isRef) + { + if (auto dve = _this.e1.isDotVarExp()) + if (dve.var.isCtorDeclaration()) + return false; + return true; // function returns a reference + } + return false; + } + + static bool castExpIsLvalue(CastExp _this) + { + //printf("e1.type = %s, to.type = %s\n", e1.type.toChars(), to.toChars()); + if (_this.rvalue || !_this.e1.isLvalue()) + return false; + return (_this.to.ty == Tsarray && (_this.e1.type.ty == Tvector || _this.e1.type.ty == Tsarray)) || + (_this.to.ty == Taarray && _this.e1.type.ty == Taarray) || + _this.e1.type.mutableOf.unSharedOf().equals(_this.to.mutableOf().unSharedOf()); + } + + static bool indexExpIsLvalue(IndexExp _this) + { + if (_this.rvalue) + return false; + auto t1b = _this.e1.type.toBasetype(); + if (t1b.isTypeAArray() || t1b.isTypeSArray() || + (_this.e1.isIndexExp() && t1b != t1b.isTypeDArray())) + { + return _this.e1.isLvalue(); + } + return true; + } + + static bool assignExpIsLvalue(AssignExp _this) + { + // Array-op 'x[] = y[]' should make an rvalue. + // Setting array length 'x.length = v' should make an rvalue. + if (_this.e1.op == EXP.slice || _this.e1.op == EXP.arrayLength) + { + return false; + } + return !_this.rvalue; + } + + bool not_rvalue = _this.rvalue == false; + + if (_this.isBinAssignExp()) + return not_rvalue; + + switch(_this.op) + { + case EXP.overloadSet: return true; + case EXP.identifier, EXP.dollar, EXP.dSymbol, EXP.star: return not_rvalue; + // Class `this` should be an rvalue; struct `this` should be an lvalue. + case EXP.this_, EXP.super_: return not_rvalue && _this.type.toBasetype().ty != Tclass; + /* string literal/slice is rvalue in default, but + * conversion to reference of static array is only allowed. + */ + case EXP.string_, EXP.slice: return not_rvalue && (_this.type && _this.type.toBasetype().ty == Tsarray); + case EXP.question: return not_rvalue && _this.isCondExp().e1.isLvalue() && _this.isCondExp().e2.isLvalue(); + case EXP.array: return !( _this.rvalue || (_this.type && _this.type.toBasetype().ty == Tvoid)); + + case EXP.vectorArray: return not_rvalue && _this.isVectorArrayExp().e1.isLvalue(); + case EXP.delegatePointer: return not_rvalue && _this.isDelegatePtrExp().e1.isLvalue(); + case EXP.delegateFunctionPointer: return not_rvalue && _this.isDelegateFuncptrExp().e1.isLvalue(); + + case EXP.comma: return not_rvalue && _this.isCommaExp().e2.isLvalue(); + case EXP.variable: return !(_this.rvalue || (_this.isVarExp().var.storage_class & (STC.lazy_ | STC.rvalue | STC.manifest))); + case EXP.template_: return _this.isTemplateExp().fd !is null; + + case EXP.dotVariable: return dotVarExpIsLvalue(_this.isDotVarExp()); + case EXP.call: return callExpIsLvalue(_this.isCallExp()); + case EXP.cast_: return castExpIsLvalue(_this.isCastExp()); + case EXP.index: return indexExpIsLvalue(_this.isIndexExp()); + case EXP.assign, EXP.loweredAssignExp, EXP.construct, EXP.blit: return assignExpIsLvalue(cast(AssignExp) _this); + default: return false; + } +} + // Return index of the field, or -1 if not found int getFieldIndex(ClassReferenceExp _this, Type fieldtype, uint fieldoffset) { diff --git a/dmd/frontend.h b/dmd/frontend.h index bb33b880f3..32cb5cc6a0 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2382,7 +2382,6 @@ class Expression : public ASTNode virtual _d_real toImaginary(); virtual complex_t toComplex(); virtual StringExp* toStringExp(); - virtual bool isLvalue(); virtual bool checkType(); Expression* deref(); int32_t isConst(); @@ -2519,7 +2518,6 @@ class BinExp : public Expression class BinAssignExp : public BinExp { public: - bool isLvalue() final override; void accept(Visitor* v) override; }; @@ -2586,7 +2584,6 @@ class ArrayExp final : public UnaExp VarDeclaration* lengthVar; bool modifiable; ArrayExp* syntaxCopy() override; - bool isLvalue() override; void accept(Visitor* v) override; }; @@ -2640,7 +2637,6 @@ class AssignExp : public BinExp public: MemorySet memset; AssignExp(Loc loc, EXP tok, Expression* e1, Expression* e2); - bool isLvalue() final override; void accept(Visitor* v) override; }; @@ -2684,7 +2680,6 @@ class CallExp final : public UnaExp static CallExp* create(Loc loc, Expression* e, Expression* earg1); static CallExp* create(Loc loc, FuncDeclaration* fd, Expression* earg1); CallExp* syntaxCopy() override; - bool isLvalue() override; void accept(Visitor* v) override; }; @@ -2696,7 +2691,6 @@ class CastExp final : public UnaExp bool trusted; Expression* lowering; CastExp* syntaxCopy() override; - bool isLvalue() override; void accept(Visitor* v) override; }; @@ -2753,7 +2747,6 @@ class CommaExp final : public BinExp const bool isGenerated; bool allowCommaExp; Expression* originalExp; - bool isLvalue() override; Optional toBool() override; void accept(Visitor* v) override; static void allow(Expression* exp); @@ -2785,7 +2778,6 @@ class CondExp final : public BinExp public: Expression* econd; CondExp* syntaxCopy() override; - bool isLvalue() override; void accept(Visitor* v) override; }; @@ -2822,14 +2814,12 @@ class DelegateExp final : public UnaExp class DelegateFuncptrExp final : public UnaExp { public: - bool isLvalue() override; void accept(Visitor* v) override; }; class DelegatePtrExp final : public UnaExp { public: - bool isLvalue() override; void accept(Visitor* v) override; }; @@ -2857,7 +2847,6 @@ class IdentifierExp : public Expression public: Identifier* ident; static IdentifierExp* create(Loc loc, Identifier* ident); - bool isLvalue() final override; void accept(Visitor* v) override; }; @@ -2913,7 +2902,6 @@ class DotVarExp final : public UnaExp public: Declaration* var; bool hasOverloads; - bool isLvalue() override; void accept(Visitor* v) override; }; @@ -2922,7 +2910,6 @@ class DsymbolExp final : public Expression public: Dsymbol* s; bool hasOverloads; - bool isLvalue() override; void accept(Visitor* v) override; }; @@ -3236,7 +3223,6 @@ class IndexExp final : public BinExp bool modifiable; bool indexIsInBounds; IndexExp* syntaxCopy() override; - bool isLvalue() override; void accept(Visitor* v) override; }; @@ -3433,7 +3419,6 @@ class OverExp final : public Expression { public: OverloadSet* vars; - bool isLvalue() override; void accept(Visitor* v) override; }; @@ -3470,7 +3455,6 @@ class PrettyFuncInitExp final : public DefaultInitExp class PtrExp final : public UnaExp { public: - bool isLvalue() override; void accept(Visitor* v) override; }; @@ -3563,7 +3547,6 @@ class SliceExp final : public UnaExp uint8_t bitFields; public: SliceExp* syntaxCopy() override; - bool isLvalue() override; Optional toBool() override; void accept(Visitor* v) override; }; @@ -3596,7 +3579,6 @@ class StringExp final : public Expression StringExp* toStringExp() override; int32_t compare(const StringExp* const se2) const; Optional toBool() override; - bool isLvalue() override; void accept(Visitor* v) override; }; @@ -3663,7 +3645,6 @@ class ThisExp : public Expression ThisExp(Loc loc, const EXP tok); ThisExp* syntaxCopy() override; Optional toBool() override; - bool isLvalue() final override; void accept(Visitor* v) override; }; @@ -3695,7 +3676,6 @@ class TemplateExp final : public Expression public: TemplateDeclaration* td; FuncDeclaration* fd; - bool isLvalue() override; bool checkType() override; void accept(Visitor* v) override; }; @@ -3772,14 +3752,12 @@ class VarExp final : public SymbolExp public: bool delegateWasExtracted; static VarExp* create(Loc loc, Declaration* var, bool hasOverloads = true); - bool isLvalue() override; void accept(Visitor* v) override; }; class VectorArrayExp final : public UnaExp { public: - bool isLvalue() override; void accept(Visitor* v) override; }; From 6fabdced7891dff3edb2dd4717a9ac68fa25463f Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Mon, 6 Oct 2025 02:20:35 +1300 Subject: [PATCH 006/440] Fix some null dereferences in dmd's test suite (dlang/dmd!21941) --- tests/dmd/compilable/test21299d.d | 3 ++- tests/dmd/compilable/test22916.d | 3 ++- tests/dmd/runnable/template9.d | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/dmd/compilable/test21299d.d b/tests/dmd/compilable/test21299d.d index 67ec60a582..a622ae7fd6 100644 --- a/tests/dmd/compilable/test21299d.d +++ b/tests/dmd/compilable/test21299d.d @@ -22,6 +22,7 @@ class Task { void removeTerminationHook(void delegate() hook) { - moveToEnd([], hook); + void delegate()[] array = [() {}]; + moveToEnd(array, hook); } } diff --git a/tests/dmd/compilable/test22916.d b/tests/dmd/compilable/test22916.d index 9f779fd07d..363a8e5d42 100644 --- a/tests/dmd/compilable/test22916.d +++ b/tests/dmd/compilable/test22916.d @@ -25,7 +25,8 @@ char* g; void test23862() { - scope char** _errors; + char* source; + scope char** _errors = &source; g = front_p(_errors); // should pass g = front_r(_errors); // should pass } diff --git a/tests/dmd/runnable/template9.d b/tests/dmd/runnable/template9.d index 7a55b2dbfe..42d6449560 100644 --- a/tests/dmd/runnable/template9.d +++ b/tests/dmd/runnable/template9.d @@ -3405,7 +3405,7 @@ template map_front12186(fun...) void test12186() { - immutable int[][] mat; + immutable int[][] mat = new int[][](1); mat.map_front12186!((in r) => 0); // OK mat.map_front12186!((const r) => 0); // OK From 6407c52c8b1e38f953406341e0ecfeefad931ef5 Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Mon, 6 Oct 2025 00:23:37 +0200 Subject: [PATCH 007/440] fix dlang/dmd!20275 - Unicode file names are not properly handled (dlang/dmd!21942) use properly converted _Dmain args instead of cArgs, always use the wide string APIs with conversion from UTF-8 --- dmd/common/file.d | 4 +-- dmd/common/smallbuffer.d | 16 +++++++----- dmd/main.d | 26 +++++++++---------- dmd/mars.d | 2 +- .../imports/\344\275\240\345\245\275.d" | 6 +++++ tests/dmd/runnable/test20275.d | 8 ++++++ 6 files changed, 39 insertions(+), 23 deletions(-) create mode 100644 "tests/dmd/runnable/imports/\344\275\240\345\245\275.d" create mode 100644 tests/dmd/runnable/test20275.d diff --git a/dmd/common/file.d b/dmd/common/file.d index 203ee27abd..9fa339a81e 100644 --- a/dmd/common/file.d +++ b/dmd/common/file.d @@ -32,10 +32,10 @@ version (Windows) { import core.stdc.wchar_; import core.sys.windows.winbase; - import core.sys.windows.winnls : CP_ACP; + import core.sys.windows.winnls : CP_UTF8; import core.sys.windows.winnt; - enum CodePage = CP_ACP; // assume filenames encoded in system default Windows ANSI code page + enum CodePage = CP_UTF8; // assume filenames already gone through Windows ANSI code page -> UTF8 conversion enum invalidHandle = INVALID_HANDLE_VALUE; } else version (Posix) diff --git a/dmd/common/smallbuffer.d b/dmd/common/smallbuffer.d index 65adec68f4..085c0e3434 100644 --- a/dmd/common/smallbuffer.d +++ b/dmd/common/smallbuffer.d @@ -121,16 +121,20 @@ version(Windows) wchar[] toWStringz(scope const(char)[] narrow, ref SmallBuffer! size_t charsToWchars(scope const(char)[] narrow, scope wchar[] buffer) { // https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar - import core.sys.windows.winnls : MultiByteToWideChar, CP_ACP; - return MultiByteToWideChar(CP_ACP, 0, narrow.ptr, cast(int) narrow.length, buffer.ptr, cast(int) buffer.length); + import core.sys.windows.winnls : MultiByteToWideChar, CP_UTF8; + return MultiByteToWideChar(CP_UTF8, 0, narrow.ptr, cast(int) narrow.length, buffer.ptr, cast(int) buffer.length); } - size_t length = charsToWchars(narrow, buffer[]); - if (length >= buffer.length) // not enough room in buffer[] + size_t length = charsToWchars(narrow, buffer[0..$-1]); + if (length == 0 && narrow.length > 0) // not enough room in buffer[] { + import core.sys.windows.winbase : GetLastError; + import core.sys.windows.winerror : ERROR_INSUFFICIENT_BUFFER; + assert(GetLastError() == ERROR_INSUFFICIENT_BUFFER); + length = charsToWchars(narrow, []); buffer.create(length + 1); // extend buffer length - length = charsToWchars(narrow, buffer[]); // try again - assert(length < buffer.length); + length = charsToWchars(narrow, buffer[0..length]); // try again + assert(length > 0 && length < buffer.length); } buffer[length] = 0; return buffer[0 .. length]; diff --git a/dmd/main.d b/dmd/main.d index a574bfdb4b..5341f66112 100644 --- a/dmd/main.d +++ b/dmd/main.d @@ -111,7 +111,7 @@ extern (C) int main(int argc, char** argv) * Returns: * Return code of the application */ -extern (C) int _Dmain(char[][]) +extern (C) int _Dmain(const(char)[][] dargs) { // possibly install memory error handler version (DigitalMars) @@ -144,8 +144,7 @@ extern (C) int _Dmain(char[][]) fputs(buf.peekChars(), stderr); } - auto args = Runtime.cArgs(); - return tryMain(args.argc, cast(const(char)**)args.argv, global.params); + return tryMain(dargs, global.params); } /************************************************************************************/ @@ -159,14 +158,13 @@ private: * provided source file and do semantic analysis on them. * * Params: - * argc = Number of arguments passed via command line * argv = Array of string arguments passed via command line * params = set based on argc, argv * * Returns: * Application return code */ -private int tryMain(size_t argc, const(char)** argv, out Param params) +private int tryMain(const(char)[][] argv, out Param params) { import dmd.common.charactertables; import dmd.sarif; @@ -190,7 +188,7 @@ private int tryMain(size_t argc, const(char)** argv, out Param params) target.setTargetBuildDefaults(); - if (parseCommandlineAndConfig(argc, argv, params, files)) + if (parseCommandlineAndConfig(argv, params, files)) return EXIT_FAILURE; global.compileEnv.previewIn = params.previewIn; @@ -452,7 +450,7 @@ private int tryMain(size_t argc, const(char)** argv, out Param params) if (params.timeTrace) { import dmd.timetrace; - initializeTimeTrace(params.timeTraceGranularityUs, argv[0]); + initializeTimeTrace(params.timeTraceGranularityUs, toCString(argv[0]).ptr); } // Create Modules @@ -873,13 +871,12 @@ private int tryMain(size_t argc, const(char)** argv, out Param params) * Parses the command line arguments and configuration files * * Params: - * argc = Number of arguments passed via command line * argv = Array of string arguments passed via command line * params = parameters from argv * files = files from argv * Returns: true on failure */ -bool parseCommandlineAndConfig(size_t argc, const(char)** argv, out Param params, ref Strings files) +bool parseCommandlineAndConfig(const(char)[][] argv, out Param params, ref Strings files) { // Detect malformed input static bool badArgs() @@ -888,15 +885,16 @@ bool parseCommandlineAndConfig(size_t argc, const(char)** argv, out Param params return true; } - if (argc < 1 || !argv) + const size_t argc = argv.length; + if (argc < 1) return badArgs(); // Convert argc/argv into arguments[] for easier handling - Strings arguments = Strings(argc); - for (size_t i = 0; i < argc; i++) + Strings arguments = Strings(argv.length); + for (size_t i = 0; i < argv.length; i++) { if (!argv[i]) return badArgs(); - arguments[i] = argv[i]; + arguments[i] = toCString(argv[i]).ptr; } if (const(char)* missingFile = responseExpand(arguments)) // expand response files error(Loc.initial, "cannot open response file '%s'", missingFile); @@ -989,7 +987,7 @@ bool parseCommandlineAndConfig(size_t argc, const(char)** argv, out Param params // in druntime: -alias MainFunc = extern(C) int function(char[][] args); +alias MainFunc = extern(C) int function(const(char)[][] args); extern (C) int _d_run_main(int argc, char** argv, MainFunc dMain); diff --git a/dmd/mars.d b/dmd/mars.d index cca1ff3272..d029689c95 100644 --- a/dmd/mars.d +++ b/dmd/mars.d @@ -479,7 +479,7 @@ extern(C) void flushMixins() * * Params: * arguments = command line arguments - * argc = argument count + * argc = original argument count before adding from DFLAGS * params = set to result of parsing `arguments` * files = set to files pulled from `arguments` * target = more things set to result of parsing `arguments` diff --git "a/tests/dmd/runnable/imports/\344\275\240\345\245\275.d" "b/tests/dmd/runnable/imports/\344\275\240\345\245\275.d" new file mode 100644 index 0000000000..e772fa18c1 --- /dev/null +++ "b/tests/dmd/runnable/imports/\344\275\240\345\245\275.d" @@ -0,0 +1,6 @@ +module imports.你好; + +int foo() +{ + return 0; +} diff --git a/tests/dmd/runnable/test20275.d b/tests/dmd/runnable/test20275.d new file mode 100644 index 0000000000..cbdf1f6e7f --- /dev/null +++ b/tests/dmd/runnable/test20275.d @@ -0,0 +1,8 @@ +// EXTRA_SOURCES: imports/你好.d + +import imports.你好; + +int main() +{ + return foo(); +} From ef2f89f54652695c02cddba55fbf863b027cd41d Mon Sep 17 00:00:00 2001 From: Albert24GG Date: Mon, 6 Oct 2025 12:00:13 +0300 Subject: [PATCH 008/440] Add `lowering` field to `ConstructExp` (dlang/dmd!21706) --- dmd/dinterpret.d | 28 ---------------------------- dmd/expression.d | 2 ++ dmd/expression.h | 1 + dmd/expressionsem.d | 18 ++++++++++-------- dmd/frontend.h | 1 + dmd/inline.d | 20 ++++++++++++++++++++ 6 files changed, 34 insertions(+), 36 deletions(-) diff --git a/dmd/dinterpret.d b/dmd/dinterpret.d index 6f5083549e..9ae091b66b 100644 --- a/dmd/dinterpret.d +++ b/dmd/dinterpret.d @@ -4702,34 +4702,6 @@ public: result = CTFEExp.voidexp; return; } - else if (isArrayConstruction(fd.ident)) - { - // In expressionsem.d, `T[x] ea = eb;` was lowered to: - // `_d_array{,set}ctor(ea[], eb[]);`. - // The following code will rewrite it back to `ea = eb` and - // then interpret that expression. - - if (fd.ident == Id._d_arrayctor) - assert(e.arguments.length == 3); - else - assert(e.arguments.length == 2); - - Expression ea = (*e.arguments)[0]; - if (ea.isCastExp) - ea = ea.isCastExp.e1; - - Expression eb = (*e.arguments)[1]; - if (eb.isCastExp() && fd.ident == Id._d_arrayctor) - eb = eb.isCastExp.e1; - - ConstructExp ce = new ConstructExp(e.loc, ea, eb); - ce.type = ea.type; - - ce.type = ea.type; - result = interpret(ce, istate); - - return; - } } else if (auto soe = ecall.isSymOffExp()) { diff --git a/dmd/expression.d b/dmd/expression.d index 64860e2250..8c469f21f2 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -3641,6 +3641,8 @@ extern (C++) final class LoweredAssignExp : AssignExp */ extern (C++) final class ConstructExp : AssignExp { + Expression lowering; + extern (D) this(Loc loc, Expression e1, Expression e2) @safe { super(loc, EXP.construct, e1, e2); diff --git a/dmd/expression.h b/dmd/expression.h index 0855747326..8af86d3a35 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -1037,6 +1037,7 @@ class AssignExp : public BinExp class ConstructExp final : public AssignExp { public: + Expression *lowering; void accept(Visitor *v) override { v->visit(this); } }; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 61246d4dfa..89afbeac6c 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -12408,16 +12408,16 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor return setError(); // Lower to object._d_array{,set}ctor(e1, e2) - Expression id = new IdentifierExp(exp.loc, Id.empty); - id = new DotIdExp(exp.loc, id, Id.object); - id = new DotIdExp(exp.loc, id, func); + Expression lowering = new IdentifierExp(ae.loc, Id.empty); + lowering = new DotIdExp(ae.loc, lowering, Id.object); + lowering = new DotIdExp(ae.loc, lowering, func); auto arguments = new Expressions(new CastExp(ae.loc, ae.e1, t1e.arrayOf).expressionSemantic(sc)); if (lowerToArrayCtor) { arguments.push(new CastExp(ae.loc, rhs, t2b.nextOf.arrayOf).expressionSemantic(sc)); - Expression ce = new CallExp(exp.loc, id, arguments); - res = ce.expressionSemantic(sc); + lowering = new CallExp(ae.loc, lowering, arguments); + lowering = lowering.expressionSemantic(sc); } else { @@ -12432,12 +12432,14 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor else arguments.push(ae.e2); - Expression ce = new CallExp(exp.loc, id, arguments); - res = Expression.combine(e0, ce).expressionSemantic(sc); + lowering = new CallExp(ae.loc, lowering, arguments); + lowering = Expression.combine(e0, lowering).expressionSemantic(sc); } + ae.lowering = lowering; + if (global.params.v.verbose) - message("lowered %s =>\n %s", exp.toChars(), res.toChars()); + message("lowered %s =>\n %s", exp.toChars(), lowering.toChars()); } } else if (auto ae = res.isAssignExp()) diff --git a/dmd/frontend.h b/dmd/frontend.h index 32cb5cc6a0..52b4c131b1 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2784,6 +2784,7 @@ class CondExp final : public BinExp class ConstructExp final : public AssignExp { public: + Expression* lowering; void accept(Visitor* v) override; }; diff --git a/dmd/inline.d b/dmd/inline.d index 6981062120..c36be26139 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -833,6 +833,18 @@ public: visit(cast(BinExp)e); } + override void visit(ConstructExp e) + { + if (e.lowering) + { + auto ce = cast(ConstructExp)e.copy(); + ce.lowering = doInlineAs!Expression(ce.lowering, ids); + result = ce; + } + else + visit(cast(AssignExp) e); + } + override void visit(LoweredAssignExp e) { result = doInlineAs!Expression(e.lowering, ids); @@ -1403,6 +1415,14 @@ public: visit(cast(BinExp)e); } + override void visit(ConstructExp e) + { + if (auto lowering = e.lowering) + inlineScan(lowering); + else + visit(cast(AssignExp) e); + } + override void visit(LoweredAssignExp e) { inlineScan(e.lowering); From 14fa8f0ace4e5576234fb1513bea0a7b1cddd828 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 10 Oct 2025 03:01:06 +0300 Subject: [PATCH 009/440] Break semantic dependency of `dmd/dtemplate.d` on `dmd/templatesem.d` attempt 2 (dlang/dmd!21949) --- dmd/dtemplate.d | 3 +-- dmd/templatesem.d | 10 +++++----- dmd/traits.d | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/dmd/dtemplate.d b/dmd/dtemplate.d index fdff9cfaac..1413a6e4d9 100644 --- a/dmd/dtemplate.d +++ b/dmd/dtemplate.d @@ -72,7 +72,6 @@ import dmd.optimize; import dmd.root.array; import dmd.common.outbuffer; import dmd.rootobject; -import dmd.templatesem : TemplateInstanceBox; import dmd.tokens; import dmd.typesem : typeSemantic; import dmd.visitor; @@ -255,7 +254,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol Expression constraint; // Hash table to look up TemplateInstance's of this TemplateDeclaration - TemplateInstance[TemplateInstanceBox] instances; + void* instances; TemplateDeclaration overnext; // next overloaded TemplateDeclaration TemplateDeclaration overroot; // first in overnext list diff --git a/dmd/templatesem.d b/dmd/templatesem.d index 6d35bea9d9..3357013cb2 100644 --- a/dmd/templatesem.d +++ b/dmd/templatesem.d @@ -1042,10 +1042,10 @@ Laftersemantic: //printf("replaceInstance()\n"); assert(errinst.errors); auto ti1 = TemplateInstanceBox(errinst); - tempdecl.instances.remove(ti1); + (cast(TemplateInstance[TemplateInstanceBox])tempdecl.instances).remove(ti1); auto ti2 = TemplateInstanceBox(tempinst); - tempdecl.instances[ti2] = tempinst; + (*(cast(TemplateInstance[TemplateInstanceBox]*) &tempdecl.instances))[ti2] = tempinst; } static if (LOG) @@ -1445,7 +1445,7 @@ private TemplateInstance findExistingInstance(TemplateDeclaration td, TemplateIn tithis.fargs = argumentList.arguments; tithis.fnames = argumentList.names; auto tibox = TemplateInstanceBox(tithis); - auto p = tibox in td.instances; + auto p = tibox in cast(TemplateInstance[TemplateInstanceBox]) td.instances; debug (FindExistingInstance) ++(p ? nFound : nNotFound); //if (p) printf("\tfound %p\n", *p); else printf("\tnot found\n"); return p ? *p : null; @@ -1459,7 +1459,7 @@ private TemplateInstance addInstance(TemplateDeclaration td, TemplateInstance ti { //printf("addInstance() %p %s\n", instances, ti.toChars()); auto tibox = TemplateInstanceBox(ti); - td.instances[tibox] = ti; + (*(cast(TemplateInstance[TemplateInstanceBox]*) &td.instances))[tibox] = ti; debug (FindExistingInstance) ++nAdded; return ti; } @@ -1474,7 +1474,7 @@ private void removeInstance(TemplateDeclaration td, TemplateInstance ti) //printf("removeInstance() %s\n", ti.toChars()); auto tibox = TemplateInstanceBox(ti); debug (FindExistingInstance) ++nRemoved; - td.instances.remove(tibox); + (cast(TemplateInstance[TemplateInstanceBox])td.instances).remove(tibox); } /****************************************************** diff --git a/dmd/traits.d b/dmd/traits.d index 545141a741..4755e372c3 100644 --- a/dmd/traits.d +++ b/dmd/traits.d @@ -1198,8 +1198,8 @@ Expression semanticTraits(TraitsExp e, Scope* sc) // create an empty AA just to copy it scope ti = new TemplateInstance(Loc.initial, Id.empty, null); auto tib = TemplateInstanceBox(ti); - td.instances[tib] = null; - td.instances.clear(); + (*(cast(TemplateInstance[TemplateInstanceBox]*) &td.instances))[tib] = null; + (cast(TemplateInstance[TemplateInstanceBox])td.instances).clear(); } td = td.syntaxCopy(null); import core.stdc.string : memcpy; From 104618083847bb293d019ff1a32d59d6c32c2e1c Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 10 Oct 2025 03:03:00 +0300 Subject: [PATCH 010/440] Break semantic dependency of `dmd/dtemplate.d` on `dmd/typesem.d` (dlang/dmd!21950) --- dmd/cxxfrontend.d | 6 +++++ dmd/dtemplate.d | 46 -------------------------------------- dmd/frontend.h | 5 ----- dmd/template.h | 6 +---- dmd/templatesem.d | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 56 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 5e8e5e3417..93c41b67f6 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -883,6 +883,12 @@ TypeInfoDeclaration getTypeInfoAssocArrayDeclaration(TypeAArray t, Scope* sc) /** * templatesem.d */ +bool declareParameter(TemplateParameter tp, Scope* sc) +{ + import dmd.templatesem; + return dmd.templatesem.declareParameter(tp, sc); +} + bool needsCodegen(TemplateInstance ti) { import dmd.templatesem; diff --git a/dmd/dtemplate.d b/dmd/dtemplate.d index 1413a6e4d9..306d3b4895 100644 --- a/dmd/dtemplate.d +++ b/dmd/dtemplate.d @@ -73,7 +73,6 @@ import dmd.root.array; import dmd.common.outbuffer; import dmd.rootobject; import dmd.tokens; -import dmd.typesem : typeSemantic; import dmd.visitor; //debug = FindExistingInstance; // print debug stats of findExistingInstance @@ -883,8 +882,6 @@ extern (C++) class TemplateParameter : ASTNode abstract TemplateParameter syntaxCopy(); - abstract bool declareParameter(Scope* sc); - abstract void print(RootObject oarg, RootObject oded); abstract RootObject specialization(); @@ -936,14 +933,6 @@ extern (C++) class TemplateTypeParameter : TemplateParameter return new TemplateTypeParameter(loc, ident, specType ? specType.syntaxCopy() : null, defaultType ? defaultType.syntaxCopy() : null); } - override final bool declareParameter(Scope* sc) - { - //printf("TemplateTypeParameter.declareParameter('%s')\n", ident.toChars()); - auto ti = new TypeIdentifier(loc, ident); - Declaration ad = new AliasDeclaration(loc, ident, ti); - return sc.insert(ad) !is null; - } - override final void print(RootObject oarg, RootObject oded) { printf(" %s\n", ident.toChars()); @@ -1039,27 +1028,6 @@ extern (C++) final class TemplateValueParameter : TemplateParameter defaultValue ? defaultValue.syntaxCopy() : null); } - override bool declareParameter(Scope* sc) - { - /* - Do type semantic earlier. - - This means for certain erroneous value parameters - their "type" can be known earlier and thus a better - error message given. - - For example: - `template test(x* x) {}` - now yields "undefined identifier" rather than the opaque - "variable `x` is used as a type". - */ - if (valType) - valType = valType.typeSemantic(loc, sc); - auto v = new VarDeclaration(loc, valType, ident, null); - v.storage_class = STC.templateparameter; - return sc.insert(v) !is null; - } - override void print(RootObject oarg, RootObject oded) { printf(" %s\n", ident.toChars()); @@ -1116,13 +1084,6 @@ extern (C++) final class TemplateAliasParameter : TemplateParameter return new TemplateAliasParameter(loc, ident, specType ? specType.syntaxCopy() : null, objectSyntaxCopy(specAlias), objectSyntaxCopy(defaultAlias)); } - override bool declareParameter(Scope* sc) - { - auto ti = new TypeIdentifier(loc, ident); - Declaration ad = new AliasDeclaration(loc, ident, ti); - return sc.insert(ad) !is null; - } - override void print(RootObject oarg, RootObject oded) { printf(" %s\n", ident.toChars()); @@ -1169,13 +1130,6 @@ extern (C++) final class TemplateTupleParameter : TemplateParameter return new TemplateTupleParameter(loc, ident); } - override bool declareParameter(Scope* sc) - { - auto ti = new TypeIdentifier(loc, ident); - Declaration ad = new AliasDeclaration(loc, ident, ti); - return sc.insert(ad) !is null; - } - override void print(RootObject oarg, RootObject oded) { printf(" %s... [", ident.toChars()); diff --git a/dmd/frontend.h b/dmd/frontend.h index 52b4c131b1..b2a7b85aa7 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -1704,7 +1704,6 @@ class TemplateParameter : public ASTNode virtual TemplateThisParameter* isTemplateThisParameter(); virtual TemplateTupleParameter* isTemplateTupleParameter(); virtual TemplateParameter* syntaxCopy() = 0; - virtual bool declareParameter(Scope* sc) = 0; virtual void print(RootObject* oarg, RootObject* oded) = 0; virtual RootObject* specialization() = 0; virtual bool hasDefaultArg() = 0; @@ -1721,7 +1720,6 @@ class TemplateAliasParameter final : public TemplateParameter RootObject* defaultAlias; TemplateAliasParameter* isTemplateAliasParameter() override; TemplateAliasParameter* syntaxCopy() override; - bool declareParameter(Scope* sc) override; void print(RootObject* oarg, RootObject* oded) override; RootObject* specialization() override; bool hasDefaultArg() override; @@ -1852,7 +1850,6 @@ class TemplateTypeParameter : public TemplateParameter Type* defaultType; TemplateTypeParameter* isTemplateTypeParameter() final override; TemplateTypeParameter* syntaxCopy() override; - bool declareParameter(Scope* sc) final override; void print(RootObject* oarg, RootObject* oded) final override; RootObject* specialization() final override; bool hasDefaultArg() final override; @@ -1872,7 +1869,6 @@ class TemplateTupleParameter final : public TemplateParameter public: TemplateTupleParameter* isTemplateTupleParameter() override; TemplateTupleParameter* syntaxCopy() override; - bool declareParameter(Scope* sc) override; void print(RootObject* oarg, RootObject* oded) override; RootObject* specialization() override; bool hasDefaultArg() override; @@ -1887,7 +1883,6 @@ class TemplateValueParameter final : public TemplateParameter Expression* defaultValue; TemplateValueParameter* isTemplateValueParameter() override; TemplateValueParameter* syntaxCopy() override; - bool declareParameter(Scope* sc) override; void print(RootObject* oarg, RootObject* oded) override; RootObject* specialization() override; bool hasDefaultArg() override; diff --git a/dmd/template.h b/dmd/template.h index 8ce1361e04..b72de9f751 100644 --- a/dmd/template.h +++ b/dmd/template.h @@ -128,7 +128,6 @@ class TemplateParameter : public ASTNode virtual TemplateTupleParameter *isTemplateTupleParameter(); virtual TemplateParameter *syntaxCopy() = 0; - virtual bool declareParameter(Scope *sc) = 0; virtual void print(RootObject *oarg, RootObject *oded) = 0; virtual RootObject *specialization() = 0; virtual bool hasDefaultArg() = 0; @@ -149,7 +148,6 @@ class TemplateTypeParameter : public TemplateParameter TemplateTypeParameter *isTemplateTypeParameter() override final; TemplateTypeParameter *syntaxCopy() override; - bool declareParameter(Scope *sc) override final; void print(RootObject *oarg, RootObject *oded) override final; RootObject *specialization() override final; bool hasDefaultArg() override final; @@ -179,7 +177,6 @@ class TemplateValueParameter final : public TemplateParameter TemplateValueParameter *isTemplateValueParameter() override; TemplateValueParameter *syntaxCopy() override; - bool declareParameter(Scope *sc) override; void print(RootObject *oarg, RootObject *oded) override; RootObject *specialization() override; bool hasDefaultArg() override; @@ -198,7 +195,6 @@ class TemplateAliasParameter final : public TemplateParameter TemplateAliasParameter *isTemplateAliasParameter() override; TemplateAliasParameter *syntaxCopy() override; - bool declareParameter(Scope *sc) override; void print(RootObject *oarg, RootObject *oded) override; RootObject *specialization() override; bool hasDefaultArg() override; @@ -213,7 +209,6 @@ class TemplateTupleParameter final : public TemplateParameter public: TemplateTupleParameter *isTemplateTupleParameter() override; TemplateTupleParameter *syntaxCopy() override; - bool declareParameter(Scope *sc) override; void print(RootObject *oarg, RootObject *oded) override; RootObject *specialization() override; bool hasDefaultArg() override; @@ -297,4 +292,5 @@ namespace dmd TemplateParameter *isTemplateParameter(RootObject *o); bool isError(const RootObject *const o); void printTemplateStats(bool listInstances, ErrorSink* eSink); + bool declareParameter(TemplateParameter *tp, Scope *sc); } diff --git a/dmd/templatesem.d b/dmd/templatesem.d index 3357013cb2..f1aca4bd1e 100644 --- a/dmd/templatesem.d +++ b/dmd/templatesem.d @@ -61,6 +61,63 @@ alias funcLeastAsSpecialized = dmd.funcsem.leastAsSpecialized; enum LOG = false; +bool declareParameter(TemplateParameter _this, Scope* sc) +{ + static bool typeDeclareParameter(TemplateTypeParameter _this, Scope* sc) + { + //printf("TemplateTypeParameter.declareParameter('%s')\n", ident.toChars()); + auto ti = new TypeIdentifier(_this.loc, _this.ident); + Declaration ad = new AliasDeclaration(_this.loc, _this.ident, ti); + return sc.insert(ad) !is null; + } + + static bool valueDeclareParameter(TemplateValueParameter _this, Scope* sc) + { + /* + Do type semantic earlier. + + This means for certain erroneous value parameters + their "type" can be known earlier and thus a better + error message given. + + For example: + `template test(x* x) {}` + now yields "undefined identifier" rather than the opaque + "variable `x` is used as a type". + */ + if (_this.valType) + _this.valType = _this.valType.typeSemantic(_this.loc, sc); + auto v = new VarDeclaration(_this.loc, _this.valType, _this.ident, null); + v.storage_class = STC.templateparameter; + return sc.insert(v) !is null; + } + + static bool aliasDeclareParameter(TemplateAliasParameter _this, Scope* sc) + { + auto ti = new TypeIdentifier(_this.loc, _this.ident); + Declaration ad = new AliasDeclaration(_this.loc, _this.ident, ti); + return sc.insert(ad) !is null; + } + + static bool tupleDeclareParameter(TemplateTupleParameter _this, Scope* sc) + { + auto ti = new TypeIdentifier(_this.loc, _this.ident); + Declaration ad = new AliasDeclaration(_this.loc, _this.ident, ti); + return sc.insert(ad) !is null; + } + + if (auto tp = _this.isTemplateTypeParameter()) + return typeDeclareParameter(tp, sc); + else if (auto vp = _this.isTemplateValueParameter()) + return valueDeclareParameter(vp, sc); + else if (auto ap = _this.isTemplateAliasParameter()) + return aliasDeclareParameter(ap, sc); + else if (auto tup = _this.isTemplateTupleParameter()) + return tupleDeclareParameter(tup, sc); + + assert(0); // unreachable +} + /************************************ * Return hash of Objects. */ From 87caeb98701ec0a0e42e4376ebaaa5440274bf04 Mon Sep 17 00:00:00 2001 From: Albert24GG Date: Fri, 10 Oct 2025 04:34:36 +0300 Subject: [PATCH 011/440] Fix dlang/dmd!21945 DIP1000 scope array of arrays comparison (dlang/dmd!21947) --- .../druntime/src/core/internal/array/equality.d | 15 +++++++++++++++ tests/dmd/compilable/fix21945.d | 6 ++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/dmd/compilable/fix21945.d diff --git a/runtime/druntime/src/core/internal/array/equality.d b/runtime/druntime/src/core/internal/array/equality.d index e0a811bf07..7a7dc5ceb2 100644 --- a/runtime/druntime/src/core/internal/array/equality.d +++ b/runtime/druntime/src/core/internal/array/equality.d @@ -27,6 +27,21 @@ bool __equals(T1, T2)(scope T1[] lhs, scope T2[] rhs) @trusted return (cast(PureType)&isEqual!(T1,T2))(lhs, rhs, lhs.length); } +pragma(inline, true) +bool __equals(T1, T2, size_t N)(scope ref T1[N] lhs, scope T2[] rhs) @trusted { + return __equals(lhs[], rhs); +} + +pragma(inline, true) +bool __equals(T1, T2, size_t N)(scope T1[] lhs, scope ref T2[N] rhs) @trusted { + return __equals(lhs, rhs[]); +} + +pragma(inline, true) +bool __equals(T1, T2, size_t N, size_t M)(scope ref T1[N] lhs, scope ref T2[M] rhs) @trusted { + return __equals(lhs[], rhs[]); +} + /****************************** * Helper function for __equals(). * Outlined to enable __equals() to be inlined, as dmd cannot inline loops. diff --git a/tests/dmd/compilable/fix21945.d b/tests/dmd/compilable/fix21945.d new file mode 100644 index 0000000000..cbd6dcb210 --- /dev/null +++ b/tests/dmd/compilable/fix21945.d @@ -0,0 +1,6 @@ +// REQUIRED_ARGS: -preview=dip1000 + +void assertEq(scope int[][3] x) @safe +{ + bool b = x == x; +} From e8ca433348c66ed729a7870e13d3bb3b821bc0dc Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 10 Oct 2025 05:31:16 +0300 Subject: [PATCH 012/440] Break semantic dependency of `dmd/expression.d` on `dmd/expressionsem.d` (dlang/dmd!21951) --- dmd/cxxfrontend.d | 8 +++++++- dmd/expression.d | 30 +----------------------------- dmd/expression.h | 1 + dmd/expressionsem.d | 35 +++++++++++++++++++++++++++++++++++ dmd/typesem.d | 2 ++ 5 files changed, 46 insertions(+), 30 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 93c41b67f6..6c7d961110 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -16,7 +16,7 @@ import dmd.astenums; import dmd.attrib; import dmd.common.outbuffer : OutBuffer; import dmd.dclass : ClassDeclaration, BaseClass; -import dmd.declaration : TypeInfoDeclaration, VarDeclaration; +import dmd.declaration : TypeInfoDeclaration, VarDeclaration, TupleDeclaration; import dmd.denum : EnumDeclaration; import dmd.dmodule /*: Module*/; import dmd.dscope : Scope; @@ -410,6 +410,12 @@ int getFieldIndex(ClassReferenceExp cre, Type fieldtype, uint fieldoffset) return dmd.expressionsem.getFieldIndex(cre, fieldtype, fieldoffset); } +void fillTupleExpExps(TupleExp te, TupleDeclaration tup) +{ + import dmd.expressionsem; + return dmd.expressionsem.fillTupleExpExps(te, tup); +} + /*********************************************************** * func.d */ diff --git a/dmd/expression.d b/dmd/expression.d index 8c469f21f2..6702ae94c8 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -32,7 +32,6 @@ import dmd.dsymbol; import dmd.dtemplate; import dmd.errors; import dmd.errorsink; -import dmd.expressionsem : getDsymbol; import dmd.func; import dmd.globals; import dmd.hdrgen; @@ -1664,34 +1663,7 @@ extern (C++) final class TupleExp : Expression { super(loc, EXP.tuple); this.exps = new Expressions(); - - this.exps.reserve(tup.objects.length); - foreach (o; *tup.objects) - { - if (Dsymbol s = getDsymbol(o)) - { - /* If tuple element represents a symbol, translate to DsymbolExp - * to supply implicit 'this' if needed later. - */ - Expression e = new DsymbolExp(loc, s); - this.exps.push(e); - } - else if (auto eo = o.isExpression()) - { - auto e = eo.copy(); - e.loc = loc; // https://issues.dlang.org/show_bug.cgi?id=15669 - this.exps.push(e); - } - else if (auto t = o.isType()) - { - Expression e = new TypeExp(loc, t); - this.exps.push(e); - } - else - { - error(loc, "`%s` is not an expression", o.toChars()); - } - } + // the rest of the constructor is moved to expressionsem.d in fillTupleExpExps function } static TupleExp create(Loc loc, Expressions* exps) @safe diff --git a/dmd/expression.h b/dmd/expression.h index 8af86d3a35..e63a4a2d27 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -63,6 +63,7 @@ namespace dmd bool equals(const Expression *exp, const Expression *e); bool isLvalue(const Expression *exp); int32_t getFieldIndex(ClassReferenceExp *cre, Type *fieldtype, uint32_t fieldoffset); + void fillTupleExpExps(TupleExp *te, TupleDeclaration *tup); } typedef unsigned char OwnedBy; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 89afbeac6c..0441a81705 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -96,6 +96,37 @@ import dmd.visitor.postorder; enum LOGSEMANTIC = false; +void fillTupleExpExps(TupleExp _this, TupleDeclaration tup) +{ + _this.exps.reserve(tup.objects.length); + foreach (o; *tup.objects) + { + if (Dsymbol s = getDsymbol(o)) + { + /* If tuple element represents a symbol, translate to DsymbolExp + * to supply implicit 'this' if needed later. + */ + Expression e = new DsymbolExp(_this.loc, s); + _this.exps.push(e); + } + else if (auto eo = o.isExpression()) + { + auto e = eo.copy(); + e.loc = _this.loc; // https://issues.dlang.org/show_bug.cgi?id=15669 + _this.exps.push(e); + } + else if (auto t = o.isType()) + { + Expression e = new TypeExp(_this.loc, t); + _this.exps.push(e); + } + else + { + error(_this.loc, "`%s` is not an expression", o.toChars()); + } + } +} + bool isLvalue(Expression _this) { static bool dotVarExpIsLvalue(DotVarExp _this) @@ -2149,7 +2180,10 @@ Lagain: if (tup.needThis() && hasThis(sc)) e = new DotVarExp(loc, new ThisExp(loc), tup); else + { e = new TupleExp(loc, tup); + fillTupleExpExps(e.isTupleExp(), tup); + } e = e.expressionSemantic(sc); return e; } @@ -15240,6 +15274,7 @@ Expression dotIdSemanticProp(DotIdExp exp, Scope* sc, bool gag) return e; } Expression e = new TupleExp(exp.loc, tup); + fillTupleExpExps(e.isTupleExp(), tup); e = e.expressionSemantic(sc); return e; } diff --git a/dmd/typesem.d b/dmd/typesem.d index 3cd45e7084..553f244c99 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -5625,6 +5625,7 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag if (TupleDeclaration tup = d.isTupleDeclaration()) { e = new TupleExp(e.loc, tup); + fillTupleExpExps(e.isTupleExp(), tup); return e.expressionSemantic(sc); } if (d.needThis() && sc.intypeof != 1) @@ -6061,6 +6062,7 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag if (TupleDeclaration tup = d.isTupleDeclaration()) { e = new TupleExp(e.loc, tup); + fillTupleExpExps(e.isTupleExp(), tup); e = e.expressionSemantic(sc); return e; } From 9773c0226ce89708e26f19e658de3f05dfe53ad6 Mon Sep 17 00:00:00 2001 From: Ayan Das <162151508+Ay1nDas@users.noreply.github.com> Date: Fri, 10 Oct 2025 18:30:32 +0530 Subject: [PATCH 013/440] Fix dlang/dmd!21634 (dlang/dmd!21933) --- dmd/errors.d | 2 -- .../dmd/fail_compilation/fail_pretty_errors.d | 16 ++++++------ tests/dmd/fail_compilation/test21634.d | 25 +++++++++++++++++++ 3 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 tests/dmd/fail_compilation/test21634.d diff --git a/dmd/errors.d b/dmd/errors.d index 7fecc0c4f1..3a0e8fb3ec 100644 --- a/dmd/errors.d +++ b/dmd/errors.d @@ -719,8 +719,6 @@ private void printDiagnostic(const(char)* format, va_list ap, ref DiagnosticCont __gshared SourceLoc old_loc; auto loc = info.loc; if (global.params.v.errorPrintMode != ErrorPrintMode.simpleError && - // ignore supplemental messages with same loc - (loc != old_loc || !info.supplemental) && // ignore invalid files loc != SourceLoc.init && // ignore mixins for now diff --git a/tests/dmd/fail_compilation/fail_pretty_errors.d b/tests/dmd/fail_compilation/fail_pretty_errors.d index ebd36a7cc1..8c31433253 100644 --- a/tests/dmd/fail_compilation/fail_pretty_errors.d +++ b/tests/dmd/fail_compilation/fail_pretty_errors.d @@ -2,23 +2,25 @@ REQUIRED_ARGS: -verrors=context TEST_OUTPUT: --- -fail_compilation/fail_pretty_errors.d(29): Error: undefined identifier `a` +fail_compilation/fail_pretty_errors.d(31): Error: undefined identifier `a` a = 1; ^ -fail_compilation/fail_pretty_errors.d-mixin-34(34): Error: undefined identifier `b` +fail_compilation/fail_pretty_errors.d-mixin-36(36): Error: undefined identifier `b` b = 1; ^ -fail_compilation/fail_pretty_errors.d(39): Error: cannot implicitly convert expression `5` of type `int` to `string` +fail_compilation/fail_pretty_errors.d(41): Error: cannot implicitly convert expression `5` of type `int` to `string` string x = 5; ^ -fail_compilation/fail_pretty_errors.d(44): Error: mixin `fail_pretty_errors.testMixin2.mixinTemplate!()` error instantiating +fail_compilation/fail_pretty_errors.d(46): Error: mixin `fail_pretty_errors.testMixin2.mixinTemplate!()` error instantiating mixin mixinTemplate; ^ -fail_compilation/fail_pretty_errors.d(50): Error: invalid array operation `"" + ""` (possible missing []) +fail_compilation/fail_pretty_errors.d(52): Error: invalid array operation `"" + ""` (possible missing []) auto x = ""+""; ^ -fail_compilation/fail_pretty_errors.d(50): did you mean to concatenate (`"" ~ ""`) instead ? -fail_compilation/fail_pretty_errors.d(53): Error: cannot implicitly convert expression `1111` of type `int` to `byte` +fail_compilation/fail_pretty_errors.d(52): did you mean to concatenate (`"" ~ ""`) instead ? + auto x = ""+""; + ^ +fail_compilation/fail_pretty_errors.d(55): Error: cannot implicitly convert expression `1111` of type `int` to `byte` byte ɑ = 1111; ^ --- diff --git a/tests/dmd/fail_compilation/test21634.d b/tests/dmd/fail_compilation/test21634.d new file mode 100644 index 0000000000..2cf2a7b4ac --- /dev/null +++ b/tests/dmd/fail_compilation/test21634.d @@ -0,0 +1,25 @@ +/* +REQUIRED_ARGS: -verrors=context +TEST_OUTPUT: +--- +fail_compilation/test21634.d(22): Error: function literal `(int x) { }` is not callable using argument types `(string)` + (int x) {} ("%s"); + ^ +fail_compilation/test21634.d(22): cannot pass argument `"%s"` of type `string` to parameter `int x` + (int x) {} ("%s"); + ^ +fail_compilation/test21634.d(24): Error: declaration `test21634.main.foo` is already defined + int foo; + ^ +fail_compilation/test21634.d(23): `variable` `foo` is defined here + float foo; + ^ +--- +*/ +void f(int x) {} +void main() +{ + (int x) {} ("%s"); + float foo; + int foo; +} From 5561a6b83f19e5ae3be93e2a4d9394554804193a Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Thu, 9 Oct 2025 10:29:11 +0000 Subject: [PATCH 014/440] issue dlang/dmd!18057, and dlang/dmd!21930 for var declarations --- dmd/importc.d | 7 +++++++ tests/dmd/fail_compilation/fix18057.c | 15 +++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/dmd/fail_compilation/fix18057.c diff --git a/dmd/importc.d b/dmd/importc.d index 9e2b108b75..e6c2a6fcc0 100644 --- a/dmd/importc.d +++ b/dmd/importc.d @@ -528,7 +528,14 @@ Dsymbol handleSymbolRedeclarations(ref Scope sc, Dsymbol s, Dsymbol s2, ScopeDsy * INT x; // match * long x; // collision * We incorrectly ignore these collisions + * when their types are not matching, err on type differences */ + + if (!cTypeEquivalence(vd.type, vd2.type)) + { + .error(vd.loc, "redefinition of `%s` with different type: `%s` vs `%s`", + vd2.ident.toChars(), vd2.type.toChars(), vd.type.toChars()); + } return vd2; } diff --git a/tests/dmd/fail_compilation/fix18057.c b/tests/dmd/fail_compilation/fix18057.c new file mode 100644 index 0000000000..9f73164703 --- /dev/null +++ b/tests/dmd/fail_compilation/fix18057.c @@ -0,0 +1,15 @@ +/* TEST_OUTPUT: +--- +fail_compilation/fix18057.c(105): Error: redefinition of `x` with different type: `int` vs `char` +--- + */ + +// https://issues.dlang.org/show_bug.cgi?id=22316 + +#line 100 + +int x; +extern int x; +typedef int INT; +extern INT x; +extern char x; From 05c267f86cf3c95b393e82b9a552c9f330aaa360 Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Thu, 9 Oct 2025 22:27:03 +0000 Subject: [PATCH 015/440] issue dlang/dmd!18057, and dlang/dmd!21930 for function declarations --- dmd/dscope.d | 2 +- dmd/funcsem.d | 2 +- dmd/importc.d | 9 +++++++++ tests/dmd/fail_compilation/test22344.c | 6 ++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dmd/dscope.d b/dmd/dscope.d index a40fdeaf23..30f0635a2f 100644 --- a/dmd/dscope.d +++ b/dmd/dscope.d @@ -746,7 +746,7 @@ extern (C++) struct Scope (s2var && s2var.storage_class & STC.extern_) && this.func) || s.isFuncDeclaration()) { - return handleSymbolRedeclarations(*s._scope, s, s2, scopesym); + return handleSymbolRedeclarations(this, s, s2, scopesym); } else // aside externs and func decls, we should be free to handle tags { diff --git a/dmd/funcsem.d b/dmd/funcsem.d index 3e489b68a5..1967d911a9 100644 --- a/dmd/funcsem.d +++ b/dmd/funcsem.d @@ -521,7 +521,7 @@ void funcDeclarationSemantic(Scope* sc, FuncDeclaration funcdecl) auto fnext = funcdecl.overnext.isFuncDeclaration(); funcDeclarationSemantic(sc, fnext); auto fn = fnext.type.isTypeFunction(); - if (!fn || !cFuncEquivalence(f, fn)) + if (!fn || !cFuncEquivalence(f, fn) || !cTypeEquivalence(f.next, fn.next)) { .error(funcdecl.loc, "%s `%s` redeclaration with different type", funcdecl.kind, funcdecl.toPrettyChars); //printf("t1: %s\n", f.toChars()); diff --git a/dmd/importc.d b/dmd/importc.d index e6c2a6fcc0..e652d56187 100644 --- a/dmd/importc.d +++ b/dmd/importc.d @@ -588,6 +588,15 @@ Dsymbol handleSymbolRedeclarations(ref Scope sc, Dsymbol s, Dsymbol s2, ScopeDsy */ fd2.overloadInsert(fd); + //for the sake of functions declared in function scope. + // check for return type equivalence also + auto tf1 = fd.type.isTypeFunction(); + auto tf2 = fd2.type.isTypeFunction(); + if (sc.func && !cTypeEquivalence(tf1.next, tf2.next) ) + { + .error(fd.loc, "%s `%s` redeclaration with different type", fd.kind, fd.toPrettyChars); + } + return fd2; } diff --git a/tests/dmd/fail_compilation/test22344.c b/tests/dmd/fail_compilation/test22344.c index a8916f66c0..a14363a7fc 100644 --- a/tests/dmd/fail_compilation/test22344.c +++ b/tests/dmd/fail_compilation/test22344.c @@ -2,6 +2,7 @@ --- fail_compilation/test22344.c(103): Error: function `test22344.func` redeclaration with different type fail_compilation/test22344.c(203): Error: function `test22344.test` redeclaration with different type +fail_compilation/test22344.c(301): Error: function `test22344.foo` redeclaration with different type --- */ @@ -26,3 +27,8 @@ int test(int x, ...) { return x; } + +#line 300 + +int foo(); +double foo(); From 0f944cdd7cadc9dcae4ae823b958b68d7fca18e6 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:19:58 +0300 Subject: [PATCH 016/440] [dscope.d] Move `Scope.createGlobal` to `dmd/dsymbolsem.d` (dlang/dmd!21956) --- dmd/doc.d | 2 +- dmd/dscope.d | 26 -------------------------- dmd/dsymbolsem.d | 35 +++++++++++++++++++++++++++++++---- dmd/semantic2.d | 2 +- dmd/semantic3.d | 2 +- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/dmd/doc.d b/dmd/doc.d index bb7f09b637..94dcb15bc1 100644 --- a/dmd/doc.d +++ b/dmd/doc.d @@ -72,7 +72,7 @@ void gendocfile(Module m, const char[] ddoctext, const char* datetime, ErrorSink // Ddoc files override default macros DocComment.parseMacros(m.escapetable, m.macrotable, ddoctext); - Scope* sc = Scope.createGlobal(m, eSink); // create root scope + Scope* sc = scopeCreateGlobal(m, eSink); // create root scope DocComment* dc = DocComment.parse(m, m.comment); dc.pmacrotable = &m.macrotable; dc.escapetable = m.escapetable; diff --git a/dmd/dscope.d b/dmd/dscope.d index 30f0635a2f..2d24d692c2 100644 --- a/dmd/dscope.d +++ b/dmd/dscope.d @@ -217,32 +217,6 @@ extern (C++) struct Scope return new Scope(); } - extern (D) static Scope* createGlobal(Module _module, ErrorSink eSink) - { - Scope* sc = Scope.alloc(); - *sc = Scope.init; - sc._module = _module; - sc.minst = _module; - sc.scopesym = new ScopeDsymbol(); - sc.scopesym.symtab = new DsymbolTable(); - sc.eSink = eSink; - assert(eSink); - // Add top level package as member of this global scope - Dsymbol m = _module; - while (m.parent) - m = m.parent; - m.addMember(null, sc.scopesym); - m.parent = null; // got changed by addMember() - sc.previews.setFromParams(global.params); - - if (_module.filetype == FileType.c) - sc.inCfile = true; - // Create the module scope underneath the global scope - sc = sc.push(_module); - sc.parent = _module; - return sc; - } - extern (D) Scope* copy() { Scope* sc = Scope.alloc(); diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index ba61f4dd08..1770854c70 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -41,6 +41,7 @@ import dmd.dtemplate; import dmd.dversion; import dmd.enumsem; import dmd.errors; +import dmd.errorsink; import dmd.escape; import dmd.expression; import dmd.expressionsem; @@ -87,6 +88,32 @@ import dmd.visitor; enum LOG = false; +Scope* scopeCreateGlobal(Module _module, ErrorSink eSink) +{ + Scope* sc = Scope.alloc(); + *sc = Scope.init; + sc._module = _module; + sc.minst = _module; + sc.scopesym = new ScopeDsymbol(); + sc.scopesym.symtab = new DsymbolTable(); + sc.eSink = eSink; + assert(eSink); + // Add top level package as member of this global scope + Dsymbol m = _module; + while (m.parent) + m = m.parent; + m.addMember(null, sc.scopesym); + m.parent = null; // got changed by addMember() + sc.previews.setFromParams(global.params); + + if (_module.filetype == FileType.c) + sc.inCfile = true; + // Create the module scope underneath the global scope + sc = sc.push(_module); + sc.parent = _module; + return sc; +} + /************************************* * Does semantic analysis on the public face of declarations. */ @@ -3019,7 +3046,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor Scope* sc = m._scope; // see if already got one from importAll() if (!sc) { - sc = Scope.createGlobal(m, global.errorSink); // create root scope + sc = scopeCreateGlobal(m, global.errorSink); // create root scope } //printf("Module = %p, linkage = %d\n", sc.scopesym, sc.linkage); @@ -3038,7 +3065,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (!m._scope) { sc = sc.pop(); - sc.pop(); // 2 pops because Scope.createGlobal() created 2 + sc.pop(); // 2 pops because scopeCreateGlobal() created 2 } m.semanticRun = PASS.semanticdone; //printf("-Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); @@ -7541,7 +7568,7 @@ extern(C++) class ImportAllVisitor : Visitor * gets imported, it is unaffected by context. * Ignore prevsc. */ - Scope* sc = Scope.createGlobal(m, global.errorSink); // create root scope + Scope* sc = scopeCreateGlobal(m, global.errorSink); // create root scope if (m.md && m.md.msg) m.md.msg = semanticString(sc, m.md.msg, "deprecation message"); @@ -7586,7 +7613,7 @@ extern(C++) class ImportAllVisitor : Visitor s.importAll(sc); } sc = sc.pop(); - sc.pop(); // 2 pops because Scope.createGlobal() created 2 + sc.pop(); // 2 pops because scopeCreateGlobal() created 2 } override void visit(AttribDeclaration atb) diff --git a/dmd/semantic2.d b/dmd/semantic2.d index 838321bf8c..94782e39e3 100644 --- a/dmd/semantic2.d +++ b/dmd/semantic2.d @@ -329,7 +329,7 @@ private extern(C++) final class Semantic2Visitor : Visitor // Note that modules get their own scope, from scratch. // This is so regardless of where in the syntax a module // gets imported, it is unaffected by context. - Scope* sc = Scope.createGlobal(mod, global.errorSink); // create root scope + Scope* sc = scopeCreateGlobal(mod, global.errorSink); // create root scope //printf("Module = %p\n", sc.scopesym); if (mod.members) { diff --git a/dmd/semantic3.d b/dmd/semantic3.d index 9e01b5693e..9f794a0a12 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -196,7 +196,7 @@ private extern(C++) final class Semantic3Visitor : Visitor // Note that modules get their own scope, from scratch. // This is so regardless of where in the syntax a module // gets imported, it is unaffected by context. - Scope* sc = Scope.createGlobal(mod, global.errorSink); // create root scope + Scope* sc = scopeCreateGlobal(mod, global.errorSink); // create root scope //printf("Module = %p\n", sc.scopesym); if (mod.members) { From 9da9a31a3ba6c496d8c8388b7506209640610708 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 11 Oct 2025 10:41:35 -0700 Subject: [PATCH 017/440] add integral promotions tests (dlang/dmd!21958) --- tests/dmd/runnable/mars1.d | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/dmd/runnable/mars1.d b/tests/dmd/runnable/mars1.d index 04731ac908..7455df41ca 100644 --- a/tests/dmd/runnable/mars1.d +++ b/tests/dmd/runnable/mars1.d @@ -9,6 +9,31 @@ template tuple(A...) { alias tuple = A; } /////////////////////// +void testIntegralPromotions() +{ + uint uconv1(int q, ubyte p) { return p; } assert(uconv1(0,0xFF) == 0xFF); + uint uconv2(int q, ushort p) { return p; } assert(uconv2(0,0xFFFF) == 0xFFFF); + uint uconv3(int q, uint p) { return p; } assert(uconv3(0,0xFFFF_FFFF) == 0xFFFF_FFFF); + //uint uconv4(int q, ulong p) { return p; } + + ulong uconv5(int q, ubyte p) { return p; } assert(uconv5(0,0xFF) == 0xFF); + ulong uconv6(int q, ushort p) { return p; } assert(uconv6(0,0xFFFF) == 0xFFFF); + ulong uconv7(int q, uint p) { return p; } assert(uconv7(0,0xFFFF_FFFF) == 0xFFFF_FFFF); + ulong uconv8(int q, ulong p) { return p; } assert(uconv8(0,0xFFFF_FFFF_FFFF_FFFF) == 0xFFFF_FFFF_FFFF_FFFF); + + uint sconv1(int q, byte p) { return p; } assert(sconv1(0,cast(byte)0xFF) == 0xFFFF_FFFF); + uint sconv2(int q, short p) { return p; } assert(sconv2(0,cast(short)0xFFFF) == 0xFFFF_FFFF); + uint sconv3(int q, int p) { return p; } assert(sconv3(0,0xFFFF_FFFF) == 0xFFFF_FFFF); + //uint sconv4(int q, long p) { return p; } + + ulong sconv5(int q, byte p) { return p; } assert(sconv5(0,cast(byte)0xFF) == 0xFFFF_FFFF_FFFF_FFFF); + ulong sconv6(int q, short p) { return p; } assert(sconv6(0,cast(short)0xFFFF) == 0xFFFF_FFFF_FFFF_FFFF); + ulong sconv7(int q, int p) { return p; } assert(sconv7(0,0xFFFF_FFFF) == 0xFFFF_FFFF_FFFF_FFFF); + ulong sconv8(int q, long p) { return p; } assert(sconv8(0,0xFFFF_FFFF_FFFF_FFFF) == 0xFFFF_FFFF_FFFF_FFFF); +} + +/////////////////////// + // https://github.com/dlang/dmd/pull/11441 long sdiv1(long l) @@ -2566,6 +2591,8 @@ void test10() int main() { + testIntegralPromotions(); + // All the various integer divide tests testsdiv2(); testulldiv(); From 1f2d6575c975b7824281dab8919e1aceb13ec35c Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sun, 12 Oct 2025 03:15:55 +0300 Subject: [PATCH 018/440] Move alignment to dsymbolsem (dlang/dmd!21957) --- dmd/dscope.d | 17 +---------------- dmd/dsymbolsem.d | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dmd/dscope.d b/dmd/dscope.d index 2d24d692c2..2dfc321f32 100644 --- a/dmd/dscope.d +++ b/dmd/dscope.d @@ -820,22 +820,7 @@ extern (C++) struct Scope // assert(0); } } - /****************************** - */ - extern (D) structalign_t alignment() - { - if (aligndecl) - { - auto ad = aligndecl.getAlignment(&this); - return ad.salign; - } - else - { - structalign_t sa; - sa.setDefault(); - return sa; - } - } + @safe @nogc pure nothrow const: /********************************** * Checks whether the current scope (or any of its parents) is deprecated. diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 1770854c70..97d7f47e5b 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -88,6 +88,21 @@ import dmd.visitor; enum LOG = false; +structalign_t alignment(Scope* _this) +{ + if (_this.aligndecl) + { + auto ad = _this.aligndecl.getAlignment(_this); + return ad.salign; + } + else + { + structalign_t sa; + sa.setDefault(); + return sa; + } +} + Scope* scopeCreateGlobal(Module _module, ErrorSink eSink) { Scope* sc = Scope.alloc(); From 982074f3b8348a3600dfb216bc1651f7e0dcb6cd Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sun, 12 Oct 2025 17:08:37 +0300 Subject: [PATCH 019/440] Move search_correct to dsymbolsem (dlang/dmd!21959) --- dmd/dscope.d | 60 ---------------------------------------------- dmd/dsymbolsem.d | 62 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/dmd/dscope.d b/dmd/dscope.d index 2dfc321f32..fd487033c9 100644 --- a/dmd/dscope.d +++ b/dmd/dscope.d @@ -39,7 +39,6 @@ import dmd.importc; import dmd.location; import dmd.common.outbuffer; import dmd.root.rmem; -import dmd.root.speller; import dmd.statement; import dmd.target; import dmd.tokens; @@ -574,65 +573,6 @@ extern (C++) struct Scope return s; } - extern (D) Dsymbol search_correct(Identifier ident) - { - if (global.gag) - return null; // don't do it for speculative compiles; too time consuming - - /************************************************ - * Given the failed search attempt, try to find - * one with a close spelling. - * Params: - * seed = identifier to search for - * cost = set to the cost, which rises with each outer scope - * Returns: - * Dsymbol if found, null if not - */ - extern (D) Dsymbol scope_search_fp(const(char)[] seed, out int cost) - { - //printf("scope_search_fp('%s')\n", seed); - /* If not in the lexer's string table, it certainly isn't in the symbol table. - * Doing this first is a lot faster. - */ - if (!seed.length) - return null; - Identifier id = Identifier.lookup(seed); - if (!id) - return null; - Scope* sc = &this; - Module.clearCache(); - Dsymbol scopesym; - Dsymbol s = sc.search(Loc.initial, id, scopesym, SearchOpt.ignoreErrors); - if (!s) - return null; - - // Do not show `@disable`d declarations - if (auto decl = s.isDeclaration()) - if (decl.storage_class & STC.disable) - return null; - // Or `deprecated` ones if we're not in a deprecated scope - if (s.isDeprecated() && !sc.isDeprecated()) - return null; - - for (cost = 0; sc; sc = sc.enclosing, ++cost) - if (sc.scopesym == scopesym) - break; - if (scopesym != s.parent) - { - ++cost; // got to the symbol through an import - if (s.visible().kind == Visibility.Kind.private_) - return null; - } - return s; - } - - Dsymbol scopesym; - // search for exact name first - if (auto s = search(Loc.initial, ident, scopesym, SearchOpt.ignoreErrors)) - return s; - return speller!scope_search_fp(ident.toString()); - } - /************************************ * Maybe `ident` was a C or C++ name. Check for that, * and suggest the D equivalent. diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 97d7f47e5b..9b75ad93ee 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -68,8 +68,9 @@ debug import dmd.printast; import dmd.root.array; import dmd.root.filename; import dmd.root.string; -import dmd.common.outbuffer; import dmd.root.rmem; +import dmd.root.speller; +import dmd.common.outbuffer; import dmd.rootobject; import dmd.safe; import dmd.semantic2; @@ -88,6 +89,65 @@ import dmd.visitor; enum LOG = false; +Dsymbol search_correct(Scope* _this, Identifier ident) +{ + if (global.gag) + return null; // don't do it for speculative compiles; too time consuming + + /************************************************ + * Given the failed search attempt, try to find + * one with a close spelling. + * Params: + * seed = identifier to search for + * cost = set to the cost, which rises with each outer scope + * Returns: + * Dsymbol if found, null if not + */ + Dsymbol scope_search_fp(const(char)[] seed, out int cost) + { + //printf("scope_search_fp('%s')\n", seed); + /* If not in the lexer's string table, it certainly isn't in the symbol table. + * Doing this first is a lot faster. + */ + if (!seed.length) + return null; + Identifier id = Identifier.lookup(seed); + if (!id) + return null; + Scope* sc = _this; + Module.clearCache(); + Dsymbol scopesym; + Dsymbol s = sc.search(Loc.initial, id, scopesym, SearchOpt.ignoreErrors); + if (!s) + return null; + + // Do not show `@disable`d declarations + if (auto decl = s.isDeclaration()) + if (decl.storage_class & STC.disable) + return null; + // Or `deprecated` ones if we're not in a deprecated scope + if (s.isDeprecated() && !sc.isDeprecated()) + return null; + + for (cost = 0; sc; sc = sc.enclosing, ++cost) + if (sc.scopesym == scopesym) + break; + if (scopesym != s.parent) + { + ++cost; // got to the symbol through an import + if (s.visible().kind == Visibility.Kind.private_) + return null; + } + return s; + } + + Dsymbol scopesym; + // search for exact name first + if (auto s = _this.search(Loc.initial, ident, scopesym, SearchOpt.ignoreErrors)) + return s; + return speller!scope_search_fp(ident.toString()); +} + structalign_t alignment(Scope* _this) { if (_this.aligndecl) From 50b1cc276a65a50750bd1e4623de2683202f3e56 Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Mon, 13 Oct 2025 17:02:45 +1300 Subject: [PATCH 020/440] Fix null deref in optional_methods test (dlang/dmd!21963) --- tests/dmd/unit/objc/protocols/optional_methods.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dmd/unit/objc/protocols/optional_methods.d b/tests/dmd/unit/objc/protocols/optional_methods.d index 7350a9004a..13cbb621a0 100644 --- a/tests/dmd/unit/objc/protocols/optional_methods.d +++ b/tests/dmd/unit/objc/protocols/optional_methods.d @@ -179,7 +179,7 @@ unittest void main() { - Foo f; + Foo f = new Foo; f.foo(); } }.stripDelimited; From 75d3083d344a2daf2a615f4ef516647a5c52112c Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Mon, 13 Oct 2025 17:45:00 +1300 Subject: [PATCH 021/440] Fix null dereference in expressionsem (dlang/dmd!21964) --- dmd/expressionsem.d | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 0441a81705..3b9ccc3ac6 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -4714,7 +4714,11 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor setError(); } } - scope (exit) result.rvalue = exp.rvalue; + scope (exit) + { + if (result !is null) + result.rvalue = exp.rvalue; + } Dsymbol scopesym; Dsymbol s = sc.search(exp.loc, exp.ident, scopesym); @@ -6806,7 +6810,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { setError(); } - else + else if (result !is null) { result.rvalue = true; } From bd953bb4b9b470de129140ce74cafded3d2b2905 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Mon, 13 Oct 2025 10:21:34 +0300 Subject: [PATCH 022/440] Break semantic dependency of `dmd/dscope.d` on `dmd/dsymbolsem.d` (dlang/dmd!21962) --- dmd/cxxfrontend.d | 7 ++ dmd/dscope.d | 187 -------------------------------------------- dmd/dsymbol.h | 1 + dmd/dsymbolsem.d | 187 ++++++++++++++++++++++++++++++++++++++++++++ dmd/expressionsem.d | 2 +- dmd/frontend.h | 1 - 6 files changed, 196 insertions(+), 189 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 6c7d961110..045e4458bf 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -301,6 +301,13 @@ bool isOverlappedWith(VarDeclaration vd, VarDeclaration v){ return dmd.dsymbolsem.isOverlappedWith(vd, v); } +Dsymbol search(Scope* sc, Loc loc, Identifier ident, out Dsymbol pscopesym, + SearchOptFlags flags = SearchOpt.all) +{ + import dmd.dsymbolsem; + return dmd.dsymbolsem.search(sc, loc, ident, pscopesym, flags); +} + /*********************************************************** * dtemplate.d */ diff --git a/dmd/dscope.d b/dmd/dscope.d index fd487033c9..7be93edded 100644 --- a/dmd/dscope.d +++ b/dmd/dscope.d @@ -26,7 +26,6 @@ import dmd.dmodule; import dmd.doc; import dmd.dstruct; import dmd.dsymbol; -import dmd.dsymbolsem; import dmd.dtemplate; import dmd.expression; import dmd.errors; @@ -387,192 +386,6 @@ extern (C++) struct Scope } } - /************************************ - * Perform unqualified name lookup by following the chain of scopes up - * until found. - * - * Params: - * loc = location to use for error messages - * ident = name to look up - * pscopesym = if supplied and name is found, set to scope that ident was found in, otherwise set to null - * flags = modify search based on flags - * - * Returns: - * symbol if found, null if not - */ - extern (C++) Dsymbol search(Loc loc, Identifier ident, out Dsymbol pscopesym, SearchOptFlags flags = SearchOpt.all) - { - version (LOGSEARCH) - { - printf("Scope.search(%p, '%s' flags=x%x)\n", &this, ident.toChars(), flags); - // Print scope chain - for (Scope* sc = &this; sc; sc = sc.enclosing) - { - if (!sc.scopesym) - continue; - printf("\tscope %s\n", sc.scopesym.toChars()); - } - - static void printMsg(string txt, Dsymbol s) - { - printf("%.*s %s.%s, kind = '%s'\n", cast(int)txt.length, txt.ptr, - s.parent ? s.parent.toChars() : "", s.toChars(), s.kind()); - } - } - - // This function is called only for unqualified lookup - assert(!(flags & (SearchOpt.localsOnly | SearchOpt.importsOnly))); - - /* If ident is "start at module scope", only look at module scope - */ - if (ident == Id.empty) - { - // Look for module scope - for (Scope* sc = &this; sc; sc = sc.enclosing) - { - assert(sc != sc.enclosing); - if (!sc.scopesym) - continue; - if (Dsymbol s = sc.scopesym.isModule()) - { - //printMsg("\tfound", s); - pscopesym = sc.scopesym; - return s; - } - } - return null; - } - - Dsymbol checkAliasThis(AggregateDeclaration ad, Identifier ident, SearchOptFlags flags, Expression* exp) - { - import dmd.mtype; - if (!ad || !ad.aliasthis) - return null; - - Declaration decl = ad.aliasthis.sym.isDeclaration(); - if (!decl) - return null; - - Type t = decl.type; - ScopeDsymbol sds; - TypeClass tc; - TypeStruct ts; - switch(t.ty) - { - case Tstruct: - ts = cast(TypeStruct)t; - sds = ts.sym; - break; - case Tclass: - tc = cast(TypeClass)t; - sds = tc.sym; - break; - case Tinstance: - sds = (cast(TypeInstance)t).tempinst; - break; - case Tenum: - sds = (cast(TypeEnum)t).sym; - break; - default: break; - } - - if (!sds) - return null; - - Dsymbol ret = sds.search(loc, ident, flags); - if (ret) - { - *exp = new DotIdExp(loc, *exp, ad.aliasthis.ident); - *exp = new DotIdExp(loc, *exp, ident); - return ret; - } - - if (!ts && !tc) - return null; - - Dsymbol s; - *exp = new DotIdExp(loc, *exp, ad.aliasthis.ident); - if (ts && !(ts.att & AliasThisRec.tracing)) - { - ts.att = cast(AliasThisRec)(ts.att | AliasThisRec.tracing); - s = checkAliasThis(sds.isAggregateDeclaration(), ident, flags, exp); - ts.att = cast(AliasThisRec)(ts.att & ~AliasThisRec.tracing); - } - else if(tc && !(tc.att & AliasThisRec.tracing)) - { - tc.att = cast(AliasThisRec)(tc.att | AliasThisRec.tracing); - s = checkAliasThis(sds.isAggregateDeclaration(), ident, flags, exp); - tc.att = cast(AliasThisRec)(tc.att & ~AliasThisRec.tracing); - } - return s; - } - - Dsymbol searchScopes(SearchOptFlags flags) - { - for (Scope* sc = &this; sc; sc = sc.enclosing) - { - assert(sc != sc.enclosing); - if (!sc.scopesym) - continue; - //printf("\tlooking in scopesym '%s', kind = '%s', flags = x%x\n", sc.scopesym.toChars(), sc.scopesym.kind(), flags); - - if (sc.scopesym.isModule()) - flags |= SearchOpt.unqualifiedModule; // tell Module.search() that SearchOpt.localsOnly is to be obeyed - else if (sc.inCfile && sc.scopesym.isStructDeclaration()) - continue; // C doesn't have struct scope - - if (Dsymbol s = sc.scopesym.search(loc, ident, flags)) - { - if (flags & SearchOpt.tagNameSpace) - { - // ImportC: if symbol is not a tag, look for it in tag table - if (!s.isScopeDsymbol()) - { - auto ps = cast(void*)s in sc._module.tagSymTab; - if (!ps) - goto NotFound; - s = *ps; - } - } - //printMsg("\tfound local", s); - pscopesym = sc.scopesym; - return s; - } - - NotFound: - if (sc.previews.fixAliasThis) - { - Expression exp = new ThisExp(loc); - if (Dsymbol aliasSym = checkAliasThis(sc.scopesym.isAggregateDeclaration(), ident, flags, &exp)) - { - //printf("found aliassym: %s\n", aliasSym.toChars()); - pscopesym = new ExpressionDsymbol(exp); - return aliasSym; - } - } - - // Stop when we hit a module, but keep going if that is not just under the global scope - if (sc.scopesym.isModule() && !(sc.enclosing && !sc.enclosing.enclosing)) - break; - } - return null; - } - - if (this.ignoresymbolvisibility) - flags |= SearchOpt.ignoreVisibility; - - // First look in local scopes - Dsymbol s = searchScopes(flags | SearchOpt.localsOnly); - version (LOGSEARCH) if (s) printMsg("-Scope.search() found local", s); - if (!s) - { - // Second look in imported modules - s = searchScopes(flags | SearchOpt.importsOnly); - version (LOGSEARCH) if (s) printMsg("-Scope.search() found import", s); - } - return s; - } - /************************************ * Maybe `ident` was a C or C++ name. Check for that, * and suggest the D equivalent. diff --git a/dmd/dsymbol.h b/dmd/dsymbol.h index 9f18c4ea37..862f070aa3 100644 --- a/dmd/dsymbol.h +++ b/dmd/dsymbol.h @@ -436,4 +436,5 @@ namespace dmd void runDeferredSemantic2(); void runDeferredSemantic3(); bool isOverlappedWith(VarDeclaration *vd, VarDeclaration *v); + Dsymbol* search(Scope *sc, Loc loc, Identifier* ident, Dsymbol*& pscopesym, uint32_t flags = 0u); } diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 9b75ad93ee..9c6e669dbd 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -89,6 +89,193 @@ import dmd.visitor; enum LOG = false; +/************************************ + * Perform unqualified name lookup by following the chain of scopes up + * until found. + * + * Params: + * _this = Scope object + * loc = location to use for error messages + * ident = name to look up + * pscopesym = if supplied and name is found, set to scope that ident was found in, otherwise set to null + * flags = modify search based on flags + * + * Returns: + * symbol if found, null if not + */ +Dsymbol search(Scope* _this, Loc loc, Identifier ident, out Dsymbol pscopesym, SearchOptFlags flags = SearchOpt.all) +{ + version (LOGSEARCH) + { + printf("Scope.search(%p, '%s' flags=x%x)\n", _this, ident.toChars(), flags); + // Print scope chain + for (Scope* sc = _this; sc; sc = sc.enclosing) + { + if (!sc.scopesym) + continue; + printf("\tscope %s\n", sc.scopesym.toChars()); + } + + static void printMsg(string txt, Dsymbol s) + { + printf("%.*s %s.%s, kind = '%s'\n", cast(int)txt.length, txt.ptr, + s.parent ? s.parent.toChars() : "", s.toChars(), s.kind()); + } + } + + // This function is called only for unqualified lookup + assert(!(flags & (SearchOpt.localsOnly | SearchOpt.importsOnly))); + + /* If ident is "start at module scope", only look at module scope + */ + if (ident == Id.empty) + { + // Look for module scope + for (Scope* sc = _this; sc; sc = sc.enclosing) + { + assert(sc != sc.enclosing); + if (!sc.scopesym) + continue; + if (Dsymbol s = sc.scopesym.isModule()) + { + //printMsg("\tfound", s); + pscopesym = sc.scopesym; + return s; + } + } + return null; + } + + Dsymbol checkAliasThis(AggregateDeclaration ad, Identifier ident, SearchOptFlags flags, Expression* exp) + { + import dmd.mtype; + if (!ad || !ad.aliasthis) + return null; + + Declaration decl = ad.aliasthis.sym.isDeclaration(); + if (!decl) + return null; + + Type t = decl.type; + ScopeDsymbol sds; + TypeClass tc; + TypeStruct ts; + switch(t.ty) + { + case Tstruct: + ts = cast(TypeStruct)t; + sds = ts.sym; + break; + case Tclass: + tc = cast(TypeClass)t; + sds = tc.sym; + break; + case Tinstance: + sds = (cast(TypeInstance)t).tempinst; + break; + case Tenum: + sds = (cast(TypeEnum)t).sym; + break; + default: break; + } + + if (!sds) + return null; + + Dsymbol ret = sds.search(loc, ident, flags); + if (ret) + { + *exp = new DotIdExp(loc, *exp, ad.aliasthis.ident); + *exp = new DotIdExp(loc, *exp, ident); + return ret; + } + + if (!ts && !tc) + return null; + + Dsymbol s; + *exp = new DotIdExp(loc, *exp, ad.aliasthis.ident); + if (ts && !(ts.att & AliasThisRec.tracing)) + { + ts.att = cast(AliasThisRec)(ts.att | AliasThisRec.tracing); + s = checkAliasThis(sds.isAggregateDeclaration(), ident, flags, exp); + ts.att = cast(AliasThisRec)(ts.att & ~AliasThisRec.tracing); + } + else if(tc && !(tc.att & AliasThisRec.tracing)) + { + tc.att = cast(AliasThisRec)(tc.att | AliasThisRec.tracing); + s = checkAliasThis(sds.isAggregateDeclaration(), ident, flags, exp); + tc.att = cast(AliasThisRec)(tc.att & ~AliasThisRec.tracing); + } + return s; + } + + Dsymbol searchScopes(SearchOptFlags flags) + { + for (Scope* sc = _this; sc; sc = sc.enclosing) + { + assert(sc != sc.enclosing); + if (!sc.scopesym) + continue; + //printf("\tlooking in scopesym '%s', kind = '%s', flags = x%x\n", sc.scopesym.toChars(), sc.scopesym.kind(), flags); + + if (sc.scopesym.isModule()) + flags |= SearchOpt.unqualifiedModule; // tell Module.search() that SearchOpt.localsOnly is to be obeyed + else if (sc.inCfile && sc.scopesym.isStructDeclaration()) + continue; // C doesn't have struct scope + + if (Dsymbol s = sc.scopesym.search(loc, ident, flags)) + { + if (flags & SearchOpt.tagNameSpace) + { + // ImportC: if symbol is not a tag, look for it in tag table + if (!s.isScopeDsymbol()) + { + auto ps = cast(void*)s in sc._module.tagSymTab; + if (!ps) + goto NotFound; + s = *ps; + } + } + //printMsg("\tfound local", s); + pscopesym = sc.scopesym; + return s; + } + + NotFound: + if (sc.previews.fixAliasThis) + { + Expression exp = new ThisExp(loc); + if (Dsymbol aliasSym = checkAliasThis(sc.scopesym.isAggregateDeclaration(), ident, flags, &exp)) + { + //printf("found aliassym: %s\n", aliasSym.toChars()); + pscopesym = new ExpressionDsymbol(exp); + return aliasSym; + } + } + + // Stop when we hit a module, but keep going if that is not just under the global scope + if (sc.scopesym.isModule() && !(sc.enclosing && !sc.enclosing.enclosing)) + break; + } + return null; + } + + if (_this.ignoresymbolvisibility) + flags |= SearchOpt.ignoreVisibility; + + // First look in local scopes + Dsymbol s = searchScopes(flags | SearchOpt.localsOnly); + version (LOGSEARCH) if (s) printMsg("-Scope.search() found local", s); + if (!s) + { + // Second look in imported modules + s = searchScopes(flags | SearchOpt.importsOnly); + version (LOGSEARCH) if (s) printMsg("-Scope.search() found import", s); + } + return s; +} + Dsymbol search_correct(Scope* _this, Identifier ident) { if (global.gag) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 3b9ccc3ac6..d0d76b0332 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -17318,7 +17318,7 @@ private VarDeclaration makeThis2Argument(Loc loc, Scope* sc, FuncDeclaration fd) bool verifyHookExist(Loc loc, ref Scope sc, Identifier id, string description, Identifier module_ = Id.object) { Dsymbol pscopesym; - auto rootSymbol = sc.search(loc, Id.empty, pscopesym); + auto rootSymbol = search(&sc, loc, Id.empty, pscopesym); if (auto moduleSymbol = rootSymbol.search(loc, module_)) if (moduleSymbol.search(loc, id)) return true; diff --git a/dmd/frontend.h b/dmd/frontend.h index b2a7b85aa7..35760fbeb7 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -7242,7 +7242,6 @@ struct Scope final Identifier* prevAnchor; AliasDeclaration* aliasAsg; StructDeclaration* argStruct; - Dsymbol* search(Loc loc, Identifier* ident, Dsymbol*& pscopesym, uint32_t flags = 0u); Scope() : enclosing(), _module(), From 8e81907e541d8cd86f4c1146588046b81e4d8720 Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Mon, 13 Oct 2025 20:22:24 +1300 Subject: [PATCH 023/440] Refix null deref in optional_methods test to not new an interface (dlang/dmd!21966) --- tests/dmd/unit/objc/protocols/optional_methods.d | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/dmd/unit/objc/protocols/optional_methods.d b/tests/dmd/unit/objc/protocols/optional_methods.d index 13cbb621a0..33e35b22db 100644 --- a/tests/dmd/unit/objc/protocols/optional_methods.d +++ b/tests/dmd/unit/objc/protocols/optional_methods.d @@ -177,9 +177,14 @@ unittest @optional void foo()(); } + extern (Objective-C) + class Bar : Foo + { + } + void main() { - Foo f = new Foo; + Foo f = new Bar; f.foo(); } }.stripDelimited; @@ -190,7 +195,7 @@ unittest "Error: function test.Foo.foo!().foo template cannot be optional" ), Diagnostic( - SourceLoc(filename, 12, 10), + SourceLoc(filename, 17, 10), "Error: template instance test.Foo.foo!() error instantiating" ) ]; From a52538050898862b35c9a3bb0f236a27a8b68048 Mon Sep 17 00:00:00 2001 From: Dennis Date: Tue, 14 Oct 2025 14:33:12 +0200 Subject: [PATCH 024/440] Deduplicate overload handling in resolvePropertiesOnly (dlang/dmd!21972) Co-authored-by: Dennis Korpel --- dmd/expressionsem.d | 53 +++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index d0d76b0332..20862b9b54 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -1906,41 +1906,18 @@ Expression resolvePropertiesOnly(Scope* sc, Expression e1) { //printf("e1 = %s %s\n", Token.toChars(e1.op), e1.toChars()); - Expression handleOverloadSet(OverloadSet os) - { - assert(os); - foreach (s; os.a) - { - auto fd = s.isFuncDeclaration(); - auto td = s.isTemplateDeclaration(); - if (fd) - { - if (fd.type.isTypeFunction().isProperty) - return resolveProperties(sc, e1); - } - else if (td && td.onemember && (fd = td.onemember.isFuncDeclaration()) !is null) - { - if (fd.type.isTypeFunction().isProperty || - (fd.storage_class2 & STC.property) || - (td._scope.stc & STC.property)) - return resolveProperties(sc, e1); - } - } - return e1; - } - Expression handleTemplateDecl(TemplateDeclaration td) { assert(td); - if (td.onemember) + if (!td.onemember) + return e1; + + if (auto fd = td.onemember.isFuncDeclaration()) { - if (auto fd = td.onemember.isFuncDeclaration()) - { - if (fd.type.isTypeFunction().isProperty || - (fd.storage_class2 & STC.property) || - (td._scope.stc & STC.property)) - return resolveProperties(sc, e1); - } + if (fd.type.isTypeFunction().isProperty || + (fd.storage_class2 & STC.property) || + (td._scope.stc & STC.property)) + return resolveProperties(sc, e1); } return e1; } @@ -1953,6 +1930,20 @@ Expression resolvePropertiesOnly(Scope* sc, Expression e1) return e1; } + Expression handleOverloadSet(OverloadSet os) + { + assert(os); + foreach (s; os.a) + { + if (auto fd = s.isFuncDeclaration()) + return handleFuncDecl(fd); + + if (auto td = s.isTemplateDeclaration()) + return handleTemplateDecl(td); + } + return e1; + } + if (auto de = e1.isDotExp()) { if (auto os = de.e2.isOverExp()) From a3371118f9db4a5120dd682326b4e8613e4657d1 Mon Sep 17 00:00:00 2001 From: Sergii K Date: Wed, 15 Oct 2025 10:07:45 +0300 Subject: [PATCH 025/440] Optimize test target filtering (dlang/dmd!21971) --- tests/dmd/run.d | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/dmd/run.d b/tests/dmd/run.d index cf7b3d1986..d652292bd4 100755 --- a/tests/dmd/run.d +++ b/tests/dmd/run.d @@ -481,12 +481,16 @@ Target[] filterTargets(Target[] targets, const string[string] env) quitSilently(1); Target[] targetsThatNeedUpdating; + const dmdLastModified = env["DMD"].timeLastModified.ifThrown(SysTime.init); foreach (t; targets) { immutable testName = t.normalizedTestName; - auto resultRunTime = resultsDir.buildPath(testName ~ ".out").timeLastModified.ifThrown(SysTime.init); - if (!force && resultRunTime > testPath(testName).timeLastModified && - resultRunTime > env["DMD"].timeLastModified.ifThrown(SysTime.init)) + auto testResultPath = resultsDir.buildPath(testName ~ ".out"); + auto resultRunTime = testResultPath.timeLastModified.ifThrown(SysTime.init); + auto testSourcePath = testPath(testName); + auto sourceLastModified = testSourcePath.timeLastModified.ifThrown(SysTime.init); + if (!force && resultRunTime > sourceLastModified && + resultRunTime > dmdLastModified) log("%s is already up-to-date", testName); else targetsThatNeedUpdating ~= t; From 16f33b9ad2e9b03a232d28214478036efe63d401 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Thu, 16 Oct 2025 01:16:26 +0300 Subject: [PATCH 026/440] Break semantic dependency of `dmd/dtemplate.d` on `dmd/dsymbolsem.d` (dlang/dmd!21917) --- dmd/doc.d | 14 ++++++---- dmd/dsymbolsem.d | 2 ++ dmd/dtemplate.d | 18 ++++--------- dmd/dtoh.d | 2 ++ dmd/expressionsem.d | 6 ++++- dmd/frontend.h | 1 + dmd/funcsem.d | 6 ++++- dmd/json.d | 2 ++ dmd/mangle/cpp.d | 5 ++++ dmd/mangle/cppwin.d | 4 +++ dmd/template.h | 1 + dmd/templatesem.d | 38 ++++++++++++++++++---------- dmd/typesem.d | 2 ++ tests/dmd/fail_compilation/fail222.d | 2 +- 14 files changed, 69 insertions(+), 34 deletions(-) diff --git a/dmd/doc.d b/dmd/doc.d index 94dcb15bc1..fb1d3df44e 100644 --- a/dmd/doc.d +++ b/dmd/doc.d @@ -33,6 +33,7 @@ import dmd.dscope; import dmd.dstruct; import dmd.dsymbol; import dmd.dsymbolsem; +import dmd.templatesem : computeOneMember; import dmd.dtemplate; import dmd.errorsink; import dmd.func; @@ -909,8 +910,9 @@ bool isCVariadicParameter(Dsymbols* a, const(char)[] p) @safe return false; } -Dsymbol getEponymousMember(TemplateDeclaration td) @safe +Dsymbol getEponymousMember(TemplateDeclaration td) { + td.computeOneMember(); if (!td.onemember) return null; if (AggregateDeclaration ad = td.onemember.isAggregateDeclaration()) @@ -924,7 +926,7 @@ Dsymbol getEponymousMember(TemplateDeclaration td) @safe return null; } -TemplateDeclaration getEponymousParent(Dsymbol s) @safe +TemplateDeclaration getEponymousParent(Dsymbol s) { if (!s.parent) return null; @@ -1091,8 +1093,9 @@ bool emitAnchorName(ref OutBuffer buf, Dsymbol s, Scope* sc, bool includeParent) if (dot) buf.writeByte('.'); // Use "this" not "__ctor" - TemplateDeclaration td; - if (s.isCtorDeclaration() || ((td = s.isTemplateDeclaration()) !is null && td.onemember && td.onemember.isCtorDeclaration())) + TemplateDeclaration td = s.isTemplateDeclaration(); + td.computeOneMember(); + if (s.isCtorDeclaration() || (td !is null && td.onemember && td.onemember.isCtorDeclaration())) { buf.writestring("this"); } @@ -2622,11 +2625,12 @@ Parameter isFunctionParameter(Dsymbols* a, const(char)[] p) @safe /**************************************************** */ -Parameter isEponymousFunctionParameter(Dsymbols* a, const(char)[] p) @safe +Parameter isEponymousFunctionParameter(Dsymbols* a, const(char)[] p) { foreach (Dsymbol dsym; *a) { TemplateDeclaration td = dsym.isTemplateDeclaration(); + td.computeOneMember(); if (td && td.onemember) { /* Case 1: we refer to a template declaration inside the template diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 9c6e669dbd..a90f8ba662 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -5726,6 +5726,8 @@ private extern(C++) class AddMemberVisitor : Visitor if (!s2.overloadInsert(dsym)) { + if (auto _td = s2.isTemplateDeclaration()) + _td.computeOneMember(); sds.multiplyDefined(Loc.initial, dsym, s2); dsym.errors = true; } diff --git a/dmd/dtemplate.d b/dmd/dtemplate.d index 306d3b4895..b043671470 100644 --- a/dmd/dtemplate.d +++ b/dmd/dtemplate.d @@ -53,7 +53,6 @@ import dmd.dinterpret; import dmd.dmodule; import dmd.dscope; import dmd.dsymbol; -import dmd.dsymbolsem : oneMembers; import dmd.errors; import dmd.errorsink; import dmd.expression; @@ -268,6 +267,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol bool isTrivialAlias; /// matches pattern `template Alias(T) { alias Alias = qualifiers(T); }` bool deprecated_; /// this template declaration is deprecated bool isCmacro; /// Whether this template is a translation of a C macro + bool haveComputedOneMember; /// Whether computeOneMeber has been called Visibility visibility; // threaded list of previous instantiation attempts on stack @@ -306,20 +306,12 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol this.literal = literal; this.ismixin = ismixin; this.isstatic = true; + this.haveComputedOneMember = false; this.visibility = Visibility(Visibility.Kind.undefined); + } - // Compute in advance for Ddoc's use - // https://issues.dlang.org/show_bug.cgi?id=11153: ident could be NULL if parsing fails. - if (!members || !ident) - return; - - Dsymbol s; - if (!oneMembers(members, s, ident) || !s) - return; - - onemember = s; - s.parent = this; - + extern(D) void computeIsTrivialAlias(Dsymbol s) + { /* Set isTrivialAliasSeq if this fits the pattern: * template AliasSeq(T...) { alias AliasSeq = T; } * or set isTrivialAlias if this fits the pattern: diff --git a/dmd/dtoh.d b/dmd/dtoh.d index 0679192b59..199e26fea6 100644 --- a/dmd/dtoh.d +++ b/dmd/dtoh.d @@ -21,6 +21,7 @@ import dmd.arraytypes; import dmd.attrib; import dmd.dsymbol; import dmd.dsymbolsem; +import dmd.templatesem : computeOneMember; import dmd.errors; import dmd.errorsink; import dmd.globals; @@ -2147,6 +2148,7 @@ public: if (!shouldEmitAndMarkVisited(td)) return; + td.computeOneMember(); if (!td.parameters || !td.onemember || (!td.onemember.isStructDeclaration && !td.onemember.isClassDeclaration && !td.onemember.isFuncDeclaration)) { visit(cast(AST.Dsymbol)td); diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 20862b9b54..9726d88be9 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -30,6 +30,7 @@ import dmd.ctorflow; import dmd.dscope; import dmd.dsymbol; import dmd.dsymbolsem; +import dmd.templatesem : computeOneMember; import dmd.declaration; import dmd.dclass; import dmd.dcast; @@ -606,6 +607,7 @@ bool hasRegularCtor(StructDeclaration sd, bool ignoreDisabled) { if (auto td = s.isTemplateDeclaration()) { + td.computeOneMember(); if (ignoreDisabled && td.onemember) { if (auto ctorDecl = td.onemember.isCtorDeclaration()) @@ -1909,6 +1911,7 @@ Expression resolvePropertiesOnly(Scope* sc, Expression e1) Expression handleTemplateDecl(TemplateDeclaration td) { assert(td); + td.computeOneMember(); if (!td.onemember) return e1; @@ -18234,14 +18237,15 @@ private bool needsTypeInference(TemplateInstance ti, Scope* sc, int flag = 0) auto td = s.isTemplateDeclaration(); if (!td) return 0; - /* If any of the overloaded template declarations need inference, * then return true */ + td.computeOneMember(); if (!td.onemember) return 0; if (auto td2 = td.onemember.isTemplateDeclaration()) { + td2.computeOneMember(); if (!td2.onemember || !td2.onemember.isFuncDeclaration()) return 0; if (ti.tiargs.length >= td.parameters.length - (td.isVariadic() ? 1 : 0)) diff --git a/dmd/frontend.h b/dmd/frontend.h index 35760fbeb7..75d207717c 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -1744,6 +1744,7 @@ class TemplateDeclaration final : public ScopeDsymbol bool isTrivialAlias; bool deprecated_; bool isCmacro; + bool haveComputedOneMember; Visibility visibility; TemplatePrevious* previous; Expression* lastConstraint; diff --git a/dmd/funcsem.d b/dmd/funcsem.d index 1967d911a9..e20a752728 100644 --- a/dmd/funcsem.d +++ b/dmd/funcsem.d @@ -1969,7 +1969,7 @@ private void checkNamedArgErrorAndReport(TemplateDeclaration td, ArgumentList ar { if (!argumentList.hasArgNames()) return; - + td.computeOneMember(); auto tf = td.onemember ? td.onemember.isFuncDeclaration() : null; if (tf && tf.type && tf.type.ty == Tfunction) { @@ -1999,8 +1999,11 @@ private void checkNamedArgErrorAndReportOverload(Dsymbol od, ArgumentList argume if (auto fd = s.isFuncDeclaration()) tf = fd; else if (auto td = s.isTemplateDeclaration()) + { + td.computeOneMember(); if (td.onemember) tf = td.onemember.isFuncDeclaration(); + } } return 0; }); @@ -2080,6 +2083,7 @@ private void printCandidates(Decl)(Loc loc, Decl declaration, bool showDeprecate // td.onemember may not have overloads set // (see fail_compilation/onemember_overloads.d) // assume if more than one member it is overloaded internally + td.computeOneMember(); bool recurse = td.onemember && (!td.onemember.isFuncDeclaration || td.members.length > 1); OutBuffer buf; diff --git a/dmd/json.d b/dmd/json.d index 080870aa47..839ac81bb5 100644 --- a/dmd/json.d +++ b/dmd/json.d @@ -25,6 +25,7 @@ import dmd.dimport; import dmd.dmodule; import dmd.dsymbol; import dmd.dsymbolsem : include; +import dmd.templatesem : computeOneMember; import dmd.dtemplate; import dmd.errors; import dmd.expression; @@ -474,6 +475,7 @@ public: void jsonProperties(TemplateDeclaration td) { jsonProperties(cast(Dsymbol)td); + td.computeOneMember(); if (td.onemember && td.onemember.isCtorDeclaration()) property("name", "this"); // __ctor -> this else diff --git a/dmd/mangle/cpp.d b/dmd/mangle/cpp.d index d9704718fb..29245e6674 100644 --- a/dmd/mangle/cpp.d +++ b/dmd/mangle/cpp.d @@ -27,6 +27,7 @@ import dmd.attrib; import dmd.declaration; import dmd.dsymbol; import dmd.dsymbolsem : isGNUABITag, toAlias, equals; +import dmd.templatesem : computeOneMember; import dmd.dtemplate; import dmd.errors; import dmd.expression; @@ -509,6 +510,10 @@ private final class CppMangleVisitor : Visitor // `&function` Dsymbol d = isDsymbol(o); Expression e = isExpression(o); + + if (auto _td = d.isTemplateDeclaration()) + _td.computeOneMember(); + if (d && d.isFuncDeclaration()) { // X .. E => template parameter is an expression diff --git a/dmd/mangle/cppwin.d b/dmd/mangle/cppwin.d index 4d12ffac83..a1f886b8f0 100644 --- a/dmd/mangle/cppwin.d +++ b/dmd/mangle/cppwin.d @@ -21,6 +21,7 @@ import dmd.denum : isSpecialEnumIdent; import dmd.dstruct; import dmd.dsymbol; import dmd.dsymbolsem : toAlias; +import dmd.templatesem : computeOneMember; import dmd.dtemplate; import dmd.errors; import dmd.errorsink; @@ -583,6 +584,9 @@ extern(D): Dsymbol d = isDsymbol(o); Expression e = isExpression(o); + if (auto _td = d.isTemplateDeclaration()) + _td.computeOneMember(); + if (d && d.isFuncDeclaration()) { buf.writeByte('$'); diff --git a/dmd/template.h b/dmd/template.h index b72de9f751..f0fba2b8d1 100644 --- a/dmd/template.h +++ b/dmd/template.h @@ -78,6 +78,7 @@ class TemplateDeclaration final : public ScopeDsymbol d_bool isTrivialAlias; // matches pattern `template Alias(T) { alias Alias = qualifiers(T); }` d_bool deprecated_; // this template declaration is deprecated d_bool isCmacro; // Whether this template is a translation of a C macro + d_bool haveComputedOneMember; // Whether computeOneMeber has been called Visibility visibility; TemplatePrevious *previous; // threaded list of previous instantiation attempts on stack diff --git a/dmd/templatesem.d b/dmd/templatesem.d index f1aca4bd1e..7d12609545 100644 --- a/dmd/templatesem.d +++ b/dmd/templatesem.d @@ -61,6 +61,24 @@ alias funcLeastAsSpecialized = dmd.funcsem.leastAsSpecialized; enum LOG = false; +void computeOneMember(TemplateDeclaration td) +{ + if (td is null || td.haveComputedOneMember) + return; + + if (td && td.members && td.ident) + { + Dsymbol s; + if (oneMembers(td.members, s, td.ident) && s) + { + td.onemember = s; + s.parent = td; + td.computeIsTrivialAlias(s); + } + td.haveComputedOneMember = true; + } +} + bool declareParameter(TemplateParameter _this, Scope* sc) { static bool typeDeclareParameter(TemplateTypeParameter _this, Scope* sc) @@ -366,7 +384,6 @@ void templateDeclarationSemantic(Scope* sc, TemplateDeclaration tempdecl) (*tempdecl.origParameters)[i] = tp.syntaxCopy(); } } - for (size_t i = 0; i < tempdecl.parameters.length; i++) { TemplateParameter tp = (*tempdecl.parameters)[i]; @@ -381,6 +398,7 @@ void templateDeclarationSemantic(Scope* sc, TemplateDeclaration tempdecl) } if (i + 1 != tempdecl.parameters.length && tp.isTemplateTupleParameter()) { + tempdecl.computeOneMember(); // for .kind .error(tempdecl.loc, "%s `%s` template sequence parameter must be the last one", tempdecl.kind, tempdecl.toPrettyChars); tempdecl.errors = true; } @@ -420,16 +438,7 @@ void templateDeclarationSemantic(Scope* sc, TemplateDeclaration tempdecl) // Compute again tempdecl.onemember = null; - if (tempdecl.members) - { - Dsymbol s; - if (oneMembers(tempdecl.members, s, tempdecl.ident) && s) - { - tempdecl.onemember = s; - s.parent = tempdecl; - } - } - + tempdecl.computeOneMember(); /* BUG: should check: * 1. template functions must not introduce virtual functions, as they * cannot be accomodated in the vtbl[] @@ -1468,6 +1477,7 @@ void aliasInstanceSemantic(TemplateInstance tempinst, Scope* sc, TemplateDeclara TemplateTypeParameter ttp = (*tempdecl.parameters)[0].isTemplateTypeParameter(); Type ta = tempinst.tdtypes[0].isType(); + tempdecl.computeOneMember(); auto ad = tempdecl.onemember.isAliasDeclaration(); // Note: qualifiers can be in both 'ad.type.mod' and 'ad.storage_class' @@ -2696,6 +2706,7 @@ MATCH matchWithInstance(Scope* sc, TemplateDeclaration td, TemplateInstance ti, ti.parent = td.parent; // Similar to doHeaderInstantiation + td.computeOneMember(); FuncDeclaration fd = td.onemember ? td.onemember.isFuncDeclaration() : null; if (fd) { @@ -3124,7 +3135,6 @@ private bool evaluateConstraint(TemplateDeclaration td, TemplateInstance ti, Sco const(char)* getConstraintEvalError(TemplateDeclaration td, ref const(char)* tip) { import dmd.staticcond; - // there will be a full tree view in verbose mode, and more compact list in the usual const full = global.params.v.verbose; uint count; @@ -3347,6 +3357,7 @@ bool findBestMatch(TemplateInstance ti, Scope* sc, ArgumentList argumentList) else { auto tdecl = ti.tempdecl.isTemplateDeclaration(); + tdecl.computeOneMember(); if (errs != global.errors) errorSupplemental(ti.loc, "while looking for match for `%s`", ti.toChars()); @@ -5412,7 +5423,7 @@ void functionResolve(ref MatchAccumulator m, Dsymbol dstart, Loc loc, Scope* sc, return 1; } //printf("td = %s\n", td.toChars()); - + td.computeOneMember(); auto f = td.onemember ? td.onemember.isFuncDeclaration() : null; if (!f) { @@ -5659,6 +5670,7 @@ void functionResolve(ref MatchAccumulator m, Dsymbol dstart, Loc loc, Scope* sc, if (td_best && ti_best && m.count == 1) { // Matches to template function + td_best.computeOneMember(); assert(td_best.onemember && td_best.onemember.isFuncDeclaration()); /* The best match is td_best with arguments tdargs. * Now instantiate the template. diff --git a/dmd/typesem.d b/dmd/typesem.d index 553f244c99..7d0f44c432 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -33,6 +33,7 @@ import dmd.dscope; import dmd.dstruct; import dmd.dsymbol; import dmd.dsymbolsem; +import dmd.templatesem : computeOneMember; import dmd.dtemplate; import dmd.enumsem; import dmd.errors; @@ -3006,6 +3007,7 @@ Type typeSemantic(Type type, Loc loc, Scope* sc) if (s) { auto td = s.isTemplateDeclaration; + td.computeOneMember(); if (td && td.onemember && td.onemember.isAggregateDeclaration) .error(loc, "template %s `%s` is used as a type without instantiation" ~ "; to instantiate it use `%s!(arguments)`", diff --git a/tests/dmd/fail_compilation/fail222.d b/tests/dmd/fail_compilation/fail222.d index e196b25306..e1df9d846d 100644 --- a/tests/dmd/fail_compilation/fail222.d +++ b/tests/dmd/fail_compilation/fail222.d @@ -2,7 +2,7 @@ TEST_OUTPUT: --- fail_compilation/fail222.d(11): Error: template `fail222.getMixin(TArg..., int i = 0)()` template sequence parameter must be the last one -fail_compilation/fail222.d(18): Error: template instance `getMixin!()` does not match template declaration `getMixin(TArg..., int i = 0)()` +fail_compilation/fail222.d(18): Error: template instance `getMixin!()` does not match template declaration `getMixin(TArg..., int i = 0)` fail_compilation/fail222.d(21): Error: template instance `fail222.Thing!()` error instantiating fail_compilation/fail222.d(23): Error: template `fail222.fooBar(A..., B...)()` template sequence parameter must be the last one --- From 0223a3edde48c750e65c2ec48e50423d6d16b36c Mon Sep 17 00:00:00 2001 From: Jonathan M Davis Date: Fri, 17 Oct 2025 02:13:40 -0600 Subject: [PATCH 027/440] Fixes dlang/dmd!20825: dmd tests do not work with FreeBSD 14 (dlang/dmd!21989) This also fixes https://github.com/dlang/dmd/issues/20607, which is for the druntime tests. The core issue is that importC can't handle stdlib.h on FreeBSD 14, because it uses a macro which uses asm, which breaks our importC tests which use stdlib.h. This fixes it so that importC doesn't use the actual macro. --- runtime/druntime/src/importc.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runtime/druntime/src/importc.h b/runtime/druntime/src/importc.h index b97d33807b..4b4195f737 100644 --- a/runtime/druntime/src/importc.h +++ b/runtime/druntime/src/importc.h @@ -138,6 +138,13 @@ typedef unsigned long long __uint64_t; #define __volatile volatile #define __sync_synchronize() #define __sync_swap(A, B) 1 + +// For whatever reason, sys/cdefs.h has to be included first even though +// it doesn't undef __sym_compat. But without #including sys/cdefs.h first and +// then undefing __sym_compat, the normal __sym_compat gets used. +#include "sys/cdefs.h" +#undef __sym_compat +#define __sym_compat(sym, impl, verid) #endif #if _MSC_VER From 26b907ad7e73726564dddcf656c923d3393a63f9 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Fri, 17 Oct 2025 21:49:09 +0800 Subject: [PATCH 028/440] [dcast.d] reduce some indentation (dlang/dmd!21982) --- dmd/dcast.d | 585 ++++++++++++++++++++++++++-------------------------- 1 file changed, 291 insertions(+), 294 deletions(-) diff --git a/dmd/dcast.d b/dmd/dcast.d index a4980a6c6b..ed83026fd0 100644 --- a/dmd/dcast.d +++ b/dmd/dcast.d @@ -90,44 +90,42 @@ Expression implicitCastTo(Expression e, Scope* sc, Type t) } auto ad = isAggregate(e.type); - if (ad && ad.aliasthis) + if (!ad || !ad.aliasthis) + return e.castTo(sc, t); + + if (!ad.type || ad.type.isTypeError()) + return e; + auto ts = ad.type.isTypeStruct(); + const adMatch = ts + ? ts.implicitConvToWithoutAliasThis(t) + : ad.type.isTypeClass().implicitConvToWithoutAliasThis(t); + + if (adMatch) + return e.castTo(sc, t); + + Type tob = t.toBasetype(); + Type t1b = e.type.toBasetype(); + if (ad == isAggregate(tob)) + return e.castTo(sc, t); + + if (t1b.ty == Tclass && tob.ty == Tclass) { - if (!ad.type || ad.type.isTypeError()) - return e; - auto ts = ad.type.isTypeStruct(); - const adMatch = ts - ? ts.implicitConvToWithoutAliasThis(t) - : ad.type.isTypeClass().implicitConvToWithoutAliasThis(t); - - if (!adMatch) + ClassDeclaration t1cd = t1b.isClassHandle(); + ClassDeclaration tocd = tob.isClassHandle(); + int offset; + if (tocd.isBaseOf(t1cd, &offset)) { - Type tob = t.toBasetype(); - Type t1b = e.type.toBasetype(); - if (ad != isAggregate(tob)) - { - if (t1b.ty == Tclass && tob.ty == Tclass) - { - ClassDeclaration t1cd = t1b.isClassHandle(); - ClassDeclaration tocd = tob.isClassHandle(); - int offset; - if (tocd.isBaseOf(t1cd, &offset)) - { - auto result = new CastExp(e.loc, e, t); - result.type = t; - return result; - } - } - - /* Forward the cast to our alias this member, rewrite to: - * cast(to)e1.aliasthis - */ - auto result = resolveAliasThis(sc, e); - return result.castTo(sc, t); - } + auto result = new CastExp(e.loc, e, t); + result.type = t; + return result; } } - return e.castTo(sc, t); + /* Forward the cast to our alias this member, rewrite to: + * cast(to)e1.aliasthis + */ + auto result = resolveAliasThis(sc, e); + return result.castTo(sc, t); } auto result = e.optimize(WANTvalue); @@ -136,54 +134,54 @@ Expression implicitCastTo(Expression e, Scope* sc, Type t) return implicitCastTo(result, sc, t); } - if (t.ty != Terror && e.type.ty != Terror) + if (t.ty == Terror || e.type.ty == Terror) + return ErrorExp.get(); + + if (!t.deco) { - if (!t.deco) + error(e.loc, "forward reference to type `%s`", t.toChars()); + return ErrorExp.get(); + } + + //printf("type %p ty %d deco %p\n", type, type.ty, type.deco); + //type = type.typeSemantic(loc, sc); + //printf("type %s t %s\n", type.deco, t.deco); + auto ts = toAutoQualChars(e.type, t); + + // Special case for improved diagnostic when const to mutable conversion + // fails due to struct/union having pointers + if (e.type.ty == Tstruct && t.ty == Tstruct && + e.type.isTypeStruct().sym == t.isTypeStruct().sym && + e.type.mod == MODFlags.const_ && t.mod == 0 && e.type.hasPointers) + { + auto sym = e.type.isTypeStruct().sym; + error(e.loc, "cannot implicitly convert expression `%s` of type `%s` to `%s` because %s `%s` contains pointers or references", + e.toErrMsg(), ts[0], ts[1], sym.kind(), sym.toErrMsg()); + return ErrorExp.get(); + } + + // Special case for pointer conversions + if (e.type.toBasetype().ty == Tpointer && t.toBasetype().ty == Tpointer) + { + Type fromPointee = e.type.nextOf(); + Type toPointee = t.nextOf(); + // Const -> mutable conversion (disallowed) + if (fromPointee.isConst() && !toPointee.isConst()) { - error(e.loc, "forward reference to type `%s`", t.toChars()); + error(e.loc, "cannot implicitly convert `%s` to `%s`", e.type.toChars(), t.toChars()); + errorSupplemental(e.loc, "Note: Converting const to mutable requires an explicit cast (`cast(int*)`)."); + return ErrorExp.get(); } - else + // Incompatible pointee types (e.g., int* -> float* ) + else if (fromPointee.toBasetype().ty != toPointee.toBasetype().ty) { - //printf("type %p ty %d deco %p\n", type, type.ty, type.deco); - //type = type.typeSemantic(loc, sc); - //printf("type %s t %s\n", type.deco, t.deco); - auto ts = toAutoQualChars(e.type, t); - - // Special case for improved diagnostic when const to mutable conversion - // fails due to struct/union having pointers - if (e.type.ty == Tstruct && t.ty == Tstruct && - e.type.isTypeStruct().sym == t.isTypeStruct().sym && - e.type.mod == MODFlags.const_ && t.mod == 0 && e.type.hasPointers) - { - auto sym = e.type.isTypeStruct().sym; - error(e.loc, "cannot implicitly convert expression `%s` of type `%s` to `%s` because %s `%s` contains pointers or references", - e.toErrMsg(), ts[0], ts[1], sym.kind(), sym.toErrMsg()); - return ErrorExp.get(); - } - - // Special case for pointer conversions - if (e.type.toBasetype().ty == Tpointer && t.toBasetype().ty == Tpointer) - { - Type fromPointee = e.type.nextOf(); - Type toPointee = t.nextOf(); - // Const -> mutable conversion (disallowed) - if (fromPointee.isConst() && !toPointee.isConst()) - { - error(e.loc, "cannot implicitly convert `%s` to `%s`", e.type.toChars(), t.toChars()); - errorSupplemental(e.loc, "Note: Converting const to mutable requires an explicit cast (`cast(int*)`)."); - return ErrorExp.get(); - } - // Incompatible pointee types (e.g., int* -> float* ) - else if (fromPointee.toBasetype().ty != toPointee.toBasetype().ty) - { - error(e.loc, "cannot implicitly convert `%s` to `%s`", e.type.toChars(), t.toChars()); - errorSupplemental(e.loc, "Note: Pointer types point to different base types (`%s` vs `%s`)", fromPointee.toChars(), toPointee.toChars()); - return ErrorExp.get(); - } - } - error(e.loc, "cannot implicitly convert expression `%s` of type `%s` to `%s`", e.toErrMsg(), ts[0], ts[1]); + error(e.loc, "cannot implicitly convert `%s` to `%s`", e.type.toChars(), t.toChars()); + errorSupplemental(e.loc, "Note: Pointer types point to different base types (`%s` vs `%s`)", fromPointee.toChars(), toPointee.toChars()); + return ErrorExp.get(); } } + error(e.loc, "cannot implicitly convert expression `%s` of type `%s` to `%s`", e.toErrMsg(), ts[0], ts[1]); + return ErrorExp.get(); } @@ -1316,73 +1314,69 @@ MATCH implicitConvTo(Expression e, Type t) if (sd.isNested()) return MATCH.nomatch; } - if (ntb.isZeroInit(e.loc)) + if (!ntb.isZeroInit(e.loc)) { - /* Zeros are implicitly convertible, except for special cases. - */ - if (auto tc = ntb.isTypeClass()) - { - /* With new() must look at the class instance initializer. - */ - ClassDeclaration cd = tc.sym; + Expression earg = e.newtype.defaultInitLiteral(e.loc); + Type targ = e.newtype.toBasetype(); - cd.size(e.loc); // resolve any forward references + if (implicitMod(earg, targ, mod) == MATCH.nomatch) + return MATCH.nomatch; + return MATCH.constant; + } + /* Zeros are implicitly convertible, except for special cases. + */ + auto tc = ntb.isTypeClass(); + if (!tc) + return MATCH.constant; + + /* With new() must look at the class instance initializer. + */ + ClassDeclaration cd = tc.sym; + + cd.size(e.loc); // resolve any forward references - if (cd.isNested()) - return MATCH.nomatch; // uplevel reference may not be convertible + if (cd.isNested()) + return MATCH.nomatch; // uplevel reference may not be convertible - assert(!cd.isInterfaceDeclaration()); + assert(!cd.isInterfaceDeclaration()); - struct ClassCheck + static bool convertible(Expression e, ClassDeclaration cd, MOD mod) + { + for (size_t i = 0; i < cd.fields.length; i++) + { + VarDeclaration v = cd.fields[i]; + Initializer _init = v._init; + if (_init) { - extern (C++) static bool convertible(Expression e, ClassDeclaration cd, MOD mod) + if (_init.isVoidInitializer()) { - for (size_t i = 0; i < cd.fields.length; i++) - { - VarDeclaration v = cd.fields[i]; - Initializer _init = v._init; - if (_init) - { - if (_init.isVoidInitializer()) - { - } - else if (ExpInitializer ei = _init.isExpInitializer()) - { - // https://issues.dlang.org/show_bug.cgi?id=21319 - // This is to prevent re-analyzing the same expression - // over and over again. - if (ei.exp == e) - return false; - Type tb = v.type.toBasetype(); - if (implicitMod(ei.exp, tb, mod) == MATCH.nomatch) - return false; - } - else - { - /* Enhancement: handle StructInitializer and ArrayInitializer - */ - return false; - } - } - else if (!v.type.isZeroInit(e.loc)) - return false; - } - return cd.baseClass ? convertible(e, cd.baseClass, mod) : true; + } + else if (ExpInitializer ei = _init.isExpInitializer()) + { + // https://issues.dlang.org/show_bug.cgi?id=21319 + // This is to prevent re-analyzing the same expression + // over and over again. + if (ei.exp == e) + return false; + Type tb = v.type.toBasetype(); + if (implicitMod(ei.exp, tb, mod) == MATCH.nomatch) + return false; + } + else + { + /* Enhancement: handle StructInitializer and ArrayInitializer + */ + return false; } } - - if (!ClassCheck.convertible(e, cd, mod)) - return MATCH.nomatch; + else if (!v.type.isZeroInit(e.loc)) + return false; } + return cd.baseClass ? convertible(e, cd.baseClass, mod) : true; } - else - { - Expression earg = e.newtype.defaultInitLiteral(e.loc); - Type targ = e.newtype.toBasetype(); - if (implicitMod(earg, targ, mod) == MATCH.nomatch) - return MATCH.nomatch; - } + if (!convertible(e, cd, mod)) + return MATCH.nomatch; /* Success */ @@ -1662,40 +1656,42 @@ MATCH implicitConvTo(Type from, Type to) } return MATCH.nomatch; } - if (auto tsa = to.isTypeSArray()) - { - if (from == to) - return MATCH.exact; + auto tsa = to.isTypeSArray(); + if (!tsa) + return MATCH.nomatch; - if (from.dim.equals(tsa.dim)) - { - MATCH m = from.next.implicitConvTo(tsa.next); + if (from == to) + return MATCH.exact; - /* Allow conversion to non-interface base class. - */ - if (m == MATCH.convert && - from.next.ty == Tclass) - { - if (auto toc = tsa.next.isTypeClass) - { - if (!toc.sym.isInterfaceDeclaration) - return MATCH.convert; - } - } + if (!from.dim.equals(tsa.dim)) + return MATCH.nomatch; - /* Since static arrays are value types, allow - * conversions from const elements to non-const - * ones, just like we allow conversion from const int - * to int. - */ - if (m >= MATCH.constant) - { - if (from.mod != to.mod) - m = MATCH.constant; - return m; - } + MATCH m = from.next.implicitConvTo(tsa.next); + + /* Allow conversion to non-interface base class. + */ + if (m == MATCH.convert && + from.next.ty == Tclass) + { + if (auto toc = tsa.next.isTypeClass) + { + if (!toc.sym.isInterfaceDeclaration) + return MATCH.convert; } } + + /* Since static arrays are value types, allow + * conversions from const elements to non-const + * ones, just like we allow conversion from const int + * to int. + */ + if (m >= MATCH.constant) + { + if (from.mod != to.mod) + m = MATCH.constant; + return m; + } + return MATCH.nomatch; } @@ -1705,25 +1701,26 @@ MATCH implicitConvTo(Type from, Type to) if (from.equals(to)) return MATCH.exact; - if (auto ta = to.isTypeDArray()) - { - if (!MODimplicitConv(from.next.mod, ta.next.mod)) - return MATCH.nomatch; // not const-compatible + auto ta = to.isTypeDArray(); + if (!ta) + return visitType(from); - /* Allow conversion to void[] - */ - if (from.next.ty != Tvoid && ta.next.ty == Tvoid) - { - return MATCH.convert; - } + if (!MODimplicitConv(from.next.mod, ta.next.mod)) + return MATCH.nomatch; // not const-compatible - MATCH m = from.next.constConv(ta.next); - if (m > MATCH.nomatch) - { - if (m == MATCH.exact && from.mod != to.mod) - m = MATCH.constant; - return m; - } + /* Allow conversion to void[] + */ + if (from.next.ty != Tvoid && ta.next.ty == Tvoid) + { + return MATCH.convert; + } + + MATCH m = from.next.constConv(ta.next); + if (m > MATCH.nomatch) + { + if (m == MATCH.exact && from.mod != to.mod) + m = MATCH.constant; + return m; } return visitType(from); @@ -1735,21 +1732,23 @@ MATCH implicitConvTo(Type from, Type to) if (from.equals(to)) return MATCH.exact; - if (auto ta = to.isTypeAArray()) - { - if (!MODimplicitConv(from.next.mod, ta.next.mod)) - return MATCH.nomatch; // not const-compatible + auto ta = to.isTypeAArray(); + if (!ta) + return visitType(from); - if (!MODimplicitConv(from.index.mod, ta.index.mod)) - return MATCH.nomatch; // not const-compatible + if (!MODimplicitConv(from.next.mod, ta.next.mod)) + return MATCH.nomatch; // not const-compatible - MATCH m = from.next.constConv(ta.next); - MATCH mi = from.index.constConv(ta.index); - if (m > MATCH.nomatch && mi > MATCH.nomatch) - { - return MODimplicitConv(from.mod, to.mod) ? MATCH.constant : MATCH.nomatch; - } + if (!MODimplicitConv(from.index.mod, ta.index.mod)) + return MATCH.nomatch; // not const-compatible + + MATCH m = from.next.constConv(ta.next); + MATCH mi = from.index.constConv(ta.index); + if (m > MATCH.nomatch && mi > MATCH.nomatch) + { + return MODimplicitConv(from.mod, to.mod) ? MATCH.constant : MATCH.nomatch; } + return visitType(from); } @@ -1772,26 +1771,24 @@ MATCH implicitConvTo(Type from, Type to) if (tf.equals(to)) return MATCH.constant; - if (tf.covariant(to) == Covariant.yes) + if (tf.covariant(to) != Covariant.yes) + return MATCH.nomatch; + + Type tret = tf.nextOf(); + Type toret = to.nextOf(); + if (tret.ty == Tclass && toret.ty == Tclass) { - Type tret = tf.nextOf(); - Type toret = to.nextOf(); - if (tret.ty == Tclass && toret.ty == Tclass) - { - /* https://issues.dlang.org/show_bug.cgi?id=10219 - * Check covariant interface return with offset tweaking. - * interface I {} - * class C : Object, I {} - * I function() dg = function C() {} // should be error - */ - int offset = 0; - if (toret.isBaseOf(tret, &offset) && offset != 0) - return MATCH.nomatch; - } - return MATCH.convert; + /* https://issues.dlang.org/show_bug.cgi?id=10219 + * Check covariant interface return with offset tweaking. + * interface I {} + * class C : Object, I {} + * I function() dg = function C() {} // should be error + */ + int offset = 0; + if (toret.isBaseOf(tret, &offset) && offset != 0) + return MATCH.nomatch; } - - return MATCH.nomatch; + return MATCH.convert; } MATCH visitPointer(TypePointer from) @@ -1841,19 +1838,17 @@ MATCH implicitConvTo(Type from, Type to) if (from.equals(to)) return MATCH.exact; - if (auto toDg = to.isTypeDelegate()) - { - MATCH m = implicitPointerConv(from.next.isTypeFunction(), toDg.next); - - // Retain the old behaviour for this refactoring - // Should probably be changed to constant to match function pointers - if (m > MATCH.convert) - m = MATCH.convert; + auto toDg = to.isTypeDelegate(); + if (!toDg) + return MATCH.nomatch; - return m; - } + MATCH m = implicitPointerConv(from.next.isTypeFunction(), toDg.next); - return MATCH.nomatch; + // Retain the old behaviour for this refactoring + // Should probably be changed to constant to match function pointers + if (m > MATCH.convert) + return MATCH.convert; + return m; } MATCH visitStruct(TypeStruct from) @@ -1889,23 +1884,23 @@ MATCH implicitConvTo(Type from, Type to) { if (from == to) return MATCH.exact; - if (auto tt = to.isTypeTuple()) + auto tt = to.isTypeTuple(); + if (!tt) + return MATCH.nomatch; + + if (from.arguments.length != tt.arguments.length) + return MATCH.nomatch; + + MATCH m = MATCH.exact; + for (size_t i = 0; i < tt.arguments.length; i++) { - if (from.arguments.length == tt.arguments.length) - { - MATCH m = MATCH.exact; - for (size_t i = 0; i < tt.arguments.length; i++) - { - Parameter arg1 = (*from.arguments)[i]; - Parameter arg2 = (*tt.arguments)[i]; - MATCH mi = arg1.type.implicitConvTo(arg2.type); - if (mi < m) - m = mi; - } - return m; - } + Parameter arg1 = (*from.arguments)[i]; + Parameter arg2 = (*tt.arguments)[i]; + MATCH mi = arg1.type.implicitConvTo(arg2.type); + if (mi < m) + m = mi; } - return MATCH.nomatch; + return m; } MATCH visitNull(TypeNull from) @@ -2299,34 +2294,32 @@ Expression castTo(Expression e, Scope* sc, Type t, Type att = null) Expression visitReal(RealExp e) { - if (!e.type.equals(t)) + if (e.type.equals(t)) + return e; + + if ((e.type.isReal() && t.isReal()) || (e.type.isImaginary() && t.isImaginary())) { - if ((e.type.isReal() && t.isReal()) || (e.type.isImaginary() && t.isImaginary())) - { - auto result = e.copy(); - result.type = t; - return result; - } - else - return visit(e); + auto result = e.copy(); + result.type = t; + return result; } - return e; + else + return visit(e); } Expression visitComplex(ComplexExp e) { - if (!e.type.equals(t)) + if (e.type.equals(t)) + return e; + + if (e.type.isComplex() && t.isComplex()) { - if (e.type.isComplex() && t.isComplex()) - { - auto result = e.copy(); - result.type = t; - return result; - } - else - return visit(e); + auto result = e.copy(); + result.type = t; + return result; } - return e; + else + return visit(e); } Expression visitStructLiteral(StructLiteralExp e) @@ -3173,47 +3166,50 @@ Expression inferType(Expression e, Type t, int flag = 0) Expression visitAle(ArrayLiteralExp ale) { Type tb = t.toBasetype(); - if (tb.isStaticOrDynamicArray()) + if (!tb.isStaticOrDynamicArray()) + return ale; + + Type tn = tb.nextOf(); + if (ale.basis) + ale.basis = inferType(ale.basis, tn, flag); + for (size_t i = 0; i < ale.elements.length; i++) { - Type tn = tb.nextOf(); - if (ale.basis) - ale.basis = inferType(ale.basis, tn, flag); - for (size_t i = 0; i < ale.elements.length; i++) + if (Expression e = (*ale.elements)[i]) { - if (Expression e = (*ale.elements)[i]) - { - e = inferType(e, tn, flag); - (*ale.elements)[i] = e; - } + e = inferType(e, tn, flag); + (*ale.elements)[i] = e; } } + return ale; } Expression visitAar(AssocArrayLiteralExp aale) { Type tb = t.toBasetype(); - if (auto taa = tb.isTypeAArray()) + auto taa = tb.isTypeAArray(); + if (!taa) + return aale; + + Type ti = taa.index; + Type tv = taa.nextOf(); + for (size_t i = 0; i < aale.keys.length; i++) { - Type ti = taa.index; - Type tv = taa.nextOf(); - for (size_t i = 0; i < aale.keys.length; i++) + if (Expression e = (*aale.keys)[i]) { - if (Expression e = (*aale.keys)[i]) - { - e = inferType(e, ti, flag); - (*aale.keys)[i] = e; - } + e = inferType(e, ti, flag); + (*aale.keys)[i] = e; } - for (size_t i = 0; i < aale.values.length; i++) + } + for (size_t i = 0; i < aale.values.length; i++) + { + if (Expression e = (*aale.values)[i]) { - if (Expression e = (*aale.values)[i]) - { - e = inferType(e, tv, flag); - (*aale.values)[i] = e; - } + e = inferType(e, tv, flag); + (*aale.values)[i] = e; } } + return aale; } @@ -4242,26 +4238,27 @@ Expression integralPromotions(Expression e, Scope* sc) void fix16997(Scope* sc, UnaExp ue) { if (global.params.fix16997 || sc.inCfile) + { ue.e1 = integralPromotions(ue.e1, sc); // desired C-like behavor - else + return; + } + + switch (ue.e1.type.toBasetype.ty) { - switch (ue.e1.type.toBasetype.ty) - { - case Tint8: - case Tuns8: - case Tint16: - case Tuns16: - //case Tbool: // these operations aren't allowed on bool anyway - case Tchar: - case Twchar: - case Tdchar: - deprecation(ue.loc, "integral promotion not done for `%s`, remove '-revert=intpromote' switch or `%scast(int)(%s)`", - ue.toChars(), EXPtoString(ue.op).ptr, ue.e1.toChars()); - break; + case Tint8: + case Tuns8: + case Tint16: + case Tuns16: + //case Tbool: // these operations aren't allowed on bool anyway + case Tchar: + case Twchar: + case Tdchar: + deprecation(ue.loc, "integral promotion not done for `%s`, remove '-revert=intpromote' switch or `%scast(int)(%s)`", + ue.toChars(), EXPtoString(ue.op).ptr, ue.e1.toChars()); + return; - default: - break; - } + default: + return; } } From 0b49bcb40fc20fbdfc6953983782d9ec64cf3d40 Mon Sep 17 00:00:00 2001 From: Dennis Date: Fri, 17 Oct 2025 15:49:50 +0200 Subject: [PATCH 029/440] Fix dlang/dmd!20927 - Non-static opCall hides struct and union default constructors (dlang/dmd!21973) Co-authored-by: Dennis Korpel --- dmd/expressionsem.d | 45 ++++++++++++++++++++++++++++++++++-- tests/dmd/runnable/opover3.d | 26 +++++++++++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 9726d88be9..e3cb2b9499 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -632,6 +632,42 @@ bool hasRegularCtor(StructDeclaration sd, bool ignoreDisabled) return result; } +/// Returns: whether `s` is a method which can possibly be called without a struct instance. +/// Used to check whether S() should try to call `S.opCall()` rather than construct a struct literal +bool hasStaticOverload(Dsymbol s) +{ + bool result = false; + overloadApply(s, (Dsymbol sym) { + if (auto fd = sym.isFuncDeclaration()) + { + if (fd.isStatic) + { + result = true; + return 1; + } + } + else if (auto td = sym.isTemplateDeclaration()) + { + // Consider both `template opCall { static opCall() {} }` and `static opCall()() {}` + if (td._scope.stc & STC.static_) + { + result = true; + return 1; + } + if (auto fd = td.onemember.isFuncDeclaration()) + { + if (fd.isStatic) + { + result = true; + return 1; + } + } + } + return 0; + }); + return result; +} + /***************************************** * Determine if `this` is available by walking up the enclosing * scopes until a function is found. @@ -7152,8 +7188,13 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor return; } // No constructor, look for overload of opCall - if (search_function(sd, Id.opCall)) - goto L1; + if (auto sym = search_function(sd, Id.opCall)) + { + // Don't consider opCall on a type with no instance + // if there's no static overload for it + if (!exp.e1.isTypeExp() || hasStaticOverload(sym)) + goto L1; + } // overload of opCall, therefore it's a call if (exp.e1.op != EXP.type) { diff --git a/tests/dmd/runnable/opover3.d b/tests/dmd/runnable/opover3.d index 7146826255..9800140169 100644 --- a/tests/dmd/runnable/opover3.d +++ b/tests/dmd/runnable/opover3.d @@ -169,6 +169,31 @@ struct S12124 // speculative opCall instantiation for diagnostic message should not cause false errors } +/**************************************/ +// https://github.com/dlang/dmd/issues/20927 + +struct NoStatic0 { auto opCall() => 2; } +struct NoStatic1 { int x; NoStatic1 opCall() => NoStatic1(3); } + +struct Yes0 { static opCall() => 2; } +struct Yes1 { static opCall()() => 2; } +struct Yes2 +{ + auto call()(int x) => this.init; + template call() { static call() => 2; } + alias opCall = call; +} + +void test20927() +{ + assert(NoStatic0() == NoStatic0.init); + assert(NoStatic1()() == NoStatic1(3)); + + assert(Yes0() == 2); + assert(Yes1() == 2); + assert(Yes2() == 2); +} + /**************************************/ void main() @@ -181,4 +206,5 @@ void main() test3c(); test4(); test12070(); + test20927(); } From 4b39bb44e21fcc06817128bdd71388dddca7a9b0 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:14:27 +0300 Subject: [PATCH 030/440] Move `Expression.toBool` to `dmd/expressionsem.d` (dlang/dmd!21991) --- dmd/blockexit.d | 1 + dmd/constfold.d | 2 +- dmd/ctfeexpr.d | 2 +- dmd/cxxfrontend.d | 7 ++++ dmd/expression.d | 78 --------------------------------------------- dmd/expression.h | 15 +-------- dmd/expressionsem.d | 53 ++++++++++++++++++++++++++++++ dmd/frontend.h | 45 ++++++++++---------------- 8 files changed, 80 insertions(+), 123 deletions(-) diff --git a/dmd/blockexit.d b/dmd/blockexit.d index ae2f12f323..aaf2517c93 100644 --- a/dmd/blockexit.d +++ b/dmd/blockexit.d @@ -20,6 +20,7 @@ import dmd.dclass; import dmd.declaration; import dmd.errorsink; import dmd.expression; +import dmd.expressionsem : toBool; import dmd.func; import dmd.globals; import dmd.id; diff --git a/dmd/constfold.d b/dmd/constfold.d index 7916f0e013..fa25099ebb 100644 --- a/dmd/constfold.d +++ b/dmd/constfold.d @@ -25,7 +25,7 @@ import dmd.declaration; import dmd.dstruct; import dmd.errors; import dmd.expression; -import dmd.expressionsem : getField, isIdentical; +import dmd.expressionsem : getField, isIdentical, toBool; import dmd.globals; import dmd.location; import dmd.mtype; diff --git a/dmd/ctfeexpr.d b/dmd/ctfeexpr.d index 1e7d0a4c71..19194eeff3 100644 --- a/dmd/ctfeexpr.d +++ b/dmd/ctfeexpr.d @@ -25,7 +25,7 @@ import dmd.dstruct; import dmd.dtemplate; import dmd.errors; import dmd.expression; -import dmd.expressionsem : isIdentical, getFieldIndex; +import dmd.expressionsem : isIdentical, getFieldIndex, toBool; import dmd.func; import dmd.globals : dinteger_t, sinteger_t, uinteger_t; import dmd.location; diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 045e4458bf..6a576a01b5 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -32,6 +32,7 @@ import dmd.init : Initializer, NeedInterpret; import dmd.location : Loc; import dmd.mtype /*: Covariant, Type, Parameter, ParameterList*/; import dmd.rootobject : RootObject; +import dmd.root.optional; import dmd.semantic3; import dmd.statement : Statement, AsmStatement, GccAsmStatement; @@ -423,6 +424,12 @@ void fillTupleExpExps(TupleExp te, TupleDeclaration tup) return dmd.expressionsem.fillTupleExpExps(te, tup); } +Optional!bool toBool(Expression exp) +{ + import dmd.expressionsem; + return dmd.expressionsem.toBool(exp); +} + /*********************************************************** * func.d */ diff --git a/dmd/expression.d b/dmd/expression.d index 6702ae94c8..d99e5c9d29 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -21,7 +21,6 @@ import dmd.aggregate; import dmd.arraytypes; import dmd.astenums; import dmd.ast_node; -import dmd.ctfeexpr : isCtfeReferenceValid; import dmd.dcast : implicitConvTo; import dmd.dclass; import dmd.declaration; @@ -43,7 +42,6 @@ import dmd.mtype; import dmd.root.complex; import dmd.root.ctfloat; import dmd.common.outbuffer; -import dmd.root.optional; import dmd.root.rmem; import dmd.rootobject; import dmd.root.string; @@ -554,13 +552,6 @@ extern (C++) abstract class Expression : ASTNode assert(0); } - /// Statically evaluate this expression to a `bool` if possible - /// Returns: an optional thath either contains the value or is empty - Optional!bool toBool() - { - return typeof(return)(); - } - bool hasCode() { return true; @@ -781,12 +772,6 @@ extern (C++) final class IntegerExp : Expression return complex_t(toReal()); } - override Optional!bool toBool() - { - bool r = toInteger() != 0; - return typeof(return)(r); - } - override void accept(Visitor v) { v.visit(this); @@ -1014,11 +999,6 @@ extern (C++) final class RealExp : Expression return complex_t(toReal(), toImaginary()); } - override Optional!bool toBool() - { - return typeof(return)(!!value); - } - override void accept(Visitor v) { v.visit(this); @@ -1070,11 +1050,6 @@ extern (C++) final class ComplexExp : Expression return value; } - override Optional!bool toBool() - { - return typeof(return)(!!value); - } - override void accept(Visitor v) { v.visit(this); @@ -1177,12 +1152,6 @@ extern (C++) class ThisExp : Expression return r; } - override Optional!bool toBool() - { - // `this` is never null (what about structs?) - return typeof(return)(true); - } - override void accept(Visitor v) { v.visit(this); @@ -1218,12 +1187,6 @@ extern (C++) final class NullExp : Expression this.type = type; } - override Optional!bool toBool() - { - // null in any type is false - return typeof(return)(false); - } - override StringExp toStringExp() { if (this.type.implicitConvTo(Type.tstring)) @@ -1530,13 +1493,6 @@ extern (C++) final class StringExp : Expression return 0; } - override Optional!bool toBool() - { - // Keep the old behaviour for this refactoring - // Should probably match language spec instead and check for length - return typeof(return)(true); - } - /******************************** * Convert string contents to a 0 terminated string, * allocated by mem.xmalloc(). @@ -1752,12 +1708,6 @@ extern (C++) final class ArrayLiteralExp : Expression return el ? el : basis; } - override Optional!bool toBool() - { - size_t dim = elements ? elements.length : 0; - return typeof(return)(dim != 0); - } - override StringExp toStringExp() { TY telem = type.nextOf().toBasetype().ty; @@ -1844,12 +1794,6 @@ extern (C++) final class AssocArrayLiteralExp : Expression return new AssocArrayLiteralExp(loc, arraySyntaxCopy(keys), arraySyntaxCopy(values)); } - override Optional!bool toBool() - { - size_t dim = keys.length; - return typeof(return)(dim != 0); - } - override void accept(Visitor v) { v.visit(this); @@ -2204,11 +2148,6 @@ extern (C++) final class SymOffExp : SymbolExp this.offset = offset; } - override Optional!bool toBool() - { - return typeof(return)(true); - } - override void accept(Visitor v) { v.visit(this); @@ -3022,13 +2961,6 @@ extern (C++) final class AddrExp : UnaExp type = t; } - override Optional!bool toBool() - { - if (isCtfeReferenceValid(e1)) - return typeof(return)(true); - return UnaExp.toBool(); - } - override void accept(Visitor v) { v.visit(this); @@ -3277,11 +3209,6 @@ extern (C++) final class SliceExp : UnaExp return se; } - override Optional!bool toBool() - { - return e1.toBool(); - } - override void accept(Visitor v) { v.visit(this); @@ -3389,11 +3316,6 @@ extern (C++) final class CommaExp : BinExp originalExp = oe; } - override Optional!bool toBool() - { - return e2.toBool(); - } - override void accept(Visitor v) { v.visit(this); diff --git a/dmd/expression.h b/dmd/expression.h index e63a4a2d27..f988d0e6d8 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -64,6 +64,7 @@ namespace dmd bool isLvalue(const Expression *exp); int32_t getFieldIndex(ClassReferenceExp *cre, Type *fieldtype, uint32_t fieldoffset); void fillTupleExpExps(TupleExp *te, TupleDeclaration *tup); + Optional toBool(Expression *exp); } typedef unsigned char OwnedBy; @@ -110,7 +111,6 @@ class Expression : public ASTNode Expression *deref(); int isConst(); - virtual Optional toBool(); virtual bool hasCode() { return true; @@ -242,7 +242,6 @@ class IntegerExp final : public Expression real_t toReal() override; real_t toImaginary() override; complex_t toComplex() override; - Optional toBool() override; void accept(Visitor *v) override { v->visit(this); } dinteger_t getInteger() { return value; } template @@ -268,7 +267,6 @@ class RealExp final : public Expression real_t toReal() override; real_t toImaginary() override; complex_t toComplex() override; - Optional toBool() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -283,7 +281,6 @@ class ComplexExp final : public Expression real_t toReal() override; real_t toImaginary() override; complex_t toComplex() override; - Optional toBool() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -318,7 +315,6 @@ class ThisExp : public Expression VarDeclaration *var; ThisExp *syntaxCopy() override; - Optional toBool() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -332,7 +328,6 @@ class SuperExp final : public ThisExp class NullExp final : public Expression { public: - Optional toBool() override; StringExp *toStringExp() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -354,7 +349,6 @@ class StringExp final : public Expression char32_t getCodeUnit(d_size_t i) const; dinteger_t getIndex(d_size_t i) const; StringExp *toStringExp() override; - Optional toBool() override; void accept(Visitor *v) override { v->visit(this); } size_t numberOfCodeUnits(int tynto = 0) const; void writeTo(void* dest, bool zero, int tyto = 0) const; @@ -404,7 +398,6 @@ class ArrayLiteralExp final : public Expression static ArrayLiteralExp *create(Loc loc, Expressions *elements); ArrayLiteralExp *syntaxCopy() override; Expression *getElement(d_size_t i); - Optional toBool() override; StringExp *toStringExp() override; void accept(Visitor *v) override { v->visit(this); } @@ -420,7 +413,6 @@ class AssocArrayLiteralExp final : public Expression Expression* loweringCtfe; AssocArrayLiteralExp *syntaxCopy() override; - Optional toBool() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -556,8 +548,6 @@ class SymOffExp final : public SymbolExp public: dinteger_t offset; - Optional toBool() override; - void accept(Visitor *v) override { v->visit(this); } }; @@ -832,7 +822,6 @@ class CallExp final : public UnaExp class AddrExp final : public UnaExp { public: - Optional toBool() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -924,7 +913,6 @@ class SliceExp final : public UnaExp public: SliceExp *syntaxCopy() override; - Optional toBool() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -987,7 +975,6 @@ class CommaExp final : public BinExp d_bool isGenerated; d_bool allowCommaExp; Expression* originalExp; - Optional toBool() override; void accept(Visitor *v) override { v->visit(this); } }; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index e3cb2b9499..f943b71e83 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -27,6 +27,7 @@ import dmd.canthrow; import dmd.chkformat; import dmd.cond; import dmd.ctorflow; +import dmd.ctfeexpr : isCtfeReferenceValid; import dmd.dscope; import dmd.dsymbol; import dmd.dsymbolsem; @@ -75,6 +76,7 @@ import dmd.root.array; import dmd.root.complex; import dmd.root.ctfloat; import dmd.root.filename; +import dmd.root.optional; import dmd.common.outbuffer; import dmd.rootobject; import dmd.root.string; @@ -97,6 +99,57 @@ import dmd.visitor.postorder; enum LOGSEMANTIC = false; +Optional!bool toBool(Expression _this) +{ + static Optional!bool integerToBool(IntegerExp _this) + { + bool r = _this.toInteger() != 0; + return typeof(return)(r); + } + + static Optional!bool arrayLiteralToBool(ArrayLiteralExp _this) + { + size_t dim = _this.elements ? _this.elements.length : 0; + return typeof(return)(dim != 0); + } + + static Optional!bool assocArrayLiteralToBool(AssocArrayLiteralExp _this) + { + size_t dim = _this.keys.length; + return typeof(return)(dim != 0); + } + + static Optional!bool addrToBool(AddrExp _this) + { + if (isCtfeReferenceValid(_this.e1)) + return typeof(return)(true); + return typeof(return)(); + } + + switch(_this.op) + { + case EXP.int64: return integerToBool(_this.isIntegerExp()); + case EXP.float64: return typeof(return)(!!_this.isRealExp().value); + case EXP.complex80: return typeof(return)(!!_this.isComplexExp().value); + // `this` is never null (what about structs?) + case EXP.this_, EXP.super_: return typeof(return)(true); + // null in any type is false + case EXP.null_: return typeof(return)(false); + // Keep the old behaviour for this refactoring + // Should probably match language spec instead and check for length + case EXP.string_: return typeof(return)(true); + case EXP.arrayLiteral: return arrayLiteralToBool(_this.isArrayLiteralExp()); + case EXP.assocArrayLiteral: return assocArrayLiteralToBool(_this.isAssocArrayLiteralExp()); + case EXP.symbolOffset: return typeof(return)(true); + case EXP.address: return addrToBool(_this.isAddrExp()); + case EXP.slice: return _this.isSliceExp().e1.toBool(); + case EXP.comma: return _this.isCommaExp().e2.toBool(); + // Statically evaluate this expression to a `bool` if possible + // Returns: an optional thath either contains the value or is empty + default: return typeof(return)(); + } +} + void fillTupleExpExps(TupleExp _this, TupleDeclaration tup) { _this.exps.reserve(tup.objects.length); diff --git a/dmd/frontend.h b/dmd/frontend.h index 75d207717c..9590fe253e 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2317,22 +2317,6 @@ struct complex_t final int32_t opEquals(complex_t y) const; }; -template -struct Optional final -{ - T value; - bool present; - Optional(T value); - static Optional create(T val); - bool isPresent() const; - bool isEmpty() const; - T get(); - bool hasValue(T exp) const; - Optional() - { - } -}; - class Expression : public ASTNode { public: @@ -2381,7 +2365,6 @@ class Expression : public ASTNode virtual bool checkType(); Expression* deref(); int32_t isConst(); - virtual Optional toBool(); virtual bool hasCode(); IntegerExp* isIntegerExp(); ErrorExp* isErrorExp(); @@ -2541,7 +2524,6 @@ class UnaExp : public Expression class AddrExp final : public UnaExp { public: - Optional toBool() override; void accept(Visitor* v) override; }; @@ -2608,7 +2590,6 @@ class ArrayLiteralExp final : public Expression static ArrayLiteralExp* create(Loc loc, Array* elements); ArrayLiteralExp* syntaxCopy() override; Expression* getElement(size_t i); - Optional toBool() override; StringExp* toStringExp() override; void accept(Visitor* v) override; }; @@ -2645,7 +2626,6 @@ class AssocArrayLiteralExp final : public Expression Expression* lowering; Expression* loweringCtfe; AssocArrayLiteralExp* syntaxCopy() override; - Optional toBool() override; void accept(Visitor* v) override; }; @@ -2743,7 +2723,6 @@ class CommaExp final : public BinExp const bool isGenerated; bool allowCommaExp; Expression* originalExp; - Optional toBool() override; void accept(Visitor* v) override; static void allow(Expression* exp); }; @@ -2758,7 +2737,6 @@ class ComplexExp final : public Expression _d_real toReal() override; _d_real toImaginary() override; complex_t toComplex() override; - Optional toBool() override; void accept(Visitor* v) override; }; @@ -3232,7 +3210,6 @@ class IntegerExp final : public Expression _d_real toReal() override; _d_real toImaginary() override; complex_t toComplex() override; - Optional toBool() override; void accept(Visitor* v) override; dinteger_t getInteger(); IntegerExp* syntaxCopy() override; @@ -3388,7 +3365,6 @@ class NotExp final : public UnaExp class NullExp final : public Expression { public: - Optional toBool() override; StringExp* toStringExp() override; void accept(Visitor* v) override; }; @@ -3465,7 +3441,6 @@ class RealExp final : public Expression _d_real toReal() override; _d_real toImaginary() override; complex_t toComplex() override; - Optional toBool() override; void accept(Visitor* v) override; }; @@ -3544,7 +3519,6 @@ class SliceExp final : public UnaExp uint8_t bitFields; public: SliceExp* syntaxCopy() override; - Optional toBool() override; void accept(Visitor* v) override; }; @@ -3575,7 +3549,6 @@ class StringExp final : public Expression dinteger_t getIndex(size_t i) const; StringExp* toStringExp() override; int32_t compare(const StringExp* const se2) const; - Optional toBool() override; void accept(Visitor* v) override; }; @@ -3641,7 +3614,6 @@ class ThisExp : public Expression VarDeclaration* var; ThisExp(Loc loc, const EXP tok); ThisExp* syntaxCopy() override; - Optional toBool() override; void accept(Visitor* v) override; }; @@ -3664,7 +3636,6 @@ class SymOffExp final : public SymbolExp { public: dinteger_t offset; - Optional toBool() override; void accept(Visitor* v) override; }; @@ -8115,6 +8086,22 @@ extern _d_real cimagl(complex_t x); extern void browse(const char* url); +template +struct Optional final +{ + T value; + bool present; + Optional(T value); + static Optional create(T val); + bool isPresent() const; + bool isEmpty() const; + T get(); + bool hasValue(T exp) const; + Optional() + { + } +}; + enum class IdentifierTable { UAX31 = 0, From 8d425758ff558f3a9cd80ec64bb7b94f26970bb0 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sun, 19 Oct 2025 10:09:57 +0300 Subject: [PATCH 031/440] Fix dlang/dmd!21997 (dlang/dmd!21998) --- dmd/mangle/cpp.d | 4 ++-- dmd/mangle/cppwin.d | 4 ++-- tests/dmd/compilable/issue21997.d | 10 ++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 tests/dmd/compilable/issue21997.d diff --git a/dmd/mangle/cpp.d b/dmd/mangle/cpp.d index 29245e6674..6385404d8a 100644 --- a/dmd/mangle/cpp.d +++ b/dmd/mangle/cpp.d @@ -511,8 +511,8 @@ private final class CppMangleVisitor : Visitor Dsymbol d = isDsymbol(o); Expression e = isExpression(o); - if (auto _td = d.isTemplateDeclaration()) - _td.computeOneMember(); + if (d && d.isTemplateDeclaration()) + d.isTemplateDeclaration().computeOneMember(); if (d && d.isFuncDeclaration()) { diff --git a/dmd/mangle/cppwin.d b/dmd/mangle/cppwin.d index a1f886b8f0..c380d42809 100644 --- a/dmd/mangle/cppwin.d +++ b/dmd/mangle/cppwin.d @@ -584,8 +584,8 @@ extern(D): Dsymbol d = isDsymbol(o); Expression e = isExpression(o); - if (auto _td = d.isTemplateDeclaration()) - _td.computeOneMember(); + if (d && d.isTemplateDeclaration()) + d.isTemplateDeclaration().computeOneMember(); if (d && d.isFuncDeclaration()) { diff --git a/tests/dmd/compilable/issue21997.d b/tests/dmd/compilable/issue21997.d new file mode 100644 index 0000000000..238c9d7ac2 --- /dev/null +++ b/tests/dmd/compilable/issue21997.d @@ -0,0 +1,10 @@ +extern(C++) struct S +{ + static void link(alias MO)(){} + __gshared int i; +} + +void main() +{ + S.link!(S.i); +} From 82dfa317b91db57c9cfb26464b4de67f10024b27 Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Sun, 19 Oct 2025 23:22:56 +1300 Subject: [PATCH 032/440] PoC DFA engine for nullability and truthiness (dlang/dmd!21965) --- dmd/cli.d | 2 + dmd/declaration.h | 2 + dmd/dfa/entry.d | 139 ++ dmd/dfa/fast/analysis.d | 2036 +++++++++++++++++++ dmd/dfa/fast/expression.d | 1902 ++++++++++++++++++ dmd/dfa/fast/report.d | 219 ++ dmd/dfa/fast/statement.d | 1336 ++++++++++++ dmd/dfa/fast/structure.d | 2789 ++++++++++++++++++++++++++ dmd/dfa/utils.d | 118 ++ dmd/dscope.d | 15 + dmd/frontend.h | 55 +- dmd/func.d | 36 + dmd/globals.d | 1 + dmd/scope.h | 2 + dmd/semantic3.d | 8 + dmd/templatesem.d | 3 + dmd/timetrace.d | 2 + tests/dmd/compilable/fastdfa.d | 711 +++++++ tests/dmd/compilable/ftimetrace.d | 6 +- tests/dmd/compilable/previewhelp.d | 1 + tests/dmd/fail_compilation/fastdfa.d | 161 ++ 21 files changed, 9542 insertions(+), 2 deletions(-) create mode 100644 dmd/dfa/entry.d create mode 100644 dmd/dfa/fast/analysis.d create mode 100644 dmd/dfa/fast/expression.d create mode 100644 dmd/dfa/fast/report.d create mode 100644 dmd/dfa/fast/statement.d create mode 100644 dmd/dfa/fast/structure.d create mode 100644 dmd/dfa/utils.d create mode 100644 tests/dmd/compilable/fastdfa.d create mode 100644 tests/dmd/fail_compilation/fastdfa.d diff --git a/dmd/cli.d b/dmd/cli.d index beb8ab745d..9553654c8a 100644 --- a/dmd/cli.d +++ b/dmd/cli.d @@ -1073,6 +1073,8 @@ dmd -cov -unittest myprog.d Feature("systemVariables", "systemVariables", "disable access to variables marked '@system' from @safe code", "https://dlang.org/spec/attribute.html#system-variables"), + Feature("fastdfa", "useFastDFA", + "Fast dataflow analysis engine, experimental"), ]; } diff --git a/dmd/declaration.h b/dmd/declaration.h index 197c69087d..9c55180483 100644 --- a/dmd/declaration.h +++ b/dmd/declaration.h @@ -610,6 +610,8 @@ class FuncDeclaration : public Declaration AttributeViolation* pureViolation; AttributeViolation* nothrowViolation; + void* parametersDFAInfo; + // Formerly FUNCFLAGS uint32_t flags; bool purityInprocess() const; diff --git a/dmd/dfa/entry.d b/dmd/dfa/entry.d new file mode 100644 index 0000000000..0a2c7ca5f0 --- /dev/null +++ b/dmd/dfa/entry.d @@ -0,0 +1,139 @@ +/** + * Entry point into Data Flow Analysis engine. + * + * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) + * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) + * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dfa/entry.d, dfa/entry.d) + * Documentation: https://dlang.org/phobos/dmd_dfa_entry.html + * Coverage: https://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/dfa/entry.d + */ +module dmd.dfa.entry; +import dmd.common.outbuffer; +import dmd.func; +import dmd.astenums; +import dmd.globals; +import dmd.mangle; +import dmd.dscope; +import dmd.dsymbol; +import core.stdc.stdio; +import core.stdc.string; + +void dfaEntry(FuncDeclaration fd, Scope* sc) +{ + version (none) + { + import core.memory; + + auto before = GC.stats; + + fastDFA(fd, sc); + + auto after = GC.stats; + if (before.allocatedInCurrentThread != after.allocatedInCurrentThread) + printf("edelta %lld\n", after.allocatedInCurrentThread - before + .allocatedInCurrentThread); + } + else + { + fastDFA(fd, sc); + } +} + +private: + +void fastDFA(FuncDeclaration fd, Scope* sc) +{ + import dmd.dfa.fast.structure; + import dmd.dfa.fast.expression; + import dmd.dfa.fast.statement; + import dmd.dfa.fast.analysis; + import dmd.dfa.fast.report; + + if (fd.skipCodegen) + { + // No point running DFA on code that'll never run but has already passed CTFE. + // Takes into account CTFE, typeof, traits compiles, CTFE, and static if/assert. + return; + } + else if (fd.isInstantiated) + { + // If its a template instantiation, + // we'll also check the scopes to see if it known to have a CT only access. + + if (sc.isKnownToHaveACompileTimeContext) + return; + } + + // Use these if statements for debugging specific things. + //if (fd.ident.toString != "incrementEffect") return; + //if (!(fd.ident.toString == "test3632" || fd.ident.toString == "test")) return; + //if (fd.loc.linnum < 1380) return; + //if (fd.getModule.ident.toString != "start") return; + //if (strcmp(mangleExact(fd), "_D5ocean4util9container5cache16ExpiringLRUCache__TQvTSQCaQBxQBvQBo20ExpiredCacheReloader__TQzTSQDpQDmQDkQDd25ExpiredCacheReloader_test7TrivialZQCz10CacheValueZQFa19getExpiringOrCreateMFmJbbZPQFi") != 0) return; + + // Protect functions based upon safetiness of it. + // It may be desirable to disable some behaviors in @system code, or completely. + version (none) + { + auto ty = fd.type.isTypeFunction; + assert(ty !is null); + if (ty.trust != TRUST.safe) + return; + } + + DFACommon dfaCommon; + scope StatementWalker stmtWalker = new StatementWalker; + ExpressionWalker expWalker; + DFAAnalyzer analyzer; + DFAReporter reporter; + + stmtWalker.dfaCommon = &dfaCommon; + expWalker.dfaCommon = &dfaCommon; + analyzer.dfaCommon = &dfaCommon; + reporter.dfaCommon = &dfaCommon; + + stmtWalker.expWalker = &expWalker; + expWalker.stmtWalker = stmtWalker; + + stmtWalker.analyzer = &analyzer; + expWalker.analyzer = &analyzer; + + analyzer.reporter = &reporter; + reporter.errorSink = global.errorSink; + + dfaCommon.printIfStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("============================== %s : %s = %s at ", + fd.getModule.ident.toChars, mangleExact(fd), fd.toFullSignature); + + appendLoc(ob, fd.loc); + ob.writestring("\n"); + }); + + scope (failure) + { + if (!dfaCommon.debugStructure) + { + printf("ICE: ERROR %s : %s = %s at %s\n", fd.getModule.ident.toChars, + mangleExact(fd), fd.toFullSignature, fd.loc.toChars); + fflush(stdout); + } + } + + version (none) + { + printf("function %s : %s = %s at %s\n", fd.getModule.ident.toChars, + mangleExact(fd), fd.toFullSignature, fd.loc.toChars); + fflush(stdout); + } + + stmtWalker.start(fd); + + dfaCommon.printIfStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("------------------------------ %s : %s = %s at ", + fd.getModule.ident.toChars, mangleExact(fd), fd.toFullSignature); + + appendLoc(ob, fd.loc); + ob.writestring("\n"); + }); +} diff --git a/dmd/dfa/fast/analysis.d b/dmd/dfa/fast/analysis.d new file mode 100644 index 0000000000..8a0f31ec76 --- /dev/null +++ b/dmd/dfa/fast/analysis.d @@ -0,0 +1,2036 @@ +/** + * Analysis engine for the fast Data Flow Analysis engine. + * + * Has the convergence and transfer functions. + * + * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) + * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) + * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dfa/fast/analysis.d, dfa/fast/analysis.d) + * Documentation: https://dlang.org/phobos/dmd_dfa_fast_analysis.html + * Coverage: https://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/dfa/fast/analysis.d + */ +module dmd.dfa.fast.analysis; +import dmd.dfa.fast.structure; +import dmd.dfa.fast.report; +import dmd.dfa.utils; +import dmd.location; +import dmd.identifier; +import dmd.func; +import dmd.declaration; +import dmd.astenums; +import dmd.mtype; +import dmd.root.array; +import core.stdc.stdio; + +//version = DebugJoinMeetOp; + +struct DFAAnalyzer +{ + DFACommon* dfaCommon; + DFAReporter* reporter; + + DFAScopeVar* convergeExpression(DFALatticeRef lr, bool isSideEffect = false) + { + if (lr.isNull) + return null; + + DFAVar* ctxVar; + DFAConsequence* ctx = lr.getContext(ctxVar); + assert(ctx !is null); + + lr.cleanupConstant(ctxVar); + + DFAScope* sc = isSideEffect ? dfaCommon.getSideEffectScope() : dfaCommon.currentDFAScope; + DFAScopeVar* ret = sc.getScopeVar(ctxVar); + + while (sc !is null) + { + if (ctx.truthiness == Truthiness.Maybe) + { + if (!ctx.maybeTopSeen && ctxVar !is null && !ctxVar.haveBase) + { + ret.lr = join(ret.lr, lr.copy); + assert(ret.lr.getContextVar() is ctxVar); + } + } + else + { + foreach (c; lr) + { + if (!c.maybeTopSeen && c.var !is null && !c.var.haveBase) + { + DFAScopeVar* scv = sc.getScopeVar(c.var); + + DFAConsequence* oldC = scv.lr.getContext; + assert(oldC !is null); + + oldC.joinConsequence(oldC, c, null, false, false, false); + assert(scv.lr.getContextVar() is c.var); + } + } + } + + sc = sc.child; + } + + return ret; + } + + void convergeStatementIf(DFALatticeRef condition, DFAScopeRef scrTrue, + DFAScopeRef scrFalse, bool haveFalseBody, bool unknownBranchTaken, + int predicateNegation) + { + const lastLoopyLabelDepth = dfaCommon.lastLoopyLabel.depth; + bool bothJumped, bothReturned; + + // False body should never be null. + assert(!scrFalse.isNull); + + void protectLoopAgainst(ref DFAScopeRef scr) + { + if (dfaCommon.lastLoopyLabel is null) + return; + + /* + We have whats looks like: + + for(;condition1;) { + if (condition2) { + ??? + } else { + ??? + } + } + + Where either true or false branch could alter a variable outside of itself. + */ + + foreach (contextVar, l, scv; scr) + { + // Ignore any variables declared within the loop + if (contextVar.declaredAtDepth >= lastLoopyLabelDepth) + continue; + + DFAScopeVar* scvParent = dfaCommon.acquireScopeVar(contextVar); + if (scvParent is null) + continue; + + DFAConsequence* c = l.context; + assert(c !is null); + + DFAConsequence* cParent = scvParent.lr.getContext; + assert(cParent !is null); + + if (c.truthiness != cParent.truthiness) + c.truthiness = Truthiness.Unknown; + if (c.nullable != cParent.nullable) + c.nullable = Nullable.Unknown; + } + } + + /* + Gates look like: + + bool gate; + if(gate) { + ??? + } else { + ??? + } + + Not: + + bool gate1, gate2; + if (gate1 && gate2) { + ??? + } else { + ??? + } + */ + DFAConsequence* gateConsequence = condition.getGateConsequence; + + /* + Given a gate, store any output state of a if statement branch into it. + Ignoring the nature of consequences, and instead look limitedly at the maybe tops. + */ + void storeGateState(ref DFALatticeRef onto, ref DFAScopeRef scr) + { + foreach (contextVar, l; scr) + { + l.walkMaybeTops((DFAConsequence* branchC) { + // Do no change the state of the gate. Causes bugs. + // Stuff like a null checked if statement results in a dereference on null. + + if (gateConsequence.var !is branchC.var + && branchC.var !is null && !branchC.var.haveBase) + { + DFAConsequence* into = onto.findConsequence(branchC.var); + + if (into !is null) + { + if (into.writeOnVarAtThisPoint < branchC.writeOnVarAtThisPoint) + into.meetConsequence(into, branchC); + } + else if ((branchC.var.isTruthy && branchC.truthiness > Truthiness.Maybe) + || (branchC.var.isNullable && branchC.nullable != Nullable.Unknown)) + { + onto.addConsequence(branchC.var, branchC); + } + } + + return true; + }); + } + } + + if (gateConsequence !is null && !gateConsequence.var.haveBase) + { + DFAScopeVar* gateScv = dfaCommon.lastLoopyLabel.getScopeVar(gateConsequence.var); + + if (gateScv !is null) + { + if (gateScv.gatePredicateWriteCount == 0 + || gateScv.gatePredicateWriteCount != gateConsequence.writeOnVarAtThisPoint) + { + gateScv.lrGatePredicate = dfaCommon.makeLatticeRef; + gateScv.lrGateNegatedPredicate = dfaCommon.makeLatticeRef; + gateScv.gatePredicateWriteCount = gateConsequence.writeOnVarAtThisPoint; + } + + if (predicateNegation == 1) + { + storeGateState(gateScv.lrGateNegatedPredicate, scrTrue); + if (haveFalseBody) + storeGateState(gateScv.lrGatePredicate, scrFalse); + } + else if (predicateNegation == 2) + { + storeGateState(gateScv.lrGatePredicate, scrTrue); + if (haveFalseBody) + storeGateState(gateScv.lrGateNegatedPredicate, scrFalse); + } + } + } + + void protectGate() + { + if (gateConsequence is null) + return; + + foreach (contextVar, lTrue, scvTrue; scrTrue) + { + DFAScopeVar* scvParent = dfaCommon.acquireScopeVar(contextVar); + if (scvParent is null) + continue; + + DFAConsequence* cTrue = lTrue.context; + assert(cTrue !is null); + + DFAConsequence* cParent = scvParent.lr.getContext; + assert(cParent !is null); + + DFAScopeVar* scvFalse = scrFalse.findScopeVar(contextVar); + DFAConsequence* cFalse = scvFalse !is null ? scvFalse.lr.getContext : null; + + if (cFalse !is null) + { + // If true and false branches disagree on state, and if either of them are above parent, set as unknown. + + if ((cTrue.truthiness != cFalse.truthiness + && (cTrue.truthiness > cParent.truthiness + || cFalse.truthiness > cParent.truthiness))) + { + cTrue.truthiness = Truthiness.Unknown; + cFalse.truthiness = Truthiness.Unknown; + } + else if (haveFalseBody && cParent.truthiness != Truthiness.Unknown + && (cTrue.truthiness == Truthiness.Unknown + || cFalse.truthiness == Truthiness.Unknown)) + { + } + else if (cTrue.nullable != cFalse.nullable + && (cTrue.nullable > cParent.nullable + || cFalse.nullable > cParent.nullable)) + { + cTrue.nullable = Nullable.Unknown; + cFalse.nullable = Nullable.Unknown; + } + else if (haveFalseBody && cParent.nullable != Nullable.Unknown + && (cTrue.nullable == Nullable.Unknown + || cFalse.nullable == Nullable.Unknown)) + { + } + } + else + { + if (cTrue.truthiness > cParent.truthiness) + cTrue.truthiness = Truthiness.Unknown; + else if (cParent.truthiness != Truthiness.Unknown + && cTrue.truthiness == Truthiness.Unknown) + { + } + + if (cTrue.nullable > cParent.nullable) + cTrue.nullable = Nullable.Unknown; + else if (cParent.nullable != Nullable.Unknown + && cTrue.nullable == Nullable.Unknown) + { + } + } + } + + foreach (contextVar, lFalse, scvFalse; scrFalse) + { + DFAScopeVar* scvParent = dfaCommon.acquireScopeVar(contextVar); + if (scvParent is null) + continue; + + DFAConsequence* cFalse = lFalse.context; + assert(cFalse !is null); + + DFAConsequence* cParent = scvParent.lr.getContext; + assert(cParent !is null); + + if (!scrTrue.isNull && scrTrue.findScopeVar(contextVar) !is null) + continue; // handled already + + if (cFalse.truthiness > cParent.truthiness + || (cParent.truthiness != Truthiness.Unknown + && cFalse.truthiness == Truthiness.Unknown)) + { + contextVar.unmodellable = true; + cFalse.truthiness = Truthiness.Unknown; + } + + if (cFalse.nullable > cParent.nullable + || (cParent.nullable != Nullable.Unknown + && cFalse.nullable == Nullable.Unknown)) + { + contextVar.unmodellable = true; + cFalse.nullable = Nullable.Unknown; + } + } + } + + protectGate; + + /* + We have a true body which means we could be in one of the following cases: + Where ... means user code. + 1. + if (condition) + else { + ??? + } + 2. + if (condition) { + ... + } else { + ... + } + 3. + if (condition) { + ... + } else { + } + */ + + if (scrTrue.isNull) + { + // If the true body is missing, that means it could not have executed. + // Converge the false branch assuming that it will always have executed. + // This covers scenario 1. + + bothJumped = scrFalse.isNull ? false : scrFalse.sc.haveJumped; + bothReturned = scrFalse.isNull ? false : scrFalse.sc.haveReturned; + + protectLoopAgainst(scrFalse); + convergeScope(scrFalse); + } + else if (haveFalseBody) + { + // We have both a true branch and a false branch with user code. + // This is scenario 2, except it isn't the full scenario. + // One of these branches or both may jump. + + /* + a. + if (condition) { + condition + ... + } else { + !condition + ... + } + b. + if (condition) { + condition + ... + jump; + } else { + !condition + ... + } + c. + if (condition) { + condition + ... + } else { + !condition + ... + jump; + } + d. + if (condition) { + condition + ... + jump; + } else { + !condition + ... + jump; + } + */ + + bothJumped = scrTrue.sc.haveJumped && scrFalse.sc.haveJumped; + bothReturned = scrTrue.sc.haveReturned && scrFalse.sc.haveReturned; + + if (scrTrue.sc.haveJumped == scrFalse.sc.haveJumped) + { + // In scenario d we've both jumped, any effects at that time were already copied to the jump point. + // Nothing for us to do in that scenario. + + if (!scrTrue.sc.haveJumped) + { + // In scenario a, neither has jumped, any effects at the end of their bodies should be meet'd. + // Then we can converge that into parent scope. + + protectGate; + DFAScopeRef meeted = meetScope(scrTrue, scrFalse, true); + assert(!meeted.isNull); + protectLoopAgainst(meeted); + convergeScope(meeted); + } + } + else if (scrTrue.sc.haveJumped) + { + // In scenario b the true branch has jumped, but not the false. + // Any effects seen at the true branch have been already copied to the jump point. + protectLoopAgainst(scrFalse); + convergeScope(scrFalse); + } + else if (scrFalse.sc.haveJumped) + { + // In scenario c, the false branch has jumped, but not the true. + // Any effects seen at the false branch have been already copied to the jump point. + protectLoopAgainst(scrTrue); + convergeScope(scrTrue); + } + else + assert(0); + } + else + { + // In scenario 3. + // We have a true branch with user code, but not a false branch. + // The false branch contains the effects of the negated condition. + + if (scrTrue.sc.haveJumped) + { + /* + The true branch jumped, which means only the false branch matters. + if (condition) { + condition + ... + jumped; + } else { + !condition + } + */ + protectLoopAgainst(scrFalse); + convergeScope(scrFalse); + } + else + { + /* + The false branch will modify the condition by negating it from within it. + We really are not interested in it. + + if (condition) { + condition + ... + } else { + !condition + } + + Consider: + if (var !is null) { + assert(var !is null); + } else { + assert(var is null); + } + Which behavior is correct? That would be the parent. + */ + + protectLoopAgainst(scrTrue); + + // I spent over a month trying to get this to be convergeScope (join instead of meet). ~Rikki + // It is a giant ball of false positives, that cannot be unraveled. + // It may appear to be a great idea to change this, but I can assure you, + // without accepting a false positive or two or three you will not be changing it from this. + // LEAVE THIS ALONE! + convergeStatement(scrTrue, false, true); + } + } + + if (bothJumped) + dfaCommon.currentDFAScope.haveJumped = true; + if (bothReturned) + dfaCommon.currentDFAScope.haveReturned = true; + } + + void applyGateOnBranch(DFAVar* gateVar, int predicateNegation, bool branch) + { + if (gateVar is null || predicateNegation == 0) + return; + + DFAScopeVar* scv = dfaCommon.lastLoopyLabel.findScopeVar(gateVar); + if (scv is null || scv.gatePredicateWriteCount != gateVar.writeCount) + return; + + void handle(ref DFALatticeRef lr) + { + foreach (cGate; lr) + { + if (cGate.writeOnVarAtThisPoint < cGate.var.writeCount) + continue; + + DFAScopeVar* scv = dfaCommon.acquireScopeVar(cGate.var); + if (scv is null) + continue; + + DFAConsequence* cCurrent = scv.lr.getContext; + assert(cCurrent !is null); + + cCurrent.joinConsequence(cCurrent, cGate, null, false); + } + } + + if (branch) + { + if (predicateNegation == 1) + handle(scv.lrGateNegatedPredicate); + else + handle(scv.lrGatePredicate); + } + else + { + if (predicateNegation == 1) + handle(scv.lrGatePredicate); + else + handle(scv.lrGateNegatedPredicate); + } + } + + void convergeStatementLoopyLabels(DFAScopeRef containing, ref Loc loc) + { + const scopeHaveRun = containing.sc.isLoopyLabelKnownToHaveRun; + + /* + A loopy label when scope is known to have ran (once): + + Label: { + ... + if (condition) { + increment; + goto Label; + } + } + + When it isn't known to ran once: + + if (condition) { + Label: { + ... + if (condition) { + increment; + goto Label; + } + } + } + + */ + + DFAScopeRef afterScopeState = containing.sc.afterScopeState; + + loopyLabelBeforeContainingCheck(containing, containing.sc.beforeScopeState, loc); + if (scopeHaveRun) + convergeScope(containing); + else + { + if (containing.sc.haveReturned) + dfaCommon.currentDFAScope.haveReturned = true; + convergeStatement(containing, false, true); + } + + convergeStatement(afterScopeState, false); + } + + void loopyLabelBeforeContainingCheck(ref DFAScopeRef containing, + DFAScopeRef beforeScopeState, ref const(Loc) loc) + { + void checkForNull(DFAScopeVar* assertedVar, DFAConsequence* oldC, DFAConsequence* newC) + { + version (none) + { + printf("check for null on %p\n", assertedVar.var); + printf(" %p %p %d %d %d\n", oldC, newC, assertedVar.derefDepth, + oldC !is null ? oldC.nullable : -1, newC !is null ? newC.nullable : -1); + } + + if (assertedVar.var.var is null || oldC is null || newC is null + || oldC.nullable != Nullable.NonNull + || newC.nullable != Nullable.Null || assertedVar.derefDepth == 0) + return; + + version (none) + { + printf(" next %d %d\n", assertedVar.derefAssertedDepth, assertedVar.derefDepth); + } + + if (assertedVar.derefAssertedDepth > 0 + && assertedVar.derefDepth < assertedVar.derefAssertedDepth) + reporter.onLoopyLabelLessNullThan(assertedVar.var, loc); + else if (assertedVar.derefAssertedDepth == 0) + reporter.onLoopyLabelLessNullThan(assertedVar.var, loc); + } + + void checkForAssignAfterAssert(ref DFAScopeRef toProcessScope, + DFAScopeVar* assertedVar, DFALattice* assertedLattice) + { + if (assertedVar.var is null || assertedVar.var.var is null) + return; + + version (none) + { + printf("checkForAssignAfterAssert %p `%s` %d:%d\n", assertedVar.var, + assertedVar.var.var.toChars, assertedVar.assertDepth, + assertedVar.assignDepth); + } + + DFALatticeRef assertedLatticeRef; + assertedLatticeRef.lattice = assertedLattice; + scope (exit) + assertedLatticeRef.lattice = null; + + foreach (c; assertedLatticeRef) + { + if (c.var is null || c.var.var is null) + continue; + + DFAScopeVar* newSCV = toProcessScope.findScopeVar(c.var); + DFAConsequence* newC; + if (newSCV is null || (newC = newSCV.lr.findConsequence(c.var)) is null) + continue; + + DFAScopeVar* currentSCV = dfaCommon.acquireScopeVar(c.var); + DFAConsequence* currentC; + if (currentSCV is null || (currentC = currentSCV.lr.findConsequence(c.var)) is null) + continue; + + version (none) + { + printf(" %p `%s`\n", c.var, c.var.var.toChars); + printf(" new assert=%d, assign=%d\n", + newSCV.assertDepth, newSCV.assignDepth); + printf(" %d:%d\n", newC.truthiness, newC.nullable); + printf(" current assert=%d, assign=%d \n", + currentSCV.assertDepth, currentSCV.assignDepth); + printf(" %d:%d\n", currentC.truthiness, currentC.nullable); + } + + const truthinessNotEqual = currentC.truthiness != Truthiness.Unknown + && currentC.truthiness != newC.truthiness; + const nullableNotEqual = currentC.nullable != Nullable.Unknown + && currentC.nullable != newC.nullable; + const assertLessThanAssign = assertedVar.assertDepth <= newSCV.assignDepth; + + if (!assertLessThanAssign || !(truthinessNotEqual || nullableNotEqual)) + continue; + else if (nullableNotEqual) + { + // If the nullability is changing, that means its not predictable + newC.nullable = Nullable.Unknown; + newC.truthiness = Truthiness.Unknown; + } + else if (truthinessNotEqual) + { + // If the truthiness is changing, that means its not predictable + newC.truthiness = Truthiness.Unknown; + } + } + } + + foreach (var, l2; beforeScopeState) + { + DFAScopeVar* oldState = dfaCommon.acquireScopeVar(var); + DFAScopeVar* newState = containing.findScopeVar(var); + if (oldState is null || newState is null) + continue; + + checkForNull(newState, oldState.lr.lattice.context, l2.context); + checkForAssignAfterAssert(beforeScopeState, newState, l2); + } + + foreach (var, l2, newState; containing) + { + if (var.var is null) + continue; + + DFAScopeVar* oldState = dfaCommon.acquireScopeVar(var); + if (oldState is null || newState is null) + continue; + + checkForNull(newState, oldState.lr.lattice.context, l2.context); + checkForAssignAfterAssert(containing, newState, l2); + } + } + + void convergeScope(DFAScopeRef scr) + { + if (scr.isNull) + return; + + const jumped = scr.sc.haveJumped, returned = scr.sc.haveReturned; + + DFALatticeRef lr; + DFAScopeVarMergable mergable; + DFAVar* var; + + for (;;) + { + lr = scr.consumeNext(var, mergable); + if (lr.isNull) + break; + + lr.cleanupConstant(var); + + dfaCommon.check; + dfaCommon.acquireScopeVar(var); + + DFAScopeVar* scv = dfaCommon.swapLattice(var, (lattice) { + assert(!lattice.isNull); + lattice.check; + + DFAVar* lrCtx = lr.getContextVar; + assert(lrCtx is var); + assert(!lr.isNull); + lr.check; + return lr; + }); + + if (scv !is null) + scv.mergable.merge(mergable); + dfaCommon.check; + } + + if (jumped) + dfaCommon.currentDFAScope.haveJumped = true; + if (returned) + dfaCommon.currentDFAScope.haveReturned = true; + } + + void convergeStatement(DFAScopeRef scr, bool allBranchesTaken = true, + bool couldScopeNotHaveRan = false, bool ignoreWriteCount = false, + bool unknownAware = false) + { + const depth = dfaCommon.currentDFAScope.depth; + + DFALatticeRef lr; + DFAScopeVarMergable mergable; + DFAVar* var; + + for (;;) + { + dfaCommon.check; + + lr = scr.consumeNext(var, mergable); + if (var is null) + break; + + lr.cleanupConstant(var); + + DFAScopeVar* scv = dfaCommon.swapLattice(var, (lattice) { + assert(!lattice.isNull); + lattice.check; + + DFAVar* lrCtx = lr.getContextVar; + assert(lrCtx is var); + + // make sure it exists in parent + DFALatticeRef lr = allBranchesTaken ? join(lattice, lr, depth, + null, couldScopeNotHaveRan || ignoreWriteCount, unknownAware) : meet(lattice, + lr, depth, couldScopeNotHaveRan); + + assert(!lr.isNull); + lr.check; + return lr; + }); + + if (scv !is null) + scv.mergable.merge(mergable); + dfaCommon.check; + } + } + + void convergeFunctionCallArgument(DFALatticeRef lr, ParameterDFAInfo* paramInfo, + ulong paramStorageClass, FuncDeclaration calling, ref Loc loc) + { + DFAVar* ctx; + DFAConsequence* cctx = lr.getContext(ctx); + + if (paramInfo !is null && cctx !is null) + { + // ok we have a context variable, check it against paramInfo + if (paramInfo.notNullIn == Fact.Guaranteed && cctx.nullable == Nullable.Null) + reporter.onFunctionCallArgumentLessThan(cctx, paramInfo, calling, loc); + } + + const isByRef = (paramStorageClass & (STC.ref_ | STC.out_)) != 0; + const couldEscape = (paramStorageClass & STC.scope_) == 0 + || (paramStorageClass & (STC.return_ | STC.returnScope | STC.returnRef)) != 0; + + bool seePointer(DFAVar* var) + { + bool handledVar; + + // If the variable can point to something we can model (i.e. symbol offset) to its base variable + // Or if the parameter is by-ref, then we must consider the output state of the parameter. + if (isByRef || var.haveBase) + { + var.walkRoots((root) { + // If the var could be escaped out, forget about reporting on it ever again + // If we had escape analysis we could temporarily disable it, but that isn't implemented. + if (couldEscape) + root.unmodellable = true; + + // Put the state of the var into an unknown state, + // this prevents it from infesting other variables. + DFALatticeRef temp = dfaCommon.makeLatticeRef; + temp.setContext(root); + seeWrite(root, temp); + this.convergeExpression(temp, true); + + // now its all set to unknown + + if (root !is var) + { + DFAConsequence* c = lr.findConsequence(root); + if (c !is null) + c.maybeTopSeen = true; + } + else + handledVar = true; + }); + } + + return handledVar; + } + + if (ctx is null) + { + lr.walkMaybeTops((c) { + if (c.var is null) + return true; + + seePointer(c.var); + return true; + }); + } + else + { + if (seePointer(ctx)) + cctx.maybeTopSeen = true; + } + + this.convergeExpression(lr, true); + } + + void transferAssert(DFALatticeRef lr, ref Loc loc, bool ignoreWriteCount, + bool dueToConditional = false) + { + if (lr.isNull) + return; + + const currentDepth = dfaCommon.currentDFAScope.depth; + bool modellable = true; + + lr.walkMaybeTops((DFAConsequence* c) { + if (c.var !is null && !c.var.isModellable) + { + modellable = false; + return false; + } + + return true; + }); + + void handle(DFAConsequence* c) + { + if (c.var is null || c.var.haveBase) + return; + + DFAScopeVar* scv = dfaCommon.acquireScopeVar(c.var); + c.var.assertedCount++; + + version (none) + { + printf("asserting %d %p %d:%d %d:%d\n", ignoreWriteCount, c.var, c.var.writeCount, + c.writeOnVarAtThisPoint, currentDepth, c.var.declaredAtDepth); + printf(" %d && %d\n", !ignoreWriteCount, + c.var.writeCount > c.writeOnVarAtThisPoint); + printf(" %d <\n", currentDepth < c.var.declaredAtDepth); + printf(" write on var %d vs %d\n", c.var.writeCount, c.writeOnVarAtThisPoint); + } + + if (currentDepth < c.var.declaredAtDepth || (!ignoreWriteCount + && c.var.writeCount > c.writeOnVarAtThisPoint)) + return; + + if ((scv = dfaCommon.lastLoopyLabel.findScopeVar(c.var)) !is null) + { + if (c.nullable == Nullable.NonNull && (scv.derefAssertedDepth == 0 + || scv.derefAssertedDepth > currentDepth)) + { + scv.derefAssertedDepth = currentDepth; + } + } + + dfaCommon.swapLattice(c.var, (lattice) { + DFAConsequence* old = lattice.addConsequence(c.var); + + version (none) + { + printf("swapping %p %d:%d and %d:%d\n", c.var, + old.truthiness, old.nullable, c.truthiness, c.nullable); + } + + old.joinConsequence(old, c, null, false, ignoreWriteCount, false); + + version (none) + { + printf(" %d:%d\n", old.truthiness, old.nullable); + } + return lattice; + }); + } + + // We want the constant context if it exists, to handle equality. + if (DFAConsequence* cctx = lr.getContext) + { + if (modellable && !dueToConditional && cctx.truthiness == Truthiness.False + && loc.isValid) + { + bool disable; + + /* + Supports: + if (gate) + assert(!gate); + and + if (!gate) + assert(gate); + We also have to consider if its the same value based upon write count. + Note: we don't care what the truthiness value actually is for the gate consequence, + we're interested in its inversion status. + However we don't need the actual predicate integer (see ExpressionWalker.walkCondition). + The flag in the consequence is enough, as !!gate should set the lr to unknown not false. + */ + if (DFAConsequence* gateCctx = lr.getGateConsequence) + { + if (DFAScopeVar* gateSCV = dfaCommon.lastLoopyLabel.findScopeVar(gateCctx.var)) + { + if (gateSCV.gatePredicateWriteCount != gateCctx.writeOnVarAtThisPoint) + { + } + else if (!gateCctx.invertedOnce) + { + disable = gateSCV.assertTrueDepth != 0 + && gateSCV.assertTrueDepth > gateSCV.assertFalseDepth; + } + else + disable = gateSCV.assertFalseDepth <= currentDepth; + } + } + + if (!disable) + reporter.onAssertIsFalse(lr, loc); + } + } + + // We want the gate consequence, not the constant context. + // Not interested in an equality. It is about any variable state. + // Update the depths, to give future asserts information needed. + if (DFAConsequence* gateCctx = lr.getGateConsequence) + { + if (DFAScopeVar* gateSCV = dfaCommon.lastLoopyLabel.getScopeVar(gateCctx.var)) + { + if (gateSCV.assignDepth == 0 || gateSCV.assertDepth > currentDepth) + { + gateSCV.assertDepth = currentDepth; + + /* + Set the depth of assert when not unknown to true/false values. + This should not be normalized onto the actual state of the variable, + but the resulting expression value. + + Given: + if (gate) + assert(!gate); + Regardless of gate being known as true/maybe/false, + this will allow us to do a primitivate variation of VRP and effectively make the argument false. + */ + if (gateCctx.truthiness == Truthiness.False + && (gateSCV.assertFalseDepth == 0 + || gateSCV.assertFalseDepth > currentDepth)) + gateSCV.assertFalseDepth = currentDepth; + else if (gateCctx.truthiness >= Truthiness.Maybe + && (gateSCV.assertTrueDepth == 0 + || gateSCV.assertTrueDepth > currentDepth)) + { + gateSCV.assertTrueDepth = currentDepth; + gateSCV.assertFalseDepth = 0; + } + } + } + } + + foreach (c; lr) + { + handle(c); + } + } + + DFALatticeRef transferAssign(DFALatticeRef assignTo, bool construct, bool isBlit, + DFALatticeRef lr, int alteredState, DFALatticeRef indexLR = DFALatticeRef.init) + { + DFAVar* assignToCtx = assignTo.getContextVar; + DFAVar* lrCtx; + DFAConsequence* lrCctx = lr.getContext(lrCtx); + + const noLR = lrCctx is null; + const lrIsTruthy = !noLR ? lrCctx.truthiness == Truthiness.True : false; + const unmodellable = lrCtx !is null && !lrCtx.isModellable; + DFALatticeRef ret; + + if (assignToCtx !is null) + { + // *var = expr; + // is very different from: + // var = expr; + + bool wasDereferenced; + + assignToCtx.visitIfReferenceToAnotherVar((contextVar) { + wasDereferenced = true; + + // This is a dereference: *var = expr; + // Which means the effects of lr don't really apply to the lhs. + + if (contextVar.isTruthy || contextVar.isNullable) + { + // The only thing we know for 100% certainty is that contextVar at this point is going to be non-null. + + DFALatticeRef temp = dfaCommon.makeLatticeRef; + DFAConsequence* cctx = temp.addConsequence(contextVar); + temp.setContext(cctx); + + if (contextVar.isTruthy) + cctx.truthiness = Truthiness.True; + if (contextVar.isNullable) + cctx.nullable = Nullable.NonNull; + + ret = join(ret, temp, 0, null); + } + }); + + if (!wasDereferenced) + { + // We're in a direct assignment + // Any effects from the lr directly apply to our lhs variable. + + if (!construct && noLR) + assignToCtx.unmodellable = true; + + DFALatticeRef assignTo2 = assignTo.copy; + assignTo2.setContext(assignToCtx); + + DFALatticeRef joined = join(assignTo2, + lr.copyWithoutInfiniteLifetime, 0, assignToCtx); + DFAConsequence* c = joined.addConsequence(assignToCtx); + joined.setContext(c); + + if (lrCtx !is null && lrCtx.haveInfiniteLifetime) + { + c.truthiness = Truthiness.True; + c.nullable = Nullable.NonNull; + } + + ret = join(ret, joined, 0, null); + } + } + else + { + ret = join(assignTo, lr.copyWithoutInfiniteLifetime, 0, null); + + DFAConsequence* c = ret.addConsequence(null); + ret.setContext(c); + + if (lrCtx !is null && lrCtx.haveInfiniteLifetime) + { + c.truthiness = Truthiness.True; + c.nullable = Nullable.NonNull; + } + + if (construct && isBlit) + { + if (noLR) + { + c.truthiness = Truthiness.False; + c.nullable = Nullable.Unknown; + } + } + } + + if (ret.isNull) + ret = dfaCommon.makeLatticeRef; + + if (!indexLR.isNull) + ret = this.transferLogicalAnd(ret, indexLR); + + DFAConsequence* retCctx = ret.addConsequence(assignToCtx); + ret.setContext(retCctx); + + if (alteredState == 1) + { + // True + retCctx.truthiness = Truthiness.True; + } + else if (alteredState == 2) + { + // NonNull + retCctx.nullable = Nullable.NonNull; + } + else if (alteredState == 3) + { + // True & NonNull + retCctx.truthiness = Truthiness.True; + retCctx.nullable = Nullable.NonNull; + } + else if (alteredState == 4) + { + // False & Null + retCctx.truthiness = Truthiness.False; + retCctx.nullable = Nullable.Null; + } + else if (alteredState == 5) + { + retCctx.truthiness = Truthiness.Unknown; + retCctx.nullable = Nullable.Unknown; + } + + if (lrIsTruthy && assignToCtx !is null && assignToCtx.isNullable) + retCctx.nullable = Nullable.NonNull; + + if (lrCtx !is null) + { + lrCtx.visitReferenceToAnotherVar((var) { + // escapes, who knows what its gonna look like after this + var.unmodellable = true; + + DFAConsequence* c = ret.addConsequence(var); + c.truthiness = Truthiness.Unknown; + c.nullable = Nullable.Unknown; + }); + } + + if (assignToCtx !is null) + { + if (!construct) + seeWrite(assignToCtx, ret); + + ret.setContext(assignToCtx); + DFAScopeVar* scv = this.convergeExpression(ret.copy, true); + assert(scv !is null); + + if (assignToCtx.isNullable && retCctx.nullable == Nullable.Null) + { + scv.mergable.nullAssignWriteCount = assignToCtx.writeCount; + scv.mergable.nullAssignAssertedCount = assignToCtx.assertedCount; + } + + if (unmodellable) + assignToCtx.unmodellable = true; + } + + return ret; + } + + DFALatticeRef transferNegate(DFALatticeRef lr, bool protectElseNegate = false) + { + bool requireMaybeContext; + + bool negate(DFAConsequence* c) + { + if (c.invertedOnce || (protectElseNegate && c.protectElseNegate)) + { + c.truthiness = Truthiness.Unknown; + c.nullable = Nullable.Unknown; + } + else if (c.var !is null && c.var.haveInfiniteLifetime) + { + // nothing can invert this + } + else + { + c.invertedOnce = true; + + if (c.var !is null && c.var.isBoolean) + { + /* + Handle the case where: + assert(!condition); + + You don't want the condition variable to effect the output lattice truthiness, + but you do want the variable to alter. + */ + requireMaybeContext = true; + c.truthiness = c.truthiness == Truthiness.False + ? Truthiness.True : Truthiness.False; + } + else if (c.truthiness > Truthiness.Maybe) + { + c.truthiness = c.truthiness == Truthiness.True + ? Truthiness.Unknown : Truthiness.True; + } + + if (c.nullable != Nullable.Unknown) + c.nullable = c.nullable == Nullable.NonNull ? Nullable.Unknown + : Nullable.NonNull; + } + + return true; + } + + if (auto cctx = lr.getContext) + { + // !(a && b) only negate the outer expression + // !(a) want to negate the inner condition + if (cctx.var is null) + negate(cctx); + else + lr.walkMaybeTops(&negate); + + if (requireMaybeContext) + { + DFAConsequence* newCctx = lr.acquireConstantAsContext(Truthiness.Maybe, + Nullable.Unknown); + // Don't forget to patch the maybe's, impacts asserts. + newCctx.maybe = cctx.var; + } + } + + return lr; + } + + DFALatticeRef transferDereference(DFALatticeRef lr, ref Loc loc) + { + DFAConsequence* ctx = lr.getContext; + bool couldBeNull; + + if (ctx !is null) + { + DFAVar* var = ctx.var; + + if (var !is null) + { + DFAScopeVar* scv; + + if ((scv = dfaCommon.lastLoopyLabel.findScopeVar(var)) !is null) + { + if (scv.derefDepth == 0 || scv.derefDepth > dfaCommon.currentDFAScope.depth) + scv.derefDepth = dfaCommon.currentDFAScope.depth; + } + + if ((scv = dfaCommon.currentDFAScope.findScopeVar(var)) !is null) + { + if (var.writeCount > 0 && scv.mergable.nullAssignAssertedCount == var.assertedCount + && scv.mergable.nullAssignWriteCount == var.writeCount + && var.var !is null) + couldBeNull = true; + } + + var = dfaCommon.findDereferenceVar(var); + lr.setContext(var); + } + + if (ctx.nullable == Nullable.Unknown) + { + // Infer input nullability + + if (couldBeNull) + reporter.onDereference(ctx, loc); + else if (!dfaCommon.currentDFAScope.inConditional && ctx.writeOnVarAtThisPoint == 0 + && ctx.var !is null && ctx.var.assertedCount == 0 + && ctx.var.param !is null && !ctx.var.param.specifiedByUser) + { + if (dfaCommon.debugIt) + printf("Infer variable as non-null `%s` at %s\n", + ctx.var.var.ident.toChars, loc.toChars); + + ctx.nullable = Nullable.NonNull; + ctx.var.param.notNullIn = ParameterDFAInfo.Fact.Guaranteed; + } + } + else if (ctx.nullable == Nullable.Null) + reporter.onDereference(ctx, loc); + } + + return lr; + } + + /// See_Also: equalityArgTypes + DFALatticeRef transferEqual(DFALatticeRef lhs, DFALatticeRef rhs, + bool equalityIsTrue, int equalityType) + { + // struct + // floating point + // lhs && rhs static or dynamic array + // cpu op + + DFAConsequence* lhsCctx = lhs.getContext, rhsCctx = rhs.getContext; + if (lhsCctx is null || rhsCctx is null) + return DFALatticeRef.init; + DFAVar* lhsVar = lhsCctx.var, rhsVar = rhsCctx.var; + + const treatAsPointer = equalityType == 6 || equalityType == 7 || equalityType == 8; + const treatAsBoolean = (lhsVar is null || lhsVar.isBoolean) + && (rhsVar is null || rhsVar.isBoolean); + Truthiness expectedTruthiness = Truthiness.Maybe; + + if (equalityIsTrue) + { + if (treatAsPointer) + { + if (lhsCctx.nullable == Nullable.Null && lhsCctx.nullable == rhsCctx.nullable) + expectedTruthiness = Truthiness.True; + else if (lhsCctx.truthiness == Truthiness.False + && lhsCctx.truthiness == rhsCctx.truthiness) + expectedTruthiness = Truthiness.True; + else if (lhsCctx.truthiness != rhsCctx.truthiness && (lhsCctx.truthiness == Truthiness.False + || rhsCctx.truthiness == Truthiness.False) + && (lhsCctx.truthiness == Truthiness.True + || rhsCctx.truthiness == Truthiness.True)) + expectedTruthiness = Truthiness.False; + } + else + { + if (lhsCctx.truthiness == Truthiness.False + && lhsCctx.truthiness == rhsCctx.truthiness) + expectedTruthiness = Truthiness.True; + else if (lhsCctx.truthiness != rhsCctx.truthiness && (lhsCctx.truthiness == Truthiness.False + || rhsCctx.truthiness == Truthiness.False) + && (lhsCctx.truthiness == Truthiness.True + || rhsCctx.truthiness == Truthiness.True)) + expectedTruthiness = Truthiness.False; + } + } + else + { + if (treatAsPointer) + { + if ((lhsCctx.nullable == Nullable.NonNull + || rhsCctx.nullable == Nullable.NonNull) + && lhsCctx.nullable != rhsCctx.nullable) + expectedTruthiness = Truthiness.True; + else if (lhsCctx.nullable == Nullable.NonNull && lhsCctx.nullable + == rhsCctx.nullable) + expectedTruthiness = Truthiness.Maybe; + else if (lhsCctx.nullable == Nullable.Null && lhsCctx.nullable == rhsCctx.nullable) + expectedTruthiness = Truthiness.False; + else if (lhsCctx.truthiness < Truthiness.False + || rhsCctx.truthiness < Truthiness.False) + expectedTruthiness = Truthiness.Unknown; + else if (lhsCctx.truthiness != rhsCctx.truthiness) + expectedTruthiness = Truthiness.Maybe; + else if (lhsCctx.truthiness == rhsCctx.truthiness) + { + // Can't know just by truthiness if lhs == rhs exactly if it isn't boolean. + if (treatAsBoolean) + expectedTruthiness = Truthiness.False; + else + expectedTruthiness = Truthiness.Unknown; + } + } + else + { + if (lhsCctx.truthiness < Truthiness.False || rhsCctx.truthiness < Truthiness.False) + expectedTruthiness = Truthiness.Unknown; + else if (lhsCctx.truthiness != rhsCctx.truthiness) + expectedTruthiness = Truthiness.Maybe; + else if (lhsCctx.truthiness == rhsCctx.truthiness) + { + // Can't know just by truthiness if lhs == rhs exactly if it isn't boolean. + if (treatAsBoolean) + expectedTruthiness = Truthiness.False; + else + expectedTruthiness = Truthiness.Unknown; + } + } + } + + if (expectedTruthiness == Truthiness.Maybe) + { + // Copy over the effects from a constant to non-constant with variable. + // Allows for a == non-null to make a non-null. + DFAConsequence* toEffectCctx, fromEffectCctx; + + if (lhsVar is null) + { + fromEffectCctx = lhsCctx; + toEffectCctx = rhsCctx; + } + else if (rhsVar is null) + { + toEffectCctx = lhsCctx; + fromEffectCctx = rhsCctx; + } + + if (toEffectCctx !is null && toEffectCctx.var !is null) + { + const copy = (toEffectCctx.var.isTruthy + && toEffectCctx.truthiness == Truthiness.Unknown) + || (toEffectCctx.var.isNullable && toEffectCctx.nullable == Nullable.Unknown); + + if (copy) + { + if (toEffectCctx.var.isTruthy) + toEffectCctx.truthiness = fromEffectCctx.truthiness; + if (toEffectCctx.var.isNullable) + toEffectCctx.nullable = fromEffectCctx.nullable; + } + } + } + + const expectedInvertedOnce = lhsCctx.invertedOnce || rhsCctx.invertedOnce; + DFALatticeRef ret = transferLogicalAnd(lhs, rhs); + + { + DFAConsequence* c = ret.acquireConstantAsContext(expectedTruthiness, Nullable.Unknown); + c.invertedOnce = expectedInvertedOnce; + + if (DFAConsequence* c2 = ret.findConsequence(rhsVar)) + { + c.maybe = rhsVar; + c2.maybe = lhsVar; + } + else + c.maybe = lhsVar; + } + + if (treatAsPointer) + { + if (equalityIsTrue) + { + // var is !null -> var non-null + // !null is var -> var non-null + + // if lhs or rhs is constant + // if lhs or rhs is non-constant && lhs or rhs !is null + // upgrade the non-constant to !is null + + if (lhsVar is null && rhsVar !is null && lhsCctx.nullable == Nullable.Null) + { + if (rhsCctx.nullable == Nullable.NonNull) + rhsCctx.nullable = Nullable.NonNull; + } + else if (lhsVar !is null && rhsVar is null && rhsCctx.nullable == Nullable.Null) + { + if (lhsCctx.nullable == Nullable.NonNull) + lhsCctx.nullable = Nullable.NonNull; + } + + ret.walkMaybeTops((c) => c.protectElseNegate = true); + } + else + { + // var !is null -> var non-null + // null !is var -> var non-null + + // if lhs or rhs is constant + // if lhs or rhs is non-constant && lhs or rhs is null + // upgrade the non-constant to !is null + + if (lhsVar is null && rhsVar !is null && lhsCctx.nullable == Nullable.Null) + { + if (rhsCctx.nullable == Nullable.Null) + rhsCctx.nullable = Nullable.NonNull; + } + else if (lhsVar !is null && rhsVar is null && rhsCctx.nullable == Nullable.Null) + { + if (lhsCctx.nullable == Nullable.Null) + lhsCctx.nullable = Nullable.NonNull; + } + } + } + + if (equalityIsTrue) + ret.walkMaybeTops((c) => c.protectElseNegate = true); + else + ret.walkMaybeTops((c) => c.invertedOnce = true); + + return ret; + } + + void transferGoto(DFAScope* toSc, bool isAfter) + { + DFAScopeRef temp = dfaCommon.currentDFAScope.copy; + + if (isAfter) + { + if (!toSc.afterScopeState.isNull) + temp = joinScope(toSc.afterScopeState, temp); + } + else + { + if (!toSc.beforeScopeState.isNull) + temp = joinScope(toSc.beforeScopeState, temp); + } + + toSc.beforeScopeState = temp; + } + + void transferForwardsGoto(Identifier ident) + { + DFAScopeRef temp = dfaCommon.currentDFAScope.copy; + + dfaCommon.swapForwardLabelScope(ident, (old) { + if (old.isNull) + return temp; + return joinScope(old, temp); + }); + } + + DFALatticeRef transferLogicalAnd(DFALatticeRef lhs, DFALatticeRef rhs) + { + DFAConsequence* cctxLHS = lhs.getContext; + DFAConsequence* cctxRHS = rhs.getContext; + const lhsCctxMaybe = cctxLHS !is null && cctxLHS.truthiness == Truthiness.Maybe; + + if (lhsCctxMaybe) + cctxLHS.truthiness = Truthiness.True; + + /* + We have two trees that look like: + constant + / \ + leaf leaf + + And need to recombine them into this form, where the constants are discarded from the origin. + */ + + DFALatticeRef ret = dfaCommon.makeLatticeRef; + DFAConsequence* cctx = ret.acquireConstantAsContext; + ret.check; + + DFAVar* lastMaybe; + + lhs.walkMaybeTops((DFAConsequence* oldC) { + if (oldC.var is null) + return true; + + DFAConsequence* newC = ret.addConsequence(oldC.var, oldC); + newC.maybe = lastMaybe; + lastMaybe = newC.var; + + ret.check; + return true; + }); + + rhs.walkMaybeTops((DFAConsequence* oldC) { + if (oldC.var is null) + return true; + + DFAConsequence* result = ret.findConsequence(oldC.var); + + if (result is null) + { + DFAConsequence* newC = ret.addConsequence(oldC.var, oldC); + newC.maybe = lastMaybe; + lastMaybe = newC.var; + } + else + result.joinConsequence(result, oldC, null, false, false, true); + + ret.check; + return true; + }); + + foreach (oldC; lhs) + { + if (oldC.var is null) + continue; + + if (!oldC.maybeTopSeen) + { + ret.addConsequence(oldC.var, oldC); + ret.check; + } + } + + foreach (oldC; rhs) + { + if (oldC.var is null) + continue; + + if (!oldC.maybeTopSeen) + { + ret.addConsequence(oldC.var, oldC); + ret.check; + } + } + + cctx.maybe = lastMaybe; + + if (cctxLHS !is null && cctxRHS !is null) + { + if (cctxLHS.truthiness == cctxRHS.truthiness) + cctx.truthiness = cctxLHS.truthiness; + else if (cctxLHS.truthiness == Truthiness.False) + cctx.truthiness = Truthiness.False; + else if (lhsCctxMaybe || cctxRHS.truthiness == Truthiness.Maybe) + cctx.truthiness = Truthiness.Maybe; + else + cctx.truthiness = Truthiness.Unknown; + } + else + cctx.truthiness = Truthiness.Unknown; + + ret.check; + return ret; + } + + DFALatticeRef transferLogicalOr(DFALatticeRef lhs, DFALatticeRef rhs) + { + DFAConsequence* lhsCctx = lhs.getContext; + DFAConsequence* rhsCctx = rhs.getContext; + DFAVar* lhsCtx = lhsCctx !is null ? lhsCctx.var : null, + rhsCtx = rhsCctx !is null ? rhsCctx.var : null; + + /* + We have two trees that look like: + constant + / \ + leaf leaf + + And need to recombine them into this form, where the constants are discarded from the origin. + + (a && b && e) || (c && d && e) -> (e) || (e) -> e + + We are not interested in a, b, c, or d. + This is due to us having no knowledge if the effect is in effect. + */ + + DFALatticeRef ret = dfaCommon.makeLatticeRef; + DFAVar* lastMaybe; + + // Add maybe tops, that are in both + lhs.walkMaybeTops((DFAConsequence* oldC) { + if (oldC.var is null) + return true; + + DFAConsequence* result = ret.addConsequence(oldC.var); + DFAConsequence* oldC2 = rhs.findConsequence(oldC.var); + + if (oldC2 is null) + return true; + + result.meetConsequence(oldC, oldC2, true); + + result.maybe = lastMaybe; + lastMaybe = result.var; + return true; + }); + + // Now add the consequences that are both in lhs and rhs, + // that are not maybe tops. + foreach (oldC; lhs) + { + if (oldC.var is null || oldC.maybeTopSeen) + continue; + + DFAConsequence* result = ret.addConsequence(oldC.var); + DFAConsequence* oldC2 = rhs.findConsequence(oldC.var); + if (oldC2 is null) + continue; + + result.meetConsequence(oldC, oldC2, true); + } + + DFAVar* newCtx = dfaCommon.findVariablePair(lhsCtx, rhsCtx); + DFAConsequence* cctx = ret.addConsequence(newCtx); + ret.setContext(cctx); + cctx.maybe = lastMaybe; + + if (lhsCctx !is null && rhsCctx !is null) + { + if (lhsCctx.truthiness == Truthiness.True || rhsCctx.truthiness == Truthiness.True) + cctx.truthiness = Truthiness.True; + else if (lhsCctx.truthiness != Truthiness.Unknown + && rhsCctx.truthiness != Truthiness.Unknown) + cctx.truthiness = Truthiness.Maybe; + } + + return ret; + } + + DFALatticeRef transferConditional(DFALatticeRef condition, DFAScopeRef scrTrue, DFALatticeRef lrTrue, + DFAScopeRef scrFalse, DFALatticeRef lrFalse, bool unknownBranchTaken, + int predicateNegation) + { + + this.convergeStatementIf(condition, scrTrue, scrFalse, false, + unknownBranchTaken, predicateNegation); + DFAVar* asContext = dfaCommon.findVariablePair(lrTrue.getContextVar, lrFalse.getContextVar); + + DFALatticeRef ret = meet(lrTrue, lrFalse, 0, true); + ret.setContext(asContext); + return ret; + } + + DFAScopeRef transferLoopyLabelAwareStage(DFAScopeRef previous, DFAScopeRef next) + { + assert(!next.isNull); + + if (next.sc.haveJumped || next.sc.haveReturned) + { + /* + Handles the case where you have: + + int* ptr; + switch(thing) { + case 0: + ptr = new int; + break; + default: + return; + } + */ + return previous; + } + + if (previous.isNull) + return next; + + const allJumped = previous.sc.haveJumped && next.sc.haveJumped, + allReturned = previous.sc.haveReturned && next.sc.haveReturned; + + DFAScopeRef ret = meetScope(previous, next, true, true); + assert(!ret.isNull); + + if (allJumped) + ret.sc.haveJumped = true; + if (allReturned) + ret.sc.haveReturned = true; + + return ret; + } + +private: + + DFAScopeRef meetScope(DFAScopeRef scr1, DFAScopeRef scr2, bool copyAll, + bool couldScopeNotHaveRan = false) + { + scr1.check; + scr2.check; + + const depth = dfaCommon.currentDFAScope.depth; + + DFAScopeRef ret; + ret.sc = dfaCommon.allocator.makeScope(dfaCommon, dfaCommon.currentDFAScope); + ret.sc.depth = depth; + ret.sc.haveJumped = scr1.sc.haveJumped && scr2.sc.haveJumped; + ret.sc.haveReturned = scr1.sc.haveReturned && scr2.sc.haveReturned; + + DFALatticeRef lr1, lr2; + DFAScopeVarMergable mergable1, mergable2; + DFAVar* var; + + for (;;) + { + lr1 = scr1.consumeNext(var, mergable1); + if (lr1.isNull) + break; + + lr2 = scr2.consumeVar(var, mergable2); + + if (!copyAll && lr2.isNull) + continue; + + lr1.check; + lr2.check; + + DFALatticeRef meeted = meet(lr1, lr2, depth, couldScopeNotHaveRan); + assert(!meeted.isNull); + meeted.check; + + DFAScopeVar* scv = ret.assignLattice(var, meeted); + scv.mergable.merge(mergable1); + scv.mergable.merge(mergable2); + } + + if (copyAll) + { + for (;;) + { + lr2 = scr2.consumeNext(var, mergable2); + if (lr2.isNull) + break; + + lr2.check; + DFAScopeVar* scv = ret.assignLattice(var, lr2); + scv.mergable.merge(mergable2); + } + } + + ret.check; + return ret; + } + + DFAScopeRef joinScope(DFAScopeRef scr1, DFAScopeRef scr2) + { + scr1.check; + scr2.check; + + const depth = dfaCommon.currentDFAScope.depth; + + DFAScopeRef ret; + ret.sc = dfaCommon.allocator.makeScope(dfaCommon, dfaCommon.currentDFAScope); + ret.sc.depth = depth; + ret.sc.haveJumped = scr1.sc.haveJumped && scr2.sc.haveJumped; + ret.sc.haveReturned = scr1.sc.haveReturned && scr2.sc.haveReturned; + + DFALatticeRef lr1, lr2; + DFAScopeVarMergable mergable1, mergable2; + DFAVar* var; + + for (;;) + { + lr1 = scr1.consumeNext(var, mergable1); + if (lr1.isNull) + break; + + lr2 = scr2.consumeVar(var, mergable2); + + lr1.check; + lr2.check; + + DFALatticeRef joined = join(lr1, lr2, depth); + assert(!joined.isNull); + joined.check; + + DFAScopeVar* scv = ret.assignLattice(var, joined); + scv.mergable.merge(mergable1); + scv.mergable.merge(mergable2); + } + + ret.check; + return ret; + } + + // Converge, see Lattice (Abstract algebra) meet operation (lower bound) + // Operates on a given lattice to converge into current scope's variable state + DFALatticeRef meet(DFALatticeRef lhs, DFALatticeRef rhs, + int filterDepthOfVariable = 0, bool couldScopeNotHaveRan = false) + { + DFALatticeRef ret = dfaCommon.makeLatticeRef; + DFAConsequence* constantRHS = rhs.findConsequence(null); + DFAVar* lhsVar = lhs.getContextVar; + + version (DebugJoinMeetOp) + { + printf("meet %p %d %d\n", lhsVar, filterDepthOfVariable, couldScopeNotHaveRan); + fflush(stdout); + } + + foreach (c1; lhs) + { + if (c1.var is null) + continue; + + version (DebugJoinMeetOp) + { + printf("meet lhs %p %d\n", c1.var, c1.var.declaredAtDepth); + fflush(stdout); + } + + if (filterDepthOfVariable < c1.var.declaredAtDepth && filterDepthOfVariable > 0) + continue; + + DFAConsequence* result = ret.addConsequence(c1.var); + DFAConsequence* c2 = rhs.findConsequence(c1.var); + + result.meetConsequence(c1, c2, couldScopeNotHaveRan); + + if (c1.var is lhsVar && constantRHS !is null) + { + result.meetConsequence(c1, constantRHS, couldScopeNotHaveRan); + } + } + + foreach (c2; rhs) + { + if (c2.var is null || lhs.findConsequence(c2.var) !is null) + continue; + + version (DebugJoinMeetOp) + { + printf("meet rhs %p %d\n", c2.var, c2.var.declaredAtDepth); + fflush(stdout); + } + + if (filterDepthOfVariable < c2.var.declaredAtDepth && filterDepthOfVariable > 0) + continue; + + DFAConsequence* result = ret.addConsequence(c2.var); + result.meetConsequence(c2, null, couldScopeNotHaveRan); + } + + ret.setContext(lhsVar); + ret.check; + return ret; + } + + // Converge, see Lattice (Abstract algebra) meet operation (upper bound) + // Operates on a given lattice to converge into current scope's variable state + DFALatticeRef join(DFALatticeRef lhs, DFALatticeRef rhs, int filterDepthOfVariable = 0, + DFAVar* ignoreLHSCtx = null, bool ignoreWriteCount = false, bool unknownAware = false) + { + DFALatticeRef ret = dfaCommon.makeLatticeRef; + DFAConsequence* constantRHS = rhs.findConsequence(null); + + DFAVar* lhsVar, rhsVar; + DFAConsequence* lhsCtx = lhs.getContext(lhsVar), rhsCtx = rhs.getContext(rhsVar); + + version (DebugJoinMeetOp) + { + printf("Running join on %p and %p, constantRHS=%p, filter=%d, ignoreLHS=%p\n", + lhsVar, rhsVar, constantRHS, filterDepthOfVariable, ignoreLHSCtx); + fflush(stdout); + } + + void processLHSVar(DFAConsequence* c1) + { + if (filterDepthOfVariable < c1.var.declaredAtDepth && filterDepthOfVariable > 0) + return; + + DFAConsequence* result = ret.addConsequence(c1.var); + DFAConsequence* c2 = rhs.findConsequence(c1.var); + + const isC1LHSCtx = lhsVar is c1.var; + result.joinConsequence(c1, c2, null, isC1LHSCtx, ignoreWriteCount, unknownAware); + + if (isC1LHSCtx && constantRHS !is null) + result.joinConsequence(c1, constantRHS, rhsCtx, true, + ignoreWriteCount, unknownAware); + } + + version (DebugJoinMeetOp) + { + printf("joining lhs\n"); + fflush(stdout); + } + + if (ignoreLHSCtx is null || lhsVar !is ignoreLHSCtx) + { + foreach (c1; lhs) + { + if (c1.var is null) + continue; + + processLHSVar(c1); + } + } + else if (lhsVar !is null && lhsVar.haveBase) + { + lhsVar.visitFirstBase((firstBase) { + firstBase.walkToRoot((var) { + processLHSVar(lhs.findConsequence(var)); + }); + }); + } + + version (DebugJoinMeetOp) + { + printf("joining rhs\n"); + fflush(stdout); + } + + foreach (c2; rhs) + { + if (c2.var is null || ret.findConsequence(c2.var) !is null) + continue; + + if (filterDepthOfVariable < c2.var.declaredAtDepth && filterDepthOfVariable > 0) + continue; + + DFAConsequence* result = ret.addConsequence(c2.var); + result.joinConsequence(c2, null, rhsCtx, false, ignoreWriteCount, unknownAware); + } + + version (DebugJoinMeetOp) + { + printf("joining rhs ctx\n"); + fflush(stdout); + } + + if (rhsCtx !is null && rhsVar is null && lhsVar !is null) + { + DFAConsequence* result = ret.addConsequence(lhsVar); + result.joinConsequence(rhsCtx, null, null, false, false, unknownAware); + if (result.writeOnVarAtThisPoint < lhsCtx.writeOnVarAtThisPoint) + result.writeOnVarAtThisPoint = lhsCtx.writeOnVarAtThisPoint; + } + + ret.setContext(lhsVar); + ret.check; + + version (DebugJoinMeetOp) + { + printf("joining done\n"); + fflush(stdout); + } + + return ret; + } + + void seeWrite(ref DFAVar* assignTo, ref DFALatticeRef from) + { + assert(assignTo !is null); + assignTo.writeCount++; + + const currentDepth = dfaCommon.currentDFAScope.depth; + + dfaCommon.acquireScopeVar(assignTo); + DFAConsequence* c = from.findConsequence(assignTo); + if (c !is null) + c.writeOnVarAtThisPoint = assignTo.writeCount; + + if (DFAScopeVar* scv = dfaCommon.lastLoopyLabel.findScopeVar(assignTo)) + { + if (scv.assignDepth == 0 || scv.assignDepth > currentDepth) + scv.assignDepth = currentDepth; + } + } +} diff --git a/dmd/dfa/fast/expression.d b/dmd/dfa/fast/expression.d new file mode 100644 index 0000000000..658e3d547e --- /dev/null +++ b/dmd/dfa/fast/expression.d @@ -0,0 +1,1902 @@ +/** + * Expression walker for the fast Data Flow Analysis engine. + * + * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) + * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) + * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dfa/fast/expression.d, dfa/fast/expression.d) + * Documentation: https://dlang.org/phobos/dmd_dfa_fast_expression.html + * Coverage: https://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/dfa/fast/expression.d + */ +module dmd.dfa.fast.expression; +import dmd.dfa.fast.analysis; +import dmd.dfa.fast.report; +import dmd.dfa.fast.statement; +import dmd.dfa.fast.structure; +import dmd.dfa.utils; +import dmd.common.outbuffer; +import dmd.location; +import dmd.expression; +import dmd.astenums; +import dmd.tokens; +import dmd.func; +import dmd.declaration; +import dmd.mtype; +import dmd.dtemplate; +import dmd.arraytypes; +import dmd.rootobject; +import core.stdc.stdio; + +struct ExpressionWalker +{ + DFACommon* dfaCommon; + StatementWalker stmtWalker; + DFAAnalyzer* analyzer; + + void seeConvergeExpression(DFALatticeRef lr, bool isSideEffect = false) + { + dfaCommon.printStateln("Converging expression:"); + lr.printState("", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + lr.check; + + dfaCommon.check; + analyzer.convergeExpression(lr, isSideEffect); + dfaCommon.check; + + dfaCommon.currentDFAScope.printState("so far", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + dfaCommon.currentDFAScope.check; + } + + void seeConvergeFunctionCallArgument(DFALatticeRef lr, ParameterDFAInfo* paramInfo, + ulong paramStorageClass, FuncDeclaration calling, ref Loc loc) + { + dfaCommon.printStateln("Converging argument:"); + lr.printState("", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + lr.check; + + dfaCommon.check; + analyzer.convergeFunctionCallArgument(lr, paramInfo, paramStorageClass, calling, loc); + dfaCommon.check; + + dfaCommon.currentDFAScope.printState("so far", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + dfaCommon.currentDFAScope.check; + } + + DFALatticeRef seeAssign(DFAVar* assignTo, bool construct, DFALatticeRef lr, + bool isBlit = false, int alteredState = 0) + { + DFALatticeRef assignTo2 = dfaCommon.makeLatticeRef; + assignTo2.setContext(assignTo); + + dfaCommon.check; + DFALatticeRef ret = seeAssign(assignTo2, construct, lr, isBlit); + dfaCommon.check; + + return ret; + } + + DFALatticeRef seeAssign(DFALatticeRef assignTo, bool construct, DFALatticeRef lr, + bool isBlit = false, int alteredState = 0, DFALatticeRef indexLR = DFALatticeRef.init) + { + dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) => ob.printf( + "Assigning construct?%d:%d %d\n", construct, isBlit, alteredState)); + assignTo.printState("to", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + assignTo.check; + lr.printState("from", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + lr.check; + indexLR.printState("index", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + indexLR.check; + + assert(analyzer !is null); + dfaCommon.check; + DFALatticeRef ret = analyzer.transferAssign(assignTo, construct, + isBlit, lr, alteredState, indexLR); + dfaCommon.check; + + ret.check; + ret.printState("result", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + return ret; + } + + DFALatticeRef seeEqual(DFALatticeRef lhs, DFALatticeRef rhs, bool truthiness, + Type lhsType, Type rhsType) + { + const equalityType = equalityArgTypes(lhsType, rhsType); + + dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("Equal iff=%d, ty=%d:%d, ety=%d", truthiness, lhsType.ty, + rhsType !is null ? rhsType.ty : -1, equalityType); + ob.writestring("\n"); + }); + + lhs.printState("lhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + rhs.printState("rhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + + dfaCommon.check; + DFALatticeRef ret = analyzer.transferEqual(lhs, rhs, truthiness, equalityType); + dfaCommon.check; + + ret.printState("result", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + return ret; + } + + DFALatticeRef seeNegate(DFALatticeRef lr, bool protectElseNegate = false) + { + lr.printState("Negate", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + return analyzer.transferNegate(lr, protectElseNegate); + } + + DFALatticeRef seeDereference(ref Loc loc, DFALatticeRef lr) + { + dfaCommon.printStateln("Dereferencing"); + lr.printState("Dereference", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + + dfaCommon.check; + DFALatticeRef ret = analyzer.transferDereference(lr, loc); + dfaCommon.check; + + ret.printState("result", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + return ret; + } + + void seeAssert(DFALatticeRef lr, ref Loc loc, bool dueToConditional = false) + { + lr.printState("Assert", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + + dfaCommon.currentDFAScope.printState("scope", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + dfaCommon.currentDFAScope.check; + + dfaCommon.check; + analyzer.transferAssert(lr, loc, false, dueToConditional); + dfaCommon.check; + + dfaCommon.currentDFAScope.printState("so far", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + dfaCommon.currentDFAScope.check; + } + + void seeSilentAssert(DFALatticeRef lr, bool ignoreWriteCount = false, + bool dueToConditional = false) + { + lr.printState("Assert silent", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + + dfaCommon.currentDFAScope.printState("scope", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + dfaCommon.currentDFAScope.check; + + Loc loc; + dfaCommon.check; + analyzer.transferAssert(lr, loc, ignoreWriteCount, dueToConditional); + dfaCommon.check; + + dfaCommon.currentDFAScope.printState("so far", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + dfaCommon.currentDFAScope.check; + } + + DFALatticeRef seeLogicalAnd(DFALatticeRef lhs, DFALatticeRef rhs) + { + dfaCommon.printStateln("Logical and:"); + lhs.printState("lhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + lhs.check; + rhs.printState("rhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + rhs.check; + + dfaCommon.check; + DFALatticeRef ret = analyzer.transferLogicalAnd(lhs, rhs); + dfaCommon.check; + + ret.printState("result", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + ret.check; + return ret; + } + + DFALatticeRef seeLogicalOr(DFALatticeRef lhs, DFALatticeRef rhs) + { + dfaCommon.printStateln("Logical or:"); + lhs.printState("lhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + rhs.printState("rhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + + dfaCommon.check; + DFALatticeRef ret = analyzer.transferLogicalOr(lhs, rhs); + dfaCommon.check; + + ret.printState("result", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + return ret; + } + + DFALatticeRef seeConditional(DFALatticeRef condition, DFAScopeRef scrTrue, DFALatticeRef lrTrue, + DFAScopeRef scrFalse, DFALatticeRef lrFalse, bool unknownBranchTaken, + int predicateNegation) + { + dfaCommon.printStateln("Condition:"); + condition.printState("condition", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + scrTrue.printState("true sc", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + lrTrue.printState("true lr", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + scrFalse.printState("false sc", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + lrFalse.printState("false lr", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + + dfaCommon.check; + DFALatticeRef ret = analyzer.transferConditional(condition, scrTrue, + lrTrue, scrFalse, lrFalse, unknownBranchTaken, predicateNegation); + dfaCommon.check; + + ret.printState("result", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + dfaCommon.currentDFAScope.printState("so far", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + + ret.check; + dfaCommon.currentDFAScope.check; + return ret; + } + + DFALatticeRef entry(DFAVar* assignTo, DFAVar* constructInto, Expression exp) + { + DFALatticeRef lattice = walk(exp); + lattice.check; + + if (assignTo !is null) + return seeAssign(assignTo, false, lattice); + else if (constructInto !is null) + return seeAssign(constructInto, true, lattice); + else + return lattice; + } + + DFALatticeRef adaptConditionForBranch(Expression expr, bool truthiness) + { + if (expr is null) + return DFALatticeRef.init; + return this.adaptConditionForBranch(this.walk(expr), expr.type, truthiness); + } + + DFALatticeRef adaptConditionForBranch(DFALatticeRef ret, Type type, bool truthiness) + { + if (ret.isNull) + { + ret = dfaCommon.makeLatticeRef; + ret.acquireConstantAsContext; + } + + DFAVar* ctx; + DFAConsequence* cctx = ret.getContext(ctx); + assert(cctx !is null); + + if (ctx !is null && ctx.isNullable && cctx.truthiness == Truthiness.Unknown) + { + DFALatticeRef against = dfaCommon.makeLatticeRef; + against.acquireConstantAsContext(Truthiness.True, Nullable.NonNull); + + ret = this.seeEqual(ret, against, truthiness, type, null); + } + else if (!truthiness) + { + if ((cctx = ret.getGateConsequence) !is null) + { + ret.setContext(cctx); + ret = this.seeNegate(ret); + } + else + { + // Unfortunately negation is a bit overactive for else bodies. + ret = dfaCommon.makeLatticeRef; + ret.acquireConstantAsContext; + } + } + + return ret; + } + + DFALatticeRef walk(Expression expr) + { + if (expr is null || dfaCommon.currentDFAScope.haveJumped) + return DFALatticeRef.init; + + __gshared immutable(string[]) AllExprOpNames = [ + __traits(allMembers, EXP) + ]; + + dfaCommon.edepth++; + dfaCommon.check; + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("[%p]%3d (%s): at ", expr, expr.op, AllExprOpNames[expr.op].ptr); + appendLoc(ob, expr.loc); + ob.writestring("\n"); + }); + + scope (exit) + { + dfaCommon.check; + dfaCommon.edepth--; + } + + final switch (expr.op) + { + case EXP.not: // !x + case EXP.equal: + case EXP.notEqual: + case EXP.identity: // is + case EXP.notIdentity: // !is + case EXP.string_: + case EXP.typeid_: + case EXP.arrayLiteral: + case EXP.assocArrayLiteral: + case EXP.arrayLength: + case EXP.int64: + case EXP.null_: + case EXP.cast_: + case EXP.variable: + int predicateNegation; + return this.walkCondition(expr, predicateNegation); + + case EXP.this_: + auto vd = expr.isThisExp.var; + + if (vd is null) + vd = dfaCommon.currentFunction.vthis; + + if (!dfaCommon.debugUnknownAST && vd is null) + return DFALatticeRef.init; + else if (vd is null) + assert(0); + + DFAVar* var = dfaCommon.findVariable(vd); + return dfaCommon.acquireLattice(var); + + case EXP.dotVariable: + auto dve = expr.isDotVarExp; + + dfaCommon.printStateln("Dot var lhs"); + DFALatticeRef ret = this.walk(dve.e1); + if (ret.isNull) + ret = dfaCommon.makeLatticeRef; + + DFAConsequence* context = ret.getContext; + DFAVar* var; + + // for indirection we start with a clean slate on each access + if (auto vd = dve.var.isVarDeclaration) + { + if (context is null || context.var is null) + var = dfaCommon.findVariable(vd); + else + var = dfaCommon.findVariable(vd, context.var); + } + + DFAConsequence* c = ret.addConsequence(var); + ret.setContext(c); + return ret; + + case EXP.symbolOffset: + // similar to address except has a variable offset + auto soe = expr.isSymOffExp; + DFALatticeRef ret; + DFAVar* varBase, varOffset; + + if (auto vd = soe.var.isVarDeclaration) + { + varBase = dfaCommon.findVariable(vd); + if (varBase is null) + return DFALatticeRef.init; + + ret = dfaCommon.acquireLattice(varBase); + if (ret.isNull) + ret = dfaCommon.makeLatticeRef; + + varOffset = dfaCommon.findOffsetVar(soe.offset, varBase); + assert(varOffset is null || varOffset.haveBase); + + DFAConsequence* c = ret.addConsequence(varOffset); + ret.setContext(c); + } + else if (auto fd = soe.var.isFuncDeclaration) + { + // For some reason, sometimes people like to do an offset that isn't zero for functions. + // So we'll ignore that and assume the offset is "right", + // even if it probably doesn't make sense to be doing it. + + ret = dfaCommon.makeLatticeRef; + ret.acquireConstantAsContext(Truthiness.True, Nullable.NonNull); + } + else + { + if (!dfaCommon.debugUnknownAST) + return DFALatticeRef.init; + else + assert(0); + } + + return ret; + + case EXP.address: + // Similar to symbolOffset except is always at offset 0 + auto ae = expr.isAddrExp; + + DFALatticeRef ret = this.walk(ae.e1); + + if (!ret.isNull) + { + DFAVar* ctx = ret.getContextVar; + + if (ctx !is null) + { + DFAVar* varOffset = dfaCommon.findOffsetVar(0, ctx); + ret.setContext(varOffset); + } + } + + return ret; + + case EXP.declaration: + auto decl = expr.isDeclarationExp.declaration; + + if (auto var = decl.isVarDeclaration) + { + DFAVar* dfaVar = dfaCommon.findVariable(var); + dfaVar.declaredAtDepth = dfaCommon.currentDFAScope.depth; + dfaCommon.acquireScopeVar(dfaVar); + + if (var._init is null) + { + // we can ignore this case, its likely from meta-programming + return DFALatticeRef.init; + } + else + { + final switch (var._init.kind) + { + case InitKind.exp: + auto ei = var._init.isExpInitializer; + DFALatticeRef lr = this.walk(ei.exp); + + if (ei.exp.isConstructExp || ei.exp.isBlitExp) + return lr; + else + return seeAssign(dfaVar, true, lr); + + case InitKind.array: + auto ai = var._init.isArrayInitializer; + DFALatticeRef lr = dfaCommon.makeLatticeRef; + DFAConsequence* c = lr.addConsequence(dfaVar); + lr.setContext(c); + + return seeAssign(dfaVar, true, lr, false, ai.value.length > 0 ? 3 : 2); + + case InitKind.void_: + case InitKind.error: + case InitKind.struct_: + case InitKind.C_: + case InitKind.default_: + return DFALatticeRef.init; + } + } + } + else + return DFALatticeRef.init; + + case EXP.construct: + auto ce = expr.isConstructExp; + + dfaCommon.printStateln("construct lhs"); + DFALatticeRef lhs = this.walk(ce.e1); + + dfaCommon.printStateln("construct rhs"); + DFALatticeRef rhs = this.walk(ce.e2); + return seeAssign(lhs, true, rhs); + + case EXP.negate: // -x + // Without VRP we can't actually model this. + auto ue = expr.isUnaExp; + DFALatticeRef ret = this.walk(ue.e1); + ret.acquireConstantAsContext; + return ret; + + // Basic types + case EXP.void_: + case EXP.float64: + case EXP.complex80: + return DFALatticeRef.init; + + case EXP.call: + auto ce = expr.isCallExp; + assert(ce !is null); + assert(ce.e1 !is null); + return callFunction(ce.f, ce.e1, null, ce.arguments, ce.loc); + + case EXP.blit: + auto be = expr.isBlitExp; + + dfaCommon.printStateln("blit lhs"); + DFALatticeRef lhs = this.walk(be.e1), rhs; + DFAVar* lhsVar = lhs.getContextVar; + + if (auto e2ve = be.e2.isVarExp) + { + if (auto sd = e2ve.var.isSymbolDeclaration) + { + // this evaluates out to a type + + rhs = dfaCommon.makeLatticeRef; + rhs.acquireConstantAsContext(Truthiness.True, Nullable.NonNull); + + goto BlitAssignRet; + } + } + + dfaCommon.printStateln("blit rhs"); + rhs = this.walk(be.e2); + + BlitAssignRet: + DFALatticeRef ret = seeAssign(lhs, true, rhs, true); + return ret; + + case EXP.assign: + auto ae = expr.isAssignExp; + + Expression lhsContext = ae.e1, lhsIndex; + + if (auto ie = ae.e1.isIndexExp) + { + // Is this AA assignment? + + if (isIndexContextAA(ie)) + { + // ae.e1 resolves to a ctx[idx] + // ie.e1 is ctx, and ie.e2 is idx + + lhsContext = ie.e1; + lhsIndex = ie.e2; + } + } + + dfaCommon.printStateln("assign lhs"); + DFALatticeRef lhs = this.walk(lhsContext); + DFALatticeRef indexLR; + + if (lhsIndex !is null) + { + dfaCommon.printStateln("assign lhs index"); + indexLR = this.walk(lhsIndex); + } + + dfaCommon.printStateln("assign rhs"); + DFALatticeRef rhs = this.walk(ae.e2); + DFALatticeRef ret = seeAssign(lhs, false, rhs, false, lhsIndex !is null ? 3 : 0, + indexLR); + + if (ret.isNull) + { + ret = dfaCommon.makeLatticeRef; + ret.acquireConstantAsContext; + } + + return ret; + + case EXP.star: + auto pe = expr.isPtrExp; + dfaCommon.printStateln("Derefencing exp"); + DFALatticeRef lr = walk(pe.e1); + return seeDereference(pe.loc, lr); + + case EXP.index: + // See Slice + auto ie = expr.isIndexExp; + + dfaCommon.printStateln("index lhs"); + DFALatticeRef lhs = this.walk(ie.e1); + dfaCommon.printStateln("index rhs"); + DFALatticeRef index = this.walk(ie.e2); + + DFAVar* lhsCtx; + DFAConsequence* lhsCctx = lhs.getContext(lhsCtx); + + Type lhsType = ie.e1.type; + bool resultHasEffect; + + if (lhsCctx !is null) + { + // Apply effects that this operation will have on to the lhs + + bool effectIndexBase = ie.indexIsInBounds; + + if (lhsType.isTypeAArray !is null) + { + if (ie.modifiable) + effectIndexBase = true; + } + else + resultHasEffect = true; + + if (effectIndexBase) + { + lhsCctx.truthiness = Truthiness.True; + lhsCctx.nullable = Nullable.NonNull; + } + } + + if (lhsCtx !is null && lhsCtx.isNullable) + { + // Dereference the lhs if its a pointer, + // this really should be the case, but it prevents unnecessary work for static arrays. + lhs = seeDereference(ie.loc, lhs); + } + + DFAVar* indexVar = dfaCommon.findIndexVar(lhsCtx); + DFALatticeRef combined = this.seeLogicalAnd(lhs, index); + DFAConsequence* newCctx = combined.addConsequence(indexVar); + combined.setContext(newCctx); + + if (resultHasEffect && indexVar !is null) + { + if (indexVar.isTruthy) + newCctx.truthiness = Truthiness.True; + if (indexVar.isNullable) + newCctx.nullable = Nullable.NonNull; + } + + return combined; + + case EXP.slice: + // See index + auto se = expr.isSliceExp; + + dfaCommon.printStateln("Slice base"); + DFALatticeRef base = this.walk(se.e1); + DFAVar* baseCtx; + DFAConsequence* baseCctx = base.getContext(baseCtx); + + if (se.lwr is null && se.upr is null) + { + // Equivalent to doing slice[] + DFAVar* indexVar = dfaCommon.findIndexVar(baseCtx); + DFAConsequence* newCctx = base.addConsequence(indexVar); + base.setContext(newCctx); + return base; + } + + Truthiness expectedTruthiness; + + if (baseCctx !is null && se.upperIsInBounds) + { + // Earlier VRP in the compiler has determined that it is non-null. + // Even if the fast DFA can't determine it, that has been done already. + + baseCctx.nullable = Nullable.NonNull; + } + + DFALatticeRef ret = base; + + if (se.lwr !is null) + { + // Handle [X .. X] + if (se.upr !is null) + { + auto lwrI = se.lwr.isIntegerExp; + auto uprI = se.upr.isIntegerExp; + + if (lwrI !is null && uprI !is null && lwrI.toInteger == uprI.toInteger) + expectedTruthiness = Truthiness.False; + } + + dfaCommon.printStateln("Slice [lwr"); + ret = this.seeLogicalAnd(ret, this.walk(se.lwr)); + } + + if (se.upr !is null) + { + dfaCommon.printStateln("Slice upr]"); + ret = this.seeLogicalAnd(ret, this.walk(se.upr)); + } + else if (se.lengthVar !is null) + { + // Implicit length var for the upper. + DFAVar* lengthVar = dfaCommon.findVariable(se.lengthVar); + ret = this.seeLogicalAnd(ret, dfaCommon.acquireLattice(lengthVar)); + } + + if (baseCtx !is null && baseCtx.isNullable) + { + // Dereference if its a pointer, + // this really should be the case, but it prevents unnecessary work for static arrays. + ret = seeDereference(se.loc, ret); + } + + DFAVar* indexVar = dfaCommon.findIndexVar(baseCtx); + DFAConsequence* newCctx = ret.addConsequence(indexVar); + ret.setContext(newCctx); + + if (indexVar !is null) + { + if (indexVar.isTruthy) + newCctx.truthiness = expectedTruthiness; + + // If this expression were to succeed, the resulting slice will be non-null. + // Thanks to the read barrier for bounds checking. + if (indexVar.isNullable) + newCctx.nullable = Nullable.NonNull; + } + + return ret; + + case EXP.assert_: + auto ae = expr.isAssertExp; + DFALatticeRef lr = this.walk(ae.e1); + seeAssert(lr, ae.e1.loc); + return DFALatticeRef.init; + + case EXP.halt: + DFALatticeRef lr = dfaCommon.makeLatticeRef; + lr.acquireConstantAsContext(Truthiness.False, Nullable.Unknown); + + seeAssert(lr, expr.loc); + // Evaluates to void + return DFALatticeRef.init; + + case EXP.new_: + auto ne = expr.isNewExp; + + DFALatticeRef ret = this.callFunction(ne.member, ne.thisexp, + ne.argprefix, ne.arguments, ne.loc); + + if (ret.isNull) + ret = dfaCommon.makeLatticeRef; + + DFAConsequence* c = ret.addConsequence(dfaCommon.getInfiniteLifetimeVariable); + ret.setContext(c); + + c.truthiness = Truthiness.True; + c.nullable = Nullable.NonNull; + return ret; + + case EXP.andAnd: + auto be = expr.isBinExp; + + stmtWalker.startScope; + dfaCommon.currentDFAScope.sideEffectFree = true; + DFALatticeRef inProgress; + + // assume rhs could be andAnd + while (be !is null) + { + DFALatticeRef lhs = this.walk(be.e1); + this.seeSilentAssert(lhs.copy); + + if (inProgress.isNull) + inProgress = lhs; + else + inProgress = seeLogicalAnd(inProgress, lhs); + + if (be.e2.op == EXP.andAnd) + { + be = be.e2.isBinExp; + continue; + } + else + { + DFALatticeRef rhs = this.walk(be.e2); + inProgress = seeLogicalAnd(inProgress, rhs); + break; + } + } + + stmtWalker.endScope; + return inProgress; + + case EXP.orOr: + auto be = expr.isBinExp; + DFALatticeRef inProgress, toNegate; + DFAScopeRef inProgressScr; + + while (be !is null) + { + // Make sure any effects converged into the scope by and expressions ext. don't effect rhs + stmtWalker.startScope; + dfaCommon.currentDFAScope.sideEffectFree = true; + + dfaCommon.printStateln("Or expression lhs:"); + DFALatticeRef lhs = this.walk(be.e1); + inProgressScr = stmtWalker.seeLoopyLabelAwareStage(inProgressScr, + stmtWalker.endScope); + + toNegate = this.adaptConditionForBranch(lhs.copy, be.e1.type, false); + + if (inProgress.isNull) + inProgress = lhs; + else + inProgress = seeLogicalOr(inProgress, lhs); + + if (be.e2.op == EXP.orOr) + { + be = be.e2.isBinExp; + continue; + } + else + { + // Make sure any effects converged into the scope by and expressions ext. don't effect rhs or return + stmtWalker.startScope; + dfaCommon.currentDFAScope.sideEffectFree = true; + + this.seeSilentAssert(toNegate, false, true); + + dfaCommon.printStateln("Or expression rhs:"); + DFALatticeRef rhs = this.walk(be.e2); + inProgressScr = stmtWalker.seeLoopyLabelAwareStage(inProgressScr, + stmtWalker.endScope); + + inProgress = seeLogicalOr(inProgress, rhs); + break; + } + } + + return inProgress; + + case EXP.in_: + auto be = expr.isBinExp; + + DFALatticeRef lhs = this.walk(be.e1); + lhs.check; + + DFALatticeRef rhs = this.walk(be.e2); + rhs.check; + + DFAVar* rhsVar = rhs.getContextVar; + + // change comparison to: lhs in rhs[...] + if (rhsVar !is null) + rhs.setContext(dfaCommon.findIndexVar(rhsVar)); + + return this.seeEqual(lhs, rhs, true, be.e1.type, be.e2.type); + + case EXP.lessThan: + case EXP.lessOrEqual: + case EXP.greaterThan: + case EXP.greaterOrEqual: + auto be = expr.isBinExp; + + DFALatticeRef lr = this.walk(be.e1); + lr.walkMaybeTops((DFAConsequence* c) { + if (c.var !is null) + { + c.var.walkRoots((root) { + root.unmodellable = true; + }); + } + return true; + }); + + lr = this.walk(be.e2); + lr.walkMaybeTops((DFAConsequence* c) { + if (c.var !is null) + { + c.var.walkRoots((root) { + root.unmodellable = true; + }); + } + return true; + }); + + DFALatticeRef ret = dfaCommon.makeLatticeRef; + ret.acquireConstantAsContext; + return ret; + + case EXP.addAssign: + case EXP.minAssign: + case EXP.leftShiftAssign: + case EXP.rightShiftAssign: + case EXP.unsignedRightShiftAssign: + case EXP.mulAssign: + case EXP.divAssign: + case EXP.modAssign: + case EXP.andAssign: + case EXP.orAssign: + case EXP.xorAssign: + case EXP.powAssign: + // We don't support the operator itself, but we do support the assignment. + // If we supported value range propergation this would need changing. + auto be = expr.isBinExp; + + dfaCommon.printStateln("assigns lhs"); + DFALatticeRef lhs = this.walk(be.e1); + dfaCommon.printStateln("assigns rhs"); + DFALatticeRef rhs = this.walk(be.e2); + + // Because we can't model it without VRP, we'll give it an unknown value. + if (rhs.isNull) + rhs = dfaCommon.makeLatticeRef; + rhs.acquireConstantAsContext; + return seeAssign(lhs, false, rhs); + + case EXP.concatenateAssign: // ~= + case EXP.concatenateElemAssign: + case EXP.concatenateDcharAssign: + // Whatever lhs started out as, it'll be non-null once we're done with it. + auto be = expr.isBinExp; + + dfaCommon.printStateln("concat assign lhs"); + DFALatticeRef lhs = this.walk(be.e1); + dfaCommon.printStateln("concat assign rhs"); + DFALatticeRef rhs = this.walk(be.e2); + + DFAVar* lhsCtx; + DFAConsequence* lhsCctx = lhs.getContext(lhsCtx), rhsCctx = rhs.getContext; + if (lhsCctx is null) + { + // We can't analyse this. + return DFALatticeRef.init; + } + + const nullableResult = concatNullableResult(be.e1.type, be.e2.type); + dfaCommon.printState((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.printf("concat nullable result %d\n", + nullableResult)); + + DFALatticeRef ret = this.seeAssign(lhs, false, rhs, false, + nullableResult == 1 || nullableResult == 2 ? 3 : 0); + + if (ret.isNull) + { + ret = dfaCommon.makeLatticeRef; + ret.acquireConstantAsContext; + } + return ret; + + case EXP.loweredAssignExp: + // Used for changing the length of lhs. + // While we can just walk the lowering and it'll "work", + // it won't be good enough. + auto be = expr.isLoweredAssignExp; + + dfaCommon.printStateln("length assign lhs"); + DFALatticeRef lhs; + + // See: slice.length = ... + if (auto ale = be.e1.isArrayLengthExp) + lhs = this.walk(ale.e1); + else + lhs = this.walk(be.e1); + + dfaCommon.printStateln("length assign rhs"); + DFALatticeRef rhs = this.walk(be.e2); + + DFAConsequence* lhsCctx = lhs.getContext, rhsCctx = rhs.getContext; + + if (lhsCctx is null) + { + // Welp we can't analyse this. + return DFALatticeRef.init; + } + + // We use the rhs truthiness to model the new length + // If it is false, the new length is zero, and therefore null. + // If it is true, the new length is greater than zero, and therefore non-null. + int alteredState; + + if (rhsCctx is null || rhsCctx.truthiness == Truthiness.Unknown + || rhsCctx.truthiness == Truthiness.Maybe) + { + alteredState = 5; + } + else + { + if (rhsCctx.truthiness == Truthiness.True) + alteredState = 3; + else + alteredState = 4; + } + + DFALatticeRef ret = this.seeAssign(lhs, false, rhs, false, alteredState); + + if (ret.isNull) + { + ret = dfaCommon.makeLatticeRef; + ret.acquireConstantAsContext; + } + else + this.seeConvergeExpression(ret.copy, true); + + return ret; + + case EXP.leftShift: + case EXP.rightShift: + case EXP.unsignedRightShift: + case EXP.add: + case EXP.min: + case EXP.mul: + case EXP.div: + case EXP.mod: + case EXP.and: + case EXP.or: + case EXP.xor: + // We don't support the operator itself, but we do support the walk. + // If we supported value range propergation this would need changing. + auto be = expr.isBinExp; + + DFALatticeRef lhs = this.walk(be.e1); + lhs.check; + + DFALatticeRef rhs = this.walk(be.e2); + rhs.check; + + DFAVar* lhsVar = lhs.getContextVar; + + DFALatticeRef ret = seeLogicalAnd(lhs, rhs); + ret.check; + + if (ret.isNull) + ret = dfaCommon.makeLatticeRef; + + DFAConsequence* c = ret.addConsequence(lhsVar); + ret.setContext(c); + c.truthiness = Truthiness.Unknown; + + ret.check; + return ret; + + case EXP.plusPlus: + case EXP.prePlusPlus: + case EXP.minusMinus: + case EXP.preMinusMinus: + auto be = expr.isBinExp; + + DFALatticeRef lhs = this.walk(be.e1); + lhs.check; + + // be.e2 is actually the value 1, but we can ignore that + DFALatticeRef rhs = dfaCommon.makeLatticeRef; + rhs.acquireConstantAsContext; + + DFAVar* lhsVar = lhs.getContextVar; + DFALatticeRef ret = seeAssign(lhs, false, rhs); + + if (lhsVar !is null) + { + DFALatticeRef effect = dfaCommon.makeLatticeRef; + effect.acquireConstantAsContext; + + lhsVar.walkRoots((root) { effect.addConsequence(root); }); + + this.seeConvergeExpression(effect, true); + } + + return ret; + + case EXP.tilde: + auto ue = expr.isUnaExp; + + DFALatticeRef ret = this.walk(ue.e1); + if (ret.isNull) + { + ret = dfaCommon.makeLatticeRef; + ret.acquireConstantAsContext; + } + return ret; + + case EXP.comma: + auto ce = expr.isCommaExp; + dfaCommon.printStateln("comma lhs"); + DFALatticeRef lhs = this.walk(ce.e1); + dfaCommon.printStateln("comma rhs"); + DFALatticeRef rhs = this.walk(ce.e2); + + DFAVar* rhsVar = rhs.getContextVar; + DFALatticeRef ret = this.seeLogicalAnd(lhs, rhs); + + if (rhsVar !is null) + ret.setContext(rhsVar); + return ret; + + case EXP.structLiteral: + auto sle = expr.isStructLiteralExp; + + if (sle.elements !is null) + { + foreach (ele; *sle.elements) + { + if (ele is null) + continue; + + if (auto ae = ele.isAddrExp) + { + if (auto sle2 = ae.e1.isStructLiteralExp) + { + if (sle.origin is sle2.origin) + continue; + } + } + + DFALatticeRef temp = this.walk(ele); + this.seeConvergeFunctionCallArgument(temp, null, 0, null, sle.loc); + } + } + + DFALatticeRef ret = dfaCommon.makeLatticeRef; + ret.acquireConstantAsContext; + return ret; + + case EXP.tuple: + auto te = expr.isTupleExp; + + DFAVar* expectedContext; + DFALatticeRef inProgress; + + if (te.e0 !is null) + { + inProgress = this.walk(te.e0); + expectedContext = inProgress.getContextVar; + } + + if (inProgress.isNull) + inProgress = dfaCommon.makeLatticeRef; + + if (te.exps !is null) + { + foreach (exp; *te.exps) + { + inProgress = this.seeLogicalAnd(inProgress, this.walk(exp)); + } + } + + if (inProgress.isNull) + inProgress = dfaCommon.makeLatticeRef; + + DFAConsequence* c = inProgress.addConsequence(expectedContext); + inProgress.setContext(c); + + if (expectedContext is null) + { + c.nullable = Nullable.Unknown; + c.truthiness = Truthiness.Unknown; + } + return inProgress; + + case EXP.question: + auto qe = expr.isCondExp; + + auto origScope = dfaCommon.currentDFAScope; + dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("Question expression %p:%p ", dfaCommon.currentDFAScope, origScope); + appendLoc(ob, qe.loc); + ob.writestring("\n"); + }); + + bool ignoreTrueBranch, ignoreFalseBranch; + bool unknownBranchTaken; + int predicateNegation; + DFALatticeRef conditionLR; + DFAVar* conditionVar; + + { + stmtWalker.startScope; + dfaCommon.currentDFAScope.sideEffectFree = true; + + dfaCommon.printStateln("Question condition:"); + conditionLR = this.walkCondition(qe.econd, predicateNegation); + conditionVar = conditionLR.getGateConsequenceVariable; + + stmtWalker.endScope; + } + + { + dfaCommon.printStateln("Question true branch:"); + stmtWalker.startScope; + dfaCommon.currentDFAScope.inConditional = true; + + DFAConsequence* c = conditionLR.getContext; + if (c !is null) + { + if (c.truthiness == Truthiness.False) + ignoreTrueBranch = true; + else if (c.truthiness == Truthiness.True) + ignoreFalseBranch = true; + else + unknownBranchTaken = true; + } + else + unknownBranchTaken = true; + + DFALatticeRef trueCondition = this.adaptConditionForBranch(conditionLR.copy, + qe.econd.type, true); + this.seeSilentAssert(trueCondition, true, true); + stmtWalker.applyGateOnBranch(conditionVar, predicateNegation, true); + } + + DFAScopeRef scrTrue, scrFalse; + DFALatticeRef lrTrue, lrFalse; + + if (!ignoreTrueBranch) + { + lrTrue = this.walk(qe.e1); + assert(dfaCommon.currentDFAScope !is origScope); + } + + scrTrue = stmtWalker.endScope; + scrTrue.check; + + assert(dfaCommon.currentDFAScope is origScope); + + { + dfaCommon.printStateln("Question false branch:"); + stmtWalker.startScope; + dfaCommon.currentDFAScope.inConditional = true; + + if (!ignoreTrueBranch) + { + DFALatticeRef falseCondition = this.adaptConditionForBranch(conditionLR.copy, + qe.econd.type, false); + this.seeSilentAssert(falseCondition, true, true); + } + + stmtWalker.applyGateOnBranch(conditionVar, predicateNegation, false); + + if (!ignoreFalseBranch) + lrFalse = this.walk(qe.e2); + + scrFalse = stmtWalker.endScope; + scrFalse.check; + } + + return this.seeConditional(conditionLR, scrTrue, lrTrue, scrFalse, + lrFalse, unknownBranchTaken, predicateNegation); + + case EXP.delegate_: + case EXP.function_: + // known no-op + return DFALatticeRef.init; + + case EXP.concatenate: + auto ce = expr.isCatExp; + + dfaCommon.printStateln("concatenate lhs"); + DFALatticeRef lhs = this.walk(ce.e1); + dfaCommon.printStateln("concatenate rlhs"); + DFALatticeRef rhs = this.walk(ce.e2); + + DFAConsequence* lhsCctx = lhs.getContext, rhsCctx = rhs.getContext; + const nullableResult = concatNullableResult(ce.e1.type, ce.e2.type); + Truthiness expectedTruthiness; + Nullable expectedNullable; + + if (nullableResult == 2) + { + expectedTruthiness = Truthiness.True; + expectedNullable = Nullable.NonNull; + } + else if (nullableResult == 1) + { + if (lhsCctx !is null) + expectedNullable = lhsCctx.nullable; + if (rhsCctx !is null && expectedNullable < rhsCctx.nullable) + expectedNullable = rhsCctx.nullable; + + if (expectedNullable == Nullable.NonNull) + expectedTruthiness = Truthiness.True; + } + + DFALatticeRef ret = this.seeLogicalAnd(lhs, rhs); + if (ret.isNull) + ret = dfaCommon.makeLatticeRef; + + ret.acquireConstantAsContext(expectedTruthiness, expectedNullable); + return ret; + + case EXP.vector: + case EXP.vectorArray: + case EXP.delegatePointer: + case EXP.delegateFunctionPointer: + auto ue = expr.isUnaExp; + return this.walk(ue.e1); + + case EXP.throw_: + auto te = expr.isThrowExp; + dfaCommon.currentDFAScope.haveJumped = true; + dfaCommon.currentDFAScope.haveReturned = true; + return this.walk(te.e1); + + case EXP.type: + // holds a type, known no-op + return DFALatticeRef.init; + + case EXP.reserved: + + // Other + case EXP.is_: //is() + case EXP.array: + case EXP.delete_: + case EXP.dotIdentifier: + case EXP.dotTemplateInstance: + case EXP.dotType: + case EXP.dollar: + case EXP.template_: + case EXP.dotTemplateDeclaration: + case EXP.dSymbol: + case EXP.uadd: + case EXP.remove: + case EXP.newAnonymousClass: + case EXP.classReference: + case EXP.thrownException: + + // Operators + + case EXP.dot: + + // Leaf operators + case EXP.identifier: + case EXP.interpolated: + case EXP.super_: + case EXP.error: + + case EXP.import_: + case EXP.mixin_: + case EXP.break_: + case EXP.continue_: + case EXP.goto_: + case EXP.scope_: + + case EXP.traits: + case EXP.overloadSet: + case EXP.line: + case EXP.file: + case EXP.fileFullPath: + case EXP.moduleString: // __MODULE__ + case EXP.functionString: // __FUNCTION__ + case EXP.prettyFunction: // __PRETTY_FUNCTION__ + case EXP.pow: + + case EXP.voidExpression: + case EXP.cantExpression: + case EXP.showCtfeContext: + case EXP.objcClassReference: + case EXP.compoundLiteral: // ( type-name ) { initializer-list } + case EXP._Generic: + case EXP.interval: + + case EXP.rvalue: + if (dfaCommon.debugUnknownAST) + { + fprintf(stderr, "Unknown DFA walk expression %d at %s\n", + expr.op, expr.loc.toChars); + assert(0); + } + else + return DFALatticeRef.init; + } + } + + /// Walks an expression that is used for a condition i.e. and if statement. + /// Tells you if the expression for the gate variable, will be exact, vs negated state. + /// Returns: 0 for unknown negation, 1 or has been negated from gate variable or 2 if it hasn't been. + DFALatticeRef walkCondition(Expression expr, out int predicateNegation) + { + bool allGateConditional = true; + bool outComeNegated; + + scope (exit) + { + if (!allGateConditional) + predicateNegation = 0; + else + predicateNegation = outComeNegated ? 1 : 2; + } + + DFALatticeRef seeExp(Expression expr, ref bool negated) + { + switch (expr.op) + { + case EXP.not: // !x + { + negated = !negated; // !!x + auto ue = expr.isUnaExp; + + if (auto ie = ue.e1.isInExp) + { + DFALatticeRef lhs = this.walk(ie.e1); + lhs.check; + + DFALatticeRef rhs = this.walk(ie.e2); + rhs.check; + + DFAVar* rhsVar = rhs.getContextVar; + + // change comparison to: lhs in rhs[...] + if (rhsVar !is null) + rhs.setContext(dfaCommon.findIndexVar(rhsVar)); + + allGateConditional = false; + return this.seeEqual(lhs, rhs, false, ie.e1.type, ie.e2.type); + } + else + return seeNegate(seeExp(ue.e1, negated)); + } + + case EXP.notEqual: // != + { + negated = !negated; + auto be = expr.isBinExp; + + bool negated2; + + dfaCommon.printStateln("!equal lhs"); + DFALatticeRef lhs = seeExp(be.e1, negated2); + dfaCommon.printStateln("!equal rhs"); + DFALatticeRef rhs = seeExp(be.e2, negated2); + + return seeEqual(lhs, rhs, false, be.e1.type, be.e2.type); + } + + case EXP.notIdentity: // !is + { + negated = !negated; + auto be = expr.isBinExp; + + bool negated2; + + dfaCommon.printStateln("!is lhs"); + DFALatticeRef lhs = seeExp(be.e1, negated2); + dfaCommon.printStateln("!is rhs"); + DFALatticeRef rhs = seeExp(be.e2, negated2); + + return seeEqual(lhs, rhs, false, be.e1.type, be.e2.type); + } + + case EXP.equal: // == + { + auto be = expr.isBinExp; + bool negated2; + + dfaCommon.printStateln("equal lhs"); + DFALatticeRef lhs = seeExp(be.e1, negated2); + dfaCommon.printStateln("equal rhs"); + DFALatticeRef rhs = seeExp(be.e2, negated2); + + return seeEqual(lhs, rhs, true, be.e1.type, be.e2.type); + } + + case EXP.identity: // is + { + auto be = expr.isBinExp; + bool negated2; + + dfaCommon.printStateln("is lhs"); + DFALatticeRef lhs = seeExp(be.e1, negated2); + dfaCommon.printStateln("is rhs"); + DFALatticeRef rhs = seeExp(be.e2, negated2); + + return seeEqual(lhs, rhs, true, be.e1.type, be.e2.type); + } + + case EXP.string_: + { + // A string literal even when empty will be non-null and true. + DFALatticeRef ret = dfaCommon.makeLatticeRef; + //ret.acquireConstantAsContext(Truthiness.True, Nullable.NonNull); + ret.acquireConstantAsContext; + return ret; + } + + case EXP.typeid_: + { + auto te = expr.isTypeidExp; + DFALatticeRef ret; + + void seeTypeIdObject(RootObject ro) + { + if (auto e = isExpression(te.obj)) + { + // [!val] does not effect the literal, gate capabilitiy + DFALatticeRef temp = this.walk(e); + + if (!ret.isNull) + ret = this.seeLogicalAnd(ret, temp); + else + ret = temp; + } + else if (auto v = isTuple(te.obj)) + { + foreach (obj; v.objects) + { + seeTypeIdObject(obj); + } + } + } + + seeTypeIdObject(te.obj); + + if (ret.isNull) + ret = dfaCommon.makeLatticeRef; + + ret.acquireConstantAsContext(Truthiness.True, Nullable.NonNull); + return ret; + } + + case EXP.arrayLiteral: + { + auto ale = expr.isArrayLiteralExp; + DFALatticeRef ret = dfaCommon.makeLatticeRef; + + if (ale.elements !is null && ale.elements.length > 0) + { + foreach (ele; *ale.elements) + { + this.seeConvergeFunctionCallArgument(this.walk(ele), + null, 0, null, ele.loc); + } + + DFAConsequence* cctx = ret.addConsequence( + dfaCommon.getInfiniteLifetimeVariable); + ret.setContext(cctx); + cctx.truthiness = Truthiness.True; + cctx.nullable = Nullable.NonNull; + } + else + ret.acquireConstantAsContext(Truthiness.False, Nullable.Null); + + return ret; + } + + case EXP.assocArrayLiteral: + { + auto aale = expr.isAssocArrayLiteralExp; + DFALatticeRef ret = dfaCommon.makeLatticeRef; + + if (aale.keys !is null && aale.keys.length > 0) + { + DFAConsequence* cctx = ret.addConsequence( + dfaCommon.getInfiniteLifetimeVariable); + ret.setContext(cctx); + cctx.truthiness = Truthiness.True; + cctx.nullable = Nullable.NonNull; + } + else + ret.acquireConstantAsContext(Truthiness.False, Nullable.Null); + + return ret; + } + + case EXP.arrayLength: + { + // This is supposed to be a read only, + // Lowered assign expression will handle the write version. + + auto ue = expr.isUnaExp; + + DFALatticeRef ret = seeExp(ue.e1, negated); + DFAConsequence* cctx = ret.getContext; + + if (ret.isNull) + { + ret = dfaCommon.makeLatticeRef; + ret.acquireConstantAsContext; + } + else if (cctx is null || cctx.var is null) + ret.acquireConstantAsContext; + else + { + DFAVar* ctx = dfaCommon.findSliceLengthVar(cctx.var); + + DFAConsequence* newCctx = ret.addConsequence(ctx); + newCctx.truthiness = cctx.truthiness; + + ret.setContext(newCctx); + } + + return ret; + } + + case EXP.null_: + { + DFALatticeRef ret = dfaCommon.makeLatticeRef; + + DFAConsequence* c = ret.addConsequence(null); + ret.setContext(c); + + c.truthiness = Truthiness.False; + c.nullable = Nullable.Null; + return ret; + } + + case EXP.int64: + { + auto ie = expr.isIntegerExp; + + auto b = ie.toBool; + if (!b.isPresent) + return DFALatticeRef.init; + + DFALatticeRef ret = dfaCommon.makeLatticeRef; + DFAConsequence* c = ret.addConsequence(null); + ret.setContext(c); + + c.truthiness = b.get ? Truthiness.True : Truthiness.False; + return ret; + } + + case EXP.cast_: + { + auto ce = expr.isCastExp; + + dfaCommon.printState((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.printf("cast to %d\n", + ce.to !is null ? ce.to.ty : -1)); + + DFALatticeRef ret = this.walk(ce.e1); + ret.check; + + if (ce.to is null || ce.to.isTypeClass) + { + // ideally we'd model up casts, and only disallow down casts + ret = dfaCommon.makeLatticeRef; + ret.acquireConstantAsContext(Truthiness.Unknown, Nullable.Unknown); + } + else + { + if (ret.isNull) + ret = dfaCommon.makeLatticeRef; + + DFAConsequence* cctx = ret.getContext; + if (cctx is null) + cctx = ret.acquireConstantAsContext; + + if (cctx.var !is null && cctx.var.isNullable && !isTypeNullable(ce.to)) + { + // This prevents pointer integer checks from infecting pointers + + cctx = ret.acquireConstantAsContext(cctx.truthiness, cctx.nullable); + } + } + + return ret; + } + + case EXP.variable: + { + auto ve = expr.isVarExp; + assert(ve !is null); + + DFALatticeRef ret; + + if (ve.var !is null) + { + if (auto vd = ve.var.isVarDeclaration) + { + DFAVar* var = dfaCommon.findVariable(vd); + + if (var !is null) + { + ret = dfaCommon.acquireLattice(var); + ret.check; + return ret; + } + } + } + + // no other declarations really apply for the DFA + ret = dfaCommon.makeLatticeRef; + ret.setContext(dfaCommon.getUnknownVar); + return ret; + } + + default: + allGateConditional = false; + return this.walk(expr); + } + } + + // In theory a gate condition can support more expressions, but to be on the safe side, let's call this good. + switch (expr.op) + { + case EXP.not: // !x + case EXP.variable: + case EXP.cast_: + case EXP.null_: + case EXP.int64: + case EXP.arrayLength: + case EXP.string_: + case EXP.typeid_: + case EXP.arrayLiteral: + case EXP.assocArrayLiteral: + case EXP.equal: // == + case EXP.identity: // is + case EXP.notEqual: // != + case EXP.notIdentity: // !is + return seeExp(expr, outComeNegated); + + default: + return this.walk(expr); + } + } + + DFALatticeRef callFunction(FuncDeclaration toCallFunction, Expression thisPointer, + Expression argPrefix, Expressions* arguments, ref Loc loc) + { + TypeFunction toCallFunctionType = toCallFunction !is null ? toCallFunction + .type.isFunction_Delegate_PtrToFunction : null; + + if (thisPointer !is null) + { + // Extract from the this pointer expression the function to call. + + if (auto dve = thisPointer.isDotVarExp) + { + if (auto fd = dve.var.isFuncDeclaration) + { + // e1.method() + thisPointer = dve.e1; + toCallFunction = fd; + toCallFunctionType = toCallFunction.type.isFunction_Delegate_PtrToFunction; + } + } + else if (auto ve = thisPointer.isVarExp) + { + // method() + thisPointer = null; + toCallFunctionType = ve.var.type.isFunction_Delegate_PtrToFunction; + } + } + + if (toCallFunction !is null && toCallFunction.ident !is null) + { + dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("Calling function `%s` at ", toCallFunction.ident.toChars); + appendLoc(ob, loc); + ob.writestring(" from "); + appendLoc(ob, toCallFunction.loc); + ob.writestring("\n"); + }); + } + else if (loc.isValid) + { + dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.writestring("Calling function at "); + appendLoc(ob, loc); + + if (toCallFunction !is null) + { + ob.writestring(" from "); + appendLoc(ob, toCallFunction.loc); + } + + ob.writestring("\n"); + }); + } + else + dfaCommon.printStateln("Calling function"); + + const functionIsNoReturn = (toCallFunction !is null && toCallFunction.noreturn) || (toCallFunctionType !is null + && toCallFunctionType.next !is null + && toCallFunctionType.next.isTypeNoreturn !is null); + + { + ParametersDFAInfo* calledFunctionInfo; + ParameterDFAInfo* thisPointerInfo; + ParameterDFAInfo* returnInfo; + + if (toCallFunction !is null && toCallFunction.parametersDFAInfo) + { + calledFunctionInfo = toCallFunction.parametersDFAInfo; + thisPointerInfo = &calledFunctionInfo.thisPointer; + returnInfo = &calledFunctionInfo.returnValue; + } + + stmtWalker.startScope; + dfaCommon.currentDFAScope.sideEffectFree = true; + + if (thisPointer !is null) + { + dfaCommon.printStateln("This:"); + DFALatticeRef thisExp = this.walk(thisPointer); + thisExp = this.seeDereference(thisPointer.loc, thisExp); + + this.seeConvergeFunctionCallArgument(thisExp, thisPointerInfo, + 0, toCallFunction, thisPointer.loc); + } + + if (argPrefix !is null) + { + dfaCommon.printStateln("Argument prefix:"); + DFALatticeRef argPrefixLR = this.walk(argPrefix); + this.seeConvergeFunctionCallArgument(argPrefixLR, null, 0, + toCallFunction, argPrefix.loc); + } + + if (arguments !is null && arguments.length > 0) + { + Parameter[] allParameters; + VarDeclaration[] allParameterVars; + ParameterDFAInfo[] allInfos = calledFunctionInfo !is null ? calledFunctionInfo.parameters + : null; + + if (toCallFunctionType !is null) + { + TypeFunction functionType = toCallFunctionType.toTypeFunction; + + if (functionType.parameterList.parameters !is null + && functionType.parameterList.parameters.length != 0) + { + allParameters = (*functionType.parameterList.parameters)[]; + } + } + + if (toCallFunction !is null) + { + if (toCallFunction.parameters !is null && toCallFunction.parameters.length != 0) + { + allParameterVars = (*toCallFunction.parameters)[]; + } + } + + dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.writestring("Calling function parameter info\n"); + + prefix(" "); + ob.printf("count=%zd, calledFunctionInfo=%p:%zd\n", arguments.length, calledFunctionInfo, + calledFunctionInfo !is null ? calledFunctionInfo.parameters.length : 0); + + prefix(" "); + ob.printf("allParameters=%zd, allParameterVars=%zd\n", + allParameters.length, allParameterVars.length); + }); + + foreach (i, arg; *arguments) + { + Parameter* param = i < allParameters.length ? &allParameters.ptr[i] : null; + VarDeclaration paramVar = i < allParameterVars.length + ? allParameterVars.ptr[i] : null; + const storageClass = (param !is null ? param.storageClass : 0) | (paramVar !is null + ? paramVar.storage_class : 0); + ParameterDFAInfo* info = i < allInfos.length ? &allInfos.ptr[i] : null; + + dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("Argument %zd, stc=%lld", i, storageClass); + ob.writestring("\n"); + + if (info !is null) + { + ob.printf(" info %d:%d", info.notNullIn, info.notNullOut); + ob.writestring("\n"); + } + }); + + DFALatticeRef argExp = this.walk(arg); + this.seeConvergeFunctionCallArgument(argExp, info, + storageClass, toCallFunction, loc); + + if (dfaCommon.currentDFAScope.haveJumped) + break; + } + } + + stmtWalker.endScope; + + { + DFALatticeRef ret = dfaCommon.makeLatticeRef; + + if (returnInfo !is null && returnInfo.notNullOut == Fact.Guaranteed) + ret.acquireConstantAsContext(Truthiness.True, Nullable.NonNull); + else + ret.acquireConstantAsContext; + + // If the function is no return, or it hasn't been semantically analysed yet, + // we'll assume it can't return. + // Otherwise we get false positives. + if (functionIsNoReturn) + { + dfaCommon.currentDFAScope.haveJumped = true; + dfaCommon.currentDFAScope.haveReturned = true; + } + + return ret; + } + } + } +} diff --git a/dmd/dfa/fast/report.d b/dmd/dfa/fast/report.d new file mode 100644 index 0000000000..147710f08d --- /dev/null +++ b/dmd/dfa/fast/report.d @@ -0,0 +1,219 @@ +/** + * Reporting mechanism for the fast Data Flow Analysis engine. + * + * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) + * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) + * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dfa/fast/report.d, dfa/fast/report.d) + * Documentation: https://dlang.org/phobos/dmd_dfa_fast_report.html + * Coverage: https://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/dfa/fast/report.d + */ +module dmd.dfa.fast.report; +import dmd.dfa.fast.structure; +import dmd.location; +import dmd.func; +import dmd.errorsink; +import dmd.declaration; +import core.stdc.stdio; + +alias Fact = ParameterDFAInfo.Fact; + +struct DFAReporter +{ + DFACommon* dfaCommon; + ErrorSink errorSink; + + void onDereference(DFAConsequence* on, ref Loc loc) + { + if (!dfaCommon.debugUnknownAST && on is null) + return; + assert(on !is null); + if (on.var is null) + return; + + int fail; + assert(on.nullable != Nullable.NonNull); + + if (on.var is null || on.var.var is null) + fail = __LINE__; + else if (!on.var.isModellable) + fail = __LINE__; + else + { + if (on.var.declaredAtDepth >= dfaCommon.lastLoopyLabel.depth) + errorSink.error(loc, "Dereference on null variable `%s`", + on.var.var.ident.toChars); + else + fail = __LINE__; + } + } + + void onLoopyLabelLessNullThan(DFAVar* var, ref const(Loc) loc) + { + if (var !is null && !var.isModellable) + return; + + errorSink.error(loc, "Variable `%s` was required to be non-null and has become null", + var.var.ident.toChars); + } + + void onEndOfScope(FuncDeclaration fd, ref Loc loc) + { + // this is where we validate escapes, for a specific location + + if (!dfaCommon.currentDFAScope.haveReturned) + return; + + // validate/infer on to function + foreachFunctionVariable(dfaCommon, fd, (scv) { + ParameterDFAInfo* param = scv.var.param; + + if (scv.var.unmodellable || param is null) + return; + + DFAConsequence* cctx = scv.lr.getContext; + + assert(cctx !is null); + assert(cctx.var is scv.var); + + Fact suggestedNotNullOut = param.notNullOut; + + if (suggestedNotNullOut == Fact.Guaranteed && cctx.nullable != Nullable.NonNull) + suggestedNotNullOut = Fact.NotGuaranteed; + else if (suggestedNotNullOut == Fact.Unspecified && cctx.nullable == Nullable.NonNull) + suggestedNotNullOut = Fact.Guaranteed; + + assert(!param.specifiedByUser); + param.notNullOut = suggestedNotNullOut; + }); + } + + void onEndOfFunction(FuncDeclaration fd, ref Loc loc) + { + version (none) + { + printf("End of function attributes for `%s` at %s\n", fd.ident.toChars, loc.toChars); + } + + // validate/infer on to function + foreachFunctionVariable(dfaCommon, fd, (scv) { + ParameterDFAInfo* param = scv.var.param; + if (param is null) + return; + + version (none) + { + if (scv.var.var !is null) + printf("Variable %p `%s` ", scv.var, scv.var.var.ident.toChars); + else + printf("Variable %p ", scv.var); + + printf("%d %d:%d %d:%d %d\n", scv.var.unmodellable, scv.var.isTruthy, + scv.var.isNullable, scv.var.isByRef, scv.var.writeCount, + param.specifiedByUser); + printf(" notNullIn=%d, notNullOut=%d\n", param.notNullIn, param.notNullOut); + } + + if (scv.var.unmodellable) + { + if (!param.specifiedByUser) + { + param.specifiedByUser = false; + + if (scv.var.isNullable) + { + param.notNullIn = Fact.Unspecified; + param.notNullOut = Fact.Unspecified; + } + } + } + else if (!param.specifiedByUser) + { + if (scv.var.isNullable) + { + if (param.notNullIn == Fact.Unspecified) + param.notNullIn = Fact.NotGuaranteed; + + if (scv.var.isByRef) + { + if (scv.var.writeCount > 0) + { + if (param.notNullOut == Fact.Unspecified) + param.notNullOut = Fact.NotGuaranteed; + } + else + param.notNullOut = param.notNullIn; + } + else + { + param.notNullOut = Fact.Unspecified; + } + } + } + + version (none) + { + printf(" notNullIn=%d, notNullOut=%d\n", + cast(int) param.notNullIn, param.notNullOut); + } + }); + } + + void onAssertIsFalse(ref DFALatticeRef lr, ref Loc loc) + { + DFAConsequence* cctx; + if (!(lr.isModellable && (lr.haveNonContext || (cctx = lr.getContext).var !is null))) + return; // ignore literals, too false positive heavy + + errorSink.error(loc, "Assert can be proven to be false"); + } + + void onFunctionCallArgumentLessThan(DFAConsequence* c, + ParameterDFAInfo* paramInfo, FuncDeclaration calling, ref Loc loc) + { + if (c.var !is null && !c.var.isModellable) + return; + + errorSink.error(loc, "Argument is expected to be non-null but was null"); + + if (paramInfo.parameterId >= 0) + { + VarDeclaration param = (*calling.parameters)[paramInfo.parameterId]; + int argId = paramInfo.parameterId + calling.needThis; + errorSink.errorSupplemental(param.loc, + "For parameter `%s` in argument %d", param.ident.toChars, argId); + } + else + errorSink.errorSupplemental(calling.loc, "For parameter `this` in called function"); + } +} + +private: + +void foreachFunctionVariable(DFACommon* dfaCommon, FuncDeclaration fd, + scope void delegate(DFAScopeVar* scv) del) +{ + DFAVar* var; + DFAScopeVar* scv; + + if (fd.vthis !is null) + { + var = dfaCommon.findVariable(fd.vthis); + scv = dfaCommon.acquireScopeVar(var); + del(scv); + } + + var = dfaCommon.getReturnVariable(); + scv = dfaCommon.acquireScopeVar(var); + del(scv); + + if (fd.parameters !is null) + { + foreach (i, param; *fd.parameters) + { + var = dfaCommon.findVariable(param); + scv = dfaCommon.acquireScopeVar(var); + del(scv); + } + } +} diff --git a/dmd/dfa/fast/statement.d b/dmd/dfa/fast/statement.d new file mode 100644 index 0000000000..6144aa7329 --- /dev/null +++ b/dmd/dfa/fast/statement.d @@ -0,0 +1,1336 @@ +/** + * Statement walker for the fast Data Flow Analysis engine. + * + * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) + * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) + * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dfa/fast/statement.d, dfa/fast/statement.d) + * Documentation: https://dlang.org/phobos/dmd_dfa_fast_statement.html + * Coverage: https://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/dfa/fast/statement.d + */ +module dmd.dfa.fast.statement; +import dmd.dfa.fast.analysis; +import dmd.dfa.fast.report; +import dmd.dfa.fast.expression; +import dmd.dfa.fast.structure; +import dmd.dfa.utils; +import dmd.common.outbuffer; +import dmd.visitor; +import dmd.visitor.foreachvar; +import dmd.location; +import dmd.func; +import dmd.identifier; +import dmd.statement; +import dmd.expression; +import dmd.timetrace; +import dmd.astenums; +import dmd.mtype; +import dmd.declaration; +import core.stdc.stdio; + +extern (D) class StatementWalker : SemanticTimeTransitiveVisitor +{ + alias visit = SemanticTimeTransitiveVisitor.visit; + + DFACommon* dfaCommon; + ExpressionWalker* expWalker; + DFAAnalyzer* analyzer; + int inLoopyLabel; + +final: + + void startScope() + { + DFAScopeRef scr; + scr.sc = dfaCommon.currentDFAScope; + scr.check; + scr.sc = null; + + dfaCommon.pushScope; + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) => ob.printf("Start scope %p:%p\n", + dfaCommon.currentDFAScope, dfaCommon.currentDFAScope.parent)); + dfaCommon.sdepth++; + } + + DFAScopeRef endScope() + { + Loc loc; + return this.endScope(loc); + } + + DFAScopeRef endScope(ref Loc endLoc) + { + DFAScopeRef ret = dfaCommon.popScope; + dfaCommon.sdepth--; + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("End scope %p:%p", ret.sc, dfaCommon.currentDFAScope); + if (endLoc.isValid) + appendLoc(ob, endLoc); + ob.writestring("\n"); + }); + + ret.printStructure("*=", dfaCommon.sdepth, dfaCommon.currentFunction); + ret.check; + + dfaCommon.currentDFAScope.printStructure("parent", dfaCommon.sdepth, + dfaCommon.currentFunction); + dfaCommon.currentDFAScope.check; + return ret; + } + + DFAScopeRef endScopeAndReport(ref Loc endLoc, bool endFunction = false) + { + analyzer.reporter.onEndOfScope(dfaCommon.currentFunction, endLoc); + if (endFunction) + analyzer.reporter.onEndOfFunction(dfaCommon.currentFunction, endLoc); + + DFAScopeRef ret = dfaCommon.popScope; + dfaCommon.sdepth--; + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("End scope %p:%p", ret.sc, dfaCommon.currentDFAScope); + if (endLoc.isValid) + appendLoc(ob, endLoc); + ob.writestring("\n"); + }); + + ret.printStructure("*=", dfaCommon.sdepth, dfaCommon.currentFunction); + ret.check; + + if (dfaCommon.currentDFAScope !is null) + { + dfaCommon.currentDFAScope.printStructure("parent", + dfaCommon.sdepth, dfaCommon.currentFunction); + dfaCommon.currentDFAScope.check; + } + return ret; + } + + void seeConvergeStatement(DFAScopeRef scr, bool ignoreWriteCount = false, + bool unknownAware = false) + { + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.printf("Converging statement: %d\n", + unknownAware)); + scr.printStructure("input", dfaCommon.sdepth, dfaCommon.currentFunction); + scr.check; + + dfaCommon.check; + dfaCommon.currentDFAScope.printStructure("scope", dfaCommon.sdepth, + dfaCommon.currentFunction); + dfaCommon.check; + + analyzer.convergeStatement(scr, true, false, ignoreWriteCount, unknownAware); + + dfaCommon.currentDFAScope.printStructure("so far", dfaCommon.sdepth, + dfaCommon.currentFunction); + dfaCommon.currentDFAScope.check; + } + + void seeConvergeScope(DFAScopeRef scr) + { + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.printf("Converging scope:\n")); + scr.printStructure("input", dfaCommon.sdepth, dfaCommon.currentFunction); + scr.check; + + dfaCommon.check; + dfaCommon.currentDFAScope.printStructure("scope", dfaCommon.sdepth, + dfaCommon.currentFunction); + dfaCommon.check; + + analyzer.convergeScope(scr); + + dfaCommon.currentDFAScope.printStructure("so far", dfaCommon.sdepth, + dfaCommon.currentFunction); + dfaCommon.currentDFAScope.check; + } + + void seeConvergeStatementIf(DFALatticeRef condition, DFAScopeRef scrTrue, + DFAScopeRef scrFalse, bool haveFalseBody, bool unknownBranchTaken, + int predicateNegation) + { + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) => ob.printf( + "Converging statement if haveFalseBody=%d, unknownBranchTaken=%d, predicateNegation=%d:\n", + haveFalseBody, unknownBranchTaken, predicateNegation)); + condition.printState("condition", dfaCommon.sdepth, dfaCommon.currentFunction); + scrTrue.printStructure("true", dfaCommon.sdepth, dfaCommon.currentFunction); + scrFalse.printStructure("false", dfaCommon.sdepth, dfaCommon.currentFunction); + + dfaCommon.currentDFAScope.printStructure("scope", dfaCommon.sdepth, + dfaCommon.currentFunction); + dfaCommon.currentDFAScope.check; + + dfaCommon.check; + analyzer.convergeStatementIf(condition, scrTrue, scrFalse, + haveFalseBody, unknownBranchTaken, predicateNegation); + dfaCommon.check; + + dfaCommon.currentDFAScope.printStructure("so far", dfaCommon.sdepth, + dfaCommon.currentFunction); + dfaCommon.currentDFAScope.check; + } + + void applyGateOnBranch(DFAVar* gateVar, int predicateNegation, bool branch) + { + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) => ob.printf( + "Applying gate condition effect on branch %d, predicateNegation=%d for %p:\n", + branch, predicateNegation, gateVar)); + + analyzer.applyGateOnBranch(gateVar, predicateNegation, branch); + dfaCommon.currentDFAScope.check; + } + + void seeConvergeStatementLoopyLabels(DFAScopeRef scr) + { + Loc loc; + seeConvergeStatementLoopyLabels(scr, loc); + } + + void seeConvergeStatementLoopyLabels(DFAScopeRef scr, ref Loc loc) + { + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.writestring( + "Converging statement loopy labels:\n")); + scr.printStructure("input", dfaCommon.sdepth, dfaCommon.currentFunction); + scr.check; + + dfaCommon.currentDFAScope.printStructure("scope", dfaCommon.sdepth, + dfaCommon.currentFunction); + dfaCommon.currentDFAScope.check; + + dfaCommon.check; + analyzer.convergeStatementLoopyLabels(scr, loc); + dfaCommon.check; + + dfaCommon.currentDFAScope.printStructure("so far", dfaCommon.sdepth, + dfaCommon.currentFunction); + dfaCommon.currentDFAScope.check; + } + + void seeCheckForCaseBefore(ref DFAScopeRef containing, DFAScopeRef jumpedTo, ref const(Loc) loc) + { + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.writestring( + "Check case before & containing state:\n")); + + containing.printStructure("containing"); + containing.check; + + jumpedTo.printStructure("jumpedTo"); + jumpedTo.check; + + dfaCommon.check; + analyzer.loopyLabelBeforeContainingCheck(containing, jumpedTo, loc); + dfaCommon.check; + } + + void seeConvergeForwardGoto(DFAScopeRef scr) + { + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.writestring("Converging forward goto:\n")); + scr.printStructure("input", dfaCommon.sdepth, dfaCommon.currentFunction); + scr.check; + + dfaCommon.currentDFAScope.printStructure("scope", dfaCommon.sdepth, + dfaCommon.currentFunction); + dfaCommon.currentDFAScope.check; + + dfaCommon.check; + analyzer.convergeStatement(scr, false); + dfaCommon.check; + + dfaCommon.currentDFAScope.printStructure("so far", dfaCommon.sdepth, + dfaCommon.currentFunction); + dfaCommon.currentDFAScope.check; + } + + DFAScopeRef seeLoopyLabelAwareStage(DFAScopeRef previous, DFAScopeRef next) + { + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.writestring("Loop stage:\n")); + previous.printStructure("previous", dfaCommon.sdepth, dfaCommon.currentFunction); + next.printStructure("next", dfaCommon.sdepth, dfaCommon.currentFunction); + + dfaCommon.check; + DFAScopeRef ret = analyzer.transferLoopyLabelAwareStage(previous, next); + dfaCommon.check; + + ret.printStructure("result", dfaCommon.sdepth, dfaCommon.currentFunction); + return ret; + } + + void seeGoto(DFAScope* toSc, bool isAfter) + { + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.printf( + "Going to scope adding state after=%d\n", isAfter)); + + dfaCommon.check; + analyzer.transferGoto(toSc, isAfter); + dfaCommon.check; + } + + void seeForwardsGoto(Identifier ident) + { + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.printf("Going to label %s\n", ident.toChars)); + + dfaCommon.check; + analyzer.transferForwardsGoto(ident); + dfaCommon.check; + } + + void constructVariable(VarDeclaration vd, bool isNonNull) + { + DFAVar* var = dfaCommon.findVariable(vd); + + DFALatticeRef lr = dfaCommon.makeLatticeRef; + DFAConsequence* c = lr.addConsequence(var); + lr.setContext(c); + c.nullable = isNonNull ? Nullable.NonNull : Nullable.Null; + + dfaCommon.check; + expWalker.seeConvergeExpression(expWalker.seeAssign(var, true, lr)); + dfaCommon.check; + } + + void start(FuncDeclaration fd) + { + dfaCommon.currentFunction = fd; + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("Starting DFA walk on %s at ", fd.ident.toChars); + appendLoc(ob, fd.loc); + ob.writestring("\n"); + }); + + timeTraceBeginEvent(TimeTraceEventType.dfa); + scope (exit) + timeTraceEndEvent(TimeTraceEventType.dfa, fd); + + this.startScope; + dfaCommon.setScopeAsLoopyLabel; + + dfaCommon.check; + DFAScopeVar* scv; + + { + if (fd.parametersDFAInfo is null) + fd.parametersDFAInfo = new ParametersDFAInfo; + + if (fd.vthis !is null) + { + DFAVar* var = dfaCommon.findVariable(fd.vthis); + var.declaredAtDepth = dfaCommon.currentDFAScope.depth; + var.param = &fd.parametersDFAInfo.thisPointer; + var.param.parameterId = -1; + scv = dfaCommon.acquireScopeVar(var); + + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.printf("vthis is %p scv %p\n", + var, scv)); + assert(scv.var is var); + + DFAScopeVar* scv2 = dfaCommon.currentDFAScope.findScopeVar(var); + assert(scv is scv2); + + dfaCommon.check; + } + + if (fd.parameters !is null) + { + if (fd.parametersDFAInfo.parameters.length != fd.parameters.length) + fd.parametersDFAInfo.parameters.length = fd.parameters.length; + + foreach (i, param; *fd.parameters) + { + DFAVar* var = dfaCommon.findVariable(param); + var.declaredAtDepth = dfaCommon.currentDFAScope.depth; + var.param = &fd.parametersDFAInfo.parameters[i]; + *var.param = ParameterDFAInfo.init; // Array won't initialize it + var.param.parameterId = cast(int) i; + scv = dfaCommon.acquireScopeVar(var); + + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.printf("param (%zd) is `%s` %p scv %p stc %lld\n", + i, param.ident !is null ? param.ident.toChars : null, + var, scv, param.storage_class)); + assert(scv.var is var); + + DFAScopeVar* scv2 = dfaCommon.currentDFAScope.findScopeVar(var); + assert(scv is scv2); + + var.isByRef = (param.storage_class & STC.ref_) == STC.ref_; + + if ((param.storage_class & STC.out_) == STC.out_) + { + var.isByRef = true; + + // blit is effectively a write + var.writeCount = 1; + } + + dfaCommon.check; + } + } + } + + { + DFAVar* var = dfaCommon.getReturnVariable(); + var.declaredAtDepth = dfaCommon.currentDFAScope.depth; + var.param = &fd.parametersDFAInfo.returnValue; + var.param.parameterId = -2; + + TypeFunction tf = fd.type.isTypeFunction(); + assert(tf !is null); + + var.isNullable = tf.isRef || isTypeNullable(tf.next); + scv = dfaCommon.acquireScopeVar(var); + + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.printf("return is %p scv %p l %p\n", + var, scv, scv.lr.lattice)); + assert(scv.var is var); + + DFAScopeVar* scv2 = dfaCommon.currentDFAScope.findScopeVar(var); + assert(scv is scv2); + + dfaCommon.check; + } + + { + // make any variables that cross the function boundary for nested function unmodelled + + foreach (vd; fd.closureVars) + { + DFAVar* var = dfaCommon.findVariable(vd); + var.unmodellable = true; + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("closureVars %s ", vd.ident.toChars); + appendLoc(ob, vd.loc); + ob.writestring("\n"); + }); + } + + foreach (vd; fd.outerVars) + { + DFAVar* var = dfaCommon.findVariable(vd); + var.unmodellable = true; + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("outerVars %s ", vd.ident.toChars); + appendLoc(ob, vd.loc); + ob.writestring("\n"); + }); + } + } + + this.visit(fd.fbody); + + // implicit return + // endScope call automatically infers/validates scope on to function. + dfaCommon.currentDFAScope.haveJumped = true; + dfaCommon.currentDFAScope.haveReturned = true; + this.endScopeAndReport(fd.endloc, true); + + if (fd.parametersDFAInfo !is null) + { + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("return=%d:%d", fd.parametersDFAInfo.returnValue.notNullIn, + fd.parametersDFAInfo.returnValue.notNullOut); + ob.writestring("\n"); + + ob.printf("this=%d:%d", fd.parametersDFAInfo.thisPointer.notNullIn, + fd.parametersDFAInfo.thisPointer.notNullOut); + ob.writestring("\n"); + + foreach (i, param; fd.parametersDFAInfo.parameters) + { + ob.printf("%zd: %d:%d", i, param.notNullIn, param.notNullOut); + ob.writestring("\n"); + } + }); + } + } + + DFALatticeRef walkExpression(DFAVar* assignTo, DFAVar* constructInto, Expression exp) + { + return expWalker.entry(assignTo, constructInto, exp); + } + + extern (C++) override void visit(Statement st) + { + __gshared immutable(string[]) AllStmtOpNames = [ + __traits(allMembers, STMT) + ]; + + if (st is null) + return; + + dfaCommon.sdepth++; + dfaCommon.check; + + scope (exit) + { + dfaCommon.check; + dfaCommon.sdepth--; + } + + if (dfaCommon.currentDFAScope.haveReturned) + { + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("%3d (%s): ignoring at ", st.stmt, AllStmtOpNames[st.stmt].ptr); + appendLoc(ob, st.loc); + ob.writestring("\n"); + }); + return; + } + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("%3d (%s): at ", st.stmt, AllStmtOpNames[st.stmt].ptr); + appendLoc(ob, st.loc); + ob.writestring("\n"); + }); + + /* + If you need to see the state of the engine, enable this and set the line number here. + Also remember to set the function name in entry, + and to enable dfaCommon.debugStructure to true with dfaCommon.debugIt set to false, + otherwise you will get lost in the output. + */ + version (none) + { + if (st.loc.linnum == 342) + { + DFAScope* sc = dfaCommon.currentDFAScope; + while (sc !is null) + { + sc.printStructure("----"); + sc = sc.parent; + } + + fflush(stdout); + assert(0); + } + } + + final switch (st.stmt) + { + case STMT.DtorExp: + expWalker.seeConvergeExpression(walkExpression(null, + null, st.isDtorExpStatement.exp)); + break; + + case STMT.Exp: + expWalker.seeConvergeExpression(walkExpression(null, + null, st.isExpStatement.exp)); + break; + case STMT.Return: + Expression exp = st.isReturnStatement.exp; + if (exp !is null) + expWalker.seeConvergeExpression(walkExpression(null, + dfaCommon.getReturnVariable, exp)); + + dfaCommon.currentDFAScope.haveJumped = true; + dfaCommon.currentDFAScope.haveReturned = true; + analyzer.reporter.onEndOfScope(dfaCommon.currentFunction, exp.loc); + break; + + case STMT.Compound: + auto cs = st.isCompoundStatement; + if (cs.statements is null) + break; + + // We need to know which statement we are in and what the next ones are + // so that we can find labels and run finally statements + + dfaCommon.printStructureln("Compound statements:"); + this.startScope; + dfaCommon.currentDFAScope.compoundStatement = cs; + + foreach (i, st2; *cs.statements) + { + dfaCommon.printStructureln("Compound statement:"); + dfaCommon.currentDFAScope.inProgressCompoundStatement = i; + this.visit(st2); + + if (dfaCommon.currentDFAScope.haveReturned) + { + dfaCommon.printStructureln("Compound returned"); + break; + } + } + + DFAScopeRef scr = this.endScope; + + dfaCommon.printStructureln("Compound converge:"); + this.seeConvergeScope(scr); + break; + + case STMT.If: + auto ifs = st.isIfStatement; + auto origScope = dfaCommon.currentDFAScope; + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("If statement %p:%p ", dfaCommon.currentDFAScope, origScope); + appendLoc(ob, ifs.loc); + ob.writestring("\n"); + }); + + bool ignoreTrueBranch, ignoreFalseBranch; + bool unknownBranchTaken; + + dfaCommon.printStructureln("If condition:"); + int predicateNegation; + DFALatticeRef conditionLR; + DFAVar* conditionVar; + + { + this.startScope; + dfaCommon.currentDFAScope.sideEffectFree = true; + + conditionLR = expWalker.walkCondition(ifs.condition, predicateNegation); + conditionVar = conditionLR.getGateConsequenceVariable; + + this.endScope; + } + + { + dfaCommon.printStructureln("If true branch:"); + this.startScope; + dfaCommon.currentDFAScope.inConditional = true; + + DFAConsequence* c = conditionLR.getContext; + if (c !is null) + { + if (c.truthiness == Truthiness.False) + ignoreTrueBranch = true; + else if (c.truthiness == Truthiness.True) + ignoreFalseBranch = true; + else + unknownBranchTaken = true; + } + else + unknownBranchTaken = true; + + DFALatticeRef trueCondition = expWalker.adaptConditionForBranch(conditionLR.copy, + ifs.condition.type, true); + expWalker.seeSilentAssert(trueCondition, true, true); + this.applyGateOnBranch(conditionVar, predicateNegation, true); + } + + DFAScopeRef ifbody, elsebody; + + if (!ignoreTrueBranch) + { + if (auto scs = ifs.ifbody.isScopeStatement) + this.visit(scs.statement); + else + this.visit(ifs.ifbody); + + assert(dfaCommon.currentDFAScope !is origScope); + + ifbody = this.endScope; + ifbody.check; + } + else + { + this.endScope; + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.writestring("true ignored\n")); + } + + assert(dfaCommon.currentDFAScope is origScope); + bool haveFalseBody; + + { + dfaCommon.printStructureln("If false branch:"); + + this.startScope; + dfaCommon.currentDFAScope.inConditional = true; + + if (!ignoreTrueBranch) + { + DFALatticeRef falseCondition = expWalker.adaptConditionForBranch(conditionLR.copy, + ifs.condition.type, false); + expWalker.seeSilentAssert(falseCondition, true, true); + } + + this.applyGateOnBranch(conditionVar, predicateNegation, false); + + if (!ignoreFalseBranch && ifs.elsebody !is null) + { + haveFalseBody = true; + + if (auto scs = ifs.elsebody.isScopeStatement) + this.visit(scs.statement); + else + this.visit(ifs.elsebody); + } + + elsebody = this.endScope; + elsebody.check; + } + + seeConvergeStatementIf(conditionLR, ifbody, elsebody, + haveFalseBody, unknownBranchTaken, predicateNegation); + break; + + case STMT.Scope: + auto sc = st.isScopeStatement; + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.writestring("Starting scope body at "); + appendLoc(ob, sc.loc); + ob.writestring("\n"); + }); + + this.startScope; + this.visit(sc.statement); + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.writestring("Completed scope body at "); + appendLoc(ob, sc.endloc); + ob.writestring("\n"); + }); + + DFAScopeRef scbody = this.endScope; + this.seeConvergeScope(scbody); + break; + + case STMT.Label: + auto ls = st.isLabelStatement; + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.printf("label %s %p %p\n", + ls.ident !is null ? ls.ident.toChars : null, ls.gotoTarget, ls.gotoTarget)); + + inLoopyLabel++; + scope (exit) + inLoopyLabel--; + + this.startScope; + dfaCommon.currentDFAScope.label = ls.ident; + dfaCommon.setScopeAsLoopyLabel; + dfaCommon.currentDFAScope.isLoopyLabelKnownToHaveRun = true; + + { + // sometimes we can by-pass needing to look up the for loop + dfaCommon.currentDFAScope.controlStatement = ls.gotoTarget !is null + ? ls.gotoTarget.isForStatement : null; + + if (dfaCommon.currentDFAScope.controlStatement is null && ls.statement !is null) + { + if (dfaCommon.currentDFAScope.controlStatement is null) + dfaCommon.currentDFAScope.controlStatement = ls.statement.isForStatement; + if (dfaCommon.currentDFAScope.controlStatement is null) + dfaCommon.currentDFAScope.controlStatement = ls.statement.isDoStatement; + if (dfaCommon.currentDFAScope.controlStatement is null) + dfaCommon.currentDFAScope.controlStatement = ls.statement.isSwitchStatement; + } + } + + dfaCommon.swapForwardLabelScope(ls.ident, (old) { + if (!old.isNull) + this.seeConvergeForwardGoto(old); + return DFAScopeRef.init; + }); + + DFAScopeRef scr; + + // by-pass scope statement processing with a dedicated variation here. + if (ls.statement is null) + { + // empty block, this is ok. + scr = this.endScope; + } + else if (auto scs = ls.statement.isScopeStatement) + { + this.visit(scs.statement); + scr = this.endScope(*cast(Loc*)&ls.loc); + } + else + { + this.visit(ls.statement); + scr = this.endScope; + } + + seeConvergeStatementLoopyLabels(scr, *cast(Loc*)&ls.loc); + break; + + case STMT.For: + auto fs = st.isForStatement; + // fs._init should be handled already + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.writestring("starting for loop at "); + appendLoc(ob, fs.endloc); + ob.writestring("\n"); + }); + + inLoopyLabel++; + scope (exit) + inLoopyLabel--; + + Expression theCondition = fs.condition; + Statement theBody = fs._body; + + /* + Check to see if the for statement is a while loop. + for(;true;) { + if (condition) { + ... + } else { + break; + } + } + */ + if (theCondition !is null) + { + auto ie = theCondition.isIntegerExp; + + if (ie !is null && ie.type is Type.tbool && ie.getInteger == 1) + { + auto ifs = theBody.isIfStatement; + + if (ifs !is null && ifs.elsebody !is null && ifs.elsebody.isBreakStatement) + { + // Okay this is actually a while loop + + theCondition = ifs.condition; + theBody = ifs.ifbody; + } + } + } + + { + this.startScope; + dfaCommon.currentDFAScope.controlStatement = st; + dfaCommon.currentDFAScope.inConditional = true; + dfaCommon.setScopeAsLoopyLabel; + + { + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.writestring("For condition:\n")); + DFALatticeRef lrCondition = expWalker.adaptConditionForBranch(theCondition, + true); + + if (auto c = lrCondition.getContext) + { + dfaCommon.currentDFAScope.isLoopyLabelKnownToHaveRun + = c.truthiness == Truthiness.True; + } + + expWalker.seeAssert(lrCondition, theCondition.loc, true); + } + + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.writestring("For body:\n")); + this.visit(theBody); + + if (!dfaCommon.currentDFAScope.haveJumped) + { + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.writestring("For increment:\n")); + DFALatticeRef lrIncrement = this.walkExpression(null, null, fs.increment); + expWalker.seeConvergeExpression(lrIncrement); + } + + DFAScopeRef scr = this.endScopeAndReport(fs.endloc); + assert(!scr.isNull); + this.seeConvergeStatementLoopyLabels(scr, *cast(Loc*)&fs.loc); + + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.writestring( + "For (effect) condition:\n")); + + DFALatticeRef lrCondition = expWalker.adaptConditionForBranch(theCondition, false); + expWalker.seeSilentAssert(lrCondition, true, true); + } + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.writestring("finished for loop at "); + appendLoc(ob, fs.endloc); + ob.writestring("\n"); + }); + + break; + + case STMT.Do: + auto ds = st.isDoStatement; + + inLoopyLabel++; + scope (exit) + inLoopyLabel--; + + this.startScope; + dfaCommon.currentDFAScope.controlStatement = st; + dfaCommon.setScopeAsLoopyLabel; + dfaCommon.currentDFAScope.isLoopyLabelKnownToHaveRun = true; + dfaCommon.currentDFAScope.inConditional = true; + + this.visit(ds._body); + + DFALatticeRef lrCondition = this.walkExpression(null, null, ds.condition); + expWalker.seeSilentAssert(lrCondition, false, true); + + dfaCommon.currentDFAScope.haveJumped = true; + DFAScopeRef scr = this.endScope(ds.endloc); + this.seeConvergeStatementLoopyLabels(scr, *cast(Loc*)&ds.loc); + break; + + case STMT.UnrolledLoop: + auto uls = st.isUnrolledLoopStatement; + + inLoopyLabel++; + scope (exit) + inLoopyLabel--; + + if (uls.statements !is null && uls.statements.length > 0) + { + this.startScope; + + dfaCommon.currentDFAScope.controlStatement = st; + dfaCommon.setScopeAsLoopyLabel; + + foreach (stmt; *uls.statements) + { + this.startScope; + this.visit(stmt); + + DFAScopeRef scr = this.endScope; + + if (scr.sc.haveReturned) + { + this.seeConvergeScope(scr); + break; + } + else + this.seeConvergeScope(scr); + } + + DFAScopeRef scr = this.endScope(); + this.seeConvergeStatementLoopyLabels(scr); + } + + break; + + case STMT.Switch: + auto ss = st.isSwitchStatement; + + this.startScope; + dfaCommon.currentDFAScope.controlStatement = ss; + dfaCommon.currentDFAScope.inConditional = true; + + DFALatticeRef lrCondition = this.walkExpression(null, null, ss.condition); + lrCondition.check; + + DFAScope* oldScope = dfaCommon.currentDFAScope; + + { + // initial pass over the case bodies + + if (ss.sdefault !is null) + { + DFACaseState* caState = dfaCommon.acquireCaseState(ss.sdefault); + + this.startScope; + dfaCommon.currentDFAScope.controlStatement = ss.sdefault; + dfaCommon.setScopeAsLoopyLabel; + + lrCondition.check; + DFALatticeRef lrCondition2 = lrCondition.copy; + lrCondition2.check; + expWalker.seeConvergeExpression(lrCondition2); + + if (ss.sdefault.statement !is null) + { + if (auto scs = ss.sdefault.statement.isScopeStatement) + this.visit(scs.statement); + else + this.visit(ss.sdefault.statement); + } + + caState.containing = this.endScope; + assert(dfaCommon.currentDFAScope is oldScope); + } + + if (ss.cases !is null) + { + foreach (cs; *ss.cases) + { + DFACaseState* caState = dfaCommon.acquireCaseState(cs); + this.startScope; + + dfaCommon.currentDFAScope.controlStatement = cs; + dfaCommon.setScopeAsLoopyLabel; + + DFALatticeRef equalTo = this.walkExpression(null, null, cs.exp); + lrCondition.check; + DFALatticeRef lrCondition2 = lrCondition.copy; + lrCondition2.check; + + expWalker.seeConvergeExpression(expWalker.seeEqual(lrCondition2, equalTo, true, + ss.condition.type.toBasetype, cs.exp.type.toBasetype)); + + if (auto scs = cs.statement.isScopeStatement) + this.visit(scs.statement); + else + this.visit(cs.statement); + + caState.containing = this.endScope; + assert(dfaCommon.currentDFAScope is oldScope); + } + } + } + + { + DFAScopeRef inProgress; + + // now let's make sure that nobody has done something bad wrt. input state + + if (ss.sdefault !is null) + { + DFACaseState* caState = dfaCommon.acquireCaseState(ss.sdefault); + + if (!caState.jumpedTo.isNull) + this.seeCheckForCaseBefore(caState.containing, + caState.jumpedTo, ss.sdefault.loc); + + inProgress = this.seeLoopyLabelAwareStage(inProgress, caState.containing); + } + + if (ss.cases !is null) + { + foreach (cs; *ss.cases) + { + DFACaseState* caState = dfaCommon.acquireCaseState(cs); + + if (!caState.jumpedTo.isNull) + this.seeCheckForCaseBefore(caState.containing, + caState.jumpedTo, cs.loc); + + inProgress = this.seeLoopyLabelAwareStage(inProgress, caState.containing); + } + } + + if (!inProgress.isNull) + { + this.seeConvergeScope(inProgress); + } + } + + DFAScopeRef scr = this.endScope(ss.endloc); + this.seeConvergeScope(scr); + break; + + case STMT.Continue: + auto cs = st.isContinueStatement; + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) => ob.printf( + "Continue statement %s\n", cs.ident !is null ? cs.ident.toChars : null)); + + auto sc = dfaCommon.findScopeGivenLabel(cs.ident); + assert(sc !is null); + + if (!dfaCommon.debugUnknownAST && sc.controlStatement is null) + break; + else + assert(sc.controlStatement !is null); + + { + // Look for control statements in the scope stack, + // specifically for a control statement that does not match the one for the continue. + // This covers things like if statements. + bool haveParentControlStatement; + DFAScope* parentScope = dfaCommon.currentDFAScope; + + while (parentScope !is sc) + { + if (parentScope.controlStatement !is null + && parentScope.controlStatement !is sc.controlStatement) + { + haveParentControlStatement = true; + break; + } + + parentScope = parentScope.parent; + } + + if (haveParentControlStatement) + dfaCommon.currentDFAScope.haveJumped = true; + } + + if (auto forLoop = sc.controlStatement.isForStatement) + { + DFALatticeRef lr = this.walkExpression(null, null, forLoop.increment); + expWalker.seeConvergeExpression(lr); + } + + seeGoto(sc, false); + runFinalizersUntilScope(sc); + break; + + case STMT.Break: + auto bs = st.isBreakStatement; + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.printf("Break statement %s\n", + bs.ident !is null ? bs.ident.toChars : null)); + + auto sc = dfaCommon.findScopeGivenLabel(bs.ident); + assert(sc !is null); + + if (!dfaCommon.debugUnknownAST && sc.controlStatement is null) + break; + else + assert(sc.controlStatement !is null); + + { + // Look for control statements in the scope stack, + // specifically for a control statement that does not match the one for the break. + // This covers things like if statements. + bool haveParentControlStatement; + DFAScope* parentScope = dfaCommon.currentDFAScope; + + while (parentScope !is sc) + { + if (parentScope.controlStatement !is null + && parentScope.controlStatement !is sc.controlStatement) + { + haveParentControlStatement = true; + break; + } + + parentScope = parentScope.parent; + } + + if (haveParentControlStatement) + dfaCommon.currentDFAScope.haveJumped = true; + } + + seeGoto(sc, true); + runFinalizersUntilScope(sc); + break; + + case STMT.Case: + break; // do nothing, already handled in switch statement + + case STMT.GotoDefault: + auto gds = st.isGotoDefaultStatement; + + auto targetScope = dfaCommon.findScopeForControlStatement(gds.sw); + assert(targetScope !is null); + + targetScope = targetScope.child; // into the case statement + assert(targetScope !is null); + assert(targetScope.controlStatement.isCaseStatement !is null + || targetScope.controlStatement.isDefaultStatement !is null); + + this.runFinalizersUntilScope(targetScope); + + DFACaseState* caState = dfaCommon.acquireCaseState(gds.sw.sdefault); + caState.jumpedTo = this.seeLoopyLabelAwareStage(caState.jumpedTo, targetScope.copy); + break; + + case STMT.GotoCase: + auto gcs = st.isGotoCaseStatement; + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.printf("Goto case statement target %p\n", + gcs.cs)); + + DFAScope* targetScope; + auto sw = dfaCommon.findSwitchGivenCase(gcs.cs, targetScope); + assert(sw !is null); + assert(targetScope !is null); + + this.runFinalizersUntilScope(targetScope); + + DFACaseState* caState = dfaCommon.acquireCaseState(gcs.cs); + caState.jumpedTo = this.seeLoopyLabelAwareStage(caState.jumpedTo, targetScope.copy); + break; + + case STMT.TryFinally: + auto tfs = st.isTryFinallyStatement; + dfaCommon.printStructure((ref OutBuffer ob, + scope PrintPrefixType prefix) => ob.printf("try finally %p %p\n", + tfs._body, tfs.finalbody)); + + this.startScope; + dfaCommon.currentDFAScope.tryFinallyStatement = tfs; + + // normal path execute both + this.visit(tfs._body); + this.visit(tfs.finalbody); + + dfaCommon.currentDFAScope.tryFinallyStatement = null; + + DFAScopeRef scr = this.endScope; + this.seeConvergeScope(scr); + break; + + case STMT.Goto: + auto gs = st.isGotoStatement; + dfaCommon.currentDFAScope.haveJumped = true; + + auto sc = dfaCommon.findScopeGivenLabel(gs.ident); + + if (sc !is null) + { + // backwards goto + seeGoto(sc, false); + } + else + seeForwardsGoto(gs.ident); + break; + + case STMT.Import: + break; // do nothing + + case STMT.With: + auto ws = st.isWithStatement; + + this.startScope; + + DFALatticeRef lr = this.walkExpression(null, null, ws.exp); + expWalker.seeConvergeExpression(lr); + + if (auto ss = ws._body.isScopeStatement) + this.visit(ss.statement); + else + this.visit(ws._body); + + DFAScopeRef scr = this.endScope(ws.endloc); + this.seeConvergeScope(scr); + break; + + case STMT.TryCatch: + // For the initial version we'll visit and then foreach var as unmodellable. + auto tc = st.isTryCatchStatement; + + this.startScope; + this.visit(tc._body); + DFAScopeRef inProgress = this.endScope(); + + if (tc.catches !is null) + { + // Mark everything as unmodellable as we have no idea how it effects anything outside the catch. + foreach (cat; *tc.catches) + { + markUnmodellable(cat.handler); + } + } + + this.seeConvergeScope(inProgress); + break; + + case STMT.Throw: + auto ts = st.isThrowStatement; + expWalker.seeConvergeExpression(this.walkExpression(null, null, ts.exp)); + + dfaCommon.currentDFAScope.haveJumped = true; + dfaCommon.currentDFAScope.haveReturned = true; + break; + + case STMT.Asm: + case STMT.InlineAsm: + case STMT.GccAsm: + case STMT.CompoundAsm: + // All variables that we've seen so far are now unmodellable + // no way to know what state they actually are in :( + dfaCommon.allocatedVariablesAllUnmodellable; + break; + + case STMT.SwitchError: + case STMT.Pragma: + case STMT.Error: + break; // ignore these + + case STMT.Default: + case STMT.CompoundDeclaration: + case STMT.ScopeGuard: + case STMT.Foreach: + case STMT.ForeachRange: + case STMT.Debug: + case STMT.CaseRange: + case STMT.StaticForeach: + case STMT.StaticAssert: + case STMT.Conditional: + case STMT.While: + case STMT.Forwarding: + case STMT.Mixin: + case STMT.Peel: + case STMT.Synchronized: + if (dfaCommon.debugUnknownAST) + { + fprintf(stderr, "Unknown DFA walk statement %d\n", st.stmt); + assert(0); + } + else + break; + } + } + + void runFinalizersUntilLabel(Identifier target) + { + DFAScope* targetHeadScope = dfaCommon.findScopeHeadOfLabelStatement(target); + + version (none) + { + printf("Run finalizers up to scope %p", targetHeadScope); + + if (targetHeadScope !is null && targetHeadScope.label !is null) + printf("%s\n", targetHeadScope.label.toChars); + else + printf("\n"); + } + + runFinalizersUntilScope(targetHeadScope); + } + + void runFinalizersUntilScope(DFAScope* targetScope) + { + DFAScope* scv = dfaCommon.currentDFAScope; + + while (scv !is null) + { + if (scv.tryFinallyStatement !is null && scv.tryFinallyStatement.finalbody !is null) + { + this.visit(scv.tryFinallyStatement.finalbody); + } + + if (scv is targetScope) + break; + scv = scv.parent; + } + } + + void markUnmodellable(Statement s) + { + void perVar(VarDeclaration vd) + { + DFAVar* var = dfaCommon.findVariable(vd); + if (var !is null) + var.unmodellable = true; + } + + void perExpr(Expression expr) + { + if (auto ve = expr.isVarExp) + { + if (auto vd = ve.var.isVarDeclaration) + perVar(vd); + } + else if (auto ue = expr.isUnaExp) + { + perExpr(ue.e1); + } + else if (auto be = expr.isBinExp) + { + perExpr(be.e1); + perExpr(be.e2); + } + } + + foreachExpAndVar(s, &perExpr, &perVar); + } +} diff --git a/dmd/dfa/fast/structure.d b/dmd/dfa/fast/structure.d new file mode 100644 index 0000000000..d522adac2a --- /dev/null +++ b/dmd/dfa/fast/structure.d @@ -0,0 +1,2789 @@ +/** + * Structure and representation of the fast Data Flow Analysis engine. + * + * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) + * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) + * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dfa/fast/structure.d, dfa/fast/structure.d) + * Documentation: https://dlang.org/phobos/dmd_dfa_fast_structure.html + * Coverage: https://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/dfa/fast/structure.d + */ +module dmd.dfa.fast.structure; +import dmd.dfa.utils; +import dmd.common.outbuffer; +import dmd.declaration; +import dmd.statement; +import dmd.func; +import dmd.mtype; +import dmd.identifier; +import dmd.globals; +import dmd.dsymbol; +import dmd.location; +import dmd.expression; +import dmd.astenums; +import core.stdc.stdio; + +package static immutable PrintPipeText = "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"; + +void appendLoc(ref OutBuffer ob, ref const(Loc) loc) +{ + writeSourceLoc(ob, SourceLoc(loc), true, Loc.messageStyle); +} + +alias PrintPrefixType = void delegate(const(char)*); + +// Old compiler versions have bugs with their copy constructors. +// Don't try to save memory by using moving to cleanup. +// Only relevant for bootstrapping purposes. +// We also require that GC.inFinalizer to exist. +enum DFACleanup = __VERSION__ >= 2102; + +//version = DebugJoinMeetOp; + +struct DFACommon +{ + DFAAllocator allocator; + DFAScope* currentDFAScope; + DFAScope* lastLoopyLabel; + DFAScope* lastCatch; + + int sdepth, edepth; + FuncDeclaration currentFunction; + + // Making these enum's instead of fields allows for significant performance gains + enum debugIt = false; + //enum debugIt = true; + enum debugStructure = false; + //enum debugStructure = true; + enum debugUnknownAST = false; + //enum debugUnknownAST = true; + enum debugVerify = false; // Disable to improve performance + + private + { + DFAVar*[16] vars; + DFAVar*[16] varPairs; + DFAVar* returnVar; + DFAVar* infiniteLifetimeVar; + DFAVar* unknownVar; + + DFALabelState*[16] forwardLabels; + DFACaseState*[16] caseEntries; + } + + void printIfStructure(scope void delegate(ref OutBuffer ob, + scope void delegate(const(char)*) prefix) del) + { + static if (debugStructure) + { + OutBuffer ob; + + void prefix(const(char)* pre) + { + printPrefix(ob, pre, sdepth, currentFunction, edepth); + } + + del(ob, &prefix); + + if (ob.length > 0) + printf(ob.peekChars); + + fflush(stdout); + } + } + + void printStructureln(const(char)[] text) + { + printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.writestring(text); + ob.writestring("\n"); + }); + } + + void printStructure(scope void delegate(ref OutBuffer ob, + scope void delegate(const(char)*) prefix) del) + { + static if (debugStructure) + { + OutBuffer ob; + + void prefix(const(char)* pre) + { + printPrefix(ob, pre, sdepth, currentFunction, edepth); + } + + prefix(""); + del(ob, &prefix); + + if (ob.length > 0) + printf(ob.peekChars); + + fflush(stdout); + } + } + + void printStateln(const(char)[] text) + { + printState((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.writestring(text); + ob.writestring("\n"); + }); + } + + void printState(scope void delegate(ref OutBuffer ob, scope PrintPrefixType prefix) del) + { + static if (debugIt) + { + OutBuffer ob; + + void prefix(const(char)* pre) + { + printPrefix(ob, pre, sdepth, currentFunction, edepth); + } + + prefix(""); + del(ob, &prefix); + + if (ob.length > 0) + printf(ob.peekChars); + + fflush(stdout); + } + } + + void pushScope() + { + DFAScope* oldScope = currentDFAScope; + currentDFAScope = allocator.makeScope(&this, oldScope); + + assert(currentDFAScope.parent !is currentDFAScope); + assert(currentDFAScope.parent is oldScope); + + if (oldScope !is null) + { + oldScope.child = currentDFAScope; + currentDFAScope.depth = oldScope.depth + 1; + currentDFAScope.inConditional = oldScope.inConditional; + } + else + { + currentDFAScope.depth = 1; + } + } + + DFAScopeRef popScope() + { + DFAScopeRef ret; + ret.sc = currentDFAScope; + + if (lastLoopyLabel is currentDFAScope) + lastLoopyLabel = lastLoopyLabel.previousLoopyLabel; + if (lastCatch is currentDFAScope) + lastCatch = lastCatch.previousCatch; + + currentDFAScope = currentDFAScope.parent; + ret.sc.parent = null; + + if (currentDFAScope !is null) + currentDFAScope.child = null; + return ret; + } + + void setScopeAsLoopyLabel() + { + this.currentDFAScope.isLoopyLabel = true; + this.currentDFAScope.previousLoopyLabel = this.lastLoopyLabel; + lastLoopyLabel = this.currentDFAScope; + } + + void setScopeAsCatch() + { + this.currentDFAScope.previousCatch = this.lastCatch; + lastCatch = this.currentDFAScope; + } + + DFAVar* findVariable(VarDeclaration vd, DFAVar* childOf = null) + { + if (vd is null) + return null; + + if (childOf is null) + { + DFAVar** bucket = &vars[(cast(size_t) cast(void*) vd) % vars.length]; + + while (*bucket !is null && cast(void*)(*bucket).var < cast(void*) vd) + { + bucket = &(*bucket).next; + } + + if (*bucket !is null && (*bucket).var is vd) + return *bucket; + + DFAVar* ret = allocator.makeVar(vd); + ret.next = *bucket; + *bucket = ret; + return ret; + } + else + return allocator.makeVar(vd, childOf); + } + + DFAVar* findVariablePair(DFAVar* a, DFAVar* b) + { + if (a is null) + return b; + else if (b is null) + return a; + else if (a is b) + return a; + + if (a > b) + { + DFAVar* temp = a; + a = b; + b = temp; + } + + const a1 = (cast(size_t) a) % 0xF, b1 = (cast(size_t) b) % 0xF; + const ab1 = (b1 << 4) | a1; + const ab2 = ab1 % 16; + + DFAVar** bucket = &varPairs[ab2]; + + while (*bucket !is null && cast(size_t)(*bucket).base1 < cast(size_t) a) + { + bucket = &(*bucket).next; + } + + if (*bucket is a) + { + while ((*bucket).base1 is a && cast(size_t)(*bucket).base2 < cast(size_t) b) + { + bucket = &(*bucket).next; + } + } + + if (*bucket is null || (*bucket).base1 !is a || (*bucket).base2 !is b) + { + DFAVar* next = *bucket; + *bucket = allocator.makeVar(null, null); + (*bucket).haveInfiniteLifetime = a.haveInfiniteLifetime && b.haveInfiniteLifetime; + (*bucket).next = next; + } + + return *bucket; + } + + DFAVar* findDereferenceVar(DFAVar* childOf) + { + if (childOf is null) + return null; + + if (childOf.dereferenceVar is null) + { + childOf.dereferenceVar = allocator.makeVar(null); + childOf.dereferenceVar.base1 = childOf; + childOf.dereferenceVar.haveInfiniteLifetime = childOf.haveInfiniteLifetime; + } + + return childOf.dereferenceVar; + } + + DFAVar* findIndexVar(DFAVar* childOf) + { + if (childOf is null) + return null; + + if (childOf.indexVar is null) + { + childOf.indexVar = allocator.makeVar(null); + childOf.indexVar.base1 = childOf; + childOf.indexVar.isAnIndex = true; + childOf.indexVar.haveInfiniteLifetime = childOf.haveInfiniteLifetime; + } + + return childOf.indexVar; + } + + DFAVar* findSliceLengthVar(DFAVar* childOf) + { + if (childOf is null) + return null; + + if (childOf.lengthVar is null) + { + childOf.lengthVar = allocator.makeVar(null); + childOf.lengthVar.base1 = childOf; + childOf.lengthVar.isLength = true; + childOf.lengthVar.haveInfiniteLifetime = childOf.haveInfiniteLifetime; + } + + return childOf.lengthVar; + } + + DFAVar* findOffsetVar(dinteger_t offset, DFAVar* childOf) + { + if (childOf is null) + return null; + + DFAVar** bucket = &childOf.childOffsetVars; + + while (*bucket !is null && (*bucket).offsetFromBase < offset) + { + bucket = &(*bucket).next; + } + + if (*bucket !is null && (*bucket).offsetFromBase == offset) + return *bucket; + + DFAVar* ret = allocator.makeVar(null); + ret.base1 = childOf; + ret.offsetFromBase = offset; + ret.haveInfiniteLifetime = childOf.haveInfiniteLifetime; + + ret.next = *bucket; + *bucket = ret; + return ret; + } + + DFAScope* findScopeForControlStatement(Statement st) + { + DFAScope* current = this.currentDFAScope; + + while (current !is null && current.controlStatement !is st) + { + current = current.parent; + } + + return current; + } + + DFAScope* findScopeHeadOfLabelStatement(Identifier label) + { + bool walkExpression(Expression e) + { + if (auto de = e.isDeclarationExp) + { + return de.declaration.isVarDeclaration !is null; + } + else if (auto be = e.isBinExp) + return walkExpression(be.e1) || walkExpression(be.e2); + else if (auto ue = e.isUnaExp) + return walkExpression(ue.e1); + else + return false; + } + + bool walkStatement(Statement s) + { + if (s is null) + return false; + + with (STMT) + { + final switch (s.stmt) + { + // could prevent it + case Exp: + auto s2 = s.isExpStatement; + return walkExpression(s2.exp); + + // could be this + case Label: + auto s2 = s.isLabelStatement; + if (s2.ident is label) + return true; + else + return walkStatement(s2.statement); + + // can be in this + case Debug: + auto s2 = s.isDebugStatement; + return walkStatement(s2.statement); + case Default: + auto s2 = s.isDefaultStatement; + return walkStatement(s2.statement); + case CaseRange: + auto s2 = s.isCaseRangeStatement; + return walkStatement(s2.statement); + case Case: + auto s2 = s.isCaseStatement; + return walkStatement(s2.statement); + case Peel: + auto s2 = s.isPeelStatement; + return walkStatement(s2.s); + case Forwarding: + auto s2 = s.isForwardingStatement; + return walkStatement(s2.statement); + case If: + auto s2 = s.isIfStatement; + return walkStatement(s2.ifbody) || walkStatement(s2.elsebody); + case Do: + auto s2 = s.isDoStatement; + return walkStatement(s2._body); + case For: + auto s2 = s.isForStatement; + return walkStatement(s2._body); + case Switch: + auto s2 = s.isSwitchStatement; + if (s2.cases !is null) + { + foreach (c; *s2.cases) + { + if (walkStatement(c)) + return true; + } + } + return false; + case UnrolledLoop: + auto s2 = s.isUnrolledLoopStatement; + if (s2.statements !is null) + { + foreach (s3; *s2.statements) + { + if (walkStatement(s3)) + return true; + } + } + return false; + case Scope: + auto s2 = s.isScopeStatement; + return walkStatement(s2.statement); + case Compound: + case CompoundDeclaration: + auto s2 = s.isCompoundStatement; + if (s2.statements !is null) + { + foreach (s3; *s2.statements) + { + if (walkStatement(s3)) + return true; + } + } + return false; + + // can't be in this + case Error: + case DtorExp: + case Mixin: + case CompoundAsm: + case Synchronized: + case With: + case TryCatch: + case TryFinally: + case ScopeGuard: + case While: + case Conditional: + case ForeachRange: + case Foreach: + case StaticForeach: + case Pragma: + case StaticAssert: + case GotoDefault: + case GotoCase: + case SwitchError: + case Return: + case Break: + case Continue: + case Throw: + case Goto: + case Asm: + case InlineAsm: + case GccAsm: + case Import: + return false; + } + } + } + + DFAScope* current = this.currentDFAScope; + + while (current !is null) + { + if (current.compoundStatement !is null) + { + foreach (s; (*current.compoundStatement.statements)[current.inProgressCompoundStatement + .. $]) + { + if (walkStatement(s)) + return current; + } + } + + current = current.parent; + } + + return null; + } + + SwitchStatement findSwitchGivenCase(CaseStatement cs, out DFAScope* target) + { + DFAScope* current = this.currentDFAScope; + + while (current !is null) + { + if (current.controlStatement !is null) + { + auto sw = current.controlStatement.isSwitchStatement; + + if (sw !is null && sw.cases !is null) + { + foreach (cs2; *sw.cases) + { + if (cs2 is cs) + { + target = current; + return sw; + } + } + } + } + + current = current.parent; + } + + return null; + } + + DFAVar* getReturnVariable() + { + if (this.returnVar is null) + this.returnVar = allocator.makeVar(null); + return this.returnVar; + } + + DFAVar* getInfiniteLifetimeVariable() + { + if (this.infiniteLifetimeVar is null) + { + this.infiniteLifetimeVar = allocator.makeVar(null); + this.infiniteLifetimeVar.haveInfiniteLifetime = true; + } + + return this.infiniteLifetimeVar; + } + + DFAVar* getUnknownVar() + { + if (this.infiniteLifetimeVar is null) + { + this.unknownVar = allocator.makeVar(null); + this.unknownVar.unmodellable = true; + } + + return this.unknownVar; + } + + DFAScope* getSideEffectScope() + { + DFAScope* current = this.currentDFAScope; + + while (current.sideEffectFree) + { + current = current.parent; + } + + return current; + } + + DFALatticeRef makeLatticeRef() + { + DFALatticeRef ret; + ret.lattice = allocator.makeLattice(&this); + ret.check; + return ret; + } + + DFAScopeVar* swapLattice(DFAVar* contextVar, scope DFALatticeRef delegate(DFALatticeRef) dg) + { + if (contextVar is null || this.currentDFAScope.depth < contextVar.declaredAtDepth) + return null; + + DFAScopeVar* scv = this.acquireScopeVar(contextVar); + + if (scv.lr.isNull) + { + scv.lr = this.makeLatticeRef; + scv.lr.setContext(contextVar); + } + + DFALatticeRef got = dg(scv.lr); + + if (!got.isNull) + { + if (got.getContextVar !is contextVar) + scv.lr.setContext(contextVar); + + scv.lr = got; + } + + scv.lr.check; + return scv; + } + + void swapForwardLabelScope(Identifier ident, scope DFAScopeRef delegate(DFAScopeRef) del) + { + DFALabelState** bucket = &this.forwardLabels[( + cast(size_t) cast(void*) ident) % this.forwardLabels.length]; + + while (*bucket !is null && cast(void*)(*bucket).ident < cast(void*) ident) + { + bucket = &(*bucket).next; + } + + if (*bucket is null || (*bucket).ident !is ident) + { + DFALabelState* temp = allocator.makeLabelState(ident); + temp.next = *bucket; + *bucket = temp; + } + + (*bucket).scr = del((*bucket).scr); + } + + DFACaseState* acquireCaseState(Statement caseStatement) + { + DFACaseState** bucket = &this.caseEntries[( + cast(size_t) cast(void*) caseStatement) % this.caseEntries.length]; + + while (*bucket !is null && cast(void*)(*bucket).caseStatement < cast(void*) caseStatement) + { + bucket = &(*bucket).next; + } + + if (*bucket is null || (*bucket).caseStatement !is caseStatement) + { + DFACaseState* temp = allocator.makeCaseState(caseStatement); + temp.next = *bucket; + *bucket = temp; + } + + return *bucket; + } + + DFALatticeRef acquireLattice(DFAVar* var) + { + DFAScopeVar* scv = this.acquireScopeVar(var); + if (scv is null) + return DFALatticeRef.init; + + return scv.lr.copy; + } + + DFAScopeVar* acquireScopeVar(DFAVar* var) + { + if (var is null || this.currentDFAScope.depth < var.declaredAtDepth) + return null; + + DFAScope* sc; + sc = this.currentDFAScope; + DFAScopeVar* scv, ret; + + while (sc !is null && sc.depth >= var.declaredAtDepth) + { + if ((scv = sc.findScopeVar(var)) !is null) + break; + + sc = sc.parent; + } + + assert(scv is null || scv.var is var); + DFAConsequence* c; + + if (scv is null) + { + // init new state + sc = this.currentDFAScope; + ret = sc.getScopeVar(var); + + c = ret.lr.getContext; + assert(ret.var is var); + assert(c !is null); + assert(c.var is var); + + return ret; + } + else + { + assert(!scv.lr.isNull); + c = scv.lr.getContext; + assert(c !is null); + assert(c.var is var); + } + + sc = sc.child; + ret = scv; + + while (sc !is null) + { + ret = sc.getScopeVar(var); + assert(ret.var is var); + // if we had state that we wanted copied, we'd do it here + + ret.lr = scv.lr.copy; + ret.mergable = scv.mergable; + + c = ret.lr.getContext; + assert(c !is null); + assert(c.var is var); + + sc = sc.child; + } + + assert(ret !is null); + return ret; + } + + DFAScope* findScopeGivenLabel(Identifier ident) + { + DFAScope* current = this.currentDFAScope; + + if (ident is null) + { + while (current.parent !is null && current.controlStatement is null) + { + current = current.parent; + } + } + else + { + while (current.parent !is null && current.label !is ident) + { + current = current.parent; + } + } + + return (current !is null && (current.label is ident || current.controlStatement !is null)) ? current + : null; + } + + void allocatedVariablesAllUnmodellable() + { + // If we're calling this, that means we have literally no idea what state these variables are in. + // Its anything after this point in the AST walk. + + DFAVar* current = allocator.allocatedlistvar; + + while (current !is null) + { + current.unmodellable = true; + current = current.listnext; + } + } + + void print() + { + DFAScope* sc = this.currentDFAScope; + + while (sc !is null) + { + printf("- scope %p\n", sc); + + foreach (i; 0 .. sc.buckets.length) + { + printf(" - bucket %zd:\n", i); + + DFAScopeVar* bucket = sc.buckets[i]; + while (bucket !is null) + { + printf(" - scope var %p for var %p\n", bucket, bucket.var); + DFAConsequence* cctx = bucket.lr.getContext; + printf(" cctx.var %p\n", cctx !is null ? cctx.var : null); + bucket = bucket.next; + } + } + + sc = sc.parent; + } + + fflush(stdout); + } + + void check() + { + static if (DFACommon.debugVerify) + { + DFAScope* sc = this.currentDFAScope; + + while (sc !is null) + { + foreach (var, l, scv; *sc) + { + assert(l !is null); + + DFAConsequence* cctx = l.context; + assert(cctx !is null); + + if (cctx.var !is var) + { + printf("check scv var %p !is %p\n", cctx.var, var); + fflush(stdout); + } + + assert(cctx.var is var); + } + + sc = sc.parent; + } + } + } +} + +struct DFAAllocator +{ + private + { + static struct Region + { + align(1): + Region* previous; + Region* next; + size_t length; + } + + // 8kb for regions of memory + //enum RegionAllocationStep = 8_192; + // 128kb for regions of memory + enum RegionAllocationStep = 131_072; + // 256kb for regions of memory + //enum RegionAllocationStep = 262_144; + // 1mb for regions of memory + //enum RegionAllocationStep = 1_048_576; + + DFAVar* allocatedlistvar, allocatedlistlastvar; + // We use free lists to reuse memory, during our operation. + DFALabelState* freelistlabel; + DFACaseState* freelistcase; + DFAVar* freelistvar; + DFAScopeVar* freelistscopevar; + DFAScope* freelistscope; + DFALattice* freelistlattice; + DFAConsequence* freelistconsequence; + + Region* currentRegion; + size_t regionUsed; + + __gshared + { + Region* lastRegion; + void[RegionAllocationStep] staticRegion = void; + } + } + + static void deinitialize() + { + import dmd.root.rmem; + + while (lastRegion !is null) + { + void* toFree; + if (lastRegion.previous !is null) + toFree = cast(void*) lastRegion; + lastRegion = lastRegion.previous; + + assert(toFree !is staticRegion.ptr); + if (toFree !is null) + Mem.xfree(toFree); + } + } + + static void checkfreelist() + { + version (none) + { + DFAVar* v = freelistvar; + DFAScopeVar* scv = freelistscopevar; + DFAScope* sc = freelistscope; + DFALattice* l = freelistlattice; + DFAConsequence* c = freelistconsequence; + + while (v !is null) + { + v = v.listnext; + } + + while (scv !is null) + { + scv = scv.listnext; + } + + while (sc !is null) + { + sc = sc.listnext; + } + + while (l !is null) + { + l = l.listnext; + } + + while (c !is null) + { + c = c.listnext; + } + } + } + + DFAVar* makeVar(VarDeclaration vd, DFAVar* childOf = null) + { + DFAVar** bucket; + + if (childOf !is null) + { + bucket = &childOf.childVars[(cast(size_t) cast(void*) vd) % childOf.childVars.length]; + + while (*bucket !is null && cast(void*)(*bucket).next < cast(void*) vd) + { + bucket = &(*bucket).next; + } + + if (*bucket !is null && (*bucket).var is vd) + return *bucket; + } + + DFAVar* ret = allocInternal!DFAVar(freelistvar); + ret.var = vd; + ret.base1 = childOf; + ret.offsetFromBase = -1; + + if (vd !is null) + applyType(ret, vd); + + if (childOf !is null) + { + ret.haveInfiniteLifetime = childOf.haveInfiniteLifetime; + ret.next = *bucket; + *bucket = ret; + } + + if (this.allocatedlistlastvar is null) + { + this.allocatedlistlastvar = ret; + this.allocatedlistvar = ret; + } + else + { + ret.listnext = this.allocatedlistvar; + this.allocatedlistvar = ret; + } + + return ret; + } + + DFAScopeVar* makeScopeVar(DFACommon* dfaCommon, DFAVar* var) + { + DFAScopeVar* ret = allocInternal!DFAScopeVar(freelistscopevar); + ret.var = var; + return ret; + } + + DFAScope* makeScope(DFACommon* dfaCommon, DFAScope* parent) + { + DFAScope* ret = allocInternal!DFAScope(freelistscope); + ret.dfaCommon = dfaCommon; + ret.parent = parent; + return ret; + } + + DFALattice* makeLattice(DFACommon* dfaCommon) + { + DFALattice* ret = allocInternal!DFALattice(freelistlattice); + ret.dfaCommon = dfaCommon; + return ret; + } + + DFAConsequence* makeConsequence(DFAVar* var, DFAConsequence* copyFrom = null) + { + DFAConsequence* ret = allocInternal!DFAConsequence(freelistconsequence); + + if (copyFrom is null) + { + ret.var = var; + } + else + { + *ret = *copyFrom; + ret.previous = null; + ret.next = null; + } + + return ret; + } + + DFALabelState* makeLabelState(Identifier ident) + { + DFALabelState* ret = allocInternal!DFALabelState(freelistlabel); + ret.ident = ident; + return ret; + } + + DFACaseState* makeCaseState(Statement caseStatement) + { + DFACaseState* ret = allocInternal!DFACaseState(freelistcase); + ret.caseStatement = caseStatement; + return ret; + } + + void free(DFAScopeVar* s) + { + s.lr = DFALatticeRef.init; + s.lrGatePredicate = DFALatticeRef.init; + s.lrGateNegatedPredicate = DFALatticeRef.init; + s.var = null; + s.next = null; + + s.listnext = freelistscopevar; + freelistscopevar = s; + } + + void free(DFAScope* s) + { + version (all) + { + DFAScope* current = s.dfaCommon.currentDFAScope; + + while (current !is null) + { + assert(current !is s); + current = current.parent; + } + } + + s.parent = null; + s.child = null; + s.previousLoopyLabel = null; + s.previousCatch = null; + + s.controlStatement = null; + s.compoundStatement = null; + s.tryFinallyStatement = null; + + s.beforeScopeState = DFAScopeRef.init; + s.afterScopeState = DFAScopeRef.init; + + foreach (ref bucket; s.buckets) + { + DFAScopeVar* next; + + while (bucket !is null) + { + next = bucket.next; + this.free(bucket); + bucket = next; + } + } + + s.listnext = freelistscope; + freelistscope = s; + } + + void free(DFALattice* l) + { + + l.firstInSequence = null; + l.lastInSequence = null; + l.constant = null; + l.context = null; + + l.listnext = freelistlattice; + freelistlattice = l; + } + + void free(DFAConsequence* c) + { + c.listnext = freelistconsequence; + freelistconsequence = c; + } + +private: + T* allocInternal(T)(ref T* freelist) + { + import core.stdc.string; + import dmd.root.rmem; + + T* ret = freelist; + + if (ret !is null) + { + freelist = freelist.listnext; + } + else + { + if (currentRegion is null) + { + Region* got = cast(Region*) staticRegion.ptr; + + if (lastRegion is null) + *got = Region(null, null, RegionAllocationStep); + + currentRegion = got; + regionUsed = Region.sizeof; + } + else if (regionUsed + T.sizeof >= currentRegion.length) + { + if (currentRegion.next !is null) + { + currentRegion = currentRegion.next; + regionUsed = Region.sizeof; + } + else + { + Region* got = cast(Region*) Mem.xmalloc(RegionAllocationStep); + assert(got !is null); + + *got = Region(currentRegion, null, RegionAllocationStep); + currentRegion.next = got; + currentRegion = got; + + lastRegion = got; + regionUsed = Region.sizeof; + } + } + + assert(currentRegion !is null); + assert(regionUsed + T.sizeof <= currentRegion.length); + + void* pos = cast(void*) currentRegion + regionUsed; + ret = cast(T*) pos; + regionUsed += T.sizeof; + } + + // Initialize it to the right type + T valInit; + memcpy(ret, &valInit, T.sizeof); + + assert(ret !is null); + return ret; + } +} + +struct DFALabelState +{ + private + { + DFALabelState* listnext; + DFALabelState* next; + } + + Identifier ident; + DFAScopeRef scr; +} + +struct DFACaseState +{ + private + { + DFACaseState* listnext; + DFACaseState* next; + } + + Statement caseStatement; // default case or case + DFAScopeRef containing; + DFAScopeRef jumpedTo; // When its jumped to this case, this is the meet'd state +} + +struct DFAVar +{ + private + { + DFAVar* listnext; + DFAVar* next; + DFAVar*[16] childVars; + DFAVar* childOffsetVars; + DFAVar* indexVar; + DFAVar* lengthVar; + } + + DFAVar* base1; + DFAVar* base2; + + VarDeclaration var; + dinteger_t offsetFromBase; // -1 if its not an offset + + bool isAnIndex; // base1[index] = this + bool isLength; // T[].length + + bool isTruthy; + bool isNullable; + + bool isBoolean; + bool isStaticArray; + bool isByRef; + + bool haveInfiniteLifetime; + + int declaredAtDepth; + int writeCount; + + DFAVar* dereferenceVar; // child var + + bool unmodellable; // DO NOT REPORT!!!! + int assertedCount; + + ParameterDFAInfo* param; + + bool haveBase() + { + return this.base1 !is null; + } + + /// Finds the root variables for this one, where base1 is null + void walkRoots(scope void delegate(DFAVar* var) del) + { + void handle(DFAVar* temp) + { + while (temp.base1 !is null && temp.base2 is null) + { + temp = temp.base1; + } + + if (temp.base2 !is null) + { + handle(temp.base1); + handle(temp.base2); + } + else + del(temp); + } + + handle(&this); + } + + /// Walk all variables that end up at a root + void walkToRoot(scope void delegate(DFAVar* var) del) + { + void handle(DFAVar* temp) + { + while (temp.base1 !is null && temp.base2 is null) + { + del(temp); + temp = temp.base1; + } + + if (temp.base2 !is null) + { + handle(temp.base1); + handle(temp.base2); + } + else + del(temp); + } + + handle(&this); + } + + /// Visit the base1 and base2 if present + void visitFirstBase(scope void delegate(DFAVar* var) del) + { + if (this.base1 is null) + return; + + del(this.base1); + + if (this.base2 !is null) + del(this.base2); + } + + void visitDereferenceBases(scope void delegate(DFAVar* var) del) + { + void handle(DFAVar* var) + { + while (var.base2 is null && var.base1 !is null + && (var.base1.dereferenceVar is var + || (var.offsetFromBase != -1 && var.var is null))) + { + var = var.base1; + } + + if (var.base2 !is null) + { + handle(var.base1); + handle(var.base2); + } + else + del(var); + } + + handle(&this); + } + + /// If this variable is a reference to another variable, visit the base variable. + void visitIfReferenceToAnotherVar(scope void delegate(DFAVar* var) del) + { + void handle(DFAVar* var, int refed) + { + while (var.base2 is null && var.base1 !is null) + { + if (var.offsetFromBase != -1 && var.var is null) + refed++; + else if (var.base1.dereferenceVar is var) + refed++; + else if (var.base1.indexVar is var) + refed++; + else + break; + + var = var.base1; + } + + if (var.base2 !is null) + { + handle(var.base1, refed); + handle(var.base2, refed); + } + else if (refed != 0) + del(var); + } + + handle(&this, 0); + } + + /// If this variable is a reference to another, takes into account dereferencing. + void visitReferenceToAnotherVar(scope void delegate(DFAVar* var) del) + { + void handle(DFAVar* var, int refed) + { + while (var.base2 is null && var.base1 !is null) + { + if (var.offsetFromBase != -1 && var.var is null) + refed++; + else if (var.base1.dereferenceVar is var) + refed--; + else if (var.base1.indexVar is var) + refed++; + else + break; + + var = var.base1; + } + + if (var.base2 !is null) + { + handle(var.base1, refed); + handle(var.base2, refed); + } + else if (refed > 0) + del(var); + } + + handle(&this, 0); + } + + bool isModellable() + { + bool ret = true; + + void handle(DFAVar* var) + { + if (var.base1 is null) + { + if (var.unmodellable) + ret = false; + } + else + { + handle(var.base1); + if (ret && var.base2 !is null) + handle(var.base2); + } + } + + handle(&this); + return ret; + } + +} + +struct DFAScopeVar +{ + private + { + DFAScopeVar* listnext; + DFAScopeVar* next; + } + + DFAVar* var; + DFALatticeRef lr; + + int gatePredicateWriteCount; + DFALatticeRef lrGatePredicate; + DFALatticeRef lrGateNegatedPredicate; + + int derefDepth; + int derefAssertedDepth; + + int assignDepth; + int assertDepth, assertTrueDepth, assertFalseDepth; + + DFAScopeVarMergable mergable; +} + +struct DFAScopeVarMergable +{ + int nullAssignWriteCount; + int nullAssignAssertedCount; + + void merge(DFAScopeVarMergable other) + { + if (other.nullAssignWriteCount > this.nullAssignWriteCount) + this.nullAssignWriteCount = other.nullAssignWriteCount; + if (other.nullAssignAssertedCount > this.nullAssignAssertedCount) + this.nullAssignAssertedCount = other.nullAssignAssertedCount; + } +} + +struct DFAScopeRef +{ + package DFAScope* sc; + + static if (DFACleanup) + { + this(ref DFAScopeRef other) + { + this.sc = other.sc; + other.sc = null; + } + + ~this() + { + if (sc is null) + return; + + sc.dfaCommon.allocator.free(sc); + sc = null; + } + } + + bool isNull() + { + return sc is null; + } + + DFAScopeVar* findScopeVar(DFAVar* contextVar) + { + if (sc is null) + return null; + + return sc.findScopeVar(contextVar); + } + + DFAScopeVar* getScopeVar(DFAVar* contextVar) + { + if (sc is null) + return null; + + return this.sc.getScopeVar(contextVar); + } + + DFALatticeRef consumeNext(out DFAVar* contextVar, out DFAScopeVarMergable mergable) + { + if (sc is null) + return DFALatticeRef.init; + + foreach (ref bucket; sc.buckets) + { + if (bucket is null) + continue; + + DFAScopeVar* scv = bucket; + contextVar = scv.var; + mergable = scv.mergable; + bucket = scv.next; + + DFALatticeRef lr = scv.lr; + sc.dfaCommon.allocator.free(scv); + return lr; + } + + return DFALatticeRef.init; + } + + DFALatticeRef consumeVar(DFAVar* contextVar, out DFAScopeVarMergable mergable) + { + if (sc is null) + return DFALatticeRef.init; + + DFAScopeVar** bucket = &sc.buckets[cast(size_t) contextVar % sc.buckets.length]; + + while (*bucket !is null && (*bucket).var < contextVar) + bucket = &(*bucket).next; + + if (*bucket is null || (*bucket).var !is contextVar) + return DFALatticeRef.init; + + DFAScopeVar* scv = *bucket; + mergable = scv.mergable; + DFALatticeRef lr = scv.lr; + + *bucket = scv.next; + sc.dfaCommon.allocator.free(scv); + return lr; + } + + DFAScopeVar* assignLattice(DFAVar* contextVar, DFALatticeRef lr) + { + if (this.isNull) + return null; + this.check; + + DFAScopeVar* ret = sc.assignLattice(contextVar, lr); + + this.check; + return ret; + } + + void printStructure(const(char)* prefix = "", int sdepth = 0, + FuncDeclaration currentFunction = null, int depth = 0) + { + if (this.isNull) + return; + + this.sc.printStructure(prefix, sdepth, currentFunction, depth); + } + + void printState(const(char)* prefix = "", int sdepth = 0, + FuncDeclaration currentFunction = null, int depth = 0) + { + if (this.isNull) + return; + + this.sc.printState(prefix, sdepth, currentFunction, depth); + } + + int opApply(scope int delegate(DFALattice*) dg) + { + if (this.sc is null) + return 0; + + return this.sc.opApply(dg); + } + + int opApply(scope int delegate(DFAVar*, DFALattice*) dg) + { + if (this.sc is null) + return 0; + + return this.sc.opApply(dg); + } + + int opApply(scope int delegate(DFAVar*, DFALattice*, DFAScopeVar*) dg) + { + if (this.sc is null) + return 0; + + return this.sc.opApply(dg); + } + + DFAScopeRef copy() + { + if (this.isNull) + return DFAScopeRef.init; + + return this.sc.copy; + } + + void check() + { + if (!this.isNull) + this.sc.check; + } +} + +struct DFAScope +{ + private + { + DFACommon* dfaCommon; + DFAScope* listnext; + DFAScope* previousLoopyLabel; + DFAScope* previousCatch; + } + + DFAScope* parent, child; + DFAScopeVar*[16] buckets; + int depth; + + bool haveJumped; // thrown, goto, break, continue, return + bool haveReturned; + bool isLoopyLabel; // Is a loop or label + bool isLoopyLabelKnownToHaveRun; // was the loopy label guaranteed to have at least one iteration? + bool inConditional; + bool sideEffectFree; // No side effects should be stored in this scope use a parent instead. + + Statement controlStatement; // needed to apply on iteration for continue, loops switch statements ext. + Identifier label; + + CompoundStatement compoundStatement; + size_t inProgressCompoundStatement; + + TryFinallyStatement tryFinallyStatement; + + DFAScopeRef beforeScopeState, afterScopeState; + + DFALattice* findLattice(DFAVar* contextVar) + { + assert(contextVar !is null); // if this is null idk what is going on! + + DFAScopeVar** bucket = &this.buckets[cast(size_t) contextVar % this.buckets.length]; + + while (*bucket !is null && (*bucket).var < contextVar) + { + bucket = &(*bucket).next; + } + + if (*bucket is null || (*bucket).var !is contextVar) + return null; + + DFAConsequence* cctx = (*bucket).lr.getContext; + if (cctx !is null) + { + assert(cctx.var is contextVar); + } + + return (*bucket).lr.lattice; + } + + DFAScopeVar* findScopeVar(DFAVar* contextVar) + { + assert(contextVar !is null); // if this is null idk what is going on! + + DFAScopeVar** bucket = &this.buckets[cast(size_t) contextVar % this.buckets.length]; + + while (*bucket !is null && (*bucket).var < contextVar) + bucket = &(*bucket).next; + + if (*bucket is null || (*bucket).var !is contextVar) + return null; + return *bucket; + } + + DFAScopeVar* getScopeVar(DFAVar* contextVar) + { + if (contextVar is null) + return null; + + this.check; + DFAScopeVar** bucket = &buckets[cast(size_t) contextVar % buckets.length]; + + while (*bucket !is null && (*bucket).var < contextVar) + bucket = &(*bucket).next; + + DFAScopeVar* scv = *bucket; + + if (scv is null || scv.var !is contextVar) + { + scv = dfaCommon.allocator.makeScopeVar(dfaCommon, contextVar); + + DFALatticeRef temp = dfaCommon.makeLatticeRef; + temp.setContext(contextVar); + scv.lr = temp; + + scv.next = *bucket; + *bucket = scv; + } + + this.check; + return scv; + } + + DFAScopeVar* createAndInheritLattice(DFAVar* contextVar, DFALattice* copyFrom) + { + assert(contextVar !is null); // if this is null idk what is going on! + + DFAScopeVar** bucket = &this.buckets[cast(size_t) contextVar % this.buckets.length]; + + while (*bucket !is null && (*bucket).var < contextVar) + bucket = &(*bucket).next; + + DFAScopeVar* scv = *bucket; + + if (scv is null || scv.var !is contextVar) + { + scv = dfaCommon.allocator.makeScopeVar(dfaCommon, contextVar); + scv.next = *bucket; + *bucket = scv; + } + + if (scv.lr.isNull) + { + scv.lr = copyFrom !is null ? copyFrom.copy : dfaCommon.makeLatticeRef; + scv.lr.setContext(contextVar); + } + + return scv; + } + + DFAScopeVar* assignLattice(DFAVar* contextVar, DFALatticeRef lr) + { + if (lr.isNull) + return null; + + DFAScopeVar** bucket = &this.buckets[cast(size_t) contextVar % this.buckets.length]; + + while (*bucket !is null && (*bucket).var < contextVar) + bucket = &(*bucket).next; + + DFAScopeVar* scv = *bucket; + + if (scv is null || scv.var !is contextVar) + { + scv = dfaCommon.allocator.makeScopeVar(this.dfaCommon, contextVar); + scv.next = *bucket; + *bucket = scv; + } + + lr.setContext(contextVar); + scv.lr = lr; + scv.lr.check; + + return scv; + } + + void printStructure(const(char)* prefix = "", int sdepth = 0, + FuncDeclaration currentFunction = null, int depth = 0) + { + static if (!this.dfaCommon.debugStructure) + return; + else + printActual(prefix, sdepth, currentFunction, depth); + } + + void printState(const(char)* prefix = "", int sdepth = 0, + FuncDeclaration currentFunction = null, int depth = 0) + { + static if (!this.dfaCommon.debugIt) + return; + else + printActual(prefix, sdepth, currentFunction, depth); + } + + private void printActual(const(char)* prefix = "", int sdepth = 0, + FuncDeclaration currentFunction = null, int depth = 0) + { + printPrefix("%s Scope", sdepth, currentFunction, depth, prefix); + printf(" %p depth=%d, completed=%d:%d", &this, this.depth, + this.haveReturned, this.haveJumped); + + if (this.label !is null) + printf(", label=`%s`\n", this.label.toChars); + else + printf("\n"); + + if (!this.beforeScopeState.isNull) + { + printPrefix("%s before scope state:\n", sdepth, currentFunction, depth, prefix); + this.beforeScopeState.sc.printActual(prefix, sdepth, currentFunction, depth + 1); + } + + if (!this.afterScopeState.isNull) + { + printPrefix("%s after scope state:\n", sdepth, currentFunction, depth, prefix); + this.afterScopeState.sc.printActual(prefix, sdepth, currentFunction, depth + 1); + } + + printPrefix("%s scv's:\n", sdepth, currentFunction, depth, prefix); + foreach (contextVar, l, scv; this) + { + printPrefix("%s on %p", sdepth, currentFunction, depth + 1, prefix, contextVar); + + if (contextVar !is null) + { + printf(";%d", contextVar.declaredAtDepth); + + if (contextVar.base1 !is null) + printf(":%p", contextVar.base1); + if (contextVar.base2 !is null) + printf(":%p", contextVar.base2); + + if (contextVar.var !is null) + printf("@%p=`%s`", contextVar.var, contextVar.var.toChars); + + printf(", unmodel=%d, write=%d", contextVar.unmodellable, contextVar.writeCount); + printf(", deref=%d:%d", scv.derefDepth, scv.derefAssertedDepth); + printf(", assign=%d, assert=%d/%d/%d", scv.assignDepth, + scv.assertDepth, scv.assertTrueDepth, scv.assertFalseDepth); + } + + printf(", nullassign=%d\n", scv.mergable.nullAssignWriteCount); + + if (this.isLoopyLabel) + { + printPrefix("%s predicate:\n", sdepth, currentFunction, depth, prefix); + scv.lrGatePredicate.printActual(prefix, sdepth, currentFunction, depth + 1); + printPrefix("%s !predicate:\n", sdepth, currentFunction, depth, prefix); + scv.lrGateNegatedPredicate.printActual(prefix, sdepth, currentFunction, depth + 1); + } + + printPrefix("%s lattice:\n", sdepth, currentFunction, depth, prefix); + l.printActual(prefix, sdepth, currentFunction, depth + 1); + } + } + + DFAScopeRef copy() + { + DFAScopeRef ret; + ret.sc = dfaCommon.allocator.makeScope(this.dfaCommon, this.parent); + ret.sc.depth = this.depth; + + // not everything is copied over as it isn't important + + foreach (var, lr, scv; this) + { + ret.sc.createAndInheritLattice(var, lr); + } + + ret.check; + return ret; + } + + void check() + { + static if (DFACommon.debugVerify) + { + foreach (contextVar1, l1; this) + { + assert(l1 !is null); + + DFALatticeRef lr1; + lr1.lattice = l1; + + size_t count; + + foreach (contextVar2, l2; this) + { + if (contextVar1 is contextVar2) + count++; + } + + assert(count == 1); + lr1.check; + + lr1.lattice = null; + } + } + } + + int opApply(scope int delegate(DFALattice*) dg) + { + int ret; + + foreach (scv; this.buckets) + { + while (scv !is null) + { + ret = dg(scv.lr.lattice); + if (ret) + return ret; + + scv = scv.next; + } + } + + return ret; + } + + int opApply(scope int delegate(DFAVar*, DFALattice*) dg) + { + int ret; + + foreach (scv; this.buckets) + { + while (scv !is null) + { + ret = dg(scv.var, scv.lr.lattice); + if (ret) + return ret; + + scv = scv.next; + } + } + + return ret; + } + + int opApply(scope int delegate(DFAVar*, DFALattice*, DFAScopeVar*) dg) + { + int ret; + + foreach (scv; this.buckets) + { + while (scv !is null) + { + ret = dg(scv.var, scv.lr.lattice, scv); + if (ret) + return ret; + + scv = scv.next; + } + } + + return ret; + } +} + +struct DFALatticeRef +{ + package DFALattice* lattice; + + static if (DFACleanup) + { + this(ref DFALatticeRef other) + { + this.lattice = other.lattice; + other.lattice = null; + } + + ~this() + { + if (isNull) + return; + + DFAConsequence* c = lattice.lastInSequence; + + while (c !is null) + { + DFAConsequence* next = c.next; + assert(next !is c); + + lattice.dfaCommon.allocator.free(c); + c = next; + } + + lattice.lastInSequence = null; + + if (lattice.constant !is null) + { + lattice.dfaCommon.allocator.free(lattice.constant); + lattice.constant = null; + } + + lattice.dfaCommon.allocator.free(lattice); + } + } + + bool isNull() + { + return lattice is null; + } + + bool haveNonContext() + { + if (isNull) + return false; + + DFAConsequence* cctx = this.getContext; + + foreach (c; this) + { + if (c !is cctx) + return true; + } + + return false; + } + + bool isModellable() + { + bool ret = true; + + bool walker(DFAConsequence* c) + { + if (c.var !is null && !c.var.isModellable) + { + ret = false; + return false; + } + + return true; + } + + this.walkMaybeTops(&walker); + return ret; + } + + DFAConsequence* findConsequence(DFAVar* var) + { + if (isNull) + return null; + + return lattice.findConsequence(var); + } + + DFAConsequence* addConsequence(DFAVar* var, DFAConsequence* copyFrom = null) + { + if (this.isNull) + return null; + + return this.lattice.addConsequence(var, copyFrom); + } + + DFAConsequence* getContext() + { + if (this.isNull) + return null; + + return this.lattice.context; + } + + DFAConsequence* getContext(out DFAVar* var) + { + if (this.isNull) + return null; + + var = this.lattice.context.var; + return this.lattice.context; + } + + DFAVar* getContextVar() + { + if (this.isNull || this.lattice.context is null) + return null; + return this.lattice.context.var; + } + + DFAConsequence* setContext(DFAConsequence* c) + { + if (c is null) + return null; + + this.lattice.context = c; + return c; + } + + DFAConsequence* setContext(DFAVar* var) + { + if (isNull) + return null; + + DFAConsequence* ret = this.addConsequence(var); + this.lattice.context = ret; + return ret; + } + + DFAConsequence* getGateConsequence() + { + if (isNull || lattice.context is null) + return null; + else if (lattice.context.var !is null && lattice.context.maybe is null) + return lattice.context; + else if (lattice.context.var is null && lattice.context.maybe !is null) + { + if (DFAConsequence* c = this.findConsequence(lattice.context.maybe)) + return c.maybe is null ? c : null; + } + + return null; + } + + DFAVar* getGateConsequenceVariable() + { + if (isNull || lattice.context is null) + return null; + else if (lattice.context.var !is null && lattice.context.maybe is null) + return lattice.context.var; + else if (lattice.context.var is null && lattice.context.maybe !is null) + { + if (DFAConsequence* c = this.findConsequence(lattice.context.maybe)) + return c.maybe is null ? c.var : null; + } + + return null; + } + + DFAConsequence* acquireConstantAsContext() + { + assert(!isNull); + return this.lattice.acquireConstantAsContext; + } + + DFAConsequence* acquireConstantAsContext(Truthiness truthiness, Nullable nullable) + { + assert(!isNull); + + DFAConsequence* ret = this.addConsequence(cast(DFAVar*) null); + this.setContext(ret); + + ret.truthiness = truthiness; + ret.nullable = nullable; + return ret; + } + + /// DFAConsequence.maybeTopSeen will be set on the DFAConsequence if it was visited + void walkMaybeTops(scope bool delegate(DFAConsequence*) del) + { + if (isNull || del is null) + return; + + this.lattice.walkMaybeTops(del); + } + + void cleanupConstant(DFAVar* contextVar) + { + if (!isNull) + this.lattice.cleanupConstant(contextVar); + } + + int opApply(scope int delegate(DFAConsequence* consequence) dg) + { + if (isNull) + return 0; + + return this.lattice.opApply(dg); + } + + void printStructure(const(char)* prefix = "", int sdepth = 0, + FuncDeclaration currentFunction = null, int depth = 0) + { + if (this.isNull) + return; + this.lattice.printStructure(prefix, sdepth, currentFunction, depth); + } + + void printState(const(char)* prefix = "", int sdepth = 0, + FuncDeclaration currentFunction = null, int depth = 0) + { + if (this.isNull) + return; + this.lattice.printState(prefix, sdepth, currentFunction, depth); + } + + void printActual(const(char)* prefix = "", int sdepth = 0, + FuncDeclaration currentFunction = null, int depth = 0) + { + if (this.isNull) + return; + this.lattice.printActual(prefix, sdepth, currentFunction, depth); + } + + DFALatticeRef copy() + { + if (this.lattice is null) + return DFALatticeRef.init; + return this.lattice.copy(); + } + + DFALatticeRef copyWithoutInfiniteLifetime() + { + if (this.lattice is null) + return DFALatticeRef.init; + return this.lattice.copyWithoutInfiniteLifetime(); + } + + void check() + { + if (!isNull) + this.lattice.check; + } +} + +struct DFALattice +{ + private + { + DFALattice* listnext; + + DFACommon* dfaCommon; + DFAConsequence* firstInSequence, lastInSequence; + DFAConsequence*[16] buckets; + + DFAConsequence* constant; + } + + DFAConsequence* context; + + DFAConsequence* findConsequence(DFAVar* var) + { + if (var is null) + return this.constant; + + DFAConsequence** bucket = this.findBucketForVar(var); + if (*bucket !is null && (*bucket).var is var) + return *bucket; + else + return null; + } + + DFAConsequence* addConsequence(DFAVar* var, DFAConsequence* copyFrom = null) + { + DFAConsequence* ret; + + if (var is null) + { + ret = dfaCommon.allocator.makeConsequence(var, copyFrom); + this.constant = ret; + } + else + { + DFAConsequence** bucket = this.findBucketForVar(var); + if (*bucket !is null && (*bucket).var is var) + return *bucket; + + ret = dfaCommon.allocator.makeConsequence(var, copyFrom); + + if (this.lastInSequence !is null) + this.lastInSequence.previous = ret; + if (this.firstInSequence is null) + this.firstInSequence = ret; + + ret.next = this.lastInSequence; + this.lastInSequence = ret; + + if (copyFrom !is null) + { + ret.invertedOnce = copyFrom.invertedOnce; + ret.protectElseNegate = copyFrom.protectElseNegate; + ret.writeOnVarAtThisPoint = copyFrom.writeOnVarAtThisPoint; + } + else + { + ret.writeOnVarAtThisPoint = var.writeCount; + } + + ret.bucketNext = *bucket; + *bucket = ret; + } + + assert(ret !is ret.next); + return ret; + } + + DFAConsequence** findBucketForVar(DFAVar* var) + { + DFAConsequence** bucket = &buckets[cast(size_t) var % buckets.length]; + + while (*bucket !is null && (*bucket).var < var) + { + bucket = &(*bucket).bucketNext; + } + + return bucket; + } + + DFAConsequence* acquireConstantAsContext() + { + DFAConsequence* ret = this.addConsequence(cast(DFAVar*) null); + this.context = ret; + + ret.truthiness = Truthiness.Unknown; + ret.nullable = Nullable.Unknown; + return ret; + } + + /// DFAConsequence.maybeTopSeen will be set on the DFAConsequence if it was visited + void walkMaybeTops(scope bool delegate(DFAConsequence*) del) + { + bool handle(DFAConsequence* c) + { + if (c is null || c.maybeTopSeen) + return true; + + c.maybeTopSeen = true; + if (!del(c)) + return false; + + if (handle(this.findConsequence(c.maybe))) + return true; + return false; + } + + foreach (c; this) + { + c.maybeTopSeen = false; + } + + if (DFAConsequence* c = this.context) + { + if (c.var !is null && c.maybe is null) + handle(c); + } + + foreach (c; this) + { + if (c.maybeTopSeen) + continue; + + if (c.maybe !is null) + { + if (!handle(c)) + break; + } + } + } + + void printStructure(const(char)* prefix = "", int sdepth = 0, + FuncDeclaration currentFunction = null, int depth = 0) + { + static if (!dfaCommon.debugStructure) + return; + else + printActual(prefix, sdepth, currentFunction, depth); + } + + void printState(const(char)* prefix = "", int sdepth = 0, + FuncDeclaration currentFunction = null, int depth = 0) + { + static if (!dfaCommon.debugIt) + return; + else + printActual(prefix, sdepth, currentFunction, depth); + } + + private void printActual(const(char)* prefix = "", int sdepth = 0, + FuncDeclaration currentFunction = null, int depth = 0) + { + printPrefix("%s Lattice:\n", sdepth, currentFunction, depth, prefix); + + foreach (consequence; this) + { + consequence.print(prefix, sdepth, currentFunction, depth, consequence is this.context); + } + } + + int opApply(scope int delegate(DFAConsequence* consequence) dg) + { + DFAConsequence* c = this.lastInSequence; + int i; + + while (c !is null) + { + i = dg(c); + if (i) + return i; + + assert(c !is c.next); + c = c.next; + } + + if (this.constant !is null) + return dg(this.constant); + else + return 0; + } + + DFALatticeRef copy() + { + DFALatticeRef ret = dfaCommon.makeLatticeRef; + + if (this.constant !is null) + { + DFAConsequence* newC = ret.addConsequence(null, this.constant); + + if (this.context is this.constant) + ret.setContext(newC); + } + + DFAConsequence* oldC = this.firstInSequence; + + while (oldC !is null) + { + DFAConsequence* newC = ret.addConsequence(oldC.var, oldC); + + if (this.context is oldC) + ret.setContext(newC); + + oldC = oldC.previous; + } + + ret.check; + return ret; + } + + DFALatticeRef copyWithoutInfiniteLifetime() + { + DFALatticeRef ret = dfaCommon.makeLatticeRef; + + if (this.constant !is null) + { + DFAConsequence* newC = ret.addConsequence(null, this.constant); + + if (this.context is this.constant) + ret.setContext(newC); + } + + DFAConsequence* oldC = this.firstInSequence; + + while (oldC !is null) + { + if (!oldC.var.haveInfiniteLifetime) + { + DFAConsequence* newC = ret.addConsequence(oldC.var, oldC); + + if (this.context is oldC) + ret.setContext(newC); + + } + oldC = oldC.previous; + } + + if (ret.getContext is null) + ret.acquireConstantAsContext; + + ret.check; + return ret; + } + + /// Remove constant if not context + void cleanupConstant(DFAVar* contextVar) + { + if (contextVar is null) + return; + + if (this.constant !is null) + { + dfaCommon.allocator.free(this.constant); + + if (this.context is this.constant) + this.context = this.addConsequence(contextVar); + + this.constant = null; + } + } + + void check() + { + static if (DFACommon.debugVerify) + { + assert((this.firstInSequence is null && this.constant is null) || this.context !is null); + + foreach (c1; this) + { + size_t countFind, countPrevious; + bool foundOurPrevious = c1.previous is null; + + foreach (c2; this) + { + if (c1.var is c2.var) + countFind++; + if (c2.previous is c1) + countPrevious++; + if (c1.previous !is null && c1.previous is c2) + foundOurPrevious = true; + } + + if (firstInSequence is c1) + countPrevious++; + + assert(countFind == 1); + assert(countPrevious <= 1); + assert(foundOurPrevious); + } + + { + DFAConsequence* temp = lastInSequence; + + while (temp !is null) + { + assert(temp.listnext is null); + temp = temp.next; + } + } + + { + DFAConsequence* temp = firstInSequence; + + while (temp !is null) + { + assert(temp.listnext is null); + temp = temp.previous; + } + } + } + } +} + +enum Truthiness : ubyte +{ + Unknown, // unmodelled + Maybe, // if assert'd non-constant consequences apply in true branch + False, // if false branch of if statement will be taken + True, // if true branch of if statement will be taken +} + +enum Nullable : ubyte +{ + Unknown, + Null, + NonNull +} + +struct DFAConsequence +{ + private + { + DFAConsequence* listnext; + DFAConsequence* previous, next, bucketNext; + } + + // This will be null if it is a constant or effect + DFAVar* var; + // only valid when var.writeCount == writeOnVarAtThisPoint + uint writeOnVarAtThisPoint; + + // Must be asserted to be true, at which point a join takes place + Truthiness truthiness; + // Ditto + Nullable nullable; + // Boolean logic can be inverted once, + // thanks to or and equality expressions we won't be tracking it beyond that one invert. + bool invertedOnce; + // Protect else bodies assertion of the condition from introducing unknowable things + bool protectElseNegate; + // When the context is maybe, look at this instead + DFAVar* maybe; + bool maybeTopSeen; + + void meetConsequence(DFAConsequence* c1, DFAConsequence* c2, bool couldScopeNotHaveRan = false) + { + void doOne(DFAConsequence* c) + { + version (DebugJoinMeetOp) + { + printf("meet one c1 %p %d %d %d\n", c.var, c.truthiness, + c.nullable, c.writeOnVarAtThisPoint); + fflush(stdout); + } + + this.invertedOnce = c.invertedOnce; + this.writeOnVarAtThisPoint = c.writeOnVarAtThisPoint; + + if (this.var is null || this.var.isTruthy) + this.truthiness = couldScopeNotHaveRan ? Truthiness.Unknown : c.truthiness; + if (this.var is null || this.var.isNullable) + this.nullable = couldScopeNotHaveRan ? Nullable.Unknown : c.nullable; + } + + void doMulti() + { + version (DebugJoinMeetOp) + { + printf("meet multi c1 %p %d %d %d\n", c1.var, c1.truthiness, + c1.nullable, c1.writeOnVarAtThisPoint); + printf("meet multi c2 %p %d %d %d\n", c2.var, c2.truthiness, + c2.nullable, c2.writeOnVarAtThisPoint); + fflush(stdout); + } + + this.writeOnVarAtThisPoint = c1.writeOnVarAtThisPoint > c2.writeOnVarAtThisPoint + ? c1.writeOnVarAtThisPoint : c2.writeOnVarAtThisPoint; + + this.invertedOnce = this.truthiness == Truthiness.Unknown + ? false : (c1.invertedOnce || c2.invertedOnce); + + if (this.var is null || this.var.isTruthy) + { + this.truthiness = (couldScopeNotHaveRan && c1.truthiness != c2.truthiness) + ? Truthiness.Unknown : (c1.truthiness < c2.truthiness + ? c1.truthiness : c2.truthiness); + if (this.truthiness == Truthiness.Maybe) + this.truthiness = Truthiness.Unknown; + } + + if (this.var is null || this.var.isNullable) + this.nullable = (couldScopeNotHaveRan && c1.nullable != c2.nullable) + ? Nullable.Unknown : (c1.nullable < c2.nullable ? c1.nullable : c2.nullable); + } + + const writeCount = this.var.writeCount; + + version (DebugJoinMeetOp) + { + printf("meet consequence c1=%p, c2=%p\n", c1, c2); + printf(" vars c1=%p, c2=%p\n", c1 !is null ? c1.var : null, + c2 !is null ? c2.var : null); + printf(" writeCount=%d/%d:%d\n", writeCount, + c1.writeOnVarAtThisPoint, c2 !is null ? c2.writeOnVarAtThisPoint : -1); + printf(" couldScopeNotHaveRan=%d\n", couldScopeNotHaveRan); + fflush(stdout); + } + + if (c2 is null || c2.writeOnVarAtThisPoint < writeCount) + doOne(c1); + else + doMulti; + } + + // c1 may be the same consequence as this + void joinConsequence(DFAConsequence* c1, DFAConsequence* c2, DFAConsequence* rhsCtx, + bool isC1Context, bool ignoreWriteCount = false, bool unknownAware = false) + { + void doOne(DFAConsequence* c) + { + version (DebugJoinMeetOp) + { + printf("join one c %p %d %d %d, isC1=%d, isC2=%d\n", c.var, + c.truthiness, c.nullable, c.writeOnVarAtThisPoint, c is c1, c is c2); + fflush(stdout); + } + + this.invertedOnce = c.invertedOnce; + if (this.var is null || this.var.isTruthy) + this.truthiness = c.truthiness; + if (this.var is null || this.var.isNullable) + this.nullable = c.nullable; + + this.writeOnVarAtThisPoint = c.writeOnVarAtThisPoint; + this.maybe = c.maybe; + } + + void doMulti(DFAConsequence* c2) + { + version (DebugJoinMeetOp) + { + printf("join multi c1 %p %d %d %d\n", c1.var, c1.truthiness, + c1.nullable, c1.writeOnVarAtThisPoint); + printf("join multi c2 %p %d %d %d\n", c2.var, c2.truthiness, + c2.nullable, c2.writeOnVarAtThisPoint); + fflush(stdout); + } + + this.invertedOnce = c1.invertedOnce || c2.invertedOnce; + this.writeOnVarAtThisPoint = c1.writeOnVarAtThisPoint < c2.writeOnVarAtThisPoint + ? c2.writeOnVarAtThisPoint : c1.writeOnVarAtThisPoint; + + if (this.var is null || this.var.isTruthy) + { + if (unknownAware && c1.truthiness == Truthiness.Unknown + || c2.truthiness == Truthiness.Unknown) + this.truthiness = Truthiness.Unknown; + else + this.truthiness = c1.truthiness < c2.truthiness ? c2.truthiness : c1.truthiness; + } + + if (this.var is null || this.var.isNullable) + { + if (unknownAware && c1.nullable == Nullable.Unknown + || c2.nullable == Nullable.Unknown) + this.nullable = Nullable.Unknown; + else + this.nullable = c1.nullable < c2.nullable ? c2.nullable : c1.nullable; + } + + this.maybe = c2.maybe; + + version (DebugJoinMeetOp) + { + printf(" result %d %d\n", this.truthiness, this.nullable); + fflush(stdout); + } + } + + const writeCount = this.var.writeCount; + + version (DebugJoinMeetOp) + { + printf("join consequence c1=%p, c2=%p, rhsCtx=%p\n", c1, c2, rhsCtx); + printf(" vars c1=%p, c2=%p, rhsCtx=%p\n", c1 !is null + ? c1.var : null, c2 !is null ? c2.var : null, rhsCtx !is null ? rhsCtx.var + : null); + printf(" writeCount=%d/%d:%d\n", writeCount, + c1.writeOnVarAtThisPoint, c2 !is null ? c2.writeOnVarAtThisPoint : -1); + printf(" isC1Context=%d, unknownAware=%d, ignoreWriteCount=%d\n", + isC1Context, unknownAware, ignoreWriteCount); + fflush(stdout); + } + + if (ignoreWriteCount) + { + if (c2 !is null) + doMulti(c2); + else + doOne(c1); + } + else if (c2 !is null && c2.writeOnVarAtThisPoint >= writeCount) + { + if (c2.writeOnVarAtThisPoint < c1.writeOnVarAtThisPoint) + doMulti(c2); + else + doOne(c2); + } + else + { + if (isC1Context && rhsCtx !is null && rhsCtx.writeOnVarAtThisPoint == writeCount + && (rhsCtx.var is null || rhsCtx.var is c1.var)) + { + if (rhsCtx.writeOnVarAtThisPoint < c1.writeOnVarAtThisPoint) + doMulti(rhsCtx); + } + else + doOne(c1); + } + } + + void print(const(char)* prefix = "", int sdepth = 0, + FuncDeclaration currentFunction = null, int depth = 0, bool context = false) + { + static immutable TruthinessStr = [ + "unkno".ptr, "maybe".ptr, "false".ptr, " true".ptr + ]; + static immutable NullableStr = ["unkno".ptr, " null".ptr, "!null".ptr]; + + printPrefix(" %s%s ", sdepth, currentFunction, depth, context ? "+".ptr : " ".ptr, prefix); + printf("%p: ", &this); + printf("truthiness=%s, nullable=%s, write=%d, ", TruthinessStr[this.truthiness], + NullableStr[this.nullable], this.writeOnVarAtThisPoint); + printf("maybe=%p:%d, protectElseNegate=%d, invertedOnce=%d ", maybe, + maybeTopSeen, protectElseNegate, invertedOnce); + printf("previous=%p, next=%p ", this.previous, this.next); + + printf("%p", this.var); + if (this.var !is null) + { + printf("=%d:%lld:b/%p/%p", this.var.assertedCount, + this.var.offsetFromBase, this.var.base1, this.var.base2); + + if (this.var !is null && this.var.var !is null) + printf("@%p=`%s`", this.var.var, this.var.var.toChars); + + } + + printf("\n", this.var); + } +} + +private: +void applyType(DFAVar* var, VarDeclaration vd) +{ + var.isNullable = vd.isRef || isTypeNullable(vd.type); + var.isTruthy = isTypeTruthy(vd.type); + + var.isStaticArray = vd.type.isTypeSArray !is null; + var.isBoolean = vd.type.ty == Tbool; + + // Unfortunately isDataseg can have very undesirable side effects that kill compilation, + // even if it shouldn't when this is ran. + if (vd.parent !is null && vd.parent.isFuncDeclaration) + { + // make sure the parent of this variable is a function, if it isn't then we can't model it. + if (!(vd.canTakeAddressOf + && (vd.storage_class & (STC.static_ | STC.extern_ | STC.gshared)) == 0)) + var.unmodellable = true; + } + else + var.unmodellable = true; +} + +void printPrefix(Args...)(ref OutBuffer ob, const(char)* prefix, int sdepth, + FuncDeclaration currentFunction, int edepth, Args args) +{ + ob.printf("%.*s[%p]", sdepth, PrintPipeText.ptr, currentFunction); + + if (edepth == 0) + ob.write(">"); + else + ob.printf(";%.*s>", edepth, PrintPipeText.ptr); + + ob.printf(prefix, args); +} + +void printPrefix(Args...)(const(char)* prefix, int sdepth, + FuncDeclaration currentFunction, int edepth, Args args) +{ + printf("%.*s[%p]", sdepth, PrintPipeText.ptr, currentFunction); + + if (edepth == 0) + printf(">"); + else + printf(";%.*s>", edepth, PrintPipeText.ptr); + + printf(prefix, args); +} diff --git a/dmd/dfa/utils.d b/dmd/dfa/utils.d new file mode 100644 index 0000000000..89679e22c3 --- /dev/null +++ b/dmd/dfa/utils.d @@ -0,0 +1,118 @@ +/** + * Utilities for Data Flow Analysis. + * + * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) + * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) + * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dfa/utils.d, dfa/utils.d) + * Documentation: https://dlang.org/phobos/dmd_dfa_utils.html + * Coverage: https://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/dfa/utils.d + */ +module dmd.dfa.utils; +import dmd.tokens; +import dmd.astenums; +import dmd.mtype; +import dmd.visitor; +import dmd.identifier; +import dmd.expression; + +bool isTypeNullable(Type type) +{ + if (type is null) + return false; + + switch (type.ty) + { + case TY.Tarray, TY.Taarray, TY.Tpointer, TY.Treference, TY.Tfunction, + TY.Tclass, TY.Tdelegate: + return true; + + default: + return false; + } +} + +bool isTypeTruthy(Type type) +{ + if (type is null) + return false; + + switch (type.ty) + { + case TY.Tident: + case TY.Terror: + case TY.Ttypeof: + case TY.Ttuple: + case TY.Treturn: + case TY.Ttraits: + case TY.Tmixin: + case TY.Tnoreturn: + case TY.Ttag: + case TY.Tsarray: + case TY.Tstruct: + return false; + + default: + return true; + } +} + +bool isIndexContextAA(IndexExp ie) +{ + if (ie is null || ie.e1 is null || ie.e1.type is null) + return false; + return ie.e1.type.isTypeAArray !is null; +} + +int concatNullableResult(Type lhs, Type rhs) +{ + // T[] ~ T[] + // T[] ~ T + // T ~ T[] + // T ~ T + + if (lhs.isStaticOrDynamicArray) + { + if (rhs.isStaticOrDynamicArray) + return 1; // Depends on lhs and rhs + return 2; // non-null + } + else if (rhs.isStaticOrDynamicArray) + return 2; + + return 0; // Unknown +} + +int equalityArgTypes(Type lhs, Type rhs) +{ + // struct + // floating point + // lhs && rhs static, dyamic array + // lhs && rhs associative array + // otherwise integral + + if (lhs.ty == Tstruct) + return 1; + else if (lhs.isFloating) + return 2; + + if (rhs is null) + rhs = lhs; // Assume rhs is similar to lhs + + const lhsSArray = lhs.isTypeSArray !is null, rhsSArray = rhs.isTypeSArray !is null; + if (lhsSArray && rhsSArray) + return 3; + else if (lhsSArray) + return 4; + else if (rhsSArray) + return 5; + + if (lhs.isTypeDArray || rhs.isTypeDArray) + return 6; + else if (lhs.ty == Taarray && rhs.ty == Taarray) + return 7; + else if (isTypeNullable(lhs)) + return 8; + else + return 0; +} diff --git a/dmd/dscope.d b/dmd/dscope.d index 7be93edded..f0ecca0be6 100644 --- a/dmd/dscope.d +++ b/dmd/dscope.d @@ -71,6 +71,14 @@ private extern (D) struct FlagBitFields bool canFree; /// is on free list bool fullinst; /// fully instantiate templates bool ctfeBlock; /// inside a `if (__ctfe)` block + + /** + Is any symbol this scope is applied to known to have a compile time only accessible context. + This is not the same as `skipCodegen` nor can it be used to contribute to this. + It is meant for analysis engines to be conservative in what functions they analyse, + to prevent perceived false positives for meta-programming heavy code. + */ + bool knownACompileTimeOnlyContext; } private extern (D) struct NonFlagBitFields @@ -260,6 +268,7 @@ extern (C++) struct Scope s.ctfeBlock = this.ctfeBlock; s.previews = this.previews; s.lastdc = null; + s.knownACompileTimeOnlyContext = this.knownACompileTimeOnlyContext; assert(&this != s); return s; } @@ -642,4 +651,10 @@ extern (C++) struct Scope { return _module && _module.edition >= edition; } + + extern (D) bool isKnownToHaveACompileTimeContext() + { + return this.knownACompileTimeOnlyContext || this.intypeof != 0 || this.traitsCompiles || this.ctfe || + this.condition || this.inTemplateConstraint || this.ctfeBlock; + } } diff --git a/dmd/frontend.h b/dmd/frontend.h index 9590fe253e..a92bde4d49 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -290,6 +290,7 @@ class BinAssignExp; struct InterpolatedSet; struct ContractInfo; struct Symbol; +struct ParametersDFAInfo; struct ObjcSelector; class ErrorInitializer; class VoidInitializer; @@ -3881,6 +3882,7 @@ class FuncDeclaration : public Declaration AttributeViolation* nogcViolation; AttributeViolation* pureViolation; AttributeViolation* nothrowViolation; + ParametersDFAInfo* parametersDFAInfo; bool purityInprocess() const; bool purityInprocess(bool v); bool safetyInprocess() const; @@ -4064,6 +4066,50 @@ class NewDeclaration final : public FuncDeclaration void accept(Visitor* v) override; }; +struct ParameterDFAInfo final +{ + int32_t parameterId; + Fact notNullIn; + Fact notNullOut; + bool specifiedByUser; + enum class Fact : uint8_t + { + Unspecified = 0u, + NotGuaranteed = 1u, + Guaranteed = 2u, + }; + + ParameterDFAInfo() : + parameterId(), + specifiedByUser() + { + } + ParameterDFAInfo(int32_t parameterId, Fact notNullIn = (Fact)0u, Fact notNullOut = (Fact)0u, bool specifiedByUser = false) : + parameterId(parameterId), + notNullIn(notNullIn), + notNullOut(notNullOut), + specifiedByUser(specifiedByUser) + {} +}; + +struct ParametersDFAInfo final +{ + ParameterDFAInfo thisPointer; + ParameterDFAInfo returnValue; + _d_dynamicArray< ParameterDFAInfo > parameters; + ParametersDFAInfo() : + thisPointer(), + returnValue(), + parameters() + { + } + ParametersDFAInfo(ParameterDFAInfo thisPointer, ParameterDFAInfo returnValue = ParameterDFAInfo(), _d_dynamicArray< ParameterDFAInfo > parameters = {}) : + thisPointer(thisPointer), + returnValue(returnValue), + parameters(parameters) + {} +}; + class PostBlitDeclaration final : public FuncDeclaration { public: @@ -5775,6 +5821,8 @@ struct ASTCodegen final using ILS = ::ILS; using InvariantDeclaration = ::InvariantDeclaration; using NewDeclaration = ::NewDeclaration; + using ParameterDFAInfo = ::ParameterDFAInfo; + using ParametersDFAInfo = ::ParametersDFAInfo; using PostBlitDeclaration = ::PostBlitDeclaration; using SharedStaticCtorDeclaration = ::SharedStaticCtorDeclaration; using SharedStaticDtorDeclaration = ::SharedStaticDtorDeclaration; @@ -7193,6 +7241,8 @@ struct Scope final bool fullinst(bool v); bool ctfeBlock() const; bool ctfeBlock(bool v); + bool knownACompileTimeOnlyContext() const; + bool knownACompileTimeOnlyContext(bool v); private: uint16_t bitFields; uint16_t bitFields2; @@ -8369,6 +8419,7 @@ struct Param final bool fix16997; FeatureState dtorFields; FeatureState systemVariables; + bool useFastDFA; CHECKENABLE useInvariants; CHECKENABLE useIn; CHECKENABLE useOut; @@ -8450,6 +8501,7 @@ struct Param final shortenedMethods(true), fixImmutableConv(), fix16997(true), + useFastDFA(), useInvariants((CHECKENABLE)0u), useIn((CHECKENABLE)0u), useOut((CHECKENABLE)0u), @@ -8494,7 +8546,7 @@ struct Param final timeTraceFile() { } - Param(bool obj, bool readStdin = false, bool multiobj = false, bool trace = false, bool tracegc = false, bool vcg_ast = false, DiagnosticReporting useDeprecated = (DiagnosticReporting)1u, bool useUnitTests = false, bool useInline = false, bool release = false, bool preservePaths = false, DiagnosticReporting useWarnings = (DiagnosticReporting)2u, bool cov = false, uint8_t covPercent = 0u, bool ctfe_cov = false, bool ignoreUnsupportedPragmas = true, bool useModuleInfo = true, bool useTypeInfo = true, bool useExceptions = true, bool useGC = true, bool betterC = false, bool addMain = false, bool allInst = false, bool bitfields = true, CppStdRevision cplusplus = (CppStdRevision)201103u, Help help = Help(), Verbose v = Verbose(), Edition edition = (Edition)2023u, void* editionFiles = nullptr, FeatureState useDIP25 = (FeatureState)2u, FeatureState useDIP1000 = (FeatureState)0u, bool ehnogc = false, bool useDIP1021 = false, FeatureState fieldwise = (FeatureState)0u, bool fixAliasThis = false, FeatureState rvalueRefParam = (FeatureState)0u, FeatureState safer = (FeatureState)0u, FeatureState noSharedAccess = (FeatureState)0u, bool previewIn = false, bool inclusiveInContracts = false, bool shortenedMethods = true, bool fixImmutableConv = false, bool fix16997 = true, FeatureState dtorFields = (FeatureState)0u, FeatureState systemVariables = (FeatureState)0u, CHECKENABLE useInvariants = (CHECKENABLE)0u, CHECKENABLE useIn = (CHECKENABLE)0u, CHECKENABLE useOut = (CHECKENABLE)0u, CHECKENABLE useArrayBounds = (CHECKENABLE)0u, CHECKENABLE useAssert = (CHECKENABLE)0u, CHECKENABLE useSwitchError = (CHECKENABLE)0u, CHECKENABLE boundscheck = (CHECKENABLE)0u, CHECKACTION checkAction = (CHECKACTION)0u, CLIIdentifierTable dIdentifierTable = (CLIIdentifierTable)0u, CLIIdentifierTable cIdentifierTable = (CLIIdentifierTable)0u, _d_dynamicArray< const char > argv0 = {}, Array modFileAliasStrings = Array(), Array imppath = Array(), Array fileImppath = Array(), _d_dynamicArray< const char > objdir = {}, _d_dynamicArray< const char > objname = {}, _d_dynamicArray< const char > libname = {}, Output ddoc = Output(), Output dihdr = Output(), Output cxxhdr = Output(), Output json = Output(), JsonFieldFlags jsonFieldFlags = (JsonFieldFlags)0u, Output makeDeps = Output(), Output mixinOut = Output(), Output moduleDeps = Output(), bool debugEnabled = false, bool run = false, Array runargs = Array(), Array cppswitches = Array(), const char* cpp = nullptr, Array objfiles = Array(), Array linkswitches = Array(), Array linkswitchIsForCC = Array(), Array libfiles = Array(), Array dllfiles = Array(), _d_dynamicArray< const char > deffile = {}, _d_dynamicArray< const char > resfile = {}, _d_dynamicArray< const char > exefile = {}, _d_dynamicArray< const char > mapfile = {}, bool fullyQualifiedObjectFiles = false, bool timeTrace = false, uint32_t timeTraceGranularityUs = 500u, const char* timeTraceFile = nullptr) : + Param(bool obj, bool readStdin = false, bool multiobj = false, bool trace = false, bool tracegc = false, bool vcg_ast = false, DiagnosticReporting useDeprecated = (DiagnosticReporting)1u, bool useUnitTests = false, bool useInline = false, bool release = false, bool preservePaths = false, DiagnosticReporting useWarnings = (DiagnosticReporting)2u, bool cov = false, uint8_t covPercent = 0u, bool ctfe_cov = false, bool ignoreUnsupportedPragmas = true, bool useModuleInfo = true, bool useTypeInfo = true, bool useExceptions = true, bool useGC = true, bool betterC = false, bool addMain = false, bool allInst = false, bool bitfields = true, CppStdRevision cplusplus = (CppStdRevision)201103u, Help help = Help(), Verbose v = Verbose(), Edition edition = (Edition)2023u, void* editionFiles = nullptr, FeatureState useDIP25 = (FeatureState)2u, FeatureState useDIP1000 = (FeatureState)0u, bool ehnogc = false, bool useDIP1021 = false, FeatureState fieldwise = (FeatureState)0u, bool fixAliasThis = false, FeatureState rvalueRefParam = (FeatureState)0u, FeatureState safer = (FeatureState)0u, FeatureState noSharedAccess = (FeatureState)0u, bool previewIn = false, bool inclusiveInContracts = false, bool shortenedMethods = true, bool fixImmutableConv = false, bool fix16997 = true, FeatureState dtorFields = (FeatureState)0u, FeatureState systemVariables = (FeatureState)0u, bool useFastDFA = false, CHECKENABLE useInvariants = (CHECKENABLE)0u, CHECKENABLE useIn = (CHECKENABLE)0u, CHECKENABLE useOut = (CHECKENABLE)0u, CHECKENABLE useArrayBounds = (CHECKENABLE)0u, CHECKENABLE useAssert = (CHECKENABLE)0u, CHECKENABLE useSwitchError = (CHECKENABLE)0u, CHECKENABLE boundscheck = (CHECKENABLE)0u, CHECKACTION checkAction = (CHECKACTION)0u, CLIIdentifierTable dIdentifierTable = (CLIIdentifierTable)0u, CLIIdentifierTable cIdentifierTable = (CLIIdentifierTable)0u, _d_dynamicArray< const char > argv0 = {}, Array modFileAliasStrings = Array(), Array imppath = Array(), Array fileImppath = Array(), _d_dynamicArray< const char > objdir = {}, _d_dynamicArray< const char > objname = {}, _d_dynamicArray< const char > libname = {}, Output ddoc = Output(), Output dihdr = Output(), Output cxxhdr = Output(), Output json = Output(), JsonFieldFlags jsonFieldFlags = (JsonFieldFlags)0u, Output makeDeps = Output(), Output mixinOut = Output(), Output moduleDeps = Output(), bool debugEnabled = false, bool run = false, Array runargs = Array(), Array cppswitches = Array(), const char* cpp = nullptr, Array objfiles = Array(), Array linkswitches = Array(), Array linkswitchIsForCC = Array(), Array libfiles = Array(), Array dllfiles = Array(), _d_dynamicArray< const char > deffile = {}, _d_dynamicArray< const char > resfile = {}, _d_dynamicArray< const char > exefile = {}, _d_dynamicArray< const char > mapfile = {}, bool fullyQualifiedObjectFiles = false, bool timeTrace = false, uint32_t timeTraceGranularityUs = 500u, const char* timeTraceFile = nullptr) : obj(obj), readStdin(readStdin), multiobj(multiobj), @@ -8540,6 +8592,7 @@ struct Param final fix16997(fix16997), dtorFields(dtorFields), systemVariables(systemVariables), + useFastDFA(useFastDFA), useInvariants(useInvariants), useIn(useIn), useOut(useOut), diff --git a/dmd/func.d b/dmd/func.d index 05df5f3f0d..4645001191 100644 --- a/dmd/func.d +++ b/dmd/func.d @@ -185,6 +185,40 @@ private struct ContractInfo Expressions* fdensureParams; /// argument list for __ensure } +/// Information for data flow analysis regarding parameters +extern(D) struct ParametersDFAInfo +{ + ParameterDFAInfo thisPointer; + ParameterDFAInfo returnValue; + ParameterDFAInfo[] parameters; +} + +/// Information for data flow analysis per parameter +extern(D) struct ParameterDFAInfo +{ + /// Parameter id: -1 this, -2 return, otherwise it is FuncDeclaration.parameters index + int parameterId; + + /// Is the parameter non-null upon input, only applies to pointers. + Fact notNullIn; + /// Is the parameter non-null, applies only for by-ref parameters that are pointers. + Fact notNullOut; + + /// Was the attributes for this parameter specified by the user? + bool specifiedByUser; + + /// Given a property, has it been specificed and is it guaranteed? + enum Fact : ubyte + { + /// + Unspecified, + /// + NotGuaranteed, + /// + Guaranteed + } +} + /*********************************************************** */ extern (C++) class FuncDeclaration : Declaration @@ -277,6 +311,8 @@ extern (C++) class FuncDeclaration : Declaration AttributeViolation* pureViolation; AttributeViolation* nothrowViolation; + ParametersDFAInfo* parametersDFAInfo; + /// See the `FUNCFLAG` struct import dmd.common.bitfields; mixin(generateBitFields!(FUNCFLAG, uint)); diff --git a/dmd/globals.d b/dmd/globals.d index a54cce3700..57b61b9f1f 100644 --- a/dmd/globals.d +++ b/dmd/globals.d @@ -216,6 +216,7 @@ extern (C++) struct Param FeatureState dtorFields; // destruct fields of partially constructed objects // https://issues.dlang.org/show_bug.cgi?id=14246 FeatureState systemVariables; // limit access to variables marked @system from @safe code + bool useFastDFA; // Use fast data flow analysis engine CHECKENABLE useInvariants = CHECKENABLE._default; // generate class invariant checks CHECKENABLE useIn = CHECKENABLE._default; // generate precondition checks diff --git a/dmd/scope.h b/dmd/scope.h index 0b1d9b66bd..afd9f6c00a 100644 --- a/dmd/scope.h +++ b/dmd/scope.h @@ -126,6 +126,8 @@ struct Scope final bool fullinst(bool v); bool ctfeBlock() const; bool ctfeBlock(bool v); + bool knownACompileTimeOnlyContext() const; + bool knownACompileTimeOnlyContext(bool v); UserAttributeDeclaration *userAttribDecl; // user defined attributes diff --git a/dmd/semantic3.d b/dmd/semantic3.d index 9f794a0a12..d89413f43f 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -75,6 +75,7 @@ import dmd.targetcompiler; import dmd.templateparamsem; import dmd.typesem; import dmd.visitor; +import dmd.dfa.entry; enum LOG = false; @@ -1429,6 +1430,13 @@ private extern(C++) final class Semantic3Visitor : Visitor oblive(funcdecl); } + if (global.params.useFastDFA && global.errors == oldErrors && funcdecl.fbody && funcdecl.type.ty != Terror) + { + // Don't run DFA if there are errors, + // this is a costly enough operation that it warrents the explicit check. + dfaEntry(funcdecl, sc); + } + /* If this function had instantiated with gagging, error reproduction will be * done by TemplateInstance::semantic. * Otherwise, error gagging should be temporarily ungagged by functionSemantic3. diff --git a/dmd/templatesem.d b/dmd/templatesem.d index 7d12609545..796f6827a7 100644 --- a/dmd/templatesem.d +++ b/dmd/templatesem.d @@ -794,6 +794,9 @@ void templateInstanceSemantic(TemplateInstance tempinst, Scope* sc, ArgumentList _scope.minst = tempinst.minst; //scope.stc = STC.none; + if (sc.isKnownToHaveACompileTimeContext) + _scope.knownACompileTimeOnlyContext = true; + // Declare each template parameter as an alias for the argument type Scope* paramscope = _scope.push(); paramscope.stc = STC.none; diff --git a/dmd/timetrace.d b/dmd/timetrace.d index 138d213a42..a29c4027be 100644 --- a/dmd/timetrace.d +++ b/dmd/timetrace.d @@ -179,6 +179,7 @@ enum TimeTraceEventType sema1Function, sema2, sema3, + dfa, ctfe, ctfeCall, codegenGlobal, @@ -200,6 +201,7 @@ private immutable string[] eventPrefixes = [ "Sema1: Function ", "Sema2: ", "Sema3: ", + "DFA: ", "Ctfe: ", "Ctfe: call ", "Code generation", diff --git a/tests/dmd/compilable/fastdfa.d b/tests/dmd/compilable/fastdfa.d new file mode 100644 index 0000000000..d975af7fc9 --- /dev/null +++ b/tests/dmd/compilable/fastdfa.d @@ -0,0 +1,711 @@ +/* + * REQUIRED_ARGS: -preview=fastdfa + */ + +@safe: + +bool isNull1(int* ptr) +{ + return ptr is null; +} + +void isNull2() +{ + int* ptr; + + if (ptr !is null) + { + int v = *ptr; // Will not error due to the null test + } + else + { + } +} + +bool truthinessYes() +{ + return true; +} + +bool truthinessNo() +{ + return false; +} + +int* nullable1(int* ptr) +{ + int* ret; + + if (truthinessYes()) + { + } + else + { + ret = ptr; + } + + int v = *ret; // ideally would error, but not required + return ret; +} + +void nullable2a(S2* head, S2* previous) +{ + S2* start; + + { + S2* current; + + if (start is null) + { + previous = head; + start = previous; + current = start.next; + } + else + { + current = start.next; + } + + previous = current.next; // should not error + } +} + +void nullable2b(S2* start, S2* head, S2* previous) +{ + { + S2* current; + + if (start is null) + { + previous = head; + start = previous; + current = start.next; + } + else + { + current = start.next; + } + + previous = current.next; // should not error + } +} + +void nullable3(S2** nextParent, S2* r) +{ + if (*nextParent is null) + *nextParent = r; // should not error +} + +void nullable4(int* temp) @trusted +{ + int buffer; + + if (temp is null) + temp = &buffer; + + int v = *temp; // should not error +} + +void truthiness1() +{ + bool a = true; + assert(a != false); + assert(a == !false); + + bool b = !a, c = a != false, d = a == false; +} + +struct S1 +{ + int* field; +} + +struct S2 +{ + S2* next; + S2* another; +} + +void trackS1(S1 s) +{ + bool b = s.field !is null; +} + +void branchCheck() +{ + bool val; + + if (false) + { + val = true; + } +} + +void loopy() +{ + int j; + + Loop: foreach (i; 0 .. 10) + { + j += i * j; + + if (j > 5) + continue; + else if (j > 6) + break; + } +} + +void loopy2() +{ + Loop: do + { + + } + while (false); +} + +void loopy3() +{ + ReadLoopConsole: for (;;) + { + } +} + +void loopy4() +{ + Loop1: foreach (i; 0 .. 10) + { + break Loop1; + } + + Loop2: foreach (i; 0 .. 10) + { + continue Loop2; + } +} + +void loopy5() +{ + Loop: foreach (i; 0 .. 4) + { + switch (i) + { + case 0: + break; + + case 1: + continue; + + case 2: + continue Loop; + + default: + break Loop; + } + } +} + +void loopy8() +{ + int* ptr = new int; + bool b = ptr !is null; + + foreach (i; 0 .. 2) + { + assert(b); // outdated consequences + ptr = null; // error + } +} + +void loopy9(int[] input) +{ + bool result; + + foreach (val; input) + { + if (val == 1) + result = true; + } + + assert(result); +} + +void loop10(bool match, uint[] testCases) +{ + foreach (tc; testCases) + { + bool failure; + if (!match) + failure = true; + assert(!failure); + } +} + +void loopy11() +{ + static struct Tup(T...) + { + T field; + alias field this; + } + + auto t1 = Tup!(int, string)(10, "hi :)"); + int i; + + foreach (e; t1) + { + static if (is(typeof(e) == int)) + { + assert(i == 0); + } + else static if (is(typeof(e) == string)) + { + assert(i == 1); + } + + i++; + } +} + +void theSitchFinally() +{ + { + goto Label; + } + + { + Label: + } + + int* ptr; + + scope (exit) + int vS = *ptr; + + int vMid = *ptr; + truthinessNo; +} + +void nodeFind() +{ + static struct Node + { + Node* next; + + static Node* previous; + } + + Node* start = Node.previous; + Node* current; + + if (start is null) + { + start = Node.previous; + current = start.next; + } + else + current = start.next; + + Node.previous = current.next; +} + +void referenceThat() @trusted +{ + int[2] val; + int* ptr = &val[1]; +} + +void logicalAnd(bool b, int* ptr) +{ + bool a = true; + + if (a && b && ptr !is null) + { + } +} + +void logicalOr(bool b, int* ptr) +{ + bool a = true; + + if ((a && b) || ptr !is null) + { + int val = *ptr; + } +} + +void rotateForChildren(void** parent) +{ + if (*parent is null) + return; +} + +void removeValue(S2* valueNode) +{ + if (valueNode.another !is null) + valueNode.next.next = valueNode.next; + + if (valueNode.next.next is valueNode) + valueNode.next.next = valueNode.another; + else + valueNode.next.another = valueNode.another; +} + +void goingByRef1(ref int* ptr) +{ + ptr = new int; +} + +void goingByRef2(ref int* ptr) +{ + if (ptr is null) + ptr = new int; +} + +void goingByRef3(ref int* ptr) +{ + if (*ptr == 3) + ptr = new int; +} + +void aaWrite1() +{ + string[string] env; + env["MYVAR1"] = "first"; + env["MYVAR2"] = "second"; + + assert(env["MYVAR1"] == "first"); +} + +void aaWrite2() +{ + struct Wrapper + { + string[string] env; + } + + Wrapper* wrapper = new Wrapper; + + wrapper.env["MYVAR1"] = "first"; + wrapper.env["MYVAR2"] = "second"; +} + +void lengthChange() +{ + int[] test; + test.length = 10; + assert(test.length == 10); + assert(test.ptr != null); + + test.length = 1; + assert(test.length == 1); + assert(test.ptr != null); + + test = test[5 .. 5]; + + test.length = 0; + assert(test.length == 0); + assert(test.ptr != null); +} + +void callLaterEffect1() @system +{ + static struct Thing + { + int* data; + + ~this() + { + (*data)++; + } + } + + int val; + scope (exit) + assert(val == 1); + + Thing thing = Thing(&val); +} + +void callLaterEffect2() @system +{ + static struct Thing + { + int* data; + + ~this() + { + (*data)++; + } + } + + int val; + Thing thing = Thing(&val); + + val = 0; + assert(val == 1); +} + +void callByRefEffect() @system +{ + static void effect(Args...)(auto ref Args args) + { + args[0] = -1; + } + + int val; + effect(val); + assert(val == 1); +} + +struct SkippableType +{ + bool a, b, c, d; +} + +bool skipItIf(SkippableType* i, SkippableType** o) +{ + *o = i; + return true; +} + +void skippedNot(SkippableType* token) @system +{ + SkippableType* storage; + + if (token.a || token.b || skipItIf(token, &storage) && (storage.a + || storage.b) || (token.c || token.d)) + { + } +} + +void indexAA() +{ + struct MyStruct + { + int x; + } + + int[MyStruct] td; + td[MyStruct(10)] = 4; + assert(td[MyStruct(10)] == 4); + assert(MyStruct(20) !in td); + assert(td[MyStruct(10)] == 4); +} + +void dupMatch() +{ + static ubyte[] copy(ubyte[] input) + { + return input; + } + + struct Escape + { + ubyte[] array; + } + + ubyte[] reference = new ubyte[20]; + ubyte[] another = copy(reference); + Escape escape = Escape(another[0 .. 0]); + + assert(reference[] == another[]); +} + +void classCall() @trusted +{ + class C + { + this(int* val) + { + *val = 1; + } + + void method() @safe + { + } + } + + int anInt; + C c = new C(&anInt); + + assert(anInt == 2); + c.method; +} + +void unknownLoopIterationCount() +{ + bool[] res; + + while (auto value = truthinessYes()) + res ~= value; + + assert(res == [1, 2, 3]); +} + +struct OrAndIndirect +{ + OrAndIndirect* left_, right_; + int val; + + OrAndIndirect* left() + { + return left_; + } + + OrAndIndirect* right() + { + return right_; + } + + OrAndIndirect* orAndIndirect(OrAndIndirect* w) + { + OrAndIndirect* wl = w.left; + OrAndIndirect* wr = w.right; + + if ((wl is null || wl.val == 0) && (wr is null || wr.val == 0)) + { + } + else + { + if (wr is null || wr.val == 0) + { + wl.val = 0; + } + } + + return null; + } +} + +void gateUpgrade(bool gate) +{ + int* ptr; + + if (gate) + { + ptr = new int; + } + + if (gate) + { + assert(ptr !is null); // no error + } +} + +void checkCompare(string input) +{ + if (input == "^^") + return; + char c = input[0]; +} + +void incrementEffect() +{ + int[] array; + assert(array.length++ == 0); + assert(array.length == 1); +} + +void unknownArrayLiteralCall() @trusted +{ + int toCall(int* ptr) + { + return *ptr; + } + + int val; + int[] literal = [toCall(&val)]; + assert(val == 0); +} + +void branchKill(bool b) +{ + assert(!b); + + if (b) + { + int* ptr; + int val = *ptr; // no error branch dead + } +} + +void switchMakeKnown(int v, int[] slice) +{ + switch (v) + { + case 0: + slice = []; + break; + default: + break; + } + + if (slice.length > 0 && slice[1] == 2) + return; +} + +void nullCompareDerefNot() +{ + static int* source; + + while (true) + { + int* ptr; + + while (true) + { + } + + ptr = source; + + if (ptr == null) + break; + + switch (*ptr) // no error + { + default: + break; + } + } +} + +void sliceAssignNull(string[] dst) +{ + dst[] = null; + dst[0] = null; +} + +void gateCheckBadAssert1(bool gate) +{ + if (gate) + assert(!gate); // no error its basically assert(0); +} + +void gateCheckBadAssert2(bool gate) +{ + if (!gate) + assert(gate); // no error its basically assert(0); +} + +bool isEqualWithGuard(int* value, int* expected) +{ + if (value is null && expected is null) + return true; + + return *value == *expected; +} + +void orIfUnknown(bool b) @system +{ + Object o; + + if (b || (o = Object.factory("object.Object")) !is null) + { + } + + if (string s = o.toString) + { + } +} diff --git a/tests/dmd/compilable/ftimetrace.d b/tests/dmd/compilable/ftimetrace.d index f111eeeee2..1afd83fe23 100644 --- a/tests/dmd/compilable/ftimetrace.d +++ b/tests/dmd/compilable/ftimetrace.d @@ -1,5 +1,5 @@ /** -REQUIRED_ARGS: -ftime-trace -ftime-trace-file=- -ftime-trace-granularity=0 +REQUIRED_ARGS: -ftime-trace -ftime-trace-file=- -ftime-trace-granularity=0 -preview=fastdfa TRANSFORM_OUTPUT: sanitize_timetrace TEST_OUTPUT: --- @@ -11,6 +11,10 @@ Codegen: function uses, object.uses Codegen: module object, object Ctfe: add(4, 8), add(4, 8) Ctfe: call add, object.add(4, 8) +DFA: add, object.add +DFA: fun, object.fun +DFA: id, object.id!int.id +DFA: uses, object.uses Import object.object, object.object Parse: Module object, object Parsing, diff --git a/tests/dmd/compilable/previewhelp.d b/tests/dmd/compilable/previewhelp.d index 10a780c566..94a01ced14 100644 --- a/tests/dmd/compilable/previewhelp.d +++ b/tests/dmd/compilable/previewhelp.d @@ -19,5 +19,6 @@ Upcoming language changes listed by -preview=name: =inclusiveincontracts 'in' contracts of overridden methods must be a superset of parent contract (https://dlang.org/changelog/2.095.0.html#inclusive-incontracts) =fixImmutableConv disallow `void[]` data from holding immutable data (https://dlang.org/changelog/2.101.0.html#dmd.fix-immutable-conv, https://issues.dlang.org/show_bug.cgi?id=17148) =systemVariables disable access to variables marked '@system' from @safe code (https://dlang.org/spec/attribute.html#system-variables) + =fastdfa Fast dataflow analysis engine, experimental ---- */ diff --git a/tests/dmd/fail_compilation/fastdfa.d b/tests/dmd/fail_compilation/fastdfa.d new file mode 100644 index 0000000000..763c450465 --- /dev/null +++ b/tests/dmd/fail_compilation/fastdfa.d @@ -0,0 +1,161 @@ +/* + * REQUIRED_ARGS: -preview=fastdfa + * TEST_OUTPUT: +--- +fail_compilation/fastdfa.d(37): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(47): Error: Argument is expected to be non-null but was null +fail_compilation/fastdfa.d(40): For parameter `ptr` in argument 0 +fail_compilation/fastdfa.d(54): Error: Variable `ptr` was required to be non-null and has become null +fail_compilation/fastdfa.d(75): Error: Variable `ptr` was required to be non-null and has become null +fail_compilation/fastdfa.d(90): Error: Dereference on null variable `ptr` +fail_compilation/fastdfa.d(112): Error: Dereference on null variable `ptr` +fail_compilation/fastdfa.d(129): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(135): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(144): Error: Dereference on null variable `ptr` +fail_compilation/fastdfa.d(159): Error: Assert can be proven to be false +--- + */ + +@safe: + +void conditionalAssert() +{ + int a; + int b; + + int c; + + if (c) + { + a = 9; + } + else + { + b = 22; + } + + assert(c); // Error: c is false +} + +int nonnull1(int* ptr) +{ + return *ptr; +} + +void nonnullCall() +{ + nonnull1(null); // error +} + +void loopy6() +{ + int* ptr = new int; + + foreach (i; 0 .. 2) // error + { + int val = *ptr; + ptr = null; // error + } +} + +void loopy7() +{ + int* ptr = new int; + + foreach (i; 0 .. 2) + { + if (ptr !is null) + int val1 = *ptr; // ok + + ptr = null; + } + + ptr = new int; + + foreach (i; 0 .. 2) // error + { + if (ptr !is null) + int val1 = *ptr; // ok + + int val2 = *ptr; // error + ptr = null; + } +} + +void nested1() +{ + static void nested2() + { + int* ptr; + int v = *ptr; // error + } + + int* ptr; + + void nested3() + { + int v = *ptr; + } + + nested2; + nested3; +} + +void theSitch(int arg) +{ + bool passedBy; + + switch (arg) + { + case 0: + int* ptr; + int v = *ptr; // error + goto default; + + case 1: + return; + + default: + if (passedBy) + goto case 1; + passedBy = true; + goto case 0; + } +} + +void assertNoCompare() +{ + int val; + assert(val); // Error: val is 0 +} + +void vectorExp() +{ + string[] stack; + assert(stack.length == 1); // Error: stack is null +} + +int nullSet(int* ptr, bool gate) +{ + if (ptr !is null) + { + if (gate) + ptr = null; + return *ptr; // error could be null + } + + return -1; +} + +void gateDowngrade(bool gate, int* ptr) +{ + if (gate) + { + ptr = null; + } + + if (gate) + { + assert(ptr !is null); // error + } +} From 4619a981b924b601351b39d99231d651f65694b5 Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Sun, 19 Oct 2025 23:37:23 +1300 Subject: [PATCH 033/440] Fix toBool move to semanticsem in fast DFA engine (dlang/dmd!22001) --- dmd/dfa/fast/expression.d | 1 + 1 file changed, 1 insertion(+) diff --git a/dmd/dfa/fast/expression.d b/dmd/dfa/fast/expression.d index 658e3d547e..7b7e4a6676 100644 --- a/dmd/dfa/fast/expression.d +++ b/dmd/dfa/fast/expression.d @@ -17,6 +17,7 @@ import dmd.dfa.utils; import dmd.common.outbuffer; import dmd.location; import dmd.expression; +import dmd.expressionsem; import dmd.astenums; import dmd.tokens; import dmd.func; From bf76a94965b0c548ccc11d53345e3b25f30f2037 Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Mon, 20 Oct 2025 15:13:43 +1300 Subject: [PATCH 034/440] Disable rewriting of finally statements to sequences unless requested (dlang/dmd!21970) --- dmd/cli.d | 4 +++ dmd/frontend.h | 5 ++- dmd/globals.d | 2 ++ dmd/globals.h | 1 + dmd/mars.d | 16 +++++++++ dmd/statementsem.d | 5 ++- .../src/core/internal/container/array.d | 13 +++++++ tests/dmd/unit/semantic/control_flow.d | 35 +++++++++++-------- 8 files changed, 65 insertions(+), 16 deletions(-) diff --git a/dmd/cli.d b/dmd/cli.d index 9553654c8a..9d5afd5d81 100644 --- a/dmd/cli.d +++ b/dmd/cli.d @@ -239,6 +239,10 @@ struct Usage $(LI $(B context): Prints the error context as part of the unrecoverable $(D AssertError).) )` ), + Option("checkactionfinally=[on|off]", + "do finally statements that do not have an Exception thrown in try body get emitted?", + "Default behavior is on. Turning this off means destructors may not run." + ), Option("checkaction=[h|help|?]", "list information on all available check actions" ), diff --git a/dmd/frontend.h b/dmd/frontend.h index a92bde4d49..34636360c8 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -8398,6 +8398,7 @@ struct Param final bool addMain; bool allInst; bool bitfields; + bool rewriteNoExceptionToSeq; CppStdRevision cplusplus; Help help; Verbose v; @@ -8489,6 +8490,7 @@ struct Param final addMain(), allInst(), bitfields(true), + rewriteNoExceptionToSeq(), cplusplus((CppStdRevision)201103u), help(), v(), @@ -8546,7 +8548,7 @@ struct Param final timeTraceFile() { } - Param(bool obj, bool readStdin = false, bool multiobj = false, bool trace = false, bool tracegc = false, bool vcg_ast = false, DiagnosticReporting useDeprecated = (DiagnosticReporting)1u, bool useUnitTests = false, bool useInline = false, bool release = false, bool preservePaths = false, DiagnosticReporting useWarnings = (DiagnosticReporting)2u, bool cov = false, uint8_t covPercent = 0u, bool ctfe_cov = false, bool ignoreUnsupportedPragmas = true, bool useModuleInfo = true, bool useTypeInfo = true, bool useExceptions = true, bool useGC = true, bool betterC = false, bool addMain = false, bool allInst = false, bool bitfields = true, CppStdRevision cplusplus = (CppStdRevision)201103u, Help help = Help(), Verbose v = Verbose(), Edition edition = (Edition)2023u, void* editionFiles = nullptr, FeatureState useDIP25 = (FeatureState)2u, FeatureState useDIP1000 = (FeatureState)0u, bool ehnogc = false, bool useDIP1021 = false, FeatureState fieldwise = (FeatureState)0u, bool fixAliasThis = false, FeatureState rvalueRefParam = (FeatureState)0u, FeatureState safer = (FeatureState)0u, FeatureState noSharedAccess = (FeatureState)0u, bool previewIn = false, bool inclusiveInContracts = false, bool shortenedMethods = true, bool fixImmutableConv = false, bool fix16997 = true, FeatureState dtorFields = (FeatureState)0u, FeatureState systemVariables = (FeatureState)0u, bool useFastDFA = false, CHECKENABLE useInvariants = (CHECKENABLE)0u, CHECKENABLE useIn = (CHECKENABLE)0u, CHECKENABLE useOut = (CHECKENABLE)0u, CHECKENABLE useArrayBounds = (CHECKENABLE)0u, CHECKENABLE useAssert = (CHECKENABLE)0u, CHECKENABLE useSwitchError = (CHECKENABLE)0u, CHECKENABLE boundscheck = (CHECKENABLE)0u, CHECKACTION checkAction = (CHECKACTION)0u, CLIIdentifierTable dIdentifierTable = (CLIIdentifierTable)0u, CLIIdentifierTable cIdentifierTable = (CLIIdentifierTable)0u, _d_dynamicArray< const char > argv0 = {}, Array modFileAliasStrings = Array(), Array imppath = Array(), Array fileImppath = Array(), _d_dynamicArray< const char > objdir = {}, _d_dynamicArray< const char > objname = {}, _d_dynamicArray< const char > libname = {}, Output ddoc = Output(), Output dihdr = Output(), Output cxxhdr = Output(), Output json = Output(), JsonFieldFlags jsonFieldFlags = (JsonFieldFlags)0u, Output makeDeps = Output(), Output mixinOut = Output(), Output moduleDeps = Output(), bool debugEnabled = false, bool run = false, Array runargs = Array(), Array cppswitches = Array(), const char* cpp = nullptr, Array objfiles = Array(), Array linkswitches = Array(), Array linkswitchIsForCC = Array(), Array libfiles = Array(), Array dllfiles = Array(), _d_dynamicArray< const char > deffile = {}, _d_dynamicArray< const char > resfile = {}, _d_dynamicArray< const char > exefile = {}, _d_dynamicArray< const char > mapfile = {}, bool fullyQualifiedObjectFiles = false, bool timeTrace = false, uint32_t timeTraceGranularityUs = 500u, const char* timeTraceFile = nullptr) : + Param(bool obj, bool readStdin = false, bool multiobj = false, bool trace = false, bool tracegc = false, bool vcg_ast = false, DiagnosticReporting useDeprecated = (DiagnosticReporting)1u, bool useUnitTests = false, bool useInline = false, bool release = false, bool preservePaths = false, DiagnosticReporting useWarnings = (DiagnosticReporting)2u, bool cov = false, uint8_t covPercent = 0u, bool ctfe_cov = false, bool ignoreUnsupportedPragmas = true, bool useModuleInfo = true, bool useTypeInfo = true, bool useExceptions = true, bool useGC = true, bool betterC = false, bool addMain = false, bool allInst = false, bool bitfields = true, bool rewriteNoExceptionToSeq = false, CppStdRevision cplusplus = (CppStdRevision)201103u, Help help = Help(), Verbose v = Verbose(), Edition edition = (Edition)2023u, void* editionFiles = nullptr, FeatureState useDIP25 = (FeatureState)2u, FeatureState useDIP1000 = (FeatureState)0u, bool ehnogc = false, bool useDIP1021 = false, FeatureState fieldwise = (FeatureState)0u, bool fixAliasThis = false, FeatureState rvalueRefParam = (FeatureState)0u, FeatureState safer = (FeatureState)0u, FeatureState noSharedAccess = (FeatureState)0u, bool previewIn = false, bool inclusiveInContracts = false, bool shortenedMethods = true, bool fixImmutableConv = false, bool fix16997 = true, FeatureState dtorFields = (FeatureState)0u, FeatureState systemVariables = (FeatureState)0u, bool useFastDFA = false, CHECKENABLE useInvariants = (CHECKENABLE)0u, CHECKENABLE useIn = (CHECKENABLE)0u, CHECKENABLE useOut = (CHECKENABLE)0u, CHECKENABLE useArrayBounds = (CHECKENABLE)0u, CHECKENABLE useAssert = (CHECKENABLE)0u, CHECKENABLE useSwitchError = (CHECKENABLE)0u, CHECKENABLE boundscheck = (CHECKENABLE)0u, CHECKACTION checkAction = (CHECKACTION)0u, CLIIdentifierTable dIdentifierTable = (CLIIdentifierTable)0u, CLIIdentifierTable cIdentifierTable = (CLIIdentifierTable)0u, _d_dynamicArray< const char > argv0 = {}, Array modFileAliasStrings = Array(), Array imppath = Array(), Array fileImppath = Array(), _d_dynamicArray< const char > objdir = {}, _d_dynamicArray< const char > objname = {}, _d_dynamicArray< const char > libname = {}, Output ddoc = Output(), Output dihdr = Output(), Output cxxhdr = Output(), Output json = Output(), JsonFieldFlags jsonFieldFlags = (JsonFieldFlags)0u, Output makeDeps = Output(), Output mixinOut = Output(), Output moduleDeps = Output(), bool debugEnabled = false, bool run = false, Array runargs = Array(), Array cppswitches = Array(), const char* cpp = nullptr, Array objfiles = Array(), Array linkswitches = Array(), Array linkswitchIsForCC = Array(), Array libfiles = Array(), Array dllfiles = Array(), _d_dynamicArray< const char > deffile = {}, _d_dynamicArray< const char > resfile = {}, _d_dynamicArray< const char > exefile = {}, _d_dynamicArray< const char > mapfile = {}, bool fullyQualifiedObjectFiles = false, bool timeTrace = false, uint32_t timeTraceGranularityUs = 500u, const char* timeTraceFile = nullptr) : obj(obj), readStdin(readStdin), multiobj(multiobj), @@ -8571,6 +8573,7 @@ struct Param final addMain(addMain), allInst(allInst), bitfields(bitfields), + rewriteNoExceptionToSeq(rewriteNoExceptionToSeq), cplusplus(cplusplus), help(help), v(v), diff --git a/dmd/globals.d b/dmd/globals.d index 57b61b9f1f..a825cb8b5d 100644 --- a/dmd/globals.d +++ b/dmd/globals.d @@ -181,6 +181,8 @@ extern (C++) struct Param bool addMain; // add a default main() function bool allInst; // generate code for all template instantiations bool bitfields = true; // support C style bit fields + bool rewriteNoExceptionToSeq; // Allow finally statements that do not throw an Exception + // in try body to rewrite to a sequence. CppStdRevision cplusplus = CppStdRevision.cpp11; // version of C++ standard to support diff --git a/dmd/globals.h b/dmd/globals.h index 3c809a637e..f1aa547d89 100644 --- a/dmd/globals.h +++ b/dmd/globals.h @@ -198,6 +198,7 @@ struct Param d_bool addMain; // add a default main() function d_bool allInst; // generate code for all template instantiations d_bool bitfields; // support C style bit fields + d_bool rewriteNoExceptionToSeq; CppStdRevision cplusplus; // version of C++ name mangling to support Help help; diff --git a/dmd/mars.d b/dmd/mars.d index d029689c95..714d2af787 100644 --- a/dmd/mars.d +++ b/dmd/mars.d @@ -689,6 +689,22 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, out Param params.useDeprecated = DiagnosticReporting.inform; else if (arg == "-c") // https://dlang.org/dmd.html#switch-c driverParams.link = false; + else if (startsWith(p + 1, "checkactionfinally")) // https://dlang.org/dmd.html#switch-checkactionfinally + { + enum len = "-checkactionfinally".length; + switch(arg[len .. $]) + { + case "=off": + params.rewriteNoExceptionToSeq = true; + break; + case "=on": + params.rewriteNoExceptionToSeq = false; + break; + default: + errorInvalidSwitch(p, "-checkactionerror argument may only be `on` or `off`"); + return false; + } + } else if (startsWith(p + 1, "checkaction")) // https://dlang.org/dmd.html#switch-checkaction { /* Parse: diff --git a/dmd/statementsem.d b/dmd/statementsem.d index 14749dc33f..26a637220f 100644 --- a/dmd/statementsem.d +++ b/dmd/statementsem.d @@ -3421,11 +3421,14 @@ Statement statementSemanticVisit(Statement s, Scope* sc) blockexit &= ~BE.throw_; // don't worry about paths that otherwise may throw // Don't care about paths that halt, either - if ((blockexit & ~BE.halt) == BE.fallthru) + // Only rewrite if it was requested. + // This has side effects where Error will not run destructors, unsafe. + if (global.params.rewriteNoExceptionToSeq && (blockexit & ~BE.halt) == BE.fallthru) { result = new CompoundStatement(tfs.loc, tfs._body, tfs.finalbody); return; } + tfs.bodyFallsThru = (blockexit & BE.fallthru) != 0; result = tfs; } diff --git a/runtime/druntime/src/core/internal/container/array.d b/runtime/druntime/src/core/internal/container/array.d index b583341d06..f1a7e5b28a 100644 --- a/runtime/druntime/src/core/internal/container/array.d +++ b/runtime/druntime/src/core/internal/container/array.d @@ -215,6 +215,13 @@ unittest { // Overflow ary.length. auto ary = Array!size_t(cast(size_t*)0xdeadbeef, -1); + scope(failure) + { + // prevent destructor from cleaning up invalid memory. + ary._length = 0; + ary._ptr = null; + } + ary.insertBack(0); } catch (OutOfMemoryError) @@ -224,6 +231,12 @@ unittest { // Overflow requested memory size for common.xrealloc(). auto ary = Array!size_t(cast(size_t*)0xdeadbeef, -2); + scope(failure) + { + // prevent destructor from cleaning up invalid memory. + ary._length = 0; + ary._ptr = null; + } ary.insertBack(0); } catch (OutOfMemoryError) diff --git a/tests/dmd/unit/semantic/control_flow.d b/tests/dmd/unit/semantic/control_flow.d index 0e4b091804..384376f512 100644 --- a/tests/dmd/unit/semantic/control_flow.d +++ b/tests/dmd/unit/semantic/control_flow.d @@ -487,25 +487,32 @@ unittest (FuncDeclaration fd) { // Rewritten as: - // bool __os2 = false; - // try - // { - // } - // catch(Throwable __o3) - // { - // __os2 = true; - // throw __o3; - // } - // if (!__os2) - // throw new Exception(""); + //bool __os2 = false; + //try + //{ + // try + // { + // } + // catch(Throwable __o3) + // { + // __os2 = true; + // throw __o3; + // } + //} + //finally + // if (!__os2) + // throw _d_newclassT(); // // FIXME: null statement at index 1 without errors?!? auto stmts = getStatements(fd); - assert(stmts.length == 4); + assert(stmts.length == 3); + + auto finallyStatement = (*stmts)[2].isTryFinallyStatement(); + assert(finallyStatement !is null); // BUG(?): blockexit yields `fallthru` for the try-catch because the exception is typed as `Throwable` - testBlockExit(fd, (*stmts)[2], BE.fallthru); - assert((*stmts)[2].isTryCatchStatement()); + testBlockExit(fd, finallyStatement._body, BE.fallthru); + assert(finallyStatement._body.isTryCatchStatement()); testBlockExit(fd, fd.fbody, BE.fallthru | BE.throw_); }); From b475f92d09da806e03419b6367f71286a0cb950d Mon Sep 17 00:00:00 2001 From: limepoutine <144896890+limepoutine@users.noreply.github.com> Date: Mon, 20 Oct 2025 12:53:38 +0800 Subject: [PATCH 035/440] Specify LANG=C in dshell/dwarf.d (dlang/dmd!21996) Co-authored-by: limepoutine --- tests/dmd/dshell/dwarf.d | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/dmd/dshell/dwarf.d b/tests/dmd/dshell/dwarf.d index 0b0e4fa688..f89523b1f1 100755 --- a/tests/dmd/dshell/dwarf.d +++ b/tests/dmd/dshell/dwarf.d @@ -31,8 +31,15 @@ int main() else immutable slash = "/"; + // Some systems are configured for binutils to output localized strings. + // Specify LANG=C to disable localization as we test for fixed strings in the output. + // https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html + // As an example (assuming binutils is compiled with localization), run + // LANG=ja_JP LANGUAGE=ja_JP objdump -H + // to see translated output in action. + auto sysObjdump = executeShell("objdump --version", ["LANG": "C"]); + // If the Unix system doesn't have objdump, disable the tests - auto sysObjdump = executeShell("objdump --version"); if (sysObjdump.status) return DISABLED; @@ -93,7 +100,8 @@ int main() auto objdump = exe ~ ".objdump"; auto objdump_file = File(objdump, "w"); - run("objdump -W " ~ exe, objdump_file); + // Also disable localization here. + run("objdump -W " ~ exe, objdump_file, stderr, ["LANG": "C"]); objdump_file.close(); auto llvmDwarfdump = executeShell("llvm-dwarfdump --version"); From fff4a1d8bb059e1e59ea2146a0ad92fcaa0be7f5 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Tue, 21 Oct 2025 00:42:47 +0300 Subject: [PATCH 036/440] Remove unneeded import (dlang/dmd!22006) --- dmd/hdrgen.d | 1 - 1 file changed, 1 deletion(-) diff --git a/dmd/hdrgen.d b/dmd/hdrgen.d index 35d0b0338c..ec25215bf2 100644 --- a/dmd/hdrgen.d +++ b/dmd/hdrgen.d @@ -22,7 +22,6 @@ import dmd.arraytypes; import dmd.astenums; import dmd.attrib; import dmd.cond; -import dmd.ctfeexpr; import dmd.dclass; import dmd.declaration; import dmd.denum; From b67ac016c344082ce31a13a88056872314b6a183 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Tue, 21 Oct 2025 01:02:24 +0300 Subject: [PATCH 037/440] Move `Type.hasUnsafeBitPatterns` to `dmd/typesem.d` (dlang/dmd!22005) --- dmd/cxxfrontend.d | 6 ++++++ dmd/frontend.h | 5 ----- dmd/mtype.d | 32 -------------------------------- dmd/mtype.h | 5 +---- dmd/safe.d | 2 +- dmd/typesem.d | 28 ++++++++++++++++++++++++++++ 6 files changed, 36 insertions(+), 42 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 6a576a01b5..542671b29b 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -867,6 +867,12 @@ Expression defaultInitLiteral(Type t, Loc loc) return dmd.typesem.defaultInitLiteral(t, loc); } +bool hasUnsafeBitpatterns(Type type) +{ + import dmd.typesem; + return dmd.typesem.hasUnsafeBitpatterns(type); +} + /*********************************************************** * typinf.d */ diff --git a/dmd/frontend.h b/dmd/frontend.h index 34636360c8..6f3ef211f7 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2108,7 +2108,6 @@ class Type : public ASTNode virtual structalign_t alignment(); virtual int32_t hasWild() const; virtual bool hasVoidInitPointers(); - virtual bool hasUnsafeBitpatterns(); virtual bool hasInvariant(); virtual Type* nextOf(); Type* baseElemOf(); @@ -4446,7 +4445,6 @@ class TypeBasic final : public Type bool isComplex() override; bool isScalar() override; bool isUnsigned() override; - bool hasUnsafeBitpatterns() override; TypeBasic* isTypeBasic() override; void accept(Visitor* v) override; }; @@ -4519,7 +4517,6 @@ class TypeEnum final : public Type bool needsCopyOrPostblit() override; bool needsNested() override; bool hasVoidInitPointers() override; - bool hasUnsafeBitpatterns() override; bool hasInvariant() override; Type* nextOf() override; void accept(Visitor* v) override; @@ -4750,7 +4747,6 @@ class TypeSArray final : public TypeArray uint32_t alignsize() override; bool isString() override; structalign_t alignment() override; - bool hasUnsafeBitpatterns() override; bool hasVoidInitPointers() override; bool hasInvariant() override; bool needsDestruction() override; @@ -4785,7 +4781,6 @@ class TypeStruct final : public Type bool needsCopyOrPostblit() override; bool needsNested() override; bool hasVoidInitPointers() override; - bool hasUnsafeBitpatterns() override; bool hasInvariant() override; uint8_t deduceWild(Type* t, bool isRef) override; void accept(Visitor* v) override; diff --git a/dmd/mtype.d b/dmd/mtype.d index 4ee7556902..cc31d18e5d 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1348,16 +1348,6 @@ extern (C++) abstract class Type : ASTNode return false; } - /************************************* - * Detect if this is an unsafe type because of the presence of `@system` members - * Returns: - * true if so - */ - bool hasUnsafeBitpatterns() - { - return false; - } - /*************************************** * Returns: true if type has any invariants */ @@ -2026,11 +2016,6 @@ extern (C++) final class TypeBasic : Type return (flags & TFlags.unsigned) != 0; } - override bool hasUnsafeBitpatterns() - { - return ty == Tbool; - } - // For eliminating dynamic_cast override TypeBasic isTypeBasic() { @@ -2196,11 +2181,6 @@ extern (C++) final class TypeSArray : TypeArray return next.alignment(); } - override bool hasUnsafeBitpatterns() - { - return next.hasUnsafeBitpatterns(); - } - override bool hasVoidInitPointers() { return next.hasVoidInitPointers(); @@ -3007,13 +2987,6 @@ extern (C++) final class TypeStruct : Type return sym.hasVoidInitPointers; } - override bool hasUnsafeBitpatterns() - { - sym.size(Loc.initial); // give error for forward references - sym.determineTypeProperties(); - return sym.hasUnsafeBitpatterns; - } - override bool hasInvariant() { sym.size(Loc.initial); // give error for forward references @@ -3155,11 +3128,6 @@ extern (C++) final class TypeEnum : Type return memType().hasVoidInitPointers(); } - override bool hasUnsafeBitpatterns() - { - return memType().hasUnsafeBitpatterns(); - } - override bool hasInvariant() { return memType().hasInvariant(); diff --git a/dmd/mtype.h b/dmd/mtype.h index 142dfc772d..fe8a215d53 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -267,7 +267,6 @@ class Type : public ASTNode virtual structalign_t alignment(); virtual int hasWild() const; virtual bool hasVoidInitPointers(); - virtual bool hasUnsafeBitpatterns(); virtual bool hasInvariant(); virtual Type *nextOf(); Type *baseElemOf(); @@ -397,7 +396,6 @@ class TypeSArray final : public TypeArray unsigned alignsize() override; bool isString() override; structalign_t alignment() override; - bool hasUnsafeBitpatterns() override; bool hasVoidInitPointers() override; bool hasInvariant() override; bool needsDestruction() override; @@ -692,7 +690,6 @@ class TypeStruct final : public Type bool needsCopyOrPostblit() override; bool needsNested() override; bool hasVoidInitPointers() override; - bool hasUnsafeBitpatterns() override; bool hasInvariant() override; unsigned char deduceWild(Type *t, bool isRef) override; @@ -721,7 +718,6 @@ class TypeEnum final : public Type bool needsCopyOrPostblit() override; bool needsNested() override; bool hasVoidInitPointers() override; - bool hasUnsafeBitpatterns() override; bool hasInvariant() override; Type *nextOf() override; @@ -843,4 +839,5 @@ namespace dmd uinteger_t size(Type *type, Loc loc); MATCH implicitConvTo(Type* from, Type* to); MATCH constConv(Type* from, Type* to); + bool hasUnsafeBitpatterns(Type* type); } diff --git a/dmd/safe.d b/dmd/safe.d index a1207f7a18..b8b270c03b 100644 --- a/dmd/safe.d +++ b/dmd/safe.d @@ -38,7 +38,7 @@ import dmd.root.string : fTuple; import dmd.target; import dmd.targetcompiler; import dmd.tokens; -import dmd.typesem : hasPointers, arrayOf, size; +import dmd.typesem : hasPointers, arrayOf, size, hasUnsafeBitpatterns; /************************************************************* * Check for unsafe access in @safe code: diff --git a/dmd/typesem.d b/dmd/typesem.d index 7d0f44c432..7fe57dff3c 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -72,6 +72,34 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; + +/************************************* + * Detect if this is an unsafe type because of the presence of `@system` members + * Returns: + * true if so + */ +bool hasUnsafeBitpatterns(Type _this) +{ + static bool tstructImpl(TypeStruct _this) + { + import dmd.dsymbolsem : size; + _this.sym.size(Loc.initial); // give error for forward references + _this.sym.determineTypeProperties(); + return _this.sym.hasUnsafeBitpatterns; + } + + if(auto tb = _this.isTypeBasic()) + return tb.ty == Tbool; + + switch(_this.ty) + { + case Tenum: return _this.isTypeEnum().memType().hasUnsafeBitpatterns(); + case Tstruct: return tstructImpl(_this.isTypeStruct()); + case Tsarray: return _this.isTypeSArray().next.hasUnsafeBitpatterns(); + default: return false; + } +} + /************************************* * Resolve a tuple index, `s[oindex]`, by figuring out what `s[oindex]` represents. * Setting one of pe/pt/ps. From 277619e5ecbf39a12a502e2787fb739bae695d22 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Tue, 21 Oct 2025 01:03:41 +0300 Subject: [PATCH 038/440] Move makeNested and makeNested2 to dsymbolsem (dlang/dmd!22007) --- dmd/aggregate.d | 114 ----------------------------------------------- dmd/dsymbolsem.d | 114 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 114 deletions(-) diff --git a/dmd/aggregate.d b/dmd/aggregate.d index a01717ed5e..c51494cf97 100644 --- a/dmd/aggregate.d +++ b/dmd/aggregate.d @@ -206,120 +206,6 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol return enclosing !is null; } - /* Append vthis field (this.tupleof[$-1]) to make this aggregate type nested. - */ - extern (D) final void makeNested() - { - if (enclosing) // if already nested - return; - if (sizeok == Sizeok.done) - return; - if (isUnionDeclaration() || isInterfaceDeclaration()) - return; - if (storage_class & STC.static_) - return; - - // If nested struct, add in hidden 'this' pointer to outer scope - auto s = toParentLocal(); - if (!s) - s = toParent2(); - if (!s) - return; - Type t = null; - if (auto fd = s.isFuncDeclaration()) - { - enclosing = fd; - - /* https://issues.dlang.org/show_bug.cgi?id=14422 - * If a nested class parent is a function, its - * context pointer (== `outer`) should be void* always. - */ - t = Type.tvoidptr; - } - else if (auto ad = s.isAggregateDeclaration()) - { - if (isClassDeclaration() && ad.isClassDeclaration()) - { - enclosing = ad; - } - else if (isStructDeclaration()) - { - if (auto ti = ad.parent.isTemplateInstance()) - { - enclosing = ti.enclosing; - } - } - t = ad.handleType(); - } - if (enclosing) - { - //printf("makeNested %s, enclosing = %s\n", toChars(), enclosing.toChars()); - assert(t); - if (t.ty == Tstruct) - t = Type.tvoidptr; // t should not be a ref type - - assert(!vthis); - vthis = new ThisDeclaration(loc, t); - //vthis.storage_class |= STC.ref_; - - // Emulate vthis.addMember() - members.push(vthis); - - // Emulate vthis.dsymbolSemantic() - vthis.storage_class |= STC.field; - vthis.parent = this; - vthis.visibility = Visibility(Visibility.Kind.public_); - vthis.alignment = t.alignment(); - vthis.semanticRun = PASS.semanticdone; - - if (sizeok == Sizeok.fwd) - fields.push(vthis); - - makeNested2(); - } - } - - /* Append vthis2 field (this.tupleof[$-1]) to add a second context pointer. - */ - extern (D) final void makeNested2() - { - if (vthis2) - return; - if (!vthis) - makeNested(); // can't add second before first - if (!vthis) - return; - if (sizeok == Sizeok.done) - return; - if (isUnionDeclaration() || isInterfaceDeclaration()) - return; - if (storage_class & STC.static_) - return; - - auto s0 = toParentLocal(); - auto s = toParent2(); - if (!s || !s0 || s == s0) - return; - auto cd = s.isClassDeclaration(); - Type t = cd ? cd.type : Type.tvoidptr; - - vthis2 = new ThisDeclaration(loc, t); - //vthis2.storage_class |= STC.ref_; - - // Emulate vthis2.addMember() - members.push(vthis2); - - // Emulate vthis2.dsymbolSemantic() - vthis2.storage_class |= STC.field; - vthis2.parent = this; - vthis2.visibility = Visibility(Visibility.Kind.public_); - vthis2.alignment = t.alignment(); - vthis2.semanticRun = PASS.semanticdone; - - if (sizeok == Sizeok.fwd) - fields.push(vthis2); - } - override final bool isExport() const { return visibility.kind == Visibility.Kind.export_; diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index a90f8ba662..6ee0e4d64e 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -89,6 +89,120 @@ import dmd.visitor; enum LOG = false; +/* Append vthis field (this.tupleof[$-1]) to make this aggregate type nested. + */ +void makeNested(AggregateDeclaration _this) +{ + if (_this.enclosing) // if already nested + return; + if (_this.sizeok == Sizeok.done) + return; + if (_this.isUnionDeclaration() || _this.isInterfaceDeclaration()) + return; + if (_this.storage_class & STC.static_) + return; + + // If nested struct, add in hidden 'this' pointer to outer scope + auto s = _this.toParentLocal(); + if (!s) + s = _this.toParent2(); + if (!s) + return; + Type t = null; + if (auto fd = s.isFuncDeclaration()) + { + _this.enclosing = fd; + + /* https://issues.dlang.org/show_bug.cgi?id=14422 + * If a nested class parent is a function, its + * context pointer (== `outer`) should be void* always. + */ + t = Type.tvoidptr; + } + else if (auto ad = s.isAggregateDeclaration()) + { + if (_this.isClassDeclaration() && ad.isClassDeclaration()) + { + _this.enclosing = ad; + } + else if (_this.isStructDeclaration()) + { + if (auto ti = ad.parent.isTemplateInstance()) + { + _this.enclosing = ti.enclosing; + } + } + t = ad.handleType(); + } + if (_this.enclosing) + { + //printf("makeNested %s, enclosing = %s\n", toChars(), enclosing.toChars()); + assert(t); + if (t.ty == Tstruct) + t = Type.tvoidptr; // t should not be a ref type + + assert(!_this.vthis); + _this.vthis = new ThisDeclaration(_this.loc, t); + //vthis.storage_class |= STC.ref_; + + // Emulate vthis.addMember() + _this.members.push(_this.vthis); + + // Emulate vthis.dsymbolSemantic() + _this.vthis.storage_class |= STC.field; + _this.vthis.parent = _this; + _this.vthis.visibility = Visibility(Visibility.Kind.public_); + _this.vthis.alignment = t.alignment(); + _this.vthis.semanticRun = PASS.semanticdone; + + if (_this.sizeok == Sizeok.fwd) + _this.fields.push(_this.vthis); + + _this.makeNested2(); + } +} + +/* Append vthis2 field (this.tupleof[$-1]) to add a second context pointer. + */ +void makeNested2(AggregateDeclaration _this) +{ + if (_this.vthis2) + return; + if (!_this.vthis) + _this.makeNested(); // can't add second before first + if (!_this.vthis) + return; + if (_this.sizeok == Sizeok.done) + return; + if (_this.isUnionDeclaration() || _this.isInterfaceDeclaration()) + return; + if (_this.storage_class & STC.static_) + return; + + auto s0 = _this.toParentLocal(); + auto s = _this.toParent2(); + if (!s || !s0 || s == s0) + return; + auto cd = s.isClassDeclaration(); + Type t = cd ? cd.type : Type.tvoidptr; + + _this.vthis2 = new ThisDeclaration(_this.loc, t); + //vthis2.storage_class |= STC.ref_; + + // Emulate vthis2.addMember() + _this.members.push(_this.vthis2); + + // Emulate vthis2.dsymbolSemantic() + _this.vthis2.storage_class |= STC.field; + _this.vthis2.parent = _this; + _this.vthis2.visibility = Visibility(Visibility.Kind.public_); + _this.vthis2.alignment = t.alignment(); + _this.vthis2.semanticRun = PASS.semanticdone; + + if (_this.sizeok == Sizeok.fwd) + _this.fields.push(_this.vthis2); +} + /************************************ * Perform unqualified name lookup by following the chain of scopes up * until found. From a21962ade5f7bc3678590db88fe0bb1be48c7af1 Mon Sep 17 00:00:00 2001 From: Dennis Date: Tue, 21 Oct 2025 12:54:09 +0200 Subject: [PATCH 039/440] ImportC: Add __module declarations (dlang/dmd!20659) --- dmd/cparse.d | 14 +++++++++ dmd/dmodule.d | 8 ++++- dmd/frontend.h | 15 ++++----- dmd/tokens.d | 5 ++- dmd/tokens.h | 1 + tests/dmd/compilable/cmodules.d | 9 ++++++ tests/dmd/compilable/imports/cpkg/cmodule.c | 13 ++++++++ .../dmd/fail_compilation/cmodule_malformed.c | 31 +++++++++++++++++++ tests/dmd/unit/lexer/location_offset.d | 1 + 9 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 tests/dmd/compilable/cmodules.d create mode 100644 tests/dmd/compilable/imports/cpkg/cmodule.c create mode 100644 tests/dmd/fail_compilation/cmodule_malformed.c diff --git a/dmd/cparse.d b/dmd/cparse.d index a0134e9d31..2cb898ea7c 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -143,6 +143,20 @@ final class CParser(AST) : Parser!AST return wrap; } + if (token.value == TOK._module) + { + token.value = TOK.module_; + auto oldMd = this.md; + parseModuleDeclaration(); + if (oldMd) + { + // We only use the first module declaration, + // subsequent __module statements should only come from #included files + this.md = oldMd; + } + continue; + } + /* GNU Extensions * external-declaration: * simple-asm-expr ; diff --git a/dmd/dmodule.d b/dmd/dmodule.d index ebe13c0f96..1352183122 100644 --- a/dmd/dmodule.d +++ b/dmd/dmodule.d @@ -765,7 +765,13 @@ extern (C++) final class Module : Package p.nextToken(); checkCompiledImport(); members = p.parseModule(); - assert(!p.md); // C doesn't have module declarations + md = p.md; + if (md) + { + this.ident = md.id; + dst = Package.resolve(md.packages, &this.parent, &ppack); + } + numlines = p.linnum; } else diff --git a/dmd/frontend.h b/dmd/frontend.h index 6f3ef211f7..83919b6d0e 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -3130,13 +3130,14 @@ enum class TOK : uint8_t _Thread_local_ = 216u, _assert_ = 217u, _import_ = 218u, - __cdecl_ = 219u, - __declspec_ = 220u, - __stdcall_ = 221u, - __thread_ = 222u, - __pragma_ = 223u, - __int128_ = 224u, - __attribute___ = 225u, + _module = 219u, + __cdecl_ = 220u, + __declspec_ = 221u, + __stdcall_ = 222u, + __thread_ = 223u, + __pragma_ = 224u, + __int128_ = 225u, + __attribute___ = 226u, }; class FuncExp final : public Expression diff --git a/dmd/tokens.d b/dmd/tokens.d index d304436766..05f413b51c 100644 --- a/dmd/tokens.d +++ b/dmd/tokens.d @@ -276,6 +276,7 @@ enum TOK : ubyte // C only extended keywords _assert, _import, + _module, __cdecl, __declspec, __stdcall, @@ -586,6 +587,7 @@ private immutable TOK[] keywords = // C only extended keywords TOK._assert, TOK._import, + TOK._module, TOK.__cdecl, TOK.__declspec, TOK.__stdcall, @@ -621,7 +623,7 @@ static immutable TOK[TOK.max + 1] Ckeywords = union_, unsigned, void_, volatile, while_, asm_, typeof_, _Alignas, _Alignof, _Atomic, _Bool, _Complex, _Generic, _Imaginary, _Noreturn, _Static_assert, _Thread_local, - _import, __cdecl, __declspec, __stdcall, __thread, __pragma, __int128, __attribute__, + _import, _module, __cdecl, __declspec, __stdcall, __thread, __pragma, __int128, __attribute__, _assert ]; foreach (kw; Ckwds) @@ -900,6 +902,7 @@ extern (C++) struct Token // C only extended keywords TOK._assert : "__check", TOK._import : "__import", + TOK._module : "__module", TOK.__cdecl : "__cdecl", TOK.__declspec : "__declspec", TOK.__stdcall : "__stdcall", diff --git a/dmd/tokens.h b/dmd/tokens.h index ecbcc02474..baa3317b02 100644 --- a/dmd/tokens.h +++ b/dmd/tokens.h @@ -282,6 +282,7 @@ enum class TOK : unsigned char // C only extended keywords _assert, _import, + _module, cdecl_, declspec, stdcall, diff --git a/tests/dmd/compilable/cmodules.d b/tests/dmd/compilable/cmodules.d new file mode 100644 index 0000000000..6cec6c814e --- /dev/null +++ b/tests/dmd/compilable/cmodules.d @@ -0,0 +1,9 @@ +/** +EXTRA_SOURCES: imports/cpkg/cmodule.c +*/ + +import imports.cpkg.cmodule; + +static assert(sqr(3) == 9); + +void main() {} diff --git a/tests/dmd/compilable/imports/cpkg/cmodule.c b/tests/dmd/compilable/imports/cpkg/cmodule.c new file mode 100644 index 0000000000..b926ef1600 --- /dev/null +++ b/tests/dmd/compilable/imports/cpkg/cmodule.c @@ -0,0 +1,13 @@ +// D module declaration + +#if __IMPORTC__ + +__module imports.cpkg.cmodule; + +// Only the first module statement is used, +// subsequent __module declarations are assumed to come from #included other files +__module some.header; + +#endif + +int sqr(int i) { return i * i; } diff --git a/tests/dmd/fail_compilation/cmodule_malformed.c b/tests/dmd/fail_compilation/cmodule_malformed.c new file mode 100644 index 0000000000..6dd888b4fe --- /dev/null +++ b/tests/dmd/fail_compilation/cmodule_malformed.c @@ -0,0 +1,31 @@ +/** +TEST_OUTPUT: +--- +fail_compilation/cmodule_malformed.c(15): Error: identifier expected following `module` +fail_compilation/cmodule_malformed.c(15): Error: no type for declarator before `"a"` +fail_compilation/cmodule_malformed.c(21): Error: no type-specifier for struct member +fail_compilation/cmodule_malformed.c(21): Error: identifier or `(` expected +fail_compilation/cmodule_malformed.c(21): Error: expected identifier for declarator +fail_compilation/cmodule_malformed.c(26): Error: found `__module` instead of statement +--- +*/ + +#if __IMPORTC__ + +__module "a"; + +typedef struct S +{ + int x; + + __module b; +} S; + +void main(void) +{ + __module c.d; +} + +__module e; + +#endif diff --git a/tests/dmd/unit/lexer/location_offset.d b/tests/dmd/unit/lexer/location_offset.d index fb7edfd5eb..d599946b38 100644 --- a/tests/dmd/unit/lexer/location_offset.d +++ b/tests/dmd/unit/lexer/location_offset.d @@ -542,6 +542,7 @@ enum ignoreTokens _assert, _import, + _module, __cdecl, __declspec, __stdcall, From 1ef20c61faa23a206493c3644ae1a0a2c8feb2c0 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Tue, 21 Oct 2025 22:13:05 +0800 Subject: [PATCH 040/440] fix dlang/dmd#21797 - no `version` set for `-profile` (dlang/dmd!21798) --- dmd/target.d | 3 +++ tests/dmd/fail_compilation/reserved_version.d | 3 ++- tests/dmd/fail_compilation/reserved_version_switch.d | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dmd/target.d b/dmd/target.d index f739cbfe35..068766377c 100644 --- a/dmd/target.d +++ b/dmd/target.d @@ -150,6 +150,9 @@ void addDefaultVersionIdentifiers(const ref Param params, const ref Target tgt) VersionCondition.addPredefinedGlobalIdent("D_HardFloat"); + if (params.trace) + VersionCondition.addPredefinedGlobalIdent("D_Profile"); + if (params.tracegc) VersionCondition.addPredefinedGlobalIdent("D_ProfileGC"); diff --git a/tests/dmd/fail_compilation/reserved_version.d b/tests/dmd/fail_compilation/reserved_version.d index 2432d1b30e..b64b80ce90 100644 --- a/tests/dmd/fail_compilation/reserved_version.d +++ b/tests/dmd/fail_compilation/reserved_version.d @@ -124,11 +124,11 @@ fail_compilation/reserved_version.d(225): Error: version identifier `D_ProfileGC fail_compilation/reserved_version.d(226): Error: version identifier `D_Invariants` is reserved and cannot be set fail_compilation/reserved_version.d(227): Error: version identifier `D_Optimized` is reserved and cannot be set fail_compilation/reserved_version.d(228): Error: version identifier `VisionOS` is reserved and cannot be set +fail_compilation/reserved_version.d(229): Error: version identifier `D_Profile` is reserved and cannot be set --- */ // Some extra empty lines to help fixup the manual line numbering after adding new version identifiers - #line 105 version = MSP430; version = D_P16; @@ -254,6 +254,7 @@ version = D_ProfileGC; version = D_Invariants; version = D_Optimized; version = VisionOS; +version = D_Profile; // This should work though debug = DigitalMars; diff --git a/tests/dmd/fail_compilation/reserved_version_switch.d b/tests/dmd/fail_compilation/reserved_version_switch.d index f124a3bf80..1d82b22f94 100644 --- a/tests/dmd/fail_compilation/reserved_version_switch.d +++ b/tests/dmd/fail_compilation/reserved_version_switch.d @@ -110,6 +110,7 @@ // REQUIRED_ARGS: -version=none // REQUIRED_ARGS: -version=D_PreConditions // REQUIRED_ARGS: -version=D_PostConditions +// REQUIRED_ARGS: -version=D_Profile // REQUIRED_ARGS: -version=D_ProfileGC // REQUIRED_ARGS: -version=D_Invariants // REQUIRED_ARGS: -version=D_Optimized @@ -336,6 +337,7 @@ Error: version identifier `all` is reserved and cannot be set Error: version identifier `none` is reserved and cannot be set Error: version identifier `D_PreConditions` is reserved and cannot be set Error: version identifier `D_PostConditions` is reserved and cannot be set +Error: version identifier `D_Profile` is reserved and cannot be set Error: version identifier `D_ProfileGC` is reserved and cannot be set Error: version identifier `D_Invariants` is reserved and cannot be set Error: version identifier `D_Optimized` is reserved and cannot be set From 15c71fc867e72a33d4a25b58039915b4608beaec Mon Sep 17 00:00:00 2001 From: Steven Schveighoffer Date: Wed, 22 Oct 2025 18:57:11 -0400 Subject: [PATCH 041/440] fix(GC): Fix dlang/dmd!22004 - Setting array length of valid trailing slice (dlang/dmd!22009) should not reallocate if it will fit in the block. --- .../core/internal/gc/impl/conservative/gc.d | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d b/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d index e4a8cdea3c..af7ea7901f 100644 --- a/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d +++ b/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d @@ -1513,7 +1513,7 @@ class ConservativeGC : GC auto existingUsed = slice.length + offset; size_t typeInfoSize = (info.attr & BlkAttr.STRUCTFINAL) ? size_t.sizeof : 0; - if (__setArrayAllocLengthImpl(info, offset + newUsed, atomic, existingUsed, typeInfoSize)) + if (__setArrayAllocLengthImpl(info, newUsed, atomic, existingUsed, typeInfoSize)) { // could expand without extending if (!bic && !atomic) @@ -5397,6 +5397,31 @@ unittest } } +// https://github.com/dlang/dmd/issues/22004 +@safe unittest +{ +outer: + foreach (i; 1 .. 100) + { + foreach (j; 0 .. i) + { + int[] orig; + orig.length = i; + if (orig.capacity == orig.length) + // skip legitimate realloc cases + continue outer; + + int[] slice = orig[j .. $]; + assert(slice.capacity != 0); + + auto ptr = &slice[0]; + slice.length += 1; + // should not have realloc'd + assert(&slice[0] is ptr); + } + } +} + // https://github.com/dlang/dmd/issues/21615 debug(SENTINEL) {} else // no additional capacity with SENTINEL version (OnlyLowMemUnittests) {} else From 203efc619b7efcd9df4c2ca9a79aedeaa545b080 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 24 Oct 2025 06:42:52 +0300 Subject: [PATCH 042/440] Move `Type.hasInvariant` to `dmd/typesem` (dlang/dmd!22018) --- dmd/cxxfrontend.d | 6 ++++++ dmd/frontend.h | 4 ---- dmd/mtype.d | 26 -------------------------- dmd/mtype.h | 5 +---- dmd/safe.d | 2 +- dmd/typesem.d | 22 ++++++++++++++++++++++ 6 files changed, 30 insertions(+), 35 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 542671b29b..db056985c7 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -873,6 +873,12 @@ bool hasUnsafeBitpatterns(Type type) return dmd.typesem.hasUnsafeBitpatterns(type); } +bool hasInvariant(Type type) +{ + import dmd.typesem; + return dmd.typesem.hasInvariant(type); +} + /*********************************************************** * typinf.d */ diff --git a/dmd/frontend.h b/dmd/frontend.h index 83919b6d0e..223e2893c9 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2108,7 +2108,6 @@ class Type : public ASTNode virtual structalign_t alignment(); virtual int32_t hasWild() const; virtual bool hasVoidInitPointers(); - virtual bool hasInvariant(); virtual Type* nextOf(); Type* baseElemOf(); virtual bool needsDestruction(); @@ -4518,7 +4517,6 @@ class TypeEnum final : public Type bool needsCopyOrPostblit() override; bool needsNested() override; bool hasVoidInitPointers() override; - bool hasInvariant() override; Type* nextOf() override; void accept(Visitor* v) override; }; @@ -4749,7 +4747,6 @@ class TypeSArray final : public TypeArray bool isString() override; structalign_t alignment() override; bool hasVoidInitPointers() override; - bool hasInvariant() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; @@ -4782,7 +4779,6 @@ class TypeStruct final : public Type bool needsCopyOrPostblit() override; bool needsNested() override; bool hasVoidInitPointers() override; - bool hasInvariant() override; uint8_t deduceWild(Type* t, bool isRef) override; void accept(Visitor* v) override; }; diff --git a/dmd/mtype.d b/dmd/mtype.d index cc31d18e5d..ea207d32a8 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1348,15 +1348,6 @@ extern (C++) abstract class Type : ASTNode return false; } - /*************************************** - * Returns: true if type has any invariants - */ - bool hasInvariant() - { - //printf("Type::hasInvariant() %s, %d\n", toChars(), ty); - return false; - } - /************************************* * If this is a type of something, return that something. */ @@ -2186,11 +2177,6 @@ extern (C++) final class TypeSArray : TypeArray return next.hasVoidInitPointers(); } - override bool hasInvariant() - { - return next.hasInvariant(); - } - override bool needsDestruction() { return next.needsDestruction(); @@ -2987,13 +2973,6 @@ extern (C++) final class TypeStruct : Type return sym.hasVoidInitPointers; } - override bool hasInvariant() - { - sym.size(Loc.initial); // give error for forward references - sym.determineTypeProperties(); - return sym.hasInvariant() || sym.hasFieldWithInvariant; - } - override MOD deduceWild(Type t, bool isRef) { if (ty == t.ty && sym == (cast(TypeStruct)t).sym) @@ -3128,11 +3107,6 @@ extern (C++) final class TypeEnum : Type return memType().hasVoidInitPointers(); } - override bool hasInvariant() - { - return memType().hasInvariant(); - } - override Type nextOf() { return memType().nextOf(); diff --git a/dmd/mtype.h b/dmd/mtype.h index fe8a215d53..e0c67bce6d 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -267,7 +267,6 @@ class Type : public ASTNode virtual structalign_t alignment(); virtual int hasWild() const; virtual bool hasVoidInitPointers(); - virtual bool hasInvariant(); virtual Type *nextOf(); Type *baseElemOf(); virtual bool needsDestruction(); @@ -397,7 +396,6 @@ class TypeSArray final : public TypeArray bool isString() override; structalign_t alignment() override; bool hasVoidInitPointers() override; - bool hasInvariant() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; @@ -690,7 +688,6 @@ class TypeStruct final : public Type bool needsCopyOrPostblit() override; bool needsNested() override; bool hasVoidInitPointers() override; - bool hasInvariant() override; unsigned char deduceWild(Type *t, bool isRef) override; void accept(Visitor *v) override { v->visit(this); } @@ -718,7 +715,6 @@ class TypeEnum final : public Type bool needsCopyOrPostblit() override; bool needsNested() override; bool hasVoidInitPointers() override; - bool hasInvariant() override; Type *nextOf() override; void accept(Visitor *v) override { v->visit(this); } @@ -840,4 +836,5 @@ namespace dmd MATCH implicitConvTo(Type* from, Type* to); MATCH constConv(Type* from, Type* to); bool hasUnsafeBitpatterns(Type* type); + bool hasInvariant(Type* type); } diff --git a/dmd/safe.d b/dmd/safe.d index b8b270c03b..9cd3b8ea34 100644 --- a/dmd/safe.d +++ b/dmd/safe.d @@ -38,7 +38,7 @@ import dmd.root.string : fTuple; import dmd.target; import dmd.targetcompiler; import dmd.tokens; -import dmd.typesem : hasPointers, arrayOf, size, hasUnsafeBitpatterns; +import dmd.typesem : hasPointers, arrayOf, size, hasUnsafeBitpatterns, hasInvariant; /************************************************************* * Check for unsafe access in @safe code: diff --git a/dmd/typesem.d b/dmd/typesem.d index 7fe57dff3c..1253082895 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -72,6 +72,28 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; +/*************************************** + * Returns: true if type has any invariants + */ +bool hasInvariant(Type _this) +{ + if (auto tsa = _this.isTypeSArray()) + { + return tsa.next.hasInvariant(); + } + else if (auto ts = _this.isTypeStruct()) + { + import dmd.dsymbolsem : size; + ts.sym.size(Loc.initial); // give error for forward references + ts.sym.determineTypeProperties(); + return ts.sym.hasInvariant() || ts.sym.hasFieldWithInvariant; + } + else if (auto te = _this.isTypeEnum()) + { + return te.memType().hasInvariant(); + } + return false; +} /************************************* * Detect if this is an unsafe type because of the presence of `@system` members From 942d0b7f7c651c5d82a18cb2b6e9767c8e0de6aa Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Fri, 24 Oct 2025 12:44:24 +0200 Subject: [PATCH 043/440] redirect output of gc/printf test to file to avoid pollution of CI logs (dlang/dmd!22021) --- runtime/druntime/test/gc/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/druntime/test/gc/Makefile b/runtime/druntime/test/gc/Makefile index 3d5acdc564..cb96de7f61 100644 --- a/runtime/druntime/test/gc/Makefile +++ b/runtime/druntime/test/gc/Makefile @@ -50,6 +50,7 @@ $(ROOT)/printf$(DOTEXE): $(src_gc) $(ROOT)/printf$(DOTEXE): private extra_sources = $(src_gc) $(ROOT)/printf$(DOTEXE): extra_dflags += \ -debug=PRINTF -debug=PRINTF_TO_FILE -debug=COLLECT_PRINTF -version=OnlyLowMemUnittests $(core_ut) -main +$(ROOT)/printf.done: run_args += >$(ROOT)/printf.log $(ROOT)/memstomp$(DOTEXE): $(src_lifetime) $(ROOT)/memstomp$(DOTEXE): private extra_sources = $(src_lifetime) From a0df8a039d73604d094b64b7a3a43d384160cb58 Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Fri, 24 Oct 2025 16:31:38 +0200 Subject: [PATCH 044/440] fix building with dmd versions 2.089 to 2.093 (dlang/dmd!22017) --- dmd/dfa/fast/analysis.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dmd/dfa/fast/analysis.d b/dmd/dfa/fast/analysis.d index 8a0f31ec76..b21fecf8ee 100644 --- a/dmd/dfa/fast/analysis.d +++ b/dmd/dfa/fast/analysis.d @@ -506,11 +506,11 @@ struct DFAAnalyzer if (cGate.writeOnVarAtThisPoint < cGate.var.writeCount) continue; - DFAScopeVar* scv = dfaCommon.acquireScopeVar(cGate.var); - if (scv is null) + DFAScopeVar* scv2 = dfaCommon.acquireScopeVar(cGate.var); + if (scv2 is null) continue; - DFAConsequence* cCurrent = scv.lr.getContext; + DFAConsequence* cCurrent = scv2.lr.getContext; assert(cCurrent !is null); cCurrent.joinConsequence(cCurrent, cGate, null, false); From b7fdf876edd240b5e7d05faa2a93aa1d43ec86c6 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 25 Oct 2025 03:33:00 +0300 Subject: [PATCH 045/440] Move `Type.alignment` to `dmd/typesem` (dlang/dmd!22024) --- dmd/cxxfrontend.d | 6 ++++++ dmd/dsymbolsem.d | 4 ++++ dmd/frontend.h | 3 --- dmd/mtype.d | 22 ---------------------- dmd/mtype.h | 4 +--- dmd/safe.d | 2 +- dmd/typesem.d | 21 +++++++++++++++++++++ 7 files changed, 33 insertions(+), 29 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index db056985c7..d5315aa080 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -849,6 +849,12 @@ uinteger_t size(Type type, Loc loc) return dmd.typesem.size(type, loc); } +structalign_t alignment(Type type) +{ + import dmd.typesem; + return dmd.typesem.alignment(type); +} + MATCH implicitConvTo(Type from, Type to) { import dmd.dcast; diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 6ee0e4d64e..bae8c86c09 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -136,6 +136,7 @@ void makeNested(AggregateDeclaration _this) } if (_this.enclosing) { + import dmd.typesem : alignment; //printf("makeNested %s, enclosing = %s\n", toChars(), enclosing.toChars()); assert(t); if (t.ty == Tstruct) @@ -166,6 +167,8 @@ void makeNested(AggregateDeclaration _this) */ void makeNested2(AggregateDeclaration _this) { + import dmd.typesem : alignment; + if (_this.vthis2) return; if (!_this.vthis) @@ -2083,6 +2086,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor /* If scope's alignment is the default, use the type's alignment, * otherwise the scope overrrides. */ + import dmd.typesem : alignment; if (dsym.alignment.isDefault()) dsym.alignment = dsym.type.alignment(); // use type's alignment diff --git a/dmd/frontend.h b/dmd/frontend.h index 223e2893c9..1cf18b1c3d 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2105,7 +2105,6 @@ class Type : public ASTNode Type* toBasetype(); virtual uint8_t deduceWild(Type* t, bool isRef); virtual ClassDeclaration* isClassHandle(); - virtual structalign_t alignment(); virtual int32_t hasWild() const; virtual bool hasVoidInitPointers(); virtual Type* nextOf(); @@ -4745,7 +4744,6 @@ class TypeSArray final : public TypeArray bool isIncomplete(); uint32_t alignsize() override; bool isString() override; - structalign_t alignment() override; bool hasVoidInitPointers() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; @@ -4773,7 +4771,6 @@ class TypeStruct final : public Type const char* kind() const override; uint32_t alignsize() override; TypeStruct* syntaxCopy() override; - structalign_t alignment() override; bool isBoolean() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; diff --git a/dmd/mtype.d b/dmd/mtype.d index ea207d32a8..b9490ab934 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1318,16 +1318,6 @@ extern (C++) abstract class Type : ASTNode return null; } - /************************************ - * Return alignment to use for this type. - */ - structalign_t alignment() - { - structalign_t s; - s.setDefault(); - return s; - } - /*************************************** * Return !=0 if the type or any of its subtypes is wild. */ @@ -2167,11 +2157,6 @@ extern (C++) final class TypeSArray : TypeArray return nty.isSomeChar; } - override structalign_t alignment() - { - return next.alignment(); - } - override bool hasVoidInitPointers() { return next.hasVoidInitPointers(); @@ -2925,13 +2910,6 @@ extern (C++) final class TypeStruct : Type return this; } - override structalign_t alignment() - { - if (sym.alignment.isUnknown()) - sym.size(sym.loc); - return sym.alignment; - } - override bool isBoolean() { return false; diff --git a/dmd/mtype.h b/dmd/mtype.h index e0c67bce6d..54245b2162 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -264,7 +264,6 @@ class Type : public ASTNode virtual unsigned char deduceWild(Type *t, bool isRef); virtual ClassDeclaration *isClassHandle(); - virtual structalign_t alignment(); virtual int hasWild() const; virtual bool hasVoidInitPointers(); virtual Type *nextOf(); @@ -394,7 +393,6 @@ class TypeSArray final : public TypeArray bool isIncomplete(); unsigned alignsize() override; bool isString() override; - structalign_t alignment() override; bool hasVoidInitPointers() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; @@ -682,7 +680,6 @@ class TypeStruct final : public Type const char *kind() override; unsigned alignsize() override; TypeStruct *syntaxCopy() override; - structalign_t alignment() override; bool isBoolean() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; @@ -837,4 +834,5 @@ namespace dmd MATCH constConv(Type* from, Type* to); bool hasUnsafeBitpatterns(Type* type); bool hasInvariant(Type* type); + structalign_t alignment(Type* type); } diff --git a/dmd/safe.d b/dmd/safe.d index 9cd3b8ea34..672acb23cd 100644 --- a/dmd/safe.d +++ b/dmd/safe.d @@ -38,7 +38,7 @@ import dmd.root.string : fTuple; import dmd.target; import dmd.targetcompiler; import dmd.tokens; -import dmd.typesem : hasPointers, arrayOf, size, hasUnsafeBitpatterns, hasInvariant; +import dmd.typesem : hasPointers, arrayOf, size, hasUnsafeBitpatterns, hasInvariant, alignment; /************************************************************* * Check for unsafe access in @safe code: diff --git a/dmd/typesem.d b/dmd/typesem.d index 1253082895..4406b30ee7 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -72,6 +72,27 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; +/************************************ + * Return alignment to use for this type. + */ +structalign_t alignment(Type _this) +{ + if (auto tsa = _this.isTypeSArray()) + { + return tsa.next.alignment(); + } + else if (auto ts = _this.isTypeStruct()) + { + import dmd.dsymbolsem : size; + if (ts.sym.alignment.isUnknown()) + ts.sym.size(ts.sym.loc); + return ts.sym.alignment; + } + structalign_t s; + s.setDefault(); + return s; +} + /*************************************** * Returns: true if type has any invariants */ From d3c847450d5146778dd1be1cc2b514fc64efa4db Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 25 Oct 2025 04:35:26 +0300 Subject: [PATCH 046/440] Move `Type._init` to `dmd/typesem` (dlang/dmd!22025) --- dmd/cxxfrontend.d | 6 ++ dmd/frontend.h | 1 - dmd/iasm/gcc.d | 2 +- dmd/main.d | 3 +- dmd/mtype.d | 120 ------------------------------ dmd/mtype.h | 2 +- dmd/typesem.d | 120 ++++++++++++++++++++++++++++++ tests/dmd/unit/deinitialization.d | 3 +- 8 files changed, 132 insertions(+), 125 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index d5315aa080..d2a737b78c 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -885,6 +885,12 @@ bool hasInvariant(Type type) return dmd.typesem.hasInvariant(type); } +void Type_init() +{ + import dmd.typesem; + return dmd.typesem.Type_init(); +} + /*********************************************************** * typinf.d */ diff --git a/dmd/frontend.h b/dmd/frontend.h index 1cf18b1c3d..c043426b40 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2067,7 +2067,6 @@ class Type : public ASTNode size_t getUniqueID() const; const char* toChars() const final override; char* toPrettyChars(bool QualifyTypes = false); - static void _init(); static void deinitialize(); virtual uint32_t alignsize(); void modToBuffer(OutBuffer& buf) const; diff --git a/dmd/iasm/gcc.d b/dmd/iasm/gcc.d index 4be94d76ad..25322c0e75 100644 --- a/dmd/iasm/gcc.d +++ b/dmd/iasm/gcc.d @@ -560,7 +560,7 @@ unittest const errors = global.startGagging(); scope(exit) global.endGagging(errors); - // If this check fails, then Type._init() was called before reaching here, + // If this check fails, then Type_init() was called before reaching here, // and the entire chunk of code that follows can be removed. assert(ASTCodegen.Type.tint32 is null); // Minimally initialize the cached types in ASTCodegen.Type, as they are diff --git a/dmd/main.d b/dmd/main.d index 5341f66112..74aadb482f 100644 --- a/dmd/main.d +++ b/dmd/main.d @@ -35,6 +35,7 @@ import dmd.dinifile; import dmd.dinterpret; import dmd.dmdparams; import dmd.dsymbolsem; +import dmd.typesem : Type_init; import dmd.dtemplate; import dmd.dtoh; import dmd.glue : generateCodeAndWrite, ObjcGlue_initialize; @@ -375,7 +376,7 @@ private int tryMain(const(char)[][] argv, out Param params) // Initialization target._init(params); - Type._init(); + Type_init(); Id.initialize(); Module._init(); Expression._init(); diff --git a/dmd/mtype.d b/dmd/mtype.d index b9490ab934..94a8d549f7 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -500,126 +500,6 @@ extern (C++) abstract class Type : ASTNode return buf.extractChars(); } - static void _init() - { - stringtable._init(14_000); - - // Set basic types - __gshared TY* basetab = - [ - Tvoid, - Tint8, - Tuns8, - Tint16, - Tuns16, - Tint32, - Tuns32, - Tint64, - Tuns64, - Tint128, - Tuns128, - Tfloat32, - Tfloat64, - Tfloat80, - Timaginary32, - Timaginary64, - Timaginary80, - Tcomplex32, - Tcomplex64, - Tcomplex80, - Tbool, - Tchar, - Twchar, - Tdchar, - Terror - ]; - - static Type merge(Type t) - { - import dmd.mangle.basic : tyToDecoBuffer; - - OutBuffer buf; - buf.reserve(3); - - if (t.ty == Tnoreturn) - buf.writestring("Nn"); - else - tyToDecoBuffer(buf, t.ty); - - auto sv = t.stringtable.update(buf[]); - if (sv.value) - return sv.value; - t.deco = cast(char*)sv.toDchars(); - sv.value = t; - return t; - } - - for (size_t i = 0; basetab[i] != Terror; i++) - { - Type t = new TypeBasic(basetab[i]); - t = merge(t); - basic[basetab[i]] = t; - } - basic[Terror] = new TypeError(); - - tnoreturn = new TypeNoreturn(); - tnoreturn.deco = merge(tnoreturn).deco; - basic[Tnoreturn] = tnoreturn; - - tvoid = basic[Tvoid]; - tint8 = basic[Tint8]; - tuns8 = basic[Tuns8]; - tint16 = basic[Tint16]; - tuns16 = basic[Tuns16]; - tint32 = basic[Tint32]; - tuns32 = basic[Tuns32]; - tint64 = basic[Tint64]; - tuns64 = basic[Tuns64]; - tint128 = basic[Tint128]; - tuns128 = basic[Tuns128]; - tfloat32 = basic[Tfloat32]; - tfloat64 = basic[Tfloat64]; - tfloat80 = basic[Tfloat80]; - - timaginary32 = basic[Timaginary32]; - timaginary64 = basic[Timaginary64]; - timaginary80 = basic[Timaginary80]; - - tcomplex32 = basic[Tcomplex32]; - tcomplex64 = basic[Tcomplex64]; - tcomplex80 = basic[Tcomplex80]; - - tbool = basic[Tbool]; - tchar = basic[Tchar]; - twchar = basic[Twchar]; - tdchar = basic[Tdchar]; - - tshiftcnt = tint32; - terror = basic[Terror]; - tnoreturn = basic[Tnoreturn]; - tnull = new TypeNull(); - tnull.deco = merge(tnull).deco; - - tvoidptr = tvoid.pointerTo(); - tstring = tchar.immutableOf().arrayOf(); - twstring = twchar.immutableOf().arrayOf(); - tdstring = tdchar.immutableOf().arrayOf(); - - const isLP64 = target.isLP64; - - tsize_t = basic[isLP64 ? Tuns64 : Tuns32]; - tptrdiff_t = basic[isLP64 ? Tint64 : Tint32]; - thash_t = tsize_t; - - static if (__VERSION__ == 2081) - { - // Related issue: https://issues.dlang.org/show_bug.cgi?id=19134 - // D 2.081.x regressed initializing class objects at compile time. - // As a workaround initialize this global at run-time instead. - TypeTuple.empty = new TypeTuple(); - } - } - /** * Deinitializes the global state of the compiler. * diff --git a/dmd/mtype.h b/dmd/mtype.h index 54245b2162..b697569e49 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -224,7 +224,6 @@ class Type : public ASTNode size_t getUniqueID() const; const char *toChars() const override; char *toPrettyChars(bool QualifyTypes = false); - static void _init(); virtual unsigned alignsize(); void modToBuffer(OutBuffer& buf) const; @@ -834,5 +833,6 @@ namespace dmd MATCH constConv(Type* from, Type* to); bool hasUnsafeBitpatterns(Type* type); bool hasInvariant(Type* type); + void Type_init(); structalign_t alignment(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index 4406b30ee7..9df6435764 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -72,6 +72,126 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; +void Type_init() +{ + Type.stringtable._init(14_000); + + // Set basic types + __gshared TY* basetab = + [ + Tvoid, + Tint8, + Tuns8, + Tint16, + Tuns16, + Tint32, + Tuns32, + Tint64, + Tuns64, + Tint128, + Tuns128, + Tfloat32, + Tfloat64, + Tfloat80, + Timaginary32, + Timaginary64, + Timaginary80, + Tcomplex32, + Tcomplex64, + Tcomplex80, + Tbool, + Tchar, + Twchar, + Tdchar, + Terror + ]; + + static Type merge(Type t) + { + import dmd.mangle.basic : tyToDecoBuffer; + + OutBuffer buf; + buf.reserve(3); + + if (t.ty == Tnoreturn) + buf.writestring("Nn"); + else + tyToDecoBuffer(buf, t.ty); + + auto sv = t.stringtable.update(buf[]); + if (sv.value) + return sv.value; + t.deco = cast(char*)sv.toDchars(); + sv.value = t; + return t; + } + + for (size_t i = 0; basetab[i] != Terror; i++) + { + Type t = new TypeBasic(basetab[i]); + t = merge(t); + Type.basic[basetab[i]] = t; + } + Type.basic[Terror] = new TypeError(); + + Type.tnoreturn = new TypeNoreturn(); + Type.tnoreturn.deco = merge(Type.tnoreturn).deco; + Type.basic[Tnoreturn] = Type.tnoreturn; + + Type.tvoid = Type.basic[Tvoid]; + Type.tint8 = Type.basic[Tint8]; + Type.tuns8 = Type.basic[Tuns8]; + Type.tint16 = Type.basic[Tint16]; + Type.tuns16 = Type.basic[Tuns16]; + Type.tint32 = Type.basic[Tint32]; + Type.tuns32 = Type.basic[Tuns32]; + Type.tint64 = Type.basic[Tint64]; + Type.tuns64 = Type.basic[Tuns64]; + Type.tint128 = Type.basic[Tint128]; + Type.tuns128 = Type.basic[Tuns128]; + Type.tfloat32 = Type.basic[Tfloat32]; + Type.tfloat64 = Type.basic[Tfloat64]; + Type.tfloat80 = Type.basic[Tfloat80]; + + Type.timaginary32 = Type.basic[Timaginary32]; + Type.timaginary64 = Type.basic[Timaginary64]; + Type.timaginary80 = Type.basic[Timaginary80]; + + Type.tcomplex32 = Type.basic[Tcomplex32]; + Type.tcomplex64 = Type.basic[Tcomplex64]; + Type.tcomplex80 = Type.basic[Tcomplex80]; + + Type.tbool = Type.basic[Tbool]; + Type.tchar = Type.basic[Tchar]; + Type.twchar = Type.basic[Twchar]; + Type.tdchar = Type.basic[Tdchar]; + + Type.tshiftcnt = Type.tint32; + Type.terror = Type.basic[Terror]; + Type.tnoreturn = Type.basic[Tnoreturn]; + Type.tnull = new TypeNull(); + Type.tnull.deco = merge(Type.tnull).deco; + + Type.tvoidptr = Type.tvoid.pointerTo(); + Type.tstring = Type.tchar.immutableOf().arrayOf(); + Type.twstring = Type.twchar.immutableOf().arrayOf(); + Type.tdstring = Type.tdchar.immutableOf().arrayOf(); + + const isLP64 = target.isLP64; + + Type.tsize_t = Type.basic[isLP64 ? Tuns64 : Tuns32]; + Type.tptrdiff_t = Type.basic[isLP64 ? Tint64 : Tint32]; + Type.thash_t = Type.tsize_t; + + static if (__VERSION__ == 2081) + { + // Related issue: https://issues.dlang.org/show_bug.cgi?id=19134 + // D 2.081.x regressed initializing class objects at compile time. + // As a workaround initialize this global at run-time instead. + TypeTuple.empty = new TypeTuple(); + } +} + /************************************ * Return alignment to use for this type. */ diff --git a/tests/dmd/unit/deinitialization.d b/tests/dmd/unit/deinitialization.d index e583631d81..9196b811af 100644 --- a/tests/dmd/unit/deinitialization.d +++ b/tests/dmd/unit/deinitialization.d @@ -36,12 +36,13 @@ unittest import dmd.target : addDefaultVersionIdentifiers; import dmd.mtype : Type; import dmd.globals : global; + import dmd.typesem : Type_init; assert(Type.stringtable == Type.stringtable.init); global._init(); - Type._init(); + Type_init(); Type.deinitialize(); global.deinitialize(); From 3d5fe594abfe308dd92ade9e409c1f56bfe6921a Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sun, 26 Oct 2025 02:41:21 +0300 Subject: [PATCH 047/440] Move `Type.hasVoidInitPointers` to `dmd/typesem` (dlang/dmd!22023) --- dmd/cxxfrontend.d | 6 ++++++ dmd/frontend.h | 4 ---- dmd/mtype.d | 29 ----------------------------- dmd/mtype.h | 5 +---- dmd/typesem.d | 28 ++++++++++++++++++++++++++++ 5 files changed, 35 insertions(+), 37 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index d2a737b78c..566f12181b 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -885,6 +885,12 @@ bool hasInvariant(Type type) return dmd.typesem.hasInvariant(type); } +bool hasVoidInitPointers(Type type) +{ + import dmd.typesem; + return dmd.typesem.hasVoidInitPointers(type); +} + void Type_init() { import dmd.typesem; diff --git a/dmd/frontend.h b/dmd/frontend.h index c043426b40..aaa10aad24 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2105,7 +2105,6 @@ class Type : public ASTNode virtual uint8_t deduceWild(Type* t, bool isRef); virtual ClassDeclaration* isClassHandle(); virtual int32_t hasWild() const; - virtual bool hasVoidInitPointers(); virtual Type* nextOf(); Type* baseElemOf(); virtual bool needsDestruction(); @@ -4514,7 +4513,6 @@ class TypeEnum final : public Type bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; - bool hasVoidInitPointers() override; Type* nextOf() override; void accept(Visitor* v) override; }; @@ -4743,7 +4741,6 @@ class TypeSArray final : public TypeArray bool isIncomplete(); uint32_t alignsize() override; bool isString() override; - bool hasVoidInitPointers() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; @@ -4774,7 +4771,6 @@ class TypeStruct final : public Type bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; - bool hasVoidInitPointers() override; uint8_t deduceWild(Type* t, bool isRef) override; void accept(Visitor* v) override; }; diff --git a/dmd/mtype.d b/dmd/mtype.d index 94a8d549f7..d843f5e3ba 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1206,18 +1206,6 @@ extern (C++) abstract class Type : ASTNode return mod & MODFlags.wild; } - /************************************* - * Detect if type has pointer fields that are initialized to void. - * Local stack variables with such void fields can remain uninitialized, - * leading to pointer bugs. - * Returns: - * true if so - */ - bool hasVoidInitPointers() - { - return false; - } - /************************************* * If this is a type of something, return that something. */ @@ -2037,11 +2025,6 @@ extern (C++) final class TypeSArray : TypeArray return nty.isSomeChar; } - override bool hasVoidInitPointers() - { - return next.hasVoidInitPointers(); - } - override bool needsDestruction() { return next.needsDestruction(); @@ -2824,13 +2807,6 @@ extern (C++) final class TypeStruct : Type return false; } - override bool hasVoidInitPointers() - { - sym.size(Loc.initial); // give error for forward references - sym.determineTypeProperties(); - return sym.hasVoidInitPointers; - } - override MOD deduceWild(Type t, bool isRef) { if (ty == t.ty && sym == (cast(TypeStruct)t).sym) @@ -2960,11 +2936,6 @@ extern (C++) final class TypeEnum : Type return tb.castMod(mod); // retain modifier bits from 'this' } - override bool hasVoidInitPointers() - { - return memType().hasVoidInitPointers(); - } - override Type nextOf() { return memType().nextOf(); diff --git a/dmd/mtype.h b/dmd/mtype.h index b697569e49..ff062b1209 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -264,7 +264,6 @@ class Type : public ASTNode virtual ClassDeclaration *isClassHandle(); virtual int hasWild() const; - virtual bool hasVoidInitPointers(); virtual Type *nextOf(); Type *baseElemOf(); virtual bool needsDestruction(); @@ -392,7 +391,6 @@ class TypeSArray final : public TypeArray bool isIncomplete(); unsigned alignsize() override; bool isString() override; - bool hasVoidInitPointers() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; @@ -683,7 +681,6 @@ class TypeStruct final : public Type bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; - bool hasVoidInitPointers() override; unsigned char deduceWild(Type *t, bool isRef) override; void accept(Visitor *v) override { v->visit(this); } @@ -710,7 +707,6 @@ class TypeEnum final : public Type bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; - bool hasVoidInitPointers() override; Type *nextOf() override; void accept(Visitor *v) override { v->visit(this); } @@ -833,6 +829,7 @@ namespace dmd MATCH constConv(Type* from, Type* to); bool hasUnsafeBitpatterns(Type* type); bool hasInvariant(Type* type); + bool hasVoidInitPointers(Type* type); void Type_init(); structalign_t alignment(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index 9df6435764..a3fbdacc45 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -72,6 +72,34 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; +/************************************* + * Detect if type has pointer fields that are initialized to void. + * Local stack variables with such void fields can remain uninitialized, + * leading to pointer bugs. + * Returns: + * true if so + */ + +bool hasVoidInitPointers(Type _this) +{ + if (auto tsa = _this.isTypeSArray()) + { + return tsa.next.hasVoidInitPointers(); + } + else if (auto ts = _this.isTypeStruct()) + { + import dmd.dsymbolsem : size; + ts.sym.size(Loc.initial); // give error for forward references + ts.sym.determineTypeProperties(); + return ts.sym.hasVoidInitPointers; + } + else if (auto te = _this.isTypeEnum()) + { + return te.memType().hasVoidInitPointers(); + } + return false; +} + void Type_init() { Type.stringtable._init(14_000); From 9888b8af6c6fb8a4ff5129a1b7d8273eae2ada01 Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Mon, 27 Oct 2025 11:50:09 +1300 Subject: [PATCH 048/440] Implement thread grave digger handling of exceptions (dlang/dmd!22029) --- runtime/druntime/src/core/exception.d | 22 +++++++++- runtime/druntime/src/core/thread/osthread.d | 8 +++- runtime/druntime/src/core/thread/threadbase.d | 19 +++++++++ runtime/druntime/test/thread/Makefile | 2 +- .../test/thread/src/filterthrownglobal.d | 31 ++++++++++++++ .../test/thread/src/filterthrownmethod.d | 41 +++++++++++++++++++ 6 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 runtime/druntime/test/thread/src/filterthrownglobal.d create mode 100644 runtime/druntime/test/thread/src/filterthrownmethod.d diff --git a/runtime/druntime/src/core/exception.d b/runtime/druntime/src/core/exception.d index c7b302c452..e1b69583e0 100644 --- a/runtime/druntime/src/core/exception.d +++ b/runtime/druntime/src/core/exception.d @@ -528,7 +528,11 @@ unittest // behavior should occur within the handler itself. This delegate // is __gshared for now based on the assumption that it will only // set by the main thread during program initialization. -private __gshared AssertHandler _assertHandler = null; +private __gshared +{ + AssertHandler _assertHandler = null; + FilterThreadThrowableHandler _filterThreadThrowableHandler = null; +} /** @@ -548,6 +552,22 @@ alias AssertHandler = void function(string file, size_t line, string msg) nothro _assertHandler = handler; } +/** +Gets/sets the Throwable filter function for threads. null means no handler is called. +*/ +alias FilterThreadThrowableHandler = void function(ref Throwable) @system nothrow; + +/// ditto +@property FilterThreadThrowableHandler filterThreadThrowableHandler() @trusted nothrow @nogc +{ + return _filterThreadThrowableHandler; +} + +/// ditto +@property void filterThreadThrowableHandler(FilterThreadThrowableHandler handler) @trusted nothrow @nogc +{ + _filterThreadThrowableHandler = handler; +} /////////////////////////////////////////////////////////////////////////////// // Overridable Callbacks diff --git a/runtime/druntime/src/core/thread/osthread.d b/runtime/druntime/src/core/thread/osthread.d index 1b5e78f4ba..c72bbd8392 100644 --- a/runtime/druntime/src/core/thread/osthread.d +++ b/runtime/druntime/src/core/thread/osthread.d @@ -2368,7 +2368,9 @@ version (Windows) void append( Throwable t ) { - obj.m_unhandled = Throwable.chainTogether(obj.m_unhandled, t); + obj.filterCaughtThrowable(t); + if (t !is null) + obj.m_unhandled = Throwable.chainTogether(obj.m_unhandled, t); } version (D_InlineAsm_X86) @@ -2535,7 +2537,9 @@ else version (Posix) void append( Throwable t ) { - obj.m_unhandled = Throwable.chainTogether(obj.m_unhandled, t); + obj.filterCaughtThrowable(t); + if (t !is null) + obj.m_unhandled = Throwable.chainTogether(obj.m_unhandled, t); } try { diff --git a/runtime/druntime/src/core/thread/threadbase.d b/runtime/druntime/src/core/thread/threadbase.d index ee12b6aa68..903c2bffc9 100644 --- a/runtime/druntime/src/core/thread/threadbase.d +++ b/runtime/druntime/src/core/thread/threadbase.d @@ -188,6 +188,25 @@ class ThreadBase */ abstract Throwable join(bool rethrow = true); + /** + * Filter any exceptions that escaped the thread entry point. + * This enables a 'grave digger' approach to exceptions. + * + * By default this method will call the global handler in core.exception. + * + * Overriding this method allows a per-thread behavior. + * + * Params: + * thrown = The thrown exception, may be null after returned. + */ + void filterCaughtThrowable(ref Throwable thrown) @system nothrow + { + import core.exception : filterThreadThrowableHandler; + if (thrown is null) + return; + else if (auto handler = filterThreadThrowableHandler()) + handler(thrown); + } /////////////////////////////////////////////////////////////////////////// // General Properties diff --git a/runtime/druntime/test/thread/Makefile b/runtime/druntime/test/thread/Makefile index 18ab7fde93..ff087cd63f 100644 --- a/runtime/druntime/test/thread/Makefile +++ b/runtime/druntime/test/thread/Makefile @@ -1,4 +1,4 @@ -TESTS := tlsgc_sections test_import tlsstack +TESTS := tlsgc_sections test_import tlsstack filterthrownglobal filterthrownmethod # join_detach is currently disabled #TESTS += join_detach diff --git a/runtime/druntime/test/thread/src/filterthrownglobal.d b/runtime/druntime/test/thread/src/filterthrownglobal.d new file mode 100644 index 0000000000..5b9fa02481 --- /dev/null +++ b/runtime/druntime/test/thread/src/filterthrownglobal.d @@ -0,0 +1,31 @@ +import core.exception; +import core.thread; + +__gshared bool caught; + +void main() +{ + filterThreadThrowableHandler = (ref Throwable t) { + if (auto t2 = cast(AssertError) t) + { + if (t2.message != "Hey!") + return; + } + else + return; + + caught = true; + t = null; + }; + + Thread t = new Thread(&entry); + t.start(); + t.join(); + + assert(caught); +} + +void entry() +{ + throw new AssertError("Hey!"); +} diff --git a/runtime/druntime/test/thread/src/filterthrownmethod.d b/runtime/druntime/test/thread/src/filterthrownmethod.d new file mode 100644 index 0000000000..8cb43b8236 --- /dev/null +++ b/runtime/druntime/test/thread/src/filterthrownmethod.d @@ -0,0 +1,41 @@ +import core.exception; +import core.thread; + +__gshared bool caught; + +void main() +{ + Thread t = new MyThread(&entry); + t.start(); + t.join(); + + assert(caught); +} + +class MyThread : Thread +{ + this( void function() fn, size_t sz = 0 ) @safe pure nothrow @nogc + { + super(fn, sz); + } + + override void filterCaughtThrowable(ref Throwable t) @system nothrow + { + if (auto t2 = cast(AssertError) t) + { + if (t2.message == "Hey!") + { + caught = true; + t = null; + return; + } + } + + super.filterCaughtThrowable(t); + } +} + +void entry() +{ + throw new AssertError("Hey!"); +} From 8f9b0fdb071fb6d9a056fced538cc29963614ffd Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Mon, 27 Oct 2025 02:37:23 +0100 Subject: [PATCH 049/440] fix force-inlining of a couple of methods (dlang/dmd!22028) * fix force-inlining of checkedint.mulu(ulong, uint) * do not force-inline core.lifetime.wipe and some methodds in core.newaa if the argument is a nested struct * allow dmd to inline rt.util.typeinfo.cmp3 * fix inlining of hashOf() on interface --- runtime/druntime/src/core/checkedint.d | 24 +++++++++++------ runtime/druntime/src/core/internal/hash.d | 26 ++++++++----------- runtime/druntime/src/core/internal/newaa.d | 10 +++++--- runtime/druntime/src/core/lifetime.d | 4 ++- runtime/druntime/src/rt/util/typeinfo.d | 5 ++-- tests/dmd/compilable/pragmainline2.d | 30 ++++++++++++++++++++++ tests/dmd/compilable/warn3882.d | 1 + 7 files changed, 69 insertions(+), 31 deletions(-) diff --git a/runtime/druntime/src/core/checkedint.d b/runtime/druntime/src/core/checkedint.d index 5b305c759a..107ef4b9ab 100644 --- a/runtime/druntime/src/core/checkedint.d +++ b/runtime/druntime/src/core/checkedint.d @@ -815,15 +815,13 @@ ulong mulu()(ulong x, uint y, ref bool overflow) { version (D_InlineAsm_X86_64) { - if (!__ctfe) - return mulu(x, ulong(y), overflow); + return __ctfe ? mulu_generic(x, y, overflow) + : mulu(x, ulong(y), overflow); + } + else + { + return mulu_generic(x, y, overflow); } - - ulong r = x * y; - if (x >> 32 && - r / x != y) - overflow = true; - return r; } /// ditto @@ -856,6 +854,16 @@ ulong mulu()(ulong x, ulong y, ref bool overflow) return r; } +private ulong mulu_generic()(ulong x, uint y, ref bool overflow) +{ + pragma(inline, true) + ulong r = x * y; + if (x >> 32 && + r / x != y) + overflow = true; + return r; +} + @betterC unittest { diff --git a/runtime/druntime/src/core/internal/hash.d b/runtime/druntime/src/core/internal/hash.d index e5c6ab1f0f..f9355220df 100644 --- a/runtime/druntime/src/core/internal/hash.d +++ b/runtime/druntime/src/core/internal/hash.d @@ -300,12 +300,9 @@ size_t hashOf(T)(scope const T val, size_t seed) if (__traits(isScalar, T) && !i static if (is(T V : V*)) { pragma(inline, true); - if (__ctfe) - { - if (val is null) return hashOf(size_t(0), seed); - assert(0, "Unable to calculate hash of non-null pointer at compile time"); - } - return hashOf(cast(size_t) val, seed); + return __ctfe ? (val is null ? hashOf(size_t(0), seed) : + assert(0, "Unable to calculate hash of non-null pointer at compile time")) + : hashOf(cast(size_t) val, seed); } else static if (is(T EType == enum) && is(typeof(val[0]))) { @@ -584,12 +581,9 @@ if (!is(T == enum) && (is(T == struct) || is(T == union)) size_t hashOf(T)(scope const T val, size_t seed = 0) if (!is(T == enum) && is(T == delegate)) { pragma(inline, true); - if (__ctfe) - { - if (val is null) return hashOf(size_t(0), hashOf(size_t(0), seed)); - assert(0, "unable to compute hash of "~T.stringof~" at compile time"); - } - return hashOf(val.ptr, hashOf(cast(void*) val.funcptr, seed)); + return __ctfe ? (val is null ? hashOf(size_t(0), hashOf(size_t(0), seed)) : + assert(0, "unable to compute hash of "~T.stringof~" at compile time")) + : hashOf(val.ptr, hashOf(cast(void*) val.funcptr, seed)); } //address-based class hash. CTFE only if null. @@ -599,8 +593,8 @@ if (!is(T == enum) && (is(T == interface) || is(T == class)) && canBitwiseHash!T) { pragma(inline, true); - if (__ctfe) if (val is null) return 0; - return hashOf(cast(const void*) val); + return __ctfe && (val is null) ? 0 + : hashOf(cast(const void*) val); } //address-based class hash. CTFE only if null. @@ -610,8 +604,8 @@ if (!is(T == enum) && (is(T == interface) || is(T == class)) && canBitwiseHash!T) { pragma(inline, true); - if (__ctfe) if (val is null) return hashOf(size_t(0), seed); - return hashOf(cast(const void*) val, seed); + return __ctfe && (val is null) ? hashOf(size_t(0), seed) + : hashOf(cast(const void*) val, seed); } //class or interface hash. CTFE depends on toHash diff --git a/runtime/druntime/src/core/internal/newaa.d b/runtime/druntime/src/core/internal/newaa.d index 966c2a5dae..ea37bfe677 100644 --- a/runtime/druntime/src/core/internal/newaa.d +++ b/runtime/druntime/src/core/internal/newaa.d @@ -113,7 +113,8 @@ static struct Entry(K, V) // backward compatibility conversions private ref compat_key(K, K2)(ref K2 key) { - pragma(inline, true); + static if(!(is(K2 == struct) && __traits(isNested, K2))) + pragma(inline, true); static if (is(K2 == const(char)[]) && is(K == string)) return (ref (ref return K2 k2) @trusted => *cast(string*)&k2)(key); else @@ -180,7 +181,8 @@ Entry!(K, V)* _newEntry(K, V, K2)(ref K2 key) template pure_hashOf(K) { - static if (__traits(compiles, function hash_t(scope const ref K key) pure nothrow @nogc @trusted { return hashOf(cast()key); })) + static if (!(is(K == struct) && __traits(isNested, K)) && + __traits(compiles, function hash_t(scope const ref K key) pure nothrow @nogc @trusted { return hashOf(cast()key); })) { // avoid wrapper call in debug builds if pure nothrow @nogc is inferred pragma(inline, true) @@ -198,7 +200,9 @@ template pure_hashOf(K) // this also breaks cyclic inference on recursive data types template pure_keyEqual(K1, K2 = K1) { - static if (__traits(compiles, function bool(ref const K1 k1, ref const K2 k2) pure nothrow @nogc @trusted { return cast()k1 == cast()k2; })) + static if (!(is(K1 == struct) && __traits(isNested, K1)) && + !(is(K2 == struct) && __traits(isNested, K2)) && + __traits(compiles, function bool(ref const K1 k1, ref const K2 k2) pure nothrow @nogc @trusted { return cast()k1 == cast()k2; })) { // avoid wrapper call in debug builds if pure nothrow @nogc is inferred pragma(inline, true) diff --git a/runtime/druntime/src/core/lifetime.d b/runtime/druntime/src/core/lifetime.d index deb81c3ee2..ad98b2f2c5 100644 --- a/runtime/druntime/src/core/lifetime.d +++ b/runtime/druntime/src/core/lifetime.d @@ -2600,11 +2600,13 @@ pure nothrow @system unittest } // wipes source after moving -pragma(inline, true) private void wipe(T, Init...)(return scope ref T source, ref const scope Init initializer) @trusted if (!Init.length || ((Init.length == 1) && (is(immutable T == immutable Init[0])))) { + static if (!is(T == struct) || !__traits(isNested, T)) + pragma(inline, true); + static if (__traits(isStaticArray, T) && hasContextPointers!T) { for (auto i = 0; i < T.length; i++) diff --git a/runtime/druntime/src/rt/util/typeinfo.d b/runtime/druntime/src/rt/util/typeinfo.d index 9c5af477cb..f0093c8547 100644 --- a/runtime/druntime/src/rt/util/typeinfo.d +++ b/runtime/druntime/src/rt/util/typeinfo.d @@ -39,9 +39,8 @@ pragma(inline, true) private int cmp3(T)(const T f1, const T f2) if (isComplex!T) { - if (int result = cmp3(f1.re, f2.re)) - return result; - return cmp3(f1.im, f2.im); + int result; + return (result = cmp3(f1.re, f2.re)) != 0 ? result : cmp3(f1.im, f2.im); } unittest diff --git a/tests/dmd/compilable/pragmainline2.d b/tests/dmd/compilable/pragmainline2.d index f57d250267..ceca6562f5 100644 --- a/tests/dmd/compilable/pragmainline2.d +++ b/tests/dmd/compilable/pragmainline2.d @@ -106,3 +106,33 @@ bool test_toUByte() return true; } static assert(test_toUByte()); + +void test_newaa() +{ + // inlining of newaa.pure_keyEqual, newaa.compat_key, newaa.pure_hashOf + // must be disabled for nested structs + struct UnsafeElement + { + int i; + static bool b; + ~this(){ + int[] arr; + void* p = arr.ptr + 1; // unsafe + } + } + UnsafeElement[int] aa1; + int[UnsafeElement] aa2; + aa1[1] = UnsafeElement(); + assert(0 !in aa1); + assert(aa1 == aa1); + assert(UnsafeElement() !in aa2); + aa2[UnsafeElement()] = 1; + + // test inlining of hashOf(Interface) + static interface Iface + { + void foo(); + } + Iface[int] aa3; + int[Iface] aa4; +} diff --git a/tests/dmd/compilable/warn3882.d b/tests/dmd/compilable/warn3882.d index 9017921e74..14ae3c64f6 100644 --- a/tests/dmd/compilable/warn3882.d +++ b/tests/dmd/compilable/warn3882.d @@ -108,6 +108,7 @@ void testCkeckedInt() bool overflow; assert(mulu(cast(long)3, cast(uint)4, overflow) == 12); + assert(mulu(cast(ulong)3, cast(uint)4, overflow) == 12); assert(testCheckedUnsigned!uint(3,4) == 12); assert(testCheckedUnsigned!ulong(3,4) == 12); From 4641f6f954b6fbf1d447d0ce088117c5240fce4e Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Mon, 27 Oct 2025 03:03:45 +0100 Subject: [PATCH 050/440] fix dlang/dmd!20246 - cannot inline function core.bitop.Split64.this (dlang/dmd!22027) restore inlining `if (__ctfe)`, but remove the respective branch from `__ctfe ? e1 : e2` during code-gen --- dmd/inlinecost.d | 6 ------ tests/dmd/compilable/pragmainline2.d | 12 +++++++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dmd/inlinecost.d b/dmd/inlinecost.d index e9cca0f96d..fd0127ddf7 100644 --- a/dmd/inlinecost.d +++ b/dmd/inlinecost.d @@ -265,12 +265,6 @@ public: } expressionInlineCost(s.condition); - if (s.isIfCtfeBlock()) - { - cost = COST_MAX; - return; - } - /* Specifically allow: * if (condition) * return exp1; diff --git a/tests/dmd/compilable/pragmainline2.d b/tests/dmd/compilable/pragmainline2.d index ceca6562f5..adeea3f225 100644 --- a/tests/dmd/compilable/pragmainline2.d +++ b/tests/dmd/compilable/pragmainline2.d @@ -103,10 +103,20 @@ bool test_toUByte() struct S { int x; } S sval; ubarr = toUbyte(sval); - return true; + return true; } static assert(test_toUByte()); +// https://github.com/dlang/dmd/issues/20246 +void test_split() +{ + // bitop.Split64 only used for 32-bit process + import core.bitop; + ulong v = 1L << 42; + int x = bsr(v); + int y = bsf(v); +} + void test_newaa() { // inlining of newaa.pure_keyEqual, newaa.compat_key, newaa.pure_hashOf From 86062e20d576e9226e09e184cbaf95869681fd7f Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Tue, 28 Oct 2025 02:49:43 +0300 Subject: [PATCH 051/440] Break semantic dependency of `mtype` on `dsymbolsem` (dlang/dmd!22031) --- dmd/cxxfrontend.d | 7 ++++++ dmd/frontend.h | 9 -------- dmd/mtype.d | 55 ----------------------------------------------- dmd/mtype.h | 10 +-------- dmd/target.d | 1 + dmd/typesem.d | 33 ++++++++++++++++++++++++++++ 6 files changed, 42 insertions(+), 73 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 566f12181b..bbbdf7b8b7 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -855,6 +855,12 @@ structalign_t alignment(Type type) return dmd.typesem.alignment(type); } +uint alignsize(Type type) +{ + import dmd.typesem; + return dmd.typesem.alignsize(type); +} + MATCH implicitConvTo(Type from, Type to) { import dmd.dcast; @@ -897,6 +903,7 @@ void Type_init() return dmd.typesem.Type_init(); } + /*********************************************************** * typinf.d */ diff --git a/dmd/frontend.h b/dmd/frontend.h index aaa10aad24..2b88c7df07 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2068,7 +2068,6 @@ class Type : public ASTNode const char* toChars() const final override; char* toPrettyChars(bool QualifyTypes = false); static void deinitialize(); - virtual uint32_t alignsize(); void modToBuffer(OutBuffer& buf) const; char* modToChars() const; virtual bool isIntegral(); @@ -4434,7 +4433,6 @@ class TypeBasic final : public Type uint32_t flags; const char* kind() const override; TypeBasic* syntaxCopy() override; - uint32_t alignsize() override; bool isIntegral() override; bool isFloating() override; bool isReal() override; @@ -4476,7 +4474,6 @@ class TypeDArray final : public TypeArray public: const char* kind() const override; TypeDArray* syntaxCopy() override; - uint32_t alignsize() override; bool isString() override; bool isBoolean() override; void accept(Visitor* v) override; @@ -4488,7 +4485,6 @@ class TypeDelegate final : public TypeNext static TypeDelegate* create(TypeFunction* t); const char* kind() const override; TypeDelegate* syntaxCopy() override; - uint32_t alignsize() override; bool isBoolean() override; void accept(Visitor* v) override; }; @@ -4500,7 +4496,6 @@ class TypeEnum final : public Type const char* kind() const override; TypeEnum* syntaxCopy() override; Type* memType(); - uint32_t alignsize() override; bool isIntegral() override; bool isFloating() override; bool isReal() override; @@ -4693,7 +4688,6 @@ class TypeNoreturn final : public Type const char* kind() const override; TypeNoreturn* syntaxCopy() override; bool isBoolean() override; - uint32_t alignsize() override; void accept(Visitor* v) override; }; @@ -4739,7 +4733,6 @@ class TypeSArray final : public TypeArray const char* kind() const override; TypeSArray* syntaxCopy() override; bool isIncomplete(); - uint32_t alignsize() override; bool isString() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; @@ -4765,7 +4758,6 @@ class TypeStruct final : public Type bool inuse; static TypeStruct* create(StructDeclaration* sym); const char* kind() const override; - uint32_t alignsize() override; TypeStruct* syntaxCopy() override; bool isBoolean() override; bool needsDestruction() override; @@ -4834,7 +4826,6 @@ class TypeVector final : public Type static TypeVector* create(Type* basetype); const char* kind() const override; TypeVector* syntaxCopy() override; - uint32_t alignsize() override; bool isIntegral() override; bool isFloating() override; bool isScalar() override; diff --git a/dmd/mtype.d b/dmd/mtype.d index d843f5e3ba..30f3aa416c 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -26,7 +26,6 @@ import dmd.declaration; import dmd.denum; import dmd.dstruct; import dmd.dsymbol; -import dmd.dsymbolsem: size; import dmd.dtemplate; import dmd.enumsem; import dmd.errors; @@ -40,7 +39,6 @@ import dmd.common.outbuffer; import dmd.root.rmem; import dmd.rootobject; import dmd.root.stringtable; -import dmd.target; import dmd.tokens; import dmd.typesem; import dmd.visitor; @@ -511,12 +509,6 @@ extern (C++) abstract class Type : ASTNode stringtable = stringtable.init; } - uint alignsize() - { - import dmd.typesem: size; - return cast(uint)size(this, Loc.initial); - } - /********************************* * Store this type's modifier name into buf. */ @@ -1824,11 +1816,6 @@ extern (C++) final class TypeBasic : Type return this; } - override uint alignsize() - { - return target.alignsize(this); - } - override bool isIntegral() { //printf("TypeBasic::isIntegral('%s') x%x\n", toChars(), flags); @@ -1908,12 +1895,6 @@ extern (C++) final class TypeVector : Type return new TypeVector(basetype.syntaxCopy()); } - override uint alignsize() - { - import dmd.typesem: size; - return cast(uint)basetype.size(); - } - override bool isIntegral() { //printf("TypeVector::isIntegral('%s') x%x\n", toChars(), flags); @@ -2014,11 +1995,6 @@ extern (C++) final class TypeSArray : TypeArray return dim.isIntegerExp() && dim.isIntegerExp().getInteger() == 0; } - override uint alignsize() - { - return next.alignsize(); - } - override bool isString() { TY nty = next.toBasetype().ty; @@ -2076,13 +2052,6 @@ extern (C++) final class TypeDArray : TypeArray return result; } - override uint alignsize() - { - // A DArray consists of two ptr-sized values, so align it on pointer size - // boundary - return target.ptrsize; - } - override bool isString() { TY nty = next.toBasetype().ty; @@ -2439,11 +2408,6 @@ extern (C++) final class TypeDelegate : TypeNext return result; } - override uint alignsize() - { - return target.ptrsize; - } - override bool isBoolean() { return true; @@ -2762,12 +2726,6 @@ extern (C++) final class TypeStruct : Type return "struct"; } - override uint alignsize() - { - sym.size(Loc.initial); // give error for forward references - return sym.alignsize; - } - override TypeStruct syntaxCopy() { return this; @@ -2860,14 +2818,6 @@ extern (C++) final class TypeEnum : Type return sym.getMemtype(Loc.initial); } - override uint alignsize() - { - Type t = memType(); - if (t.ty == Terror) - return 4; - return t.alignsize(); - } - override bool isIntegral() { return memType().isIntegral(); @@ -3222,11 +3172,6 @@ extern (C++) final class TypeNoreturn : Type return true; // bottom type can be implicitly converted to any other type } - override uint alignsize() - { - return 0; - } - override void accept(Visitor v) { v.visit(this); diff --git a/dmd/mtype.h b/dmd/mtype.h index ff062b1209..000181cce6 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -225,7 +225,6 @@ class Type : public ASTNode const char *toChars() const override; char *toPrettyChars(bool QualifyTypes = false); - virtual unsigned alignsize(); void modToBuffer(OutBuffer& buf) const; char *modToChars() const; @@ -341,7 +340,6 @@ class TypeBasic final : public Type const char *kind() override; TypeBasic *syntaxCopy() override; - unsigned alignsize() override; bool isIntegral() override; bool isFloating() override; bool isReal() override; @@ -363,7 +361,6 @@ class TypeVector final : public Type static TypeVector *create(Type *basetype); const char *kind() override; TypeVector *syntaxCopy() override; - unsigned alignsize() override; bool isIntegral() override; bool isFloating() override; bool isScalar() override; @@ -389,7 +386,6 @@ class TypeSArray final : public TypeArray const char *kind() override; TypeSArray *syntaxCopy() override; bool isIncomplete(); - unsigned alignsize() override; bool isString() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; @@ -404,7 +400,6 @@ class TypeDArray final : public TypeArray public: const char *kind() override; TypeDArray *syntaxCopy() override; - unsigned alignsize() override; bool isString() override; bool isBoolean() override; @@ -570,7 +565,6 @@ class TypeDelegate final : public TypeNext static TypeDelegate *create(TypeFunction *t); const char *kind() override; TypeDelegate *syntaxCopy() override; - unsigned alignsize() override; bool isBoolean() override; void accept(Visitor *v) override { v->visit(this); } @@ -675,7 +669,6 @@ class TypeStruct final : public Type static TypeStruct *create(StructDeclaration *sym); const char *kind() override; - unsigned alignsize() override; TypeStruct *syntaxCopy() override; bool isBoolean() override; bool needsDestruction() override; @@ -693,7 +686,6 @@ class TypeEnum final : public Type const char *kind() override; TypeEnum *syntaxCopy() override; - unsigned alignsize() override; Type *memType(Loc loc); bool isIntegral() override; bool isFloating() override; @@ -774,7 +766,6 @@ class TypeNoreturn final : public Type const char *kind() override; TypeNoreturn *syntaxCopy() override; bool isBoolean() override; - unsigned alignsize() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -832,4 +823,5 @@ namespace dmd bool hasVoidInitPointers(Type* type); void Type_init(); structalign_t alignment(Type* type); + unsigned alignsize(Type* type); } diff --git a/dmd/target.d b/dmd/target.d index 068766377c..6dbf77a315 100644 --- a/dmd/target.d +++ b/dmd/target.d @@ -620,6 +620,7 @@ extern (C++) struct Target */ extern (C++) uint fieldalign(Type type) { + import dmd.typesem : alignsize; const size = type.alignsize(); if ((isX86_64 || isAArch64 || os == Target.OS.OSX) && (size == 16 || size == 32)) diff --git a/dmd/typesem.d b/dmd/typesem.d index a3fbdacc45..12c309f77f 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -72,6 +72,39 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; +uint alignsize(Type _this) +{ + static uint structAlignsize(TypeStruct _this) + { + import dmd.dsymbolsem : size; + _this.sym.size(Loc.initial); // give error for forward references + return _this.sym.alignsize; + } + + static uint enumAlignsize(TypeEnum _this) + { + Type t = _this.memType(); + if (t.ty == Terror) + return 4; + return t.alignsize(); + } + + if (auto tb = _this.isTypeBasic()) + return target.alignsize(tb); + + switch(_this.ty) + { + case Tvector: return cast(uint)_this.isTypeVector().basetype.size(); + case Tsarray: return _this.isTypeSArray().next.alignsize(); + // A DArray consists of two ptr-sized values, so align it on pointer size boundary + case Tarray, Tdelegate: return target.ptrsize; + case Tstruct: return structAlignsize(_this.isTypeStruct()); + case Tenum: return enumAlignsize(_this.isTypeEnum()); + case Tnoreturn: return 0; + default: return cast(uint)size(_this, Loc.initial); + } +} + /************************************* * Detect if type has pointer fields that are initialized to void. * Local stack variables with such void fields can remain uninitialized, From 386341c5816e8bbf103f878337f392676bb2dd4a Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Tue, 28 Oct 2025 02:51:40 +0300 Subject: [PATCH 052/440] Break semantic dependency of `hdrgen` on `typesem` (dlang/dmd!22033) --- dmd/hdrgen.d | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dmd/hdrgen.d b/dmd/hdrgen.d index ec25215bf2..e8fe59b2f6 100644 --- a/dmd/hdrgen.d +++ b/dmd/hdrgen.d @@ -49,7 +49,6 @@ import dmd.root.string; import dmd.statement; import dmd.staticassert; import dmd.tokens; -import dmd.typesem : castMod; import dmd.visitor; struct HdrGenState @@ -4341,14 +4340,14 @@ private void typeToBufferx(Type t, ref OutBuffer buf, ref HdrGenState hgs) void visitDArray(TypeDArray t) { - Type ut = t.castMod(0); + auto basetype = t.next.toBasetype(); if (hgs.declstring) goto L1; - if (ut.equals(Type.tstring)) + if (basetype.ty == Tchar && basetype.isImmutable()) buf.put("string"); - else if (ut.equals(Type.twstring)) + else if (basetype.ty == Twchar && basetype.isImmutable()) buf.put("wstring"); - else if (ut.equals(Type.tdstring)) + else if (basetype.ty == Tdchar && basetype.isImmutable()) buf.put("dstring"); else { From df9033f1ba340498c5a39aed632741044ef07f2a Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Tue, 28 Oct 2025 03:34:24 +0300 Subject: [PATCH 053/440] Break semantic dependency of `mtype` on `enumsem` (dlang/dmd!22032) --- dmd/cxxfrontend.d | 6 ++++++ dmd/frontend.h | 1 - dmd/mtype.d | 40 +++++++++++++--------------------------- dmd/mtype.h | 2 +- dmd/typesem.d | 13 +++++++++++++ 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index bbbdf7b8b7..68ea856f5e 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -837,6 +837,12 @@ Type referenceTo(Type type) return dmd.typesem.referenceTo(type); } +Type memType(TypeEnum type) +{ + import dmd.typesem; + return dmd.typesem.memType(type); +} + uinteger_t size(Type type) { import dmd.typesem; diff --git a/dmd/frontend.h b/dmd/frontend.h index 2b88c7df07..2629287211 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -4495,7 +4495,6 @@ class TypeEnum final : public Type EnumDeclaration* sym; const char* kind() const override; TypeEnum* syntaxCopy() override; - Type* memType(); bool isIntegral() override; bool isFloating() override; bool isReal() override; diff --git a/dmd/mtype.d b/dmd/mtype.d index 30f3aa416c..d2617b3a69 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -27,7 +27,6 @@ import dmd.denum; import dmd.dstruct; import dmd.dsymbol; import dmd.dtemplate; -import dmd.enumsem; import dmd.errors; import dmd.expression; import dmd.hdrgen; @@ -2813,82 +2812,69 @@ extern (C++) final class TypeEnum : Type return this; } - Type memType() - { - return sym.getMemtype(Loc.initial); - } - override bool isIntegral() { - return memType().isIntegral(); + return this.memType().isIntegral(); } override bool isFloating() { - return memType().isFloating(); + return this.memType().isFloating(); } override bool isReal() { - return memType().isReal(); + return this.memType().isReal(); } override bool isImaginary() { - return memType().isImaginary(); + return this.memType().isImaginary(); } override bool isComplex() { - return memType().isComplex(); + return this.memType().isComplex(); } override bool isScalar() { - return memType().isScalar(); + return this.memType().isScalar(); } override bool isUnsigned() { - return memType().isUnsigned(); + return this.memType().isUnsigned(); } override bool isBoolean() { - return memType().isBoolean(); + return this.memType().isBoolean(); } override bool isString() { - return memType().isString(); + return this.memType().isString(); } override bool needsDestruction() { - return memType().needsDestruction(); + return this.memType().needsDestruction(); } override bool needsCopyOrPostblit() { - return memType().needsCopyOrPostblit(); + return this.memType().needsCopyOrPostblit(); } override bool needsNested() { - return memType().needsNested(); - } - - extern (D) Type toBasetype2() - { - if (!sym.members && !sym.memtype) - return this; - auto tb = sym.getMemtype(Loc.initial).toBasetype(); - return tb.castMod(mod); // retain modifier bits from 'this' + return this.memType().needsNested(); } override Type nextOf() { - return memType().nextOf(); + return this.memType().nextOf(); } override void accept(Visitor v) diff --git a/dmd/mtype.h b/dmd/mtype.h index 000181cce6..ca54246c9f 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -686,7 +686,6 @@ class TypeEnum final : public Type const char *kind() override; TypeEnum *syntaxCopy() override; - Type *memType(Loc loc); bool isIntegral() override; bool isFloating() override; bool isReal() override; @@ -823,5 +822,6 @@ namespace dmd bool hasVoidInitPointers(Type* type); void Type_init(); structalign_t alignment(Type* type); + Type* memType(TypeEnum* type); unsigned alignsize(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index 12c309f77f..5ca5e05535 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -72,6 +72,19 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; +Type toBasetype2(TypeEnum _this) +{ + if (!_this.sym.members && !_this.sym.memtype) + return _this; + auto tb = _this.sym.getMemtype(Loc.initial).toBasetype(); + return tb.castMod(_this.mod); // retain modifier bits from '_this' +} + +Type memType(TypeEnum _this) +{ + return _this.sym.getMemtype(Loc.initial); +} + uint alignsize(Type _this) { static uint structAlignsize(TypeStruct _this) From e18fa1e533f552dc32b6084788980314cf109823 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Tue, 28 Oct 2025 11:26:00 +0300 Subject: [PATCH 054/440] Remove import (dlang/dmd!22034) --- dmd/astcodegen.d | 1 - 1 file changed, 1 deletion(-) diff --git a/dmd/astcodegen.d b/dmd/astcodegen.d index 109208b1c9..787c9ca156 100644 --- a/dmd/astcodegen.d +++ b/dmd/astcodegen.d @@ -33,7 +33,6 @@ struct ASTCodegen public import dmd.statement; public import dmd.staticassert; public import dmd.typesem; - public import dmd.ctfeexpr; public import dmd.init : Designator; From 9ee9c5807dce96c9824f79ac9c7280a032134fb2 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Tue, 28 Oct 2025 11:27:59 +0300 Subject: [PATCH 055/440] Remove `typesem` import from `astcodegen` (dlang/dmd!22035) --- dmd/astcodegen.d | 3 +- dmd/mtype.d | 103 +++++++++++++++++++++++++++++++++++++++++++++++ dmd/typesem.d | 103 ----------------------------------------------- 3 files changed, 104 insertions(+), 105 deletions(-) diff --git a/dmd/astcodegen.d b/dmd/astcodegen.d index 787c9ca156..53afd53de9 100644 --- a/dmd/astcodegen.d +++ b/dmd/astcodegen.d @@ -32,12 +32,11 @@ struct ASTCodegen public import dmd.nspace; public import dmd.statement; public import dmd.staticassert; - public import dmd.typesem; public import dmd.init : Designator; alias initializerToExpression = dmd.initsem.initializerToExpression; - alias typeToExpression = dmd.typesem.typeToExpression; + alias typeToExpression = dmd.mtype.typeToExpression; alias UserAttributeDeclaration = dmd.attrib.UserAttributeDeclaration; alias Ensure = dmd.func.Ensure; // workaround for bug in older DMD frontends alias ErrorExp = dmd.expression.ErrorExp; diff --git a/dmd/mtype.d b/dmd/mtype.d index d2617b3a69..047ad425e2 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -58,6 +58,109 @@ private auto X(T, U)(T m, U n) return (m << 4) | n; } +/* Helper function for `typeToExpression`. Contains common code + * for TypeQualified derived classes. + */ +Expression typeToExpressionHelper(TypeQualified t, Expression e, size_t i = 0) +{ + //printf("toExpressionHelper(e = %s %s)\n", EXPtoString(e.op).ptr, e.toChars()); + foreach (id; t.idents[i .. t.idents.length]) + { + //printf("\t[%d] e: '%s', id: '%s'\n", i, e.toChars(), id.toChars()); + + final switch (id.dyncast()) + { + // ... '. ident' + case DYNCAST.identifier: + e = new DotIdExp(e.loc, e, cast(Identifier)id); + break; + + // ... '. name!(tiargs)' + case DYNCAST.dsymbol: + auto ti = (cast(Dsymbol)id).isTemplateInstance(); + assert(ti); + e = new DotTemplateInstanceExp(e.loc, e, ti.name, ti.tiargs); + break; + + // ... '[type]' + case DYNCAST.type: // https://issues.dlang.org/show_bug.cgi?id=1215 + e = new ArrayExp(t.loc, e, new TypeExp(t.loc, cast(Type)id)); + break; + + // ... '[expr]' + case DYNCAST.expression: // https://issues.dlang.org/show_bug.cgi?id=1215 + e = new ArrayExp(t.loc, e, cast(Expression)id); + break; + + case DYNCAST.object: + case DYNCAST.tuple: + case DYNCAST.parameter: + case DYNCAST.statement: + case DYNCAST.condition: + case DYNCAST.templateparameter: + case DYNCAST.initializer: + assert(0); + } + } + return e; +} + +/****************************************** + * We've mistakenly parsed `t` as a type. + * Redo `t` as an Expression only if there are no type modifiers. + * Params: + * t = mistaken type + * Returns: + * t redone as Expression, null if cannot + */ +Expression typeToExpression(Type t) +{ + static Expression visitSArray(TypeSArray t) + { + if (auto e = t.next.typeToExpression()) + return new ArrayExp(t.dim.loc, e, t.dim); + return null; + } + + static Expression visitAArray(TypeAArray t) + { + if (auto e = t.next.typeToExpression()) + { + if (auto ei = t.index.typeToExpression()) + return new ArrayExp(t.loc, e, ei); + } + return null; + } + + static Expression visitIdentifier(TypeIdentifier t) + { + return typeToExpressionHelper(t, new IdentifierExp(t.loc, t.ident)); + } + + static Expression visitInstance(TypeInstance t) + { + return typeToExpressionHelper(t, new ScopeExp(t.loc, t.tempinst)); + } + + // easy way to enable 'auto v = new int[mixin("exp")];' in 2.088+ + static Expression visitMixin(TypeMixin t) + { + return new TypeExp(t.loc, t); + } + + if (t.mod) + return null; + switch (t.ty) + { + case Tsarray: return visitSArray(t.isTypeSArray()); + case Taarray: return visitAArray(t.isTypeAArray()); + case Tident: return visitIdentifier(t.isTypeIdentifier()); + case Tinstance: return visitInstance(t.isTypeInstance()); + case Tmixin: return visitMixin(t.isTypeMixin()); + default: return null; + } +} + /*************************** * Return !=0 if modfrom can be implicitly converted to modto */ diff --git a/dmd/typesem.d b/dmd/typesem.d index 5ca5e05535..d8541e9601 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -880,62 +880,6 @@ void purityLevel(TypeFunction typeFunction) tf.purity = typeFunction.purity; } -/****************************************** - * We've mistakenly parsed `t` as a type. - * Redo `t` as an Expression only if there are no type modifiers. - * Params: - * t = mistaken type - * Returns: - * t redone as Expression, null if cannot - */ -Expression typeToExpression(Type t) -{ - static Expression visitSArray(TypeSArray t) - { - if (auto e = t.next.typeToExpression()) - return new ArrayExp(t.dim.loc, e, t.dim); - return null; - } - - static Expression visitAArray(TypeAArray t) - { - if (auto e = t.next.typeToExpression()) - { - if (auto ei = t.index.typeToExpression()) - return new ArrayExp(t.loc, e, ei); - } - return null; - } - - static Expression visitIdentifier(TypeIdentifier t) - { - return typeToExpressionHelper(t, new IdentifierExp(t.loc, t.ident)); - } - - static Expression visitInstance(TypeInstance t) - { - return typeToExpressionHelper(t, new ScopeExp(t.loc, t.tempinst)); - } - - // easy way to enable 'auto v = new int[mixin("exp")];' in 2.088+ - static Expression visitMixin(TypeMixin t) - { - return new TypeExp(t.loc, t); - } - - if (t.mod) - return null; - switch (t.ty) - { - case Tsarray: return visitSArray(t.isTypeSArray()); - case Taarray: return visitAArray(t.isTypeAArray()); - case Tident: return visitIdentifier(t.isTypeIdentifier()); - case Tinstance: return visitInstance(t.isTypeInstance()); - case Tmixin: return visitMixin(t.isTypeMixin()); - default: return null; - } -} - /************************************* * https://issues.dlang.org/show_bug.cgi?id=14488 * Check if the inner most base type is complex or imaginary. @@ -8342,53 +8286,6 @@ bool isOpaqueType(Type t) private: -/* Helper function for `typeToExpression`. Contains common code - * for TypeQualified derived classes. - */ -Expression typeToExpressionHelper(TypeQualified t, Expression e, size_t i = 0) -{ - //printf("toExpressionHelper(e = %s %s)\n", EXPtoString(e.op).ptr, e.toChars()); - foreach (id; t.idents[i .. t.idents.length]) - { - //printf("\t[%d] e: '%s', id: '%s'\n", i, e.toChars(), id.toChars()); - - final switch (id.dyncast()) - { - // ... '. ident' - case DYNCAST.identifier: - e = new DotIdExp(e.loc, e, cast(Identifier)id); - break; - - // ... '. name!(tiargs)' - case DYNCAST.dsymbol: - auto ti = (cast(Dsymbol)id).isTemplateInstance(); - assert(ti); - e = new DotTemplateInstanceExp(e.loc, e, ti.name, ti.tiargs); - break; - - // ... '[type]' - case DYNCAST.type: // https://issues.dlang.org/show_bug.cgi?id=1215 - e = new ArrayExp(t.loc, e, new TypeExp(t.loc, cast(Type)id)); - break; - - // ... '[expr]' - case DYNCAST.expression: // https://issues.dlang.org/show_bug.cgi?id=1215 - e = new ArrayExp(t.loc, e, cast(Expression)id); - break; - - case DYNCAST.object: - case DYNCAST.tuple: - case DYNCAST.parameter: - case DYNCAST.statement: - case DYNCAST.condition: - case DYNCAST.templateparameter: - case DYNCAST.initializer: - assert(0); - } - } - return e; -} - /************************** * This evaluates exp while setting length to be the number * of elements in the tuple t. From 8150459649b99fb1db4d50094f6c5435283f20da Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Tue, 28 Oct 2025 11:28:51 +0300 Subject: [PATCH 056/440] Remove unused imports in AST-related files (dlang/dmd!22036) --- dmd/cond.d | 3 --- dmd/declaration.d | 1 - dmd/dmodule.d | 3 --- dmd/dstruct.d | 4 ---- dmd/dtemplate.d | 3 --- dmd/dversion.d | 6 ------ dmd/func.d | 3 --- 7 files changed, 23 deletions(-) diff --git a/dmd/cond.d b/dmd/cond.d index 1d994f0dcb..5fbb897b83 100644 --- a/dmd/cond.d +++ b/dmd/cond.d @@ -17,8 +17,6 @@ import core.stdc.string; import dmd.arraytypes; import dmd.astenums; import dmd.ast_node; -import dmd.dcast; -import dmd.dinterpret; import dmd.dmodule; import dmd.dscope; import dmd.dsymbol; @@ -28,7 +26,6 @@ import dmd.globals; import dmd.identifier; import dmd.location; import dmd.mtype; -import dmd.optimize; import dmd.common.outbuffer; import dmd.rootobject; import dmd.root.string; diff --git a/dmd/declaration.d b/dmd/declaration.d index 6fb7356d76..3c615dfdb4 100644 --- a/dmd/declaration.d +++ b/dmd/declaration.d @@ -18,7 +18,6 @@ import dmd.arraytypes; import dmd.astenums; import dmd.ctorflow; import dmd.dclass; -import dmd.delegatize; import dmd.dscope; import dmd.dstruct; import dmd.dsymbol; diff --git a/dmd/dmodule.d b/dmd/dmodule.d index 1352183122..b34169f97f 100644 --- a/dmd/dmodule.d +++ b/dmd/dmodule.d @@ -28,7 +28,6 @@ import dmd.declaration; import dmd.dimport; import dmd.dmacro; import dmd.doc; -import dmd.dscope; import dmd.dsymbol; import dmd.errors; import dmd.errorsink; @@ -47,8 +46,6 @@ import dmd.root.port; import dmd.root.rmem; import dmd.root.string; import dmd.rootobject; -import dmd.semantic2; -import dmd.semantic3; import dmd.target; import dmd.utils; import dmd.visitor; diff --git a/dmd/dstruct.d b/dmd/dstruct.d index b565f159ae..b973527333 100644 --- a/dmd/dstruct.d +++ b/dmd/dstruct.d @@ -21,7 +21,6 @@ import dmd.astenums; import dmd.attrib; import dmd.declaration; import dmd.dmodule; -import dmd.dscope; import dmd.dsymbol; import dmd.dtemplate; import dmd.expression; @@ -30,10 +29,7 @@ import dmd.id; import dmd.identifier; import dmd.location; import dmd.mtype; -import dmd.opover; -import dmd.target; import dmd.tokens; -import dmd.typinf; import dmd.visitor; enum StructFlags : int diff --git a/dmd/dtemplate.d b/dmd/dtemplate.d index b043671470..d90b73d3d3 100644 --- a/dmd/dtemplate.d +++ b/dmd/dtemplate.d @@ -46,10 +46,8 @@ import dmd.arraytypes; import dmd.astenums; import dmd.ast_node; import dmd.attrib; -import dmd.dcast; import dmd.dclass; import dmd.declaration; -import dmd.dinterpret; import dmd.dmodule; import dmd.dscope; import dmd.dsymbol; @@ -67,7 +65,6 @@ import dmd.location; import dmd.mangle; import dmd.mtype; import dmd.opover; -import dmd.optimize; import dmd.root.array; import dmd.common.outbuffer; import dmd.rootobject; diff --git a/dmd/dversion.d b/dmd/dversion.d index 1561ebb0b7..166eb92fe3 100644 --- a/dmd/dversion.d +++ b/dmd/dversion.d @@ -14,15 +14,9 @@ module dmd.dversion; -import dmd.arraytypes; -import dmd.cond; -import dmd.dmodule; -import dmd.dscope; import dmd.dsymbol; -import dmd.dsymbolsem; import dmd.identifier; import dmd.location; -import dmd.common.outbuffer; import dmd.visitor; /*********************************************************** diff --git a/dmd/func.d b/dmd/func.d index 4645001191..76a4c83def 100644 --- a/dmd/func.d +++ b/dmd/func.d @@ -24,11 +24,8 @@ import dmd.aggregate; import dmd.arraytypes; import dmd.astenums; import dmd.blockexit; -import dmd.dcast; import dmd.dclass; import dmd.declaration; -import dmd.delegatize; -import dmd.dmodule; import dmd.dscope; import dmd.dstruct; import dmd.dsymbol; From 56b2de662ed4a4ca5c56f6765c52ce74b2295784 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Wed, 29 Oct 2025 00:22:53 -0700 Subject: [PATCH 057/440] add core.internal.vararg.gnu (dlang/dmd!22039) --- .../druntime/src/core/internal/vararg/gnu.d | 78 +++++++++++++++++++ runtime/druntime/src/core/stdc/stdarg.d | 47 +++-------- 2 files changed, 88 insertions(+), 37 deletions(-) create mode 100644 runtime/druntime/src/core/internal/vararg/gnu.d diff --git a/runtime/druntime/src/core/internal/vararg/gnu.d b/runtime/druntime/src/core/internal/vararg/gnu.d new file mode 100644 index 0000000000..0218490f2c --- /dev/null +++ b/runtime/druntime/src/core/internal/vararg/gnu.d @@ -0,0 +1,78 @@ +/** + * Varargs implementation for the GNU compilers (Gnu D Compiler) + * Used by core.stdc.stdarg and core.vararg. + * + * Reference: https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#appendix-variable-argument-lists + * + * Copyright: Copyright D Language Foundation 2025 + * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). + * Authors: Various + * Source: $(DRUNTIMESRC core/internal/vararg/gnu.d) + */ + +module core.internal.vararg.gnu; + +version (GNU): + +// Uses gcc.builtins + +T alignUp(size_t alignment = size_t.sizeof, T)(T base) pure +{ + enum mask = alignment - 1; + static assert(alignment > 0 && (alignment & mask) == 0, "alignment must be a power of 2"); + auto b = cast(size_t) base; + b = (b + mask) & ~mask; + return cast(T) b; +} + +unittest +{ + assert(1.alignUp == size_t.sizeof); + assert(31.alignUp!16 == 32); + assert(32.alignUp!16 == 32); + assert(33.alignUp!16 == 48); + assert((-9).alignUp!8 == -8); +} + + +version (BigEndian) +{ + // Adjusts a size_t-aligned pointer for types smaller than size_t. + T* adjustForBigEndian(T)(T* p, size_t size) pure + { + return size >= size_t.sizeof ? p : + cast(T*) ((cast(void*) p) + (size_t.sizeof - size)); + } +} + +/** + * The argument pointer type. + */ +alias va_list = __gnuc_va_list; +alias __gnuc_va_list = __builtin_va_list; + +/** + * Initialize ap. + * parmn should be the last named parameter. + */ +void va_start(T)(out va_list ap, ref T parmn); + +/** + * Retrieve and return the next value that is of type T. + */ +T va_arg(T)(ref va_list ap); // intrinsic + +/** + * Retrieve and store in parmn the next value that is of type T. + */ +void va_arg(T)(ref va_list ap, ref T parmn); // intrinsic + +/** + * End use of ap. + */ +alias va_end = __builtin_va_end; + +/** + * Make a copy of ap. + */ +alias va_copy = __builtin_va_copy; diff --git a/runtime/druntime/src/core/stdc/stdarg.d b/runtime/druntime/src/core/stdc/stdarg.d index 220b27c4cf..9f16f4689e 100644 --- a/runtime/druntime/src/core/stdc/stdarg.d +++ b/runtime/druntime/src/core/stdc/stdarg.d @@ -15,17 +15,17 @@ module core.stdc.stdarg; @nogc: nothrow: +version (GNU) + public import core.internal.vararg.gnu; +else: + version (X86_64) { version (Windows) { /* different ABI */ } else version = SysV_x64; } -version (GNU) -{ - import gcc.builtins; -} -else version (SysV_x64) +version (SysV_x64) { static import core.internal.vararg.sysv_x64; @@ -49,11 +49,7 @@ version (PPC64) version = PPC_Any; version (RISCV32) version = RISCV_Any; version (RISCV64) version = RISCV_Any; -version (GNU) -{ - // Uses gcc.builtins -} -else version (ARM_Any) +version (ARM_Any) { // Darwin uses a simpler varargs implementation version (OSX) {} @@ -107,12 +103,7 @@ version (BigEndian) /** * The argument pointer type. */ -version (GNU) -{ - alias va_list = __gnuc_va_list; - alias __gnuc_va_list = __builtin_va_list; -} -else version (SysV_x64) +version (SysV_x64) { alias va_list = core.internal.vararg.sysv_x64.va_list; public import core.internal.vararg.sysv_x64 : __va_list, __va_list_tag; @@ -149,11 +140,7 @@ else * Initialize ap. * parmn should be the last named parameter. */ -version (GNU) -{ - void va_start(T)(out va_list ap, ref T parmn); -} -else version (LDC) +version (LDC) { pragma(LDC_va_start) void va_start(T)(out va_list ap, ref T parmn) @nogc; @@ -177,9 +164,6 @@ else version (DigitalMars) /** * Retrieve and return the next value that is of type T. */ -version (GNU) - T va_arg(T)(ref va_list ap); // intrinsic -else T va_arg(T)(ref va_list ap) { version (X86) @@ -295,9 +279,6 @@ T va_arg(T)(ref va_list ap) /** * Retrieve and store in parmn the next value that is of type T. */ -version (GNU) - void va_arg(T)(ref va_list ap, ref T parmn); // intrinsic -else void va_arg(T)(ref va_list ap, ref T parmn) { parmn = va_arg!T(ap); @@ -307,11 +288,7 @@ void va_arg(T)(ref va_list ap, ref T parmn) /** * End use of ap. */ -version (GNU) -{ - alias va_end = __builtin_va_end; -} -else version (LDC) +version (LDC) { pragma(LDC_va_end) void va_end(va_list ap); @@ -325,11 +302,7 @@ else version (DigitalMars) /** * Make a copy of ap. */ -version (GNU) -{ - alias va_copy = __builtin_va_copy; -} -else version (LDC) +version (LDC) { pragma(LDC_va_copy) void va_copy(out va_list dest, va_list src); From 03f44716015708eb10ee4725bba9d409e610fdba Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Wed, 29 Oct 2025 00:23:46 -0700 Subject: [PATCH 058/440] rename internal.vararg.aarch64 to internal.vararg.aapcs64 (dlang/dmd!22038) --- .../internal/vararg/{aarch64.d => aapcs64.d} | 21 ++++++++++--------- runtime/druntime/src/core/stdc/stdarg.d | 8 +++---- runtime/druntime/src/core/vararg.d | 4 ++-- 3 files changed, 17 insertions(+), 16 deletions(-) rename runtime/druntime/src/core/internal/vararg/{aarch64.d => aapcs64.d} (91%) diff --git a/runtime/druntime/src/core/internal/vararg/aarch64.d b/runtime/druntime/src/core/internal/vararg/aapcs64.d similarity index 91% rename from runtime/druntime/src/core/internal/vararg/aarch64.d rename to runtime/druntime/src/core/internal/vararg/aapcs64.d index 2f1930e14b..b2e7c22be2 100644 --- a/runtime/druntime/src/core/internal/vararg/aarch64.d +++ b/runtime/druntime/src/core/internal/vararg/aapcs64.d @@ -1,24 +1,25 @@ /** - * Varargs implementation for the AArch64 Procedure Call Standard (not followed by Apple). + * Varargs implementation for the AArch64 Procedure Call Standard AAPCS64 (not followed by Apple). * Used by core.stdc.stdarg and core.vararg. + * Can only be imported with version (AArch64). * * Reference: https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#appendix-variable-argument-lists * - * Copyright: Copyright Digital Mars 2020 - 2020. + * Copyright: Copyright Digital Mars 2020 - 2025. * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). * Authors: Martin Kinkelin - * Source: $(DRUNTIMESRC core/internal/vararg/aarch64.d) + * Source: $(DRUNTIMESRC core/internal/vararg/aapcs64.d) */ -module core.internal.vararg.aarch64; +module core.internal.vararg.aapcs64; -version (AArch64): +version (AArch64): // core.internal.vararg.aapcs64 is only for version (AArch64) -// Darwin uses a simpler varargs implementation -version (OSX) {} -else version (iOS) {} -else version (TVOS) {} -else version (WatchOS) {} +// Darwin uses a simpler varargs implementation than AAPCS64, so should not import this module +version (OSX) { } +else version (iOS) { } +else version (TVOS) { } +else version (WatchOS) { } else: import core.stdc.stdarg : alignUp; diff --git a/runtime/druntime/src/core/stdc/stdarg.d b/runtime/druntime/src/core/stdc/stdarg.d index 9f16f4689e..c08d22ccba 100644 --- a/runtime/druntime/src/core/stdc/stdarg.d +++ b/runtime/druntime/src/core/stdc/stdarg.d @@ -65,7 +65,7 @@ version (ARM_Any) else version (AArch64) { version = AAPCS64; - static import core.internal.vararg.aarch64; + static import core.internal.vararg.aapcs64; } } @@ -120,9 +120,9 @@ else version (AAPCS32) } else version (AAPCS64) { - alias va_list = core.internal.vararg.aarch64.va_list; + alias va_list = core.internal.vararg.aapcs64.va_list; version (DigitalMars) - public import core.internal.vararg.aarch64 : __va_list, __va_list_tag; + public import core.internal.vararg.aapcs64 : __va_list, __va_list_tag; } else version (RISCV_Any) { @@ -213,7 +213,7 @@ T va_arg(T)(ref va_list ap) } else version (AAPCS64) { - return core.internal.vararg.aarch64.va_arg!T(ap); + return core.internal.vararg.aapcs64.va_arg!T(ap); } else version (ARM_Any) { diff --git a/runtime/druntime/src/core/vararg.d b/runtime/druntime/src/core/vararg.d index e6dd47d06d..a283f1a203 100644 --- a/runtime/druntime/src/core/vararg.d +++ b/runtime/druntime/src/core/vararg.d @@ -106,8 +106,8 @@ void va_arg()(ref va_list ap, TypeInfo ti, void* parmn) } else version (AAPCS64) { - static import core.internal.vararg.aarch64; - core.internal.vararg.aarch64.va_arg(ap, ti, parmn); + static import core.internal.vararg.aapcs64; + core.internal.vararg.aapcs64.va_arg(ap, ti, parmn); } else version (ARM_Any) { From 19a7fb747bf9297719ae7cf530bce748d6484c0d Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Wed, 29 Oct 2025 10:52:05 +0300 Subject: [PATCH 059/440] Remove unused imports in AST-related files Pt. 2 (dlang/dmd!22041) --- dmd/aggregate.d | 6 ------ dmd/arrayop.d | 1 - dmd/attrib.d | 5 ----- dmd/canthrow.d | 4 ---- dmd/cond.d | 2 -- dmd/ctfeexpr.d | 2 -- dmd/dcast.d | 1 - dmd/declaration.d | 7 ------- dmd/dmodule.d | 5 ----- dmd/doc.d | 2 -- dmd/dstruct.d | 5 ----- dmd/dsymbol.d | 4 ---- dmd/dsymbolsem.d | 9 --------- dmd/dtemplate.d | 8 -------- dmd/dtoh.d | 5 ----- dmd/expression.d | 4 ---- dmd/frontend.h | 37 ------------------------------------- dmd/func.d | 8 -------- dmd/initsem.d | 3 --- dmd/mtype.d | 2 -- dmd/staticassert.d | 1 - dmd/traits.d | 5 ----- dmd/typesem.d | 5 ----- 23 files changed, 131 deletions(-) diff --git a/dmd/aggregate.d b/dmd/aggregate.d index c51494cf97..794ececb03 100644 --- a/dmd/aggregate.d +++ b/dmd/aggregate.d @@ -20,21 +20,15 @@ import core.checkedint; import dmd.aliasthis; import dmd.arraytypes; import dmd.astenums; -import dmd.attrib; import dmd.declaration; import dmd.dscope; -import dmd.dstruct; import dmd.dsymbol; -import dmd.dtemplate; import dmd.errors; import dmd.expression; import dmd.func; -import dmd.hdrgen; -import dmd.id; import dmd.identifier; import dmd.location; import dmd.mtype; -import dmd.tokens; import dmd.visitor; /** diff --git a/dmd/arrayop.d b/dmd/arrayop.d index ea6f87f60e..c7b3bc7987 100644 --- a/dmd/arrayop.d +++ b/dmd/arrayop.d @@ -19,7 +19,6 @@ import dmd.astenums; import dmd.dcast : implicitConvTo; import dmd.declaration; import dmd.dscope; -import dmd.dsymbol; import dmd.errors; import dmd.expression; import dmd.expressionsem; diff --git a/dmd/attrib.d b/dmd/attrib.d index 97dfa5ef68..1a429dccfc 100644 --- a/dmd/attrib.d +++ b/dmd/attrib.d @@ -24,24 +24,19 @@ module dmd.attrib; -import dmd.aggregate; import dmd.arraytypes; import dmd.astenums; import dmd.cond; -import dmd.declaration; import dmd.dmodule; import dmd.dscope; import dmd.dsymbol; import dmd.expression; -import dmd.func; import dmd.hdrgen : visibilityToBuffer; import dmd.id; import dmd.identifier; import dmd.location; -import dmd.mtype; import dmd.objc; // for objc.addSymbols import dmd.common.outbuffer; -import dmd.root.array; // for each import dmd.visitor; /*********************************************************** diff --git a/dmd/canthrow.d b/dmd/canthrow.d index 78c7ec6c01..34dacf0747 100644 --- a/dmd/canthrow.d +++ b/dmd/canthrow.d @@ -14,11 +14,8 @@ module dmd.canthrow; import dmd.aggregate; -import dmd.arraytypes; -import dmd.attrib; import dmd.astenums; import dmd.blockexit : BE, checkThrow; -import dmd.declaration; import dmd.dsymbol; import dmd.dsymbolsem : include, toAlias; import dmd.errorsink; @@ -26,7 +23,6 @@ import dmd.expression; import dmd.expressionsem : errorSupplementalInferredAttr, isLvalue; import dmd.func; import dmd.globals; -import dmd.init; import dmd.mtype; import dmd.tokens; import dmd.visitor; diff --git a/dmd/cond.d b/dmd/cond.d index 5fbb897b83..8e0ef757b7 100644 --- a/dmd/cond.d +++ b/dmd/cond.d @@ -19,7 +19,6 @@ import dmd.astenums; import dmd.ast_node; import dmd.dmodule; import dmd.dscope; -import dmd.dsymbol; import dmd.errors; import dmd.expression; import dmd.globals; @@ -32,7 +31,6 @@ import dmd.root.string; import dmd.tokens; import dmd.utils; import dmd.visitor; -import dmd.id; import dmd.statement; import dmd.declaration; import dmd.dstruct; diff --git a/dmd/ctfeexpr.d b/dmd/ctfeexpr.d index 19194eeff3..4e7fa43949 100644 --- a/dmd/ctfeexpr.d +++ b/dmd/ctfeexpr.d @@ -31,13 +31,11 @@ import dmd.globals : dinteger_t, sinteger_t, uinteger_t; import dmd.location; import dmd.mtype; import dmd.root.bitarray; -import dmd.root.complex; import dmd.root.ctfloat; import dmd.root.port; import dmd.root.rmem; import dmd.tokens; import dmd.typesem; -import dmd.visitor; /****************************************************************/ /* A type meant as a union of all the Expression types, diff --git a/dmd/dcast.d b/dmd/dcast.d index ed83026fd0..7ae2df7687 100644 --- a/dmd/dcast.d +++ b/dmd/dcast.d @@ -14,7 +14,6 @@ module dmd.dcast; import core.stdc.stdio; import core.stdc.string; import dmd.aggregate; -import dmd.aliasthis; import dmd.arrayop; import dmd.arraytypes; import dmd.astenums; diff --git a/dmd/declaration.d b/dmd/declaration.d index 3c615dfdb4..8b5ead130e 100644 --- a/dmd/declaration.d +++ b/dmd/declaration.d @@ -16,10 +16,6 @@ import core.stdc.stdio; import dmd.aggregate; import dmd.arraytypes; import dmd.astenums; -import dmd.ctorflow; -import dmd.dclass; -import dmd.dscope; -import dmd.dstruct; import dmd.dsymbol; import dmd.dtemplate; import dmd.errors; @@ -27,7 +23,6 @@ import dmd.errorsink; import dmd.expression; import dmd.func; import dmd.globals; -import dmd.hdrgen; import dmd.id; import dmd.identifier; import dmd.init; @@ -35,11 +30,9 @@ import dmd.intrange; import dmd.location; import dmd.mtype; import dmd.common.outbuffer; -import dmd.rootobject; import dmd.root.filename; import dmd.target; import dmd.targetcompiler; -import dmd.tokens; import dmd.visitor; diff --git a/dmd/dmodule.d b/dmd/dmodule.d index b34169f97f..dc974bc7c6 100644 --- a/dmd/dmodule.d +++ b/dmd/dmodule.d @@ -25,12 +25,10 @@ import dmd.common.outbuffer; import dmd.compiler; import dmd.cparse; import dmd.declaration; -import dmd.dimport; import dmd.dmacro; import dmd.doc; import dmd.dsymbol; import dmd.errors; -import dmd.errorsink; import dmd.expression; import dmd.file_manager; import dmd.func; @@ -43,11 +41,8 @@ import dmd.root.array; import dmd.root.file; import dmd.root.filename; import dmd.root.port; -import dmd.root.rmem; import dmd.root.string; -import dmd.rootobject; import dmd.target; -import dmd.utils; import dmd.visitor; version (Windows) diff --git a/dmd/doc.d b/dmd/doc.d index fb1d3df44e..17e2d55653 100644 --- a/dmd/doc.d +++ b/dmd/doc.d @@ -45,8 +45,6 @@ import dmd.lexer; import dmd.location; import dmd.mtype; import dmd.root.array; -import dmd.root.file; -import dmd.root.filename; import dmd.common.outbuffer; import dmd.root.port; import dmd.root.rmem; diff --git a/dmd/dstruct.d b/dmd/dstruct.d index b973527333..ac5ee046cc 100644 --- a/dmd/dstruct.d +++ b/dmd/dstruct.d @@ -18,18 +18,13 @@ import core.stdc.stdio; import dmd.aggregate; import dmd.arraytypes; import dmd.astenums; -import dmd.attrib; -import dmd.declaration; import dmd.dmodule; import dmd.dsymbol; -import dmd.dtemplate; -import dmd.expression; import dmd.func; import dmd.id; import dmd.identifier; import dmd.location; import dmd.mtype; -import dmd.tokens; import dmd.visitor; enum StructFlags : int diff --git a/dmd/dsymbol.d b/dmd/dsymbol.d index 9575108e70..55484cec1c 100644 --- a/dmd/dsymbol.d +++ b/dmd/dsymbol.d @@ -17,7 +17,6 @@ import core.stdc.string; import core.stdc.stdlib; import dmd.aggregate; -import dmd.aliasthis; import dmd.arraytypes; import dmd.attrib; import dmd.astenums; @@ -34,10 +33,7 @@ import dmd.dtemplate; import dmd.errors; import dmd.expression; import dmd.func; -import dmd.id; import dmd.identifier; -import dmd.init; -import dmd.lexer; import dmd.location; import dmd.mtype; import dmd.nspace; diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index bae8c86c09..30e8f655ec 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -42,7 +42,6 @@ import dmd.dversion; import dmd.enumsem; import dmd.errors; import dmd.errorsink; -import dmd.escape; import dmd.expression; import dmd.expressionsem; import dmd.func; @@ -53,7 +52,6 @@ import dmd.identifier; import dmd.importc; import dmd.init; import dmd.initsem; -import dmd.intrange; import dmd.hdrgen; import dmd.lexer; import dmd.location; @@ -61,12 +59,9 @@ import dmd.mtype; import dmd.mustuse; import dmd.nspace; import dmd.objc; -import dmd.opover; import dmd.optimize; import dmd.parse; -debug import dmd.printast; import dmd.root.array; -import dmd.root.filename; import dmd.root.string; import dmd.root.rmem; import dmd.root.speller; @@ -78,11 +73,9 @@ import dmd.semantic3; import dmd.sideeffect; import dmd.staticassert; import dmd.tokens; -import dmd.utils; import dmd.statement; import dmd.target; import dmd.targetcompiler; -import dmd.templateparamsem; import dmd.templatesem; import dmd.typesem; import dmd.visitor; @@ -265,7 +258,6 @@ Dsymbol search(Scope* _this, Loc loc, Identifier ident, out Dsymbol pscopesym, S Dsymbol checkAliasThis(AggregateDeclaration ad, Identifier ident, SearchOptFlags flags, Expression* exp) { - import dmd.mtype; if (!ad || !ad.aliasthis) return null; @@ -1485,7 +1477,6 @@ bool isPOD(StructDeclaration sd) if (sd.ispod != ThreeState.none) return (sd.ispod == ThreeState.yes); - import dmd.clone; bool hasCpCtorLocal; bool hasMoveCtorLocal; diff --git a/dmd/dtemplate.d b/dmd/dtemplate.d index d90b73d3d3..a0b51ca4bb 100644 --- a/dmd/dtemplate.d +++ b/dmd/dtemplate.d @@ -40,13 +40,9 @@ module dmd.dtemplate; import core.stdc.stdio; import core.stdc.string; -import dmd.aggregate; -import dmd.aliasthis; import dmd.arraytypes; import dmd.astenums; import dmd.ast_node; -import dmd.attrib; -import dmd.dclass; import dmd.declaration; import dmd.dmodule; import dmd.dscope; @@ -57,14 +53,10 @@ import dmd.expression; import dmd.func; import dmd.globals; import dmd.hdrgen; -import dmd.id; import dmd.identifier; -import dmd.impcnvtab; -import dmd.init; import dmd.location; import dmd.mangle; import dmd.mtype; -import dmd.opover; import dmd.root.array; import dmd.common.outbuffer; import dmd.rootobject; diff --git a/dmd/dtoh.d b/dmd/dtoh.d index 199e26fea6..e2bbbc499b 100644 --- a/dmd/dtoh.d +++ b/dmd/dtoh.d @@ -18,8 +18,6 @@ import core.stdc.ctype; import dmd.astcodegen; import dmd.astenums; import dmd.arraytypes; -import dmd.attrib; -import dmd.dsymbol; import dmd.dsymbolsem; import dmd.templatesem : computeOneMember; import dmd.errors; @@ -581,7 +579,6 @@ public: debug (Debug_DtoH) { mixin(traceVisit!s); - import dmd.asttypename; printf("[AST.Dsymbol enter] %s\n", s.astTypeName().ptr); } } @@ -1755,7 +1752,6 @@ public: // `this` but accessible via `outer` if (auto td = s.isThisDeclaration()) { - import dmd.id; this.ident = Id.outer; } else @@ -2705,7 +2701,6 @@ public: } else { - import dmd.hdrgen; // Hex floating point literals were introduced in C++ 17 const allowHex = global.params.cplusplus >= CppStdRevision.cpp17; floatToBuffer(e.type, e.value, *buf, allowHex); diff --git a/dmd/expression.d b/dmd/expression.d index d99e5c9d29..9e015f9aa1 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -17,20 +17,16 @@ import core.stdc.stdarg; import core.stdc.stdio; import core.stdc.string; -import dmd.aggregate; import dmd.arraytypes; import dmd.astenums; import dmd.ast_node; import dmd.dcast : implicitConvTo; import dmd.dclass; import dmd.declaration; -import dmd.dimport; -import dmd.dmodule; import dmd.dstruct; import dmd.dsymbol; import dmd.dtemplate; import dmd.errors; -import dmd.errorsink; import dmd.func; import dmd.globals; import dmd.hdrgen; diff --git a/dmd/frontend.h b/dmd/frontend.h index 2629287211..7fa1d6e6eb 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -5485,41 +5485,6 @@ class StaticAssert final : public Dsymbol void accept(Visitor* v) override; }; -struct UnionExp final -{ - #pragma pack(push, 8) -private: - union _AnonStruct_u - { - char exp[22LLU]; - char integerexp[32LLU]; - char errorexp[22LLU]; - char realexp[48LLU]; - char complexexp[64LLU]; - char symoffexp[56LLU]; - char stringexp[44LLU]; - char arrayliteralexp[56LLU]; - char assocarrayliteralexp[56LLU]; - char structliteralexp[64LLU]; - char compoundliteralexp[32LLU]; - char nullexp[22LLU]; - char dotvarexp[41LLU]; - char addrexp[32LLU]; - char indexexp[58LLU]; - char sliceexp[57LLU]; - char vectorexp[45LLU]; - }; - #pragma pack(pop) - - // Ignoring var u alignment 8 - _AnonStruct_u u; -public: - UnionExp() : - u() - { - } -}; - enum class MODFlags { none = 0, @@ -5902,8 +5867,6 @@ struct ASTCodegen final using WhileStatement = ::WhileStatement; using WithStatement = ::WithStatement; using StaticAssert = ::StaticAssert; - using UnionExp = ::UnionExp; - using emplaceExp = ::emplaceExp; typedef UserAttributeDeclaration* UserAttributeDeclaration; typedef Ensure Ensure; typedef ErrorExp* ErrorExp; diff --git a/dmd/func.d b/dmd/func.d index 76a4c83def..faabc7726c 100644 --- a/dmd/func.d +++ b/dmd/func.d @@ -23,27 +23,19 @@ import core.stdc.string; import dmd.aggregate; import dmd.arraytypes; import dmd.astenums; -import dmd.blockexit; import dmd.dclass; import dmd.declaration; -import dmd.dscope; -import dmd.dstruct; import dmd.dsymbol; import dmd.dtemplate; -import dmd.escape; -import dmd.expression; import dmd.globals; import dmd.hdrgen; import dmd.id; import dmd.identifier; -import dmd.init; import dmd.location; import dmd.mtype; import dmd.objc; import dmd.common.outbuffer; import dmd.rootobject; -import dmd.root.string; -import dmd.root.stringtable; import dmd.statement; import dmd.targetcompiler; import dmd.tokens; diff --git a/dmd/initsem.d b/dmd/initsem.d index c02ee34b5a..9e9d46f446 100644 --- a/dmd/initsem.d +++ b/dmd/initsem.d @@ -14,8 +14,6 @@ module dmd.initsem; import core.stdc.stdio; import core.checkedint; -import dmd.aggregate; -import dmd.aliasthis; import dmd.arraytypes; import dmd.astenums; import dmd.dcast; @@ -617,7 +615,6 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn static if (0) if (auto ts = tx.isTypeStruct()) { - import dmd.common.outbuffer; OutBuffer buf; HdrGenState hgs; toCBuffer(ts.sym, buf, hgs); diff --git a/dmd/mtype.d b/dmd/mtype.d index 047ad425e2..c1b03f2155 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -27,13 +27,11 @@ import dmd.denum; import dmd.dstruct; import dmd.dsymbol; import dmd.dtemplate; -import dmd.errors; import dmd.expression; import dmd.hdrgen; import dmd.id; import dmd.identifier; import dmd.location; -import dmd.root.ctfloat; import dmd.common.outbuffer; import dmd.root.rmem; import dmd.rootobject; diff --git a/dmd/staticassert.d b/dmd/staticassert.d index 52ded559e5..2957fa6e8f 100644 --- a/dmd/staticassert.d +++ b/dmd/staticassert.d @@ -18,7 +18,6 @@ import dmd.dsymbol; import dmd.expression; import dmd.location; import dmd.id; -import dmd.identifier; import dmd.visitor; /*********************************************************** diff --git a/dmd/traits.d b/dmd/traits.d index 4755e372c3..568fe08077 100644 --- a/dmd/traits.d +++ b/dmd/traits.d @@ -17,14 +17,12 @@ import core.stdc.stdio; import dmd.aggregate; import dmd.arraytypes; -import dmd.astcodegen; import dmd.astenums; import dmd.attrib; import dmd.attribsem; import dmd.canthrow; import dmd.dclass; import dmd.declaration; -import dmd.dimport; import dmd.dinterpret; import dmd.dmodule; import dmd.dscope; @@ -46,7 +44,6 @@ import dmd.mangle : decoToType; import dmd.mtype; import dmd.nogc; import dmd.optimize; -import dmd.parse; import dmd.root.array; import dmd.root.speller; import dmd.root.stringtable; @@ -54,9 +51,7 @@ import dmd.target; import dmd.templatesem : TemplateInstance_semanticTiargs, TemplateInstanceBox; import dmd.tokens; import dmd.typesem; -import dmd.visitor; import dmd.rootobject; -import dmd.common.outbuffer; import dmd.root.string; enum LOGSEMANTIC = false; diff --git a/dmd/typesem.d b/dmd/typesem.d index d8541e9601..4c80961c96 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -17,7 +17,6 @@ import core.stdc.stdio; import dmd.access; import dmd.aggregate; -import dmd.aliasthis; import dmd.arrayop; import dmd.arraytypes; import dmd.astcodegen; @@ -26,7 +25,6 @@ import dmd.dcast; import dmd.dclass; import dmd.declaration; import dmd.denum; -import dmd.dimport; import dmd.dinterpret; import dmd.dmodule; import dmd.dscope; @@ -37,7 +35,6 @@ import dmd.templatesem : computeOneMember; import dmd.dtemplate; import dmd.enumsem; import dmd.errors; -import dmd.errorsink; import dmd.expression; import dmd.expressionsem; import dmd.func; @@ -51,7 +48,6 @@ import dmd.importc; import dmd.init; import dmd.initsem; import dmd.location; -import dmd.visitor; import dmd.mtype; import dmd.mangle; import dmd.nogc; @@ -65,7 +61,6 @@ import dmd.root.rmem; import dmd.common.outbuffer; import dmd.rootobject; import dmd.root.string; -import dmd.root.stringtable; import dmd.safe; import dmd.semantic3; import dmd.sideeffect; From fdeaf14e6fd7fad02b7c383bf068fca68cb3fc76 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Wed, 29 Oct 2025 03:34:46 -0700 Subject: [PATCH 060/440] move __va_argsave_t to sysv_x64.d (dlang/dmd!22043) --- .../druntime/src/core/internal/vararg/sysv_x64.d | 10 ++++++++++ runtime/druntime/src/core/stdc/stdarg.d | 13 +------------ runtime/druntime/src/core/stdc/stdio.d | 16 ++++++++-------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/runtime/druntime/src/core/internal/vararg/sysv_x64.d b/runtime/druntime/src/core/internal/vararg/sysv_x64.d index d753fb019c..795de87459 100644 --- a/runtime/druntime/src/core/internal/vararg/sysv_x64.d +++ b/runtime/druntime/src/core/internal/vararg/sysv_x64.d @@ -41,6 +41,16 @@ alias __va_list = __va_list_tag; */ alias va_list = __va_list*; +version (DigitalMars) +{ + align(16) struct __va_argsave_t + { + size_t[6] regs; // RDI,RSI,RDX,RCX,R8,R9 + real[8] fpregs; // XMM0..XMM7 + __va_list va; + } +} + /// T va_arg(T)(va_list ap) { diff --git a/runtime/druntime/src/core/stdc/stdarg.d b/runtime/druntime/src/core/stdc/stdarg.d index c08d22ccba..82383ea72b 100644 --- a/runtime/druntime/src/core/stdc/stdarg.d +++ b/runtime/druntime/src/core/stdc/stdarg.d @@ -28,16 +28,6 @@ version (X86_64) version (SysV_x64) { static import core.internal.vararg.sysv_x64; - - version (DigitalMars) - { - align(16) struct __va_argsave_t - { - size_t[6] regs; // RDI,RSI,RDX,RCX,R8,R9 - real[8] fpregs; // XMM0..XMM7 - __va_list va; - } - } } version (ARM) version = ARM_Any; @@ -105,8 +95,7 @@ version (BigEndian) */ version (SysV_x64) { - alias va_list = core.internal.vararg.sysv_x64.va_list; - public import core.internal.vararg.sysv_x64 : __va_list, __va_list_tag; + public import core.internal.vararg.sysv_x64 : va_list, __va_list, __va_list_tag; } else version (AAPCS32) { diff --git a/runtime/druntime/src/core/stdc/stdio.d b/runtime/druntime/src/core/stdc/stdio.d index b493a7fa85..0c4e02f70e 100644 --- a/runtime/druntime/src/core/stdc/stdio.d +++ b/runtime/druntime/src/core/stdc/stdio.d @@ -1703,14 +1703,14 @@ else version (OpenBSD) { /// void rewind(FILE*); - /// - pure void clearerr(FILE*); - /// - pure int feof(FILE*); - /// - pure int ferror(FILE*); - /// - int fileno(FILE*); + /// + pure void clearerr(FILE*); + /// + pure int feof(FILE*); + /// + pure int ferror(FILE*); + /// + int fileno(FILE*); } /// From 25c20fd65e9660c34b317575826d25648647806c Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 31 Oct 2025 02:05:53 +0200 Subject: [PATCH 061/440] Break semantic dependency of `expression.d` on `dcast` (dlang/dmd!22045) --- dmd/builtin.d | 1 + dmd/ctfeexpr.d | 2 +- dmd/cxxfrontend.d | 6 ++++ dmd/expression.d | 77 --------------------------------------------- dmd/expression.h | 5 +-- dmd/expressionsem.d | 75 +++++++++++++++++++++++++++++++++++++++++++ dmd/frontend.h | 6 +--- dmd/mangle/cpp.d | 1 + dmd/mangle/cppwin.d | 1 + dmd/semantic2.d | 4 ++- 10 files changed, 90 insertions(+), 88 deletions(-) diff --git a/dmd/builtin.d b/dmd/builtin.d index a72c8cf49d..b3eb7a7bb5 100644 --- a/dmd/builtin.d +++ b/dmd/builtin.d @@ -177,6 +177,7 @@ Expression eval_ctfeWrite(Loc loc, FuncDeclaration fd, Expression[] arguments) import core.stdc.stdio: fprintf, stderr; import dmd.expression: CTFEExp; import dmd.ctfeexpr: resolveSlice; + import dmd.expressionsem : toStringExp; Expression e = arguments[0]; const se = resolveSlice(e).toStringExp(); diff --git a/dmd/ctfeexpr.d b/dmd/ctfeexpr.d index 4e7fa43949..b093bfa797 100644 --- a/dmd/ctfeexpr.d +++ b/dmd/ctfeexpr.d @@ -25,7 +25,7 @@ import dmd.dstruct; import dmd.dtemplate; import dmd.errors; import dmd.expression; -import dmd.expressionsem : isIdentical, getFieldIndex, toBool; +import dmd.expressionsem : isIdentical, getFieldIndex, toBool, toStringExp; import dmd.func; import dmd.globals : dinteger_t, sinteger_t, uinteger_t; import dmd.location; diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 68ea856f5e..a4273c3a0c 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -430,6 +430,12 @@ Optional!bool toBool(Expression exp) return dmd.expressionsem.toBool(exp); } +StringExp toStringExp(Expression exp) +{ + import dmd.expressionsem; + return dmd.expressionsem.toStringExp(exp); +} + /*********************************************************** * func.d */ diff --git a/dmd/expression.d b/dmd/expression.d index 9e015f9aa1..bcf9221bb3 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -20,7 +20,6 @@ import core.stdc.string; import dmd.arraytypes; import dmd.astenums; import dmd.ast_node; -import dmd.dcast : implicitConvTo; import dmd.dclass; import dmd.declaration; import dmd.dstruct; @@ -37,7 +36,6 @@ import dmd.location; import dmd.mtype; import dmd.root.complex; import dmd.root.ctfloat; -import dmd.common.outbuffer; import dmd.root.rmem; import dmd.rootobject; import dmd.root.string; @@ -495,11 +493,6 @@ extern (C++) abstract class Expression : ASTNode return complex_t(CTFloat.zero); } - StringExp toStringExp() - { - return null; - } - /**************************************** * Check that the expression has a valid type. * If not, generates an error "... has no type". @@ -1183,18 +1176,6 @@ extern (C++) final class NullExp : Expression this.type = type; } - override StringExp toStringExp() - { - if (this.type.implicitConvTo(Type.tstring)) - { - auto se = new StringExp(loc, (cast(char*)mem.xcalloc(1, 1))[0 .. 0]); - se.type = Type.tstring; - return se; - } - - return null; - } - override void accept(Visitor v) { v.visit(this); @@ -1419,12 +1400,6 @@ extern (C++) final class StringExp : Expression } } - override StringExp toStringExp() - { - return this; - } - - /** * Compare two `StringExp` by length, then value * @@ -1704,58 +1679,6 @@ extern (C++) final class ArrayLiteralExp : Expression return el ? el : basis; } - override StringExp toStringExp() - { - TY telem = type.nextOf().toBasetype().ty; - if (!(telem.isSomeChar || (telem == Tvoid && (!elements || elements.length == 0)))) - return null; - - ubyte sz = 1; - if (telem == Twchar) - sz = 2; - else if (telem == Tdchar) - sz = 4; - - OutBuffer buf; - if (elements) - { - foreach (i; 0 .. elements.length) - { - auto ch = this[i]; - if (ch.op != EXP.int64) - return null; - if (sz == 1) - buf.writeByte(cast(ubyte)ch.toInteger()); - else if (sz == 2) - buf.writeword(cast(uint)ch.toInteger()); - else - buf.write4(cast(uint)ch.toInteger()); - } - } - char prefix; - if (sz == 1) - { - prefix = 'c'; - buf.writeByte(0); - } - else if (sz == 2) - { - prefix = 'w'; - buf.writeword(0); - } - else - { - prefix = 'd'; - buf.write4(0); - } - - const size_t len = buf.length / sz - 1; - auto se = new StringExp(loc, buf.extractSlice()[0 .. len * sz], len, sz, prefix); - se.sz = sz; - se.type = type; - return se; - } - override void accept(Visitor v) { v.visit(this); diff --git a/dmd/expression.h b/dmd/expression.h index f988d0e6d8..39c22cc37d 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -65,6 +65,7 @@ namespace dmd int32_t getFieldIndex(ClassReferenceExp *cre, Type *fieldtype, uint32_t fieldoffset); void fillTupleExpExps(TupleExp *te, TupleDeclaration *tup); Optional toBool(Expression *exp); + StringExp *toStringExp(Expression *exp); } typedef unsigned char OwnedBy; @@ -105,7 +106,6 @@ class Expression : public ASTNode virtual real_t toReal(); virtual real_t toImaginary(); virtual complex_t toComplex(); - virtual StringExp *toStringExp(); virtual bool checkType(); Expression *addressOf(); Expression *deref(); @@ -328,7 +328,6 @@ class SuperExp final : public ThisExp class NullExp final : public Expression { public: - StringExp *toStringExp() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -348,7 +347,6 @@ class StringExp final : public Expression static StringExp *create(Loc loc, const void *s, d_size_t len); char32_t getCodeUnit(d_size_t i) const; dinteger_t getIndex(d_size_t i) const; - StringExp *toStringExp() override; void accept(Visitor *v) override { v->visit(this); } size_t numberOfCodeUnits(int tynto = 0) const; void writeTo(void* dest, bool zero, int tyto = 0) const; @@ -398,7 +396,6 @@ class ArrayLiteralExp final : public Expression static ArrayLiteralExp *create(Loc loc, Expressions *elements); ArrayLiteralExp *syntaxCopy() override; Expression *getElement(d_size_t i); - StringExp *toStringExp() override; void accept(Visitor *v) override { v->visit(this); } }; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index f943b71e83..f3129ae13a 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -81,6 +81,7 @@ import dmd.common.outbuffer; import dmd.rootobject; import dmd.root.string; import dmd.root.utf; +import dmd.root.rmem; import dmd.semantic2; import dmd.semantic3; import dmd.sideeffect; @@ -99,6 +100,80 @@ import dmd.visitor.postorder; enum LOGSEMANTIC = false; +StringExp toStringExp(Expression _this) +{ + static StringExp nullExpToStringExp(NullExp _this) + { + if (_this.type.implicitConvTo(Type.tstring)) + { + auto se = new StringExp(_this.loc, (cast(char*).mem.xcalloc(1, 1))[0 .. 0]); + se.type = Type.tstring; + return se; + } + return null; + } + + static StringExp arrayLiteralToStringExp(ArrayLiteralExp _this) + { + TY telem = _this.type.nextOf().toBasetype().ty; + if (!(telem.isSomeChar || (telem == Tvoid && (!_this.elements || _this.elements.length == 0)))) + return null; + + ubyte sz = 1; + if (telem == Twchar) + sz = 2; + else if (telem == Tdchar) + sz = 4; + + OutBuffer buf; + if (_this.elements) + { + foreach (i; 0 .. _this.elements.length) + { + auto ch = _this[i]; + if (ch.op != EXP.int64) + return null; + if (sz == 1) + buf.writeByte(cast(ubyte)ch.toInteger()); + else if (sz == 2) + buf.writeword(cast(uint)ch.toInteger()); + else + buf.write4(cast(uint)ch.toInteger()); + } + } + char prefix; + if (sz == 1) + { + prefix = 'c'; + buf.writeByte(0); + } + else if (sz == 2) + { + prefix = 'w'; + buf.writeword(0); + } + else + { + prefix = 'd'; + buf.write4(0); + } + + const size_t len = buf.length / sz - 1; + auto se = new StringExp(_this.loc, buf.extractSlice()[0 .. len * sz], len, sz, prefix); + se.sz = sz; + se.type = _this.type; + return se; + } + + switch(_this.op) + { + case EXP.null_: return nullExpToStringExp(_this.isNullExp()); + case EXP.string_: return _this.isStringExp(); + case EXP.arrayLiteral: return arrayLiteralToStringExp(_this.isArrayLiteralExp()); + default: return null; + } +} + Optional!bool toBool(Expression _this) { static Optional!bool integerToBool(IntegerExp _this) diff --git a/dmd/frontend.h b/dmd/frontend.h index 7fa1d6e6eb..a8046aec02 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -172,7 +172,6 @@ class TypeMixin; class TypeTraits; class TypeNoreturn; class TypeTag; -class StringExp; class IntegerExp; class ErrorExp; class VoidInitExp; @@ -184,6 +183,7 @@ class DsymbolExp; class ThisExp; class SuperExp; class NullExp; +class StringExp; class InterpExp; class TupleExp; class ArrayLiteralExp; @@ -2356,7 +2356,6 @@ class Expression : public ASTNode virtual _d_real toReal(); virtual _d_real toImaginary(); virtual complex_t toComplex(); - virtual StringExp* toStringExp(); virtual bool checkType(); Expression* deref(); int32_t isConst(); @@ -2585,7 +2584,6 @@ class ArrayLiteralExp final : public Expression static ArrayLiteralExp* create(Loc loc, Array* elements); ArrayLiteralExp* syntaxCopy() override; Expression* getElement(size_t i); - StringExp* toStringExp() override; void accept(Visitor* v) override; }; @@ -3361,7 +3359,6 @@ class NotExp final : public UnaExp class NullExp final : public Expression { public: - StringExp* toStringExp() override; void accept(Visitor* v) override; }; @@ -3543,7 +3540,6 @@ class StringExp final : public Expression void writeTo(void* dest, bool zero, int32_t tyto = 0) const; char32_t getCodeUnit(size_t i) const; dinteger_t getIndex(size_t i) const; - StringExp* toStringExp() override; int32_t compare(const StringExp* const se2) const; void accept(Visitor* v) override; }; diff --git a/dmd/mangle/cpp.d b/dmd/mangle/cpp.d index 6385404d8a..1ae36722b7 100644 --- a/dmd/mangle/cpp.d +++ b/dmd/mangle/cpp.d @@ -27,6 +27,7 @@ import dmd.attrib; import dmd.declaration; import dmd.dsymbol; import dmd.dsymbolsem : isGNUABITag, toAlias, equals; +import dmd.expressionsem : toStringExp; import dmd.templatesem : computeOneMember; import dmd.dtemplate; import dmd.errors; diff --git a/dmd/mangle/cppwin.d b/dmd/mangle/cppwin.d index c380d42809..283d4475d7 100644 --- a/dmd/mangle/cppwin.d +++ b/dmd/mangle/cppwin.d @@ -21,6 +21,7 @@ import dmd.denum : isSpecialEnumIdent; import dmd.dstruct; import dmd.dsymbol; import dmd.dsymbolsem : toAlias; +import dmd.expressionsem : toStringExp; import dmd.templatesem : computeOneMember; import dmd.dtemplate; import dmd.errors; diff --git a/dmd/semantic2.d b/dmd/semantic2.d index 94782e39e3..cca8dcea38 100644 --- a/dmd/semantic2.d +++ b/dmd/semantic2.d @@ -799,7 +799,9 @@ private void doGNUABITagSemantic(ref Expression e, ref Expression* lastTag) // `const` (and nor is `StringExp`, by extension). static int predicate(const scope Expression* e1, const scope Expression* e2) { - return (cast(Expression*)e1).toStringExp().compare((cast(Expression*)e2).toStringExp()); + Expression e11 = cast(Expression) *e1; + Expression e22 = cast(Expression) *e2; + return e11.toStringExp().compare(e22.toStringExp()); } ale.elements.sort!predicate; } From 3725679c6e0aafb587693bcc8a851bc33e21a77e Mon Sep 17 00:00:00 2001 From: limepoutine Date: Fri, 31 Oct 2025 20:20:42 +0800 Subject: [PATCH 062/440] Emit stack frame for try blocks with EH_DM (dlang/dmd!22046) --- tests/dmd/runnable/nested.d | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/dmd/runnable/nested.d b/tests/dmd/runnable/nested.d index 4c99c59e8a..89617de580 100644 --- a/tests/dmd/runnable/nested.d +++ b/tests/dmd/runnable/nested.d @@ -2526,6 +2526,27 @@ void test14846() foo14846({ S* p = new S(1); }); foo14846({ S[] a = [S()]; }); foo14846({ S[] a = [S(1)]; }); + + void named1() + { + S s; + } + + foo14846(&named1); + + void named2() + { + S s = S(1); + } + + foo14846(&named2); + + void named3() + { + S[3] s; + } + + foo14846(&named3); } /*******************************************/ From 44be3ffe8ee4c534ee00c9d9794b1fca89c8bd7c Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Sat, 1 Nov 2025 12:34:30 +0100 Subject: [PATCH 063/440] avoid spurious Windows CI test failure in druntime/test/shared (dlang/dmd!22052) tests dllgc and dynamiccast compile both executable and shared library from the same source file, but the DLL with -version=DLL. Both targets have the same intermediate object file which can cause both build and runtime errors when building concurrently. Solution: generate object files for DLLs to a different directory --- runtime/druntime/test/shared/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/druntime/test/shared/Makefile b/runtime/druntime/test/shared/Makefile index 4c359b09a0..f56de4a2f9 100644 --- a/runtime/druntime/test/shared/Makefile +++ b/runtime/druntime/test/shared/Makefile @@ -33,7 +33,7 @@ PATH := $(dir $(DRUNTIMESO));$(PATH) endif $(ROOT)/dllgc.done: $(ROOT)/dllgc$(DOTDLL) -$(ROOT)/dllgc$(DOTDLL): extra_dflags += -version=DLL +$(ROOT)/dllgc$(DOTDLL): extra_dflags += -version=DLL -od=$(ROOT)/dll endif # Windows $(ROOT)/dynamiccast.done: $(ROOT)/%.done: $(ROOT)/%$(DOTEXE) $(ROOT)/%$(DOTDLL) @@ -44,7 +44,7 @@ $(ROOT)/dynamiccast.done: $(ROOT)/%.done: $(ROOT)/%$(DOTEXE) $(ROOT)/%$(DOTDLL) test -f $(ROOT)/dynamiccast_endmain @touch $@ $(ROOT)/dynamiccast$(DOTEXE): private extra_ldlibs.d += $(LINKDL) -$(ROOT)/dynamiccast$(DOTDLL): private extra_dflags += -version=DLL +$(ROOT)/dynamiccast$(DOTDLL): private extra_dflags += -version=DLL -od=$(ROOT)/dll # Avoid a race condition that I sometimes hit with make -j8. # Maybe temporary file collisions when invoking the linker? From cb2cc7dee916bee119b1cdfbae0bcb5f8c58f960 Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Sat, 1 Nov 2025 12:34:46 +0100 Subject: [PATCH 064/440] fix dlang/dmd!22048 #including emits warnings from driverspecs.h and no_sal2.h (dlang/dmd!22049) use appropriate definitions to disable Microsoft Source Code Annotation macros instead of #including the respective headers prematurely --- runtime/druntime/src/importc.h | 7 +++---- tests/dmd/compilable/test22048.c | 9 +++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 tests/dmd/compilable/test22048.c diff --git a/runtime/druntime/src/importc.h b/runtime/druntime/src/importc.h index 4b4195f737..dd2cdb87b4 100644 --- a/runtime/druntime/src/importc.h +++ b/runtime/druntime/src/importc.h @@ -158,10 +158,9 @@ typedef unsigned long long __uint64_t; #define _stdcall __stdcall #define _declspec __declspec -// This header disables the Windows API Annotations macros -// Need to include sal.h to get the pragma once to prevent macro redefinition. -#include "sal.h" -#include "no_sal2.h" +// disable the Microsoft Source Code Annotation macros in "sal.h" +#define _USE_DECLSPECS_FOR_SAL 0 +#define _USE_ATTRIBUTES_FOR_SAL 0 #endif /**************************** diff --git a/tests/dmd/compilable/test22048.c b/tests/dmd/compilable/test22048.c new file mode 100644 index 0000000000..2453df3ffd --- /dev/null +++ b/tests/dmd/compilable/test22048.c @@ -0,0 +1,9 @@ +/* +TEST_OUTPUT: +--- +--- +*/ + +#ifdef _MSCVER +#include +#endif From 3e9d9ca5c0aecfbc31b04905342761d2b0ad791e Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Sat, 1 Nov 2025 12:36:18 +0100 Subject: [PATCH 065/440] fix CI building documentation (dlang/dmd!22050) --- dmd/doc.d | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dmd/doc.d b/dmd/doc.d index 17e2d55653..4328391d69 100644 --- a/dmd/doc.d +++ b/dmd/doc.d @@ -3111,7 +3111,9 @@ struct MarkdownLink { size_t iStart = i + 1; size_t iEnd = iStart; - if (iEnd >= buf.length || buf[iEnd] != '[' || (iEnd+1 < buf.length && buf[iEnd+1] == ']')) + if (iEnd >= buf.length) + return i; + if (buf[iEnd] != '[' || (iEnd+1 < buf.length && buf[iEnd+1] == ']')) { // collapsed reference [foo][] or shortcut reference [foo] iStart = delimiter.iStart + delimiter.count - 1; From 241bf2237499dd9fd894c7634cbcd372822c4662 Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Tue, 4 Nov 2025 00:34:56 +0100 Subject: [PATCH 066/440] fix inlining of functions in core.stdc.stdatomic (dlang/dmd!22051) --- runtime/druntime/src/core/stdc/stdatomic.d | 387 ++++++++++----------- tests/dmd/compilable/pragmainline2.d | 33 ++ 2 files changed, 218 insertions(+), 202 deletions(-) diff --git a/runtime/druntime/src/core/stdc/stdatomic.d b/runtime/druntime/src/core/stdc/stdatomic.d index 51968af8c5..966d29d808 100644 --- a/runtime/druntime/src/core/stdc/stdatomic.d +++ b/runtime/druntime/src/core/stdc/stdatomic.d @@ -165,27 +165,23 @@ void atomic_flag_clear_explicit_impl()(atomic_flag* obj, memory_order order) { assert(obj !is null); - final switch (order) - { - case memory_order.memory_order_relaxed: - atomicStore!(memory_order.memory_order_relaxed)(&obj.b, false); - break; + // use series of ternary expressions instead of switch to help the dmd inliner + order == memory_order.memory_order_relaxed ? + atomicStore!(memory_order.memory_order_relaxed)(&obj.b, false) : - case memory_order.memory_order_acquire: - case memory_order.memory_order_acq_rel: - // Ideally this would error at compile time but alas it is not an intrinsic. - // Note: this is not a valid memory order for this operation. - atomicStore!(memory_order.memory_order_seq_cst)(&obj.b, false); - break; + order == memory_order.memory_order_acquire || + order == memory_order.memory_order_acq_rel ? + // Ideally this would error at compile time but alas it is not an intrinsic. + // Note: this is not a valid memory order for this operation. + atomicStore!(memory_order.memory_order_seq_cst)(&obj.b, false) : - case memory_order.memory_order_release: - atomicStore!(memory_order.memory_order_release)(&obj.b, false); - break; + order == memory_order.memory_order_release ? + atomicStore!(memory_order.memory_order_release)(&obj.b, false) : - case memory_order.memory_order_seq_cst: - atomicStore(&obj.b, false); - break; - } + order == memory_order.memory_order_seq_cst ? + atomicStore(&obj.b, false) : + + cast(void) assert(0); } /// @@ -210,25 +206,26 @@ bool atomic_flag_test_and_set_explicit_impl()(atomic_flag* obj, memory_order ord { assert(obj !is null); - final switch (order) - { - case memory_order.memory_order_relaxed: - return atomicExchange!(memory_order.memory_order_relaxed)(&obj.b, true); + // use series of ternary expressions instead of switch to help the dmd inliner + return + order == memory_order.memory_order_relaxed ? + atomicExchange!(memory_order.memory_order_relaxed)(&obj.b, true) : - case memory_order.memory_order_acquire: + order == memory_order.memory_order_acquire ? // Ideally this would error at compile time but alas it is not an intrinsic. // Note: this is not a valid memory order for this operation. - return atomicExchange!(memory_order.memory_order_seq_cst)(&obj.b, true); + atomicExchange!(memory_order.memory_order_seq_cst)(&obj.b, true) : - case memory_order.memory_order_release: - return atomicExchange!(memory_order.memory_order_release)(&obj.b, true); + order == memory_order.memory_order_release ? + atomicExchange!(memory_order.memory_order_release)(&obj.b, true) : - case memory_order.memory_order_acq_rel: - return atomicExchange!(memory_order.memory_order_acq_rel)(&obj.b, true); + order == memory_order.memory_order_acq_rel ? + atomicExchange!(memory_order.memory_order_acq_rel)(&obj.b, true) : - case memory_order.memory_order_seq_cst: - return atomicExchange(&obj.b, true); - } + order == memory_order.memory_order_seq_cst ? + atomicExchange(&obj.b, true) : + + assert(0); } /// @@ -271,28 +268,24 @@ A kill_dependency(A)(A y) @trusted pragma(inline, true) void atomic_signal_fence_impl()(memory_order order) { - final switch (order) - { - case memory_order.memory_order_relaxed: - // This is a no-op operation for relaxed memory orders. - break; + // use series of ternary expressions instead of switch to help the dmd inliner + order == memory_order.memory_order_relaxed ? + // This is a no-op operation for relaxed memory orders. + cast(void)0 : - case memory_order.memory_order_acquire: - atomicSignalFence!(memory_order.memory_order_acquire); - break; + order == memory_order.memory_order_acquire ? + atomicSignalFence!(memory_order.memory_order_acquire) : - case memory_order.memory_order_release: - atomicSignalFence!(memory_order.memory_order_release); - break; + order == memory_order.memory_order_release ? + atomicSignalFence!(memory_order.memory_order_release) : - case memory_order.memory_order_acq_rel: - atomicSignalFence!(memory_order.memory_order_acq_rel); - break; + order == memory_order.memory_order_acq_rel ? + atomicSignalFence!(memory_order.memory_order_acq_rel) : - case memory_order.memory_order_seq_cst: - atomicSignalFence!(memory_order.memory_order_seq_cst); - break; - } + order == memory_order.memory_order_seq_cst ? + atomicSignalFence!(memory_order.memory_order_seq_cst) : + + cast(void) assert(0); } /// @@ -305,28 +298,24 @@ unittest pragma(inline, true) void atomic_thread_fence_impl()(memory_order order) { - final switch (order) - { - case memory_order.memory_order_relaxed: - // This is a no-op operation for relaxed memory orders. - break; + // use series of ternary expressions instead of switch to help the dmd inliner + order == memory_order.memory_order_relaxed ? + // This is a no-op operation for relaxed memory orders. + cast(void)0 : - case memory_order.memory_order_acquire: - atomicFence!(memory_order.memory_order_acquire); - break; + order == memory_order.memory_order_acquire ? + atomicFence!(memory_order.memory_order_acquire) : - case memory_order.memory_order_release: - atomicFence!(memory_order.memory_order_release); - break; + order == memory_order.memory_order_release ? + atomicFence!(memory_order.memory_order_release) : - case memory_order.memory_order_acq_rel: - atomicFence!(memory_order.memory_order_acq_rel); - break; + order == memory_order.memory_order_acq_rel ? + atomicFence!(memory_order.memory_order_acq_rel) : - case memory_order.memory_order_seq_cst: - atomicFence!(memory_order.memory_order_seq_cst); - break; - } + order == memory_order.memory_order_seq_cst ? + atomicFence!(memory_order.memory_order_seq_cst) : + + cast(void) assert(0); } /// @@ -437,27 +426,23 @@ void atomic_store_explicit_impl(A, C)(shared(A)* obj, C desired, memory_order or { assert(obj !is null); - final switch (order) - { - case memory_order.memory_order_relaxed: - atomicStore!(memory_order.memory_order_relaxed)(cast(A*)obj, cast(A)desired); - break; + // use series of ternary expressions instead of switch to help the dmd inliner + order == memory_order.memory_order_relaxed ? + atomicStore!(memory_order.memory_order_relaxed)(cast(A*)obj, cast(A)desired) : - case memory_order.memory_order_acquire: - case memory_order.memory_order_acq_rel: - // Ideally this would error at compile time but alas it is not an intrinsic. - // Note: this is not a valid memory order for this operation. - atomicStore!(memory_order.memory_order_release)(cast(A*)obj, cast(A)desired); - break; + order == memory_order.memory_order_acquire || + order == memory_order.memory_order_acq_rel ? + // Ideally this would error at compile time but alas it is not an intrinsic. + // Note: this is not a valid memory order for this operation. + atomicStore!(memory_order.memory_order_release)(cast(A*)obj, cast(A)desired) : - case memory_order.memory_order_release: - atomicStore!(memory_order.memory_order_release)(cast(A*)obj, cast(A)desired); - break; + order == memory_order.memory_order_release ? + atomicStore!(memory_order.memory_order_release)(cast(A*)obj, cast(A)desired) : - case memory_order.memory_order_seq_cst: - atomicStore!(memory_order.memory_order_seq_cst)(cast(A*)obj, cast(A)desired); - break; - } + order == memory_order.memory_order_seq_cst ? + atomicStore!(memory_order.memory_order_seq_cst)(cast(A*)obj, cast(A)desired) : + + cast(void) assert(0); } /// @@ -501,23 +486,24 @@ A atomic_load_explicit_impl(A)(const shared(A)* obj, memory_order order) @truste { assert(obj !is null); - final switch (order) - { - case memory_order.memory_order_relaxed: - return atomicLoad!(memory_order.memory_order_relaxed)(cast(A*)obj); + // use series of ternary expressions instead of switch to help the dmd inliner + return + order == memory_order.memory_order_relaxed ? + atomicLoad!(memory_order.memory_order_relaxed)(cast(A*)obj) : - case memory_order.memory_order_acquire: - return atomicLoad!(memory_order.memory_order_acquire)(cast(A*)obj); + order == memory_order.memory_order_acquire ? + atomicLoad!(memory_order.memory_order_acquire)(cast(A*)obj) : - case memory_order.memory_order_release: - case memory_order.memory_order_acq_rel: + order == memory_order.memory_order_release || + order == memory_order.memory_order_acq_rel ? // Ideally this would error at compile time but alas it is not an intrinsic. // Note: this is not a valid memory order for this operation. - return atomicLoad!(memory_order.memory_order_acquire)(cast(A*)obj); + atomicLoad!(memory_order.memory_order_acquire)(cast(A*)obj) : - case memory_order.memory_order_seq_cst: - return atomicLoad!(memory_order.memory_order_seq_cst)(cast(A*)obj); - } + order == memory_order.memory_order_seq_cst ? + atomicLoad!(memory_order.memory_order_seq_cst)(cast(A*)obj) : + + assert(0); } /// @@ -554,25 +540,26 @@ A atomic_exchange_explicit_impl(A, C)(shared(A)* obj, C desired, memory_order or { assert(obj !is null); - final switch (order) - { - case memory_order.memory_order_relaxed: - return atomicExchange!(memory_order.memory_order_relaxed)(cast(A*)obj, cast(A)desired); + // use series of ternary expressions instead of switch to help the dmd inliner + return + order == memory_order.memory_order_relaxed ? + atomicExchange!(memory_order.memory_order_relaxed)(cast(A*)obj, cast(A)desired) : - case memory_order.memory_order_acquire: + order == memory_order.memory_order_acquire ? // Ideally this would error at compile time but alas it is not an intrinsic. // Note: this is not a valid memory order for this operation. - return atomicExchange!(memory_order.memory_order_seq_cst)(cast(A*)obj, cast(A)desired); + atomicExchange!(memory_order.memory_order_seq_cst)(cast(A*)obj, cast(A)desired) : - case memory_order.memory_order_release: - return atomicExchange!(memory_order.memory_order_release)(cast(A*)obj, cast(A)desired); + order == memory_order.memory_order_release ? + atomicExchange!(memory_order.memory_order_release)(cast(A*)obj, cast(A)desired) : - case memory_order.memory_order_acq_rel: - return atomicExchange!(memory_order.memory_order_acq_rel)(cast(A*)obj, cast(A)desired); + order == memory_order.memory_order_acq_rel ? + atomicExchange!(memory_order.memory_order_acq_rel)(cast(A*)obj, cast(A)desired) : - case memory_order.memory_order_seq_cst: - return atomicExchange!(memory_order.memory_order_seq_cst)(cast(A*)obj, cast(A)desired); - } + order == memory_order.memory_order_seq_cst ? + atomicExchange!(memory_order.memory_order_seq_cst)(cast(A*)obj, cast(A)desired) : + + assert(0); } /// @@ -641,19 +628,19 @@ bool atomic_compare_exchange_strong_explicit_impl(A, B, C)(shared(A)* obj, B* ex assert(obj !is null); // NOTE: To not have to deal with all invalid cases, the failure model is ignored for now. - final switch(succ) - { - case memory_order.memory_order_relaxed: - return atomicCompareExchangeStrong!(memory_order.memory_order_relaxed, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired); - case memory_order.memory_order_acquire: - return atomicCompareExchangeStrong!(memory_order.memory_order_acquire, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired); - case memory_order.memory_order_release: - return atomicCompareExchangeStrong!(memory_order.memory_order_release, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired); - case memory_order.memory_order_acq_rel: - return atomicCompareExchangeStrong!(memory_order.memory_order_acq_rel, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired); - case memory_order.memory_order_seq_cst: - return atomicCompareExchangeStrong!(memory_order.memory_order_seq_cst, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired); - } + // use series of ternary expressions instead of switch to help the dmd inliner + return + succ == memory_order.memory_order_relaxed ? + atomicCompareExchangeStrong!(memory_order.memory_order_relaxed, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired) : + succ == memory_order.memory_order_acquire ? + atomicCompareExchangeStrong!(memory_order.memory_order_acquire, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired) : + succ == memory_order.memory_order_release ? + atomicCompareExchangeStrong!(memory_order.memory_order_release, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired) : + succ == memory_order.memory_order_acq_rel ? + atomicCompareExchangeStrong!(memory_order.memory_order_acq_rel, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired) : + succ == memory_order.memory_order_seq_cst ? + atomicCompareExchangeStrong!(memory_order.memory_order_seq_cst, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired) : + assert(0); } /// @@ -689,19 +676,19 @@ bool atomic_compare_exchange_weak_explicit_impl(A, B, C)(shared(A)* obj, B* expe assert(obj !is null); // NOTE: To not have to deal with all invalid cases, the failure model is ignored for now. - final switch(succ) - { - case memory_order.memory_order_relaxed: - return atomicCompareExchangeWeak!(memory_order.memory_order_relaxed, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired); - case memory_order.memory_order_acquire: - return atomicCompareExchangeWeak!(memory_order.memory_order_acquire, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired); - case memory_order.memory_order_release: - return atomicCompareExchangeWeak!(memory_order.memory_order_release, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired); - case memory_order.memory_order_acq_rel: - return atomicCompareExchangeWeak!(memory_order.memory_order_acq_rel, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired); - case memory_order.memory_order_seq_cst: - return atomicCompareExchangeWeak!(memory_order.memory_order_seq_cst, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired); - } + // use series of ternary expressions instead of switch to help the dmd inliner + return + succ == memory_order.memory_order_relaxed ? + atomicCompareExchangeWeak!(memory_order.memory_order_relaxed, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired) : + succ == memory_order.memory_order_acquire ? + atomicCompareExchangeWeak!(memory_order.memory_order_acquire, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired) : + succ == memory_order.memory_order_release ? + atomicCompareExchangeWeak!(memory_order.memory_order_release, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired) : + succ == memory_order.memory_order_acq_rel ? + atomicCompareExchangeWeak!(memory_order.memory_order_acq_rel, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired) : + succ == memory_order.memory_order_seq_cst ? + atomicCompareExchangeWeak!(memory_order.memory_order_seq_cst, memory_order.memory_order_relaxed)(cast(B*)obj, expected, cast(B)desired) : + assert(0); } /// @@ -774,19 +761,19 @@ A atomic_fetch_add_explicit_impl(A, M)(shared(A)* obj, M arg, memory_order order { assert(obj !is null); - final switch(order) - { - case memory_order.memory_order_relaxed: - return atomic_fetch_op!(memory_order.memory_order_relaxed, "+=")(cast(A*)obj, arg); - case memory_order.memory_order_acquire: - return atomic_fetch_op!(memory_order.memory_order_acquire, "+=")(cast(A*)obj, arg); - case memory_order.memory_order_release: - return atomic_fetch_op!(memory_order.memory_order_release, "+=")(cast(A*)obj, arg); - case memory_order.memory_order_acq_rel: - return atomic_fetch_op!(memory_order.memory_order_acq_rel, "+=")(cast(A*)obj, arg); - case memory_order.memory_order_seq_cst: - return atomic_fetch_op!(memory_order.memory_order_seq_cst, "+=")(cast(A*)obj, arg); - } + // use series of ternary expressions instead of switch to help the dmd inliner + return + order == memory_order.memory_order_relaxed ? + atomic_fetch_op!(memory_order.memory_order_relaxed, "+=")(cast(A*)obj, arg) : + order == memory_order.memory_order_acquire ? + atomic_fetch_op!(memory_order.memory_order_acquire, "+=")(cast(A*)obj, arg) : + order == memory_order.memory_order_release ? + atomic_fetch_op!(memory_order.memory_order_release, "+=")(cast(A*)obj, arg) : + order == memory_order.memory_order_acq_rel ? + atomic_fetch_op!(memory_order.memory_order_acq_rel, "+=")(cast(A*)obj, arg) : + order == memory_order.memory_order_seq_cst ? + atomic_fetch_op!(memory_order.memory_order_seq_cst, "+=")(cast(A*)obj, arg) : + assert(0); } /// @@ -807,19 +794,18 @@ A atomic_fetch_sub_explicit_impl(A, M)(shared(A)* obj, M arg, memory_order order { assert(obj !is null); - final switch(order) - { - case memory_order.memory_order_relaxed: - return atomic_fetch_op!(memory_order.memory_order_relaxed, "-=")(cast(A*)obj, arg); - case memory_order.memory_order_acquire: - return atomic_fetch_op!(memory_order.memory_order_acquire, "-=")(cast(A*)obj, arg); - case memory_order.memory_order_release: - return atomic_fetch_op!(memory_order.memory_order_release, "-=")(cast(A*)obj, arg); - case memory_order.memory_order_acq_rel: - return atomic_fetch_op!(memory_order.memory_order_acq_rel, "-=")(cast(A*)obj, arg); - case memory_order.memory_order_seq_cst: - return atomic_fetch_op!(memory_order.memory_order_seq_cst, "-=")(cast(A*)obj, arg); - } + return + order == memory_order.memory_order_relaxed ? + atomic_fetch_op!(memory_order.memory_order_relaxed, "-=")(cast(A*)obj, arg) : + order == memory_order.memory_order_acquire ? + atomic_fetch_op!(memory_order.memory_order_acquire, "-=")(cast(A*)obj, arg) : + order == memory_order.memory_order_release ? + atomic_fetch_op!(memory_order.memory_order_release, "-=")(cast(A*)obj, arg) : + order == memory_order.memory_order_acq_rel ? + atomic_fetch_op!(memory_order.memory_order_acq_rel, "-=")(cast(A*)obj, arg) : + order == memory_order.memory_order_seq_cst ? + atomic_fetch_op!(memory_order.memory_order_seq_cst, "-=")(cast(A*)obj, arg) : + assert(0); } /// @@ -856,19 +842,18 @@ A atomic_fetch_or_explicit_impl(A, M)(shared(A)* obj, M arg, memory_order order) { assert(obj !is null); - final switch(order) - { - case memory_order.memory_order_relaxed: - return atomic_fetch_op!(memory_order.memory_order_relaxed, "|=")(cast(A*)obj, arg); - case memory_order.memory_order_acquire: - return atomic_fetch_op!(memory_order.memory_order_acquire, "|=")(cast(A*)obj, arg); - case memory_order.memory_order_release: - return atomic_fetch_op!(memory_order.memory_order_release, "|=")(cast(A*)obj, arg); - case memory_order.memory_order_acq_rel: - return atomic_fetch_op!(memory_order.memory_order_acq_rel, "|=")(cast(A*)obj, arg); - case memory_order.memory_order_seq_cst: - return atomic_fetch_op!(memory_order.memory_order_seq_cst, "|=")(cast(A*)obj, arg); - } + return + order == memory_order.memory_order_relaxed ? + atomic_fetch_op!(memory_order.memory_order_relaxed, "|=")(cast(A*)obj, arg) : + order == memory_order.memory_order_acquire ? + atomic_fetch_op!(memory_order.memory_order_acquire, "|=")(cast(A*)obj, arg) : + order == memory_order.memory_order_release ? + atomic_fetch_op!(memory_order.memory_order_release, "|=")(cast(A*)obj, arg) : + order == memory_order.memory_order_acq_rel ? + atomic_fetch_op!(memory_order.memory_order_acq_rel, "|=")(cast(A*)obj, arg) : + order == memory_order.memory_order_seq_cst ? + atomic_fetch_op!(memory_order.memory_order_seq_cst, "|=")(cast(A*)obj, arg) : + assert(0); } /// @@ -901,19 +886,18 @@ A atomic_fetch_xor_explicit_impl(A, M)(shared(A)* obj, M arg, memory_order order { assert(obj !is null); - final switch(order) - { - case memory_order.memory_order_relaxed: - return atomic_fetch_op!(memory_order.memory_order_relaxed, "^=")(cast(A*)obj, arg); - case memory_order.memory_order_acquire: - return atomic_fetch_op!(memory_order.memory_order_acquire, "^=")(cast(A*)obj, arg); - case memory_order.memory_order_release: - return atomic_fetch_op!(memory_order.memory_order_release, "^=")(cast(A*)obj, arg); - case memory_order.memory_order_acq_rel: - return atomic_fetch_op!(memory_order.memory_order_acq_rel, "^=")(cast(A*)obj, arg); - case memory_order.memory_order_seq_cst: - return atomic_fetch_op!(memory_order.memory_order_seq_cst, "^=")(cast(A*)obj, arg); - } + return + order == memory_order.memory_order_relaxed ? + atomic_fetch_op!(memory_order.memory_order_relaxed, "^=")(cast(A*)obj, arg) : + order == memory_order.memory_order_acquire ? + atomic_fetch_op!(memory_order.memory_order_acquire, "^=")(cast(A*)obj, arg) : + order == memory_order.memory_order_release ? + atomic_fetch_op!(memory_order.memory_order_release, "^=")(cast(A*)obj, arg) : + order == memory_order.memory_order_acq_rel ? + atomic_fetch_op!(memory_order.memory_order_acq_rel, "^=")(cast(A*)obj, arg) : + order == memory_order.memory_order_seq_cst ? + atomic_fetch_op!(memory_order.memory_order_seq_cst, "^=")(cast(A*)obj, arg) : + assert(0); } /// @@ -946,19 +930,18 @@ A atomic_fetch_and_explicit_impl(A, M)(shared(A)* obj, M arg, memory_order order { assert(obj !is null); - final switch(order) - { - case memory_order.memory_order_relaxed: - return atomic_fetch_op!(memory_order.memory_order_relaxed, "&=")(cast(A*)obj, arg); - case memory_order.memory_order_acquire: - return atomic_fetch_op!(memory_order.memory_order_acquire, "&=")(cast(A*)obj, arg); - case memory_order.memory_order_release: - return atomic_fetch_op!(memory_order.memory_order_release, "&=")(cast(A*)obj, arg); - case memory_order.memory_order_acq_rel: - return atomic_fetch_op!(memory_order.memory_order_acq_rel, "&=")(cast(A*)obj, arg); - case memory_order.memory_order_seq_cst: - return atomic_fetch_op!(memory_order.memory_order_seq_cst, "&=")(cast(A*)obj, arg); - } + return + order == memory_order.memory_order_relaxed ? + atomic_fetch_op!(memory_order.memory_order_relaxed, "&=")(cast(A*)obj, arg) : + order == memory_order.memory_order_acquire ? + atomic_fetch_op!(memory_order.memory_order_acquire, "&=")(cast(A*)obj, arg) : + order == memory_order.memory_order_release ? + atomic_fetch_op!(memory_order.memory_order_release, "&=")(cast(A*)obj, arg) : + order == memory_order.memory_order_acq_rel ? + atomic_fetch_op!(memory_order.memory_order_acq_rel, "&=")(cast(A*)obj, arg) : + order == memory_order.memory_order_seq_cst ? + atomic_fetch_op!(memory_order.memory_order_seq_cst, "&=")(cast(A*)obj, arg) : + assert(0); } /// @@ -971,11 +954,11 @@ unittest private: -pragma(inline, true) A atomic_fetch_op(memory_order order, string op, A, M)(A* obj, M arg) @trusted { static if (is(A : ulong) && (op == "+=" || op == "-=")) { + pragma(inline, true) // these cannot handle floats static if (op == "+=") { diff --git a/tests/dmd/compilable/pragmainline2.d b/tests/dmd/compilable/pragmainline2.d index adeea3f225..eb19818038 100644 --- a/tests/dmd/compilable/pragmainline2.d +++ b/tests/dmd/compilable/pragmainline2.d @@ -146,3 +146,36 @@ void test_newaa() Iface[int] aa3; int[Iface] aa4; } + +void test_stdatomic() +{ + import core.stdc.stdatomic; + + // check inlining for the unittests of core.stdc.stdatomic + atomic_flag flag; + atomic_flag_test_and_set_explicit_impl(&flag, memory_order.memory_order_seq_cst); + atomic_flag_clear_explicit_impl(&flag, memory_order.memory_order_seq_cst); + + atomic_signal_fence_impl(memory_order.memory_order_seq_cst); + atomic_thread_fence_impl(memory_order.memory_order_seq_cst); + + shared(int) val; + atomic_store_explicit_impl(&val, 3, memory_order.memory_order_seq_cst); + + atomic_load_explicit_impl(&val, memory_order.memory_order_seq_cst); + + atomic_fetch_and_explicit_impl(&val, 3, memory_order.memory_order_seq_cst); + atomic_exchange_explicit_impl(&val, 2, memory_order.memory_order_seq_cst); + + int expected = 2; + atomic_compare_exchange_strong_explicit_impl(&val, &expected, 1, memory_order.memory_order_seq_cst, memory_order.memory_order_seq_cst); + + expected = 1; + atomic_compare_exchange_weak_explicit_impl(&val, &expected, 2, memory_order.memory_order_seq_cst, memory_order.memory_order_seq_cst); + + atomic_fetch_add_explicit_impl(&val, 3, memory_order.memory_order_seq_cst); + atomic_fetch_sub_explicit_impl(&val, 3, memory_order.memory_order_seq_cst); + atomic_fetch_or_explicit_impl(&val, 3, memory_order.memory_order_seq_cst); + atomic_fetch_xor_explicit_impl(&val, 3, memory_order.memory_order_seq_cst); + atomic_fetch_and_explicit_impl(&val, 3, memory_order.memory_order_seq_cst); +} From ee7cd8a3fb80534c2f0c5c23053b9d10a2ded76f Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Tue, 4 Nov 2025 12:09:39 +0100 Subject: [PATCH 067/440] allow dmd test run arguments to be grouped with quotes so they don't generate as many combinations (dlang/dmd!22059) apply to the slower CI builds by combining -O and -release --- tests/dmd/tools/d_do_test.d | 50 ++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/tests/dmd/tools/d_do_test.d b/tests/dmd/tools/d_do_test.d index 3f7e490feb..7d7cb879bd 100755 --- a/tests/dmd/tools/d_do_test.d +++ b/tests/dmd/tools/d_do_test.d @@ -880,11 +880,59 @@ REQUIRED_ARGS(linux32): -fPIC assert(args.requiredArgs == "-os=windows", args.requiredArgs); } +string[] splitQuoted(string text) +{ + import std.utf, std.uni; + enum quote = '\''; + + string[] args; + size_t pos = 0; + while (pos < text.length) + { + size_t startpos = pos; + dchar ch = decode(text, pos); + if (isWhite(ch)) + continue; + + size_t quoted = 0; + size_t endpos = pos; + while (pos < text.length) + { + if (ch == quote) + { + while (pos < text.length) + { + dchar ch2 = decode(text, pos); + if (ch2 == quote) // no escaping + { + quoted++; + break; + } + } + ch = 0; + } + else + { + ch = decode(text, pos); + } + if (isWhite(ch)) + break; + endpos = pos; + } + if (quoted == 1 && text[startpos] == quote && text[endpos-1] == quote) + startpos++, endpos--; + auto arg = text[startpos .. endpos].strip; + if (!arg.empty) + args ~= arg; + } + return args; +} + /// Generates all permutations of the space-separated word contained in `argstr` string[] combinations(string argstr) { string[] results; - string[] args = split(argstr); + string[] args = splitQuoted(argstr); long combinations = 1 << args.length; for (size_t i = 0; i < combinations; i++) { From 0a948d113fe67d758991e7958f36ce09df86eb26 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Fri, 7 Nov 2025 08:43:26 +0800 Subject: [PATCH 068/440] Restrict some imports (dlang/dmd!22063) --- dmd/expression.d | 6 ++++-- dmd/objc.d | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dmd/expression.d b/dmd/expression.d index bcf9221bb3..c4407035de 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -28,7 +28,7 @@ import dmd.dtemplate; import dmd.errors; import dmd.func; import dmd.globals; -import dmd.hdrgen; +import dmd.hdrgen : toChars; import dmd.id; import dmd.identifier; import dmd.init; @@ -463,6 +463,7 @@ extern (C++) abstract class Expression : ASTNode dinteger_t toInteger() { + // import dmd.hdrgen : EXPtoString; //printf("Expression %s\n", EXPtoString(op).ptr); if (!type || !type.isTypeError()) error(loc, "integer constant expression expected instead of `%s`", toChars()); @@ -471,6 +472,7 @@ extern (C++) abstract class Expression : ASTNode uinteger_t toUInteger() { + // import dmd.hdrgen : EXPtoString; //printf("Expression %s\n", EXPtoString(op).ptr); return cast(uinteger_t)toInteger(); } @@ -776,7 +778,7 @@ extern (C++) final class IntegerExp : Expression this.value = normalize(type.toBasetype().ty, value); } - extern (D) static dinteger_t normalize(TY ty, dinteger_t value) + extern (D) private static dinteger_t normalize(TY ty, dinteger_t value) { /* 'Normalize' the value of the integer to be in range of the type */ diff --git a/dmd/objc.d b/dmd/objc.d index 5b7afd5dd5..604487d405 100644 --- a/dmd/objc.d +++ b/dmd/objc.d @@ -17,12 +17,11 @@ import dmd.aggregate; import dmd.arraytypes; import dmd.astenums; import dmd.attrib; -import dmd.attribsem; +import dmd.attribsem : foreachUda; import dmd.cond; import dmd.dclass; import dmd.declaration; import dmd.denum; -import dmd.dmodule; import dmd.dscope; import dmd.dstruct; import dmd.dsymbol; From 3812367a11bc8fef0fc2aa63ee598c8a4701801e Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 7 Nov 2025 04:36:11 +0200 Subject: [PATCH 069/440] Move some free functions to templatesem (dlang/dmd!22064) --- dmd/dtemplate.d | 378 ----------------------------------------- dmd/templateparamsem.d | 1 + dmd/templatesem.d | 376 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 377 insertions(+), 378 deletions(-) diff --git a/dmd/dtemplate.d b/dmd/dtemplate.d index a0b51ca4bb..f68c92811c 100644 --- a/dmd/dtemplate.d +++ b/dmd/dtemplate.d @@ -433,384 +433,6 @@ extern (C++) final class TypeDeduced : Type } } -/* ======================== Type ============================================ */ - -/*********************************************************** - * Check whether the type t representation relies on one or more the template parameters. - * Params: - * t = Tested type, if null, returns false. - * tparams = Template parameters. - * iStart = Start index of tparams to limit the tested parameters. If it's - * nonzero, tparams[0..iStart] will be excluded from the test target. - */ -bool reliesOnTident(Type t, TemplateParameters* tparams, size_t iStart = 0) -{ - return reliesOnTemplateParameters(t, (*tparams)[0 .. tparams.length]); -} - -/*********************************************************** - * Check whether the type t representation relies on one or more the template parameters. - * Params: - * t = Tested type, if null, returns false. - * tparams = Template parameters. - */ -bool reliesOnTemplateParameters(Type t, TemplateParameter[] tparams) -{ - bool visitVector(TypeVector t) - { - return t.basetype.reliesOnTemplateParameters(tparams); - } - - bool visitAArray(TypeAArray t) - { - return t.next.reliesOnTemplateParameters(tparams) || - t.index.reliesOnTemplateParameters(tparams); - } - - bool visitFunction(TypeFunction t) - { - foreach (i, fparam; t.parameterList) - { - if (fparam.type.reliesOnTemplateParameters(tparams)) - return true; - } - return t.next.reliesOnTemplateParameters(tparams); - } - - bool visitIdentifier(TypeIdentifier t) - { - foreach (tp; tparams) - { - if (tp.ident.equals(t.ident)) - return true; - } - return false; - } - - bool visitInstance(TypeInstance t) - { - foreach (tp; tparams) - { - if (t.tempinst.name == tp.ident) - return true; - } - - if (t.tempinst.tiargs) - foreach (arg; *t.tempinst.tiargs) - { - if (Type ta = isType(arg)) - { - if (ta.reliesOnTemplateParameters(tparams)) - return true; - } - } - - return false; - } - - bool visitTypeof(TypeTypeof t) - { - //printf("TypeTypeof.reliesOnTemplateParameters('%s')\n", t.toChars()); - return t.exp.reliesOnTemplateParameters(tparams); - } - - bool visitTuple(TypeTuple t) - { - if (t.arguments) - foreach (arg; *t.arguments) - { - if (arg.type.reliesOnTemplateParameters(tparams)) - return true; - } - - return false; - } - - if (!t) - return false; - - Type tb = t.toBasetype(); - switch (tb.ty) - { - case Tvector: return visitVector(tb.isTypeVector()); - case Taarray: return visitAArray(tb.isTypeAArray()); - case Tfunction: return visitFunction(tb.isTypeFunction()); - case Tident: return visitIdentifier(tb.isTypeIdentifier()); - case Tinstance: return visitInstance(tb.isTypeInstance()); - case Ttypeof: return visitTypeof(tb.isTypeTypeof()); - case Ttuple: return visitTuple(tb.isTypeTuple()); - case Tenum: return false; - default: return tb.nextOf().reliesOnTemplateParameters(tparams); - } -} - -/*********************************************************** - * Check whether the expression representation relies on one or more the template parameters. - * Params: - * e = expression to test - * tparams = Template parameters. - * Returns: - * true if it does - */ -private bool reliesOnTemplateParameters(Expression e, TemplateParameter[] tparams) -{ - extern (C++) final class ReliesOnTemplateParameters : Visitor - { - alias visit = Visitor.visit; - public: - TemplateParameter[] tparams; - bool result; - - extern (D) this(TemplateParameter[] tparams) @safe - { - this.tparams = tparams; - } - - override void visit(Expression e) - { - //printf("Expression.reliesOnTemplateParameters('%s')\n", e.toChars()); - } - - override void visit(IdentifierExp e) - { - //printf("IdentifierExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - foreach (tp; tparams) - { - if (e.ident == tp.ident) - { - result = true; - return; - } - } - } - - override void visit(TupleExp e) - { - //printf("TupleExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - if (e.exps) - { - foreach (ea; *e.exps) - { - ea.accept(this); - if (result) - return; - } - } - } - - override void visit(ArrayLiteralExp e) - { - //printf("ArrayLiteralExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - if (e.elements) - { - foreach (el; *e.elements) - { - el.accept(this); - if (result) - return; - } - } - } - - override void visit(AssocArrayLiteralExp e) - { - //printf("AssocArrayLiteralExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - foreach (ek; *e.keys) - { - ek.accept(this); - if (result) - return; - } - foreach (ev; *e.values) - { - ev.accept(this); - if (result) - return; - } - } - - override void visit(StructLiteralExp e) - { - //printf("StructLiteralExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - if (e.elements) - { - foreach (ea; *e.elements) - { - ea.accept(this); - if (result) - return; - } - } - } - - override void visit(TypeExp e) - { - //printf("TypeExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - result = e.type.reliesOnTemplateParameters(tparams); - } - - override void visit(NewExp e) - { - //printf("NewExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - if (e.placement) - e.placement.accept(this); - if (e.thisexp) - e.thisexp.accept(this); - result = e.newtype.reliesOnTemplateParameters(tparams); - if (!result && e.arguments) - { - foreach (ea; *e.arguments) - { - ea.accept(this); - if (result) - return; - } - } - } - - override void visit(NewAnonClassExp e) - { - //printf("NewAnonClassExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - result = true; - } - - override void visit(FuncExp e) - { - //printf("FuncExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - result = true; - } - - override void visit(TypeidExp e) - { - //printf("TypeidExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - if (auto ea = isExpression(e.obj)) - ea.accept(this); - else if (auto ta = isType(e.obj)) - result = ta.reliesOnTemplateParameters(tparams); - } - - override void visit(TraitsExp e) - { - //printf("TraitsExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - if (e.args) - { - foreach (oa; *e.args) - { - if (auto ea = isExpression(oa)) - ea.accept(this); - else if (auto ta = isType(oa)) - result = ta.reliesOnTemplateParameters(tparams); - if (result) - return; - } - } - } - - override void visit(IsExp e) - { - //printf("IsExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - result = e.targ.reliesOnTemplateParameters(tparams); - } - - override void visit(UnaExp e) - { - //printf("UnaExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - e.e1.accept(this); - } - - override void visit(DotTemplateInstanceExp e) - { - //printf("DotTemplateInstanceExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - visit(e.isUnaExp()); - if (!result && e.ti.tiargs) - { - foreach (oa; *e.ti.tiargs) - { - if (auto ea = isExpression(oa)) - ea.accept(this); - else if (auto ta = isType(oa)) - result = ta.reliesOnTemplateParameters(tparams); - if (result) - return; - } - } - } - - override void visit(CallExp e) - { - //printf("CallExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - visit(e.isUnaExp()); - if (!result && e.arguments) - { - foreach (ea; *e.arguments) - { - ea.accept(this); - if (result) - return; - } - } - } - - override void visit(CastExp e) - { - //printf("CallExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - visit(e.isUnaExp()); - // e.to can be null for cast() with no type - if (!result && e.to) - result = e.to.reliesOnTemplateParameters(tparams); - } - - override void visit(SliceExp e) - { - //printf("SliceExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - visit(e.isUnaExp()); - if (!result && e.lwr) - e.lwr.accept(this); - if (!result && e.upr) - e.upr.accept(this); - } - - override void visit(IntervalExp e) - { - //printf("IntervalExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - e.lwr.accept(this); - if (!result) - e.upr.accept(this); - } - - override void visit(ArrayExp e) - { - //printf("ArrayExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - visit(e.isUnaExp()); - if (!result && e.arguments) - { - foreach (ea; *e.arguments) - ea.accept(this); - } - } - - override void visit(BinExp e) - { - //printf("BinExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - e.e1.accept(this); - if (!result) - e.e2.accept(this); - } - - override void visit(CondExp e) - { - //printf("BinExp.reliesOnTemplateParameters('%s')\n", e.toChars()); - e.econd.accept(this); - if (!result) - visit(e.isBinExp()); - } - } - - scope ReliesOnTemplateParameters v = new ReliesOnTemplateParameters(tparams); - e.accept(v); - return v.result; -} - /*********************************************************** * https://dlang.org/spec/template.html#TemplateParameter */ diff --git a/dmd/templateparamsem.d b/dmd/templateparamsem.d index 561181a2cc..4954b1d2be 100644 --- a/dmd/templateparamsem.d +++ b/dmd/templateparamsem.d @@ -20,6 +20,7 @@ import dmd.globals; import dmd.location; import dmd.expression; import dmd.expressionsem; +import dmd.templatesem; import dmd.rootobject; import dmd.mtype; import dmd.typesem; diff --git a/dmd/templatesem.d b/dmd/templatesem.d index 796f6827a7..ac107b0492 100644 --- a/dmd/templatesem.d +++ b/dmd/templatesem.d @@ -61,6 +61,382 @@ alias funcLeastAsSpecialized = dmd.funcsem.leastAsSpecialized; enum LOG = false; +/*********************************************************** + * Check whether the type t representation relies on one or more the template parameters. + * Params: + * t = Tested type, if null, returns false. + * tparams = Template parameters. + * iStart = Start index of tparams to limit the tested parameters. If it's + * nonzero, tparams[0..iStart] will be excluded from the test target. + */ +bool reliesOnTident(Type t, TemplateParameters* tparams, size_t iStart = 0) +{ + return reliesOnTemplateParameters(t, (*tparams)[0 .. tparams.length]); +} + +/*********************************************************** + * Check whether the type t representation relies on one or more the template parameters. + * Params: + * t = Tested type, if null, returns false. + * tparams = Template parameters. + */ +bool reliesOnTemplateParameters(Type t, TemplateParameter[] tparams) +{ + bool visitVector(TypeVector t) + { + return t.basetype.reliesOnTemplateParameters(tparams); + } + + bool visitAArray(TypeAArray t) + { + return t.next.reliesOnTemplateParameters(tparams) || + t.index.reliesOnTemplateParameters(tparams); + } + + bool visitFunction(TypeFunction t) + { + foreach (i, fparam; t.parameterList) + { + if (fparam.type.reliesOnTemplateParameters(tparams)) + return true; + } + return t.next.reliesOnTemplateParameters(tparams); + } + + bool visitIdentifier(TypeIdentifier t) + { + foreach (tp; tparams) + { + if (tp.ident.equals(t.ident)) + return true; + } + return false; + } + + bool visitInstance(TypeInstance t) + { + foreach (tp; tparams) + { + if (t.tempinst.name == tp.ident) + return true; + } + + if (t.tempinst.tiargs) + foreach (arg; *t.tempinst.tiargs) + { + if (Type ta = isType(arg)) + { + if (ta.reliesOnTemplateParameters(tparams)) + return true; + } + } + + return false; + } + + bool visitTypeof(TypeTypeof t) + { + //printf("TypeTypeof.reliesOnTemplateParameters('%s')\n", t.toChars()); + return t.exp.reliesOnTemplateParameters(tparams); + } + + bool visitTuple(TypeTuple t) + { + if (t.arguments) + foreach (arg; *t.arguments) + { + if (arg.type.reliesOnTemplateParameters(tparams)) + return true; + } + + return false; + } + + if (!t) + return false; + + Type tb = t.toBasetype(); + switch (tb.ty) + { + case Tvector: return visitVector(tb.isTypeVector()); + case Taarray: return visitAArray(tb.isTypeAArray()); + case Tfunction: return visitFunction(tb.isTypeFunction()); + case Tident: return visitIdentifier(tb.isTypeIdentifier()); + case Tinstance: return visitInstance(tb.isTypeInstance()); + case Ttypeof: return visitTypeof(tb.isTypeTypeof()); + case Ttuple: return visitTuple(tb.isTypeTuple()); + case Tenum: return false; + default: return tb.nextOf().reliesOnTemplateParameters(tparams); + } +} + +/*********************************************************** + * Check whether the expression representation relies on one or more the template parameters. + * Params: + * e = expression to test + * tparams = Template parameters. + * Returns: + * true if it does + */ +private bool reliesOnTemplateParameters(Expression e, TemplateParameter[] tparams) +{ + extern (C++) final class ReliesOnTemplateParameters : Visitor + { + alias visit = Visitor.visit; + public: + TemplateParameter[] tparams; + bool result; + + extern (D) this(TemplateParameter[] tparams) @safe + { + this.tparams = tparams; + } + + override void visit(Expression e) + { + //printf("Expression.reliesOnTemplateParameters('%s')\n", e.toChars()); + } + + override void visit(IdentifierExp e) + { + //printf("IdentifierExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + foreach (tp; tparams) + { + if (e.ident == tp.ident) + { + result = true; + return; + } + } + } + + override void visit(TupleExp e) + { + //printf("TupleExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + if (e.exps) + { + foreach (ea; *e.exps) + { + ea.accept(this); + if (result) + return; + } + } + } + + override void visit(ArrayLiteralExp e) + { + //printf("ArrayLiteralExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + if (e.elements) + { + foreach (el; *e.elements) + { + el.accept(this); + if (result) + return; + } + } + } + + override void visit(AssocArrayLiteralExp e) + { + //printf("AssocArrayLiteralExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + foreach (ek; *e.keys) + { + ek.accept(this); + if (result) + return; + } + foreach (ev; *e.values) + { + ev.accept(this); + if (result) + return; + } + } + + override void visit(StructLiteralExp e) + { + //printf("StructLiteralExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + if (e.elements) + { + foreach (ea; *e.elements) + { + ea.accept(this); + if (result) + return; + } + } + } + + override void visit(TypeExp e) + { + //printf("TypeExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + result = e.type.reliesOnTemplateParameters(tparams); + } + + override void visit(NewExp e) + { + //printf("NewExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + if (e.placement) + e.placement.accept(this); + if (e.thisexp) + e.thisexp.accept(this); + result = e.newtype.reliesOnTemplateParameters(tparams); + if (!result && e.arguments) + { + foreach (ea; *e.arguments) + { + ea.accept(this); + if (result) + return; + } + } + } + + override void visit(NewAnonClassExp e) + { + //printf("NewAnonClassExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + result = true; + } + + override void visit(FuncExp e) + { + //printf("FuncExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + result = true; + } + + override void visit(TypeidExp e) + { + //printf("TypeidExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + if (auto ea = isExpression(e.obj)) + ea.accept(this); + else if (auto ta = isType(e.obj)) + result = ta.reliesOnTemplateParameters(tparams); + } + + override void visit(TraitsExp e) + { + //printf("TraitsExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + if (e.args) + { + foreach (oa; *e.args) + { + if (auto ea = isExpression(oa)) + ea.accept(this); + else if (auto ta = isType(oa)) + result = ta.reliesOnTemplateParameters(tparams); + if (result) + return; + } + } + } + + override void visit(IsExp e) + { + //printf("IsExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + result = e.targ.reliesOnTemplateParameters(tparams); + } + + override void visit(UnaExp e) + { + //printf("UnaExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + e.e1.accept(this); + } + + override void visit(DotTemplateInstanceExp e) + { + //printf("DotTemplateInstanceExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + visit(e.isUnaExp()); + if (!result && e.ti.tiargs) + { + foreach (oa; *e.ti.tiargs) + { + if (auto ea = isExpression(oa)) + ea.accept(this); + else if (auto ta = isType(oa)) + result = ta.reliesOnTemplateParameters(tparams); + if (result) + return; + } + } + } + + override void visit(CallExp e) + { + //printf("CallExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + visit(e.isUnaExp()); + if (!result && e.arguments) + { + foreach (ea; *e.arguments) + { + ea.accept(this); + if (result) + return; + } + } + } + + override void visit(CastExp e) + { + //printf("CallExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + visit(e.isUnaExp()); + // e.to can be null for cast() with no type + if (!result && e.to) + result = e.to.reliesOnTemplateParameters(tparams); + } + + override void visit(SliceExp e) + { + //printf("SliceExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + visit(e.isUnaExp()); + if (!result && e.lwr) + e.lwr.accept(this); + if (!result && e.upr) + e.upr.accept(this); + } + + override void visit(IntervalExp e) + { + //printf("IntervalExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + e.lwr.accept(this); + if (!result) + e.upr.accept(this); + } + + override void visit(ArrayExp e) + { + //printf("ArrayExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + visit(e.isUnaExp()); + if (!result && e.arguments) + { + foreach (ea; *e.arguments) + ea.accept(this); + } + } + + override void visit(BinExp e) + { + //printf("BinExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + e.e1.accept(this); + if (!result) + e.e2.accept(this); + } + + override void visit(CondExp e) + { + //printf("BinExp.reliesOnTemplateParameters('%s')\n", e.toChars()); + e.econd.accept(this); + if (!result) + visit(e.isBinExp()); + } + } + + scope ReliesOnTemplateParameters v = new ReliesOnTemplateParameters(tparams); + e.accept(v); + return v.result; +} + void computeOneMember(TemplateDeclaration td) { if (td is null || td.haveComputedOneMember) From 0256379281e7e156701a61cf289db4c0c4cce609 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 7 Nov 2025 04:36:51 +0200 Subject: [PATCH 070/440] Move StaticForEach.ready to statementsem (dlang/dmd!22065) --- dmd/cond.d | 9 --------- dmd/dsymbolsem.d | 1 + dmd/expressionsem.d | 3 ++- dmd/statementsem.d | 9 +++++++++ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/dmd/cond.d b/dmd/cond.d index 8e0ef757b7..a813900016 100644 --- a/dmd/cond.d +++ b/dmd/cond.d @@ -229,15 +229,6 @@ extern (C++) final class StaticForeach : RootObject { // TODO: move to druntime? return new CallExp(loc, new TypeExp(loc, type), e); } - - /***************************************** - * Returns: - * `true` iff ready to call `dmd.statementsem.makeTupleForeach`. - */ - extern(D) bool ready() - { - return aggrfe && aggrfe.aggr && aggrfe.aggr.type && aggrfe.aggr.type.toBasetype().ty == Ttuple; - } } /*********************************************************** diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 30e8f655ec..5876705d1c 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -74,6 +74,7 @@ import dmd.sideeffect; import dmd.staticassert; import dmd.tokens; import dmd.statement; +import dmd.statementsem : ready; import dmd.target; import dmd.targetcompiler; import dmd.templatesem; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index f3129ae13a..491395d8f0 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -18835,8 +18835,9 @@ void lowerNonArrayAggregate(StaticForeach sfe, Scope* sc) */ extern(D) void prepare(StaticForeach sfe, Scope* sc) { - assert(sc); + import dmd.statementsem : ready; + assert(sc); if (sfe.aggrfe) { sc = sc.startCTFE(); diff --git a/dmd/statementsem.d b/dmd/statementsem.d index 26a637220f..bd19ccc6f8 100644 --- a/dmd/statementsem.d +++ b/dmd/statementsem.d @@ -72,6 +72,15 @@ version (DMDLIB) version = CallbackAPI; } +/***************************************** + * Returns: + * `true` iff ready to call `dmd.statementsem.makeTupleForeach`. + */ +bool ready(StaticForeach _this) +{ + return _this.aggrfe && _this.aggrfe.aggr && _this.aggrfe.aggr.type && _this.aggrfe.aggr.type.toBasetype().ty == Ttuple; +} + /***************************************** * CTFE requires FuncDeclaration::labtab for the interpretation. * So fixing the label name inside in/out contracts is necessary From 2f72760b00d0d1750a34a45ba12cf79ef7b9de3e Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 7 Nov 2025 04:37:45 +0200 Subject: [PATCH 071/440] Move `expandTuples`, `expToVariable`, and `calledFunctionType` free functions in `expression` to `expressionsem` (dlang/dmd!22066) --- dmd/canthrow.d | 2 +- dmd/cxxfrontend.d | 10 +-- dmd/escape.d | 1 + dmd/expression.d | 186 -------------------------------------------- dmd/expressionsem.d | 186 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 193 insertions(+), 192 deletions(-) diff --git a/dmd/canthrow.d b/dmd/canthrow.d index 34dacf0747..5828f0ac44 100644 --- a/dmd/canthrow.d +++ b/dmd/canthrow.d @@ -20,7 +20,7 @@ import dmd.dsymbol; import dmd.dsymbolsem : include, toAlias; import dmd.errorsink; import dmd.expression; -import dmd.expressionsem : errorSupplementalInferredAttr, isLvalue; +import dmd.expressionsem : errorSupplementalInferredAttr, isLvalue, calledFunctionType; import dmd.func; import dmd.globals; import dmd.mtype; diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index a4273c3a0c..9f096fde07 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -370,17 +370,17 @@ Expression getDefaultValue(EnumDeclaration ed, Loc loc) return dmd.enumsem.getDefaultValue(ed, loc); } + /*********************************************************** - * expression.d + * expressionsem.d */ + void expandTuples(Expressions* exps, ArgumentLabels* names = null) { - return dmd.expression.expandTuples(exps, names); + import dmd.expressionsem; + return dmd.expressionsem.expandTuples(exps, names); } -/*********************************************************** - * expressionsem.d - */ Expression expressionSemantic(Expression e, Scope* sc) { import dmd.expressionsem; diff --git a/dmd/escape.d b/dmd/escape.d index d3473f691d..392e927501 100644 --- a/dmd/escape.d +++ b/dmd/escape.d @@ -24,6 +24,7 @@ import dmd.dscope; import dmd.dsymbol; import dmd.errors; import dmd.expression; +import dmd.expressionsem : calledFunctionType, expToVariable; import dmd.func; import dmd.funcsem; import dmd.globals : FeatureState; diff --git a/dmd/expression.d b/dmd/expression.d index c4407035de..3723f13994 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -63,103 +63,6 @@ inout(Expression) lastComma(inout Expression e) } -/**************************************** - * Expand tuples in-place. - * - * Example: - * When there's a call `f(10, pair: AliasSeq!(20, 30), single: 40)`, the input is: - * `exps = [10, (20, 30), 40]` - * `names = [null, "pair", "single"]` - * The arrays will be modified to: - * `exps = [10, 20, 30, 40]` - * `names = [null, "pair", null, "single"]` - * - * Params: - * exps = array of Expressions - * names = optional array of names corresponding to Expressions - */ -void expandTuples(Expressions* exps, ArgumentLabels* names = null) -{ - //printf("expandTuples()\n"); - if (exps is null) - return; - - if (names) - { - if (exps.length != names.length) - { - printf("exps.length = %d, names.length = %d\n", cast(int) exps.length, cast(int) names.length); - printf("exps = %s, names = %s\n", exps.toChars(), names.toChars()); - if (exps.length > 0) - printf("%s\n", (*exps)[0].loc.toChars()); - assert(0); - } - } - - // At `index`, a tuple of length `length` is expanded. Insert corresponding nulls in `names`. - void expandNames(size_t index, size_t length) - { - if (names) - { - if (length == 0) - { - names.remove(index); - return; - } - foreach (i; 1 .. length) - { - names.insert(index + i, ArgumentLabel(cast(Identifier) null, Loc.init)); - } - } - } - - for (size_t i = 0; i < exps.length; i++) - { - Expression arg = (*exps)[i]; - if (!arg) - continue; - - // Look for tuple with 0 members - if (auto e = arg.isTypeExp()) - { - if (auto tt = e.type.toBasetype().isTypeTuple()) - { - if (!tt.arguments || tt.arguments.length == 0) - { - exps.remove(i); - expandNames(i, 0); - if (i == exps.length) - return; - } - else // Expand a TypeTuple - { - exps.remove(i); - auto texps = new Expressions(tt.arguments.length); - foreach (j, a; *tt.arguments) - (*texps)[j] = new TypeExp(e.loc, a.type); - exps.insert(i, texps); - expandNames(i, texps.length); - } - i--; - continue; - } - } - - // Inline expand all the tuples - while (arg.op == EXP.tuple) - { - TupleExp te = cast(TupleExp)arg; - exps.remove(i); // remove arg - exps.insert(i, te.exps); // replace with tuple contents - expandNames(i, te.exps.length); - if (i == exps.length) - return; // empty tuple, no more arguments - (*exps)[i] = Expression.combine(te.e0, (*exps)[i]); - arg = (*exps)[i]; - } - } -} - /**************************************** * If `s` is a function template, i.e. the only member of a template * and that member is a function, return that template. @@ -200,76 +103,6 @@ DotIdExp typeDotIdExp(Loc loc, Type type, Identifier ident) @safe return new DotIdExp(loc, new TypeExp(loc, type), ident); } -/*************************************************** - * Given an Expression, find the variable it really is. - * - * For example, `a[index]` is really `a`, and `s.f` is really `s`. - * Params: - * e = Expression to look at - * deref = number of dereferences encountered - * Returns: - * variable if there is one, null if not - */ -VarDeclaration expToVariable(Expression e, out int deref) -{ - deref = 0; - while (1) - { - switch (e.op) - { - case EXP.variable: - return e.isVarExp().var.isVarDeclaration(); - - case EXP.dotVariable: - e = e.isDotVarExp().e1; - if (e.type.toBasetype().isTypeClass()) - deref++; - - continue; - - case EXP.index: - { - e = e.isIndexExp().e1; - if (!e.type.toBasetype().isTypeSArray()) - deref++; - - continue; - } - - case EXP.slice: - { - e = e.isSliceExp().e1; - if (!e.type.toBasetype().isTypeSArray()) - deref++; - - continue; - } - - case EXP.super_: - return e.isSuperExp().var.isVarDeclaration(); - case EXP.this_: - return e.isThisExp().var.isVarDeclaration(); - - // Temporaries for rvalues that need destruction - // are of form: (T s = rvalue, s). For these cases - // we can just return var declaration of `s`. However, - // this is intentionally not calling `Expression.extractLast` - // because at this point we cannot infer the var declaration - // of more complex generated comma expressions such as the - // one for the array append hook. - case EXP.comma: - { - if (auto ve = e.isCommaExp().e2.isVarExp()) - return ve.var.isVarDeclaration(); - - return null; - } - default: - return null; - } - } -} - enum OwnedBy : ubyte { code, // normal code expression in AST @@ -2811,25 +2644,6 @@ extern (C++) final class CallExp : UnaExp } } -/** - * Get the called function type from a call expression - * Params: - * ce = function call expression. Must have had semantic analysis done. - * Returns: called function type, or `null` if error / no semantic analysis done - */ -TypeFunction calledFunctionType(CallExp ce) -{ - Type t = ce.e1.type; - if (!t) - return null; - t = t.toBasetype(); - if (auto tf = t.isTypeFunction()) - return tf; - if (auto td = t.isTypeDelegate()) - return td.nextOf().isTypeFunction(); - return null; -} - FuncDeclaration isFuncAddress(Expression e, bool* hasOverloads = null) @safe { if (auto ae = e.isAddrExp()) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 491395d8f0..46a024e611 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -100,6 +100,192 @@ import dmd.visitor.postorder; enum LOGSEMANTIC = false; +/*************************************************** + * Given an Expression, find the variable it really is. + * + * For example, `a[index]` is really `a`, and `s.f` is really `s`. + * Params: + * e = Expression to look at + * deref = number of dereferences encountered + * Returns: + * variable if there is one, null if not + */ +VarDeclaration expToVariable(Expression e, out int deref) +{ + deref = 0; + while (1) + { + switch (e.op) + { + case EXP.variable: + return e.isVarExp().var.isVarDeclaration(); + + case EXP.dotVariable: + e = e.isDotVarExp().e1; + if (e.type.toBasetype().isTypeClass()) + deref++; + + continue; + + case EXP.index: + { + e = e.isIndexExp().e1; + if (!e.type.toBasetype().isTypeSArray()) + deref++; + + continue; + } + + case EXP.slice: + { + e = e.isSliceExp().e1; + if (!e.type.toBasetype().isTypeSArray()) + deref++; + + continue; + } + + case EXP.super_: + return e.isSuperExp().var.isVarDeclaration(); + case EXP.this_: + return e.isThisExp().var.isVarDeclaration(); + + // Temporaries for rvalues that need destruction + // are of form: (T s = rvalue, s). For these cases + // we can just return var declaration of `s`. However, + // this is intentionally not calling `Expression.extractLast` + // because at this point we cannot infer the var declaration + // of more complex generated comma expressions such as the + // one for the array append hook. + case EXP.comma: + { + if (auto ve = e.isCommaExp().e2.isVarExp()) + return ve.var.isVarDeclaration(); + + return null; + } + default: + return null; + } + } +} + +/** + * Get the called function type from a call expression + * Params: + * ce = function call expression. Must have had semantic analysis done. + * Returns: called function type, or `null` if error / no semantic analysis done + */ +TypeFunction calledFunctionType(CallExp ce) +{ + Type t = ce.e1.type; + if (!t) + return null; + t = t.toBasetype(); + if (auto tf = t.isTypeFunction()) + return tf; + if (auto td = t.isTypeDelegate()) + return td.nextOf().isTypeFunction(); + return null; +} + +/**************************************** + * Expand tuples in-place. + * + * Example: + * When there's a call `f(10, pair: AliasSeq!(20, 30), single: 40)`, the input is: + * `exps = [10, (20, 30), 40]` + * `names = [null, "pair", "single"]` + * The arrays will be modified to: + * `exps = [10, 20, 30, 40]` + * `names = [null, "pair", null, "single"]` + * + * Params: + * exps = array of Expressions + * names = optional array of names corresponding to Expressions + */ +void expandTuples(Expressions* exps, ArgumentLabels* names = null) +{ + //printf("expandTuples()\n"); + if (exps is null) + return; + + if (names) + { + if (exps.length != names.length) + { + printf("exps.length = %d, names.length = %d\n", cast(int) exps.length, cast(int) names.length); + printf("exps = %s, names = %s\n", exps.toChars(), names.toChars()); + if (exps.length > 0) + printf("%s\n", (*exps)[0].loc.toChars()); + assert(0); + } + } + + // At `index`, a tuple of length `length` is expanded. Insert corresponding nulls in `names`. + void expandNames(size_t index, size_t length) + { + if (names) + { + if (length == 0) + { + names.remove(index); + return; + } + foreach (i; 1 .. length) + { + names.insert(index + i, ArgumentLabel(cast(Identifier) null, Loc.init)); + } + } + } + + for (size_t i = 0; i < exps.length; i++) + { + Expression arg = (*exps)[i]; + if (!arg) + continue; + + // Look for tuple with 0 members + if (auto e = arg.isTypeExp()) + { + if (auto tt = e.type.toBasetype().isTypeTuple()) + { + if (!tt.arguments || tt.arguments.length == 0) + { + exps.remove(i); + expandNames(i, 0); + if (i == exps.length) + return; + } + else // Expand a TypeTuple + { + exps.remove(i); + auto texps = new Expressions(tt.arguments.length); + foreach (j, a; *tt.arguments) + (*texps)[j] = new TypeExp(e.loc, a.type); + exps.insert(i, texps); + expandNames(i, texps.length); + } + i--; + continue; + } + } + + // Inline expand all the tuples + while (arg.op == EXP.tuple) + { + TupleExp te = cast(TupleExp)arg; + exps.remove(i); // remove arg + exps.insert(i, te.exps); // replace with tuple contents + expandNames(i, te.exps.length); + if (i == exps.length) + return; // empty tuple, no more arguments + (*exps)[i] = Expression.combine(te.e0, (*exps)[i]); + arg = (*exps)[i]; + } + } +} + StringExp toStringExp(Expression _this) { static StringExp nullExpToStringExp(NullExp _this) From a6102872c85ac035aeb08c1c6b9a5b19ff59d59c Mon Sep 17 00:00:00 2001 From: Steven Schveighoffer Date: Thu, 6 Nov 2025 23:26:01 -0500 Subject: [PATCH 072/440] fix(GC): Fix issue with GC thread cleanup routine being called after thread is unregistered (and therefore will not be paused). --- runtime/druntime/src/core/gc/gcinterface.d | 10 ++++------ runtime/druntime/src/core/thread/osthread.d | 8 ++++++++ runtime/druntime/src/core/thread/threadbase.d | 4 ---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/runtime/druntime/src/core/gc/gcinterface.d b/runtime/druntime/src/core/gc/gcinterface.d index 6cab62ef99..37f0832bf5 100644 --- a/runtime/druntime/src/core/gc/gcinterface.d +++ b/runtime/druntime/src/core/gc/gcinterface.d @@ -292,12 +292,10 @@ interface GC * (from the registry hook) should assume this function may not be called * on termination if the GC is never initialized. * - * Most times, this is called from the thread that is the given thread - * reference, but it's possible the `thread` parameter is not the same as - * the current thread. - * - * There is no guarantee the thread is still registered as - * `ThreadBase.getThis()`. + * This function is only called from a thread that was started from the D + * runtime, and is terminating. The GC can assume the thread is still in + * the list of running threads and can be paused for a GC cycle. This is + * not called for the main thread which initialized the GC. */ void cleanupThread(ThreadBase thread) nothrow @nogc; } diff --git a/runtime/druntime/src/core/thread/osthread.d b/runtime/druntime/src/core/thread/osthread.d index c72bbd8392..8c29018da3 100644 --- a/runtime/druntime/src/core/thread/osthread.d +++ b/runtime/druntime/src/core/thread/osthread.d @@ -2351,6 +2351,10 @@ version (Windows) scope (exit) { + // allow the GC to clean up any resources it allocated for this thread. + import core.internal.gc.proxy : gc_getProxy; + gc_getProxy().cleanupThread(obj); + Thread.remove(obj); obj.destroyDataStorage(); } @@ -2482,6 +2486,10 @@ else version (Posix) scope (exit) { + // allow the GC to clean up any resources it allocated for this thread. + import core.internal.gc.proxy : gc_getProxy; + gc_getProxy().cleanupThread(obj); + Thread.remove(obj); atomicStore!(MemoryOrder.raw)(obj.m_isRunning, false); obj.destroyDataStorage(); diff --git a/runtime/druntime/src/core/thread/threadbase.d b/runtime/druntime/src/core/thread/threadbase.d index 903c2bffc9..6281be59fb 100644 --- a/runtime/druntime/src/core/thread/threadbase.d +++ b/runtime/druntime/src/core/thread/threadbase.d @@ -150,10 +150,6 @@ class ThreadBase package void destroyDataStorage() nothrow @nogc { - // allow the GC to clean up any resources it allocated for this thread. - import core.internal.gc.proxy : gc_getProxy; - gc_getProxy().cleanupThread(this); - rt_tlsgc_destroy(m_tlsrtdata); m_tlsrtdata = null; } From 07e5a7932e1c4fcdc9ffa8554873912015172659 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sun, 9 Nov 2025 11:03:28 +0200 Subject: [PATCH 073/440] Replace toInteger with value (dlang/dmd!22068) --- dmd/hdrgen.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dmd/hdrgen.d b/dmd/hdrgen.d index e8fe59b2f6..78ce16c4f4 100644 --- a/dmd/hdrgen.d +++ b/dmd/hdrgen.d @@ -2207,7 +2207,7 @@ private void expressionPrettyPrint(Expression e, ref OutBuffer buf, ref HdrGenSt void visitInteger(IntegerExp e) { - const ulong v = e.toInteger(); + const ulong v = e.value; if (e.type) { Type t = e.type; @@ -2222,7 +2222,7 @@ private void expressionPrettyPrint(Expression e, ref OutBuffer buf, ref HdrGenSt { foreach (em; *sym.members) { - if ((cast(EnumMember)em).value.toInteger == v) + if ((cast(EnumMember)em).value.isIntegerExp().value == v) { const id = em.ident.toString(); buf.printf("%s.%.*s", sym.toChars(), cast(int)id.length, id.ptr); @@ -3813,7 +3813,7 @@ private void sizeToBuffer(Expression e, ref OutBuffer buf, ref HdrGenState hgs) { Expression ex = (e.op == EXP.cast_ ? (cast(CastExp)e).e1 : e); ex = ex.optimize(WANTvalue); - const ulong uval = ex.op == EXP.int64 ? ex.toInteger() : cast(ulong)-1; + const ulong uval = ex.op == EXP.int64 ? ex.isIntegerExp().value : cast(ulong)-1; if (cast(long)uval >= 0) { if (uval <= 0xFFFFU) From cf3ac04fd6d4570302afc6353ee35b437a4de732 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sun, 9 Nov 2025 11:04:36 +0200 Subject: [PATCH 074/440] Move `Expression.toInteger` and `Expression.toUInteger` to `expressionsem` (dlang/dmd!22073) --- dmd/argtypes_aarch64.d | 1 + dmd/argtypes_sysv_x64.d | 1 + dmd/argtypes_x86.d | 1 + dmd/builtin.d | 1 + dmd/compiler.d | 1 + dmd/constfold.d | 2 +- dmd/ctfeexpr.d | 2 +- dmd/cxxfrontend.d | 12 +++++++++++ dmd/dtoh.d | 1 + dmd/expression.d | 44 +---------------------------------------- dmd/expression.h | 9 ++------- dmd/expressionsem.d | 40 +++++++++++++++++++++++++++++++++++++ dmd/frontend.h | 13 ++---------- dmd/lambdacomp.d | 2 +- dmd/mangle/cpp.d | 2 +- dmd/mangle/cppwin.d | 2 +- dmd/mangle/package.d | 1 + dmd/printast.d | 1 + 18 files changed, 70 insertions(+), 66 deletions(-) diff --git a/dmd/argtypes_aarch64.d b/dmd/argtypes_aarch64.d index f936fec95a..dd502bd22f 100644 --- a/dmd/argtypes_aarch64.d +++ b/dmd/argtypes_aarch64.d @@ -15,6 +15,7 @@ import dmd.astenums; import dmd.dsymbolsem : isPOD; import dmd.mtype; import dmd.typesem; +import dmd.expressionsem : toUInteger; /**************************************************** * This breaks a type down into 'simpler' types that can be passed to a function diff --git a/dmd/argtypes_sysv_x64.d b/dmd/argtypes_sysv_x64.d index 0be02ff2b4..40cfca3ad9 100644 --- a/dmd/argtypes_sysv_x64.d +++ b/dmd/argtypes_sysv_x64.d @@ -16,6 +16,7 @@ import dmd.declaration; import dmd.dsymbolsem : isPOD; import dmd.mtype; import dmd.typesem; +import dmd.expressionsem : toInteger; import dmd.target; import dmd.visitor; diff --git a/dmd/argtypes_x86.d b/dmd/argtypes_x86.d index b77683b313..89591e5645 100644 --- a/dmd/argtypes_x86.d +++ b/dmd/argtypes_x86.d @@ -17,6 +17,7 @@ import core.checkedint; import dmd.astenums; import dmd.declaration; import dmd.dsymbolsem : isPOD; +import dmd.expressionsem : toInteger; import dmd.location; import dmd.mtype; import dmd.typesem; diff --git a/dmd/builtin.d b/dmd/builtin.d index b3eb7a7bb5..6f012abee9 100644 --- a/dmd/builtin.d +++ b/dmd/builtin.d @@ -17,6 +17,7 @@ import dmd.arraytypes; import dmd.astenums; import dmd.errors; import dmd.expression; +import dmd.expressionsem : toInteger; import dmd.func; import dmd.location; import dmd.mangle; diff --git a/dmd/compiler.d b/dmd/compiler.d index 1f043352c4..aaa3a74728 100644 --- a/dmd/compiler.d +++ b/dmd/compiler.d @@ -19,6 +19,7 @@ import dmd.ctfeexpr; import dmd.dmodule; import dmd.errors; import dmd.expression; +import dmd.expressionsem : toInteger; import dmd.globals; import dmd.id; import dmd.identifier; diff --git a/dmd/constfold.d b/dmd/constfold.d index fa25099ebb..943c9d7adb 100644 --- a/dmd/constfold.d +++ b/dmd/constfold.d @@ -25,7 +25,7 @@ import dmd.declaration; import dmd.dstruct; import dmd.errors; import dmd.expression; -import dmd.expressionsem : getField, isIdentical, toBool; +import dmd.expressionsem : getField, isIdentical, toBool, toInteger, toUInteger; import dmd.globals; import dmd.location; import dmd.mtype; diff --git a/dmd/ctfeexpr.d b/dmd/ctfeexpr.d index b093bfa797..74d4c1259b 100644 --- a/dmd/ctfeexpr.d +++ b/dmd/ctfeexpr.d @@ -25,7 +25,7 @@ import dmd.dstruct; import dmd.dtemplate; import dmd.errors; import dmd.expression; -import dmd.expressionsem : isIdentical, getFieldIndex, toBool, toStringExp; +import dmd.expressionsem : isIdentical, getFieldIndex, toBool, toStringExp, toInteger; import dmd.func; import dmd.globals : dinteger_t, sinteger_t, uinteger_t; import dmd.location; diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 9f096fde07..0e01b9d642 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -436,6 +436,18 @@ StringExp toStringExp(Expression exp) return dmd.expressionsem.toStringExp(exp); } +dinteger_t toInteger(Expression exp) +{ + import dmd.expressionsem; + return dmd.expressionsem.toInteger(exp); +} + +uinteger_t toUInteger(Expression exp) +{ + import dmd.expressionsem; + return dmd.expressionsem.toUInteger(exp); +} + /*********************************************************** * func.d */ diff --git a/dmd/dtoh.d b/dmd/dtoh.d index e2bbbc499b..839127ca42 100644 --- a/dmd/dtoh.d +++ b/dmd/dtoh.d @@ -20,6 +20,7 @@ import dmd.astenums; import dmd.arraytypes; import dmd.dsymbolsem; import dmd.templatesem : computeOneMember; +import dmd.expressionsem : toInteger; import dmd.errors; import dmd.errorsink; import dmd.globals; diff --git a/dmd/expression.d b/dmd/expression.d index 3723f13994..46262b8d42 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -294,22 +294,6 @@ extern (C++) abstract class Expression : ASTNode return a; } - dinteger_t toInteger() - { - // import dmd.hdrgen : EXPtoString; - //printf("Expression %s\n", EXPtoString(op).ptr); - if (!type || !type.isTypeError()) - error(loc, "integer constant expression expected instead of `%s`", toChars()); - return 0; - } - - uinteger_t toUInteger() - { - // import dmd.hdrgen : EXPtoString; - //printf("Expression %s\n", EXPtoString(op).ptr); - return cast(uinteger_t)toInteger(); - } - real_t toReal() { error(loc, "floating point constant expression expected instead of `%s`", toChars()); @@ -569,12 +553,6 @@ extern (C++) final class IntegerExp : Expression return new IntegerExp(loc, value, type); } - override dinteger_t toInteger() - { - // normalize() is necessary until we fix all the paints of 'type' - return value = normalize(type.toBasetype().ty, value); - } - override real_t toReal() { // normalize() is necessary until we fix all the paints of 'type' @@ -611,7 +589,7 @@ extern (C++) final class IntegerExp : Expression this.value = normalize(type.toBasetype().ty, value); } - extern (D) private static dinteger_t normalize(TY ty, dinteger_t value) + extern (D) static dinteger_t normalize(TY ty, dinteger_t value) { /* 'Normalize' the value of the integer to be in range of the type */ @@ -798,16 +776,6 @@ extern (C++) final class RealExp : Expression return new RealExp(loc, value, type); } - override dinteger_t toInteger() - { - return cast(sinteger_t)toReal(); - } - - override uinteger_t toUInteger() - { - return cast(uinteger_t)toReal(); - } - override real_t toReal() { return type.isReal() ? value : CTFloat.zero; @@ -849,16 +817,6 @@ extern (C++) final class ComplexExp : Expression return new ComplexExp(loc, value, type); } - override dinteger_t toInteger() - { - return cast(sinteger_t)toReal(); - } - - override uinteger_t toUInteger() - { - return cast(uinteger_t)toReal(); - } - override real_t toReal() { return creall(value); diff --git a/dmd/expression.h b/dmd/expression.h index 39c22cc37d..c31db3ac63 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -66,6 +66,8 @@ namespace dmd void fillTupleExpExps(TupleExp *te, TupleDeclaration *tup); Optional toBool(Expression *exp); StringExp *toStringExp(Expression *exp); + dinteger_t toInteger(Expression *exp); + uinteger_t toUInteger(Expression *exp); } typedef unsigned char OwnedBy; @@ -101,8 +103,6 @@ class Expression : public ASTNode const char* toChars() const final override; - virtual dinteger_t toInteger(); - virtual uinteger_t toUInteger(); virtual real_t toReal(); virtual real_t toImaginary(); virtual complex_t toComplex(); @@ -238,7 +238,6 @@ class IntegerExp final : public Expression dinteger_t value; static IntegerExp *create(Loc loc, dinteger_t value, Type *type); - dinteger_t toInteger() override; real_t toReal() override; real_t toImaginary() override; complex_t toComplex() override; @@ -262,8 +261,6 @@ class RealExp final : public Expression real_t value; static RealExp *create(Loc loc, real_t value, Type *type); - dinteger_t toInteger() override; - uinteger_t toUInteger() override; real_t toReal() override; real_t toImaginary() override; complex_t toComplex() override; @@ -276,8 +273,6 @@ class ComplexExp final : public Expression complex_t value; static ComplexExp *create(Loc loc, complex_t value, Type *type); - dinteger_t toInteger() override; - uinteger_t toUInteger() override; real_t toReal() override; real_t toImaginary() override; complex_t toComplex() override; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 46a024e611..846a2b80a9 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -100,6 +100,46 @@ import dmd.visitor.postorder; enum LOGSEMANTIC = false; +dinteger_t toInteger(Expression _this) +{ + if (auto iexp = _this.isIntegerExp()) + { + // normalize() is necessary until we fix all the paints of 'type' + return iexp.value = IntegerExp.normalize(iexp.type.toBasetype().ty, iexp.value); + } + else if (auto rexp = _this.isRealExp()) + { + return cast(sinteger_t)rexp.toReal(); + } + + else if (auto cexp = _this.isComplexExp()) + { + return cast(sinteger_t)cexp.toReal(); + } + + // import dmd.hdrgen : EXPtoString; + //printf("Expression %s\n", EXPtoString(op).ptr); + if (!_this.type || !_this.type.isTypeError()) + error(_this.loc, "integer constant expression expected instead of `%s`", _this.toChars()); + return 0; +} + +uinteger_t toUInteger(Expression _this) +{ + if (auto rexp = _this.isRealExp()) + { + return cast(uinteger_t)rexp.toReal(); + } + else if (auto cexp = _this.isComplexExp()) + { + return cast(uinteger_t)cexp.toReal(); + } + // import dmd.hdrgen : EXPtoString; + //printf("Expression %s\n", EXPtoString(op).ptr); + return cast(uinteger_t)_this.toInteger(); +} + + /*************************************************** * Given an Expression, find the variable it really is. * diff --git a/dmd/frontend.h b/dmd/frontend.h index a8046aec02..4748d6d272 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2298,10 +2298,6 @@ enum class EXP : uint8_t rvalue = 128u, }; -typedef uint64_t dinteger_t; - -typedef uint64_t uinteger_t; - struct complex_t final { _d_real re; @@ -2351,8 +2347,6 @@ class Expression : public ASTNode virtual Expression* syntaxCopy(); DYNCAST dyncast() const final override; const char* toChars() const final override; - virtual dinteger_t toInteger(); - virtual uinteger_t toUInteger(); virtual _d_real toReal(); virtual _d_real toImaginary(); virtual complex_t toComplex(); @@ -2725,8 +2719,6 @@ class ComplexExp final : public Expression public: complex_t value; static ComplexExp* create(Loc loc, complex_t value, Type* type); - dinteger_t toInteger() override; - uinteger_t toUInteger() override; _d_real toReal() override; _d_real toImaginary() override; complex_t toComplex() override; @@ -3195,12 +3187,13 @@ class IndexExp final : public BinExp void accept(Visitor* v) override; }; +typedef uint64_t dinteger_t; + class IntegerExp final : public Expression { public: dinteger_t value; static IntegerExp* create(Loc loc, dinteger_t value, Type* type); - dinteger_t toInteger() override; _d_real toReal() override; _d_real toImaginary() override; complex_t toComplex() override; @@ -3429,8 +3422,6 @@ class RealExp final : public Expression public: _d_real value; static RealExp* create(Loc loc, _d_real value, Type* type); - dinteger_t toInteger() override; - uinteger_t toUInteger() override; _d_real toReal() override; _d_real toImaginary() override; complex_t toComplex() override; diff --git a/dmd/lambdacomp.d b/dmd/lambdacomp.d index 2b8a8ed498..445ddd69d7 100644 --- a/dmd/lambdacomp.d +++ b/dmd/lambdacomp.d @@ -25,7 +25,7 @@ import dmd.dsymbol; import dmd.dsymbolsem; import dmd.dtemplate; import dmd.expression; -import dmd.expressionsem : getConstInitializer; +import dmd.expressionsem : getConstInitializer, toInteger; import dmd.func; import dmd.hdrgen; import dmd.mangle; diff --git a/dmd/mangle/cpp.d b/dmd/mangle/cpp.d index 1ae36722b7..ae0e60bd24 100644 --- a/dmd/mangle/cpp.d +++ b/dmd/mangle/cpp.d @@ -27,7 +27,7 @@ import dmd.attrib; import dmd.declaration; import dmd.dsymbol; import dmd.dsymbolsem : isGNUABITag, toAlias, equals; -import dmd.expressionsem : toStringExp; +import dmd.expressionsem : toStringExp, toInteger, toUInteger; import dmd.templatesem : computeOneMember; import dmd.dtemplate; import dmd.errors; diff --git a/dmd/mangle/cppwin.d b/dmd/mangle/cppwin.d index 283d4475d7..a0bd4cc670 100644 --- a/dmd/mangle/cppwin.d +++ b/dmd/mangle/cppwin.d @@ -21,7 +21,7 @@ import dmd.denum : isSpecialEnumIdent; import dmd.dstruct; import dmd.dsymbol; import dmd.dsymbolsem : toAlias; -import dmd.expressionsem : toStringExp; +import dmd.expressionsem : toStringExp, toInteger, toUInteger; import dmd.templatesem : computeOneMember; import dmd.dtemplate; import dmd.errors; diff --git a/dmd/mangle/package.d b/dmd/mangle/package.d index a6a80b7be7..07bf52ec8f 100644 --- a/dmd/mangle/package.d +++ b/dmd/mangle/package.d @@ -146,6 +146,7 @@ import dmd.dinterpret; import dmd.dmodule; import dmd.dsymbol; import dmd.dsymbolsem : toAlias; +import dmd.expressionsem : toInteger; import dmd.dtemplate; import dmd.errors; import dmd.expression; diff --git a/dmd/printast.d b/dmd/printast.d index 5e4c9f787f..80995d4103 100644 --- a/dmd/printast.d +++ b/dmd/printast.d @@ -14,6 +14,7 @@ module dmd.printast; import core.stdc.stdio; import dmd.expression; +import dmd.expressionsem : toInteger; import dmd.ctfeexpr; import dmd.tokens; import dmd.visitor; From a3ad2f9915e522b848144f465d59eed0448716ba Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Mon, 10 Nov 2025 06:17:36 +0200 Subject: [PATCH 075/440] Move `Expression.toReal` and `Expression.toComplex` to `expressionsem` (dlang/dmd!22076) --- dmd/builtin.d | 2 +- dmd/compiler.d | 2 +- dmd/constfold.d | 2 +- dmd/ctfeexpr.d | 2 +- dmd/cxxfrontend.d | 14 +++++++++++++ dmd/expression.d | 48 -------------------------------------------- dmd/expression.h | 10 ++------- dmd/expressionsem.d | 42 ++++++++++++++++++++++++++++++++++++++ dmd/frontend.h | 28 +++++++++----------------- dmd/mangle/package.d | 2 +- 10 files changed, 73 insertions(+), 79 deletions(-) diff --git a/dmd/builtin.d b/dmd/builtin.d index 6f012abee9..5581b0dda3 100644 --- a/dmd/builtin.d +++ b/dmd/builtin.d @@ -17,7 +17,7 @@ import dmd.arraytypes; import dmd.astenums; import dmd.errors; import dmd.expression; -import dmd.expressionsem : toInteger; +import dmd.expressionsem : toInteger, toReal; import dmd.func; import dmd.location; import dmd.mangle; diff --git a/dmd/compiler.d b/dmd/compiler.d index aaa3a74728..9f6b88a74c 100644 --- a/dmd/compiler.d +++ b/dmd/compiler.d @@ -19,7 +19,7 @@ import dmd.ctfeexpr; import dmd.dmodule; import dmd.errors; import dmd.expression; -import dmd.expressionsem : toInteger; +import dmd.expressionsem : toInteger, toReal; import dmd.globals; import dmd.id; import dmd.identifier; diff --git a/dmd/constfold.d b/dmd/constfold.d index 943c9d7adb..801c7e0dce 100644 --- a/dmd/constfold.d +++ b/dmd/constfold.d @@ -25,7 +25,7 @@ import dmd.declaration; import dmd.dstruct; import dmd.errors; import dmd.expression; -import dmd.expressionsem : getField, isIdentical, toBool, toInteger, toUInteger; +import dmd.expressionsem : getField, isIdentical, toBool, toInteger, toUInteger, toReal, toComplex; import dmd.globals; import dmd.location; import dmd.mtype; diff --git a/dmd/ctfeexpr.d b/dmd/ctfeexpr.d index 74d4c1259b..1f9984c0d6 100644 --- a/dmd/ctfeexpr.d +++ b/dmd/ctfeexpr.d @@ -25,7 +25,7 @@ import dmd.dstruct; import dmd.dtemplate; import dmd.errors; import dmd.expression; -import dmd.expressionsem : isIdentical, getFieldIndex, toBool, toStringExp, toInteger; +import dmd.expressionsem : isIdentical, getFieldIndex, toBool, toStringExp, toInteger, toReal, toComplex; import dmd.func; import dmd.globals : dinteger_t, sinteger_t, uinteger_t; import dmd.location; diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 0e01b9d642..df6496c46c 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -33,6 +33,8 @@ import dmd.location : Loc; import dmd.mtype /*: Covariant, Type, Parameter, ParameterList*/; import dmd.rootobject : RootObject; import dmd.root.optional; +import dmd.root.longdouble : real_t = longdouble; +import dmd.root.complex; import dmd.semantic3; import dmd.statement : Statement, AsmStatement, GccAsmStatement; @@ -448,6 +450,18 @@ uinteger_t toUInteger(Expression exp) return dmd.expressionsem.toUInteger(exp); } +real_t toReal(Expression exp) +{ + import dmd.expressionsem; + return dmd.expressionsem.toReal(exp); +} + +complex_t toComplex(Expression exp) +{ + import dmd.expressionsem; + return dmd.expressionsem.toComplex(exp); +} + /*********************************************************** * func.d */ diff --git a/dmd/expression.d b/dmd/expression.d index 46262b8d42..a941d4e02c 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -294,24 +294,12 @@ extern (C++) abstract class Expression : ASTNode return a; } - real_t toReal() - { - error(loc, "floating point constant expression expected instead of `%s`", toChars()); - return CTFloat.zero; - } - real_t toImaginary() { error(loc, "floating point constant expression expected instead of `%s`", toChars()); return CTFloat.zero; } - complex_t toComplex() - { - error(loc, "floating point constant expression expected instead of `%s`", toChars()); - return complex_t(CTFloat.zero); - } - /**************************************** * Check that the expression has a valid type. * If not, generates an error "... has no type". @@ -553,27 +541,11 @@ extern (C++) final class IntegerExp : Expression return new IntegerExp(loc, value, type); } - override real_t toReal() - { - // normalize() is necessary until we fix all the paints of 'type' - const ty = type.toBasetype().ty; - const val = normalize(ty, value); - value = val; - return (ty == Tuns64) - ? real_t(cast(ulong)val) - : real_t(cast(long)val); - } - override real_t toImaginary() { return CTFloat.zero; } - override complex_t toComplex() - { - return complex_t(toReal()); - } - override void accept(Visitor v) { v.visit(this); @@ -776,21 +748,11 @@ extern (C++) final class RealExp : Expression return new RealExp(loc, value, type); } - override real_t toReal() - { - return type.isReal() ? value : CTFloat.zero; - } - override real_t toImaginary() { return type.isReal() ? CTFloat.zero : value; } - override complex_t toComplex() - { - return complex_t(toReal(), toImaginary()); - } - override void accept(Visitor v) { v.visit(this); @@ -817,21 +779,11 @@ extern (C++) final class ComplexExp : Expression return new ComplexExp(loc, value, type); } - override real_t toReal() - { - return creall(value); - } - override real_t toImaginary() { return cimagl(value); } - override complex_t toComplex() - { - return value; - } - override void accept(Visitor v) { v.visit(this); diff --git a/dmd/expression.h b/dmd/expression.h index c31db3ac63..6add11d615 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -68,6 +68,8 @@ namespace dmd StringExp *toStringExp(Expression *exp); dinteger_t toInteger(Expression *exp); uinteger_t toUInteger(Expression *exp); + real_t toReal(Expression *exp); + complex_t toComplex(Expression *exp); } typedef unsigned char OwnedBy; @@ -103,9 +105,7 @@ class Expression : public ASTNode const char* toChars() const final override; - virtual real_t toReal(); virtual real_t toImaginary(); - virtual complex_t toComplex(); virtual bool checkType(); Expression *addressOf(); Expression *deref(); @@ -238,9 +238,7 @@ class IntegerExp final : public Expression dinteger_t value; static IntegerExp *create(Loc loc, dinteger_t value, Type *type); - real_t toReal() override; real_t toImaginary() override; - complex_t toComplex() override; void accept(Visitor *v) override { v->visit(this); } dinteger_t getInteger() { return value; } template @@ -261,9 +259,7 @@ class RealExp final : public Expression real_t value; static RealExp *create(Loc loc, real_t value, Type *type); - real_t toReal() override; real_t toImaginary() override; - complex_t toComplex() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -273,9 +269,7 @@ class ComplexExp final : public Expression complex_t value; static ComplexExp *create(Loc loc, complex_t value, Type *type); - real_t toReal() override; real_t toImaginary() override; - complex_t toComplex() override; void accept(Visitor *v) override { v->visit(this); } }; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 846a2b80a9..627bc58db2 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -100,6 +100,48 @@ import dmd.visitor.postorder; enum LOGSEMANTIC = false; +real_t toReal(Expression _this) +{ + if (auto iexp = _this.isIntegerExp()) + { + // normalize() is necessary until we fix all the paints of 'type' + const ty = iexp.type.toBasetype().ty; + const val = iexp.normalize(ty, iexp.value); + iexp.value = val; + return (ty == Tuns64) + ? real_t(cast(ulong)val) + : real_t(cast(long)val); + } + else if (auto rexp = _this.isRealExp()) + { + return rexp.type.isReal() ? rexp.value : CTFloat.zero; + } + else if (auto cexp = _this.isComplexExp()) + { + return creall(cexp.value); + } + error(_this.loc, "floating point constant expression expected instead of `%s`", _this.toChars()); + return CTFloat.zero; +} + +complex_t toComplex(Expression _this) +{ + if (auto iexp = _this.isIntegerExp()) + { + return complex_t(iexp.toReal()); + } + else if (auto rexp = _this.isRealExp()) + { + return complex_t(rexp.toReal(), rexp.toImaginary()); + } + else if (auto cexp = _this.isComplexExp()) + { + return cexp.value; + } + error(_this.loc, "floating point constant expression expected instead of `%s`", _this.toChars()); + return complex_t(CTFloat.zero); +} + dinteger_t toInteger(Expression _this) { if (auto iexp = _this.isIntegerExp()) diff --git a/dmd/frontend.h b/dmd/frontend.h index 4748d6d272..58841e195f 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2298,16 +2298,6 @@ enum class EXP : uint8_t rvalue = 128u, }; -struct complex_t final -{ - _d_real re; - _d_real im; - complex_t() = delete; - complex_t(_d_real re); - complex_t(_d_real re, _d_real im); - int32_t opEquals(complex_t y) const; -}; - class Expression : public ASTNode { public: @@ -2347,9 +2337,7 @@ class Expression : public ASTNode virtual Expression* syntaxCopy(); DYNCAST dyncast() const final override; const char* toChars() const final override; - virtual _d_real toReal(); virtual _d_real toImaginary(); - virtual complex_t toComplex(); virtual bool checkType(); Expression* deref(); int32_t isConst(); @@ -2714,14 +2702,22 @@ class CommaExp final : public BinExp static void allow(Expression* exp); }; +struct complex_t final +{ + _d_real re; + _d_real im; + complex_t() = delete; + complex_t(_d_real re); + complex_t(_d_real re, _d_real im); + int32_t opEquals(complex_t y) const; +}; + class ComplexExp final : public Expression { public: complex_t value; static ComplexExp* create(Loc loc, complex_t value, Type* type); - _d_real toReal() override; _d_real toImaginary() override; - complex_t toComplex() override; void accept(Visitor* v) override; }; @@ -3194,9 +3190,7 @@ class IntegerExp final : public Expression public: dinteger_t value; static IntegerExp* create(Loc loc, dinteger_t value, Type* type); - _d_real toReal() override; _d_real toImaginary() override; - complex_t toComplex() override; void accept(Visitor* v) override; dinteger_t getInteger(); IntegerExp* syntaxCopy() override; @@ -3422,9 +3416,7 @@ class RealExp final : public Expression public: _d_real value; static RealExp* create(Loc loc, _d_real value, Type* type); - _d_real toReal() override; _d_real toImaginary() override; - complex_t toComplex() override; void accept(Visitor* v) override; }; diff --git a/dmd/mangle/package.d b/dmd/mangle/package.d index 07bf52ec8f..df88465bd0 100644 --- a/dmd/mangle/package.d +++ b/dmd/mangle/package.d @@ -146,7 +146,7 @@ import dmd.dinterpret; import dmd.dmodule; import dmd.dsymbol; import dmd.dsymbolsem : toAlias; -import dmd.expressionsem : toInteger; +import dmd.expressionsem : toInteger, toReal; import dmd.dtemplate; import dmd.errors; import dmd.expression; From 5a0b800e612f3c02b7ef2663a2790c1a60c97abd Mon Sep 17 00:00:00 2001 From: limepoutine Date: Mon, 10 Nov 2025 14:13:31 +0800 Subject: [PATCH 076/440] Remove `hdrscan` from inline cost visitor (dlang/dmd!22053) --- dmd/inline.d | 92 +++++++++++++++++++++--------------------------- dmd/inlinecost.d | 53 +++++++++++----------------- 2 files changed, 60 insertions(+), 85 deletions(-) diff --git a/dmd/inline.d b/dmd/inline.d index c36be26139..e1e3571dd3 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -1473,7 +1473,7 @@ public: asStates = false; } - if (canInline(fd, false, false, asStates, eSink)) + if (canInline(fd, parent == fd.toParent2(), asStates, eSink)) { expandInline(e.loc, fd, parent, eret, null, e.arguments, asStates, e.vthis2, eresult, sresult, again); if (asStatements && eresult) @@ -1528,7 +1528,7 @@ public: else if (auto dve = e.e1.isDotVarExp()) { fd = dve.var.isFuncDeclaration(); - if (fd && fd != parent && canInline(fd, true, false, asStatements, eSink)) + if (fd && fd != parent && canInline(fd, !fd.isNested(), asStatements, eSink)) { if (dve.e1.op == EXP.call && dve.e1.type.toBasetype().ty == Tstruct) { @@ -1776,8 +1776,7 @@ public: * Test that `fd` can be inlined. * * Params: - * hasthis = `true` if the function call has explicit 'this' expression. - * hdrscan = `true` if the inline scan is for 'D header' content. + * hasThis = `true` if the caller can access the callee's this pointer. * statementsToo = `true` if the function call is placed on ExpStatement. * It means more code-block dependent statements in fd body - ForStatement, * ThrowStatement, etc. can be inlined. @@ -1785,23 +1784,18 @@ public: * * Returns: * true if the function body can be expanded. - * - * Todo: - * - Would be able to eliminate `hasthis` parameter, because semantic analysis - * no longer accepts calls of contextful function without valid 'this'. - * - Would be able to eliminate `hdrscan` parameter, because it's always false. */ -private bool canInline(FuncDeclaration fd, bool hasthis, bool hdrscan, bool statementsToo, ErrorSink eSink) +private bool canInline(FuncDeclaration fd, bool hasThis, bool statementsToo, ErrorSink eSink) { int cost; static if (CANINLINE_LOG) { - printf("FuncDeclaration.canInline(hasthis = %d, statementsToo = %d, '%s')\n", - hasthis, statementsToo, fd.toPrettyChars()); + printf("FuncDeclaration.canInline(hasThis = %d, statementsToo = %d, '%s')\n", + hasThis, statementsToo, fd.toPrettyChars()); } - if (fd.needThis() && !hasthis) + if (fd.needThis() && !hasThis) return false; if (fd.inlineNest) @@ -1813,7 +1807,7 @@ private bool canInline(FuncDeclaration fd, bool hasthis, bool hdrscan, bool stat return false; } - if (fd.semanticRun < PASS.semantic3 && !hdrscan) + if (fd.semanticRun < PASS.semantic3) { if (!fd.fbody) return false; @@ -1901,8 +1895,7 @@ private bool canInline(FuncDeclaration fd, bool hasthis, bool hdrscan, bool stat */ if (tfnext.ty != Tvoid && (!fd.hasReturnExp || - hasDtor(tfnext) && (statementsToo || tfnext.isTypeSArray())) && - !hdrscan) + hasDtor(tfnext) && (statementsToo || tfnext.isTypeSArray()))) { static if (CANINLINE_LOG) { @@ -1932,10 +1925,10 @@ private bool canInline(FuncDeclaration fd, bool hasthis, bool hdrscan, bool stat (fd.ident == Id.require && fd.toParent().isFuncDeclaration() && fd.toParent().isFuncDeclaration().needThis()) || - !hdrscan && (fd.isSynchronized() || - fd.isImportedSymbol() || - fd.hasNestedFrameRefs() || - (fd.isVirtual() && !fd.isFinalFunc()))) + (fd.isSynchronized() || + fd.isImportedSymbol() || + fd.hasNestedFrameRefs() || + (fd.isVirtual() && !fd.isFinalFunc()))) { static if (CANINLINE_LOG) { @@ -1956,7 +1949,7 @@ private bool canInline(FuncDeclaration fd, bool hasthis, bool hdrscan, bool stat } { - cost = inlineCostFunction(fd, hasthis, hdrscan); + cost = inlineCostFunction(fd, hasThis); } static if (CANINLINE_LOG) { @@ -1968,36 +1961,33 @@ private bool canInline(FuncDeclaration fd, bool hasthis, bool hdrscan, bool stat if (!statementsToo && cost > COST_MAX) goto Lno; - if (!hdrscan) - { - // Don't modify inlineStatus for header content scan - if (statementsToo) - fd.inlineStatusStmt = ILS.yes; - else - fd.inlineStatusExp = ILS.yes; + if (statementsToo) + fd.inlineStatusStmt = ILS.yes; + else + fd.inlineStatusExp = ILS.yes; - inlineScanDsymbol(fd, eSink); // Don't scan recursively for header content scan + inlineScanDsymbol(fd, eSink); - if (fd.inlineStatusExp == ILS.uninitialized) + if (fd.inlineStatusExp == ILS.uninitialized) + { + // Need to redo cost computation, as some statements or expressions have been inlined + cost = inlineCostFunction(fd, hasThis); + static if (CANINLINE_LOG) { - // Need to redo cost computation, as some statements or expressions have been inlined - cost = inlineCostFunction(fd, hasthis, hdrscan); - static if (CANINLINE_LOG) - { - printf("recomputed cost = %d for %s\n", cost, fd.toChars()); - } + printf("recomputed cost = %d for %s\n", cost, fd.toChars()); + } - if (tooCostly(cost)) - goto Lno; - if (!statementsToo && cost > COST_MAX) - goto Lno; + if (tooCostly(cost)) + goto Lno; + if (!statementsToo && cost > COST_MAX) + goto Lno; - if (statementsToo) - fd.inlineStatusStmt = ILS.yes; - else - fd.inlineStatusExp = ILS.yes; - } + if (statementsToo) + fd.inlineStatusStmt = ILS.yes; + else + fd.inlineStatusExp = ILS.yes; } + static if (CANINLINE_LOG) { printf("\t2: yes %s\n", fd.toChars()); @@ -2008,13 +1998,11 @@ Lno: if (fd.inlining == PINLINE.always && global.params.useWarnings == DiagnosticReporting.inform) eSink.warning(fd.loc, "cannot inline function `%s`", fd.toPrettyChars()); - if (!hdrscan) // Don't modify inlineStatus for header content scan - { - if (statementsToo) - fd.inlineStatusStmt = ILS.no; - else - fd.inlineStatusExp = ILS.no; - } + if (statementsToo) + fd.inlineStatusStmt = ILS.no; + else + fd.inlineStatusExp = ILS.no; + static if (CANINLINE_LOG) { printf("\t2: no %s\n", fd.toChars()); diff --git a/dmd/inlinecost.d b/dmd/inlinecost.d index fd0127ddf7..07adab5af6 100644 --- a/dmd/inlinecost.d +++ b/dmd/inlinecost.d @@ -67,7 +67,7 @@ bool tooCostly(int cost) pure nothrow @safe */ int inlineCostExpression(Expression e) { - scope InlineCostVisitor icv = new InlineCostVisitor(false, true, true, null); + scope InlineCostVisitor icv = new InlineCostVisitor(true, false); icv.expressionInlineCost(e); return icv.cost; } @@ -77,14 +77,13 @@ int inlineCostExpression(Expression e) * Determine cost of inlining function * Params: * fd = function to determine cost of - * hasthis = if the function call has explicit 'this' expression - * hdrscan = if generating a header file + * hasThis = if the caller can access the callee's this pointer * Returns: * cost of inlining fd */ -int inlineCostFunction(FuncDeclaration fd, bool hasthis, bool hdrscan) +int inlineCostFunction(FuncDeclaration fd, bool hasThis) { - scope InlineCostVisitor icv = new InlineCostVisitor(hasthis, hdrscan, false, fd); + scope InlineCostVisitor icv = new InlineCostVisitor(false, hasThis); fd.fbody.accept(icv); return icv.cost; } @@ -149,32 +148,28 @@ extern (C++) final class InlineCostVisitor : Visitor { alias visit = Visitor.visit; public: + // if the expression being visited is a default argument, which is + // specified to be copied at call site and can contain more types of + // expression (like alloca) than regular inlining + immutable bool callerCopy; + + // if the caller can access the callee's this pointer + immutable bool hasThis; + int nested; - bool hasthis; - bool hdrscan; // if inline scan for 'header' content - bool allowAlloca; - FuncDeclaration fd; int cost; // zero start for subsequent AST - extern (D) this() scope @safe - { - } - - extern (D) this(bool hasthis, bool hdrscan, bool allowAlloca, FuncDeclaration fd) scope @safe + extern (D) this(bool callerCopy, bool hasThis) scope @safe { - this.hasthis = hasthis; - this.hdrscan = hdrscan; - this.allowAlloca = allowAlloca; - this.fd = fd; + this.callerCopy = callerCopy; + this.hasThis = hasThis; } extern (D) this(InlineCostVisitor icv) scope @safe { nested = icv.nested; - hasthis = icv.hasthis; - hdrscan = icv.hdrscan; - allowAlloca = icv.allowAlloca; - fd = icv.fd; + callerCopy = icv.callerCopy; + hasThis = icv.hasThis; } override void visit(Statement s) @@ -395,19 +390,11 @@ public: override void visit(ThisExp e) { //printf("ThisExp.inlineCost3() %s\n", toChars()); - if (!fd) + if (!hasThis) { cost = COST_MAX; return; } - if (!hdrscan) - { - if (fd.isNested() || !hasthis) - { - cost = COST_MAX; - return; - } - } cost++; } @@ -453,7 +440,7 @@ public: cost = COST_MAX; // finish DeclarationExp.doInlineAs return; } - if (!hdrscan && vd.isDataseg()) + if (!callerCopy && vd.isDataseg()) { cost = COST_MAX; return; @@ -504,7 +491,7 @@ public: // can't handle that at present. if (e.e1.op == EXP.dotVariable && (cast(DotVarExp)e.e1).e1.op == EXP.super_) cost = COST_MAX; - else if (e.f && e.f.ident == Id.__alloca && e.f._linkage == LINK.c && !allowAlloca) + else if (e.f && e.f.ident == Id.__alloca && e.f._linkage == LINK.c && !callerCopy) cost = COST_MAX; // inlining alloca may cause stack overflows else cost++; From d41ff461249aedf22e2035c7410556f657f71646 Mon Sep 17 00:00:00 2001 From: Steven Schveighoffer Date: Tue, 11 Nov 2025 22:16:46 -0500 Subject: [PATCH 077/440] Update docs for thread_detachThis and thread_detachByAddr to reflect the GC shutdown process for detaching threads. --- runtime/druntime/src/core/thread/threadbase.d | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/runtime/druntime/src/core/thread/threadbase.d b/runtime/druntime/src/core/thread/threadbase.d index 6281be59fb..350d738f8b 100644 --- a/runtime/druntime/src/core/thread/threadbase.d +++ b/runtime/druntime/src/core/thread/threadbase.d @@ -864,6 +864,11 @@ package ThreadT thread_attachThis_tpl(ThreadT)() * Deregisters the calling thread from use with the runtime. If this routine * is called for a thread which is not registered, the result is undefined. * + * Once the thread is removed from the runtime, it must not use the GC because + * it does not participate in the Stop-The-World mechanisms. With the default + * GC, that has a global lock, this might not cause races, but in GCs with + * regional locks, it definitely can cause races. + * * NOTE: This routine does not run thread-local static destructors when called. * If full functionality as a D thread is desired, the following function * must be called before thread_detachThis, particularly if the thread is @@ -871,6 +876,10 @@ package ThreadT thread_attachThis_tpl(ThreadT)() * * $(D extern(C) void rt_moduleTlsDtor();) * + * This also does not call the GC thread cleanup routine. After running + * module dtors, it is recommended to call + * $(D gc_getProxy().cleanupThread(Thread.getThis());) + * * See_Also: * $(REF thread_attachThis, core,thread,osthread) */ @@ -885,12 +894,22 @@ extern (C) void thread_detachThis() nothrow @nogc * Deregisters the given thread from use with the runtime. If this routine * is called for a thread which is not registered, the result is undefined. * + * Once the thread is removed from the runtime, it must not use the GC because + * it does not participate in the Stop-The-World mechanisms. With the default + * GC, that has a global lock, this might not cause races, but in GCs with + * regional locks, it definitely can cause races. + * * NOTE: This routine does not run thread-local static destructors when called. * If full functionality as a D thread is desired, the following function - * must be called by the detached thread, particularly if the thread is - * being detached at some indeterminate time before program termination: + * must be called by the detached thread before calling this function, + * particularly if the thread is being detached at some indeterminate + * time before program termination: * * $(D extern(C) void rt_moduleTlsDtor();) + * + * This also does not call the GC thread cleanup routine. After running + * module dtors, it is recommended to call (from the thread itself) + * $(D gc_getProxy().cleanupThread(Thread.getThis());) */ extern (C) void thread_detachByAddr(ThreadID addr) { From 182b6eb00d40278d3dad45dce938a0a0d2e5709c Mon Sep 17 00:00:00 2001 From: limepoutine Date: Wed, 12 Nov 2025 12:34:20 +0800 Subject: [PATCH 078/440] Fix a type mismatch in glue layer (dlang/dmd!22081) --- tests/dmd/runnable/opcolon.d | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/dmd/runnable/opcolon.d diff --git a/tests/dmd/runnable/opcolon.d b/tests/dmd/runnable/opcolon.d new file mode 100644 index 0000000000..554d542b90 --- /dev/null +++ b/tests/dmd/runnable/opcolon.d @@ -0,0 +1,24 @@ +// REQUIRED_ARGS: -betterC + +/* This test triggers an address miscalculation bug in DMD 2.111 + * with -inline. + * May not crash if the data segment has a different layout, + * e.g. when pasted into another file. + */ + +struct S { + int i; +} + +__gshared S gs = S(1); +ref S get() +{ + return gs; +} + +extern (C) +int main() +{ + (get().i ? get() : get()).i++; + return 0; +} From b88e5f439d8d01c6d1854780c41c09afbcb1f69a Mon Sep 17 00:00:00 2001 From: limepoutine Date: Wed, 12 Nov 2025 12:34:58 +0800 Subject: [PATCH 079/440] Fix inlining of WithStatement (dlang/dmd!22082) --- dmd/inline.d | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dmd/inline.d b/dmd/inline.d index e1e3571dd3..1b7d82a185 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -1217,7 +1217,13 @@ public: override void visit(WithStatement s) { - inlineScan(s.exp); + if (s.wthis && s.wthis._init) + { + if (auto ie = s.wthis._init.isExpInitializer()) + { + inlineScan(ie.exp); + } + } inlineScan(s._body); } From 8c75d6f59b0e2e0a03aed90d5eafd910098d1f25 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Thu, 13 Nov 2025 15:41:55 +0200 Subject: [PATCH 080/440] Move `Type.makeConst` to `typesem` (dlang/dmd!22090) --- dmd/cxxfrontend.d | 5 +++++ dmd/frontend.h | 2 -- dmd/mtype.d | 41 -------------------------------------- dmd/mtype.h | 3 +-- dmd/typesem.d | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+), 45 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index df6496c46c..d622fa6774 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -941,6 +941,11 @@ void Type_init() return dmd.typesem.Type_init(); } +Type makeConst(Type type) +{ + import dmd.typesem; + return dmd.typesem.makeConst(type); +} /*********************************************************** * typinf.d diff --git a/dmd/frontend.h b/dmd/frontend.h index 58841e195f..59a1685da1 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2091,7 +2091,6 @@ class Type : public ASTNode bool isNaked() const; Type* nullAttributes() const; bool hasDeprecatedAliasThis(); - virtual Type* makeConst(); virtual Type* makeImmutable(); virtual Type* makeShared(); virtual Type* makeSharedConst(); @@ -4373,7 +4372,6 @@ class TypeNext : public Type Type* next; int32_t hasWild() const final override; Type* nextOf() final override; - Type* makeConst() final override; Type* makeImmutable() final override; Type* makeShared() final override; Type* makeSharedConst() final override; diff --git a/dmd/mtype.d b/dmd/mtype.d index c1b03f2155..70a347cdd5 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1159,17 +1159,6 @@ extern (C++) abstract class Type : ASTNode return ad && ad.aliasthis && (ad.aliasthis.isDeprecated || ad.aliasthis.sym.isDeprecated); } - Type makeConst() - { - //printf("Type::makeConst() %p, %s\n", this, toChars()); - if (mcache && mcache.cto) - return mcache.cto; - Type t = this.nullAttributes(); - t.mod = MODFlags.const_; - //printf("-Type::makeConst() %p, %s\n", t, toChars()); - return t; - } - Type makeImmutable() { if (mcache && mcache.ito) @@ -1532,36 +1521,6 @@ extern (C++) abstract class TypeNext : Type return next; } - override final Type makeConst() - { - //printf("TypeNext::makeConst() %p, %s\n", this, toChars()); - if (mcache && mcache.cto) - { - assert(mcache.cto.mod == MODFlags.const_); - return mcache.cto; - } - TypeNext t = cast(TypeNext)Type.makeConst(); - if (ty != Tfunction && next.ty != Tfunction && !next.isImmutable()) - { - if (next.isShared()) - { - if (next.isWild()) - t.next = next.sharedWildConstOf(); - else - t.next = next.sharedConstOf(); - } - else - { - if (next.isWild()) - t.next = next.wildConstOf(); - else - t.next = next.constOf(); - } - } - //printf("TypeNext::makeConst() returns %p, %s\n", t, t.toChars()); - return t; - } - override final Type makeImmutable() { //printf("TypeNext::makeImmutable() %s\n", toChars()); diff --git a/dmd/mtype.h b/dmd/mtype.h index ca54246c9f..7e2146aa2b 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -249,7 +249,6 @@ class Type : public ASTNode bool isNaked() const { return mod == 0; } Type *nullAttributes() const; bool hasDeprecatedAliasThis(); - virtual Type *makeConst(); virtual Type *makeImmutable(); virtual Type *makeShared(); virtual Type *makeSharedConst(); @@ -318,7 +317,6 @@ class TypeNext : public Type int hasWild() const override final; Type *nextOf() override final; - Type *makeConst() override final; Type *makeImmutable() override final; Type *makeShared() override final; Type *makeSharedConst() override final; @@ -824,4 +822,5 @@ namespace dmd structalign_t alignment(Type* type); Type* memType(TypeEnum* type); unsigned alignsize(Type* type); + Type *makeConst(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index 4c80961c96..371fb04325 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -67,6 +67,56 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; +Type makeConst(Type _this) +{ + if (_this.mcache && _this.mcache.cto) + { + assert(_this.mcache.cto.mod == MODFlags.const_); + return _this.mcache.cto; + } + + static Type defaultMakeConst(Type _this) + { + //printf("Type::makeConst() %p, %s\n", this, toChars()); + Type t = _this.nullAttributes(); + t.mod = MODFlags.const_; + //printf("-Type::makeConst() %p, %s\n", t, toChars()); + return t; + } + + static Type typeNextMakeConst(TypeNext _this) + { + //printf("TypeNext::makeConst() %p, %s\n", this, toChars()); + TypeNext t = cast(TypeNext)defaultMakeConst(cast(Type)_this); + if (_this.ty != Tfunction && _this.next.ty != Tfunction && !_this.next.isImmutable()) + { + if (_this.next.isShared()) + { + if (_this.next.isWild()) + t.next = _this.next.sharedWildConstOf(); + else + t.next = _this.next.sharedConstOf(); + } + else + { + if (_this.next.isWild()) + t.next = _this.next.wildConstOf(); + else + t.next = _this.next.constOf(); + } + } + //printf("TypeNext::makeConst() returns %p, %s\n", t, t.toChars()); + return t; + } + + switch(_this.ty) + { + case Tpointer, Treference, Tfunction, Tdelegate, Tslice, Tarray, Taarray, Tsarray: + return typeNextMakeConst(cast(TypeNext) _this); + default: return defaultMakeConst(_this); + } +} + Type toBasetype2(TypeEnum _this) { if (!_this.sym.members && !_this.sym.memtype) From 8865b006a3f786bd1ff1bc0e0eba222ba1f74b28 Mon Sep 17 00:00:00 2001 From: Clouudy <90809810+Clouud9@users.noreply.github.com> Date: Thu, 13 Nov 2025 18:06:21 -0500 Subject: [PATCH 081/440] Added Windows implementation of timespec_get --- .../druntime/src/core/sys/windows/stdc/time.d | 62 +++++++++++++------ 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/runtime/druntime/src/core/sys/windows/stdc/time.d b/runtime/druntime/src/core/sys/windows/stdc/time.d index 407b92c20a..3a35e28c11 100644 --- a/runtime/druntime/src/core/sys/windows/stdc/time.d +++ b/runtime/druntime/src/core/sys/windows/stdc/time.d @@ -15,9 +15,7 @@ module core.sys.windows.stdc.time; -version (Windows): - -import core.stdc.config; +version (Windows) : import core.stdc.config; extern (C): @trusted: // There are only a few functions here that use unsafe C strings. @@ -25,17 +23,16 @@ nothrow: @nogc: /// -struct tm -{ - int tm_sec; /// seconds after the minute - [0, 60] - int tm_min; /// minutes after the hour - [0, 59] - int tm_hour; /// hours since midnight - [0, 23] - int tm_mday; /// day of the month - [1, 31] - int tm_mon; /// months since January - [0, 11] - int tm_year; /// years since 1900 - int tm_wday; /// days since Sunday - [0, 6] - int tm_yday; /// days since January 1 - [0, 365] - int tm_isdst; /// Daylight Saving Time flag +struct tm { + int tm_sec; /// seconds after the minute - [0, 60] + int tm_min; /// minutes after the hour - [0, 59] + int tm_hour; /// hours since midnight - [0, 23] + int tm_mday; /// day of the month - [1, 31] + int tm_mon; /// months since January - [0, 11] + int tm_year; /// years since 1900 + int tm_wday; /// days since Sunday - [0, 6] + int tm_yday; /// days since January 1 - [0, 365] + int tm_isdst; /// Daylight Saving Time flag } /// @@ -47,13 +44,42 @@ enum clock_t CLOCKS_PER_SEC = 1000; clock_t clock(); /// -void tzset(); // non-standard +void tzset(); // non-standard /// -void _tzset(); // non-standard +void _tzset(); // non-standard /// -@system char* _strdate(return scope char* s); // non-standard +@system char* _strdate(return scope char* s); // non-standard /// -@system char* _strtime(return scope char* s); // non-standard +@system char* _strtime(return scope char* s); // non-standard /// extern __gshared const(char)*[2] tzname; // non-standard + +/* +version (Win64) { + pragma(lib, "libucrt"); + + struct timespec { + time_t tv_sec; + long tv_nsec; + } + + enum TIME_UTC = 0; + + int _timespec64_get(const timespec* ts, int base); + int _timespec32_get(const timespec* ts, int base); + alias timespec_get = _timespec64_get; +} +*/ +pragma(lib, "msvcrt"); + +struct timespec { + time_t tv_sec; + long tv_nsec; +} + +enum TIME_UTC = 0; + +int _timespec64_get(const timespec* ts, int base); +int _timespec32_get(const timespec* ts, int base); +alias timespec_get = _timespec64_get; \ No newline at end of file From c4bab1e186ed14b2f32c75ec35deff2d5d190a93 Mon Sep 17 00:00:00 2001 From: Clouudy <90809810+Clouud9@users.noreply.github.com> Date: Thu, 13 Nov 2025 19:33:13 -0500 Subject: [PATCH 082/440] Made TIME_UTC the proper value --- runtime/druntime/src/core/sys/windows/stdc/time.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/druntime/src/core/sys/windows/stdc/time.d b/runtime/druntime/src/core/sys/windows/stdc/time.d index 3a35e28c11..60b65de551 100644 --- a/runtime/druntime/src/core/sys/windows/stdc/time.d +++ b/runtime/druntime/src/core/sys/windows/stdc/time.d @@ -78,7 +78,7 @@ struct timespec { long tv_nsec; } -enum TIME_UTC = 0; +enum TIME_UTC = 1; int _timespec64_get(const timespec* ts, int base); int _timespec32_get(const timespec* ts, int base); From 62880f530d2f6db34b4e36d473f4e527007b8c23 Mon Sep 17 00:00:00 2001 From: Clouudy <90809810+Clouud9@users.noreply.github.com> Date: Thu, 13 Nov 2025 19:35:16 -0500 Subject: [PATCH 083/440] Added POSIX implementation of timespec_get --- runtime/druntime/src/core/sys/posix/stdc/time.d | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/runtime/druntime/src/core/sys/posix/stdc/time.d b/runtime/druntime/src/core/sys/posix/stdc/time.d index c5a2e1b718..f016cd3142 100644 --- a/runtime/druntime/src/core/sys/posix/stdc/time.d +++ b/runtime/druntime/src/core/sys/posix/stdc/time.d @@ -50,6 +50,11 @@ struct tm } public import core.sys.posix.sys.types : time_t, clock_t; +public import core.sys.posix.time; + +int timespec_get(timespec* ts, int base); + +enum TIME_UTC = 1; /// version (CRuntime_Glibc) From db10d94156cbe97ace2df09542a986342441ab46 Mon Sep 17 00:00:00 2001 From: Clouudy <90809810+Clouud9@users.noreply.github.com> Date: Thu, 13 Nov 2025 20:01:10 -0500 Subject: [PATCH 084/440] Fixed formatting changes --- .../druntime/src/core/sys/windows/stdc/time.d | 49 +++++++------------ 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/runtime/druntime/src/core/sys/windows/stdc/time.d b/runtime/druntime/src/core/sys/windows/stdc/time.d index 60b65de551..5a27bf4aac 100644 --- a/runtime/druntime/src/core/sys/windows/stdc/time.d +++ b/runtime/druntime/src/core/sys/windows/stdc/time.d @@ -15,7 +15,9 @@ module core.sys.windows.stdc.time; -version (Windows) : import core.stdc.config; +version (Windows): + +import core.stdc.config; extern (C): @trusted: // There are only a few functions here that use unsafe C strings. @@ -23,16 +25,17 @@ nothrow: @nogc: /// -struct tm { - int tm_sec; /// seconds after the minute - [0, 60] - int tm_min; /// minutes after the hour - [0, 59] - int tm_hour; /// hours since midnight - [0, 23] - int tm_mday; /// day of the month - [1, 31] - int tm_mon; /// months since January - [0, 11] - int tm_year; /// years since 1900 - int tm_wday; /// days since Sunday - [0, 6] - int tm_yday; /// days since January 1 - [0, 365] - int tm_isdst; /// Daylight Saving Time flag +struct tm +{ + int tm_sec; /// seconds after the minute - [0, 60] + int tm_min; /// minutes after the hour - [0, 59] + int tm_hour; /// hours since midnight - [0, 23] + int tm_mday; /// day of the month - [1, 31] + int tm_mon; /// months since January - [0, 11] + int tm_year; /// years since 1900 + int tm_wday; /// days since Sunday - [0, 6] + int tm_yday; /// days since January 1 - [0, 365] + int tm_isdst; /// Daylight Saving Time flag } /// @@ -44,33 +47,17 @@ enum clock_t CLOCKS_PER_SEC = 1000; clock_t clock(); /// -void tzset(); // non-standard +void tzset(); // non-standard /// -void _tzset(); // non-standard +void _tzset(); // non-standard /// -@system char* _strdate(return scope char* s); // non-standard +@system char* _strdate(return scope char* s); // non-standard /// -@system char* _strtime(return scope char* s); // non-standard +@system char* _strtime(return scope char* s); // non-standard /// extern __gshared const(char)*[2] tzname; // non-standard -/* -version (Win64) { - pragma(lib, "libucrt"); - - struct timespec { - time_t tv_sec; - long tv_nsec; - } - - enum TIME_UTC = 0; - - int _timespec64_get(const timespec* ts, int base); - int _timespec32_get(const timespec* ts, int base); - alias timespec_get = _timespec64_get; -} -*/ pragma(lib, "msvcrt"); struct timespec { From cd119d106a4f564661f347cf20ae186afd669589 Mon Sep 17 00:00:00 2001 From: Clouudy <90809810+Clouud9@users.noreply.github.com> Date: Thu, 13 Nov 2025 20:02:25 -0500 Subject: [PATCH 085/440] Newline added at end --- runtime/druntime/src/core/sys/windows/stdc/time.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/druntime/src/core/sys/windows/stdc/time.d b/runtime/druntime/src/core/sys/windows/stdc/time.d index 5a27bf4aac..702df7ccd9 100644 --- a/runtime/druntime/src/core/sys/windows/stdc/time.d +++ b/runtime/druntime/src/core/sys/windows/stdc/time.d @@ -69,4 +69,4 @@ enum TIME_UTC = 1; int _timespec64_get(const timespec* ts, int base); int _timespec32_get(const timespec* ts, int base); -alias timespec_get = _timespec64_get; \ No newline at end of file +alias timespec_get = _timespec64_get; From 46e4a5641a0d39d181960ec93541e1e5d5eb638f Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 14 Nov 2025 08:58:01 +0200 Subject: [PATCH 086/440] Move `Type.makeMutable` and `Type.makeImmutable` to `typesem` (dlang/dmd!22094) --- dmd/cparse.d | 2 +- dmd/cxxfrontend.d | 12 ++++++++++ dmd/frontend.h | 4 ---- dmd/mtype.d | 44 ----------------------------------- dmd/mtype.h | 6 ++--- dmd/typesem.d | 59 ++++++++++++++++++++++++++++++++++++++++++----- 6 files changed, 68 insertions(+), 59 deletions(-) diff --git a/dmd/cparse.d b/dmd/cparse.d index 2cb898ea7c..9c4645a991 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -27,7 +27,7 @@ import dmd.root.array; import dmd.common.outbuffer; import dmd.root.rmem; import dmd.tokens; -import dmd.typesem : size; +import dmd.typesem : size, makeImmutable; /*********************************************************** */ diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index d622fa6774..c5a951b435 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -947,6 +947,18 @@ Type makeConst(Type type) return dmd.typesem.makeConst(type); } +Type makeImmutable(Type type) +{ + import dmd.typesem; + return dmd.typesem.makeImmutable(type); +} + +Type makeMutable(Type type) +{ + import dmd.typesem; + return dmd.typesem.makeMutable(type); +} + /*********************************************************** * typinf.d */ diff --git a/dmd/frontend.h b/dmd/frontend.h index 59a1685da1..aee3089e42 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2091,14 +2091,12 @@ class Type : public ASTNode bool isNaked() const; Type* nullAttributes() const; bool hasDeprecatedAliasThis(); - virtual Type* makeImmutable(); virtual Type* makeShared(); virtual Type* makeSharedConst(); virtual Type* makeWild(); virtual Type* makeWildConst(); virtual Type* makeSharedWild(); virtual Type* makeSharedWildConst(); - virtual Type* makeMutable(); Type* toBasetype(); virtual uint8_t deduceWild(Type* t, bool isRef); virtual ClassDeclaration* isClassHandle(); @@ -4372,14 +4370,12 @@ class TypeNext : public Type Type* next; int32_t hasWild() const final override; Type* nextOf() final override; - Type* makeImmutable() final override; Type* makeShared() final override; Type* makeSharedConst() final override; Type* makeWild() final override; Type* makeWildConst() final override; Type* makeSharedWild() final override; Type* makeSharedWildConst() final override; - Type* makeMutable() final override; uint8_t deduceWild(Type* t, bool isRef) final override; void transitive(); void accept(Visitor* v) override; diff --git a/dmd/mtype.d b/dmd/mtype.d index 70a347cdd5..791f8f419c 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1159,15 +1159,6 @@ extern (C++) abstract class Type : ASTNode return ad && ad.aliasthis && (ad.aliasthis.isDeprecated || ad.aliasthis.sym.isDeprecated); } - Type makeImmutable() - { - if (mcache && mcache.ito) - return mcache.ito; - Type t = this.nullAttributes(); - t.mod = MODFlags.immutable_; - return t; - } - Type makeShared() { if (mcache && mcache.sto) @@ -1222,13 +1213,6 @@ extern (C++) abstract class Type : ASTNode return t; } - Type makeMutable() - { - Type t = this.nullAttributes(); - t.mod = mod & MODFlags.shared_; - return t; - } - /******************************* * If this is a shell around another type, * get that other type. @@ -1521,22 +1505,6 @@ extern (C++) abstract class TypeNext : Type return next; } - override final Type makeImmutable() - { - //printf("TypeNext::makeImmutable() %s\n", toChars()); - if (mcache && mcache.ito) - { - assert(mcache.ito.isImmutable()); - return mcache.ito; - } - TypeNext t = cast(TypeNext)Type.makeImmutable(); - if (ty != Tfunction && next.ty != Tfunction && !next.isImmutable()) - { - t.next = next.immutableOf(); - } - return t; - } - override final Type makeShared() { //printf("TypeNext::makeShared() %s\n", toChars()); @@ -1674,18 +1642,6 @@ extern (C++) abstract class TypeNext : Type return t; } - override final Type makeMutable() - { - //printf("TypeNext::makeMutable() %p, %s\n", this, toChars()); - TypeNext t = cast(TypeNext)Type.makeMutable(); - if (ty == Tsarray) - { - t.next = next.mutableOf(); - } - //printf("TypeNext::makeMutable() returns %p, %s\n", t, t.toChars()); - return t; - } - override final MOD deduceWild(Type t, bool isRef) { if (ty == Tfunction) diff --git a/dmd/mtype.h b/dmd/mtype.h index 7e2146aa2b..146254e626 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -249,14 +249,12 @@ class Type : public ASTNode bool isNaked() const { return mod == 0; } Type *nullAttributes() const; bool hasDeprecatedAliasThis(); - virtual Type *makeImmutable(); virtual Type *makeShared(); virtual Type *makeSharedConst(); virtual Type *makeWild(); virtual Type *makeWildConst(); virtual Type *makeSharedWild(); virtual Type *makeSharedWildConst(); - virtual Type *makeMutable(); Type *toBasetype(); virtual unsigned char deduceWild(Type *t, bool isRef); @@ -317,14 +315,12 @@ class TypeNext : public Type int hasWild() const override final; Type *nextOf() override final; - Type *makeImmutable() override final; Type *makeShared() override final; Type *makeSharedConst() override final; Type *makeWild() override final; Type *makeWildConst() override final; Type *makeSharedWild() override final; Type *makeSharedWildConst() override final; - Type *makeMutable() override final; unsigned char deduceWild(Type *t, bool isRef) override final; void transitive(); void accept(Visitor *v) override { v->visit(this); } @@ -823,4 +819,6 @@ namespace dmd Type* memType(TypeEnum* type); unsigned alignsize(Type* type); Type *makeConst(Type* type); + Type* makeMutable(Type* type); + Type* makeImmutable(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index 371fb04325..19c5796e3f 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -67,6 +67,55 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; +private inout(TypeNext) isTypeNext(inout Type _this) +{ + switch(_this.ty) + { + case Tpointer, Treference, Tfunction, Tdelegate, Tslice, Tarray, Taarray, Tsarray: + return cast(typeof(return)) _this; + default: return null; + } +} + +Type makeImmutable(Type _this) +{ + if (_this.mcache && _this.mcache.ito) + return _this.mcache.ito; + Type t = _this.nullAttributes(); + t.mod = MODFlags.immutable_; + + if (auto tn = _this.isTypeNext()) + { + //printf("TypeNext::makeImmutable() %s\n", toChars()); + TypeNext _t = cast(TypeNext) t; + if (tn.ty != Tfunction && tn.next.ty != Tfunction && !tn.next.isImmutable()) + { + _t.next = tn.next.immutableOf(); + } + return _t; + } + return t; +} + +Type makeMutable(Type _this) +{ + Type t = _this.nullAttributes(); + t.mod = _this.mod & MODFlags.shared_; + + if (auto tn = _this.isTypeNext()) + { + //printf("TypeNext::makeMutable() %p, %s\n", this, toChars()); + TypeNext _t = cast(TypeNext)t; + if (tn.ty == Tsarray) + { + _t.next = tn.next.mutableOf(); + } + //printf("TypeNext::makeMutable() returns %p, %s\n", t, t.toChars()); + return _t; + } + return t; +} + Type makeConst(Type _this) { if (_this.mcache && _this.mcache.cto) @@ -109,12 +158,10 @@ Type makeConst(Type _this) return t; } - switch(_this.ty) - { - case Tpointer, Treference, Tfunction, Tdelegate, Tslice, Tarray, Taarray, Tsarray: - return typeNextMakeConst(cast(TypeNext) _this); - default: return defaultMakeConst(_this); - } + if (auto tn = _this.isTypeNext()) + return typeNextMakeConst(tn); + + return defaultMakeConst(_this); } Type toBasetype2(TypeEnum _this) From d33af720abe151d461746429adc10721737531c9 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Fri, 14 Nov 2025 15:22:00 +0800 Subject: [PATCH 087/440] Enable inlining of immutable local delegates (dlang/dmd!22089) --- dmd/inline.d | 152 ++++++++++++-------------- tests/dmd/runnable/imports/inline4a.d | 13 +++ tests/dmd/runnable/inline4.d | 9 ++ 3 files changed, 89 insertions(+), 85 deletions(-) create mode 100644 tests/dmd/runnable/imports/inline4a.d create mode 100644 tests/dmd/runnable/inline4.d diff --git a/dmd/inline.d b/dmd/inline.d index 1b7d82a185..0121dac747 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -1456,14 +1456,8 @@ public: inlineScan(e.e1); arrayInlineScan(e.arguments); - //printf("visitCallExp() %s\n", e.toChars()); - FuncDeclaration fd; - - void inlineFd() + void inlineFd(FuncDeclaration fd) { - if (!fd || fd == parent) - return; - /* If the arguments generate temporaries that need destruction, the destruction * must be done after the function body is executed. * The easiest way to accomplish that is to do the inlining as an Expression. @@ -1490,51 +1484,59 @@ public: } } - /* Pattern match various ASTs looking for indirect function calls, delegate calls, - * function literal calls, delegate literal calls, and dot member calls. - * If so, and that is only assigned its _init. - * If so, do 'copy propagation' of the _init value and try to inline it. - */ - if (auto ve = e.e1.isVarExp()) + FuncDeclaration resolveCallTarget(Expression e, out Expression explicitThis) { - fd = ve.var.isFuncDeclaration(); - if (fd) - // delegate call - inlineFd(); - else + /* Peel exactly one layer of (*fptr)() or (*&f)(). + */ + if (auto pe = e.isPtrExp()) + { + if (pe.e1.isVarExp()) + e = pe.e1; + else if (auto se = pe.e1.isSymOffExp()) + return se.var.isFuncDeclaration(); + else + return null; + } + + /* Pattern match various ASTs looking for indirect function calls, delegate calls, + * function literal calls, delegate literal calls, and dot member calls. + * If so, and that is only assigned its _init. + * If so, do 'copy propagation' of the _init value and try to inline it. + */ + if (auto ve = e.isVarExp()) { - // delegate literal call + if (FuncDeclaration fd = ve.var.isFuncDeclaration()) + return fd; + auto v = ve.var.isVarDeclaration(); - if (v && v._init && v.type.ty == Tdelegate && onlyOneAssign(v, parent)) + if (!v || !v._init || !onlyOneAssign(v, parent)) + return null; + + //printf("init: %s\n", v._init.toChars()); + auto ei = v._init.isExpInitializer(); + if (!ei || (ei.exp.op != EXP.blit && ei.exp.op != EXP.construct)) + return null; + + Expression e2 = (cast(AssignExp)ei.exp).e2; + if (auto se = e2.isSymOffExp()) { - //printf("init: %s\n", v._init.toChars()); - auto ei = v._init.isExpInitializer(); - if (ei && ei.exp.op == EXP.blit) + // function pointer call + return se.var.isFuncDeclaration(); + } + else if (auto fe = e2.isFuncExp()) + { + // function/delegate literal call + return fe.fd; + } + else if (auto de = e2.isDelegateExp()) + { + if (auto ve2 = de.e1.isVarExp()) { - Expression e2 = (cast(AssignExp)ei.exp).e2; - if (auto fe = e2.isFuncExp()) - { - auto fld = fe.fd; - assert(fld.tok == TOK.delegate_); - fd = fld; - inlineFd(); - } - else if (auto de = e2.isDelegateExp()) - { - if (auto ve2 = de.e1.isVarExp()) - { - fd = ve2.var.isFuncDeclaration(); - inlineFd(); - } - } + return ve2.var.isFuncDeclaration(); } } } - } - else if (auto dve = e.e1.isDotVarExp()) - { - fd = dve.var.isFuncDeclaration(); - if (fd && fd != parent && canInline(fd, !fd.isNested(), asStatements, eSink)) + else if (auto dve = e.isDotVarExp()) { if (dve.e1.op == EXP.call && dve.e1.type.toBasetype().ty == Tstruct) { @@ -1542,56 +1544,36 @@ public: * of dve.e1, but this won't work if dve.e1 is * a function call. */ + return null; } - else - { - expandInline(e.loc, fd, parent, eret, dve.e1, e.arguments, asStatements, e.vthis2, eresult, sresult, again); - } + + explicitThis = dve.e1; + return dve.var.isFuncDeclaration(); } - } - else if (e.e1.op == EXP.star && - (cast(PtrExp)e.e1).e1.op == EXP.variable) - { - auto ve = e.e1.isPtrExp().e1.isVarExp(); - VarDeclaration v = ve.var.isVarDeclaration(); - if (v && v._init && onlyOneAssign(v, parent)) + else if (auto fe = e.isFuncExp()) { - //printf("init: %s\n", v._init.toChars()); - auto ei = v._init.isExpInitializer(); - if (ei && ei.exp.op == EXP.blit) - { - Expression e2 = (cast(AssignExp)ei.exp).e2; - // function pointer call - if (auto se = e2.isSymOffExp()) - { - fd = se.var.isFuncDeclaration(); - inlineFd(); - } - // function literal call - else if (auto fe = e2.isFuncExp()) - { - auto fld = fe.fd; - assert(fld.tok == TOK.function_); - fd = fld; - inlineFd(); - } - } + return fe.fd; } + + return null; } - else if (auto fe = e.e1.isFuncExp()) + + //printf("visitCallExp() %s\n", e.toChars()); + Expression explicitThis; + FuncDeclaration fd = resolveCallTarget(e.e1, explicitThis); + + if (!fd || fd == parent) + return; + + if (explicitThis) { - if (fe.fd) - { - fd = fe.fd; - inlineFd(); - } - else + if (!canInline(fd, !fd.isNested(), asStatements, eSink)) return; + + expandInline(e.loc, fd, parent, eret, explicitThis, e.arguments, asStatements, e.vthis2, eresult, sresult, again); } else - { - return; - } + inlineFd(fd); if (global.params.v.verbose && (eresult || sresult)) message("inlined %s =>\n %s", fd.toPrettyChars(), parent.toPrettyChars()); diff --git a/tests/dmd/runnable/imports/inline4a.d b/tests/dmd/runnable/imports/inline4a.d new file mode 100644 index 0000000000..046a3af9d5 --- /dev/null +++ b/tests/dmd/runnable/imports/inline4a.d @@ -0,0 +1,13 @@ +module imports.inline4a; + +pragma(inline, true) +int foo() +{ + return 1; +} + +pragma(inline, true) +auto bar() +{ + return &foo; +} diff --git a/tests/dmd/runnable/inline4.d b/tests/dmd/runnable/inline4.d new file mode 100644 index 0000000000..bda5fcccec --- /dev/null +++ b/tests/dmd/runnable/inline4.d @@ -0,0 +1,9 @@ +import imports.inline4a; + +void main() +{ + immutable baz = () => 1; + assert(foo() == bar()()); + assert(foo() == baz()); + assert(bar()() == baz()); +} From 3c50e186bfc7e0f4a6e4e3ecf9b6c43575883bfe Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 14 Nov 2025 10:00:42 +0200 Subject: [PATCH 088/440] Move `Type.makeShared` and `Type.makeSharedConst` to `typesem` (dlang/dmd!22095) --- dmd/cxxfrontend.d | 12 +++++++++ dmd/frontend.h | 4 --- dmd/mtype.d | 68 ----------------------------------------------- dmd/mtype.h | 6 ++--- dmd/typesem.d | 58 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 76 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index c5a951b435..c8c84ee889 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -959,6 +959,18 @@ Type makeMutable(Type type) return dmd.typesem.makeMutable(type); } +Type makeShared(Type type) +{ + import dmd.typesem; + return dmd.typesem.makeShared(type); +} + +Type makeSharedConst(Type type) +{ + import dmd.typesem; + return dmd.typesem.makeSharedConst(type); +} + /*********************************************************** * typinf.d */ diff --git a/dmd/frontend.h b/dmd/frontend.h index aee3089e42..636297f338 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2091,8 +2091,6 @@ class Type : public ASTNode bool isNaked() const; Type* nullAttributes() const; bool hasDeprecatedAliasThis(); - virtual Type* makeShared(); - virtual Type* makeSharedConst(); virtual Type* makeWild(); virtual Type* makeWildConst(); virtual Type* makeSharedWild(); @@ -4370,8 +4368,6 @@ class TypeNext : public Type Type* next; int32_t hasWild() const final override; Type* nextOf() final override; - Type* makeShared() final override; - Type* makeSharedConst() final override; Type* makeWild() final override; Type* makeWildConst() final override; Type* makeSharedWild() final override; diff --git a/dmd/mtype.d b/dmd/mtype.d index 791f8f419c..756df8d570 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1159,24 +1159,6 @@ extern (C++) abstract class Type : ASTNode return ad && ad.aliasthis && (ad.aliasthis.isDeprecated || ad.aliasthis.sym.isDeprecated); } - Type makeShared() - { - if (mcache && mcache.sto) - return mcache.sto; - Type t = this.nullAttributes(); - t.mod = MODFlags.shared_; - return t; - } - - Type makeSharedConst() - { - if (mcache && mcache.scto) - return mcache.scto; - Type t = this.nullAttributes(); - t.mod = MODFlags.shared_ | MODFlags.const_; - return t; - } - Type makeWild() { if (mcache && mcache.wto) @@ -1505,56 +1487,6 @@ extern (C++) abstract class TypeNext : Type return next; } - override final Type makeShared() - { - //printf("TypeNext::makeShared() %s\n", toChars()); - if (mcache && mcache.sto) - { - assert(mcache.sto.mod == MODFlags.shared_); - return mcache.sto; - } - TypeNext t = cast(TypeNext)Type.makeShared(); - if (ty != Tfunction && next.ty != Tfunction && !next.isImmutable()) - { - if (next.isWild()) - { - if (next.isConst()) - t.next = next.sharedWildConstOf(); - else - t.next = next.sharedWildOf(); - } - else - { - if (next.isConst()) - t.next = next.sharedConstOf(); - else - t.next = next.sharedOf(); - } - } - //printf("TypeNext::makeShared() returns %p, %s\n", t, t.toChars()); - return t; - } - - override final Type makeSharedConst() - { - //printf("TypeNext::makeSharedConst() %s\n", toChars()); - if (mcache && mcache.scto) - { - assert(mcache.scto.mod == (MODFlags.shared_ | MODFlags.const_)); - return mcache.scto; - } - TypeNext t = cast(TypeNext)Type.makeSharedConst(); - if (ty != Tfunction && next.ty != Tfunction && !next.isImmutable()) - { - if (next.isWild()) - t.next = next.sharedWildConstOf(); - else - t.next = next.sharedConstOf(); - } - //printf("TypeNext::makeSharedConst() returns %p, %s\n", t, t.toChars()); - return t; - } - override final Type makeWild() { //printf("TypeNext::makeWild() %s\n", toChars()); diff --git a/dmd/mtype.h b/dmd/mtype.h index 146254e626..fcd4746a67 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -249,8 +249,6 @@ class Type : public ASTNode bool isNaked() const { return mod == 0; } Type *nullAttributes() const; bool hasDeprecatedAliasThis(); - virtual Type *makeShared(); - virtual Type *makeSharedConst(); virtual Type *makeWild(); virtual Type *makeWildConst(); virtual Type *makeSharedWild(); @@ -315,8 +313,6 @@ class TypeNext : public Type int hasWild() const override final; Type *nextOf() override final; - Type *makeShared() override final; - Type *makeSharedConst() override final; Type *makeWild() override final; Type *makeWildConst() override final; Type *makeSharedWild() override final; @@ -821,4 +817,6 @@ namespace dmd Type *makeConst(Type* type); Type* makeMutable(Type* type); Type* makeImmutable(Type* type); + Type* makeShared(Type* type); + Type* makeSharedConst(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index 19c5796e3f..4b5ceaf6b4 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -77,6 +77,64 @@ private inout(TypeNext) isTypeNext(inout Type _this) } } +Type makeSharedConst(Type _this) +{ + if (_this.mcache && _this.mcache.scto) + return _this.mcache.scto; + Type t = _this.nullAttributes(); + t.mod = MODFlags.shared_ | MODFlags.const_; + + if (auto tn = _this.isTypeNext()) + { + //printf("TypeNext::makeSharedConst() %s\n", toChars()); + TypeNext _t = cast(TypeNext) t; + if (tn.ty != Tfunction && tn.next.ty != Tfunction && !tn.next.isImmutable()) + { + if (tn.next.isWild()) + _t.next = tn.next.sharedWildConstOf(); + else + _t.next = tn.next.sharedConstOf(); + } + //printf("TypeNext::makeSharedConst() returns %p, %s\n", t, t.toChars()); + return _t; + } + return t; +} + +Type makeShared(Type _this) +{ + if (_this.mcache && _this.mcache.sto) + return _this.mcache.sto; + Type t = _this.nullAttributes(); + t.mod = MODFlags.shared_; + + if (auto tn = _this.isTypeNext()) + { + //printf("TypeNext::makeShared() %s\n", toChars()); + TypeNext _t = cast(TypeNext) t; + if (tn.ty != Tfunction && tn.next.ty != Tfunction && !tn.next.isImmutable()) + { + if (tn.next.isWild()) + { + if (tn.next.isConst()) + _t.next = tn.next.sharedWildConstOf(); + else + _t.next = tn.next.sharedWildOf(); + } + else + { + if (tn.next.isConst()) + _t.next = tn.next.sharedConstOf(); + else + _t.next = tn.next.sharedOf(); + } + } + //printf("TypeNext::makeShared() returns %p, %s\n", t, t.toChars()); + return _t; + } + return t; +} + Type makeImmutable(Type _this) { if (_this.mcache && _this.mcache.ito) From 8cd854d4fc7229ada095aa0430b356e0c993c20b Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Fri, 14 Nov 2025 17:08:17 +0800 Subject: [PATCH 089/440] Remove dmd.target from expression.d (dlang/dmd!22097) --- dmd/expression.d | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/dmd/expression.d b/dmd/expression.d index a941d4e02c..a5f1207b30 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -40,7 +40,6 @@ import dmd.root.rmem; import dmd.rootobject; import dmd.root.string; import dmd.root.utf; -import dmd.target; import dmd.tokens; import dmd.visitor; @@ -566,6 +565,8 @@ extern (C++) final class IntegerExp : Expression /* 'Normalize' the value of the integer to be in range of the type */ dinteger_t result; + if (ty == Tpointer) + ty = Type.tsize_t.ty; switch (ty) { case Tbool: @@ -607,15 +608,6 @@ extern (C++) final class IntegerExp : Expression result = cast(ulong)value; break; - case Tpointer: - if (target.ptrsize == 8) - goto case Tuns64; - if (target.ptrsize == 4) - goto case Tuns32; - if (target.ptrsize == 2) - goto case Tuns16; - assert(0); - default: break; } From f52b68307bd21a23ac2639bbc56b10d4a243e61f Mon Sep 17 00:00:00 2001 From: Clouudy <90809810+Clouud9@users.noreply.github.com> Date: Thu, 13 Nov 2025 20:23:29 -0500 Subject: [PATCH 090/440] Added documentation to specify that timespec_get is C11. Narrowed POSIX imports. Remove pragma for msvcrt --- runtime/druntime/src/core/sys/posix/stdc/time.d | 6 ++++-- runtime/druntime/src/core/sys/windows/stdc/time.d | 12 +++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/runtime/druntime/src/core/sys/posix/stdc/time.d b/runtime/druntime/src/core/sys/posix/stdc/time.d index f016cd3142..b622874158 100644 --- a/runtime/druntime/src/core/sys/posix/stdc/time.d +++ b/runtime/druntime/src/core/sys/posix/stdc/time.d @@ -1,5 +1,5 @@ /** - * D header file for C99. + * D header file for C99/C11. * * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_time.h.html, _time.h) * @@ -50,10 +50,12 @@ struct tm } public import core.sys.posix.sys.types : time_t, clock_t; -public import core.sys.posix.time; +public import core.sys.posix.time : timespec; +/// timespec_get introduced in C11 int timespec_get(timespec* ts, int base); +/// Base Value used for timespec_get enum TIME_UTC = 1; /// diff --git a/runtime/druntime/src/core/sys/windows/stdc/time.d b/runtime/druntime/src/core/sys/windows/stdc/time.d index 702df7ccd9..1dc00b917e 100644 --- a/runtime/druntime/src/core/sys/windows/stdc/time.d +++ b/runtime/druntime/src/core/sys/windows/stdc/time.d @@ -1,5 +1,5 @@ /** - * D header file for C99. + * D header file for C99/C11. * * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_time.h.html, _time.h) * @@ -58,15 +58,21 @@ void _tzset(); // non-standard /// extern __gshared const(char)*[2] tzname; // non-standard -pragma(lib, "msvcrt"); - +/// timespec, introduced in C11 struct timespec { time_t tv_sec; + // Do not change tv_nsec to a c_long, this causes segfaults long tv_nsec; } +/// Base Value used for timespec_get enum TIME_UTC = 1; +/// 64-bit version of timespec_get for Windows int _timespec64_get(const timespec* ts, int base); + +/// 32-bit version of timespec_get for Windows int _timespec32_get(const timespec* ts, int base); + +/// timespec_get, introduced in C11 alias timespec_get = _timespec64_get; From 1de48b2b6da6037c56d106fd44d829da5aa365bc Mon Sep 17 00:00:00 2001 From: Clouuday <90809810+Clouud9@users.noreply.github.com> Date: Sun, 16 Nov 2025 15:42:36 -0500 Subject: [PATCH 091/440] Added 32 and 64 bit versions of timespec and timespec_get for Windows, instead of the erroneous single implementation. --- .../druntime/src/core/sys/windows/stdc/time.d | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/runtime/druntime/src/core/sys/windows/stdc/time.d b/runtime/druntime/src/core/sys/windows/stdc/time.d index 1dc00b917e..fb8799f18b 100644 --- a/runtime/druntime/src/core/sys/windows/stdc/time.d +++ b/runtime/druntime/src/core/sys/windows/stdc/time.d @@ -58,21 +58,34 @@ void _tzset(); // non-standard /// extern __gshared const(char)*[2] tzname; // non-standard -/// timespec, introduced in C11 -struct timespec { - time_t tv_sec; - // Do not change tv_nsec to a c_long, this causes segfaults - long tv_nsec; + +// timespec functions, introduced in C11 +alias __time64_t = long; +alias __time32_t = int; + +/// 32-bit timespec struct +struct _timespec32 { + __time32_t tv_sec; + c_long tv_nsec; } +/// 64-bit timespec struct +struct _timespec64 { + __time64_t tv_sec; + c_long tv_nsec; +} + +/// Timespec structure, introduced in C11 +alias timespec = _timespec64; + /// Base Value used for timespec_get enum TIME_UTC = 1; /// 64-bit version of timespec_get for Windows -int _timespec64_get(const timespec* ts, int base); +int _timespec64_get(const _timespec64* ts, int base); /// 32-bit version of timespec_get for Windows -int _timespec32_get(const timespec* ts, int base); +int _timespec32_get(const _timespec32* ts, int base); /// timespec_get, introduced in C11 alias timespec_get = _timespec64_get; From f2140bbe303861af3d730cec0380d878606fcd2e Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Mon, 17 Nov 2025 01:49:35 +0200 Subject: [PATCH 092/440] Move `makeWild`, `makeWildConst`, `makeSharedWild`, and `makeSharedWildConst` to `typesem` (dlang/dmd!22103) --- dmd/cxxfrontend.d | 24 +++++++++ dmd/frontend.h | 8 --- dmd/mtype.d | 123 ---------------------------------------------- dmd/mtype.h | 12 ++--- dmd/typesem.d | 103 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 131 insertions(+), 139 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index c8c84ee889..cab2104211 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -971,6 +971,30 @@ Type makeSharedConst(Type type) return dmd.typesem.makeSharedConst(type); } +Type makeWild(Type type) +{ + import dmd.typesem; + return dmd.typesem.makeWild(type); +} + +Type makeWildConst(Type type) +{ + import dmd.typesem; + return dmd.typesem.makeWildConst(type); +} + +Type makeSharedWild(Type type) +{ + import dmd.typesem; + return dmd.typesem.makeSharedWild(type); +} + +Type makeSharedWildConst(Type type) +{ + import dmd.typesem; + return dmd.typesem.makeSharedWildConst(type); +} + /*********************************************************** * typinf.d */ diff --git a/dmd/frontend.h b/dmd/frontend.h index 636297f338..8dcbf41546 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2091,10 +2091,6 @@ class Type : public ASTNode bool isNaked() const; Type* nullAttributes() const; bool hasDeprecatedAliasThis(); - virtual Type* makeWild(); - virtual Type* makeWildConst(); - virtual Type* makeSharedWild(); - virtual Type* makeSharedWildConst(); Type* toBasetype(); virtual uint8_t deduceWild(Type* t, bool isRef); virtual ClassDeclaration* isClassHandle(); @@ -4368,10 +4364,6 @@ class TypeNext : public Type Type* next; int32_t hasWild() const final override; Type* nextOf() final override; - Type* makeWild() final override; - Type* makeWildConst() final override; - Type* makeSharedWild() final override; - Type* makeSharedWildConst() final override; uint8_t deduceWild(Type* t, bool isRef) final override; void transitive(); void accept(Visitor* v) override; diff --git a/dmd/mtype.d b/dmd/mtype.d index 756df8d570..208747b01f 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1159,42 +1159,6 @@ extern (C++) abstract class Type : ASTNode return ad && ad.aliasthis && (ad.aliasthis.isDeprecated || ad.aliasthis.sym.isDeprecated); } - Type makeWild() - { - if (mcache && mcache.wto) - return mcache.wto; - Type t = this.nullAttributes(); - t.mod = MODFlags.wild; - return t; - } - - Type makeWildConst() - { - if (mcache && mcache.wcto) - return mcache.wcto; - Type t = this.nullAttributes(); - t.mod = MODFlags.wildconst; - return t; - } - - Type makeSharedWild() - { - if (mcache && mcache.swto) - return mcache.swto; - Type t = this.nullAttributes(); - t.mod = MODFlags.shared_ | MODFlags.wild; - return t; - } - - Type makeSharedWildConst() - { - if (mcache && mcache.swcto) - return mcache.swcto; - Type t = this.nullAttributes(); - t.mod = MODFlags.shared_ | MODFlags.wildconst; - return t; - } - /******************************* * If this is a shell around another type, * get that other type. @@ -1487,93 +1451,6 @@ extern (C++) abstract class TypeNext : Type return next; } - override final Type makeWild() - { - //printf("TypeNext::makeWild() %s\n", toChars()); - if (mcache && mcache.wto) - { - assert(mcache.wto.mod == MODFlags.wild); - return mcache.wto; - } - TypeNext t = cast(TypeNext)Type.makeWild(); - if (ty != Tfunction && next.ty != Tfunction && !next.isImmutable()) - { - if (next.isShared()) - { - if (next.isConst()) - t.next = next.sharedWildConstOf(); - else - t.next = next.sharedWildOf(); - } - else - { - if (next.isConst()) - t.next = next.wildConstOf(); - else - t.next = next.wildOf(); - } - } - //printf("TypeNext::makeWild() returns %p, %s\n", t, t.toChars()); - return t; - } - - override final Type makeWildConst() - { - //printf("TypeNext::makeWildConst() %s\n", toChars()); - if (mcache && mcache.wcto) - { - assert(mcache.wcto.mod == MODFlags.wildconst); - return mcache.wcto; - } - TypeNext t = cast(TypeNext)Type.makeWildConst(); - if (ty != Tfunction && next.ty != Tfunction && !next.isImmutable()) - { - if (next.isShared()) - t.next = next.sharedWildConstOf(); - else - t.next = next.wildConstOf(); - } - //printf("TypeNext::makeWildConst() returns %p, %s\n", t, t.toChars()); - return t; - } - - override final Type makeSharedWild() - { - //printf("TypeNext::makeSharedWild() %s\n", toChars()); - if (mcache && mcache.swto) - { - assert(mcache.swto.isSharedWild()); - return mcache.swto; - } - TypeNext t = cast(TypeNext)Type.makeSharedWild(); - if (ty != Tfunction && next.ty != Tfunction && !next.isImmutable()) - { - if (next.isConst()) - t.next = next.sharedWildConstOf(); - else - t.next = next.sharedWildOf(); - } - //printf("TypeNext::makeSharedWild() returns %p, %s\n", t, t.toChars()); - return t; - } - - override final Type makeSharedWildConst() - { - //printf("TypeNext::makeSharedWildConst() %s\n", toChars()); - if (mcache && mcache.swcto) - { - assert(mcache.swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); - return mcache.swcto; - } - TypeNext t = cast(TypeNext)Type.makeSharedWildConst(); - if (ty != Tfunction && next.ty != Tfunction && !next.isImmutable()) - { - t.next = next.sharedWildConstOf(); - } - //printf("TypeNext::makeSharedWildConst() returns %p, %s\n", t, t.toChars()); - return t; - } - override final MOD deduceWild(Type t, bool isRef) { if (ty == Tfunction) diff --git a/dmd/mtype.h b/dmd/mtype.h index fcd4746a67..2f9b964eb2 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -249,10 +249,6 @@ class Type : public ASTNode bool isNaked() const { return mod == 0; } Type *nullAttributes() const; bool hasDeprecatedAliasThis(); - virtual Type *makeWild(); - virtual Type *makeWildConst(); - virtual Type *makeSharedWild(); - virtual Type *makeSharedWildConst(); Type *toBasetype(); virtual unsigned char deduceWild(Type *t, bool isRef); @@ -313,10 +309,6 @@ class TypeNext : public Type int hasWild() const override final; Type *nextOf() override final; - Type *makeWild() override final; - Type *makeWildConst() override final; - Type *makeSharedWild() override final; - Type *makeSharedWildConst() override final; unsigned char deduceWild(Type *t, bool isRef) override final; void transitive(); void accept(Visitor *v) override { v->visit(this); } @@ -819,4 +811,8 @@ namespace dmd Type* makeImmutable(Type* type); Type* makeShared(Type* type); Type* makeSharedConst(Type* type); + Type *makeWild(Type* type); + Type *makeWildConst(Type* type); + Type *makeSharedWild(Type* type); + Type *makeSharedWildConst(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index 4b5ceaf6b4..5cc3f89574 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -77,6 +77,109 @@ private inout(TypeNext) isTypeNext(inout Type _this) } } +Type makeSharedWildConst(Type _this) +{ + if (_this.mcache && _this.mcache.swcto) + return _this.mcache.swcto; + Type t = _this.nullAttributes(); + t.mod = MODFlags.shared_ | MODFlags.wildconst; + + if (auto tn = _this.isTypeNext()) + { + //printf("TypeNext::makeSharedWildConst() %s\n", toChars()); + TypeNext _t = cast(TypeNext) t; + if (tn.ty != Tfunction && tn.next.ty != Tfunction && !tn.next.isImmutable()) + { + _t.next = tn.next.sharedWildConstOf(); + } + //printf("TypeNext::makeSharedWildConst() returns %p, %s\n", t, t.toChars()); + return _t; + } + return t; +} + +Type makeSharedWild(Type _this) +{ + if (_this.mcache && _this.mcache.swto) + return _this.mcache.swto; + Type t = _this.nullAttributes(); + t.mod = MODFlags.shared_ | MODFlags.wild; + + if (auto tn = _this.isTypeNext()) + { + //printf("TypeNext::makeSharedWild() %s\n", toChars()); + TypeNext _t = cast(TypeNext) t; + if (tn.ty != Tfunction && tn.next.ty != Tfunction && !tn.next.isImmutable()) + { + if (tn.next.isConst()) + _t.next = tn.next.sharedWildConstOf(); + else + _t.next = tn.next.sharedWildOf(); + } + //printf("TypeNext::makeSharedWild() returns %p, %s\n", t, t.toChars()); + return _t; + } + return t; +} + +Type makeWildConst(Type _this) +{ + if (_this.mcache && _this.mcache.wcto) + return _this.mcache.wcto; + Type t = _this.nullAttributes(); + t.mod = MODFlags.wildconst; + + if (auto tn = _this.isTypeNext()) + { + //printf("TypeNext::makeWildConst() %s\n", toChars()); + TypeNext _t = cast(TypeNext) t; + if (tn.ty != Tfunction && tn.next.ty != Tfunction && !tn.next.isImmutable()) + { + if (tn.next.isShared()) + _t.next = tn.next.sharedWildConstOf(); + else + _t.next = tn.next.wildConstOf(); + } + //printf("TypeNext::makeWildConst() returns %p, %s\n", t, t.toChars()); + return _t; + } + return t; +} + +Type makeWild(Type _this) +{ + if (_this.mcache && _this.mcache.wto) + return _this.mcache.wto; + Type t = _this.nullAttributes(); + t.mod = MODFlags.wild; + + if (auto tn = _this.isTypeNext()) + { + //printf("TypeNext::makeWild() %s\n", toChars()); + TypeNext _t = cast(TypeNext) t; + if (tn.ty != Tfunction && tn.next.ty != Tfunction && !tn.next.isImmutable()) + { + if (tn.next.isShared()) + { + if (tn.next.isConst()) + _t.next = tn.next.sharedWildConstOf(); + else + _t.next = tn.next.sharedWildOf(); + } + else + { + if (tn.next.isConst()) + _t.next = tn.next.wildConstOf(); + else + _t.next = tn.next.wildOf(); + } + } + //printf("TypeNext::makeWild() returns %p, %s\n", t, t.toChars()); + return _t; + } + return t; +} + Type makeSharedConst(Type _this) { if (_this.mcache && _this.mcache.scto) From a5153a4e9b32bae47c7ccc34a10fb189fcf021d8 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Mon, 17 Nov 2025 08:41:27 +0800 Subject: [PATCH 093/440] [parse.d] `parseType`: remove unused `TemplateParameters` arg (dlang/dmd!22104) --- dmd/parse.d | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dmd/parse.d b/dmd/parse.d index 3120eb67fd..6ed157caf7 100644 --- a/dmd/parse.d +++ b/dmd/parse.d @@ -3038,7 +3038,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer } else { - at = parseType(&ai, null, &loc); + at = parseType(&ai, &loc); } ae = null; if (token.value == TOK.assign) // = defaultArg @@ -3211,7 +3211,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer { Ltype: // Type identifier - type = parseType(&ident, null); + type = parseType(&ident); if (type == AST.Type.terror) { type = null; @@ -3578,10 +3578,9 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer /* Parse a type and optional identifier * Params: * pident = set to Identifier if there is one, null if not - * ptpl = if !null, then set to TemplateParameterList * pdeclLoc = if !null, then set to location of the declarator */ - AST.Type parseType(Identifier* pident = null, AST.TemplateParameters** ptpl = null, Loc* pdeclLoc = null) + AST.Type parseType(Identifier* pident = null, Loc* pdeclLoc = null) { /* Take care of the storage class prefixes that * serve as type attributes: @@ -3641,7 +3640,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer if (pdeclLoc) *pdeclLoc = token.loc; int alt = 0; - t = parseDeclarator(t, alt, pident, ptpl); + t = parseDeclarator(t, alt, pident, null); checkCstyleTypeSyntax(typeLoc, t, alt, pident ? *pident : null); t = t.addSTC(stc); From bed9c43879de13c2a202c1e2b8e604ba21ba6ca2 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Mon, 17 Nov 2025 16:30:11 +0800 Subject: [PATCH 094/440] [parse.d] move calls to `addSTC` into `parseType` (dlang/dmd!22105) --- dmd/parse.d | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/dmd/parse.d b/dmd/parse.d index 6ed157caf7..6b1ca8e785 100644 --- a/dmd/parse.d +++ b/dmd/parse.d @@ -3577,10 +3577,18 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer /* Parse a type and optional identifier * Params: - * pident = set to Identifier if there is one, null if not - * pdeclLoc = if !null, then set to location of the declarator + * pident = set to Identifier if there is one, null if not + * pdeclLoc = if !null, then set to location of the declarator + * stc = Storage Class */ - AST.Type parseType(Identifier* pident = null, Loc* pdeclLoc = null) + AST.Type parseType(STC stc) + { + return parseType(null, null, stc); + } + + ///Ditto + AST.Type parseType(Identifier* pident = null, Loc* pdeclLoc = null, + STC stc = STC.none) { /* Take care of the storage class prefixes that * serve as type attributes: @@ -3593,7 +3601,6 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer * shared inout type * shared inout const type */ - STC stc = STC.none; while (1) { switch (token.value) @@ -3822,7 +3829,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer // const(type) nextToken(); check(TOK.leftParenthesis); - t = parseType().addSTC(STC.const_); + t = parseType(STC.const_); check(TOK.rightParenthesis); break; @@ -3830,7 +3837,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer // immutable(type) nextToken(); check(TOK.leftParenthesis); - t = parseType().addSTC(STC.immutable_); + t = parseType(STC.immutable_); check(TOK.rightParenthesis); break; @@ -3838,7 +3845,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer // shared(type) nextToken(); check(TOK.leftParenthesis); - t = parseType().addSTC(STC.shared_); + t = parseType(STC.shared_); check(TOK.rightParenthesis); break; @@ -3846,7 +3853,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer // wild(type) nextToken(); check(TOK.leftParenthesis); - t = parseType().addSTC(STC.wild); + t = parseType(STC.wild); check(TOK.rightParenthesis); break; From b8335dd5c1b2b6391b6ab0fb0ff153ffa4810adf Mon Sep 17 00:00:00 2001 From: Clouuday <90809810+Clouud9@users.noreply.github.com> Date: Tue, 18 Nov 2025 14:00:44 -0500 Subject: [PATCH 095/440] Formatting changes --- runtime/druntime/src/core/sys/windows/stdc/time.d | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/runtime/druntime/src/core/sys/windows/stdc/time.d b/runtime/druntime/src/core/sys/windows/stdc/time.d index fb8799f18b..7cb43b856c 100644 --- a/runtime/druntime/src/core/sys/windows/stdc/time.d +++ b/runtime/druntime/src/core/sys/windows/stdc/time.d @@ -58,19 +58,20 @@ void _tzset(); // non-standard /// extern __gshared const(char)*[2] tzname; // non-standard - // timespec functions, introduced in C11 alias __time64_t = long; alias __time32_t = int; /// 32-bit timespec struct -struct _timespec32 { +struct _timespec32 +{ __time32_t tv_sec; c_long tv_nsec; } /// 64-bit timespec struct -struct _timespec64 { +struct _timespec64 +{ __time64_t tv_sec; c_long tv_nsec; } From bdfb8e3ed36291281a66a8d4a9667ee2f4512292 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Wed, 19 Nov 2025 17:26:05 +0800 Subject: [PATCH 096/440] Fix dlang/dmd!22111 - call move ctor for ref __rvalue returns (dlang/dmd!22112) --- dmd/expressionsem.d | 50 +++++++++++++++++++++++++++++++++++- tests/dmd/runnable/rvalue1.d | 33 ++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 627bc58db2..fe0d3591c2 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -623,6 +623,54 @@ bool isLvalue(Expression _this) } } +/*********************************************************** + * Determine if copy elision is allowed when copying an expression to + * a typed storage. This basically elides a restricted subset of so-called + * "pure" rvalues, i.e. expressions with no reference semantics. + */ +bool canElideCopy(Expression e, Type to, bool checkMod = true) +{ + if (checkMod && !MODimplicitConv(e.type.mod, to.mod)) + return false; + + static bool visitCallExp(CallExp e) + { + if (auto dve = e.e1.isDotVarExp()) + if (dve.var.isCtorDeclaration()) + return true; + + auto tb = e.e1.type.toBasetype(); + if (tb.ty == Tdelegate || tb.ty == Tpointer) + tb = tb.nextOf(); + auto tf = tb.isTypeFunction(); + return tf && !tf.isRef; + } + + switch (e.op) + { + case EXP.call: + return visitCallExp(e.isCallExp()); + case EXP.comma: + auto ce = e.isCommaExp(); + return canElideCopy(ce.e2, to, checkMod); + case EXP.question: + auto ce = e.isCondExp(); + return canElideCopy(ce.e1, to, checkMod) && canElideCopy(ce.e2, to, checkMod); + + case EXP.structLiteral: + return true; + case EXP.dotVariable: + // If an aggregate can be elided, so are its fields + auto dve = e.isDotVarExp(); + auto vd = dve.var.isVarDeclaration(); + return vd && vd.isField() && canElideCopy(dve.e1, dve.e1.type, false); + case EXP.variable: + return (e.isVarExp().var.storage_class & STC.rvalue) != 0; + default: + return false; + } +} + // Return index of the field, or -1 if not found int getFieldIndex(ClassReferenceExp _this, Type fieldtype, uint fieldoffset) { @@ -1723,7 +1771,7 @@ extern (D) Expression doCopyOrMove(Scope* sc, Expression e, Type t, bool nrvo, b { e = callCpCtor(sc, e, t, nrvo); } - else if (move && sd && sd.hasMoveCtor && !e.isCallExp() && !e.isStructLiteralExp()) + else if (move && sd && sd.hasMoveCtor && !canElideCopy(e, t ? t : e.type, false)) { // #move /* Rewrite as: diff --git a/tests/dmd/runnable/rvalue1.d b/tests/dmd/runnable/rvalue1.d index 2592f2a9e9..07f566a8d6 100644 --- a/tests/dmd/runnable/rvalue1.d +++ b/tests/dmd/runnable/rvalue1.d @@ -242,6 +242,37 @@ void test10() assert(s.p.s == "hello"); } +/********************************/ +// https://github.com/dlang/dmd/issues/22111 + +__gshared int copyCount11; +__gshared int moveCount11; +__gshared int dtorCount11; + +struct S11 +{ + int i; + this(S11 rhs) { moveCount11++; } + this(ref S rhs) { copyCount11++; } + ~this() { dtorCount11++; } +} + +__gshared S11 s11obj; + +ref S11 refS11() { return s11obj; } +ref S11 moveS11() __rvalue { return s11obj; } +S11 copyRefS11() { return __rvalue(refS11()); } +S11 copyMoveS11() { return moveS11(); } + +void test11() +{ + copyRefS11(); + assert(copyCount11 == 0 && moveCount11 == 1 && dtorCount11 == 2); + moveCount11 = dtorCount11 = 0; + copyMoveS11(); + assert(copyCount11 == 0 && moveCount11 == 1 && dtorCount11 == 2); +} + /********************************/ int main() @@ -255,6 +286,8 @@ int main() test7(); test8(); test9(); + test10(); + test11(); return 0; } From d2be05f92bd368dbb8e0c3dd9d5ee8db9422a751 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Thu, 20 Nov 2025 06:28:04 +0800 Subject: [PATCH 097/440] Don't elide copy when passing lvalue to value parameters (dlang/dmd!22113) --- tests/dmd/runnable/test22079.d | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/dmd/runnable/test22079.d diff --git a/tests/dmd/runnable/test22079.d b/tests/dmd/runnable/test22079.d new file mode 100644 index 0000000000..a2e676759a --- /dev/null +++ b/tests/dmd/runnable/test22079.d @@ -0,0 +1,18 @@ +struct S { + ~this() {} +} + +__gshared S s = S(); + +ref S refS() { + return s; +} + +void takeS(S s2) { + assert(&s !is &s2); +} + +void main() +{ + takeS(refS()); +} From 18517025c54cbaf1ad2fd510d3a41a5dc1a70d6e Mon Sep 17 00:00:00 2001 From: Clouudy <90809810+Clouud9@users.noreply.github.com> Date: Wed, 19 Nov 2025 19:13:25 -0500 Subject: [PATCH 098/440] Fix timespec_get Windows bindings (dlang/dmd!22115) --- runtime/druntime/src/core/sys/windows/stdc/time.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/druntime/src/core/sys/windows/stdc/time.d b/runtime/druntime/src/core/sys/windows/stdc/time.d index 7cb43b856c..2cf2b5a396 100644 --- a/runtime/druntime/src/core/sys/windows/stdc/time.d +++ b/runtime/druntime/src/core/sys/windows/stdc/time.d @@ -83,10 +83,10 @@ alias timespec = _timespec64; enum TIME_UTC = 1; /// 64-bit version of timespec_get for Windows -int _timespec64_get(const _timespec64* ts, int base); +int _timespec64_get(scope const(_timespec64)* ts, int base); /// 32-bit version of timespec_get for Windows -int _timespec32_get(const _timespec32* ts, int base); +int _timespec32_get(scope const(_timespec32)* ts, int base); /// timespec_get, introduced in C11 alias timespec_get = _timespec64_get; From 13f695bac606bc3701c12fe47ff5ae907832d8cc Mon Sep 17 00:00:00 2001 From: Hiroki Noda <927749+kubo39@users.noreply.github.com> Date: Fri, 21 Nov 2025 00:46:51 +0900 Subject: [PATCH 099/440] Fix Segmentation Fault: `ref return` in struct or class (dlang/dmd!22114) --- dmd/expressionsem.d | 2 +- tests/dmd/compilable/dotvar_ref_return.d | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/compilable/dotvar_ref_return.d diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index fe0d3591c2..433e064990 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -17110,7 +17110,7 @@ Expression toLvalue(Expression _this, Scope* sc, const(char)* action, Expression } if (!_this.isLvalue()) return visit(_this); - if (e1.op == EXP.this_ && sc.ctorflow.fieldinit.length && !(sc.ctorflow.callSuper & CSX.any_ctor)) + if (e1.op == EXP.this_ && sc && sc.ctorflow.fieldinit.length && !(sc.ctorflow.callSuper & CSX.any_ctor)) { if (VarDeclaration vd = var.isVarDeclaration()) { diff --git a/tests/dmd/compilable/dotvar_ref_return.d b/tests/dmd/compilable/dotvar_ref_return.d new file mode 100644 index 0000000000..881368e2a2 --- /dev/null +++ b/tests/dmd/compilable/dotvar_ref_return.d @@ -0,0 +1,11 @@ +// REQUIRED_ARGS: -inline + +struct Foo +{ + int x; + int foo() + { + ref get() { return x; } + return get(); + } +} From 1cb90033ea3dcbf41211dfbf4676f06fb3164c3b Mon Sep 17 00:00:00 2001 From: Clouudy <90809810+Clouud9@users.noreply.github.com> Date: Thu, 20 Nov 2025 18:52:22 -0500 Subject: [PATCH 100/440] Fixed timespec_get annotations (dlang/dmd!22119) * Changed timespec to scope instead of scope const * Added @system on timespec_get implementations --- runtime/druntime/src/core/sys/windows/stdc/time.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/druntime/src/core/sys/windows/stdc/time.d b/runtime/druntime/src/core/sys/windows/stdc/time.d index 2cf2b5a396..c3fa12216c 100644 --- a/runtime/druntime/src/core/sys/windows/stdc/time.d +++ b/runtime/druntime/src/core/sys/windows/stdc/time.d @@ -83,10 +83,10 @@ alias timespec = _timespec64; enum TIME_UTC = 1; /// 64-bit version of timespec_get for Windows -int _timespec64_get(scope const(_timespec64)* ts, int base); +@system int _timespec64_get(scope _timespec64* ts, int base); /// 32-bit version of timespec_get for Windows -int _timespec32_get(scope const(_timespec32)* ts, int base); +@system int _timespec32_get(scope _timespec32* ts, int base); /// timespec_get, introduced in C11 alias timespec_get = _timespec64_get; From 513f142cdc59b7e6689318a766e3d831e9ced1c5 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Fri, 21 Nov 2025 09:57:17 +0800 Subject: [PATCH 101/440] Implement move semantics in inliner (dlang/dmd!22085) --- dmd/inline.d | 86 +++------ tests/dmd/runnable/inline4.d | 354 +++++++++++++++++++++++++++++++++++ tests/dmd/runnable/rvalue1.d | 2 +- 3 files changed, 385 insertions(+), 57 deletions(-) diff --git a/dmd/inline.d b/dmd/inline.d index 0121dac747..75713ce408 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -29,7 +29,7 @@ import dmd.dsymbol; import dmd.dsymbolsem : include, toAlias, toParentP, followInstantiationContext, runDeferredSemantic3; import dmd.dtemplate; import dmd.expression; -import dmd.expressionsem : semanticTypeInfo; +import dmd.expressionsem : canElideCopy, semanticTypeInfo; import dmd.errors : message; import dmd.errorsink; import dmd.func; @@ -153,6 +153,7 @@ private final class InlineDoState FuncDeclaration fd; // function being inlined (old parent) // inline result bool foundReturn; + bool needsCopy; this(Dsymbol parent, FuncDeclaration fd) scope { @@ -368,6 +369,16 @@ public: //printf("ReturnStatement.doInlineAs!%s() '%s'\n", Result.stringof.ptr, s.exp ? s.exp.toChars() : ""); ids.foundReturn = true; + if (!ids.needsCopy && s.exp && s.exp.type.ty == Tstruct) + { + auto tf = ids.fd.type.isTypeFunction(); + if (!ids.fd.isCtorDeclaration() && !ids.fd.nrvo_var && + !tf.isRef && !canElideCopy(s.exp, tf.nextOf())) + { + ids.needsCopy = true; + } + } + auto exp = doInlineAs!Expression(s.exp, ids); if (!exp) // https://issues.dlang.org/show_bug.cgi?id=14560 // 'return' must not leave in the expand result @@ -1475,7 +1486,7 @@ public: if (canInline(fd, parent == fd.toParent2(), asStates, eSink)) { - expandInline(e.loc, fd, parent, eret, null, e.arguments, asStates, e.vthis2, eresult, sresult, again); + expandInline(e, fd, parent, eret, null, asStates, eresult, sresult, again); if (asStatements && eresult) { sresult = new ExpStatement(eresult.loc, eresult); @@ -1570,7 +1581,7 @@ public: if (!canInline(fd, !fd.isNested(), asStatements, eSink)) return; - expandInline(e.loc, fd, parent, eret, explicitThis, e.arguments, asStatements, e.vthis2, eresult, sresult, again); + expandInline(e, fd, parent, eret, explicitThis, asStatements, eresult, sresult, again); } else inlineFd(fd); @@ -2003,22 +2014,20 @@ Lno: * ethis.fd(arguments) * * Params: - * callLoc = location of CallExp + * e = original CallExp * fd = function to expand * parent = function that the call to fd is being expanded into * eret = if !null then the lvalue of where the nrvo return value goes - * ethis = 'this' reference - * arguments = arguments passed to fd * asStatements = expand to Statements rather than Expressions * eresult = if expanding to an expression, this is where the expression is written to * sresult = if expanding to a statement, this is where the statement is written to * again = if true, then fd can be inline scanned again because there may be * more opportunities for inlining */ -private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration parent, Expression eret, - Expression ethis, Expressions* arguments, bool asStatements, VarDeclaration vthis2, - out Expression eresult, out Statement sresult, out bool again) +private void expandInline(CallExp ecall, FuncDeclaration fd, FuncDeclaration parent, Expression eret, + Expression ethis, bool asStatements, out Expression eresult, out Statement sresult, out bool again) { + Loc callLoc = ecall.loc; auto tf = fd.type.isTypeFunction(); static if (LOG || CANINLINE_LOG || EXPANDINLINE_LOG) printf("FuncDeclaration.expandInline('%s', %d)\n", fd.toChars(), asStatements); @@ -2097,6 +2106,7 @@ private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration paren { Expression e0; ethis = Expression.extractLast(ethis, e0); + VarDeclaration vthis2 = ecall.vthis2; assert(vthis2 || !fd.hasDualContext); if (vthis2) { @@ -2135,8 +2145,6 @@ private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration paren vthis = new VarDeclaration(fd.loc, ethis.type, Id.This, ei); if (ethis.type.ty != Tclass) vthis.storage_class = STC.ref_; - else - vthis.storage_class = STC.in_; vthis._linkage = LINK.d; vthis.parent = parent; @@ -2154,13 +2162,13 @@ private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration paren // Set up parameters Expression eparams; - if (arguments && arguments.length) + if (ecall.arguments && ecall.arguments.length) { - assert(fd.parameters.length == arguments.length); - foreach (i; 0 .. arguments.length) + assert(fd.parameters.length == ecall.arguments.length); + foreach (i; 0 .. ecall.arguments.length) { auto vfrom = (*fd.parameters)[i]; - auto arg = (*arguments)[i]; + auto arg = (*ecall.arguments)[i]; auto ei = new ExpInitializer(vfrom.loc, arg); auto vto = new VarDeclaration(vfrom.loc, vfrom.type, vfrom.ident, ei); @@ -2181,6 +2189,9 @@ private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration paren } } + if (arg.rvalue) + vto.storage_class |= STC.ref_; + // Even if vto is STC.lazy_, `vto = arg` is handled correctly in glue layer. ei.exp = new BlitExp(vto.loc, vto, arg); ei.exp.type = vto.type; @@ -2290,8 +2301,7 @@ private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration paren * the returned reference is exactly same as vthis, and the 'this' variable * already exists at the caller side. */ - if (tf.next.ty == Tstruct && !fd.nrvo_var && !fd.isCtorDeclaration() && - !isConstruction(e)) + if (ids.needsCopy) { /* Generate a new variable to hold the result and initialize it with the * inlined body of the function: @@ -2325,6 +2335,9 @@ private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration paren eresult = Expression.combine(eresult, eret, ethis, eparams); eresult = Expression.combine(eresult, e); + if (ecall.rvalue || tf.isRvalue) + eresult.rvalue = true; + static if (EXPANDINLINE_LOG) printf("\n[%s] %s expandInline eresult = %s\n", callLoc.toChars(), fd.toPrettyChars(), eresult.toChars()); @@ -2335,45 +2348,6 @@ private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration paren parent.inlineStatusExp = ILS.uninitialized; } -/**************************************************** - * Determine if the value of `e` is the result of construction. - * - * Params: - * e = expression to check - * Returns: - * true for value generated by a constructor or struct literal - */ -private bool isConstruction(Expression e) -{ - e = lastComma(e); - - if (e.op == EXP.structLiteral) - { - return true; - } - /* Detect: - * structliteral.ctor(args) - */ - else if (e.op == EXP.call) - { - auto ce = cast(CallExp)e; - if (ce.e1.op == EXP.dotVariable) - { - auto dve = cast(DotVarExp)ce.e1; - auto fd = dve.var.isFuncDeclaration(); - if (fd && fd.isCtorDeclaration()) - { - if (dve.e1.op == EXP.structLiteral) - { - return true; - } - } - } - } - return false; -} - - /*********************************************************** * Determine if v is 'head const', meaning * that once it is initialized it is not changed diff --git a/tests/dmd/runnable/inline4.d b/tests/dmd/runnable/inline4.d index bda5fcccec..9de563752c 100644 --- a/tests/dmd/runnable/inline4.d +++ b/tests/dmd/runnable/inline4.d @@ -1,9 +1,363 @@ import imports.inline4a; +struct S +{ + int a; + int b; + int c; + + bool test(int a_, int b_, int c_) inout + { + return a_ == a && b_ == b && c_ == c; + } +} + +__gshared S globalS = S(2, 3, 4); +__gshared S globalS2 = S(); +immutable S immutableS = S(9, 8, 7); + +S getVal() +{ + // Returns by value + return globalS; +} + +ref S getRef() +{ + // Returns by reference + return globalS; +} + +ref S getRefRvalue() __rvalue +{ + // Takes ownership of globalS + return globalS; +} + +S getImmutable() +{ + return immutableS; +} + +__gshared int globalDtorCount; + +struct D +{ + int d; + + this(D rhs) + { + d = rhs.d; + rhs.d = 0xdeadbeef; + } + + this(ref D rhs) + { + d = 12345; + } + + ~this() + { + if (d == 123456) + globalDtorCount++; + d = 0xdeadbeef; + } +} + +__gshared D globalD = D(123456); +__gshared D globalD2 = D(10000); + +void resetD() +{ + globalDtorCount = 0; + globalD.d = 123456; + globalD2.d = 10000; +} + +D getD() +{ + // Returns by value + return globalD; +} + +D getRvalueD() +{ + // Returns by moving globalD, but should not have reference semantics + // Tests if the inliner incorrectly applies reference semantics + return __rvalue(globalD); +} + +ref D getRefD() +{ + // Returns by reference + return globalD; +} + +ref D getRefRvalueD() __rvalue +{ + // Takes ownership of globalS + return globalD; +} + +/************************************/ +// Test inlining of return by value + +S funcVal1() +{ + return getVal(); +} + +S funcVal2() +{ + return getRef(); +} + +S funcVal3() +{ + return getRefRvalue(); +} + +S funcVal4() +{ + return globalS.a ? immutableS : globalS; +} + +S funcVal5() +{ + return globalS.a ? globalS : S(); +} + +D funcVal6() +{ + return getD(); +} + +D funcVal7() +{ + return getRvalueD(); +} + +D funcVal8() +{ + return getRefD(); +} + +D funcVal9() +{ + return getRefRvalueD(); +} + +D funcVal10() +{ + return __rvalue(globalS.a ? globalD : D()); +} + +void consumeD(D d) {} + +void testValueReturn() +{ + // Returning by value should not change the source object + getVal().a++; + assert(globalS.test(2, 3, 4)); + getImmutable().a++; + assert(immutableS.test(9, 8, 7)); + funcVal1().a++; + assert(globalS.test(2, 3, 4)); + funcVal2().c++; + assert(globalS.test(2, 3, 4)); + funcVal3().c++; + assert(globalS.test(2, 3, 4)); + funcVal4().a++; + assert(immutableS.test(9, 8, 7)); + funcVal5().a++; + assert(globalS.test(2, 3, 4)); + + consumeD(getD()); + assert(globalD.d == 123456); + assert(globalDtorCount == 0); + + consumeD(__rvalue(getD())); + assert(globalD.d == 123456); + assert(globalDtorCount == 0); + + consumeD(getRvalueD()); + assert(globalD.d == 0xdeadbeef); + assert(globalDtorCount == 1); + resetD(); + + consumeD(__rvalue(getRvalueD())); + assert(globalD.d == 0xdeadbeef); + assert(globalDtorCount == 1); + resetD(); + + consumeD(funcVal6()); + assert(globalD.d == 123456); + assert(globalDtorCount == 0); + + consumeD(__rvalue(funcVal6())); + assert(globalD.d == 123456); + assert(globalDtorCount == 0); + + consumeD(funcVal7()); + assert(globalD.d == 0xdeadbeef); + assert(globalDtorCount == 1); + resetD(); + + consumeD(__rvalue(funcVal7())); + assert(globalD.d == 0xdeadbeef); + assert(globalDtorCount == 1); + resetD(); + + consumeD(funcVal8()); + assert(globalD.d == 123456); + assert(globalDtorCount == 0); + + consumeD(__rvalue(funcVal8())); + assert(globalD.d == 123456); + assert(globalDtorCount == 0); + + consumeD(funcVal9()); + assert(globalD.d == 0xdeadbeef); + assert(globalDtorCount == 1); + resetD(); + + consumeD(__rvalue(funcVal9())); + assert(globalD.d == 0xdeadbeef); + assert(globalDtorCount == 1); + resetD(); + + consumeD(funcVal10()); + assert(globalD.d == 123456); + assert(globalDtorCount == 0); + + consumeD(__rvalue(funcVal10())); + assert(globalD.d == 123456); + assert(globalDtorCount == 0); +} + + +/************************************/ +// Test inlining of return by reference + +ref S funcRef1() +{ + return getRef(); +} + +ref S funcRef2() +{ + + return globalS.a ? globalS : globalS2; +} + +ref D funcRef3() +{ + return getRefD(); +} + +ref D funcRef4() +{ + return __rvalue(globalS.a ? globalD : globalD2); +} + +void consumeRefD(ref D d) +{ + assert(d.d == 123456); + consumeD(__rvalue(d)); + assert(d.d == 0xdeadbeef); +} + +void testRefReturn() +{ + // Returning by ref should mutate the source object + funcRef1().a++; + assert(globalS.test(3, 3, 4)); + funcRef2().c++; + assert(globalS.test(3, 3, 5)); + + // Passing ref to value parameter should trigger a copy + resetD(); + consumeD(funcRef3()); + assert(globalD.d == 123456); + assert(globalDtorCount == 0); + + // ... but not if there is __rvalue + consumeD(__rvalue(funcRef3())); + assert(globalD.d == 0xdeadbeef); + assert(globalDtorCount == 1); + + // ditto + resetD(); + consumeD(funcRef4()); + assert(globalD.d == 123456); + assert(globalDtorCount == 0); + consumeD(__rvalue(funcRef4())); + assert(globalD.d == 0xdeadbeef); + assert(globalDtorCount == 1); + + resetD(); + consumeRefD(funcRef3()); + + resetD(); + consumeRefD(funcRef4()); +} + +/************************************/ +// Test inlining of return by rvalue reference + +ref S funcRvalueRef1() __rvalue +{ + return getRef(); +} + +ref S funcRvalueRef2() __rvalue +{ + return globalS.a ? globalS : globalS2; +} + +ref D funcRvalueRef3() __rvalue +{ + return getRefD(); +} + +ref D funcRvalueRef4() __rvalue +{ + return globalS.a ? globalD : globalD2; +} + +void consumeRvalueRefD(D d) +{ + assert(d.d == 123456); + consumeD(__rvalue(d)); + assert(d.d == 0xdeadbeef); +} + +void testRvalueRefReturn() +{ + // rvalue ref is ref + funcRvalueRef1().a++; + assert(globalS.test(4, 3, 5)); + funcRvalueRef2().c++; + assert(globalS.test(4, 3, 6)); + + resetD(); + consumeRvalueRefD(funcRvalueRef3()); + + resetD(); + consumeRvalueRefD(funcRvalueRef4()); +} + +/************************************/ + void main() { immutable baz = () => 1; assert(foo() == bar()()); assert(foo() == baz()); assert(bar()() == baz()); + + testValueReturn(); + testRefReturn(); + testRvalueRefReturn(); + } diff --git a/tests/dmd/runnable/rvalue1.d b/tests/dmd/runnable/rvalue1.d index 07f566a8d6..cdc2a1d405 100644 --- a/tests/dmd/runnable/rvalue1.d +++ b/tests/dmd/runnable/rvalue1.d @@ -1,4 +1,4 @@ -/* PERMUTE_ARGS: -preview=rvaluerefparam +/* REQUIRED_ARGS: -preview=rvaluerefparam /* testing __rvalue */ import core.stdc.stdio; From 2921b160829537f778e85f120fc9ac56d59cdea3 Mon Sep 17 00:00:00 2001 From: Paul Backus Date: Thu, 20 Nov 2025 22:40:48 -0500 Subject: [PATCH 102/440] Mark timespec_get as @system (dlang/dmd!22120) This function cannot be @safe or @trusted because it requires its pointer argument to be non-null. It needs an explicit @system attribute because the modules that contain the bindings have a blanket-applied @trusted: attribute at the top. --- runtime/druntime/src/core/sys/posix/stdc/time.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/druntime/src/core/sys/posix/stdc/time.d b/runtime/druntime/src/core/sys/posix/stdc/time.d index b622874158..dee81ecc34 100644 --- a/runtime/druntime/src/core/sys/posix/stdc/time.d +++ b/runtime/druntime/src/core/sys/posix/stdc/time.d @@ -53,7 +53,7 @@ public import core.sys.posix.sys.types : time_t, clock_t; public import core.sys.posix.time : timespec; /// timespec_get introduced in C11 -int timespec_get(timespec* ts, int base); +@system int timespec_get(timespec* ts, int base); /// Base Value used for timespec_get enum TIME_UTC = 1; From f14c25aa4f7946344583041860623abca579bae8 Mon Sep 17 00:00:00 2001 From: "Quirin F. Schroll" Date: Fri, 21 Nov 2025 11:18:59 +0100 Subject: [PATCH 103/440] Fix dlang/dmd!22118 - Allow lambdas with typed `auto ref` parameters --- dmd/expressionsem.d | 2 +- dmd/parse.d | 4 ++++ tests/dmd/compilable/autoreflambda.d | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/compilable/autoreflambda.d diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 433e064990..50c3ad9048 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -7114,7 +7114,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor //printf("td = %p, treq = %p\n", td, fd.treq); if (exp.td) { - assert(exp.td.parameters && exp.td.parameters.length); + assert(exp.td.parameters); exp.td.dsymbolSemantic(sc); exp.type = Type.tvoid; // temporary type diff --git a/dmd/parse.d b/dmd/parse.d index 6b1ca8e785..9851959646 100644 --- a/dmd/parse.d +++ b/dmd/parse.d @@ -2872,6 +2872,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer auto parameters = new AST.Parameters(); VarArg varargs = VarArg.none; STC varargsStc; + bool hasAutoRefParam = false; // Attributes allowed for ... enum VarArgsStc = STC.const_ | STC.immutable_ | STC.shared_ | STC.scope_ | STC.return_ | STC.returnScope | STC.returnRef; @@ -3007,6 +3008,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer } L2: storageClass = appendStorageClass(storageClass, stc); + hasAutoRefParam |= (storageClass & (STC.auto_ | STC.ref_)) == (STC.auto_ | STC.ref_); continue; default: @@ -3038,6 +3040,8 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer } else { + if (tpl && !*tpl && hasAutoRefParam) + *tpl = new AST.TemplateParameters(); at = parseType(&ai, &loc); } ae = null; diff --git a/tests/dmd/compilable/autoreflambda.d b/tests/dmd/compilable/autoreflambda.d new file mode 100644 index 0000000000..a20b273fc0 --- /dev/null +++ b/tests/dmd/compilable/autoreflambda.d @@ -0,0 +1 @@ +alias f = (auto ref int x) {}; From e5552ef7b4d3c48044038895862eca5cb79cc268 Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Sat, 22 Nov 2025 00:32:24 +0100 Subject: [PATCH 104/440] fix regression in dlang/dmd!20863 triggering an assertion if TypeInfo_AssociativeArray is misdefined (dlang/dmd!22126) --- dmd/semantic3.d | 27 +++++++++++++++++--------- tests/dmd/fail_compilation/test20863.d | 23 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 tests/dmd/fail_compilation/test20863.d diff --git a/dmd/semantic3.d b/dmd/semantic3.d index d89413f43f..cd25ac012d 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -1612,6 +1612,10 @@ private extern(C++) final class Semantic3Visitor : Visitor override void visit(TypeInfoAssociativeArrayDeclaration ti) { + if (ti.semanticRun >= PASS.semantic3) + return; + ti.semanticRun = PASS.semantic3; + auto t = ti.tinfo.isTypeAArray(); Loc loc = t.loc; auto sc2 = sc ? sc : ti._scope; @@ -1643,19 +1647,24 @@ private extern(C++) final class Semantic3Visitor : Visitor // generate ti.xtoHash auto hashinst = makeDotExp(Identifier.idPool("aaGetHash")); e = expressionSemantic(hashinst, sc2); - assert(e.isVarExp() && e.type.isTypeFunction()); - ti.xtoHash = e.isVarExp().var; - if (auto tmpl = ti.xtoHash.parent.isTemplateInstance()) - tmpl.minst = sc2._module.importedFrom; // ensure it gets emitted + if (!e.isErrorExp()) + { + assert(e.isVarExp() && e.type.isTypeFunction()); + ti.xtoHash = e.isVarExp().var; + if (auto tmpl = ti.xtoHash.parent.isTemplateInstance()) + tmpl.minst = sc2._module.importedFrom; // ensure it gets emitted + } // generate ti.xopEqual auto equalinst = makeDotExp(Identifier.idPool("aaOpEqual")); e = expressionSemantic(equalinst, sc2); - assert(e.isVarExp() && e.type.isTypeFunction()); - ti.xopEqual = e.isVarExp().var; - if (auto tmpl = ti.xopEqual.parent.isTemplateInstance()) - tmpl.minst = sc2._module.importedFrom; // ensure it gets emitted - + if (!e.isErrorExp()) + { + assert(e.isVarExp() && e.type.isTypeFunction()); + ti.xopEqual = e.isVarExp().var; + if (auto tmpl = ti.xopEqual.parent.isTemplateInstance()) + tmpl.minst = sc2._module.importedFrom; // ensure it gets emitted + } visit(cast(ASTCodegen.TypeInfoDeclaration)ti); } } diff --git a/tests/dmd/fail_compilation/test20863.d b/tests/dmd/fail_compilation/test20863.d new file mode 100644 index 0000000000..2808da50e3 --- /dev/null +++ b/tests/dmd/fail_compilation/test20863.d @@ -0,0 +1,23 @@ +// must not assert/crash with empty declarations +/* TEST_OUTPUT: +--- +fail_compilation\test20863.d(21): Error: no property `Entry` for type `object.TypeInfo_AssociativeArray` +fail_compilation\test20863.d(17): class `TypeInfo_AssociativeArray` defined here +fail_compilation\test20863.d(21): Error: no property `aaGetHash` for type `object.TypeInfo_AssociativeArray` +fail_compilation\test20863.d(17): class `TypeInfo_AssociativeArray` defined here +fail_compilation\test20863.d(21): Error: no property `aaOpEqual` for type `object.TypeInfo_AssociativeArray` +fail_compilation\test20863.d(17): class `TypeInfo_AssociativeArray` defined here +--- +*/ + +module object; + +class Object { } +class TypeInfo { } +class TypeInfo_AssociativeArray { } + +extern(C) int main() +{ + int[int] aa; + return 0; +} From a866f5840436c7d2f7ba1016e68fedff198c8477 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Sun, 23 Nov 2025 21:16:16 +0800 Subject: [PATCH 105/440] Implement an always-inline pass in inliner (dlang/dmd!22122) Do inlining in two stages with `pragma(inline, true)` done first before others done in the second pass --- dmd/dsymbol.d | 4 +- dmd/dsymbol.h | 4 +- dmd/frontend.h | 4 +- dmd/inline.d | 191 +++++++++++++------- dmd/main.d | 19 +- tests/dmd/runnable/imports/inline4a.d | 13 -- tests/dmd/runnable/imports/pragmainline_a.d | 39 ++++ tests/dmd/runnable/inline4.d | 8 - tests/dmd/runnable/pragmainline.d | 53 ++++++ 9 files changed, 242 insertions(+), 93 deletions(-) delete mode 100644 tests/dmd/runnable/imports/inline4a.d create mode 100644 tests/dmd/runnable/imports/pragmainline_a.d create mode 100644 tests/dmd/runnable/pragmainline.d diff --git a/dmd/dsymbol.d b/dmd/dsymbol.d index 55484cec1c..7eaba6e0cd 100644 --- a/dmd/dsymbol.d +++ b/dmd/dsymbol.d @@ -175,8 +175,8 @@ enum PASS : ubyte semantic2done, // semantic2() done semantic3, // semantic3() started semantic3done, // semantic3() done - inline, // inline started - inlinedone, // inline done + inlinePragma, // inline pragma(inline, true) functions started + inlineAll, // inline all functions started obj, // toObjFile() run } diff --git a/dmd/dsymbol.h b/dmd/dsymbol.h index 862f070aa3..fdf1aa60f5 100644 --- a/dmd/dsymbol.h +++ b/dmd/dsymbol.h @@ -138,8 +138,8 @@ enum class PASS : uint8_t semantic2done, // semantic2() done semantic3, // semantic3() started semantic3done, // semantic3() done - inline_, // inline started - inlinedone, // inline done + inlinePragma, // inline pragma(inline, true) functions started + inlineAll, // inline all functions started obj // toObjFile() run }; diff --git a/dmd/frontend.h b/dmd/frontend.h index 8dcbf41546..ca02d65934 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -429,8 +429,8 @@ enum class PASS : uint8_t semantic2done = 4u, semantic3 = 5u, semantic3done = 6u, - inline_ = 7u, - inlinedone = 8u, + inlinePragma = 7u, + inlineAll = 8u, obj = 9u, }; diff --git a/dmd/inline.d b/dmd/inline.d index 75713ce408..7aa94484fb 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -52,39 +52,34 @@ import dmd.visitor.postorder; import dmd.inlinecost; /*********************************************************** - * Scan function implementations in Module m looking for functions that can be inlined, + * Scan for always-inline functions in Module m to be inlined, * and inline them in situ. * * Params: * m = module to scan * eSink = where to report errors */ -public void inlineScanModule(Module m, ErrorSink eSink) +public void inlineScanPragmaInline(Module m, ErrorSink eSink) { if (m.semanticRun != PASS.semantic3done) return; - m.semanticRun = PASS.inline; - - // Note that modules get their own scope, from scratch. - // This is so regardless of where in the syntax a module - // gets imported, it is unaffected by context. - //printf("Module = %p\n", m.sc.scopesym); - - foreach (i; 0 .. m.members.length) - { - Dsymbol s = (*m.members)[i]; - //if (global.params.v.verbose) - // message("inline scan symbol %s", s.toChars()); - inlineScanDsymbol(s, eSink); - } - m.semanticRun = PASS.inlinedone; + inlineScanModule(m, PASS.inlinePragma, eSink); } -private void inlineScanDsymbol(Dsymbol s, ErrorSink eSink) +/*********************************************************** + * Scan all functions in Module m and try to inline them in situ. + * + * Params: + * m = module to scan + * eSink = where to report errors + */ +public void inlineScanAllFunctions(Module m, ErrorSink eSink) { - scope InlineScanVisitorDsymbol v = new InlineScanVisitorDsymbol(eSink); - s.accept(v); + if (m.semanticRun != PASS.semantic3done && m.semanticRun != PASS.inlinePragma) + return; + + inlineScanModule(m, PASS.inlineAll, eSink); } /*********************************************************** @@ -1037,20 +1032,32 @@ private Result doInlineAs(Result)(Expression e, InlineDoState ids) private extern (C++) final class InlineScanVisitor : Visitor { alias visit = Visitor.visit; + public: FuncDeclaration parent; // function being scanned + PASS pass; + ErrorSink eSink; + // As the visit method cannot return a value, these variables // are used to pass the result from 'visit' back to 'inlineScan' Statement sresult; Expression eresult; - ErrorSink eSink; bool again; - extern (D) this(ErrorSink eSink) scope @safe + extern (D) this(FuncDeclaration parent, PASS pass, ErrorSink eSink) scope @safe { + this.parent = parent; + this.pass = pass; this.eSink = eSink; } + void reset() + { + sresult = null; + eresult = null; + again = false; + } + override void visit(Statement s) { } @@ -1301,17 +1308,19 @@ public: { } - void scanVar(Dsymbol s) + override void visit(DeclarationExp e) { - //printf("scanVar(%s %s)\n", s.kind(), s.toPrettyChars()); - if (VarDeclaration vd = s.isVarDeclaration()) + if (VarDeclaration vd = e.declaration.isVarDeclaration()) { if (TupleDeclaration td = vd.toAlias().isTupleDeclaration()) { - td.foreachVar((s) + foreach (o; *td.objects) { - scanVar(s); // TODO - }); + if (auto te = o.isExpression()) + { + inlineScan(te); + } + } } else if (vd._init) { @@ -1321,16 +1330,6 @@ public: } } } - else - { - inlineScanDsymbol(s, eSink); - } - } - - override void visit(DeclarationExp e) - { - //printf("DeclarationExp.inlineScan() %s\n", e.toChars()); - scanVar(e.declaration); } override void visit(UnaExp e) @@ -1477,14 +1476,14 @@ public: bool asStates = asStatements; if (asStates) { - if (fd.inlineStatusExp == ILS.yes) + if (fd.semanticRun == pass && fd.inlineStatusExp == ILS.yes) asStates = false; // inline as expressions // so no need to recompute argumentsNeedDtors() else if (argumentsNeedDtors(e.arguments)) asStates = false; } - if (canInline(fd, parent == fd.toParent2(), asStates, eSink)) + if (canInline(fd, parent == fd.toParent2(), asStates, pass, eSink)) { expandInline(e, fd, parent, eret, null, asStates, eresult, sresult, again); if (asStatements && eresult) @@ -1578,7 +1577,7 @@ public: if (explicitThis) { - if (!canInline(fd, !fd.isNested(), asStatements, eSink)) + if (!canInline(fd, !fd.isNested(), asStatements, pass, eSink)) return; expandInline(e, fd, parent, eret, explicitThis, asStatements, eresult, sresult, again); @@ -1681,11 +1680,14 @@ public: private extern (C++) final class InlineScanVisitorDsymbol : Visitor { alias visit = Visitor.visit; + public: + PASS pass; ErrorSink eSink; - extern (D) this(ErrorSink eSink) scope @safe + extern (D) this(PASS pass, ErrorSink eSink) scope @safe { + this.pass = pass; this.eSink = eSink; } @@ -1703,33 +1705,53 @@ public: { printf("FuncDeclaration.inlineScan('%s')\n", fd.toPrettyChars()); } - if (!(global.params.useInline || fd.hasAlwaysInlines)) + + if (!fd.fbody || fd.isNaked || fd.skipCodegen) return; - if (fd.isUnitTestDeclaration() && !global.params.useUnitTests || fd.inlineScanned) + + if (fd.semanticRun < PASS.semantic3done) + return; + + if (fd.semanticRun == pass && fd.inlineScanned) return; - if (fd.fbody && !fd.isNaked) + + if (fd.isUnitTestDeclaration() && !global.params.useUnitTests) + return; + + if (!fd.hasAlwaysInlines && pass == PASS.inlinePragma) + return; + + if (fd.semanticRun != pass) { - while (1) - { - fd.inlineNest++; - fd.inlineScanned = true; + fd.inlineStatusExp = ILS.uninitialized; + fd.inlineStatusStmt = ILS.uninitialized; + } + + fd.inlineScanned = true; + fd.semanticRun = pass; - scope InlineScanVisitor v = new InlineScanVisitor(eSink); - v.parent = fd; - v.inlineScan(fd.fbody); - bool again = v.again; + scope InlineScanVisitor v = new InlineScanVisitor(fd, pass, eSink); - fd.inlineNest--; - if (!again) - break; + do + { + fd.inlineNest++; + v.reset(); + v.inlineScan(fd.fbody); + fd.inlineNest--; + } while (v.again); + + if (fd.localsymtab) + { + foreach (keyValue; fd.localsymtab.tab.asRange) + { + keyValue.value.accept(this); } } } override void visit(AttribDeclaration d) { - Dsymbols* decls = d.include(null); - if (decls) + if (Dsymbols* decls = d.include(null)) { foreach (i; 0 .. decls.length) { @@ -1771,6 +1793,36 @@ public: } } +/*********************************************************** + * Scan function implementations in Module m looking for functions that can be inlined, + * and inline them in situ. + * + * Params: + * m = module to scan + * pass = the current pass (inline1 or inline2) + * eSink = where to report errors + */ +private void inlineScanModule(Module m, PASS pass, ErrorSink eSink) +{ + assert(pass == PASS.inlinePragma || pass == PASS.inlineAll); + + // Note that modules get their own scope, from scratch. + // This is so regardless of where in the syntax a module + // gets imported, it is unaffected by context. + + //printf("Module = %p\n", m.sc.scopesym); + + scope v = new InlineScanVisitorDsymbol(pass, eSink); + + foreach (i; 0 .. m.members.length) + { + Dsymbol s = (*m.members)[i]; + s.accept(v); + } + + m.semanticRun = pass; +} + /*********************************************************** * Test that `fd` can be inlined. * @@ -1784,7 +1836,7 @@ public: * Returns: * true if the function body can be expanded. */ -private bool canInline(FuncDeclaration fd, bool hasThis, bool statementsToo, ErrorSink eSink) +private bool canInline(FuncDeclaration fd, bool hasThis, bool statementsToo, PASS pass, ErrorSink eSink) { int cost; @@ -1821,6 +1873,15 @@ private bool canInline(FuncDeclaration fd, bool hasThis, bool statementsToo, Err if (fd.skipCodegen) return false; + // Reset ILS if the decision was made in another pass + if (fd.semanticRun != pass) + { + fd.inlineScanned = false; + fd.inlineStatusExp = ILS.uninitialized; + fd.inlineStatusStmt = ILS.uninitialized; + fd.semanticRun = pass; + } + final switch (statementsToo ? fd.inlineStatusStmt : fd.inlineStatusExp) { case ILS.yes: @@ -1842,7 +1903,7 @@ private bool canInline(FuncDeclaration fd, bool hasThis, bool statementsToo, Err final switch (fd.inlining) { case PINLINE.default_: - if (!global.params.useInline) + if (pass != PASS.inlineAll) return false; break; case PINLINE.always: @@ -1965,7 +2026,10 @@ private bool canInline(FuncDeclaration fd, bool hasThis, bool statementsToo, Err else fd.inlineStatusExp = ILS.yes; - inlineScanDsymbol(fd, eSink); + { + scope v = new InlineScanVisitorDsymbol(pass, eSink); + fd.accept(v); + } if (fd.inlineStatusExp == ILS.uninitialized) { @@ -1994,8 +2058,11 @@ private bool canInline(FuncDeclaration fd, bool hasThis, bool statementsToo, Err return true; Lno: - if (fd.inlining == PINLINE.always && global.params.useWarnings == DiagnosticReporting.inform) + if (fd.inlining == PINLINE.always && pass == PASS.inlinePragma && + global.params.useWarnings == DiagnosticReporting.inform) + { eSink.warning(fd.loc, "cannot inline function `%s`", fd.toPrettyChars()); + } if (statementsToo) fd.inlineStatusStmt = ILS.no; diff --git a/dmd/main.d b/dmd/main.d index 74aadb482f..edb150bc5c 100644 --- a/dmd/main.d +++ b/dmd/main.d @@ -661,14 +661,25 @@ private int tryMain(const(char)[][] argv, out Param params) if (global.errors) removeHdrFilesAndFail(params, modules); - // Scan for functions to inline + // Scan for modules with always inline functions foreach (m; modules) { - if (params.useInline || m.hasAlwaysInlines) + if (m.hasAlwaysInlines) { if (params.v.verbose) - message("inline scan %s", m.toChars()); - inlineScanModule(m, global.errorSink); + message("scan pragma(inline) in %s", m.toChars()); + inlineScanPragmaInline(m, global.errorSink); + } + } + + if (params.useInline) + { + // Scan for functions to inline + foreach (m; modules) + { + if (params.v.verbose) + message("scan all inlines in %s", m.toChars()); + inlineScanAllFunctions(m, global.errorSink); } } diff --git a/tests/dmd/runnable/imports/inline4a.d b/tests/dmd/runnable/imports/inline4a.d deleted file mode 100644 index 046a3af9d5..0000000000 --- a/tests/dmd/runnable/imports/inline4a.d +++ /dev/null @@ -1,13 +0,0 @@ -module imports.inline4a; - -pragma(inline, true) -int foo() -{ - return 1; -} - -pragma(inline, true) -auto bar() -{ - return &foo; -} diff --git a/tests/dmd/runnable/imports/pragmainline_a.d b/tests/dmd/runnable/imports/pragmainline_a.d new file mode 100644 index 0000000000..f8d2480bc0 --- /dev/null +++ b/tests/dmd/runnable/imports/pragmainline_a.d @@ -0,0 +1,39 @@ +module imports.pragmainline_a; + +pragma(inline, true) +int foo() +{ + return 1; +} + +pragma(inline, true) +auto bar() +{ + return &foo; +} + +mixin template LengthField(alias sym) +{ + pragma(inline, true) + size_t length() const + { + return sym.length; + } +} + +struct Data +{ + string data; + mixin LengthField!data; + + pragma(inline, true) + int opApply(scope int delegate(const Data) dg) { + return dg(this); + } +} + +pragma(inline, true) +int value() +{ + return 10; +} diff --git a/tests/dmd/runnable/inline4.d b/tests/dmd/runnable/inline4.d index 9de563752c..141509fd97 100644 --- a/tests/dmd/runnable/inline4.d +++ b/tests/dmd/runnable/inline4.d @@ -1,5 +1,3 @@ -import imports.inline4a; - struct S { int a; @@ -351,13 +349,7 @@ void testRvalueRefReturn() void main() { - immutable baz = () => 1; - assert(foo() == bar()()); - assert(foo() == baz()); - assert(bar()() == baz()); - testValueReturn(); testRefReturn(); testRvalueRefReturn(); - } diff --git a/tests/dmd/runnable/pragmainline.d b/tests/dmd/runnable/pragmainline.d new file mode 100644 index 0000000000..6db0767460 --- /dev/null +++ b/tests/dmd/runnable/pragmainline.d @@ -0,0 +1,53 @@ +// REQUIRED_ARGS: -wi +/* TEST_OUTPUT: +--- +--- +*/ + + +import imports.pragmainline_a; + +auto anonclass() +{ + return new class { + pragma(inline, true) + final size_t foo() + { + return value(); + } + }; +} + +auto testAlwaysInline() +{ + size_t var; + + foreach (d; Data("string")) + { + var = d.length(); + } + + assert(var == 6); + + var = anonclass().foo(); + + assert(var == 10); + + auto nested = (size_t i) { + return i - value(); + }; + + var = nested(var); + + assert(var == 0); +} + +void main() +{ + immutable baz = () => 1; + assert(foo() == bar()()); + assert(foo() == baz()); + assert(bar()() == baz()); + + testAlwaysInline(); +} From 08812b340faff330a5dd6c51a1649961711652f0 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sun, 23 Nov 2025 22:17:16 +0200 Subject: [PATCH 106/440] Move `Type.isIntegral` to `typesem` (dlang/dmd!22130) --- dmd/constfold.d | 2 +- dmd/cxxfrontend.d | 6 ++++++ dmd/dinterpret.d | 2 +- dmd/frontend.h | 4 ---- dmd/intrange.d | 1 + dmd/mtype.d | 22 ---------------------- dmd/mtype.h | 5 +---- dmd/target.d | 2 +- dmd/typesem.d | 11 +++++++++++ 9 files changed, 22 insertions(+), 33 deletions(-) diff --git a/dmd/constfold.d b/dmd/constfold.d index 801c7e0dce..042225c97d 100644 --- a/dmd/constfold.d +++ b/dmd/constfold.d @@ -37,7 +37,7 @@ import dmd.root.utf; import dmd.sideeffect; import dmd.target; import dmd.tokens; -import dmd.typesem : toDsymbol, equivalent, sarrayOf, size; +import dmd.typesem : toDsymbol, equivalent, sarrayOf, size, isIntegral; private enum LOG = false; diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index cab2104211..a32d3d08c7 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -995,6 +995,12 @@ Type makeSharedWildConst(Type type) return dmd.typesem.makeSharedWildConst(type); } +bool isIntegral(Type type) +{ + import dmd.typesem; + return dmd.typesem.isIntegral(type); +} + /*********************************************************** * typinf.d */ diff --git a/dmd/dinterpret.d b/dmd/dinterpret.d index 9ae091b66b..3f266d40b9 100644 --- a/dmd/dinterpret.d +++ b/dmd/dinterpret.d @@ -51,7 +51,7 @@ import dmd.root.utf; import dmd.statement; import dmd.semantic2 : findFunc; import dmd.tokens; -import dmd.typesem : mutableOf, equivalent, pointerTo, sarrayOf, arrayOf, size, merge, defaultInitLiteral; +import dmd.typesem : mutableOf, equivalent, pointerTo, sarrayOf, arrayOf, size, merge, defaultInitLiteral, isIntegral; import dmd.utils : arrayCastBigEndian; import dmd.visitor; diff --git a/dmd/frontend.h b/dmd/frontend.h index ca02d65934..7c9e8b72ba 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2070,7 +2070,6 @@ class Type : public ASTNode static void deinitialize(); void modToBuffer(OutBuffer& buf) const; char* modToChars() const; - virtual bool isIntegral(); virtual bool isFloating(); virtual bool isReal(); virtual bool isImaginary(); @@ -4394,7 +4393,6 @@ class TypeBasic final : public Type uint32_t flags; const char* kind() const override; TypeBasic* syntaxCopy() override; - bool isIntegral() override; bool isFloating() override; bool isReal() override; bool isImaginary() override; @@ -4456,7 +4454,6 @@ class TypeEnum final : public Type EnumDeclaration* sym; const char* kind() const override; TypeEnum* syntaxCopy() override; - bool isIntegral() override; bool isFloating() override; bool isReal() override; bool isImaginary() override; @@ -4786,7 +4783,6 @@ class TypeVector final : public Type static TypeVector* create(Type* basetype); const char* kind() const override; TypeVector* syntaxCopy() override; - bool isIntegral() override; bool isFloating() override; bool isScalar() override; bool isUnsigned() override; diff --git a/dmd/intrange.d b/dmd/intrange.d index f68e302f74..ec303797a8 100644 --- a/dmd/intrange.d +++ b/dmd/intrange.d @@ -16,6 +16,7 @@ import core.stdc.stdio; import dmd.astenums : Tdchar; import dmd.mtype : Type; import dmd.globals : uinteger_t; +import dmd.typesem : isIntegral; private uinteger_t copySign(uinteger_t x, bool sign) @safe { diff --git a/dmd/mtype.d b/dmd/mtype.d index 208747b01f..2da7291e2e 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -632,11 +632,6 @@ extern (C++) abstract class Type : ASTNode return buf.extractChars(); } - bool isIntegral() - { - return false; - } - // real, imaginary, or complex bool isFloating() { @@ -1640,12 +1635,6 @@ extern (C++) final class TypeBasic : Type return this; } - override bool isIntegral() - { - //printf("TypeBasic::isIntegral('%s') x%x\n", toChars(), flags); - return (flags & TFlags.integral) != 0; - } - override bool isFloating() { return (flags & TFlags.floating) != 0; @@ -1719,12 +1708,6 @@ extern (C++) final class TypeVector : Type return new TypeVector(basetype.syntaxCopy()); } - override bool isIntegral() - { - //printf("TypeVector::isIntegral('%s') x%x\n", toChars(), flags); - return basetype.nextOf().isIntegral(); - } - override bool isFloating() { return basetype.nextOf().isFloating(); @@ -2637,11 +2620,6 @@ extern (C++) final class TypeEnum : Type return this; } - override bool isIntegral() - { - return this.memType().isIntegral(); - } - override bool isFloating() { return this.memType().isFloating(); diff --git a/dmd/mtype.h b/dmd/mtype.h index 2f9b964eb2..3815a332f9 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -228,7 +228,6 @@ class Type : public ASTNode void modToBuffer(OutBuffer& buf) const; char *modToChars() const; - virtual bool isIntegral(); virtual bool isFloating(); // real, imaginary, or complex virtual bool isReal(); virtual bool isImaginary(); @@ -322,7 +321,6 @@ class TypeBasic final : public Type const char *kind() override; TypeBasic *syntaxCopy() override; - bool isIntegral() override; bool isFloating() override; bool isReal() override; bool isImaginary() override; @@ -343,7 +341,6 @@ class TypeVector final : public Type static TypeVector *create(Type *basetype); const char *kind() override; TypeVector *syntaxCopy() override; - bool isIntegral() override; bool isFloating() override; bool isScalar() override; bool isUnsigned() override; @@ -668,7 +665,6 @@ class TypeEnum final : public Type const char *kind() override; TypeEnum *syntaxCopy() override; - bool isIntegral() override; bool isFloating() override; bool isReal() override; bool isImaginary() override; @@ -815,4 +811,5 @@ namespace dmd Type *makeWildConst(Type* type); Type *makeSharedWild(Type* type); Type *makeSharedWildConst(Type* type); + bool isIntegral(Type* type); } diff --git a/dmd/target.d b/dmd/target.d index 6dbf77a315..5471f86c89 100644 --- a/dmd/target.d +++ b/dmd/target.d @@ -314,7 +314,7 @@ extern (C++) struct Target import dmd.location; import dmd.astenums : LINK, TY; import dmd.mtype : Type, TypeFunction, TypeTuple; - import dmd.typesem : pointerTo, size; + import dmd.typesem : pointerTo, size, isIntegral; import dmd.root.ctfloat : real_t; import dmd.statement : Statement; import dmd.tokens : EXP; diff --git a/dmd/typesem.d b/dmd/typesem.d index 5cc3f89574..d18b34a56d 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -77,6 +77,17 @@ private inout(TypeNext) isTypeNext(inout Type _this) } } +bool isIntegral(Type _this) +{ + if (auto tb = _this.isTypeBasic()) + return (tb.flags & TFlags.integral) != 0; + else if (auto tv = _this.isTypeVector()) + return tv.basetype.nextOf().isIntegral(); + else if (auto te = _this.isTypeEnum()) + return te.memType().isIntegral(); + return false; +} + Type makeSharedWildConst(Type _this) { if (_this.mcache && _this.mcache.swcto) From 4d9e24aa9cf941c2496446aad0c818bd9b387d54 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Mon, 24 Nov 2025 01:03:40 +0200 Subject: [PATCH 107/440] Move `Expression.toImaginary` to `expressionsem` (dlang/dmd!22131) --- dmd/constfold.d | 2 +- dmd/ctfeexpr.d | 2 +- dmd/cxxfrontend.d | 6 ++++++ dmd/expression.d | 21 --------------------- dmd/expression.h | 5 +---- dmd/expressionsem.d | 13 +++++++++++++ dmd/frontend.h | 4 ---- dmd/mangle/package.d | 2 +- 8 files changed, 23 insertions(+), 32 deletions(-) diff --git a/dmd/constfold.d b/dmd/constfold.d index 042225c97d..b07e1a4bbd 100644 --- a/dmd/constfold.d +++ b/dmd/constfold.d @@ -25,7 +25,7 @@ import dmd.declaration; import dmd.dstruct; import dmd.errors; import dmd.expression; -import dmd.expressionsem : getField, isIdentical, toBool, toInteger, toUInteger, toReal, toComplex; +import dmd.expressionsem; import dmd.globals; import dmd.location; import dmd.mtype; diff --git a/dmd/ctfeexpr.d b/dmd/ctfeexpr.d index 1f9984c0d6..8087db2d25 100644 --- a/dmd/ctfeexpr.d +++ b/dmd/ctfeexpr.d @@ -25,7 +25,7 @@ import dmd.dstruct; import dmd.dtemplate; import dmd.errors; import dmd.expression; -import dmd.expressionsem : isIdentical, getFieldIndex, toBool, toStringExp, toInteger, toReal, toComplex; +import dmd.expressionsem; import dmd.func; import dmd.globals : dinteger_t, sinteger_t, uinteger_t; import dmd.location; diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index a32d3d08c7..004bc3fcb6 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -462,6 +462,12 @@ complex_t toComplex(Expression exp) return dmd.expressionsem.toComplex(exp); } +real_t toImaginary(Expression exp) +{ + import dmd.expressionsem; + return dmd.expressionsem.toImaginary(exp); +} + /*********************************************************** * func.d */ diff --git a/dmd/expression.d b/dmd/expression.d index a5f1207b30..1359051736 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -293,12 +293,6 @@ extern (C++) abstract class Expression : ASTNode return a; } - real_t toImaginary() - { - error(loc, "floating point constant expression expected instead of `%s`", toChars()); - return CTFloat.zero; - } - /**************************************** * Check that the expression has a valid type. * If not, generates an error "... has no type". @@ -540,11 +534,6 @@ extern (C++) final class IntegerExp : Expression return new IntegerExp(loc, value, type); } - override real_t toImaginary() - { - return CTFloat.zero; - } - override void accept(Visitor v) { v.visit(this); @@ -740,11 +729,6 @@ extern (C++) final class RealExp : Expression return new RealExp(loc, value, type); } - override real_t toImaginary() - { - return type.isReal() ? CTFloat.zero : value; - } - override void accept(Visitor v) { v.visit(this); @@ -771,11 +755,6 @@ extern (C++) final class ComplexExp : Expression return new ComplexExp(loc, value, type); } - override real_t toImaginary() - { - return cimagl(value); - } - override void accept(Visitor v) { v.visit(this); diff --git a/dmd/expression.h b/dmd/expression.h index 6add11d615..09bf8e7f0e 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -69,6 +69,7 @@ namespace dmd dinteger_t toInteger(Expression *exp); uinteger_t toUInteger(Expression *exp); real_t toReal(Expression *exp); + real_t toImaginary(Expression *exp); complex_t toComplex(Expression *exp); } @@ -105,7 +106,6 @@ class Expression : public ASTNode const char* toChars() const final override; - virtual real_t toImaginary(); virtual bool checkType(); Expression *addressOf(); Expression *deref(); @@ -238,7 +238,6 @@ class IntegerExp final : public Expression dinteger_t value; static IntegerExp *create(Loc loc, dinteger_t value, Type *type); - real_t toImaginary() override; void accept(Visitor *v) override { v->visit(this); } dinteger_t getInteger() { return value; } template @@ -259,7 +258,6 @@ class RealExp final : public Expression real_t value; static RealExp *create(Loc loc, real_t value, Type *type); - real_t toImaginary() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -269,7 +267,6 @@ class ComplexExp final : public Expression complex_t value; static ComplexExp *create(Loc loc, complex_t value, Type *type); - real_t toImaginary() override; void accept(Visitor *v) override { v->visit(this); } }; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 433e064990..6767054b40 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -100,6 +100,19 @@ import dmd.visitor.postorder; enum LOGSEMANTIC = false; +real_t toImaginary(Expression _this) +{ + if (auto ie = _this.isIntegerExp()) + return CTFloat.zero; + else if (auto re = _this.isRealExp) + return re.type.isReal() ? CTFloat.zero : re.value; + else if (auto ce = _this.isComplexExp()) + return cimagl(ce.value); + + error(_this.loc, "floating point constant expression expected instead of `%s`", _this.toChars()); + return CTFloat.zero; +} + real_t toReal(Expression _this) { if (auto iexp = _this.isIntegerExp()) diff --git a/dmd/frontend.h b/dmd/frontend.h index 7c9e8b72ba..c0c61b48a5 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2327,7 +2327,6 @@ class Expression : public ASTNode virtual Expression* syntaxCopy(); DYNCAST dyncast() const final override; const char* toChars() const final override; - virtual _d_real toImaginary(); virtual bool checkType(); Expression* deref(); int32_t isConst(); @@ -2707,7 +2706,6 @@ class ComplexExp final : public Expression public: complex_t value; static ComplexExp* create(Loc loc, complex_t value, Type* type); - _d_real toImaginary() override; void accept(Visitor* v) override; }; @@ -3180,7 +3178,6 @@ class IntegerExp final : public Expression public: dinteger_t value; static IntegerExp* create(Loc loc, dinteger_t value, Type* type); - _d_real toImaginary() override; void accept(Visitor* v) override; dinteger_t getInteger(); IntegerExp* syntaxCopy() override; @@ -3406,7 +3403,6 @@ class RealExp final : public Expression public: _d_real value; static RealExp* create(Loc loc, _d_real value, Type* type); - _d_real toImaginary() override; void accept(Visitor* v) override; }; diff --git a/dmd/mangle/package.d b/dmd/mangle/package.d index df88465bd0..8b68ac87a4 100644 --- a/dmd/mangle/package.d +++ b/dmd/mangle/package.d @@ -146,7 +146,7 @@ import dmd.dinterpret; import dmd.dmodule; import dmd.dsymbol; import dmd.dsymbolsem : toAlias; -import dmd.expressionsem : toInteger, toReal; +import dmd.expressionsem : toInteger, toReal, toImaginary; import dmd.dtemplate; import dmd.errors; import dmd.expression; From 26d388a0c9d880b310d129f27513d42c37c50340 Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Mon, 24 Nov 2025 10:01:23 +0100 Subject: [PATCH 108/440] AA: don't require TypeInfo if compiling without it (dlang/dmd!22137) --- runtime/druntime/src/core/internal/newaa.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/druntime/src/core/internal/newaa.d b/runtime/druntime/src/core/internal/newaa.d index ea37bfe677..55bc16e5e8 100644 --- a/runtime/druntime/src/core/internal/newaa.d +++ b/runtime/druntime/src/core/internal/newaa.d @@ -226,7 +226,8 @@ private: firstUsed = cast(uint) buckets.length; // only for binary compatibility - entryTI = typeid(Entry!(K, V)); + version(D_TypeInfo) + entryTI = typeid(Entry!(K, V)); hashFn = delegate size_t (scope ref const K key) nothrow pure @nogc @safe { return pure_hashOf!K(key); }; From 2de8b5c4c0f8eda4198cb0257754759d6cba827b Mon Sep 17 00:00:00 2001 From: Emmanuel Nyarko <57257441+Emmankoko@users.noreply.github.com> Date: Mon, 24 Nov 2025 09:13:53 +0000 Subject: [PATCH 109/440] fix dlang/dmd!21925 importC: symbol duplication in symbol table for global redeclared symbols (dlang/dmd!22003) --- dmd/importc.d | 4 ++++ tests/dmd/runnable/fix21925.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/dmd/runnable/fix21925.c diff --git a/dmd/importc.d b/dmd/importc.d index e652d56187..db16ce763d 100644 --- a/dmd/importc.d +++ b/dmd/importc.d @@ -520,6 +520,10 @@ Dsymbol handleSymbolRedeclarations(ref Scope sc, Dsymbol s, Dsymbol s2, ScopeDsy sds.symtab.update(vd); // replace vd2 with the definition return vd; } + else if (!i1 && !(vd2.storage_class & STC.extern_)) /* incoming has void void definition */ + { + vd.storage_class |= STC.extern_; + } /* BUG: the types should match, which needs semantic() to be run on it * extern int x; diff --git a/tests/dmd/runnable/fix21925.c b/tests/dmd/runnable/fix21925.c new file mode 100644 index 0000000000..b3e8d0a89b --- /dev/null +++ b/tests/dmd/runnable/fix21925.c @@ -0,0 +1,14 @@ +//https://github.com/dlang/dmd/issues/21925 + +#include +int a; +int a; +int a; +int a; +int a; + + +int main() +{ + assert(a == 0); // no duplicate symbol error +} From bcc666a4e9d6240d7d819d59a67a27a88a56e53c Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Mon, 24 Nov 2025 16:36:23 +0200 Subject: [PATCH 110/440] Move `Type.isFloating` and `Type.isReal` to `typesem` (dlang/dmd!22133) --- dmd/builtin.d | 1 + dmd/constfold.d | 2 +- dmd/cxxfrontend.d | 12 ++++++++++++ dmd/dfa/utils.d | 1 + dmd/dinterpret.d | 2 +- dmd/frontend.h | 7 ------- dmd/mtype.d | 36 ------------------------------------ dmd/mtype.h | 9 ++------- dmd/target.d | 2 +- dmd/typesem.d | 21 +++++++++++++++++++++ 10 files changed, 40 insertions(+), 53 deletions(-) diff --git a/dmd/builtin.d b/dmd/builtin.d index 5581b0dda3..3f814244e0 100644 --- a/dmd/builtin.d +++ b/dmd/builtin.d @@ -18,6 +18,7 @@ import dmd.astenums; import dmd.errors; import dmd.expression; import dmd.expressionsem : toInteger, toReal; +import dmd.typesem : isFloating; import dmd.func; import dmd.location; import dmd.mangle; diff --git a/dmd/constfold.d b/dmd/constfold.d index b07e1a4bbd..d7db3c3bf3 100644 --- a/dmd/constfold.d +++ b/dmd/constfold.d @@ -37,7 +37,7 @@ import dmd.root.utf; import dmd.sideeffect; import dmd.target; import dmd.tokens; -import dmd.typesem : toDsymbol, equivalent, sarrayOf, size, isIntegral; +import dmd.typesem; private enum LOG = false; diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 004bc3fcb6..b34672f498 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -1007,6 +1007,18 @@ bool isIntegral(Type type) return dmd.typesem.isIntegral(type); } +bool isFloating(Type type) +{ + import dmd.typesem; + return dmd.typesem.isFloating(type); +} + +bool isReal(Type type) +{ + import dmd.typesem; + return dmd.typesem.isReal(type); +} + /*********************************************************** * typinf.d */ diff --git a/dmd/dfa/utils.d b/dmd/dfa/utils.d index 89679e22c3..f5909162df 100644 --- a/dmd/dfa/utils.d +++ b/dmd/dfa/utils.d @@ -15,6 +15,7 @@ import dmd.mtype; import dmd.visitor; import dmd.identifier; import dmd.expression; +import dmd.typesem : isFloating; bool isTypeNullable(Type type) { diff --git a/dmd/dinterpret.d b/dmd/dinterpret.d index 3f266d40b9..61088e02bb 100644 --- a/dmd/dinterpret.d +++ b/dmd/dinterpret.d @@ -51,7 +51,7 @@ import dmd.root.utf; import dmd.statement; import dmd.semantic2 : findFunc; import dmd.tokens; -import dmd.typesem : mutableOf, equivalent, pointerTo, sarrayOf, arrayOf, size, merge, defaultInitLiteral, isIntegral; +import dmd.typesem; import dmd.utils : arrayCastBigEndian; import dmd.visitor; diff --git a/dmd/frontend.h b/dmd/frontend.h index c0c61b48a5..c301b7729b 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2070,8 +2070,6 @@ class Type : public ASTNode static void deinitialize(); void modToBuffer(OutBuffer& buf) const; char* modToChars() const; - virtual bool isFloating(); - virtual bool isReal(); virtual bool isImaginary(); virtual bool isComplex(); virtual bool isScalar(); @@ -4389,8 +4387,6 @@ class TypeBasic final : public Type uint32_t flags; const char* kind() const override; TypeBasic* syntaxCopy() override; - bool isFloating() override; - bool isReal() override; bool isImaginary() override; bool isComplex() override; bool isScalar() override; @@ -4450,8 +4446,6 @@ class TypeEnum final : public Type EnumDeclaration* sym; const char* kind() const override; TypeEnum* syntaxCopy() override; - bool isFloating() override; - bool isReal() override; bool isImaginary() override; bool isComplex() override; bool isScalar() override; @@ -4779,7 +4773,6 @@ class TypeVector final : public Type static TypeVector* create(Type* basetype); const char* kind() const override; TypeVector* syntaxCopy() override; - bool isFloating() override; bool isScalar() override; bool isUnsigned() override; bool isBoolean() override; diff --git a/dmd/mtype.d b/dmd/mtype.d index 2da7291e2e..f81693bf70 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -632,17 +632,6 @@ extern (C++) abstract class Type : ASTNode return buf.extractChars(); } - // real, imaginary, or complex - bool isFloating() - { - return false; - } - - bool isReal() - { - return false; - } - bool isImaginary() { return false; @@ -1635,16 +1624,6 @@ extern (C++) final class TypeBasic : Type return this; } - override bool isFloating() - { - return (flags & TFlags.floating) != 0; - } - - override bool isReal() - { - return (flags & TFlags.real_) != 0; - } - override bool isImaginary() { return (flags & TFlags.imaginary) != 0; @@ -1708,11 +1687,6 @@ extern (C++) final class TypeVector : Type return new TypeVector(basetype.syntaxCopy()); } - override bool isFloating() - { - return basetype.nextOf().isFloating(); - } - override bool isScalar() { return basetype.nextOf().isScalar(); @@ -2620,16 +2594,6 @@ extern (C++) final class TypeEnum : Type return this; } - override bool isFloating() - { - return this.memType().isFloating(); - } - - override bool isReal() - { - return this.memType().isReal(); - } - override bool isImaginary() { return this.memType().isImaginary(); diff --git a/dmd/mtype.h b/dmd/mtype.h index 3815a332f9..f0a760977f 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -228,8 +228,6 @@ class Type : public ASTNode void modToBuffer(OutBuffer& buf) const; char *modToChars() const; - virtual bool isFloating(); // real, imaginary, or complex - virtual bool isReal(); virtual bool isImaginary(); virtual bool isComplex(); virtual bool isScalar(); @@ -321,8 +319,6 @@ class TypeBasic final : public Type const char *kind() override; TypeBasic *syntaxCopy() override; - bool isFloating() override; - bool isReal() override; bool isImaginary() override; bool isComplex() override; bool isScalar() override; @@ -341,7 +337,6 @@ class TypeVector final : public Type static TypeVector *create(Type *basetype); const char *kind() override; TypeVector *syntaxCopy() override; - bool isFloating() override; bool isScalar() override; bool isUnsigned() override; bool isBoolean() override; @@ -665,8 +660,6 @@ class TypeEnum final : public Type const char *kind() override; TypeEnum *syntaxCopy() override; - bool isFloating() override; - bool isReal() override; bool isImaginary() override; bool isComplex() override; bool isScalar() override; @@ -812,4 +805,6 @@ namespace dmd Type *makeSharedWild(Type* type); Type *makeSharedWildConst(Type* type); bool isIntegral(Type* type); + bool isFloating(Type* type); + bool isReal(Type* type); } diff --git a/dmd/target.d b/dmd/target.d index 5471f86c89..2a4edec85b 100644 --- a/dmd/target.d +++ b/dmd/target.d @@ -314,7 +314,7 @@ extern (C++) struct Target import dmd.location; import dmd.astenums : LINK, TY; import dmd.mtype : Type, TypeFunction, TypeTuple; - import dmd.typesem : pointerTo, size, isIntegral; + import dmd.typesem; import dmd.root.ctfloat : real_t; import dmd.statement : Statement; import dmd.tokens : EXP; diff --git a/dmd/typesem.d b/dmd/typesem.d index d18b34a56d..22e49367cc 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -77,6 +77,27 @@ private inout(TypeNext) isTypeNext(inout Type _this) } } +bool isReal(Type _this) +{ + if (auto tb = _this.isTypeBasic()) + return (tb.flags & TFlags.real_) != 0; + else if (auto te = _this.isTypeEnum()) + return te.memType().isReal(); + return false; +} + +// real, imaginary, or complex +bool isFloating(Type _this) +{ + if (auto tb = _this.isTypeBasic()) + return (tb.flags & TFlags.floating) != 0; + else if (auto tv = _this.isTypeVector()) + return tv.basetype.nextOf().isFloating(); + else if (auto te = _this.isTypeEnum()) + return te.memType().isFloating(); + return false; +} + bool isIntegral(Type _this) { if (auto tb = _this.isTypeBasic()) From d0d6c147e6f4bd096be05205fb80e5d072270b01 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Mon, 24 Nov 2025 22:06:33 +0100 Subject: [PATCH 111/440] declaration: Change xopEqual/xtoHash AST type to Declaration (dlang/dmd!22142) --- dmd/declaration.d | 4 ++-- dmd/declaration.h | 4 ++-- dmd/frontend.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dmd/declaration.d b/dmd/declaration.d index 8b5ead130e..1275baf72e 100644 --- a/dmd/declaration.d +++ b/dmd/declaration.d @@ -949,8 +949,8 @@ extern (C++) final class TypeInfoStaticArrayDeclaration : TypeInfoDeclaration extern (C++) final class TypeInfoAssociativeArrayDeclaration : TypeInfoDeclaration { Type entry; // type of TypeInfo_AssociativeArray.Entry!(t.index, t.next) - Dsymbol xopEqual; // implementation of TypeInfo_AssociativeArray.equals - Dsymbol xtoHash; // implementation of TypeInfo_AssociativeArray.getHash + Declaration xopEqual; // implementation of TypeInfo_AssociativeArray.equals + Declaration xtoHash; // implementation of TypeInfo_AssociativeArray.getHash extern (D) this(Type tinfo) { diff --git a/dmd/declaration.h b/dmd/declaration.h index 9c55180483..bd0ffd1c63 100644 --- a/dmd/declaration.h +++ b/dmd/declaration.h @@ -385,8 +385,8 @@ class TypeInfoAssociativeArrayDeclaration final : public TypeInfoDeclaration { public: Type* entry; - Dsymbol* xopEqual; - Dsymbol* xtoHash; + Declaration* xopEqual; + Declaration* xtoHash; static TypeInfoAssociativeArrayDeclaration *create(Type *tinfo); diff --git a/dmd/frontend.h b/dmd/frontend.h index c301b7729b..f4fe6f09fd 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -6826,8 +6826,8 @@ class TypeInfoAssociativeArrayDeclaration final : public TypeInfoDeclaration { public: Type* entry; - Dsymbol* xopEqual; - Dsymbol* xtoHash; + Declaration* xopEqual; + Declaration* xtoHash; static TypeInfoAssociativeArrayDeclaration* create(Type* tinfo); void accept(Visitor* v) override; }; From ea18a535f529cfab7b6158daf5e6935e9438aadc Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Mon, 24 Nov 2025 22:11:12 +0100 Subject: [PATCH 112/440] semantic3: Fix more assertions if TypeInfo_AssociativeArray is misdefined (dlang/dmd!22143) --- dmd/semantic3.d | 35 ++++++++++++++++++------- tests/dmd/fail_compilation/test20863.d | 23 ---------------- tests/dmd/fail_compilation/test20863a.d | 23 ++++++++++++++++ tests/dmd/fail_compilation/test20863b.d | 25 ++++++++++++++++++ 4 files changed, 73 insertions(+), 33 deletions(-) delete mode 100644 tests/dmd/fail_compilation/test20863.d create mode 100644 tests/dmd/fail_compilation/test20863a.d create mode 100644 tests/dmd/fail_compilation/test20863b.d diff --git a/dmd/semantic3.d b/dmd/semantic3.d index cd25ac012d..93f73eefa9 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -1631,6 +1631,11 @@ private extern(C++) final class Semantic3Visitor : Visitor return new DotTemplateInstanceExp(loc, id, hook, tiargs); } + void notTemplateFunction(Loc loc, Identifier id) + { + error(loc, "`%s` isn't a template function", id.toChars()); + } + // generate ti.entry auto tempinst = makeDotExp(Id.Entry); auto e = expressionSemantic(tempinst, sc2); @@ -1645,25 +1650,35 @@ private extern(C++) final class Semantic3Visitor : Visitor semanticTypeInfo(sc2, ti.entry); // might get deferred // generate ti.xtoHash - auto hashinst = makeDotExp(Identifier.idPool("aaGetHash")); + auto aaGetHash = Identifier.idPool("aaGetHash"); + auto hashinst = makeDotExp(aaGetHash); e = expressionSemantic(hashinst, sc2); if (!e.isErrorExp()) { - assert(e.isVarExp() && e.type.isTypeFunction()); - ti.xtoHash = e.isVarExp().var; - if (auto tmpl = ti.xtoHash.parent.isTemplateInstance()) - tmpl.minst = sc2._module.importedFrom; // ensure it gets emitted + if (!e.isVarExp() || !e.type.isTypeFunction()) + notTemplateFunction(e.loc, aaGetHash); + else + { + ti.xtoHash = e.isVarExp().var; + if (auto tmpl = ti.xtoHash.parent.isTemplateInstance()) + tmpl.minst = sc2._module.importedFrom; // ensure it gets emitted + } } // generate ti.xopEqual - auto equalinst = makeDotExp(Identifier.idPool("aaOpEqual")); + auto aaOpEqual = Identifier.idPool("aaOpEqual"); + auto equalinst = makeDotExp(aaOpEqual); e = expressionSemantic(equalinst, sc2); if (!e.isErrorExp()) { - assert(e.isVarExp() && e.type.isTypeFunction()); - ti.xopEqual = e.isVarExp().var; - if (auto tmpl = ti.xopEqual.parent.isTemplateInstance()) - tmpl.minst = sc2._module.importedFrom; // ensure it gets emitted + if (!e.isVarExp() || !e.type.isTypeFunction()) + notTemplateFunction(e.loc, aaOpEqual); + else + { + ti.xopEqual = e.isVarExp().var; + if (auto tmpl = ti.xopEqual.parent.isTemplateInstance()) + tmpl.minst = sc2._module.importedFrom; // ensure it gets emitted + } } visit(cast(ASTCodegen.TypeInfoDeclaration)ti); } diff --git a/tests/dmd/fail_compilation/test20863.d b/tests/dmd/fail_compilation/test20863.d deleted file mode 100644 index 2808da50e3..0000000000 --- a/tests/dmd/fail_compilation/test20863.d +++ /dev/null @@ -1,23 +0,0 @@ -// must not assert/crash with empty declarations -/* TEST_OUTPUT: ---- -fail_compilation\test20863.d(21): Error: no property `Entry` for type `object.TypeInfo_AssociativeArray` -fail_compilation\test20863.d(17): class `TypeInfo_AssociativeArray` defined here -fail_compilation\test20863.d(21): Error: no property `aaGetHash` for type `object.TypeInfo_AssociativeArray` -fail_compilation\test20863.d(17): class `TypeInfo_AssociativeArray` defined here -fail_compilation\test20863.d(21): Error: no property `aaOpEqual` for type `object.TypeInfo_AssociativeArray` -fail_compilation\test20863.d(17): class `TypeInfo_AssociativeArray` defined here ---- -*/ - -module object; - -class Object { } -class TypeInfo { } -class TypeInfo_AssociativeArray { } - -extern(C) int main() -{ - int[int] aa; - return 0; -} diff --git a/tests/dmd/fail_compilation/test20863a.d b/tests/dmd/fail_compilation/test20863a.d new file mode 100644 index 0000000000..545b436a66 --- /dev/null +++ b/tests/dmd/fail_compilation/test20863a.d @@ -0,0 +1,23 @@ +// must not assert/crash with empty declarations +/* TEST_OUTPUT: +--- +fail_compilation/test20863a.d(21): Error: no property `Entry` for type `object.TypeInfo_AssociativeArray` +fail_compilation/test20863a.d(17): class `TypeInfo_AssociativeArray` defined here +fail_compilation/test20863a.d(21): Error: no property `aaGetHash` for type `object.TypeInfo_AssociativeArray` +fail_compilation/test20863a.d(17): class `TypeInfo_AssociativeArray` defined here +fail_compilation/test20863a.d(21): Error: no property `aaOpEqual` for type `object.TypeInfo_AssociativeArray` +fail_compilation/test20863a.d(17): class `TypeInfo_AssociativeArray` defined here +--- +*/ + +module object; + +class Object { } +class TypeInfo { } +class TypeInfo_AssociativeArray { } + +extern(C) int main() +{ + int[int] aa; + return 0; +} diff --git a/tests/dmd/fail_compilation/test20863b.d b/tests/dmd/fail_compilation/test20863b.d new file mode 100644 index 0000000000..27a1dbefd7 --- /dev/null +++ b/tests/dmd/fail_compilation/test20863b.d @@ -0,0 +1,25 @@ +// must not assert/crash with mismatched declarations +/* TEST_OUTPUT: +--- +fail_compilation/test20863b.d(23): Error: `Entry` isn't a template +fail_compilation/test20863b.d(23): Error: `aaGetHash` isn't a template function +fail_compilation/test20863b.d(23): Error: `aaOpEqual` isn't a template function +--- +*/ + +module object; + +class Object { } +class TypeInfo { } +class TypeInfo_AssociativeArray +{ + int Entry; + struct aaOpEqual(K, V) { } + struct aaGetHash(K, V) { } +} + +extern(C) int main() +{ + int[int] aa; + return 0; +} From 639070d8dc05b35958a4b8654046921c43194467 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Mon, 24 Nov 2025 22:12:29 +0100 Subject: [PATCH 113/440] C++: Add dmd::printInstantiationTrace to compiler interface (dlang/dmd!22139) --- dmd/cxxfrontend.d | 5 +++++ dmd/template.h | 1 + 2 files changed, 6 insertions(+) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index b34672f498..29e659a6dd 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -354,6 +354,11 @@ void printTemplateStats(bool listInstances, ErrorSink eSink) return dmd.dtemplate.printTemplateStats(listInstances, eSink); } +void printInstantiationTrace(TemplateInstance ti) +{ + return ti.printInstantiationTrace(); +} + /*********************************************************** * dtoh.d */ diff --git a/dmd/template.h b/dmd/template.h index f0fba2b8d1..c38a630d7c 100644 --- a/dmd/template.h +++ b/dmd/template.h @@ -293,5 +293,6 @@ namespace dmd TemplateParameter *isTemplateParameter(RootObject *o); bool isError(const RootObject *const o); void printTemplateStats(bool listInstances, ErrorSink* eSink); + void printInstantiationTrace(TemplateInstance *ti); bool declareParameter(TemplateParameter *tp, Scope *sc); } From f8cf3cef7b8155c747c87ebfcb38251712e80dce Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Wed, 26 Nov 2025 13:22:12 -0800 Subject: [PATCH 114/440] fix dlang/dmd!22069 Backend tail recursion optimization is broken (dlang/dmd!22146) --- tests/dmd/runnable/issue22069.d | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/dmd/runnable/issue22069.d diff --git a/tests/dmd/runnable/issue22069.d b/tests/dmd/runnable/issue22069.d new file mode 100644 index 0000000000..41a94a9b1e --- /dev/null +++ b/tests/dmd/runnable/issue22069.d @@ -0,0 +1,27 @@ +// REQUIRED_ARGS: -O +// https://github.com/dlang/dmd/issues/22069 + +int recurse(int* i) +{ + L1: + int j = 0; + int* p = &j; + + if (*i) + { + return recurse(p); + } + else + { + if (p is i) + assert(0); + else + return j; + } +} + +void main() +{ + int i = 1; + recurse(&i); +} From d1224a1d78c5b047b7d8f5b21e341ec9783e498e Mon Sep 17 00:00:00 2001 From: limepoutine Date: Fri, 28 Nov 2025 15:57:50 +0800 Subject: [PATCH 115/440] Fix dlang#22134 - do not elide mutable pointers to data segment (dlang/dmd!22151) --- dmd/expressionsem.d | 3 ++- tests/dmd/runnable/structlit_rvalue.d | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/runnable/structlit_rvalue.d diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 6767054b40..96e27542dd 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -671,7 +671,8 @@ bool canElideCopy(Expression e, Type to, bool checkMod = true) return canElideCopy(ce.e1, to, checkMod) && canElideCopy(ce.e2, to, checkMod); case EXP.structLiteral: - return true; + auto sle = e.isStructLiteralExp(); + return !(checkMod && sle.useStaticInit && to.isMutable()); case EXP.dotVariable: // If an aggregate can be elided, so are its fields auto dve = e.isDotVarExp(); diff --git a/tests/dmd/runnable/structlit_rvalue.d b/tests/dmd/runnable/structlit_rvalue.d new file mode 100644 index 0000000000..c8f63c71f3 --- /dev/null +++ b/tests/dmd/runnable/structlit_rvalue.d @@ -0,0 +1,15 @@ +void refCounted(ProcessPipes val) +{ + val = ProcessPipes.init; +} + +struct ProcessPipes +{ + char[33] arr; + ~this() @safe {} +} + +void main() +{ + refCounted(ProcessPipes.init); +} From e977f63fbc87ff06629218d40342323d1159456e Mon Sep 17 00:00:00 2001 From: Emmanuel Nyarko <57257441+Emmankoko@users.noreply.github.com> Date: Fri, 28 Nov 2025 14:36:12 +0000 Subject: [PATCH 116/440] provide builtin impls (dlang/dmd!22102) --- runtime/druntime/src/__importc_builtins.di | 233 +++++++++++++++++++++ 1 file changed, 233 insertions(+) diff --git a/runtime/druntime/src/__importc_builtins.di b/runtime/druntime/src/__importc_builtins.di index e1ba543008..574bc0b37f 100644 --- a/runtime/druntime/src/__importc_builtins.di +++ b/runtime/druntime/src/__importc_builtins.di @@ -12,6 +12,9 @@ module __builtins; +import core.stdc.config : c_long, c_ulong; +import core.checkedint : adds, subs, muls; + /* gcc relies on internal __builtin_xxxx functions and templates to * accomplish . D does the same thing with templates in core.stdc.stdarg. * Here, we redirect the gcc builtin declarations to the equivalent @@ -118,3 +121,233 @@ version (CRuntime_Glibc) version (AArch64) alias __Float32x4_t = __vector(float[4]); alias __Float64x2_t = __vector(double[2]); } + +// https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html + +private bool overflowOp(alias op, T1, T2, T3)(T1 a, T2 b, ref T3 res) +{ + bool overflow = false; + res = op(a, b, overflow); + return overflow; +} + +private T builtin_opc(alias op, T)(T a, T b, T carry_in, ref T carry_out) +{ + carry_out = op(a, b, a) | op(a, carry_in, a); + return a; +} + +pragma(inline, true) +{ + bool __builtin_add_overflow(T1, T2, T3)(T1 a, T2 b, T3* res) => overflowOp!(adds, T1, T2, T3)(a, b, *res); + bool __builtin_sub_overflow(T1, T2, T3)(T1 a, T2 b, T3* res) => overflowOp!(subs, T1, T2, T3)(a, b, *res); + bool __builtin_mul_overflow(T1, T2, T3)(T1 a, T2 b, T3* res) => overflowOp!(muls, T1, T2, T3)(a, b, *res); + bool __builtin_add_overflow_p(T1, T2, T3)(T1 a, T2 b, T3 c) => overflowOp!(adds, T1, T2, T3)(a, b, res); + bool __builtin_sub_overflow_p(T1, T2, T3)(T1 a, T2 b, T3 c) => overflowOp!(subs, T1, T2, T3)(a, b, res); + bool __builtin_mul_overflow_p(T1, T2, T3)(T1 a, T2 b, T3 c) => overflowOp!(muls, T1, T2, T3)(a, b, res); + bool __builtin_sadd_overflow ()(int a, int b, int* res) => overflowOp!(adds, int , int , int )(a, b, *res); + bool __builtin_saddl_overflow ()(c_long a, c_long b, c_long* res) => overflowOp!(adds, c_long , c_long , c_long )(a, b, *res); + bool __builtin_saddll_overflow()(long a, long b, long* res) => overflowOp!(adds, long , long , long )(a, b, *res); + bool __builtin_uadd_overflow ()(uint a, uint b, uint* res) => overflowOp!(adds, uint , uint , uint )(a, b, *res); + bool __builtin_uaddl_overflow ()(c_ulong a, c_ulong b, c_ulong* res) => overflowOp!(adds, c_ulong, c_ulong, c_ulong)(a, b, *res); + bool __builtin_uaddll_overflow()(ulong a, ulong b, ulong* res) => overflowOp!(adds, ulong , ulong , ulong )(a, b, *res); + bool __builtin_ssub_overflow ()(int a, int b, int* res) => overflowOp!(subs, int , int , int )(a, b, *res); + bool __builtin_ssubl_overflow ()(c_long a, c_long b, c_long* res) => overflowOp!(subs, c_long , c_long , c_long )(a, b, *res); + bool __builtin_ssubll_overflow()(long a, long b, long* res) => overflowOp!(subs, long , long , long )(a, b, *res); + bool __builtin_usub_overflow ()(uint a, uint b, uint* res) => overflowOp!(subs, uint , uint , uint )(a, b, *res); + bool __builtin_usubl_overflow ()(c_ulong a, c_ulong b, c_ulong* res) => overflowOp!(subs, c_ulong, c_ulong, c_ulong)(a, b, *res); + bool __builtin_usubll_overflow()(ulong a, ulong b, ulong* res) => overflowOp!(subs, ulong , ulong , ulong )(a, b, *res); + bool __builtin_smul_overflow ()(int a, int b, int* res) => overflowOp!(muls, int , int , int )(a, b, *res); + bool __builtin_smull_overflow ()(c_long a, c_long b, c_long* res) => overflowOp!(muls, c_long , c_long , c_long )(a, b, *res); + bool __builtin_smulll_overflow()(long a, long b, long* res) => overflowOp!(muls, long , long , long )(a, b, *res); + bool __builtin_umul_overflow ()(uint a, uint b, uint* res) => overflowOp!(muls, uint , uint , uint )(a, b, *res); + bool __builtin_umull_overflow ()(c_ulong a, c_ulong b, c_ulong* res) => overflowOp!(muls, c_ulong, c_ulong, c_ulong)(a, b, *res); + bool __builtin_umulll_overflow()(ulong a, ulong b, ulong* res) => overflowOp!(muls, ulong , ulong , ulong )(a, b, *res); + + uint __builtin_addc ()(uint a, uint b, uint carry_in, uint* carry_out) => builtin_opc!(adds, uint )(a, b, carry_in, *carry_out); + ulong __builtin_addcl ()(ulong a, ulong b, uint carry_in, ulong* carry_out) => builtin_opc!(adds, ulong)(a, b, carry_in, *carry_out); + ulong __builtin_addcll()(ulong a, ulong b, ulong carry_in, ulong* carry_out) => builtin_opc!(adds, ulong)(a, b, carry_in, *carry_out); + uint __builtin_subc ()(uint a, uint b, uint carry_in, uint* carry_out) => builtin_opc!(subs, uint )(a, b, carry_in, *carry_out); + ulong __builtin_subcl ()(ulong a, ulong b, uint carry_in, ulong* carry_out) => builtin_opc!(subs, ulong)(a, b, carry_in, *carry_out); + ulong __builtin_subcll()(ulong a, ulong b, ulong carry_in, ulong* carry_out) => builtin_opc!(subs, ulong)(a, b, carry_in, *carry_out); +} + +unittest { + int r1; + assert(__builtin_sadd_overflow(2147483647, 1, &r1) == true); + assert(__builtin_sadd_overflow(1, 1, &r1) == false); + + assert(__builtin_ssub_overflow(-2147483648, 1, &r1) == true); + assert(__builtin_ssub_overflow(5, 3, &r1) == false); + + assert(__builtin_smul_overflow(2000000000, 2, &r1) == true); + assert(__builtin_smul_overflow(10, 20, &r1) == false); + + uint ur; + assert(__builtin_uadd_overflow(0xFFFFFFFFu, 1u, &ur) == true); + assert(__builtin_uadd_overflow(10u, 20u, &ur) == false); + + assert(__builtin_usub_overflow(0u, 1u, &ur) == true); + assert(__builtin_usub_overflow(20u, 10u, &ur) == false); + + assert(__builtin_umul_overflow(0xFFFFFFFFu, 2u, &ur) == true); + assert(__builtin_umul_overflow(10u, 20u, &ur) == false); + + uint carry; + uint rr = __builtin_addc(1u, 1u, 0u, &carry); + assert(rr == 2); + assert(carry == 0); + + rr = __builtin_addc(0xFFFFFFFFu, 1u, 0u, &carry); + assert(carry == 1); + + rr = __builtin_subc(1u, 1u, 0u, &carry); + assert(rr == 0); + assert(carry == 0); + + rr = __builtin_subc(0u, 1u, 0u, &carry); + assert(carry == 1); +} + +private U signbit(T, U)(T x) +{ + T arg = x; + return cast(U)arg >> (T.sizeof * 8 - 1); +} + +pragma(inline, true) +{ + // https://gcc.gnu.org/onlinedocs/gcc/Bit-Operation-Builtins.html + import core.bitop : popcnt, bsr, bsf, rol, ror; + private int clz(T)(T x) => bsr(x) ^ ((int.sizeof * 8)-1); + + int __builtin_clz()(uint x) => clz!uint(x); + int __builtin_clzl()(c_ulong x) => clz!c_ulong(x); + int __builtin_clzll()(ulong x) => clz!ulong(x); + int __builtin_clzg(T)(T arg) => clz(arg); + + int __builtin_ctz()(uint x) => bsf(x); + int __builtin_ctzl()(c_ulong x) => bsf(x); + int __builtin_ctzll()(ulong x) => bsf(x); + int __builtin_ctzg(T)(T arg) => bsf(arg); + + int __builtin_clrsb()(int x) => signbit!(int, uint)(x) ? clz!uint(~x) - 1 : clz!uint(x) -1; + int __builtin_clrsbl()(c_long x) => signbit!(c_long, c_ulong)(x) ? clz!c_ulong(~x) - 1 : clz!c_ulong(x) -1; + int __builtin_clrsbll()(long x) => signbit!(long, ulong)(x) ? clz!ulong(~x) - 1 : clz!ulong(x) -1; + int __builtin_clrsbg(T, U)(T arg) => signbit!(T, U)(arg) ? clz!U(~x) - 1 : clz!U(x) -1; + + int __builtin_ffs()(int x) => x ? bsf(x) + 1 : 0; + int __builtin_ffsl()(c_long x) => x ? bsf(x) + 1 : 0; + int __builtin_ffsll()(long x) => x ? bsf(x) + 1 : 0; + int __builtin_ffsg(T)(T arg) => arg ? bsf(arg) + 1 : 0; + + int __builtin_popcount()(uint x) => popcnt(x); + int __builtin_popcountl()(c_ulong x) => popcnt(x); + int __builtin_popcountll()(ulong x) => popcnt(x); + int __builtin_popcountg(T)(T arg) => popcnt(arg); + + int __builtin_parity()(uint x) => popcnt(x) % 2; + int __builtin_parityl()(c_ulong) => popcnt(x) % 2; + int __builtin_parityll()(ulong) => popcnt(x) % 2; + int __builtin_parityg(T)(T arg) => popcnt(arg) % 2; + + T __builtin_stdc_bit_ceil(T)(T arg) => arg <= 1 ? T(1) : T(2) << (T.sizeof * 8 - 1 - clz(arg - 1)); + T __builtin_stdc_bit_floor(T)(T arg) => arg == 0 ? T(0) : T(1) << (T.sizeof * 8 - 1 - clz(arg)); + uint __builtin_stdc_bit_width(T)(T arg) => T.sizeof * 8 - clz(arg); + uint __builtin_stdc_count_ones (T)(T arg) => popcnt(arg); + uint __builtin_stdc_count_zeros(T)(T arg) => popcnt(cast(T) ~arg); + uint __builtin_stdc_first_leading_one (T)(T arg) => clz( arg) + 1U; + uint __builtin_stdc_first_leading_zero (T)(T arg) => clz(~arg) + 1U; + uint __builtin_stdc_first_trailing_one (T)(T arg) => ctz( arg) + 1U; + uint __builtin_stdc_first_trailing_zero(T)(T arg) => ctz(~arg) + 1U; + uint __builtin_stdc_has_single_bit(T)(T arg) => popcnt(arg) == 1; + T1 __builtin_stdc_rotate_left (T1, T2)(T1 arg1, T2 arg2) => roL(arg1, arg2); + T1 __builtin_stdc_rotate_right(T1, T2)(T1 arg1, T2 arg2) => ror(arg1, arg2); +} + +unittest +{ + assert((__builtin_ffs(1)) == 1); + assert((__builtin_ffs(2)) == 2); + assert((__builtin_ffsl(8L)) == 4); + assert((__builtin_ffsll(16L)) == 5); + + assert((__builtin_clz(1u)) >= 0); + assert((__builtin_clzl(1UL)) >= 0); + assert((__builtin_clzll(1UL)) >= 0); + + assert((__builtin_ctz(4u)) == 2); + assert((__builtin_ctzl(4UL)) == 2); + assert((__builtin_ctzll(8UL)) == 3); + + assert((__builtin_clrsb(1)) >= 0); + assert((__builtin_clrsbl(1L)) >= 0); + assert((__builtin_clrsbll(1L)) >= 0); + + assert((__builtin_popcount(3u)) == 2); + assert((__builtin_popcountl(3UL)) == 2); + assert((__builtin_popcountll(3UL)) == 2); + + assert((__builtin_parity(3u)) == 0); + assert((__builtin_parityl(3UL)) == 0); + assert((__builtin_parityll(3UL)) == 0); + + assert((__builtin_stdc_rotate_right(2u, 1)) >= 1); +} + +// https://gcc.gnu.org/onlinedocs/gcc/CRC-Builtins.html + +/* processes from LSB */ +C rev_crc_data(C, D, P)(C crc, D data, P poly) +{ + foreach (_; 0 .. D.sizeof * 8) { + bool mix = (crc ^ data) & 0x01; + crc >>= 1; + if (mix) + crc ^= poly; + data >>= 1; + } + return crc; +} + +/* processes from MSB */ +C crc_data(C, D, P)(C crc, D data, P poly) +{ + enum dbit_width = D.sizeof * 8; + foreach (_; 0 .. dbit_width) { + C top_bit = cast(C)1 << (C.sizeof * 8 - 1); + bool data_bit = ((data & (cast(D)1 << (dbit_width - 1))) != 0); + bool mix = ((crc & top_bit) != 0) ^ data_bit; + crc <<= 1; + if (mix) + crc ^= poly; + data <<= 1; + } + return crc; +} + + +pragma(inline, true) +{ + ubyte __builtin_rev_crc8_data8()(ubyte crc, ubyte data, ubyte poly) => rev_crc_data!(ubyte, ubyte, ubyte)(crc, data, poly); + ushort __builtin_rev_crc16_data16()(ushort crc, ushort data, ushort poly) => rev_crc_data!(ushort, ushort, ushort)(crc, data, poly); + ushort __builtin_rev_crc16_data8()(ushort crc, ubyte data, ushort poly) => rev_crc_data!(ushort, ubyte, ushort)(crc, data, poly); + uint __builtin_rev_crc32_data32()(uint crc, uint data, uint poly) => rev_crc_data!(uint, uint, uint)(crc, data, poly); + uint __builtin_rev_crc32_data8()(uint crc, ubyte data, uint poly) => rev_crc_data!(uint, ubyte, uint)(crc, data, poly); + uint __builtin_rev_crc32_data16()(uint crc, ushort data, uint poly) => rev_crc_data!(uint, ushort, uint)(crc, data, poly); + ulong __builtin_rev_crc64_data64()(ulong crc, ulong data, ulong poly) => rev_crc_data!(ulong, ulong, ulong)(crc, data, poly); + ulong __builtin_rev_crc64_data8()(ulong crc, ubyte data, ulong poly) => rev_crc_data!(ulong, ubyte, ulong)(crc, data, poly); + ulong __builtin_rev_crc64_data16()(ulong crc, ushort data, ulong poly) => rev_crc_data!(ulong, ushort, ulong)(crc, data, poly); + ulong __builtin_rev_crc64_data32()(ulong crc, uint data, ulong poly) => rev_crc_data!(ulong, uint, ulong)(crc, data, poly); + + ubyte __builtin_crc8_data8()(ubyte crc, ubyte data, ubyte poly) => crc_data!(ubyte, ubyte, ubyte)(crc, data, poly); + ushort __builtin_crc16_data16()(ushort crc, ushort data, ushort poly) => crc_data!(ushort, ushort, ushort)(crc, data, poly); + ushort __builtin_crc16_data8()(ushort crc, ubyte data, ushort poly) => crc_data!(ushort, ubyte, ushort)(crc, data, poly); + uint __builtin_crc32_data32()(uint crc, uint data, uint poly) => crc_data!(uint, uint, uint)(crc, data, poly); + uint __builtin_crc32_data8()(uint crc, ubyte data, uint poly) => crc_data!(uint, ubyte, uint)(crc, data, poly); + uint __builtin_crc32_data16()(uint crc, ushort data, uint poly) => crc_data!(uint, ushort, uint)(crc, data, poly); + ulong __builtin_crc64_data64()(ulong crc, ulong data, ulong poly) => crc_data!(ulong, ulong, ulong)(crc, data, poly); + ulong __builtin_crc64_data8()(ulong crc, ubyte data, ulong poly) => crc_data!(ulong, ubyte, ulong)(crc, data, poly); + ulong __builtin_crc64_data16()(ulong crc, ushort data, ulong poly) => crc_data!(ulong, ushort, ulong)(crc, data, poly); + ulong __builtin_crc64_data32()(ulong crc, uint data, ulong poly) => crc_data!(ulong, uint, ulong)(crc, data, poly); +} From a3151d085906aa2c57c5272498cf22702b80ed29 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Fri, 28 Nov 2025 15:49:08 -0800 Subject: [PATCH 117/440] make bitfields part of D (dlang/dmd!22156) --- tests/dmd/compilable/dbitfield.d | 2 +- tests/dmd/fail_compilation/biterrors.d | 2 +- tests/dmd/fail_compilation/biterrors2.d | 2 +- tests/dmd/fail_compilation/biterrors3.d | 2 +- tests/dmd/fail_compilation/biterrors4.d | 2 +- tests/dmd/fail_compilation/biterrors5.d | 2 +- tests/dmd/fail_compilation/bitintro.d | 2 +- tests/dmd/fail_compilation/dbitfields.d | 2 +- tests/dmd/fail_compilation/test16188.d | 2 +- tests/dmd/fail_compilation/test17284.d | 2 +- tests/dmd/runnable/dbitfields.d | 2 +- tests/dmd/runnable/dbitfieldsdm.d | 196 ++++++++++++++++++++++++ tests/dmd/runnable/dbitfieldsms.d | 1 - tests/dmd/runnable/dbitfieldsposix32.d | 1 - tests/dmd/runnable/dbitfieldsposix64.d | 1 - 15 files changed, 207 insertions(+), 14 deletions(-) create mode 100644 tests/dmd/runnable/dbitfieldsdm.d diff --git a/tests/dmd/compilable/dbitfield.d b/tests/dmd/compilable/dbitfield.d index 7187c37410..7471706154 100644 --- a/tests/dmd/compilable/dbitfield.d +++ b/tests/dmd/compilable/dbitfield.d @@ -1,4 +1,4 @@ -/* REQUIRED_ARGS: -preview=bitfields +/* */ /***************************************************/ diff --git a/tests/dmd/fail_compilation/biterrors.d b/tests/dmd/fail_compilation/biterrors.d index 9515039a72..e14001b1b9 100644 --- a/tests/dmd/fail_compilation/biterrors.d +++ b/tests/dmd/fail_compilation/biterrors.d @@ -1,4 +1,4 @@ -/* REQUIRED_ARGS: -preview=bitfields +/* * TEST_OUTPUT: --- fail_compilation/biterrors.d(103): Error: initializer not allowed for bitfield declaration diff --git a/tests/dmd/fail_compilation/biterrors2.d b/tests/dmd/fail_compilation/biterrors2.d index 85554931d1..7c7de33946 100644 --- a/tests/dmd/fail_compilation/biterrors2.d +++ b/tests/dmd/fail_compilation/biterrors2.d @@ -1,4 +1,4 @@ -/* REQUIRED_ARGS: -preview=bitfields +/* * TEST_OUTPUT: --- fail_compilation/biterrors2.d(100): Error: variable `biterrors2.a` - bitfield must be member of struct, union, or class diff --git a/tests/dmd/fail_compilation/biterrors3.d b/tests/dmd/fail_compilation/biterrors3.d index e956fc2f6e..6fbf16f923 100644 --- a/tests/dmd/fail_compilation/biterrors3.d +++ b/tests/dmd/fail_compilation/biterrors3.d @@ -1,4 +1,4 @@ -/* REQUIRED_ARGS: -preview=bitfields +/* * TEST_OUTPUT: --- fail_compilation/biterrors3.d(103): Error: storage class not allowed for bitfield declaration diff --git a/tests/dmd/fail_compilation/biterrors4.d b/tests/dmd/fail_compilation/biterrors4.d index 53b5cdc232..5457ad53c5 100644 --- a/tests/dmd/fail_compilation/biterrors4.d +++ b/tests/dmd/fail_compilation/biterrors4.d @@ -1,4 +1,4 @@ -/* REQUIRED_ARGS: -preview=bitfields +/* * TEST_OUTPUT: --- fail_compilation/biterrors4.d(109): Error: cannot take address of bitfield `s.a` diff --git a/tests/dmd/fail_compilation/biterrors5.d b/tests/dmd/fail_compilation/biterrors5.d index e17516b8f8..3e661799b8 100644 --- a/tests/dmd/fail_compilation/biterrors5.d +++ b/tests/dmd/fail_compilation/biterrors5.d @@ -1,4 +1,4 @@ -/* REQUIRED_ARGS: -preview=bitfields +/* * TEST_OUTPUT: --- fail_compilation/biterrors5.d(25): Error: bitfield symbol expected not struct `biterrors5.S` diff --git a/tests/dmd/fail_compilation/bitintro.d b/tests/dmd/fail_compilation/bitintro.d index d58c3ea56f..c91621c722 100644 --- a/tests/dmd/fail_compilation/bitintro.d +++ b/tests/dmd/fail_compilation/bitintro.d @@ -1,4 +1,4 @@ -/* REQUIRED_ARGS: -preview=bitfields +/* */ struct S diff --git a/tests/dmd/fail_compilation/dbitfields.d b/tests/dmd/fail_compilation/dbitfields.d index 0dd1a0bf96..5d135b7bf4 100644 --- a/tests/dmd/fail_compilation/dbitfields.d +++ b/tests/dmd/fail_compilation/dbitfields.d @@ -1,4 +1,4 @@ -/* REQUIRED_ARGS: -preview=bitfields +/* * TEST_OUTPUT: --- fail_compilation/dbitfields.d(118): Error: reinterpretation through overlapped field `e` is not allowed in CTFE diff --git a/tests/dmd/fail_compilation/test16188.d b/tests/dmd/fail_compilation/test16188.d index e3fedf34bd..eaa3352276 100644 --- a/tests/dmd/fail_compilation/test16188.d +++ b/tests/dmd/fail_compilation/test16188.d @@ -1,4 +1,4 @@ -/* REQUIRED_ARGS: -preview=bitfields +/* * TEST_OUTPUT: --- fail_compilation/test16188.d(101): Error: no property `name` for `Where()` of type `test16188.Where` diff --git a/tests/dmd/fail_compilation/test17284.d b/tests/dmd/fail_compilation/test17284.d index a68a0b32d2..0ad4a27133 100644 --- a/tests/dmd/fail_compilation/test17284.d +++ b/tests/dmd/fail_compilation/test17284.d @@ -4,7 +4,7 @@ TEST_OUTPUT: fail_compilation/test17284.d(17): Error: accessing overlapped field `U.c` with pointers is not allowed in a `@safe` function pure nothrow @safe void(U t) --- -REQUIRED_ARGS: -preview=bitfields + */ // https://issues.dlang.org/show_bug.cgi?id=17284 diff --git a/tests/dmd/runnable/dbitfields.d b/tests/dmd/runnable/dbitfields.d index aa154c7bbb..c8ebdc8f87 100644 --- a/tests/dmd/runnable/dbitfields.d +++ b/tests/dmd/runnable/dbitfields.d @@ -1,4 +1,4 @@ -/* REQUIRED_ARGS: -preview=bitfields +/* */ struct S diff --git a/tests/dmd/runnable/dbitfieldsdm.d b/tests/dmd/runnable/dbitfieldsdm.d new file mode 100644 index 0000000000..e18ad9abeb --- /dev/null +++ b/tests/dmd/runnable/dbitfieldsdm.d @@ -0,0 +1,196 @@ +/* test bitfields for Digital Mars + * Note that this test is for win32 only + * + * + * DISABLED: win32mscoff win64 linux freebsd osx + * RUN_OUTPUT: +--- + DM | MS | P32 | P64 +T0 = 1 1 || 1 1 | 1 1 | 1 1 | 1 1 +T1 = 2 2 || 2 2 | 2 2 | 2 2 | 2 2 +T2 = 4 4 || 4 4 | 4 4 | 4 4 | 4 4 +T3 = 16 8 || 16 8 | 16 8 | 8 4 | 8 8 +T4 = 16 8 || 16 8 | 16 8 | 12 4 | 16 8 +T5 = 16 8 || 16 8 | 16 8 | 8 4 | 8 8 +S1 = 8 8 || 8 8 | 8 8 | 4 4 | 8 8 +S2 = 4 4 || 4 4 | 4 4 | 4 4 | 4 4 +S3 = 8 4 || 8 4 | 8 4 | 4 4 | 4 4 +S4 = 8 4 || 8 4 | 8 4 | 4 4 | 4 4 +S5 = 8 4 || 8 4 | 8 4 | 4 4 | 4 4 +S6 = 2 2 || 2 2 | 2 2 | 2 2 | 2 2 +S7 = 16 8 || 16 8 | 16 8 | 4 4 | 8 8 +S8 = 4 2 || 4 2 | 4 2 | 2 2 | 2 2 +S8A = 4 2 || 4 2 | 4 2 | 2 2 | 2 2 +S8B = 6 2 || 6 2 | 6 2 | 2 2 | 2 2 +S8C = 8 4 || 8 4 | 8 4 | 4 4 | 4 4 +S9 = 4 2 || 4 2 | 4 2 | 4 2 | 4 2 +S10 = 1 1 || 0 0 | * * | 0 1 | 0 1 +S11 = 1 1 || 0 0 | 4 1 | 0 1 | 0 1 +S12 = 4 4 || 4 4 | 4 4 | 4 4 | 4 4 +S13 = 8 4 || 8 4 | 8 4 | 8 4 | 8 4 +S14 = 8 4 || 8 4 | 8 4 | 8 4 | 8 4 +S15 = 8 4 || 8 4 | 8 4 | 4 4 | 4 4 +S16 = 4 4 || 0 0 | 4 4 | 4 1 | 4 1 +S17 = 4 4 || 4 4 | 4 4 | 4 4 | 4 4 +S18 = 2 1 || 2 1 | 2 1 | 5 1 | 9 1 +A0 = 16 8 || 16 8 | 16 8 | 12 4 | 16 8 +A1 = 12 4 || 12 4 | 12 4 | 12 4 | 12 4 +A2 = 12 4 || 12 4 | 12 4 | 12 4 | 12 4 +A3 = 16 4 || 16 4 | 16 4 | 16 4 | 16 4 +A4 = 12 4 || 12 4 | 12 4 | 8 4 | 8 4 +A5 = 2 1 || 2 1 | 2 1 | 2 1 | 2 1 +A6 = 4 2 || 4 2 | 4 2 | 2 2 | 2 2 +A7 = 16 4 || 16 4 | 16 4 | 12 4 | 16 8 +A8 = 12 4 || 12 4 | 12 4 | 8 4 | 8 8 +A9 = 32 8 || 32 8 | 32 8 | 16 4 | 16 8 +A10 = 4 2 || 4 2 | 4 2 | 2 2 | 2 2 +A11 = 16 4 || 16 4 | 16 4 | 12 4 | 12 4 +S9 = x30200 +S14 = x300000201 +S15 = x201 +S18 = 1 should be 4 +A0 = x1 +--- + */ + +import core.stdc.stdio; + +int is64bit() { return size_t.sizeof == 8; } // otherwise assume 32 bit + +/*************************************************************/ + +struct T0 { ubyte x:1; }; // +struct T1 { short x:1; }; // +struct T2 { int x:1; }; // +struct T3 { ubyte a,b,c,d; long x:1; }; // +struct T4 { ubyte a,b,c,d,e,f,g,h; long x:1; }; // +struct T5 { ubyte a,b,c,d,e,f,g; long x:1; }; // +struct S1 { long f:1; }; // +struct S2 { int x:1; int y:1; }; // +struct S3 { short c; int x:1; uint y:1; }; // +struct S4 { int x:1; short y:1; }; // +struct S5 { short x:1; int y:1; }; // +struct S6 { short x:1; short y:1; }; // +struct S7 { short x:1; int y:1; long z:1; }; // +struct S8 { ubyte a; ubyte b:1; short c:2; }; // +struct S8A { ubyte b:1; short c:2; }; // +struct S8B { ubyte a; short b:1; ubyte c:2; }; // +struct S8C { ubyte a; int b:1; }; // +struct S9 { ubyte a; ubyte b:2; short c:9; }; // +struct S10 { }; // sizeof differs from C treatment +struct S11 { int :0; }; // sizeof differs from C treatment +struct S12 { int :0; int x; }; // +struct S13 { uint x:12; uint x1:1; uint x2:1; uint x3:1; uint x4:1; int w; }; // +struct S14 { ubyte a; ubyte b:4; int c:30; }; // +struct S15 { ubyte a; ubyte b:2; int c:9; }; // +struct S16 { int :32; }; // sizeof differs from C treatment +struct S17 { int a:32; }; // +struct S18 { ubyte a; long :0; ubyte b; }; // +struct A0 { int a; long b:34, c:4; }; // +struct A1 { int a; uint b:11; int c; }; // +struct A2 { int a; uint b:11, c:5, d:16; // + int e; }; +struct A3 { int a; uint b:11, c:5, :0, d:16; // + int e; }; +struct A4 { int a:8; short b:7; // + uint c:29; }; +struct A5 { ubyte a:7, b:2; }; // +struct A6 { ubyte a:7; short b:2; }; // +struct A7 { short a:8; int b:16; int c; // + ubyte d:7; }; +struct A8 { short a:8; int b:16; int :0; // + ubyte c:7; }; +struct A9 { ushort a:8; int b:16; // + uint c:29; long d:9; + uint e:2, f:31; }; +struct A10 { ushort a:8; ubyte b; }; // +struct A11 { ubyte a; int b:5, c:11, :0, d:8; // + struct { int ee:8; } }; + +int main() +{ + /* MS produces identical results for 32 and 64 bit compiles, + * DM is 32 bit only + */ + printf(" DM | MS | P32 | P64\n"); + printf("T0 = %2d %d || 1 1 | 1 1 | 1 1 | 1 1\n", cast(int)T0.sizeof, cast(int)T0.alignof); + printf("T1 = %2d %d || 2 2 | 2 2 | 2 2 | 2 2\n", cast(int)T1.sizeof, cast(int)T1.alignof); + printf("T2 = %2d %d || 4 4 | 4 4 | 4 4 | 4 4\n", cast(int)T2.sizeof, cast(int)T2.alignof); + printf("T3 = %2d %d || 16 8 | 16 8 | 8 4 | 8 8\n", cast(int)T3.sizeof, cast(int)T3.alignof); + printf("T4 = %2d %d || 16 8 | 16 8 | 12 4 | 16 8\n", cast(int)T4.sizeof, cast(int)T4.alignof); + printf("T5 = %2d %d || 16 8 | 16 8 | 8 4 | 8 8\n", cast(int)T5.sizeof, cast(int)T5.alignof); + printf("S1 = %2d %d || 8 8 | 8 8 | 4 4 | 8 8\n", cast(int)S1.sizeof, cast(int)S1.alignof); + printf("S2 = %2d %d || 4 4 | 4 4 | 4 4 | 4 4\n", cast(int)S2.sizeof, cast(int)S2.alignof); + printf("S3 = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", cast(int)S3.sizeof, cast(int)S3.alignof); + printf("S4 = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", cast(int)S4.sizeof, cast(int)S4.alignof); + printf("S5 = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", cast(int)S5.sizeof, cast(int)S5.alignof); + printf("S6 = %2d %d || 2 2 | 2 2 | 2 2 | 2 2\n", cast(int)S6.sizeof, cast(int)S6.alignof); + printf("S7 = %2d %d || 16 8 | 16 8 | 4 4 | 8 8\n", cast(int)S7.sizeof, cast(int)S7.alignof); + printf("S8 = %2d %d || 4 2 | 4 2 | 2 2 | 2 2\n", cast(int)S8.sizeof, cast(int)S8.alignof); + printf("S8A = %2d %d || 4 2 | 4 2 | 2 2 | 2 2\n", cast(int)S8A.sizeof, cast(int)S8A.alignof); + printf("S8B = %2d %d || 6 2 | 6 2 | 2 2 | 2 2\n", cast(int)S8B.sizeof, cast(int)S8B.alignof); + printf("S8C = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", cast(int)S8C.sizeof, cast(int)S8C.alignof); + printf("S9 = %2d %d || 4 2 | 4 2 | 4 2 | 4 2\n", cast(int)S9.sizeof, cast(int)S9.alignof); + printf("S10 = %2d %d || 0 0 | * * | 0 1 | 0 1\n", cast(int)S10.sizeof, cast(int)S10.alignof); // MS doesn't compile + printf("S11 = %2d %d || 0 0 | 4 1 | 0 1 | 0 1\n", cast(int)S11.sizeof, cast(int)S11.alignof); + printf("S12 = %2d %d || 4 4 | 4 4 | 4 4 | 4 4\n", cast(int)S12.sizeof, cast(int)S12.alignof); + printf("S13 = %2d %d || 8 4 | 8 4 | 8 4 | 8 4\n", cast(int)S13.sizeof, cast(int)S13.alignof); + printf("S14 = %2d %d || 8 4 | 8 4 | 8 4 | 8 4\n", cast(int)S14.sizeof, cast(int)S14.alignof); + printf("S15 = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", cast(int)S15.sizeof, cast(int)S15.alignof); + printf("S16 = %2d %d || 0 0 | 4 4 | 4 1 | 4 1\n", cast(int)S16.sizeof, cast(int)S16.alignof); + printf("S17 = %2d %d || 4 4 | 4 4 | 4 4 | 4 4\n", cast(int)S17.sizeof, cast(int)S17.alignof); + printf("S18 = %2d %d || 2 1 | 2 1 | 5 1 | 9 1\n", cast(int)S18.sizeof, cast(int)S18.alignof); + printf("A0 = %2d %d || 16 8 | 16 8 | 12 4 | 16 8\n", cast(int)A0.sizeof, cast(int)A0.alignof); + printf("A1 = %2d %d || 12 4 | 12 4 | 12 4 | 12 4\n", cast(int)A1.sizeof, cast(int)A1.alignof); + printf("A2 = %2d %d || 12 4 | 12 4 | 12 4 | 12 4\n", cast(int)A2.sizeof, cast(int)A2.alignof); + printf("A3 = %2d %d || 16 4 | 16 4 | 16 4 | 16 4\n", cast(int)A3.sizeof, cast(int)A3.alignof); + printf("A4 = %2d %d || 12 4 | 12 4 | 8 4 | 8 4\n", cast(int)A4.sizeof, cast(int)A4.alignof); + printf("A5 = %2d %d || 2 1 | 2 1 | 2 1 | 2 1\n", cast(int)A5.sizeof, cast(int)A5.alignof); + printf("A6 = %2d %d || 4 2 | 4 2 | 2 2 | 2 2\n", cast(int)A6.sizeof, cast(int)A6.alignof); + printf("A7 = %2d %d || 16 4 | 16 4 | 12 4 | 16 8\n", cast(int)A7.sizeof, cast(int)A7.alignof); + printf("A8 = %2d %d || 12 4 | 12 4 | 8 4 | 8 8\n", cast(int)A8.sizeof, cast(int)A8.alignof); + printf("A9 = %2d %d || 32 8 | 32 8 | 16 4 | 16 8\n", cast(int)A9.sizeof, cast(int)A9.alignof); + printf("A10 = %2d %d || 4 2 | 4 2 | 2 2 | 2 2\n", cast(int)A10.sizeof, cast(int)A10.alignof); + printf("A11 = %2d %d || 16 4 | 16 4 | 12 4 | 12 4\n", cast(int)A11.sizeof, cast(int)A11.alignof); + + { + S9 s; + uint x; + *cast(uint *)&s = 0; + s.b = 2; s.c = 3; + x = *cast(uint *)&s; + printf("S9 = x%x\n", x); + } + { + S14 s = { 1, 2, 3 }; + ulong v; + *cast(long *)&s = 0; + s.a = 1; + s.b = 2; + s.c = 3; + v = *cast(ulong *)&s; + printf("S14 = x%llx\n", v); + } + { + S15 s = { 1,2,3 }; + uint x; + *cast(uint *)&s = 0; + s.a = 1; s.b = 2; s.c = 3; + x = *cast(uint *)&s; + printf("S15 = x%x\n", x); + } + { + S18 s; + printf("S18 = %d should be %d\n", cast(int)(&s.b - &s.a), is64bit() ? 8 : 4); + } + { + A0 s; + long x; + *cast(long *)&s = 0; + s.a = 1; s.b = 15; + x = *cast(long *)&s; + printf("A0 = x%llx\n", x); + } + + return 0; +} diff --git a/tests/dmd/runnable/dbitfieldsms.d b/tests/dmd/runnable/dbitfieldsms.d index 42157f7c7b..70a72c19b7 100644 --- a/tests/dmd/runnable/dbitfieldsms.d +++ b/tests/dmd/runnable/dbitfieldsms.d @@ -1,5 +1,4 @@ /* test bitfields for Microsoft C - * REQUIRED_ARGS: -preview=bitfields * DISABLED: win32 linux freebsd openbsd osx * RUN_OUTPUT: --- diff --git a/tests/dmd/runnable/dbitfieldsposix32.d b/tests/dmd/runnable/dbitfieldsposix32.d index 33ef3acdb4..26e44d29fc 100644 --- a/tests/dmd/runnable/dbitfieldsposix32.d +++ b/tests/dmd/runnable/dbitfieldsposix32.d @@ -1,5 +1,4 @@ /* test bitfields - * REQUIRED_ARGS: -preview=bitfields * DISABLED: win32 win64 linux64 freebsd64 openbsd64 osx64 * RUN_OUTPUT: --- diff --git a/tests/dmd/runnable/dbitfieldsposix64.d b/tests/dmd/runnable/dbitfieldsposix64.d index 59aaf27327..86c3a5d861 100644 --- a/tests/dmd/runnable/dbitfieldsposix64.d +++ b/tests/dmd/runnable/dbitfieldsposix64.d @@ -1,5 +1,4 @@ /* test bitfields - * REQUIRED_ARGS: -preview=bitfields * DISABLED: win32 win64 linux32 freebsd32 openbsd32 osx32 * RUN_OUTPUT: --- From abe2bb729965ba79d53c1cc6a1be06ce4dd2bf8e Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Sat, 29 Nov 2025 11:58:11 +0100 Subject: [PATCH 118/440] fix dlang/dmd!22157 - Compiling std.utf8 with -inline crashes the compile (dlang/dmd!22159) don't try to optimize if super used in nested function. --- dmd/inline.d | 6 +++++- tests/dmd/runnable/inline4.d | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/dmd/inline.d b/dmd/inline.d index 7aa94484fb..273e1b2f58 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -629,7 +629,11 @@ public: override void visit(SuperExp e) { - assert(ids.vthis); + if (!ids.vthis) + { + result = e; + return; + } result = new VarExp(e.loc, ids.vthis); if (ids.fd.hasDualContext) { diff --git a/tests/dmd/runnable/inline4.d b/tests/dmd/runnable/inline4.d index 141509fd97..afc116bbeb 100644 --- a/tests/dmd/runnable/inline4.d +++ b/tests/dmd/runnable/inline4.d @@ -345,6 +345,17 @@ void testRvalueRefReturn() consumeRvalueRefD(funcRvalueRef4()); } +/************************************/ +// https://github.com/dlang/dmd/issues/22157 +class Test22157 +{ + override string toString() + { + auto e = { return cast() super; } (); + return null; + } +} + /************************************/ void main() From 5866de24d0de52404acacc1cf55a59594ddfa724 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Mon, 1 Dec 2025 01:30:58 -0800 Subject: [PATCH 119/440] use out parameters in functionParameters() (dlang/dmd!22163) --- dmd/expressionsem.d | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 96e27542dd..b3b425855f 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -3909,7 +3909,7 @@ private bool checkDefCtor(Loc loc, Type t) */ private bool functionParameters(Loc loc, Scope* sc, TypeFunction tf, Expression ethis, Type tthis, ArgumentList argumentList, FuncDeclaration fd, - Type* prettype, Expression* peprefix) + out Type prettype, out Expression peprefix) { Expressions* arguments = argumentList.arguments; //printf("functionParameters() fd: %s tf: %s\n", fd ? fd.ident.toChars() : "", toChars(tf)); @@ -3919,7 +3919,6 @@ private bool functionParameters(Loc loc, Scope* sc, const olderrors = global.errors; bool err = false; Expression eprefix = null; - *peprefix = null; if (argumentList.names) { @@ -4705,8 +4704,8 @@ private bool functionParameters(Loc loc, Scope* sc, tret = tret.substWildTo(wildmatch); } - *prettype = tret; - *peprefix = eprefix; + prettype = tret; + peprefix = eprefix; return (err || olderrors != global.errors); } @@ -6564,7 +6563,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor TypeFunction tf = f.type.isTypeFunction(); if (!exp.arguments) exp.arguments = new Expressions(); - if (functionParameters(exp.loc, sc, tf, null, exp.type, exp.argumentList, f, &exp.type, &exp.argprefix)) + if (functionParameters(exp.loc, sc, tf, null, exp.type, exp.argumentList, f, exp.type, exp.argprefix)) return setError(); exp.member = f.isCtorDeclaration(); @@ -6679,7 +6678,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor TypeFunction tf = f.type.isTypeFunction(); if (!exp.arguments) exp.arguments = new Expressions(); - if (functionParameters(exp.loc, sc, tf, null, exp.type, exp.argumentList, f, &exp.type, &exp.argprefix)) + if (functionParameters(exp.loc, sc, tf, null, exp.type, exp.argumentList, f, exp.type, exp.argprefix)) return setError(); exp.member = f.isCtorDeclaration(); @@ -8274,7 +8273,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor Expression argprefix; if (!exp.arguments) exp.arguments = new Expressions(); - if (functionParameters(exp.loc, sc, cast(TypeFunction)t1, ethis, tthis, exp.argumentList, exp.f, &exp.type, &argprefix)) + if (functionParameters(exp.loc, sc, cast(TypeFunction)t1, ethis, tthis, exp.argumentList, exp.f, exp.type, argprefix)) return setError(); if (!exp.type) From 3c510aba0ab216137af8122dd7f38ce10e7092d0 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Tue, 2 Dec 2025 01:02:11 +0200 Subject: [PATCH 120/440] Move `Type.isBoolean` to `typesem` (dlang/dmd!22168) --- dmd/cxxfrontend.d | 6 ++++++ dmd/frontend.h | 10 --------- dmd/mtype.d | 53 ----------------------------------------------- dmd/mtype.h | 11 +--------- dmd/typesem.d | 16 ++++++++++++++ 5 files changed, 23 insertions(+), 73 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 29e659a6dd..dd3da89556 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -1024,6 +1024,12 @@ bool isReal(Type type) return dmd.typesem.isReal(type); } +bool isBoolean(Type type) +{ + import dmd.typesem; + return dmd.typesem.isBoolean(type); +} + /*********************************************************** * typinf.d */ diff --git a/dmd/frontend.h b/dmd/frontend.h index f4fe6f09fd..5ecd65d2b6 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2076,7 +2076,6 @@ class Type : public ASTNode virtual bool isUnsigned(); virtual bool isScopeClass(); virtual bool isString(); - virtual bool isBoolean(); bool isConst() const; bool isImmutable() const; bool isMutable() const; @@ -4376,7 +4375,6 @@ class TypeAArray final : public TypeArray static TypeAArray* create(Type* t, Type* index); const char* kind() const override; TypeAArray* syntaxCopy() override; - bool isBoolean() override; void accept(Visitor* v) override; }; @@ -4416,7 +4414,6 @@ class TypeClass final : public Type ClassDeclaration* isClassHandle() override; uint8_t deduceWild(Type* t, bool isRef) override; bool isScopeClass() override; - bool isBoolean() override; void accept(Visitor* v) override; }; @@ -4426,7 +4423,6 @@ class TypeDArray final : public TypeArray const char* kind() const override; TypeDArray* syntaxCopy() override; bool isString() override; - bool isBoolean() override; void accept(Visitor* v) override; }; @@ -4436,7 +4432,6 @@ class TypeDelegate final : public TypeNext static TypeDelegate* create(TypeFunction* t); const char* kind() const override; TypeDelegate* syntaxCopy() override; - bool isBoolean() override; void accept(Visitor* v) override; }; @@ -4450,7 +4445,6 @@ class TypeEnum final : public Type bool isComplex() override; bool isScalar() override; bool isUnsigned() override; - bool isBoolean() override; bool isString() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; @@ -4634,7 +4628,6 @@ class TypeNoreturn final : public Type public: const char* kind() const override; TypeNoreturn* syntaxCopy() override; - bool isBoolean() override; void accept(Visitor* v) override; }; @@ -4643,7 +4636,6 @@ class TypeNull final : public Type public: const char* kind() const override; TypeNull* syntaxCopy() override; - bool isBoolean() override; void accept(Visitor* v) override; }; @@ -4706,7 +4698,6 @@ class TypeStruct final : public Type static TypeStruct* create(StructDeclaration* sym); const char* kind() const override; TypeStruct* syntaxCopy() override; - bool isBoolean() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; @@ -4775,7 +4766,6 @@ class TypeVector final : public Type TypeVector* syntaxCopy() override; bool isScalar() override; bool isUnsigned() override; - bool isBoolean() override; TypeBasic* elementType(); void accept(Visitor* v) override; }; diff --git a/dmd/mtype.d b/dmd/mtype.d index f81693bf70..4daa81d68c 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -662,14 +662,6 @@ extern (C++) abstract class Type : ASTNode return false; } - /************************** - * Returns true if T can be converted to boolean value. - */ - bool isBoolean() - { - return isScalar(); - } - final bool isConst() const nothrow pure @nogc @safe { return (mod & MODFlags.const_) != 0; @@ -1697,11 +1689,6 @@ extern (C++) final class TypeVector : Type return basetype.nextOf().isUnsigned(); } - override bool isBoolean() - { - return false; - } - TypeBasic elementType() { assert(basetype.ty == Tsarray); @@ -1839,11 +1826,6 @@ extern (C++) final class TypeDArray : TypeArray return nty.isSomeChar; } - override bool isBoolean() - { - return true; - } - override void accept(Visitor v) { v.visit(this); @@ -1885,11 +1867,6 @@ extern (C++) final class TypeAArray : TypeArray return result; } - override bool isBoolean() - { - return true; - } - override void accept(Visitor v) { v.visit(this); @@ -2189,11 +2166,6 @@ extern (C++) final class TypeDelegate : TypeNext return result; } - override bool isBoolean() - { - return true; - } - override void accept(Visitor v) { v.visit(this); @@ -2512,11 +2484,6 @@ extern (C++) final class TypeStruct : Type return this; } - override bool isBoolean() - { - return false; - } - override bool needsDestruction() { return sym.dtor !is null; @@ -2614,11 +2581,6 @@ extern (C++) final class TypeEnum : Type return this.memType().isUnsigned(); } - override bool isBoolean() - { - return this.memType().isBoolean(); - } - override bool isString() { return this.memType().isString(); @@ -2705,11 +2667,6 @@ extern (C++) final class TypeClass : Type return sym.stack; } - override bool isBoolean() - { - return true; - } - override void accept(Visitor v) { v.visit(this); @@ -2888,11 +2845,6 @@ extern (C++) final class TypeNull : Type return this; } - override bool isBoolean() - { - return true; - } - override void accept(Visitor v) { v.visit(this); @@ -2920,11 +2872,6 @@ extern (C++) final class TypeNoreturn : Type return this; } - override bool isBoolean() - { - return true; // bottom type can be implicitly converted to any other type - } - override void accept(Visitor v) { v.visit(this); diff --git a/dmd/mtype.h b/dmd/mtype.h index f0a760977f..910ff6b0cd 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -234,7 +234,6 @@ class Type : public ASTNode virtual bool isUnsigned(); virtual bool isScopeClass(); virtual bool isString(); - virtual bool isBoolean(); bool isConst() const { return (mod & MODconst) != 0; } bool isImmutable() const { return (mod & MODimmutable) != 0; } bool isMutable() const { return (mod & (MODconst | MODimmutable | MODwild)) == 0; } @@ -339,7 +338,6 @@ class TypeVector final : public Type TypeVector *syntaxCopy() override; bool isScalar() override; bool isUnsigned() override; - bool isBoolean() override; TypeBasic *elementType(); void accept(Visitor *v) override { v->visit(this); } @@ -375,7 +373,6 @@ class TypeDArray final : public TypeArray const char *kind() override; TypeDArray *syntaxCopy() override; bool isString() override; - bool isBoolean() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -389,7 +386,6 @@ class TypeAArray final : public TypeArray static TypeAArray *create(Type *t, Type *index); const char *kind() override; TypeAArray *syntaxCopy() override; - bool isBoolean() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -539,7 +535,6 @@ class TypeDelegate final : public TypeNext static TypeDelegate *create(TypeFunction *t); const char *kind() override; TypeDelegate *syntaxCopy() override; - bool isBoolean() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -644,7 +639,6 @@ class TypeStruct final : public Type static TypeStruct *create(StructDeclaration *sym); const char *kind() override; TypeStruct *syntaxCopy() override; - bool isBoolean() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; @@ -664,7 +658,6 @@ class TypeEnum final : public Type bool isComplex() override; bool isScalar() override; bool isUnsigned() override; - bool isBoolean() override; bool isString() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; @@ -686,7 +679,6 @@ class TypeClass final : public Type ClassDeclaration *isClassHandle() override; unsigned char deduceWild(Type *t, bool isRef) override; bool isScopeClass() override; - bool isBoolean() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -725,7 +717,6 @@ class TypeNull final : public Type const char *kind() override; TypeNull *syntaxCopy() override; - bool isBoolean() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -735,7 +726,6 @@ class TypeNoreturn final : public Type public: const char *kind() override; TypeNoreturn *syntaxCopy() override; - bool isBoolean() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -807,4 +797,5 @@ namespace dmd bool isIntegral(Type* type); bool isFloating(Type* type); bool isReal(Type* type); + bool isBoolean(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index 22e49367cc..e8d2d33dd8 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -77,6 +77,22 @@ private inout(TypeNext) isTypeNext(inout Type _this) } } +/************************** + * Returns true if T can be converted to boolean value. + */ +bool isBoolean(Type _this) +{ + switch(_this.ty) + { + case Tvector, Tstruct: return false; + case Tarray, Taarray, Tdelegate, Tclass, Tnull: return true; + case Tenum: return _this.isTypeEnum().memType().isBoolean(); + // bottom type can be implicitly converted to any other type + case Tnoreturn: return true; + default: return _this.isScalar(); + } +} + bool isReal(Type _this) { if (auto tb = _this.isTypeBasic()) From 59c4f01d0233044a1e3b9590a318c7342e475d7d Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Tue, 2 Dec 2025 01:40:00 +0200 Subject: [PATCH 121/440] Move `Type.isString` to `typesem` (dlang/dmd!22166) --- dmd/cxxfrontend.d | 6 ++++++ dmd/frontend.h | 4 ---- dmd/mtype.d | 22 ---------------------- dmd/mtype.h | 6 ++---- dmd/typesem.d | 17 +++++++++++++++++ 5 files changed, 25 insertions(+), 30 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index dd3da89556..28d8555df7 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -1024,6 +1024,12 @@ bool isReal(Type type) return dmd.typesem.isReal(type); } +bool isString(Type type) +{ + import dmd.typesem; + return dmd.typesem.isString(type); +} + bool isBoolean(Type type) { import dmd.typesem; diff --git a/dmd/frontend.h b/dmd/frontend.h index 5ecd65d2b6..7c2cb74c31 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2075,7 +2075,6 @@ class Type : public ASTNode virtual bool isScalar(); virtual bool isUnsigned(); virtual bool isScopeClass(); - virtual bool isString(); bool isConst() const; bool isImmutable() const; bool isMutable() const; @@ -4422,7 +4421,6 @@ class TypeDArray final : public TypeArray public: const char* kind() const override; TypeDArray* syntaxCopy() override; - bool isString() override; void accept(Visitor* v) override; }; @@ -4445,7 +4443,6 @@ class TypeEnum final : public Type bool isComplex() override; bool isScalar() override; bool isUnsigned() override; - bool isString() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; @@ -4672,7 +4669,6 @@ class TypeSArray final : public TypeArray const char* kind() const override; TypeSArray* syntaxCopy() override; bool isIncomplete(); - bool isString() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; diff --git a/dmd/mtype.d b/dmd/mtype.d index 4daa81d68c..c218b74e08 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -657,11 +657,6 @@ extern (C++) abstract class Type : ASTNode return false; } - bool isString() - { - return false; - } - final bool isConst() const nothrow pure @nogc @safe { return (mod & MODFlags.const_) != 0; @@ -1763,12 +1758,6 @@ extern (C++) final class TypeSArray : TypeArray return dim.isIntegerExp() && dim.isIntegerExp().getInteger() == 0; } - override bool isString() - { - TY nty = next.toBasetype().ty; - return nty.isSomeChar; - } - override bool needsDestruction() { return next.needsDestruction(); @@ -1820,12 +1809,6 @@ extern (C++) final class TypeDArray : TypeArray return result; } - override bool isString() - { - TY nty = next.toBasetype().ty; - return nty.isSomeChar; - } - override void accept(Visitor v) { v.visit(this); @@ -2581,11 +2564,6 @@ extern (C++) final class TypeEnum : Type return this.memType().isUnsigned(); } - override bool isString() - { - return this.memType().isString(); - } - override bool needsDestruction() { return this.memType().needsDestruction(); diff --git a/dmd/mtype.h b/dmd/mtype.h index 910ff6b0cd..16c0768a47 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -233,7 +233,7 @@ class Type : public ASTNode virtual bool isScalar(); virtual bool isUnsigned(); virtual bool isScopeClass(); - virtual bool isString(); + bool isConst() const { return (mod & MODconst) != 0; } bool isImmutable() const { return (mod & MODimmutable) != 0; } bool isMutable() const { return (mod & (MODconst | MODimmutable | MODwild)) == 0; } @@ -358,7 +358,6 @@ class TypeSArray final : public TypeArray const char *kind() override; TypeSArray *syntaxCopy() override; bool isIncomplete(); - bool isString() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; @@ -372,7 +371,6 @@ class TypeDArray final : public TypeArray public: const char *kind() override; TypeDArray *syntaxCopy() override; - bool isString() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -658,7 +656,6 @@ class TypeEnum final : public Type bool isComplex() override; bool isScalar() override; bool isUnsigned() override; - bool isString() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; @@ -797,5 +794,6 @@ namespace dmd bool isIntegral(Type* type); bool isFloating(Type* type); bool isReal(Type* type); + bool isString(Type* type); bool isBoolean(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index e8d2d33dd8..ea7582e7e8 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -77,6 +77,23 @@ private inout(TypeNext) isTypeNext(inout Type _this) } } +bool isString(Type _this) +{ + if (auto tsa = _this.isTypeSArray()) + { + TY nty = tsa.next.toBasetype().ty; + return nty.isSomeChar(); + } + else if (auto tda = _this.isTypeDArray()) + { + TY nty = tda.next.toBasetype().ty; + return nty.isSomeChar(); + } + else if (auto te = _this.isTypeEnum()) + return te.memType().isString(); + return false; +} + /************************** * Returns true if T can be converted to boolean value. */ From 6fd4ca85b9dec50e7a50e586d2d194e223fb1bcb Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Tue, 2 Dec 2025 00:11:11 +0000 Subject: [PATCH 122/440] Tweak placement `new` errors & forbid dynamic array PlacementExpression (dlang/dmd!22165) Fix garbled placement `new` in safe function error. Fix typo for qualified PlacementExpression error, add test. Add error for dynamic array PlacementExpression. Fixes dlang/dmd!22164. Add test for dynamic array result (existing error). --- dmd/expressionsem.d | 11 +++++--- tests/dmd/fail_compilation/placenew.d | 36 +++++++++++++++++++-------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index b3b425855f..f2805699af 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -6284,13 +6284,18 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor error(p.loc, "PlacementExpression `%s` is an rvalue, but must be an lvalue", p.toChars()); return setError(); } - if (sc.setUnsafe(false, p.loc, "`@safe` function `%s` cannot use placement `new`", sc.func)) + if (sc.setUnsafe(false, p.loc, "placement `new`", sc.func)) { return setError(); } - if (!exp.placement.type.isNaked) + if (!p.type.isNaked) { - error(p.loc, "PlacementExpression `%s` of type `%s` be unshared and mutable", p.toChars(), toChars(p.type)); + error(p.loc, "PlacementExpression `%s` of type `%s` must be unshared and mutable", p.toChars(), toChars(p.type)); + return setError(); + } + if (p.type.ty == Tarray) + { + error(p.loc, "PlacementExpression cannot be a dynamic array"); return setError(); } checkModifiable(exp.placement, sc); diff --git a/tests/dmd/fail_compilation/placenew.d b/tests/dmd/fail_compilation/placenew.d index 033d078e19..2cb15eb530 100644 --- a/tests/dmd/fail_compilation/placenew.d +++ b/tests/dmd/fail_compilation/placenew.d @@ -1,21 +1,24 @@ /* TEST_OUTPUT: --- -fail_compilation/placenew.d(23): Error: PlacementExpression `3` is an rvalue, but must be an lvalue -fail_compilation/placenew.d(28): Error: undefined identifier `x` -fail_compilation/placenew.d(36): Error: `new ( i )` PlacementExpression cannot be evaluated at compile time -fail_compilation/placenew.d(39): called from here: `xxx()` -fail_compilation/placenew.d(39): while evaluating: `static assert(xxx() == 1)` -fail_compilation/placenew.d(48): Error: new placement size 24 must be >= object size 40 -fail_compilation/placenew.d(54): Error: placement new cannot be used with associative arrays -fail_compilation/placenew.d(67): Error: new placement size 4 must be >= class object size $?:32=16|64=24$ -fail_compilation/placenew.d(77): Error: `@safe` function `test7` cannot use placement `new` is not allowed in a `@safe` function +fail_compilation/placenew.d(26): Error: PlacementExpression `3` is an rvalue, but must be an lvalue +fail_compilation/placenew.d(31): Error: undefined identifier `x` +fail_compilation/placenew.d(39): Error: `new ( i )` PlacementExpression cannot be evaluated at compile time +fail_compilation/placenew.d(42): called from here: `xxx()` +fail_compilation/placenew.d(42): while evaluating: `static assert(xxx() == 1)` +fail_compilation/placenew.d(51): Error: new placement size 24 must be >= object size 40 +fail_compilation/placenew.d(57): Error: placement new cannot be used with associative arrays +fail_compilation/placenew.d(70): Error: new placement size 4 must be >= class object size $?:32=16|64=24$ +fail_compilation/placenew.d(80): Error: placement `new` is not allowed in a `@safe` function +fail_compilation/placenew.d(89): Error: PlacementExpression cannot be a dynamic array +fail_compilation/placenew.d(92): Error: placement new cannot be used with dynamic arrays +fail_compilation/placenew.d(95): Error: PlacementExpression `s` of type `const(int)` must be unshared and mutable --- */ void test0() { int i; - int* pi = new (i) int; + int* pi = new (i) int; // OK } void test1() @@ -78,3 +81,16 @@ void test7() } /*************************************************/ + +void test8() +{ + void[] a; + a.reserve(int.sizeof); + int* ps = new(a) int; + + ubyte[a.sizeof] sa; + int[] ia = new(sa) int[4]; + + const int s; + ps = new(s) int; +} From a6a723cc2cfe214cca6eb47d96f133721e900b18 Mon Sep 17 00:00:00 2001 From: naydef Date: Tue, 2 Dec 2025 10:07:07 +0000 Subject: [PATCH 123/440] Fix nanosleep mangling on musl libc (dlang/dmd!22167) --- runtime/druntime/src/core/sys/posix/time.d | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/druntime/src/core/sys/posix/time.d b/runtime/druntime/src/core/sys/posix/time.d index fdd6b0a888..732c18a97c 100644 --- a/runtime/druntime/src/core/sys/posix/time.d +++ b/runtime/druntime/src/core/sys/posix/time.d @@ -489,6 +489,7 @@ else version (CRuntime_Musl) enum CLOCK_SGI_CYCLE = 10; enum CLOCK_TAI = 11; + pragma(mangle, muslRedirTime64Mangle!("nanosleep", "__nanosleep_time64")) int nanosleep(const scope timespec*, timespec*); pragma(mangle, muslRedirTime64Mangle!("clock_getres", "__clock_getres_time64")) From ff6d05cd169cd5250ae654039a40ab5116d0dfb3 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Tue, 2 Dec 2025 18:08:43 +0800 Subject: [PATCH 124/440] Don't elide fields with elaborate copy/move ctors (dlang/dmd!22173) --- dmd/expressionsem.d | 25 ++++++++++++++++++------- tests/dmd/runnable/rvalue1.d | 30 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index f2805699af..28b39ebd27 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -659,10 +659,22 @@ bool canElideCopy(Expression e, Type to, bool checkMod = true) return tf && !tf.isRef; } + static bool visitDotVarExp(DotVarExp e) + { + auto vd = e.var.isVarDeclaration(); + if (!vd || !vd.isField()) + return false; + + auto sd = vd.type.isTypeStruct(); + if (!sd || sd.needsCopyOrPostblit() || sd.sym.hasMoveCtor) + return false; + + // If an aggregate can be elided, so are its fields + return canElideCopy(e.e1, e.e1.type, false); + } + switch (e.op) { - case EXP.call: - return visitCallExp(e.isCallExp()); case EXP.comma: auto ce = e.isCommaExp(); return canElideCopy(ce.e2, to, checkMod); @@ -670,14 +682,13 @@ bool canElideCopy(Expression e, Type to, bool checkMod = true) auto ce = e.isCondExp(); return canElideCopy(ce.e1, to, checkMod) && canElideCopy(ce.e2, to, checkMod); + case EXP.call: + return visitCallExp(e.isCallExp()); + case EXP.dotVariable: + return visitDotVarExp(e.isDotVarExp()); case EXP.structLiteral: auto sle = e.isStructLiteralExp(); return !(checkMod && sle.useStaticInit && to.isMutable()); - case EXP.dotVariable: - // If an aggregate can be elided, so are its fields - auto dve = e.isDotVarExp(); - auto vd = dve.var.isVarDeclaration(); - return vd && vd.isField() && canElideCopy(dve.e1, dve.e1.type, false); case EXP.variable: return (e.isVarExp().var.storage_class & STC.rvalue) != 0; default: diff --git a/tests/dmd/runnable/rvalue1.d b/tests/dmd/runnable/rvalue1.d index cdc2a1d405..084ce3b9c3 100644 --- a/tests/dmd/runnable/rvalue1.d +++ b/tests/dmd/runnable/rvalue1.d @@ -275,6 +275,36 @@ void test11() /********************************/ +struct S12{ + S12* ptr; + this(int) { ptr = &this; } + this(ref inout S12) { ptr = &this; } + this(S12) { ptr = &this; } +} + +struct V12 +{ + S12 s; + this(int) { s = S12(1); } +} + +void foo(S12 s) +{ + assert(&s == s.ptr); +} + +S12 bar() +{ + return __rvalue(V12(1).s); +} + +void test12() +{ + foo(bar()); +} + +/********************************/ + int main() { test1(); From 62fd924c391bbcdbc1198ab02b7ff96892989dae Mon Sep 17 00:00:00 2001 From: limepoutine Date: Tue, 2 Dec 2025 18:35:49 +0800 Subject: [PATCH 125/440] Serialize compilation of dllgc test (dlang/dmd!22162) --- runtime/druntime/test/common.mak | 2 +- runtime/druntime/test/shared/Makefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/druntime/test/common.mak b/runtime/druntime/test/common.mak index 406b2fd566..085593c457 100644 --- a/runtime/druntime/test/common.mak +++ b/runtime/druntime/test/common.mak @@ -157,7 +157,7 @@ TARGET_ARCH.d = $(model_flag) ########## Other common code ########## -.PHONY: all cleam +.PHONY: all clean all: $(TESTS:%=$(OBJDIR)/%.done) $(OBJDIR)/%.done: $(OBJDIR)/%$(DOTEXE) diff --git a/runtime/druntime/test/shared/Makefile b/runtime/druntime/test/shared/Makefile index f56de4a2f9..8553f12c4b 100644 --- a/runtime/druntime/test/shared/Makefile +++ b/runtime/druntime/test/shared/Makefile @@ -32,8 +32,8 @@ extra_dflags += -version=SharedRuntime PATH := $(dir $(DRUNTIMESO));$(PATH) endif -$(ROOT)/dllgc.done: $(ROOT)/dllgc$(DOTDLL) -$(ROOT)/dllgc$(DOTDLL): extra_dflags += -version=DLL -od=$(ROOT)/dll +$(ROOT)/dllgc$(DOTEXE): $(ROOT)/dllgc$(DOTDLL) +$(ROOT)/dllgc$(DOTDLL): private extra_dflags += -version=DLL -od=$(ROOT)/dll endif # Windows $(ROOT)/dynamiccast.done: $(ROOT)/%.done: $(ROOT)/%$(DOTEXE) $(ROOT)/%$(DOTDLL) From b8c84d815aa123b44e4336748a6bbf9a031ad51c Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 5 Dec 2025 05:26:26 +0200 Subject: [PATCH 126/440] Move `Type.deduceWild` to `typesem` (dlang/dmd!22107) --- dmd/cxxfrontend.d | 6 +++ dmd/expressionsem.d | 2 +- dmd/frontend.h | 4 -- dmd/mtype.d | 97 --------------------------------------- dmd/mtype.h | 5 +- dmd/typesem.d | 109 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 106 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 28d8555df7..75c0419b7b 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -1006,6 +1006,12 @@ Type makeSharedWildConst(Type type) return dmd.typesem.makeSharedWildConst(type); } +MOD deduceWild(Type type, Type t, bool isRef) +{ + import dmd.typesem; + return dmd.typesem.deduceWild(type, t, isRef); +} + bool isIntegral(Type type) { import dmd.typesem; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 28b39ebd27..d03db78375 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -3992,7 +3992,7 @@ private bool functionParameters(Loc loc, Scope* sc, * Start with the `this` argument, later on merge into wildmatch the mod bits of the rest * of the arguments. */ - MOD wildmatch = (tthis && !isCtorCall) ? tthis.Type.deduceWild(tf, false) : 0; + MOD wildmatch = (tthis && !isCtorCall) ? tthis.typeDeduceWild(tf, false) : 0; bool done = false; foreach (const i; 0 .. n) diff --git a/dmd/frontend.h b/dmd/frontend.h index 7c2cb74c31..9dbe502e06 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2087,7 +2087,6 @@ class Type : public ASTNode Type* nullAttributes() const; bool hasDeprecatedAliasThis(); Type* toBasetype(); - virtual uint8_t deduceWild(Type* t, bool isRef); virtual ClassDeclaration* isClassHandle(); virtual int32_t hasWild() const; virtual Type* nextOf(); @@ -4355,7 +4354,6 @@ class TypeNext : public Type Type* next; int32_t hasWild() const final override; Type* nextOf() final override; - uint8_t deduceWild(Type* t, bool isRef) final override; void transitive(); void accept(Visitor* v) override; }; @@ -4411,7 +4409,6 @@ class TypeClass final : public Type const char* kind() const override; TypeClass* syntaxCopy() override; ClassDeclaration* isClassHandle() override; - uint8_t deduceWild(Type* t, bool isRef) override; bool isScopeClass() override; void accept(Visitor* v) override; }; @@ -4697,7 +4694,6 @@ class TypeStruct final : public Type bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; - uint8_t deduceWild(Type* t, bool isRef) override; void accept(Visitor* v) override; }; diff --git a/dmd/mtype.d b/dmd/mtype.d index c218b74e08..edb8f2a4ae 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1143,38 +1143,6 @@ extern (C++) abstract class Type : ASTNode return ((te = isTypeEnum()) !is null) ? te.toBasetype2() : this; } - /*************************************** - * Compute MOD bits matching `this` argument type to wild parameter type. - * Params: - * t = corresponding parameter type - * isRef = parameter is `ref` or `out` - * Returns: - * MOD bits - */ - MOD deduceWild(Type t, bool isRef) - { - //printf("Type::deduceWild this = '%s', tprm = '%s'\n", toChars(), tprm.toChars()); - if (t.isWild()) - { - if (isImmutable()) - return MODFlags.immutable_; - if (isWildConst()) - { - if (t.isWildConst()) - return MODFlags.wild; - return MODFlags.wildconst; - } - if (isWild()) - return MODFlags.wild; - if (isConst()) - return MODFlags.const_; - if (isMutable()) - return MODFlags.mutable; - assert(0); - } - return 0; - } - inout(ClassDeclaration) isClassHandle() inout { return null; @@ -1422,30 +1390,6 @@ extern (C++) abstract class TypeNext : Type return next; } - override final MOD deduceWild(Type t, bool isRef) - { - if (ty == Tfunction) - return 0; - - ubyte wm; - - Type tn = t.nextOf(); - if (!isRef && (ty == Tarray || ty == Tpointer) && tn) - { - wm = next.deduceWild(tn, true); - if (!wm) - wm = Type.deduceWild(t, true); - } - else - { - wm = Type.deduceWild(t, isRef); - if (!wm && tn) - wm = next.deduceWild(tn, true); - } - - return wm; - } - final void transitive() { /* Invoke transitivity of type attributes @@ -2496,26 +2440,6 @@ extern (C++) final class TypeStruct : Type return false; } - override MOD deduceWild(Type t, bool isRef) - { - if (ty == t.ty && sym == (cast(TypeStruct)t).sym) - return Type.deduceWild(t, isRef); - - ubyte wm = 0; - - if (t.hasWild() && sym.aliasthis && !(att & AliasThisRec.tracing)) - { - if (auto ato = aliasthisOf(this)) - { - att = cast(AliasThisRec)(att | AliasThisRec.tracing); - wm = ato.deduceWild(t, isRef); - att = cast(AliasThisRec)(att & ~AliasThisRec.tracing); - } - } - - return wm; - } - override void accept(Visitor v) { v.visit(this); @@ -2619,27 +2543,6 @@ extern (C++) final class TypeClass : Type return sym; } - override MOD deduceWild(Type t, bool isRef) - { - ClassDeclaration cd = t.isClassHandle(); - if (cd && (sym == cd || cd.isBaseOf(sym, null))) - return Type.deduceWild(t, isRef); - - ubyte wm = 0; - - if (t.hasWild() && sym.aliasthis && !(att & AliasThisRec.tracing)) - { - if (auto ato = aliasthisOf(this)) - { - att = cast(AliasThisRec)(att | AliasThisRec.tracing); - wm = ato.deduceWild(t, isRef); - att = cast(AliasThisRec)(att & ~AliasThisRec.tracing); - } - } - - return wm; - } - override bool isScopeClass() { return sym.stack; diff --git a/dmd/mtype.h b/dmd/mtype.h index 16c0768a47..1efb9e4629 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -246,7 +246,6 @@ class Type : public ASTNode Type *nullAttributes() const; bool hasDeprecatedAliasThis(); Type *toBasetype(); - virtual unsigned char deduceWild(Type *t, bool isRef); virtual ClassDeclaration *isClassHandle(); virtual int hasWild() const; @@ -305,7 +304,6 @@ class TypeNext : public Type int hasWild() const override final; Type *nextOf() override final; - unsigned char deduceWild(Type *t, bool isRef) override final; void transitive(); void accept(Visitor *v) override { v->visit(this); } }; @@ -640,7 +638,6 @@ class TypeStruct final : public Type bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; - unsigned char deduceWild(Type *t, bool isRef) override; void accept(Visitor *v) override { v->visit(this); } }; @@ -674,7 +671,6 @@ class TypeClass final : public Type const char *kind() override; TypeClass *syntaxCopy() override; ClassDeclaration *isClassHandle() override; - unsigned char deduceWild(Type *t, bool isRef) override; bool isScopeClass() override; void accept(Visitor *v) override { v->visit(this); } @@ -791,6 +787,7 @@ namespace dmd Type *makeWildConst(Type* type); Type *makeSharedWild(Type* type); Type *makeSharedWildConst(Type* type); + unsigned char deduceWild(Type* type, Type* t, bool isRef); bool isIntegral(Type* type); bool isFloating(Type* type); bool isReal(Type* type); diff --git a/dmd/typesem.d b/dmd/typesem.d index ea7582e7e8..766800ca73 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -77,6 +77,115 @@ private inout(TypeNext) isTypeNext(inout Type _this) } } +// Exposed as it is used in `expressionsem` +MOD typeDeduceWild(Type _this, Type t, bool isRef) +{ + //printf("Type::deduceWild this = '%s', tprm = '%s'\n", toChars(), tprm.toChars()); + if (t.isWild()) + { + if (_this.isImmutable()) + return MODFlags.immutable_; + if (_this.isWildConst()) + { + if (t.isWildConst()) + return MODFlags.wild; + return MODFlags.wildconst; + } + if (_this.isWild()) + return MODFlags.wild; + if (_this.isConst()) + return MODFlags.const_; + if (_this.isMutable()) + return MODFlags.mutable; + assert(0); + } + return 0; +} + +/*************************************** + * Compute MOD bits matching `this` argument type to wild parameter type. + * Params: + * _this = base parameter type + * t = corresponding parameter type + * isRef = parameter is `ref` or `out` + * Returns: + * MOD bits + */ +MOD deduceWild(Type _this, Type t, bool isRef) +{ + static MOD typeNextDeduceWild(TypeNext _this, Type t, bool isRef) + { + if (_this.ty == Tfunction) + return 0; + + ubyte wm; + + Type tn = t.nextOf(); + if (!isRef && (_this.ty == Tarray || _this.ty == Tpointer) && tn) + { + wm = _this.next.deduceWild(tn, true); + if (!wm) + wm = typeDeduceWild(cast(Type)_this, t, true); + } + else + { + wm = typeDeduceWild(cast(Type)_this, t, isRef); + if (!wm && tn) + wm = _this.next.deduceWild(tn, true); + } + return wm; + } + + static MOD typeStructDeduceWild(TypeStruct _this, Type t, bool isRef) + { + if (_this.ty == t.ty && _this.sym == (cast(TypeStruct)t).sym) + return typeDeduceWild(cast(Type)_this, t, isRef); + + ubyte wm = 0; + + if (t.hasWild() && _this.sym.aliasthis && !(_this.att & AliasThisRec.tracing)) + { + if (auto ato = aliasthisOf(_this)) + { + _this.att = cast(AliasThisRec)(_this.att | AliasThisRec.tracing); + wm = ato.deduceWild(t, isRef); + _this.att = cast(AliasThisRec)(_this.att & ~AliasThisRec.tracing); + } + } + + return wm; + } + + static MOD typeClassDeduceWild(TypeClass _this, Type t, bool isRef) + { + ClassDeclaration cd = t.isClassHandle(); + if (cd && (_this.sym == cd || cd.isBaseOf(_this.sym, null))) + return typeDeduceWild(cast(Type)_this, t, isRef); + + ubyte wm = 0; + + if (t.hasWild() && _this.sym.aliasthis && !(_this.att & AliasThisRec.tracing)) + { + if (auto ato = aliasthisOf(_this)) + { + _this.att = cast(AliasThisRec)(_this.att | AliasThisRec.tracing); + wm = ato.deduceWild(t, isRef); + _this.att = cast(AliasThisRec)(_this.att & ~AliasThisRec.tracing); + } + } + + return wm; + } + + if (auto tn = _this.isTypeNext()) + return typeNextDeduceWild(tn, t, isRef); + else if (auto ts = _this.isTypeStruct()) + return typeStructDeduceWild(ts, t, isRef); + else if (auto tc = _this.isTypeClass()) + return typeClassDeduceWild(tc, t, isRef); + return typeDeduceWild(_this, t, isRef); +} + bool isString(Type _this) { if (auto tsa = _this.isTypeSArray()) From 69fe278a8f51101425c8f0a86ccb60860d6fb101 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 5 Dec 2025 06:33:48 +0200 Subject: [PATCH 127/440] Move `Type.isComplex` and `Type.isImaginary` to `typesem` (dlang/dmd!22183) --- dmd/cxxfrontend.d | 12 ++++++++++++ dmd/frontend.h | 6 ------ dmd/hdrgen.d | 2 +- dmd/mtype.d | 38 ++++++++------------------------------ dmd/mtype.h | 8 ++------ dmd/typesem.d | 16 ++++++++++++++++ 6 files changed, 39 insertions(+), 43 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 75c0419b7b..d529ffb190 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -1030,6 +1030,18 @@ bool isReal(Type type) return dmd.typesem.isReal(type); } +bool isComplex(Type type) +{ + import dmd.typesem; + return dmd.typesem.isComplex(type); +} + +bool isImaginary(Type type) +{ + import dmd.typesem; + return dmd.typesem.isImaginary(type); +} + bool isString(Type type) { import dmd.typesem; diff --git a/dmd/frontend.h b/dmd/frontend.h index 9dbe502e06..3e225e38ff 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2070,8 +2070,6 @@ class Type : public ASTNode static void deinitialize(); void modToBuffer(OutBuffer& buf) const; char* modToChars() const; - virtual bool isImaginary(); - virtual bool isComplex(); virtual bool isScalar(); virtual bool isUnsigned(); virtual bool isScopeClass(); @@ -4382,8 +4380,6 @@ class TypeBasic final : public Type uint32_t flags; const char* kind() const override; TypeBasic* syntaxCopy() override; - bool isImaginary() override; - bool isComplex() override; bool isScalar() override; bool isUnsigned() override; TypeBasic* isTypeBasic() override; @@ -4436,8 +4432,6 @@ class TypeEnum final : public Type EnumDeclaration* sym; const char* kind() const override; TypeEnum* syntaxCopy() override; - bool isImaginary() override; - bool isComplex() override; bool isScalar() override; bool isUnsigned() override; bool needsDestruction() override; diff --git a/dmd/hdrgen.d b/dmd/hdrgen.d index 78ce16c4f4..22d469b3c7 100644 --- a/dmd/hdrgen.d +++ b/dmd/hdrgen.d @@ -3200,7 +3200,7 @@ void floatToBuffer(Type type, const real_t value, ref OutBuffer buf, const bool default: break; } - if (t.isImaginary()) + if (t.isImaginaryNonSemantic()) buf.put('i'); } } diff --git a/dmd/mtype.d b/dmd/mtype.d index edb8f2a4ae..137f20299d 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -56,6 +56,14 @@ private auto X(T, U)(T m, U n) return (m << 4) | n; } +bool isImaginaryNonSemantic(Type _this) +{ + assert(_this.isTypeEnum() is null); + if (auto tb = _this.isTypeBasic()) + return (tb.flags & TFlags.imaginary) != 0; + return false; +} + /* Helper function for `typeToExpression`. Contains common code * for TypeQualified derived classes. */ @@ -632,16 +640,6 @@ extern (C++) abstract class Type : ASTNode return buf.extractChars(); } - bool isImaginary() - { - return false; - } - - bool isComplex() - { - return false; - } - bool isScalar() { return false; @@ -1555,16 +1553,6 @@ extern (C++) final class TypeBasic : Type return this; } - override bool isImaginary() - { - return (flags & TFlags.imaginary) != 0; - } - - override bool isComplex() - { - return (flags & TFlags.complex) != 0; - } - override bool isScalar() { return (flags & (TFlags.integral | TFlags.floating)) != 0; @@ -2468,16 +2456,6 @@ extern (C++) final class TypeEnum : Type return this; } - override bool isImaginary() - { - return this.memType().isImaginary(); - } - - override bool isComplex() - { - return this.memType().isComplex(); - } - override bool isScalar() { return this.memType().isScalar(); diff --git a/dmd/mtype.h b/dmd/mtype.h index 1efb9e4629..662212e2ff 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -228,8 +228,6 @@ class Type : public ASTNode void modToBuffer(OutBuffer& buf) const; char *modToChars() const; - virtual bool isImaginary(); - virtual bool isComplex(); virtual bool isScalar(); virtual bool isUnsigned(); virtual bool isScopeClass(); @@ -316,8 +314,6 @@ class TypeBasic final : public Type const char *kind() override; TypeBasic *syntaxCopy() override; - bool isImaginary() override; - bool isComplex() override; bool isScalar() override; bool isUnsigned() override; @@ -649,8 +645,6 @@ class TypeEnum final : public Type const char *kind() override; TypeEnum *syntaxCopy() override; - bool isImaginary() override; - bool isComplex() override; bool isScalar() override; bool isUnsigned() override; bool needsDestruction() override; @@ -791,6 +785,8 @@ namespace dmd bool isIntegral(Type* type); bool isFloating(Type* type); bool isReal(Type* type); + bool isImaginary(Type* type); + bool isComplex(Type* type); bool isString(Type* type); bool isBoolean(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index 766800ca73..637f541670 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -77,6 +77,22 @@ private inout(TypeNext) isTypeNext(inout Type _this) } } +bool isImaginary(Type _this) +{ + if (auto te = _this.isTypeEnum()) + return te.memType().isImaginary(); + return _this.isImaginaryNonSemantic(); +} + +bool isComplex(Type _this) +{ + if (auto tb = _this.isTypeBasic()) + return (tb.flags & TFlags.complex) != 0; + else if (auto te = _this.isTypeEnum()) + return te.memType().isComplex(); + return false; +} + // Exposed as it is used in `expressionsem` MOD typeDeduceWild(Type _this, Type t, bool isRef) { From f6cabdfa4724d1a34fa91f4bdf26665e1be405b9 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 5 Dec 2025 06:37:30 +0200 Subject: [PATCH 128/440] Move `Type.transitive` to `typesem` (dlang/dmd!22184) --- dmd/cxxfrontend.d | 6 ++++++ dmd/frontend.h | 1 - dmd/mtype.d | 7 ------- dmd/mtype.h | 2 +- dmd/typesem.d | 6 ++++++ 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index d529ffb190..6968485a9f 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -952,6 +952,12 @@ void Type_init() return dmd.typesem.Type_init(); } +void transitive(TypeNext type) +{ + import dmd.typesem; + return dmd.typesem.transitive(type); +} + Type makeConst(Type type) { import dmd.typesem; diff --git a/dmd/frontend.h b/dmd/frontend.h index 3e225e38ff..71a277120e 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -4352,7 +4352,6 @@ class TypeNext : public Type Type* next; int32_t hasWild() const final override; Type* nextOf() final override; - void transitive(); void accept(Visitor* v) override; }; diff --git a/dmd/mtype.d b/dmd/mtype.d index 137f20299d..6536f923be 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1388,13 +1388,6 @@ extern (C++) abstract class TypeNext : Type return next; } - final void transitive() - { - /* Invoke transitivity of type attributes - */ - next = next.addMod(mod); - } - override void accept(Visitor v) { v.visit(this); diff --git a/dmd/mtype.h b/dmd/mtype.h index 662212e2ff..6c826e2c47 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -302,7 +302,6 @@ class TypeNext : public Type int hasWild() const override final; Type *nextOf() override final; - void transitive(); void accept(Visitor *v) override { v->visit(this); } }; @@ -769,6 +768,7 @@ namespace dmd bool hasInvariant(Type* type); bool hasVoidInitPointers(Type* type); void Type_init(); + void transitive(TypeNext* type); structalign_t alignment(Type* type); Type* memType(TypeEnum* type); unsigned alignsize(Type* type); diff --git a/dmd/typesem.d b/dmd/typesem.d index 637f541670..d589edb0ab 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -67,6 +67,12 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; +void transitive(TypeNext _this) +{ + // Invoke transitivity of type attributes + _this.next = _this.next.addMod(_this.mod); +} + private inout(TypeNext) isTypeNext(inout Type _this) { switch(_this.ty) From 7a84bee7a62489223fcb225ac9ca613360b6aeb0 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 5 Dec 2025 07:19:37 +0200 Subject: [PATCH 129/440] Move `Type.isUnsigned` to `typesem` (dlang/dmd!22185) --- dmd/cxxfrontend.d | 6 ++++++ dmd/declaration.d | 26 -------------------------- dmd/dsymbolsem.d | 27 +++++++++++++++++++++++++++ dmd/frontend.h | 5 ----- dmd/intrange.d | 2 +- dmd/mtype.d | 20 -------------------- dmd/mtype.h | 5 +---- dmd/typesem.d | 11 +++++++++++ 8 files changed, 46 insertions(+), 56 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 6968485a9f..0ef9c35f35 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -1060,6 +1060,12 @@ bool isBoolean(Type type) return dmd.typesem.isBoolean(type); } +bool isUnsigned(Type type) +{ + import dmd.typesem; + return dmd.typesem.isUnsigned(type); +} + /*********************************************************** * typinf.d */ diff --git a/dmd/declaration.d b/dmd/declaration.d index 1275baf72e..faeab44ed1 100644 --- a/dmd/declaration.d +++ b/dmd/declaration.d @@ -684,32 +684,6 @@ extern (C++) class BitFieldDeclaration : VarDeclaration { v.visit(this); } - - /*********************************** - * Retrieve the .min or .max values. - * Only valid after semantic analysis. - * Params: - * id = Id.min or Id.max - * Returns: - * the min or max value - */ - final ulong getMinMax(Identifier id) - { - const width = fieldWidth; - const uns = type.isUnsigned(); - const min = id == Id.min; - ulong v; - assert(width != 0); // should have been rejected in semantic pass - if (width == ulong.sizeof * 8) - v = uns ? (min ? ulong.min : ulong.max) - : (min ? long.min : long.max); - else - v = uns ? (min ? 0 - : (1L << width) - 1) - : (min ? -(1L << (width - 1)) - : (1L << (width - 1)) - 1); - return v; - } } /*********************************************************** diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 5876705d1c..61d578d477 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -83,6 +83,33 @@ import dmd.visitor; enum LOG = false; +/*********************************** + * Retrieve the .min or .max values. + * Only valid after semantic analysis. + * Params: + * _this = bit field instance + * id = Id.min or Id.max + * Returns: + * the min or max value + */ +ulong getMinMax(BitFieldDeclaration _this, Identifier id) +{ + const width = _this.fieldWidth; + const uns = _this.type.isUnsigned(); + const min = id == Id.min; + ulong v; + assert(width != 0); // should have been rejected in semantic pass + if (width == ulong.sizeof * 8) + v = uns ? (min ? ulong.min : ulong.max) + : (min ? long.min : long.max); + else + v = uns ? (min ? 0 + : (1L << width) - 1) + : (min ? -(1L << (width - 1)) + : (1L << (width - 1)) - 1); + return v; +} + /* Append vthis field (this.tupleof[$-1]) to make this aggregate type nested. */ void makeNested(AggregateDeclaration _this) diff --git a/dmd/frontend.h b/dmd/frontend.h index 71a277120e..cb5cf9adbc 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2071,7 +2071,6 @@ class Type : public ASTNode void modToBuffer(OutBuffer& buf) const; char* modToChars() const; virtual bool isScalar(); - virtual bool isUnsigned(); virtual bool isScopeClass(); bool isConst() const; bool isImmutable() const; @@ -4380,7 +4379,6 @@ class TypeBasic final : public Type const char* kind() const override; TypeBasic* syntaxCopy() override; bool isScalar() override; - bool isUnsigned() override; TypeBasic* isTypeBasic() override; void accept(Visitor* v) override; }; @@ -4432,7 +4430,6 @@ class TypeEnum final : public Type const char* kind() const override; TypeEnum* syntaxCopy() override; bool isScalar() override; - bool isUnsigned() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; @@ -4750,7 +4747,6 @@ class TypeVector final : public Type const char* kind() const override; TypeVector* syntaxCopy() override; bool isScalar() override; - bool isUnsigned() override; TypeBasic* elementType(); void accept(Visitor* v) override; }; @@ -6736,7 +6732,6 @@ class BitFieldDeclaration : public VarDeclaration uint32_t bitOffset; BitFieldDeclaration* syntaxCopy(Dsymbol* s) override; void accept(Visitor* v) override; - uint64_t getMinMax(Identifier* id); }; class SymbolDeclaration final : public Declaration diff --git a/dmd/intrange.d b/dmd/intrange.d index ec303797a8..462bf9b4ad 100644 --- a/dmd/intrange.d +++ b/dmd/intrange.d @@ -16,7 +16,7 @@ import core.stdc.stdio; import dmd.astenums : Tdchar; import dmd.mtype : Type; import dmd.globals : uinteger_t; -import dmd.typesem : isIntegral; +import dmd.typesem : isIntegral, isUnsigned; private uinteger_t copySign(uinteger_t x, bool sign) @safe { diff --git a/dmd/mtype.d b/dmd/mtype.d index 6536f923be..04cbb1aa62 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -645,11 +645,6 @@ extern (C++) abstract class Type : ASTNode return false; } - bool isUnsigned() - { - return false; - } - bool isScopeClass() { return false; @@ -1551,11 +1546,6 @@ extern (C++) final class TypeBasic : Type return (flags & (TFlags.integral | TFlags.floating)) != 0; } - override bool isUnsigned() - { - return (flags & TFlags.unsigned) != 0; - } - // For eliminating dynamic_cast override TypeBasic isTypeBasic() { @@ -1604,11 +1594,6 @@ extern (C++) final class TypeVector : Type return basetype.nextOf().isScalar(); } - override bool isUnsigned() - { - return basetype.nextOf().isUnsigned(); - } - TypeBasic elementType() { assert(basetype.ty == Tsarray); @@ -2454,11 +2439,6 @@ extern (C++) final class TypeEnum : Type return this.memType().isScalar(); } - override bool isUnsigned() - { - return this.memType().isUnsigned(); - } - override bool needsDestruction() { return this.memType().needsDestruction(); diff --git a/dmd/mtype.h b/dmd/mtype.h index 6c826e2c47..4450a1667a 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -229,7 +229,6 @@ class Type : public ASTNode char *modToChars() const; virtual bool isScalar(); - virtual bool isUnsigned(); virtual bool isScopeClass(); bool isConst() const { return (mod & MODconst) != 0; } @@ -314,7 +313,6 @@ class TypeBasic final : public Type const char *kind() override; TypeBasic *syntaxCopy() override; bool isScalar() override; - bool isUnsigned() override; // For eliminating dynamic_cast TypeBasic *isTypeBasic() override; @@ -330,7 +328,6 @@ class TypeVector final : public Type const char *kind() override; TypeVector *syntaxCopy() override; bool isScalar() override; - bool isUnsigned() override; TypeBasic *elementType(); void accept(Visitor *v) override { v->visit(this); } @@ -645,7 +642,6 @@ class TypeEnum final : public Type const char *kind() override; TypeEnum *syntaxCopy() override; bool isScalar() override; - bool isUnsigned() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; bool needsNested() override; @@ -789,4 +785,5 @@ namespace dmd bool isComplex(Type* type); bool isString(Type* type); bool isBoolean(Type* type); + bool isUnsigned(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index d589edb0ab..8274c4e785 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -83,6 +83,17 @@ private inout(TypeNext) isTypeNext(inout Type _this) } } +bool isUnsigned(Type _this) +{ + if (auto tb = _this.isTypeBasic()) + return (tb.flags & TFlags.unsigned) != 0; + else if (auto tv = _this.isTypeVector()) + return tv.basetype.nextOf().isUnsigned(); + else if (auto te = _this.isTypeEnum()) + return te.memType().isUnsigned(); + return false; +} + bool isImaginary(Type _this) { if (auto te = _this.isTypeEnum()) From ece8fb1b77e06c0f7e6d36f11ead28003ae2efa2 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 5 Dec 2025 10:47:03 +0200 Subject: [PATCH 130/440] Move `Type.needsNested` to `typesem` (dlang/dmd!22186) --- dmd/cxxfrontend.d | 6 ++++++ dmd/dscope.d | 34 ---------------------------------- dmd/expressionsem.d | 36 ++++++++++++++++++++++++++++++++++++ dmd/frontend.h | 4 ---- dmd/mtype.d | 40 ---------------------------------------- dmd/mtype.h | 5 +---- dmd/typesem.d | 30 ++++++++++++++++++++++++++++++ 7 files changed, 73 insertions(+), 82 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 0ef9c35f35..89056f7e91 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -1060,6 +1060,12 @@ bool isBoolean(Type type) return dmd.typesem.isBoolean(type); } +bool needsNested(Type type) +{ + import dmd.typesem; + return dmd.typesem.needsNested(type); +} + bool isUnsigned(Type type) { import dmd.typesem; diff --git a/dmd/dscope.d b/dmd/dscope.d index f0ecca0be6..9edf2590db 100644 --- a/dmd/dscope.d +++ b/dmd/dscope.d @@ -361,40 +361,6 @@ extern (C++) struct Scope return pop(); } - - /******************************* - * Merge results of `ctorflow` into `this`. - * Params: - * loc = for error messages - * ctorflow = flow results to merge in - */ - extern (D) void merge(Loc loc, const ref CtorFlow ctorflow) - { - if (!mergeCallSuper(this.ctorflow.callSuper, ctorflow.callSuper)) - error(loc, "one path skips constructor"); - - const fies = ctorflow.fieldinit; - if (!this.ctorflow.fieldinit.length || !fies.length) - return; - FuncDeclaration f = func; - if (fes) - f = fes.func; - auto ad = f.isMemberDecl(); - assert(ad); - foreach (i, v; ad.fields) - { - bool mustInit = (v.storage_class & STC.nodefaultctor || v.type.needsNested()); - auto fieldInit = &this.ctorflow.fieldinit[i]; - const fiesCurrent = fies[i]; - if (fieldInit.loc is Loc.init) - fieldInit.loc = fiesCurrent.loc; - if (!mergeFieldInit(this.ctorflow.fieldinit[i].csx, fiesCurrent.csx) && mustInit) - { - error(loc, "one path skips field `%s`", v.toChars()); - } - } - } - /************************************ * Maybe `ident` was a C or C++ name. Check for that, * and suggest the D equivalent. diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index d03db78375..a676ed56b9 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -100,6 +100,40 @@ import dmd.visitor.postorder; enum LOGSEMANTIC = false; +/******************************* + * Merge results of `ctorflow` into `_this`. + * Params: + * _this = scope to merge the results into + * loc = for error messages + * ctorflow = flow results to merge in + */ +void merge(Scope* _this, Loc loc, const ref CtorFlow ctorflow) +{ + if (!mergeCallSuper(_this.ctorflow.callSuper, ctorflow.callSuper)) + error(loc, "one path skips constructor"); + + const fies = ctorflow.fieldinit; + if (!_this.ctorflow.fieldinit.length || !fies.length) + return; + FuncDeclaration f = _this.func; + if (_this.fes) + f = _this.fes.func; + auto ad = f.isMemberDecl(); + assert(ad); + foreach (i, v; ad.fields) + { + bool mustInit = (v.storage_class & STC.nodefaultctor || v.type.needsNested()); + auto fieldInit = &_this.ctorflow.fieldinit[i]; + const fiesCurrent = fies[i]; + if (fieldInit.loc is Loc.init) + fieldInit.loc = fiesCurrent.loc; + if (!mergeFieldInit(_this.ctorflow.fieldinit[i].csx, fiesCurrent.csx) && mustInit) + { + error(loc, "one path skips field `%s`", v.toChars()); + } + } +} + real_t toImaginary(Expression _this) { if (auto ie = _this.isIntegerExp()) @@ -16102,6 +16136,8 @@ Expression dotTemplateSemanticProp(DotTemplateInstanceExp exp, Scope* sc, bool g MATCH matchType(FuncExp funcExp, Type to, Scope* sc, FuncExp* presult, ErrorSink eSink) { + import dmd.typesem : merge; + auto loc = funcExp.loc; auto tok = funcExp.tok; auto td = funcExp.td; diff --git a/dmd/frontend.h b/dmd/frontend.h index cb5cf9adbc..8bb7be8a99 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2090,7 +2090,6 @@ class Type : public ASTNode Type* baseElemOf(); virtual bool needsDestruction(); virtual bool needsCopyOrPostblit(); - virtual bool needsNested(); virtual TypeBasic* isTypeBasic(); TypeFunction* isPtrToFunction(); TypeFunction* isFunction_Delegate_PtrToFunction(); @@ -4432,7 +4431,6 @@ class TypeEnum final : public Type bool isScalar() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; - bool needsNested() override; Type* nextOf() override; void accept(Visitor* v) override; }; @@ -4658,7 +4656,6 @@ class TypeSArray final : public TypeArray bool isIncomplete(); bool needsDestruction() override; bool needsCopyOrPostblit() override; - bool needsNested() override; void accept(Visitor* v) override; }; @@ -4683,7 +4680,6 @@ class TypeStruct final : public Type TypeStruct* syntaxCopy() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; - bool needsNested() override; void accept(Visitor* v) override; }; diff --git a/dmd/mtype.d b/dmd/mtype.d index 04cbb1aa62..9d76418e9d 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1224,14 +1224,6 @@ extern (C++) abstract class Type : ASTNode return false; } - /********************************* - * - */ - bool needsNested() - { - return false; - } - // For eliminating dynamic_cast TypeBasic isTypeBasic() { @@ -1678,14 +1670,6 @@ extern (C++) final class TypeSArray : TypeArray return next.needsCopyOrPostblit(); } - /********************************* - * - */ - override bool needsNested() - { - return next.needsNested(); - } - override void accept(Visitor v) { v.visit(this); @@ -2387,25 +2371,6 @@ extern (C++) final class TypeStruct : Type return sym.hasCopyCtor || sym.postblit; } - override bool needsNested() - { - if (inuse) return false; // circular type, error instead of crashing - - inuse = true; - scope(exit) inuse = false; - - if (sym.isNested()) - return true; - - for (size_t i = 0; i < sym.fields.length; i++) - { - VarDeclaration v = sym.fields[i]; - if (!v.isDataseg() && v.type.needsNested()) - return true; - } - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -2449,11 +2414,6 @@ extern (C++) final class TypeEnum : Type return this.memType().needsCopyOrPostblit(); } - override bool needsNested() - { - return this.memType().needsNested(); - } - override Type nextOf() { return this.memType().nextOf(); diff --git a/dmd/mtype.h b/dmd/mtype.h index 4450a1667a..dee03e51f7 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -250,7 +250,6 @@ class Type : public ASTNode Type *baseElemOf(); virtual bool needsDestruction(); virtual bool needsCopyOrPostblit(); - virtual bool needsNested(); TypeFunction *toTypeFunction(); @@ -350,7 +349,6 @@ class TypeSArray final : public TypeArray bool isIncomplete(); bool needsDestruction() override; bool needsCopyOrPostblit() override; - bool needsNested() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -629,7 +627,6 @@ class TypeStruct final : public Type TypeStruct *syntaxCopy() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; - bool needsNested() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -644,7 +641,6 @@ class TypeEnum final : public Type bool isScalar() override; bool needsDestruction() override; bool needsCopyOrPostblit() override; - bool needsNested() override; Type *nextOf() override; void accept(Visitor *v) override { v->visit(this); } @@ -785,5 +781,6 @@ namespace dmd bool isComplex(Type* type); bool isString(Type* type); bool isBoolean(Type* type); + bool needsNested(Type* type); bool isUnsigned(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index 8274c4e785..9f26fec108 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -83,6 +83,36 @@ private inout(TypeNext) isTypeNext(inout Type _this) } } +bool needsNested(Type _this) +{ + static bool typeStructNeedsNested(TypeStruct _this) + { + if (_this.inuse) return false; // circular type, error instead of crashing + + _this.inuse = true; + scope(exit) _this.inuse = false; + + if (_this.sym.isNested()) + return true; + + for (size_t i = 0; i < _this.sym.fields.length; i++) + { + VarDeclaration v = _this.sym.fields[i]; + if (!v.isDataseg() && v.type.needsNested()) + return true; + } + return false; + } + + if (auto tsa = _this.isTypeSArray()) + return tsa.next.needsNested(); + else if (auto ts = _this.isTypeStruct()) + return typeStructNeedsNested(ts); + else if (auto te = _this.isTypeEnum()) + return te.memType().needsNested(); + return false; +} + bool isUnsigned(Type _this) { if (auto tb = _this.isTypeBasic()) From f3f34ed8318ed9a8127a8c66d28d09a14bc357a0 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Sat, 6 Dec 2025 06:55:29 +0800 Subject: [PATCH 131/440] Allow NRVO across commas (dlang/dmd!22192) --- tests/dmd/runnable/test28.d | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/dmd/runnable/test28.d b/tests/dmd/runnable/test28.d index f744712f2f..24f8e96ca4 100644 --- a/tests/dmd/runnable/test28.d +++ b/tests/dmd/runnable/test28.d @@ -1272,6 +1272,41 @@ void test18576() /*******************************************/ +struct S67 +{ + S67* ptr; + + this(int) + { + pragma(inline, false); + ptr = &this; + } + + @disable this(this); +} + +pragma(inline, false) +S67 make67() +{ + return S67(1); +} + +__gshared int i67; + +S67 f67() +{ + i67++; + return make67(); +} + +void test67() +{ + S67 s = f67(); + assert(s.ptr == &s); +} + +/*******************************************/ + void main() { printf("Start\n"); @@ -1336,6 +1371,7 @@ void main() test64(); test65(); test18576(); + test67(); printf("Success\n"); } From 439d7140acdd6b6a617bf26506072cf22af7612c Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 6 Dec 2025 00:57:44 +0200 Subject: [PATCH 132/440] Move `Type.needsDestruction` to `typesem` (dlang/dmd!22191) --- dmd/cxxfrontend.d | 10 ++++++++-- dmd/frontend.h | 4 ---- dmd/mtype.d | 24 ------------------------ dmd/mtype.h | 7 ++----- dmd/typesem.d | 15 +++++++++++++++ 5 files changed, 25 insertions(+), 35 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 89056f7e91..1c59388036 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -1060,16 +1060,22 @@ bool isBoolean(Type type) return dmd.typesem.isBoolean(type); } +bool isUnsigned(Type type) +{ + import dmd.typesem; + return dmd.typesem.isUnsigned(type); +} + bool needsNested(Type type) { import dmd.typesem; return dmd.typesem.needsNested(type); } -bool isUnsigned(Type type) +bool needsDestruction(Type type) { import dmd.typesem; - return dmd.typesem.isUnsigned(type); + return dmd.typesem.needsDestruction(type); } /*********************************************************** diff --git a/dmd/frontend.h b/dmd/frontend.h index 8bb7be8a99..087b392361 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2088,7 +2088,6 @@ class Type : public ASTNode virtual int32_t hasWild() const; virtual Type* nextOf(); Type* baseElemOf(); - virtual bool needsDestruction(); virtual bool needsCopyOrPostblit(); virtual TypeBasic* isTypeBasic(); TypeFunction* isPtrToFunction(); @@ -4429,7 +4428,6 @@ class TypeEnum final : public Type const char* kind() const override; TypeEnum* syntaxCopy() override; bool isScalar() override; - bool needsDestruction() override; bool needsCopyOrPostblit() override; Type* nextOf() override; void accept(Visitor* v) override; @@ -4654,7 +4652,6 @@ class TypeSArray final : public TypeArray const char* kind() const override; TypeSArray* syntaxCopy() override; bool isIncomplete(); - bool needsDestruction() override; bool needsCopyOrPostblit() override; void accept(Visitor* v) override; }; @@ -4678,7 +4675,6 @@ class TypeStruct final : public Type static TypeStruct* create(StructDeclaration* sym); const char* kind() const override; TypeStruct* syntaxCopy() override; - bool needsDestruction() override; bool needsCopyOrPostblit() override; void accept(Visitor* v) override; }; diff --git a/dmd/mtype.d b/dmd/mtype.d index 9d76418e9d..381307000c 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1206,15 +1206,6 @@ extern (C++) abstract class Type : ASTNode return m; } - /******************************** - * true if when type goes out of scope, it needs a destructor applied. - * Only applies to value types, not ref types. - */ - bool needsDestruction() - { - return false; - } - /******************************** * true if when type is copied, it needs a copy constructor or postblit * applied. Only applies to value types, not ref types. @@ -1660,11 +1651,6 @@ extern (C++) final class TypeSArray : TypeArray return dim.isIntegerExp() && dim.isIntegerExp().getInteger() == 0; } - override bool needsDestruction() - { - return next.needsDestruction(); - } - override bool needsCopyOrPostblit() { return next.needsCopyOrPostblit(); @@ -2361,11 +2347,6 @@ extern (C++) final class TypeStruct : Type return this; } - override bool needsDestruction() - { - return sym.dtor !is null; - } - override bool needsCopyOrPostblit() { return sym.hasCopyCtor || sym.postblit; @@ -2404,11 +2385,6 @@ extern (C++) final class TypeEnum : Type return this.memType().isScalar(); } - override bool needsDestruction() - { - return this.memType().needsDestruction(); - } - override bool needsCopyOrPostblit() { return this.memType().needsCopyOrPostblit(); diff --git a/dmd/mtype.h b/dmd/mtype.h index dee03e51f7..b3b287626b 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -248,7 +248,6 @@ class Type : public ASTNode virtual int hasWild() const; virtual Type *nextOf(); Type *baseElemOf(); - virtual bool needsDestruction(); virtual bool needsCopyOrPostblit(); TypeFunction *toTypeFunction(); @@ -347,7 +346,6 @@ class TypeSArray final : public TypeArray const char *kind() override; TypeSArray *syntaxCopy() override; bool isIncomplete(); - bool needsDestruction() override; bool needsCopyOrPostblit() override; void accept(Visitor *v) override { v->visit(this); } @@ -625,7 +623,6 @@ class TypeStruct final : public Type static TypeStruct *create(StructDeclaration *sym); const char *kind() override; TypeStruct *syntaxCopy() override; - bool needsDestruction() override; bool needsCopyOrPostblit() override; void accept(Visitor *v) override { v->visit(this); } @@ -639,7 +636,6 @@ class TypeEnum final : public Type const char *kind() override; TypeEnum *syntaxCopy() override; bool isScalar() override; - bool needsDestruction() override; bool needsCopyOrPostblit() override; Type *nextOf() override; @@ -781,6 +777,7 @@ namespace dmd bool isComplex(Type* type); bool isString(Type* type); bool isBoolean(Type* type); - bool needsNested(Type* type); bool isUnsigned(Type* type); + bool needsNested(Type* type); + bool needsDestruction(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index 9f26fec108..6ab48ca600 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -83,6 +83,21 @@ private inout(TypeNext) isTypeNext(inout Type _this) } } +/******************************** + * true if when type goes out of scope, it needs a destructor applied. + * Only applies to value types, not ref types. + */ +bool needsDestruction(Type _this) +{ + if (auto tsa = _this.isTypeSArray()) + return tsa.next.needsDestruction(); + else if (auto ts = _this.isTypeStruct()) + return ts.sym.dtor !is null; + else if (auto te = _this.isTypeEnum()) + return te.memType().needsDestruction(); + return false; +} + bool needsNested(Type _this) { static bool typeStructNeedsNested(TypeStruct _this) From a0a20b0fae465fee9a2e0f4f31eb38b20b1bcec9 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Sat, 6 Dec 2025 06:58:46 +0800 Subject: [PATCH 133/440] Make `__copyrvalue` an rvalue (dlang/dmd!22188) --- dmd/expressionsem.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index a676ed56b9..ff142b054b 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -1841,7 +1841,7 @@ extern (D) Expression doCopyOrMove(Scope* sc, Expression e, Type t, bool nrvo, b VarDeclaration vd = new VarDeclaration(e.loc, e.type, Identifier.generateId("__copyrvalue"), null); if (nrvo) vd.nrvo = true; - vd.storage_class |= STC.nodtor; + vd.storage_class |= STC.temp | STC.rvalue | STC.nodtor; vd.dsymbolSemantic(sc); Expression de = new DeclarationExp(e.loc, vd); Expression ve = new VarExp(e.loc, vd); From efd6c0b2e26a86ad8ad34d8bcb38c7939b07f4bf Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 6 Dec 2025 01:16:56 +0200 Subject: [PATCH 134/440] Break dependency of `TypeBasic` on `merge` (dlang/dmd!22190) --- dmd/iasm/gcc.d | 3 +++ dmd/mtype.d | 1 - dmd/typesem.d | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dmd/iasm/gcc.d b/dmd/iasm/gcc.d index 25322c0e75..d30275a095 100644 --- a/dmd/iasm/gcc.d +++ b/dmd/iasm/gcc.d @@ -553,6 +553,7 @@ GccAsmStatement parseGccAsm(Parser)(Parser p, GccAsmStatement s) unittest { import dmd.mtype : TypeBasic; + import dmd.typesem : merge; if (!global.errorSink) global.errorSink = new ErrorSinkCompiler; @@ -573,8 +574,10 @@ unittest ASTCodegen.Type.tchar = null; } scope tint32 = new TypeBasic(ASTCodegen.Tint32); + tint32.merge(); ASTCodegen.Type.tint32 = tint32; scope tchar = new TypeBasic(ASTCodegen.Tchar); + tchar.merge(); ASTCodegen.Type.tchar = tchar; // Imitates asmSemantic if version = IN_GCC. diff --git a/dmd/mtype.d b/dmd/mtype.d index 381307000c..4c109c6e70 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1510,7 +1510,6 @@ extern (C++) final class TypeBasic : Type } this.dstring = d; this.flags = flags; - merge(this); } override const(char)* kind() const diff --git a/dmd/typesem.d b/dmd/typesem.d index 6ab48ca600..8bf04f8a35 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -708,6 +708,7 @@ void Type_init() for (size_t i = 0; basetab[i] != Terror; i++) { Type t = new TypeBasic(basetab[i]); + .merge(t); t = merge(t); Type.basic[basetab[i]] = t; } From 2a28fae6d3ee421afd7c5591b1c1dc32c2f2c9f9 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 6 Dec 2025 04:02:20 +0200 Subject: [PATCH 135/440] Move `Type.needsCopyOrPostblit` to `typesem` (dlang/dmd!22194) --- dmd/cxxfrontend.d | 6 ++++++ dmd/frontend.h | 4 ---- dmd/mtype.d | 24 ------------------------ dmd/mtype.h | 5 +---- dmd/typesem.d | 15 +++++++++++++++ 5 files changed, 22 insertions(+), 32 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 1c59388036..c2627ea771 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -1078,6 +1078,12 @@ bool needsDestruction(Type type) return dmd.typesem.needsDestruction(type); } +bool needsCopyOrPostblit(Type type) +{ + import dmd.typesem; + return dmd.typesem.needsCopyOrPostblit(type); +} + /*********************************************************** * typinf.d */ diff --git a/dmd/frontend.h b/dmd/frontend.h index 087b392361..cbbc3eb49e 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2088,7 +2088,6 @@ class Type : public ASTNode virtual int32_t hasWild() const; virtual Type* nextOf(); Type* baseElemOf(); - virtual bool needsCopyOrPostblit(); virtual TypeBasic* isTypeBasic(); TypeFunction* isPtrToFunction(); TypeFunction* isFunction_Delegate_PtrToFunction(); @@ -4428,7 +4427,6 @@ class TypeEnum final : public Type const char* kind() const override; TypeEnum* syntaxCopy() override; bool isScalar() override; - bool needsCopyOrPostblit() override; Type* nextOf() override; void accept(Visitor* v) override; }; @@ -4652,7 +4650,6 @@ class TypeSArray final : public TypeArray const char* kind() const override; TypeSArray* syntaxCopy() override; bool isIncomplete(); - bool needsCopyOrPostblit() override; void accept(Visitor* v) override; }; @@ -4675,7 +4672,6 @@ class TypeStruct final : public Type static TypeStruct* create(StructDeclaration* sym); const char* kind() const override; TypeStruct* syntaxCopy() override; - bool needsCopyOrPostblit() override; void accept(Visitor* v) override; }; diff --git a/dmd/mtype.d b/dmd/mtype.d index 4c109c6e70..2e8eae1580 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1206,15 +1206,6 @@ extern (C++) abstract class Type : ASTNode return m; } - /******************************** - * true if when type is copied, it needs a copy constructor or postblit - * applied. Only applies to value types, not ref types. - */ - bool needsCopyOrPostblit() - { - return false; - } - // For eliminating dynamic_cast TypeBasic isTypeBasic() { @@ -1650,11 +1641,6 @@ extern (C++) final class TypeSArray : TypeArray return dim.isIntegerExp() && dim.isIntegerExp().getInteger() == 0; } - override bool needsCopyOrPostblit() - { - return next.needsCopyOrPostblit(); - } - override void accept(Visitor v) { v.visit(this); @@ -2346,11 +2332,6 @@ extern (C++) final class TypeStruct : Type return this; } - override bool needsCopyOrPostblit() - { - return sym.hasCopyCtor || sym.postblit; - } - override void accept(Visitor v) { v.visit(this); @@ -2384,11 +2365,6 @@ extern (C++) final class TypeEnum : Type return this.memType().isScalar(); } - override bool needsCopyOrPostblit() - { - return this.memType().needsCopyOrPostblit(); - } - override Type nextOf() { return this.memType().nextOf(); diff --git a/dmd/mtype.h b/dmd/mtype.h index b3b287626b..24dccd5292 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -248,7 +248,6 @@ class Type : public ASTNode virtual int hasWild() const; virtual Type *nextOf(); Type *baseElemOf(); - virtual bool needsCopyOrPostblit(); TypeFunction *toTypeFunction(); @@ -346,7 +345,6 @@ class TypeSArray final : public TypeArray const char *kind() override; TypeSArray *syntaxCopy() override; bool isIncomplete(); - bool needsCopyOrPostblit() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -623,7 +621,6 @@ class TypeStruct final : public Type static TypeStruct *create(StructDeclaration *sym); const char *kind() override; TypeStruct *syntaxCopy() override; - bool needsCopyOrPostblit() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -636,7 +633,6 @@ class TypeEnum final : public Type const char *kind() override; TypeEnum *syntaxCopy() override; bool isScalar() override; - bool needsCopyOrPostblit() override; Type *nextOf() override; void accept(Visitor *v) override { v->visit(this); } @@ -780,4 +776,5 @@ namespace dmd bool isUnsigned(Type* type); bool needsNested(Type* type); bool needsDestruction(Type* type); + bool needsCopyOrPostblit(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index 8bf04f8a35..4d17996dac 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -83,6 +83,21 @@ private inout(TypeNext) isTypeNext(inout Type _this) } } +/******************************** + * true if when type is copied, it needs a copy constructor or postblit + * applied. Only applies to value types, not ref types. + */ +bool needsCopyOrPostblit(Type _this) +{ + if (auto tsa = _this.isTypeSArray()) + return tsa.next.needsCopyOrPostblit(); + else if (auto ts = _this.isTypeStruct()) + return ts.sym.hasCopyCtor || ts.sym.postblit; + else if (auto te = _this.isTypeEnum()) + return te.memType().needsCopyOrPostblit(); + return false; +} + /******************************** * true if when type goes out of scope, it needs a destructor applied. * Only applies to value types, not ref types. From d6f1d6bf45838360d16c906f9a8e8b291b229f3c Mon Sep 17 00:00:00 2001 From: limepoutine Date: Sat, 6 Dec 2025 15:17:04 +0800 Subject: [PATCH 136/440] Make sure to return the hidden pointer with RVO (dlang/dmd!22197) --- tests/dmd/runnable/test28.d | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/dmd/runnable/test28.d b/tests/dmd/runnable/test28.d index 24f8e96ca4..4c50611601 100644 --- a/tests/dmd/runnable/test28.d +++ b/tests/dmd/runnable/test28.d @@ -1,3 +1,5 @@ +// PERMUTE_ARGS: -fPIC -inline -release -g -O + module test; import core.stdc.stdio; @@ -1305,6 +1307,56 @@ void test67() assert(s.ptr == &s); } +/*******************************************/ +// https://github.com/dlang/dmd/issues/22160 + +struct Vector22160(T) +{ + T[] _payload; + + ~this() const nothrow {} + + @property size_t length() const + { + return _payload.length; + } + + @property T* ptr() inout { + return cast(T*) _payload.ptr; + } +} + +struct DEREncoder +{ + Vector22160!ubyte getContentsUnlocked() + { + return Vector22160!ubyte(); + } + + Vector22160!ubyte m_contents; +} + +Vector22160!ubyte putInSequence()(const auto ref Vector22160!ubyte contents) +{ + return DEREncoder().getContentsUnlocked(); +} + +void foo22160(T)(Vector22160!T*, T* ptr, size_t) +{ + assert(ptr is null); +} + +void bar22160(Vector22160!ubyte val) +{ + ulong[16] padding = 0x1234567890123456UL; + foo22160(&val, val.ptr, val.length); +} + +void test22160() +{ + bar22160(putInSequence(Vector22160!ubyte())); +} + /*******************************************/ void main() @@ -1372,6 +1424,7 @@ void main() test65(); test18576(); test67(); + test22160(); printf("Success\n"); } From 466f361e336eb5b643baf5427c3bb67d3c1c83c8 Mon Sep 17 00:00:00 2001 From: naydef Date: Mon, 8 Dec 2025 01:33:55 +0000 Subject: [PATCH 137/440] Fix dlang/dmd!22176: Add if_.d and ioctl.d (dlang/dmd!22177) --- .../druntime/src/core/sys/linux/hdlc/ioctl.d | 92 ++++++++++++ runtime/druntime/src/core/sys/linux/net/if_.d | 134 ++++++++++++++++++ 2 files changed, 226 insertions(+) create mode 100644 runtime/druntime/src/core/sys/linux/hdlc/ioctl.d create mode 100644 runtime/druntime/src/core/sys/linux/net/if_.d diff --git a/runtime/druntime/src/core/sys/linux/hdlc/ioctl.d b/runtime/druntime/src/core/sys/linux/hdlc/ioctl.d new file mode 100644 index 0000000000..f879aae70a --- /dev/null +++ b/runtime/druntime/src/core/sys/linux/hdlc/ioctl.d @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +module core.sys.linux.hdlc.ioctl; + +import core.sys.linux.net.if_ : IFNAMSIZ; + +version (linux): +extern(C): +@nogc: +nothrow: + +enum GENERIC_HDLC_VERSION = 4; /* For synchronization with sethdlc utility */ + +enum CLOCK_DEFAULT = 0; /* Default setting */ +enum CLOCK_EXT = 1; /* External TX and RX clock - DTE */ +enum CLOCK_INT = 2; /* Internal TX and RX clock - DCE */ +enum CLOCK_TXINT = 3; /* Internal TX and external RX clock */ +enum CLOCK_TXFROMRX = 4; /* TX clock derived from external RX clock */ + + +enum ENCODING_DEFAULT = 0; /* Default setting */ +enum ENCODING_NRZ = 1; +enum ENCODING_NRZI = 2; +enum ENCODING_FM_MARK = 3; +enum ENCODING_FM_SPACE = 4; +enum ENCODING_MANCHESTER = 5; + + +enum PARITY_DEFAULT = 0; /* Default setting */ +enum PARITY_NONE = 1; /* No parity */ +enum PARITY_CRC16_PR0 = 2; /* CRC16, initial value 0x0000 */ +enum PARITY_CRC16_PR1 = 3; /* CRC16, initial value 0xFFFF */ +enum PARITY_CRC16_PR0_CCITT = 4; /* CRC16, initial 0x0000, ITU-T version */ +enum PARITY_CRC16_PR1_CCITT = 5; /* CRC16, initial 0xFFFF, ITU-T version */ +enum PARITY_CRC32_PR0_CCITT = 6; /* CRC32, initial value 0x00000000 */ +enum PARITY_CRC32_PR1_CCITT = 7; /* CRC32, initial value 0xFFFFFFFF */ + +enum LMI_DEFAULT = 0; /* Default setting */ +enum LMI_NONE = 1; /* No LMI, all PVCs are static */ +enum LMI_ANSI = 2; /* ANSI Annex D */ +enum LMI_CCITT = 3; /* ITU-T Annex A */ +enum LMI_CISCO = 4; /* The "original" LMI, aka Gang of Four */ + +struct sync_serial_settings { + uint clock_rate; /* bits per second */ + uint clock_type; /* internal, external, TX-internal etc. */ + ushort loopback; +} /* V.35, V.24, X.21 */ + +struct te1_settings{ + uint clock_rate; /* bits per second */ + uint clock_type; /* internal, external, TX-internal etc. */ + ushort loopback; + uint slot_map; +} /* T1, E1 */ + +struct raw_hdlc_proto { + ushort encoding; + ushort parity; +} + +struct fr_proto { + uint t391; + uint t392; + uint n391; + uint n392; + uint n393; + ushort lmi; + ushort dce; /* 1 for DCE (network side) operation */ +} + +struct fr_proto_pvc { + uint dlci; +} /* for creating/deleting FR PVCs */ + +struct fr_proto_pvc_info { + uint dlci; + char[IFNAMSIZ] master = 0; /* Name of master FRAD device */ +} /* for returning PVC information only */ + +struct cisco_proto { + uint interval; + uint timeout; +} + +struct x25_hdlc_proto { + ushort dce; /* 1 for DCE (network side) operation */ + uint modulo; /* modulo (8 = basic / 128 = extended) */ + uint window; /* frame window size */ + uint t1; /* timeout t1 */ + uint t2; /* timeout t2 */ + uint n2; /* frame retry counter */ +} diff --git a/runtime/druntime/src/core/sys/linux/net/if_.d b/runtime/druntime/src/core/sys/linux/net/if_.d new file mode 100644 index 0000000000..62d247f125 --- /dev/null +++ b/runtime/druntime/src/core/sys/linux/net/if_.d @@ -0,0 +1,134 @@ +/++ + D header file for Linux's net/if.h. + + Copyright: Copyright 2025 + License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). + +/ +module core.sys.linux.net.if_; + +public import core.sys.posix.sys.socket : sockaddr; +public import core.sys.linux.hdlc.ioctl; + +version (linux): +extern(C): +@nogc: +nothrow: + +enum IFNAMSIZ = 16; +enum IFALIASZ = 256; +enum ALTIFNAMSIZ = 128; +enum IFHWADDRLEN = 6; + +enum IFF_UP = 0x1; +enum IFF_BROADCAST = 0x2; +enum IFF_DEBUG = 0x4; +enum IFF_LOOPBACK = 0x8; +enum IFF_POINTOPOINT = 0x10; +enum IFF_NOTRAILERS = 0x20; +enum IFF_RUNNING = 0x40; +enum IFF_NOARP = 0x80; +enum IFF_PROMISC = 0x100; +enum IFF_ALLMULTI = 0x200; +enum IFF_MASTER = 0x400; +enum IFF_SLAVE = 0x800; +enum IFF_MULTICAST = 0x1000; +enum IFF_PORTSEL = 0x2000; +enum IFF_AUTOMEDIA = 0x4000; +enum IFF_DYNAMIC = 0x8000; +enum IFF_LOWER_UP = 0x10000; +enum IFF_DORMANT = 0x20000; +enum IFF_ECHO = 0x40000; + +enum IF_GET_IFACE = 0x0001; /* for querying only */ +enum IF_GET_PROTO = 0x0002; + +/* For definitions see hdlc.h */ +enum IF_IFACE_V35 = 0x1000; /* V.35 serial interface */ +enum IF_IFACE_V24 = 0x1001; /* V.24 serial interface */ +enum IF_IFACE_X21 = 0x1002; /* X.21 serial interface */ +enum IF_IFACE_T1 = 0x1003; /* T1 telco serial interface */ +enum IF_IFACE_E1 = 0x1004; /* E1 telco serial interface */ +enum IF_IFACE_SYNC_SERIAL = 0x1005; /* can't be set by software */ +enum IF_IFACE_X21D = 0x1006; /* X.21 Dual Clocking (FarSite) */ + +/* For definitions see hdlc.h */ +enum IF_PROTO_HDLC = 0x2000; /* raw HDLC protocol */ +enum IF_PROTO_PPP = 0x2001; /* PPP protocol */ +enum IF_PROTO_CISCO = 0x2002; /* Cisco HDLC protocol */ +enum IF_PROTO_FR = 0x2003; /* Frame Relay protocol */ +enum IF_PROTO_FR_ADD_PVC = 0x2004; /* Create FR PVC */ +enum IF_PROTO_FR_DEL_PVC = 0x2005; /* Delete FR PVC */ +enum IF_PROTO_X25 = 0x2006; /* X.25 */ +enum IF_PROTO_HDLC_ETH = 0x2007; /* raw HDLC, Ethernet emulation */ +enum IF_PROTO_FR_ADD_ETH_PVC = 0x2008; /* Create FR Ethernet-bridged PVC */ +enum IF_PROTO_FR_DEL_ETH_PVC = 0x2009; /* Delete FR Ethernet-bridged PVC */ +enum IF_PROTO_FR_PVC = 0x200A; /* for reading PVC status */ +enum IF_PROTO_FR_ETH_PVC = 0x200B; +enum IF_PROTO_RAW = 0x200C; /* RAW Socket */ + +enum IF_OPER_UNKNOWN = 0; +enum IF_OPER_NOTPRESENT = 1; +enum IF_OPER_DOWN = 2; +enum IF_OPER_LOWERLAYERDOWN = 3; +enum IF_OPER_TESTING = 4; +enum IF_OPER_DORMANT = 5; +enum IF_OPER_UP = 6; + +enum IF_LINK_MODE_DEFAULT = 0; +enum IF_LINK_MODE_DORMANT = 1; /* limit upward transition to dormant */ +enum IF_LINK_MODE_TESTING = 2; /* limit upward transition to testing */ + +struct ifmap { + uint mem_start; + uint mem_end; + ushort base_addr; + ubyte irq; + ubyte dma; + ubyte port; + /* 3 bytes spare */ +} + +struct if_settings { + uint type; /* Type of physical device or protocol */ + uint size; /* Size of the data allocated by the caller */ + union { + /* {atm/eth/dsl}_settings anyone ? */ + raw_hdlc_proto* raw_hdlc; + cisco_proto* cisco; + fr_proto* fr; + fr_proto_pvc* fr_pvc; + fr_proto_pvc_info* fr_pvc_info; + x25_hdlc_proto* x25; + + /* interface settings */ + sync_serial_settings* sync; + te1_settings* te1; + }; +} + +struct ifreq { + union + { + char[IFNAMSIZ] ifrn_name = 0; /* if name, e.g. "en0" */ + } + + union { + + short ifru_flags; + int ifru_ivalue; + int ifru_mtu; + ifmap ifru_map; + char[IFNAMSIZ] ifru_slave; /* Just fits the size */ + char[IFNAMSIZ] ifru_newname; + void* ifru_data; + if_settings ifru_settings; + } +} + +struct ifconf { + int ifc_len; /* size of buffer */ + union { + char* ifcu_buf; + ifreq* ifcu_req; + } +} From bbbc6043bd12e106e6f3f0ff91e2146a92e0a5f4 Mon Sep 17 00:00:00 2001 From: apz28 Date: Mon, 8 Dec 2025 02:34:37 -0500 Subject: [PATCH 138/440] =?UTF-8?q?Fix=20dlang/dmd!17483:=20=20Fix=20Windo?= =?UTF-8?q?ws=20portion=20using=20...Windows=20Kits\10\Include\10.?= =?UTF-8?q?=E2=80=A6=20(dlang/dmd!22201)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix dlang/dmd!17483: Fix Windows portion using ...Windows Kits\10\Include\10.0.14393.0\ucrt\locale.h * Get rid of extra spaces --- runtime/druntime/src/core/stdc/locale.d | 88 ++++++++++++++++++------- 1 file changed, 63 insertions(+), 25 deletions(-) diff --git a/runtime/druntime/src/core/stdc/locale.d b/runtime/druntime/src/core/stdc/locale.d index 357d75e958..50b45980dc 100644 --- a/runtime/druntime/src/core/stdc/locale.d +++ b/runtime/druntime/src/core/stdc/locale.d @@ -29,32 +29,70 @@ nothrow: @nogc: /// -struct lconv +version (Windows) { - char* decimal_point; - char* thousands_sep; - char* grouping; - char* int_curr_symbol; - char* currency_symbol; - char* mon_decimal_point; - char* mon_thousands_sep; - char* mon_grouping; - char* positive_sign; - char* negative_sign; - byte int_frac_digits; - byte frac_digits; - byte p_cs_precedes; - byte p_sep_by_space; - byte n_cs_precedes; - byte n_sep_by_space; - byte p_sign_posn; - byte n_sign_posn; - byte int_p_cs_precedes; - byte int_p_sep_by_space; - byte int_n_cs_precedes; - byte int_n_sep_by_space; - byte int_p_sign_posn; - byte int_n_sign_posn; + import core.stdc.wchar_ : wchar_t; + + // ...Windows Kits\10\Include\10.0.14393.0\ucrt\locale.h + struct lconv + { + char* decimal_point; + char* thousands_sep; + char* grouping; + char* int_curr_symbol; + char* currency_symbol; + char* mon_decimal_point; + char* mon_thousands_sep; + char* mon_grouping; + char* positive_sign; + char* negative_sign; + char int_frac_digits = 0; // " = 0" For zero init + char frac_digits = 0; + char p_cs_precedes = 0; + char p_sep_by_space = 0; + char n_cs_precedes = 0; + char n_sep_by_space = 0; + char p_sign_posn = 0; + char n_sign_posn = 0; + wchar_t* _W_decimal_point; + wchar_t* _W_thousands_sep; + wchar_t* _W_int_curr_symbol; + wchar_t* _W_currency_symbol; + wchar_t* _W_mon_decimal_point; + wchar_t* _W_mon_thousands_sep; + wchar_t* _W_positive_sign; + wchar_t* _W_negative_sign; + } +} +else +{ + struct lconv + { + char* decimal_point; + char* thousands_sep; + char* grouping; + char* int_curr_symbol; + char* currency_symbol; + char* mon_decimal_point; + char* mon_thousands_sep; + char* mon_grouping; + char* positive_sign; + char* negative_sign; + byte int_frac_digits; + byte frac_digits; + byte p_cs_precedes; + byte p_sep_by_space; + byte n_cs_precedes; + byte n_sep_by_space; + byte p_sign_posn; + byte n_sign_posn; + byte int_p_cs_precedes; + byte int_p_sep_by_space; + byte int_n_cs_precedes; + byte int_n_sep_by_space; + byte int_p_sign_posn; + byte int_n_sign_posn; + } } version (CRuntime_Glibc) From 9948f076ae10a499cc1038d617f48c7272f8efc3 Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Tue, 9 Dec 2025 10:39:52 +0100 Subject: [PATCH 139/440] fix regression in dlang/dmd!21066 issuing deprecation message about immutable keys being cast to non-immutable. (dlang/dmd!22208) Avoid adding the cast for implicitly convertable expressions. --- dmd/dcast.d | 8 +++++--- dmd/expressionsem.d | 6 +++--- tests/dmd/runnable/testaa2.d | 8 ++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/dmd/dcast.d b/dmd/dcast.d index 7ae2df7687..41c103ce7e 100644 --- a/dmd/dcast.d +++ b/dmd/dcast.d @@ -4262,13 +4262,14 @@ void fix16997(Scope* sc, UnaExp ue) } /*********************************** - * See if both types are arrays that can be compared + * See if an AA key can be compared * for equality without any casting. Return true if so. * This is to enable comparing things like an immutable * array with a mutable one. */ -extern (D) bool arrayTypeCompatibleWithoutCasting(Type t1, Type t2) +extern (D) bool keyCompatibleWithoutCasting(Expression ekey, Type t2) { + Type t1 = ekey.type; t1 = t1.toBasetype(); t2 = t2.toBasetype(); @@ -4276,8 +4277,9 @@ extern (D) bool arrayTypeCompatibleWithoutCasting(Type t1, Type t2) { if (t1.nextOf().implicitConvTo(t2.nextOf()) >= MATCH.constant || t2.nextOf().implicitConvTo(t1.nextOf()) >= MATCH.constant) return true; + return false; } - return false; + return implicitConvTo(ekey, t2) >= MATCH.constant; } /******************************************************************/ diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index ff142b054b..b0abe5d0a6 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -11483,7 +11483,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor * https://issues.dlang.org/show_bug.cgi?id=2684 * see also bug https://issues.dlang.org/show_bug.cgi?id=2954 b */ - if (!arrayTypeCompatibleWithoutCasting(exp.e2.type, taa.index)) + if (!keyCompatibleWithoutCasting(exp.e2, taa.index)) { exp.e2 = exp.e2.implicitCastTo(sc, taa.index); // type checking if (exp.e2.type == Type.terror) @@ -14581,7 +14581,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor TypeAArray ta = cast(TypeAArray)t2b; // Special handling for array keys - if (!arrayTypeCompatibleWithoutCasting(exp.e1.type, ta.index)) + if (!keyCompatibleWithoutCasting(exp.e1, ta.index)) { // Convert key to type of key exp.e1 = exp.e1.implicitCastTo(sc, ta.index); @@ -19649,7 +19649,7 @@ private Expression rewriteAAIndexAssign(BinExp exp, Scope* sc, ref Type[2] alias foreach (ekey; ekeys) { Type tidx = ekey.type.toBasetype(); - if (tidx.ty == Tarray && tidx.nextOf().isMutable()) + if (tidx.ty == Tarray && tidx.nextOf().isMutable() && !ekey.isArrayLiteralExp()) { error(loc, "associative arrays can only be assigned values with immutable keys, not `%s`", tidx.toChars()); return ErrorExp.get(); diff --git a/tests/dmd/runnable/testaa2.d b/tests/dmd/runnable/testaa2.d index 74da97d55e..9247bbf84e 100644 --- a/tests/dmd/runnable/testaa2.d +++ b/tests/dmd/runnable/testaa2.d @@ -327,6 +327,14 @@ void test21207() foo(); } +/************************************************/ +void foo() @safe +{ + immutable key = 1; + int[int] aa; + aa[key] = 123; +} + /************************************************/ void testEvaluationOrder() From ea616b29b518a2d42c2a9509aa9928c93fb92d3c Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Tue, 9 Dec 2025 22:44:01 +1300 Subject: [PATCH 140/440] Implement for fast dfa engine point analysis (dlang/dmd!22195) --- dmd/dfa/entry.d | 24 +- dmd/dfa/fast/analysis.d | 418 +++++-- dmd/dfa/fast/expression.d | 1540 +++++++++++++++++--------- dmd/dfa/fast/statement.d | 91 +- dmd/dfa/fast/structure.d | 1010 ++++++++++++++++- dmd/dfa/utils.d | 38 +- tests/dmd/compilable/fastdfa.d | 102 ++ tests/dmd/fail_compilation/fastdfa.d | 96 +- 8 files changed, 2611 insertions(+), 708 deletions(-) diff --git a/dmd/dfa/entry.d b/dmd/dfa/entry.d index 0a2c7ca5f0..290c88076d 100644 --- a/dmd/dfa/entry.d +++ b/dmd/dfa/entry.d @@ -66,11 +66,11 @@ void fastDFA(FuncDeclaration fd, Scope* sc) } // Use these if statements for debugging specific things. - //if (fd.ident.toString != "incrementEffect") return; + //if (fd.ident.toString != "switchMakeKnown") return; //if (!(fd.ident.toString == "test3632" || fd.ident.toString == "test")) return; //if (fd.loc.linnum < 1380) return; //if (fd.getModule.ident.toString != "start") return; - //if (strcmp(mangleExact(fd), "_D5ocean4util9container5cache16ExpiringLRUCache__TQvTSQCaQBxQBvQBo20ExpiredCacheReloader__TQzTSQDpQDmQDkQDd25ExpiredCacheReloader_test7TrivialZQCz10CacheValueZQFa19getExpiringOrCreateMFmJbbZPQFi") != 0) return; + //if (strcmp(mangleExact(fd), "_D4core8internal5array8equality__T7isEqualTxS3dub6recipe13packagerecipe17ConfigurationInfoTxQBwZQCkFNbMAxQCjMQgmZb") != 0) return; // Protect functions based upon safetiness of it. // It may be desirable to disable some behaviors in @system code, or completely. @@ -122,13 +122,31 @@ void fastDFA(FuncDeclaration fd, Scope* sc) version (none) { - printf("function %s : %s = %s at %s\n", fd.getModule.ident.toChars, + printf("function s %s : %s = %s at %s\n", fd.getModule.ident.toChars, mangleExact(fd), fd.toFullSignature, fd.loc.toChars); fflush(stdout); } + version (none) + { + import dmd.hdrgen; + + OutBuffer buf; + HdrGenState hgs; + hgs.vcg_ast = true; + toCBuffer(fd, buf, hgs); + printf(buf.extractChars); + } + stmtWalker.start(fd); + version (none) + { + printf("function e %s : %s = %s at %s\n", fd.getModule.ident.toChars, + mangleExact(fd), fd.toFullSignature, fd.loc.toChars); + fflush(stdout); + } + dfaCommon.printIfStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { ob.printf("------------------------------ %s : %s = %s at ", fd.getModule.ident.toChars, mangleExact(fd), fd.toFullSignature); diff --git a/dmd/dfa/fast/analysis.d b/dmd/dfa/fast/analysis.d index b21fecf8ee..76f1ee51d0 100644 --- a/dmd/dfa/fast/analysis.d +++ b/dmd/dfa/fast/analysis.d @@ -21,6 +21,7 @@ import dmd.declaration; import dmd.astenums; import dmd.mtype; import dmd.root.array; +import dmd.common.outbuffer; import core.stdc.stdio; //version = DebugJoinMeetOp; @@ -41,17 +42,34 @@ struct DFAAnalyzer lr.cleanupConstant(ctxVar); + version (DebugJoinMeetOp) + { + printf("converge expression for var %p isSideEffect=%d\n", ctxVar, isSideEffect); + lr.printState("after cleanup"); + flush(stdout); + } + DFAScope* sc = isSideEffect ? dfaCommon.getSideEffectScope() : dfaCommon.currentDFAScope; DFAScopeVar* ret = sc.getScopeVar(ctxVar); while (sc !is null) { + version (DebugJoinMeetOp) + { + printf("on sc %p\n", sc); + flush(stdout); + } + + DFAScopeVar* scv; + if (ctx.truthiness == Truthiness.Maybe) { + scv = sc.getScopeVar(ctxVar); + if (!ctx.maybeTopSeen && ctxVar !is null && !ctxVar.haveBase) { - ret.lr = join(ret.lr, lr.copy); - assert(ret.lr.getContextVar() is ctxVar); + scv.lr = join(scv.lr, lr.copy, 0, null, false, true); + assert(scv.lr.getContextVar() is ctxVar); } } else @@ -60,12 +78,12 @@ struct DFAAnalyzer { if (!c.maybeTopSeen && c.var !is null && !c.var.haveBase) { - DFAScopeVar* scv = sc.getScopeVar(c.var); + scv = sc.getScopeVar(c.var); DFAConsequence* oldC = scv.lr.getContext; assert(oldC !is null); - oldC.joinConsequence(oldC, c, null, false, false, false); + oldC.joinConsequence(oldC, c, null, false, false, true); assert(scv.lr.getContextVar() is c.var); } } @@ -126,6 +144,8 @@ struct DFAAnalyzer c.truthiness = Truthiness.Unknown; if (c.nullable != cParent.nullable) c.nullable = Nullable.Unknown; + if (c.pa != cParent.pa) + c.pa = DFAPAValue.Unknown; } } @@ -867,12 +887,27 @@ struct DFAAnalyzer bool modellable = true; lr.walkMaybeTops((DFAConsequence* c) { - if (c.var !is null && !c.var.isModellable) + if (c.var is null) + return true; + else if (!c.var.isModellable) { modellable = false; return false; } + if (c.var.isLength) + { + DFAConsequence* bCctx = lr.addConsequence(c.var.base1); + bCctx.pa = c.pa; + + if ((c.pa.kind == DFAPAValue.Kind.Concrete + || c.pa.kind == DFAPAValue.Kind.Lower) && c.pa.value > 0) + { + bCctx.truthiness = Truthiness.True; + bCctx.nullable = Nullable.NonNull; + } + } + return true; }); @@ -1060,24 +1095,12 @@ struct DFAAnalyzer // We're in a direct assignment // Any effects from the lr directly apply to our lhs variable. + ret = dfaCommon.makeLatticeRef; + DFAConsequence* cctx = ret.addConsequence(assignToCtx, lrCctx); + ret.setContext(cctx); + if (!construct && noLR) assignToCtx.unmodellable = true; - - DFALatticeRef assignTo2 = assignTo.copy; - assignTo2.setContext(assignToCtx); - - DFALatticeRef joined = join(assignTo2, - lr.copyWithoutInfiniteLifetime, 0, assignToCtx); - DFAConsequence* c = joined.addConsequence(assignToCtx); - joined.setContext(c); - - if (lrCtx !is null && lrCtx.haveInfiniteLifetime) - { - c.truthiness = Truthiness.True; - c.nullable = Nullable.NonNull; - } - - ret = join(ret, joined, 0, null); } } else @@ -1143,6 +1166,9 @@ struct DFAAnalyzer if (lrIsTruthy && assignToCtx !is null && assignToCtx.isNullable) retCctx.nullable = Nullable.NonNull; + if (retCctx.truthiness == Truthiness.Maybe) + retCctx.truthiness = Truthiness.Unknown; + if (lrCtx !is null) { lrCtx.visitReferenceToAnotherVar((var) { @@ -1177,12 +1203,15 @@ struct DFAAnalyzer return ret; } - DFALatticeRef transferNegate(DFALatticeRef lr, bool protectElseNegate = false) + DFALatticeRef transferNegate(DFALatticeRef lr, Type type, + bool protectElseNegate = false, bool limitToContext = false) { bool requireMaybeContext; bool negate(DFAConsequence* c) { + c.pa.negate(type); + if (c.invertedOnce || (protectElseNegate && c.protectElseNegate)) { c.truthiness = Truthiness.Unknown; @@ -1227,7 +1256,7 @@ struct DFAAnalyzer { // !(a && b) only negate the outer expression // !(a) want to negate the inner condition - if (cctx.var is null) + if (cctx.var is null || limitToContext) negate(cctx); else lr.walkMaybeTops(&negate); @@ -1244,6 +1273,72 @@ struct DFAAnalyzer return lr; } + DFALatticeRef transferMathOp(DFALatticeRef lhs, DFALatticeRef rhs, Type type, PAMathOp op) + { + DFAConsequence* lhsCctx = lhs.getContext; + DFAConsequence* rhsCctx = rhs.getContext; + + assert(lhsCctx !is null); + assert(rhsCctx !is null); + + DFAPAValue newValue = lhsCctx.pa; + + final switch (op) + { + case PAMathOp.add: + newValue.addFrom(rhsCctx.pa, type); + break; + case PAMathOp.sub: + newValue.subtractFrom(rhsCctx.pa, type); + break; + case PAMathOp.mul: + newValue.multiplyFrom(rhsCctx.pa, type); + break; + case PAMathOp.div: + newValue.divideFrom(rhsCctx.pa, type); + break; + case PAMathOp.mod: + newValue.modulasFrom(rhsCctx.pa, type); + break; + case PAMathOp.and: + newValue.bitwiseAndBy(rhsCctx.pa, type); + break; + case PAMathOp.or: + newValue.bitwiseOrBy(rhsCctx.pa, type); + break; + case PAMathOp.xor: + newValue.bitwiseXorBy(rhsCctx.pa, type); + break; + case PAMathOp.pow: + newValue.powerBy(rhsCctx.pa, type); + break; + case PAMathOp.leftShift: + newValue.leftShiftBy(rhsCctx.pa, type); + break; + case PAMathOp.rightShiftSigned: + newValue.rightShiftSignedBy(rhsCctx.pa, type); + break; + case PAMathOp.rightShiftUnsigned: + newValue.rightShiftUnsignedBy(rhsCctx.pa, type); + break; + + case PAMathOp.postInc: + case PAMathOp.postDec: + assert(0); + } + + DFALatticeRef ret = transferLogicalAnd(lhs, rhs); + ret.check; + + if (ret.isNull) + ret = dfaCommon.makeLatticeRef; + DFAConsequence* cctx = ret.acquireConstantAsContext(); + cctx.pa = newValue; + + ret.check; + return ret; + } + DFALatticeRef transferDereference(DFALatticeRef lr, ref Loc loc) { DFAConsequence* ctx = lr.getContext; @@ -1290,7 +1385,8 @@ struct DFAAnalyzer ctx.var.var.ident.toChars, loc.toChars); ctx.nullable = Nullable.NonNull; - ctx.var.param.notNullIn = ParameterDFAInfo.Fact.Guaranteed; + if (!ctx.var.doNotInferNonNull) + ctx.var.param.notNullIn = ParameterDFAInfo.Fact.Guaranteed; } } else if (ctx.nullable == Nullable.Null) @@ -1302,7 +1398,7 @@ struct DFAAnalyzer /// See_Also: equalityArgTypes DFALatticeRef transferEqual(DFALatticeRef lhs, DFALatticeRef rhs, - bool equalityIsTrue, int equalityType) + bool equalityIsTrue, EqualityArgType equalityType) { // struct // floating point @@ -1314,82 +1410,104 @@ struct DFAAnalyzer return DFALatticeRef.init; DFAVar* lhsVar = lhsCctx.var, rhsVar = rhsCctx.var; - const treatAsPointer = equalityType == 6 || equalityType == 7 || equalityType == 8; - const treatAsBoolean = (lhsVar is null || lhsVar.isBoolean) - && (rhsVar is null || rhsVar.isBoolean); - Truthiness expectedTruthiness = Truthiness.Maybe; + bool couldBeUnknown; + checkVRPVar(lhsVar, couldBeUnknown); + checkVRPVar(rhsVar, couldBeUnknown); - if (equalityIsTrue) - { - if (treatAsPointer) - { - if (lhsCctx.nullable == Nullable.Null && lhsCctx.nullable == rhsCctx.nullable) - expectedTruthiness = Truthiness.True; - else if (lhsCctx.truthiness == Truthiness.False - && lhsCctx.truthiness == rhsCctx.truthiness) - expectedTruthiness = Truthiness.True; - else if (lhsCctx.truthiness != rhsCctx.truthiness && (lhsCctx.truthiness == Truthiness.False - || rhsCctx.truthiness == Truthiness.False) - && (lhsCctx.truthiness == Truthiness.True - || rhsCctx.truthiness == Truthiness.True)) - expectedTruthiness = Truthiness.False; - } - else - { - if (lhsCctx.truthiness == Truthiness.False - && lhsCctx.truthiness == rhsCctx.truthiness) - expectedTruthiness = Truthiness.True; - else if (lhsCctx.truthiness != rhsCctx.truthiness && (lhsCctx.truthiness == Truthiness.False - || rhsCctx.truthiness == Truthiness.False) - && (lhsCctx.truthiness == Truthiness.True - || rhsCctx.truthiness == Truthiness.True)) - expectedTruthiness = Truthiness.False; - } - } - else + const treatAsInteger = equalityType == EqualityArgType.Unknown; + const treatAsPointer = equalityType == EqualityArgType.DynamicArray + || equalityType == EqualityArgType.AssociativeArray + || equalityType == EqualityArgType.Nullable; + + dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("Transfer equal treatAsInteger=%d, treatAsPointer=%d, couldBeUnknown=%d", + treatAsInteger, treatAsPointer, couldBeUnknown); + ob.writestring("\n"); + + prefix(""); + ob.printf("lhs cctx %p, lhs var %p, rhs cctx %p, rhs var %p", + lhsCctx, lhsVar, rhsCctx, rhsVar); + ob.writestring("\n"); + }); + + Truthiness expectedTruthiness; + + if ((lhsVar is null || lhsVar.isModellable) && (rhsVar is null || rhsVar.isModellable)) { - if (treatAsPointer) + expectedTruthiness = Truthiness.Maybe; + + if (equalityIsTrue) { - if ((lhsCctx.nullable == Nullable.NonNull - || rhsCctx.nullable == Nullable.NonNull) - && lhsCctx.nullable != rhsCctx.nullable) - expectedTruthiness = Truthiness.True; - else if (lhsCctx.nullable == Nullable.NonNull && lhsCctx.nullable - == rhsCctx.nullable) - expectedTruthiness = Truthiness.Maybe; - else if (lhsCctx.nullable == Nullable.Null && lhsCctx.nullable == rhsCctx.nullable) - expectedTruthiness = Truthiness.False; - else if (lhsCctx.truthiness < Truthiness.False - || rhsCctx.truthiness < Truthiness.False) - expectedTruthiness = Truthiness.Unknown; - else if (lhsCctx.truthiness != rhsCctx.truthiness) - expectedTruthiness = Truthiness.Maybe; - else if (lhsCctx.truthiness == rhsCctx.truthiness) + if (treatAsPointer) { - // Can't know just by truthiness if lhs == rhs exactly if it isn't boolean. - if (treatAsBoolean) + if (lhsCctx.nullable == Nullable.Null && lhsCctx.nullable == rhsCctx.nullable) + expectedTruthiness = Truthiness.True; + else if (lhsCctx.truthiness == Truthiness.False + && lhsCctx.truthiness == rhsCctx.truthiness) + expectedTruthiness = Truthiness.True; + else if (lhsCctx.truthiness != rhsCctx.truthiness && (lhsCctx.truthiness == Truthiness.False + || rhsCctx.truthiness == Truthiness.False) + && (lhsCctx.truthiness == Truthiness.True + || rhsCctx.truthiness == Truthiness.True)) expectedTruthiness = Truthiness.False; - else - expectedTruthiness = Truthiness.Unknown; + } + else + { + expectedTruthiness = lhsCctx.pa.compareEqual(rhsCctx.pa); + + if (expectedTruthiness < Truthiness.False) + { + if (lhsCctx.truthiness == Truthiness.False + && lhsCctx.truthiness == rhsCctx.truthiness) + expectedTruthiness = Truthiness.True; + else if (!treatAsInteger && lhsCctx.truthiness != rhsCctx.truthiness + && (lhsCctx.truthiness == Truthiness.False + || rhsCctx.truthiness == Truthiness.False) + && (lhsCctx.truthiness == Truthiness.True + || rhsCctx.truthiness == Truthiness.True)) + expectedTruthiness = Truthiness.False; + else + expectedTruthiness = Truthiness.Maybe; + } + else if (couldBeUnknown || !treatAsInteger) + expectedTruthiness = Truthiness.Maybe; } } else { - if (lhsCctx.truthiness < Truthiness.False || rhsCctx.truthiness < Truthiness.False) - expectedTruthiness = Truthiness.Unknown; - else if (lhsCctx.truthiness != rhsCctx.truthiness) - expectedTruthiness = Truthiness.Maybe; - else if (lhsCctx.truthiness == rhsCctx.truthiness) + if (treatAsPointer) { - // Can't know just by truthiness if lhs == rhs exactly if it isn't boolean. - if (treatAsBoolean) + if ((lhsCctx.nullable == Nullable.NonNull + || rhsCctx.nullable == Nullable.NonNull) + && lhsCctx.nullable != rhsCctx.nullable) + expectedTruthiness = Truthiness.True; + else if (lhsCctx.nullable == Nullable.NonNull + && lhsCctx.nullable == rhsCctx.nullable) + expectedTruthiness = Truthiness.Maybe; + else if (lhsCctx.nullable == Nullable.Null + && lhsCctx.nullable == rhsCctx.nullable) expectedTruthiness = Truthiness.False; + } + else + { + expectedTruthiness = lhsCctx.pa.compareNotEqual(rhsCctx.pa); + + if (expectedTruthiness >= Truthiness.False) + { + if (couldBeUnknown || !treatAsInteger) + expectedTruthiness = Truthiness.Maybe; + } else - expectedTruthiness = Truthiness.Unknown; + expectedTruthiness = Truthiness.Maybe; } } } + dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("Expected truthiness of equality %d", expectedTruthiness); + ob.writestring("\n"); + }); + if (expectedTruthiness == Truthiness.Maybe) { // Copy over the effects from a constant to non-constant with variable. @@ -1415,10 +1533,24 @@ struct DFAAnalyzer if (copy) { - if (toEffectCctx.var.isTruthy) - toEffectCctx.truthiness = fromEffectCctx.truthiness; - if (toEffectCctx.var.isNullable) - toEffectCctx.nullable = fromEffectCctx.nullable; + if (equalityIsTrue) + { + if (toEffectCctx.var.isTruthy) + toEffectCctx.truthiness = fromEffectCctx.truthiness; + if (toEffectCctx.var.isNullable) + toEffectCctx.nullable = fromEffectCctx.nullable; + } + else + { + if (toEffectCctx.var.isTruthy) + toEffectCctx.truthiness = fromEffectCctx.truthiness == Truthiness.True ? Truthiness.False + : (fromEffectCctx.truthiness == Truthiness.False + ? Truthiness.True : Truthiness.Unknown); + if (toEffectCctx.var.isNullable) + toEffectCctx.nullable = fromEffectCctx.nullable == Nullable.NonNull ? Nullable.Null + : (fromEffectCctx.nullable == Nullable.Null + ? Nullable.NonNull : Nullable.Unknown); + } } } } @@ -1493,6 +1625,67 @@ struct DFAAnalyzer return ret; } + DFALatticeRef transferGreaterThan(bool orEqualTo, DFALatticeRef lhs, DFALatticeRef rhs) + { + DFAVar* lhsVar, rhsVar; + DFAConsequence* lhsCctx = lhs.getContext(lhsVar); + DFAConsequence* rhsCctx = rhs.getContext(rhsVar); + + assert(lhsCctx !is null); + assert(rhsCctx !is null); + + bool couldBeUnknown; + checkVRPVar(lhsCctx.var, couldBeUnknown); + checkVRPVar(rhsCctx.var, couldBeUnknown); + + Truthiness expectedTruthiness; + + if ((lhsVar is null || lhsVar.isModellable) && (rhsVar is null || rhsVar.isModellable)) + { + expectedTruthiness = orEqualTo ? lhsCctx.pa.greaterThanOrEqual( + rhsCctx.pa) : lhsCctx.pa.greaterThan(rhsCctx.pa); + + if (couldBeUnknown) + expectedTruthiness = Truthiness.Maybe; + + if (lhsVar !is null) + { + if (rhsCctx.pa.kind == DFAPAValue.Kind.Concrete + && (rhsCctx.pa.value > 0 || (!orEqualTo && rhsCctx.pa.value == 0))) + { + // ok clearly non-null + + if (lhsVar.isTruthy) + lhsCctx.truthiness = Truthiness.True; + if (lhsVar.isNullable) + lhsCctx.nullable = Nullable.NonNull; + } + + lhsVar.walkRoots((var) { + if (var is lhsVar) + return; + + DFAConsequence* cctx = lhs.findConsequence(var); + if (cctx is null) + return; + + cctx.truthiness = lhsCctx.truthiness; + cctx.nullable = lhsCctx.nullable; + cctx.pa = lhsCctx.pa; + }); + } + + if (rhsVar !is null) + { + rhsVar.walkRoots((var) { var.doNotInferNonNull = true; }); + } + } + + DFALatticeRef ret = this.transferLogicalAnd(lhs, rhs); + ret.acquireConstantAsContext(expectedTruthiness, Nullable.Unknown); + return ret; + } + void transferGoto(DFAScope* toSc, bool isAfter) { DFAScopeRef temp = dfaCommon.currentDFAScope.copy; @@ -1544,15 +1737,17 @@ struct DFAAnalyzer DFAConsequence* cctx = ret.acquireConstantAsContext; ret.check; - DFAVar* lastMaybe; + DFAVar* firstMaybe; + DFAVar** lastMaybe = &firstMaybe; lhs.walkMaybeTops((DFAConsequence* oldC) { if (oldC.var is null) return true; DFAConsequence* newC = ret.addConsequence(oldC.var, oldC); - newC.maybe = lastMaybe; - lastMaybe = newC.var; + + *lastMaybe = newC.var; + lastMaybe = &newC.maybe; ret.check; return true; @@ -1567,8 +1762,9 @@ struct DFAAnalyzer if (result is null) { DFAConsequence* newC = ret.addConsequence(oldC.var, oldC); - newC.maybe = lastMaybe; - lastMaybe = newC.var; + + *lastMaybe = newC.var; + lastMaybe = &newC.maybe; } else result.joinConsequence(result, oldC, null, false, false, true); @@ -1601,7 +1797,7 @@ struct DFAAnalyzer } } - cctx.maybe = lastMaybe; + cctx.maybe = firstMaybe; if (cctxLHS !is null && cctxRHS !is null) { @@ -1925,13 +2121,20 @@ private: version (DebugJoinMeetOp) { - printf("Running join on %p and %p, constantRHS=%p, filter=%d, ignoreLHS=%p\n", - lhsVar, rhsVar, constantRHS, filterDepthOfVariable, ignoreLHSCtx); + printf("Running join on %p and %p, constantRHS=%p, filter=%d, ignoreLHS=%p, ignoreWriteCount=%d, unknownAware=%d\n", + lhsVar, rhsVar, constantRHS, filterDepthOfVariable, + ignoreLHSCtx, ignoreWriteCount, unknownAware); fflush(stdout); } void processLHSVar(DFAConsequence* c1) { + version (DebugJoinMeetOp) + { + printf("Processing LHS var %p\n", c1.var); + fflush(stdout); + } + if (filterDepthOfVariable < c1.var.declaredAtDepth && filterDepthOfVariable > 0) return; @@ -1979,6 +2182,12 @@ private: foreach (c2; rhs) { + version (DebugJoinMeetOp) + { + printf("Processing RHS var %p\n", c2.var); + fflush(stdout); + } + if (c2.var is null || ret.findConsequence(c2.var) !is null) continue; @@ -1997,6 +2206,12 @@ private: if (rhsCtx !is null && rhsVar is null && lhsVar !is null) { + version (DebugJoinMeetOp) + { + printf("Processing RHS context var %p to lhs context var %p\n", rhsCtx.var, lhsVar); + fflush(stdout); + } + DFAConsequence* result = ret.addConsequence(lhsVar); result.joinConsequence(rhsCtx, null, null, false, false, unknownAware); if (result.writeOnVarAtThisPoint < lhsCtx.writeOnVarAtThisPoint) @@ -2015,6 +2230,15 @@ private: return ret; } + void checkVRPVar(DFAVar* var, ref bool couldBeUnknown) + { + if (var is null) + return; + + if (var.declaredAtDepth > 0 && dfaCommon.lastLoopyLabel.depth > var.declaredAtDepth) + couldBeUnknown = true; + } + void seeWrite(ref DFAVar* assignTo, ref DFALatticeRef from) { assert(assignTo !is null); diff --git a/dmd/dfa/fast/expression.d b/dmd/dfa/fast/expression.d index 7b7e4a6676..0c349c3dd6 100644 --- a/dmd/dfa/fast/expression.d +++ b/dmd/dfa/fast/expression.d @@ -34,6 +34,8 @@ struct ExpressionWalker StatementWalker stmtWalker; DFAAnalyzer* analyzer; + __gshared immutable(string[]) AllExprOpNames = [__traits(allMembers, EXP)]; + void seeConvergeExpression(DFALatticeRef lr, bool isSideEffect = false) { dfaCommon.printStateln("Converging expression:"); @@ -98,6 +100,10 @@ struct ExpressionWalker ret.check; ret.printState("result", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + + dfaCommon.currentDFAScope.printState("so far", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + dfaCommon.currentDFAScope.check; return ret; } @@ -123,10 +129,34 @@ struct ExpressionWalker return ret; } - DFALatticeRef seeNegate(DFALatticeRef lr, bool protectElseNegate = false) + DFALatticeRef seeNegate(DFALatticeRef lr, Type type, + bool protectElseNegate = false, bool limitToContext = false) { lr.printState("Negate", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); - return analyzer.transferNegate(lr, protectElseNegate); + + dfaCommon.check; + DFALatticeRef ret = analyzer.transferNegate(lr, type, protectElseNegate, limitToContext); + dfaCommon.check; + + ret.printState("result", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + return ret; + } + + DFALatticeRef seeMathOp(DFALatticeRef lhs, DFALatticeRef rhs, Type type, PAMathOp op) + { + dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("Math op %d", op); + ob.writestring("\n"); + }); + lhs.printState("lhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + rhs.printState("rhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + + dfaCommon.check; + DFALatticeRef ret = analyzer.transferMathOp(lhs, rhs, type, op); + dfaCommon.check; + + ret.printState("result", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + return ret; } DFALatticeRef seeDereference(ref Loc loc, DFALatticeRef lr) @@ -241,6 +271,20 @@ struct ExpressionWalker return ret; } + DFALatticeRef seeGreaterThan(bool orEqualTo, DFALatticeRef lhs, DFALatticeRef rhs) + { + dfaCommon.printStateln(orEqualTo ? "Greater than or equal to:" : "Greater than:"); + lhs.printState("lhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + rhs.printState("rhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + + dfaCommon.check; + DFALatticeRef ret = analyzer.transferGreaterThan(orEqualTo, lhs, rhs); + dfaCommon.check; + + ret.printState("result", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + return ret; + } + DFALatticeRef entry(DFAVar* assignTo, DFAVar* constructInto, Expression exp) { DFALatticeRef lattice = walk(exp); @@ -276,7 +320,11 @@ struct ExpressionWalker if (ctx !is null && ctx.isNullable && cctx.truthiness == Truthiness.Unknown) { DFALatticeRef against = dfaCommon.makeLatticeRef; - against.acquireConstantAsContext(Truthiness.True, Nullable.NonNull); + + if (truthiness) + against.acquireConstantAsContext(Truthiness.True, Nullable.NonNull); + else + against.acquireConstantAsContext(Truthiness.False, Nullable.Null); ret = this.seeEqual(ret, against, truthiness, type, null); } @@ -285,7 +333,7 @@ struct ExpressionWalker if ((cctx = ret.getGateConsequence) !is null) { ret.setContext(cctx); - ret = this.seeNegate(ret); + ret = this.seeNegate(ret, type); } else { @@ -303,15 +351,11 @@ struct ExpressionWalker if (expr is null || dfaCommon.currentDFAScope.haveJumped) return DFALatticeRef.init; - __gshared immutable(string[]) AllExprOpNames = [ - __traits(allMembers, EXP) - ]; - dfaCommon.edepth++; dfaCommon.check; dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { - ob.printf("[%p]%3d (%s): at ", expr, expr.op, AllExprOpNames[expr.op].ptr); + ob.printf("[%p]%3d walk (%s): at ", expr, expr.op, AllExprOpNames[expr.op].ptr); appendLoc(ob, expr.loc); ob.writestring("\n"); }); @@ -459,6 +503,11 @@ struct ExpressionWalker { case InitKind.exp: auto ei = var._init.isExpInitializer; + + // does this var escape another? Can't model that. + if ((var.storage_class & STC.ref_) == STC.ref_) + markUnmodellable(ei.exp); + DFALatticeRef lr = this.walk(ei.exp); if (ei.exp.isConstructExp || ei.exp.isBlitExp) @@ -497,17 +546,17 @@ struct ExpressionWalker return seeAssign(lhs, true, rhs); case EXP.negate: // -x - // Without VRP we can't actually model this. auto ue = expr.isUnaExp; DFALatticeRef ret = this.walk(ue.e1); - ret.acquireConstantAsContext; - return ret; + return this.seeNegate(ret, ue.type, false, true); // Basic types case EXP.void_: case EXP.float64: case EXP.complex80: - return DFALatticeRef.init; + DFALatticeRef ret = dfaCommon.makeLatticeRef; + ret.acquireConstantAsContext; + return ret; case EXP.call: auto ce = expr.isCallExp; @@ -520,7 +569,6 @@ struct ExpressionWalker dfaCommon.printStateln("blit lhs"); DFALatticeRef lhs = this.walk(be.e1), rhs; - DFAVar* lhsVar = lhs.getContextVar; if (auto e2ve = be.e2.isVarExp) { @@ -591,145 +639,141 @@ struct ExpressionWalker return seeDereference(pe.loc, lr); case EXP.index: - // See Slice - auto ie = expr.isIndexExp; + { + // See Slice + auto ie = expr.isIndexExp; - dfaCommon.printStateln("index lhs"); - DFALatticeRef lhs = this.walk(ie.e1); - dfaCommon.printStateln("index rhs"); - DFALatticeRef index = this.walk(ie.e2); + dfaCommon.printStateln("index lhs"); + DFALatticeRef lhs = this.walk(ie.e1); + dfaCommon.printStateln("index rhs"); + DFALatticeRef index = this.walk(ie.e2); - DFAVar* lhsCtx; - DFAConsequence* lhsCctx = lhs.getContext(lhsCtx); + DFAVar* lhsCtx; + DFAConsequence* lhsCctx = lhs.getContext(lhsCtx); - Type lhsType = ie.e1.type; - bool resultHasEffect; + Type lhsType = ie.e1.type; + bool resultHasEffect; - if (lhsCctx !is null) - { - // Apply effects that this operation will have on to the lhs + if (lhsCctx !is null) + { + // Apply effects that this operation will have on to the lhs - bool effectIndexBase = ie.indexIsInBounds; + bool effectIndexBase = ie.indexIsInBounds; - if (lhsType.isTypeAArray !is null) - { - if (ie.modifiable) - effectIndexBase = true; + if (lhsType.isTypeAArray !is null) + { + if (ie.modifiable) + effectIndexBase = true; + } + else + resultHasEffect = true; + + if (effectIndexBase) + { + lhsCctx.truthiness = Truthiness.True; + lhsCctx.nullable = Nullable.NonNull; + } } - else - resultHasEffect = true; - if (effectIndexBase) + if (lhsCtx !is null && lhsCtx.isNullable) { - lhsCctx.truthiness = Truthiness.True; - lhsCctx.nullable = Nullable.NonNull; + // Dereference the lhs if its a pointer, + // this really should be the case, but it prevents unnecessary work for static arrays. + lhs = seeDereference(ie.loc, lhs); } - } - if (lhsCtx !is null && lhsCtx.isNullable) - { - // Dereference the lhs if its a pointer, - // this really should be the case, but it prevents unnecessary work for static arrays. - lhs = seeDereference(ie.loc, lhs); - } + DFAVar* indexVar = dfaCommon.findIndexVar(lhsCtx); + DFALatticeRef combined = this.seeLogicalAnd(lhs, index); + DFAConsequence* newCctx = combined.addConsequence(indexVar); + combined.setContext(newCctx); - DFAVar* indexVar = dfaCommon.findIndexVar(lhsCtx); - DFALatticeRef combined = this.seeLogicalAnd(lhs, index); - DFAConsequence* newCctx = combined.addConsequence(indexVar); - combined.setContext(newCctx); + if (resultHasEffect && indexVar !is null) + { + if (indexVar.isTruthy) + newCctx.truthiness = Truthiness.True; + if (indexVar.isNullable) + newCctx.nullable = Nullable.NonNull; + } - if (resultHasEffect && indexVar !is null) - { - if (indexVar.isTruthy) - newCctx.truthiness = Truthiness.True; - if (indexVar.isNullable) - newCctx.nullable = Nullable.NonNull; + return combined; } - return combined; - case EXP.slice: - // See index - auto se = expr.isSliceExp; + { + // See index + auto se = expr.isSliceExp; - dfaCommon.printStateln("Slice base"); - DFALatticeRef base = this.walk(se.e1); - DFAVar* baseCtx; - DFAConsequence* baseCctx = base.getContext(baseCtx); + dfaCommon.printStateln("Slice base"); + DFALatticeRef base = this.walk(se.e1); + DFAVar* baseCtx = base.getContextVar; - if (se.lwr is null && se.upr is null) - { - // Equivalent to doing slice[] - DFAVar* indexVar = dfaCommon.findIndexVar(baseCtx); - DFAConsequence* newCctx = base.addConsequence(indexVar); - base.setContext(newCctx); - return base; - } + if (se.lwr is null && se.upr is null) + { + // Equivalent to doing slice[] + DFAVar* indexVar = dfaCommon.findIndexVar(baseCtx); + DFAConsequence* newCctx = base.addConsequence(indexVar); + base.setContext(newCctx); + return base; + } - Truthiness expectedTruthiness; + Truthiness expectedTruthiness; + DFALatticeRef ret = base; - if (baseCctx !is null && se.upperIsInBounds) - { - // Earlier VRP in the compiler has determined that it is non-null. - // Even if the fast DFA can't determine it, that has been done already. + { + dfaCommon.printStateln("Slice [lwr"); + DFALatticeRef lower = this.walk(se.lwr); + dfaCommon.printStateln("Slice upr]"); + DFALatticeRef upper = this.walk(se.upr); - baseCctx.nullable = Nullable.NonNull; - } + DFAConsequence* lowerCctx = lower.getContext, upperCctx = upper.getContext; + DFAPAValue newPA; - DFALatticeRef ret = base; + if (lowerCctx !is null && upperCctx !is null) + { + newPA = upperCctx.pa; + newPA.subtractFrom(lowerCctx.pa, Type.tuns64); + } - if (se.lwr !is null) - { - // Handle [X .. X] - if (se.upr !is null) - { - auto lwrI = se.lwr.isIntegerExp; - auto uprI = se.upr.isIntegerExp; + DFALatticeRef together = this.seeLogicalAnd(lower, upper); + ret = this.seeLogicalAnd(ret, together); - if (lwrI !is null && uprI !is null && lwrI.toInteger == uprI.toInteger) - expectedTruthiness = Truthiness.False; - } + DFAConsequence* cctx = ret.addConsequence(baseCtx); + cctx.pa = newPA; - dfaCommon.printStateln("Slice [lwr"); - ret = this.seeLogicalAnd(ret, this.walk(se.lwr)); - } + if (se.upperIsInBounds + || (newPA.kind == DFAPAValue.Kind.Concrete && newPA.value > 0)) + { + expectedTruthiness = Truthiness.True; + cctx.truthiness = Truthiness.True; + cctx.nullable = Nullable.NonNull; + } + } - if (se.upr !is null) - { - dfaCommon.printStateln("Slice upr]"); - ret = this.seeLogicalAnd(ret, this.walk(se.upr)); - } - else if (se.lengthVar !is null) - { - // Implicit length var for the upper. - DFAVar* lengthVar = dfaCommon.findVariable(se.lengthVar); - ret = this.seeLogicalAnd(ret, dfaCommon.acquireLattice(lengthVar)); - } + if (baseCtx !is null && baseCtx.isNullable) + { + // Dereference if its a pointer, + // this really should be the case, but it prevents unnecessary work for static arrays. + ret = seeDereference(se.loc, ret); + } - if (baseCtx !is null && baseCtx.isNullable) - { - // Dereference if its a pointer, - // this really should be the case, but it prevents unnecessary work for static arrays. - ret = seeDereference(se.loc, ret); - } + DFAVar* indexVar = dfaCommon.findIndexVar(baseCtx); + DFAConsequence* newCctx = ret.addConsequence(indexVar); + ret.setContext(newCctx); - DFAVar* indexVar = dfaCommon.findIndexVar(baseCtx); - DFAConsequence* newCctx = ret.addConsequence(indexVar); - ret.setContext(newCctx); + if (indexVar !is null) + { + if (indexVar.isTruthy) + newCctx.truthiness = expectedTruthiness; - if (indexVar !is null) - { - if (indexVar.isTruthy) - newCctx.truthiness = expectedTruthiness; + // If this expression were to succeed, the resulting slice will be non-null. + // Thanks to the read barrier for bounds checking. + if (indexVar.isNullable) + newCctx.nullable = Nullable.NonNull; + } - // If this expression were to succeed, the resulting slice will be non-null. - // Thanks to the read barrier for bounds checking. - if (indexVar.isNullable) - newCctx.nullable = Nullable.NonNull; + return ret; } - return ret; - case EXP.assert_: auto ae = expr.isAssertExp; DFALatticeRef lr = this.walk(ae.e1); @@ -750,6 +794,9 @@ struct ExpressionWalker DFALatticeRef ret = this.callFunction(ne.member, ne.thisexp, ne.argprefix, ne.arguments, ne.loc); + if (ne.placement !is null) + markUnmodellable(ne.placement); + if (ret.isNull) ret = dfaCommon.makeLatticeRef; @@ -795,52 +842,34 @@ struct ExpressionWalker return inProgress; case EXP.orOr: - auto be = expr.isBinExp; - DFALatticeRef inProgress, toNegate; - DFAScopeRef inProgressScr; - - while (be !is null) - { - // Make sure any effects converged into the scope by and expressions ext. don't effect rhs - stmtWalker.startScope; - dfaCommon.currentDFAScope.sideEffectFree = true; - - dfaCommon.printStateln("Or expression lhs:"); - DFALatticeRef lhs = this.walk(be.e1); - inProgressScr = stmtWalker.seeLoopyLabelAwareStage(inProgressScr, - stmtWalker.endScope); - - toNegate = this.adaptConditionForBranch(lhs.copy, be.e1.type, false); - - if (inProgress.isNull) - inProgress = lhs; - else - inProgress = seeLogicalOr(inProgress, lhs); - - if (be.e2.op == EXP.orOr) - { - be = be.e2.isBinExp; - continue; - } - else - { - // Make sure any effects converged into the scope by and expressions ext. don't effect rhs or return - stmtWalker.startScope; - dfaCommon.currentDFAScope.sideEffectFree = true; + int predicateNegation; + return this.walkCondition(expr.isLogicalExp, predicateNegation); - this.seeSilentAssert(toNegate, false, true); + case EXP.lessThan: + // < becomes > + auto be = expr.isBinExp; + DFALatticeRef lhs = this.walk(be.e2); + DFALatticeRef rhs = this.walk(be.e1); + return this.seeGreaterThan(false, lhs, rhs); - dfaCommon.printStateln("Or expression rhs:"); - DFALatticeRef rhs = this.walk(be.e2); - inProgressScr = stmtWalker.seeLoopyLabelAwareStage(inProgressScr, - stmtWalker.endScope); + case EXP.lessOrEqual: + // <= becomes >= + auto be = expr.isBinExp; + DFALatticeRef lhs = this.walk(be.e2); + DFALatticeRef rhs = this.walk(be.e1); + return this.seeGreaterThan(true, lhs, rhs); - inProgress = seeLogicalOr(inProgress, rhs); - break; - } - } + case EXP.greaterThan: + auto be = expr.isBinExp; + DFALatticeRef lhs = this.walk(be.e1); + DFALatticeRef rhs = this.walk(be.e2); + return this.seeGreaterThan(false, lhs, rhs); - return inProgress; + case EXP.greaterOrEqual: + auto be = expr.isBinExp; + DFALatticeRef lhs = this.walk(be.e1); + DFALatticeRef rhs = this.walk(be.e2); + return this.seeGreaterThan(true, lhs, rhs); case EXP.in_: auto be = expr.isBinExp; @@ -859,438 +888,398 @@ struct ExpressionWalker return this.seeEqual(lhs, rhs, true, be.e1.type, be.e2.type); - case EXP.lessThan: - case EXP.lessOrEqual: - case EXP.greaterThan: - case EXP.greaterOrEqual: - auto be = expr.isBinExp; - - DFALatticeRef lr = this.walk(be.e1); - lr.walkMaybeTops((DFAConsequence* c) { - if (c.var !is null) - { - c.var.walkRoots((root) { - root.unmodellable = true; - }); - } - return true; - }); - - lr = this.walk(be.e2); - lr.walkMaybeTops((DFAConsequence* c) { - if (c.var !is null) - { - c.var.walkRoots((root) { - root.unmodellable = true; - }); - } - return true; - }); - - DFALatticeRef ret = dfaCommon.makeLatticeRef; - ret.acquireConstantAsContext; - return ret; - case EXP.addAssign: + return walkMathAssignOp(expr.isBinExp, PAMathOp.add); case EXP.minAssign: - case EXP.leftShiftAssign: - case EXP.rightShiftAssign: - case EXP.unsignedRightShiftAssign: + return walkMathAssignOp(expr.isBinExp, PAMathOp.sub); case EXP.mulAssign: + return walkMathAssignOp(expr.isBinExp, PAMathOp.mul); case EXP.divAssign: + return walkMathAssignOp(expr.isBinExp, PAMathOp.div); case EXP.modAssign: + return walkMathAssignOp(expr.isBinExp, PAMathOp.mod); case EXP.andAssign: + return walkMathAssignOp(expr.isBinExp, PAMathOp.and); case EXP.orAssign: + return walkMathAssignOp(expr.isBinExp, PAMathOp.or); case EXP.xorAssign: + return walkMathAssignOp(expr.isBinExp, PAMathOp.xor); case EXP.powAssign: - // We don't support the operator itself, but we do support the assignment. - // If we supported value range propergation this would need changing. - auto be = expr.isBinExp; - - dfaCommon.printStateln("assigns lhs"); - DFALatticeRef lhs = this.walk(be.e1); - dfaCommon.printStateln("assigns rhs"); - DFALatticeRef rhs = this.walk(be.e2); - - // Because we can't model it without VRP, we'll give it an unknown value. - if (rhs.isNull) - rhs = dfaCommon.makeLatticeRef; - rhs.acquireConstantAsContext; - return seeAssign(lhs, false, rhs); + return walkMathAssignOp(expr.isBinExp, PAMathOp.pow); + case EXP.leftShiftAssign: + return walkMathAssignOp(expr.isBinExp, PAMathOp.leftShift); + case EXP.rightShiftAssign: + return walkMathAssignOp(expr.isBinExp, PAMathOp.rightShiftSigned); + case EXP.unsignedRightShiftAssign: + return walkMathAssignOp(expr.isBinExp, PAMathOp.rightShiftUnsigned); case EXP.concatenateAssign: // ~= + return concatenateTwo(expr.isBinExp, 0, true); case EXP.concatenateElemAssign: + return concatenateTwo(expr.isBinExp, 1, true); case EXP.concatenateDcharAssign: - // Whatever lhs started out as, it'll be non-null once we're done with it. - auto be = expr.isBinExp; - - dfaCommon.printStateln("concat assign lhs"); - DFALatticeRef lhs = this.walk(be.e1); - dfaCommon.printStateln("concat assign rhs"); - DFALatticeRef rhs = this.walk(be.e2); - - DFAVar* lhsCtx; - DFAConsequence* lhsCctx = lhs.getContext(lhsCtx), rhsCctx = rhs.getContext; - if (lhsCctx is null) - { - // We can't analyse this. - return DFALatticeRef.init; - } + return concatenateTwo(expr.isBinExp, 2, true); - const nullableResult = concatNullableResult(be.e1.type, be.e2.type); - dfaCommon.printState((ref OutBuffer ob, - scope PrintPrefixType prefix) => ob.printf("concat nullable result %d\n", - nullableResult)); - - DFALatticeRef ret = this.seeAssign(lhs, false, rhs, false, - nullableResult == 1 || nullableResult == 2 ? 3 : 0); - - if (ret.isNull) + case EXP.loweredAssignExp: { - ret = dfaCommon.makeLatticeRef; - ret.acquireConstantAsContext; - } - return ret; + // Used for changing the length of lhs. + // While we can just walk the lowering and it'll "work", + // it won't be good enough. + auto be = expr.isLoweredAssignExp; - case EXP.loweredAssignExp: - // Used for changing the length of lhs. - // While we can just walk the lowering and it'll "work", - // it won't be good enough. - auto be = expr.isLoweredAssignExp; + if (auto ale = be.e1.isArrayLengthExp) + { + // See: slice.length = rhs + dfaCommon.printStateln("length assign lhs"); + DFALatticeRef lhs = this.walk(ale.e1); + dfaCommon.printStateln("length assign rhs"); + DFALatticeRef rhs = this.walk(be.e2); - dfaCommon.printStateln("length assign lhs"); - DFALatticeRef lhs; + DFAConsequence* lhsCctx = lhs.getContext, rhsCctx = rhs.getContext; + assert(lhsCctx !is null); + assert(rhsCctx !is null); - // See: slice.length = ... - if (auto ale = be.e1.isArrayLengthExp) - lhs = this.walk(ale.e1); - else - lhs = this.walk(be.e1); + { + // remove anything that added to the calculation of the point analysis value + DFAPAValue rhsPA = rhsCctx.pa; - dfaCommon.printStateln("length assign rhs"); - DFALatticeRef rhs = this.walk(be.e2); + rhs = dfaCommon.makeLatticeRef; + rhsCctx = rhs.acquireConstantAsContext; + rhsCctx.pa = rhsPA; + } - DFAConsequence* lhsCctx = lhs.getContext, rhsCctx = rhs.getContext; + // We use the rhs truthiness to model the new length + // If it is false, the new length is zero, and therefore null. + // If it is true, the new length is greater than zero, and therefore non-null. + int alteredState; - if (lhsCctx is null) - { - // Welp we can't analyse this. - return DFALatticeRef.init; - } + if (rhsCctx is null || rhsCctx.truthiness == Truthiness.Unknown + || rhsCctx.truthiness == Truthiness.Maybe) + { + alteredState = 5; + } + else + { + if (rhsCctx.truthiness == Truthiness.True) + alteredState = 3; + else + alteredState = 4; + } - // We use the rhs truthiness to model the new length - // If it is false, the new length is zero, and therefore null. - // If it is true, the new length is greater than zero, and therefore non-null. - int alteredState; + { + DFAVar* lhsLengthVar = dfaCommon.findSliceLengthVar(lhsCctx.var); + lhs.addConsequence(lhsLengthVar, lhsCctx); + } - if (rhsCctx is null || rhsCctx.truthiness == Truthiness.Unknown - || rhsCctx.truthiness == Truthiness.Maybe) - { - alteredState = 5; - } - else - { - if (rhsCctx.truthiness == Truthiness.True) - alteredState = 3; + return this.seeAssign(lhs, false, rhs, false, alteredState); + } else - alteredState = 4; - } - - DFALatticeRef ret = this.seeAssign(lhs, false, rhs, false, alteredState); - - if (ret.isNull) - { - ret = dfaCommon.makeLatticeRef; - ret.acquireConstantAsContext; + { + // unknown lowered assign exp, use the lowering. + return this.walk(be.lowering); + } } - else - this.seeConvergeExpression(ret.copy, true); - - return ret; - case EXP.leftShift: - case EXP.rightShift: - case EXP.unsignedRightShift: case EXP.add: + return walkMathOp(expr.isBinExp, PAMathOp.add); case EXP.min: + return walkMathOp(expr.isBinExp, PAMathOp.sub); case EXP.mul: + return walkMathOp(expr.isBinExp, PAMathOp.mul); case EXP.div: + return walkMathOp(expr.isBinExp, PAMathOp.div); case EXP.mod: + return walkMathOp(expr.isBinExp, PAMathOp.mod); case EXP.and: + return walkMathOp(expr.isBinExp, PAMathOp.and); case EXP.or: + return walkMathOp(expr.isBinExp, PAMathOp.or); case EXP.xor: - // We don't support the operator itself, but we do support the walk. - // If we supported value range propergation this would need changing. - auto be = expr.isBinExp; - - DFALatticeRef lhs = this.walk(be.e1); - lhs.check; - - DFALatticeRef rhs = this.walk(be.e2); - rhs.check; + return walkMathOp(expr.isBinExp, PAMathOp.xor); + case EXP.pow: + return walkMathOp(expr.isBinExp, PAMathOp.pow); + case EXP.leftShift: + return walkMathOp(expr.isBinExp, PAMathOp.leftShift); + case EXP.rightShift: + return walkMathOp(expr.isBinExp, PAMathOp.rightShiftSigned); + case EXP.unsignedRightShift: + return walkMathOp(expr.isBinExp, PAMathOp.rightShiftUnsigned); - DFAVar* lhsVar = lhs.getContextVar; + case EXP.plusPlus: + return walkMathAssignOp(expr.isBinExp, PAMathOp.postInc); + case EXP.minusMinus: + return walkMathAssignOp(expr.isBinExp, PAMathOp.postDec); - DFALatticeRef ret = seeLogicalAnd(lhs, rhs); - ret.check; + case EXP.prePlusPlus: + DFALatticeRef effect = dfaCommon.makeLatticeRef; + DFAConsequence* cctx = effect.acquireConstantAsContext; + cctx.pa = DFAPAValue(1); - if (ret.isNull) - ret = dfaCommon.makeLatticeRef; + return walkMathAssignOp(expr.isUnaExp, effect, PAMathOp.add); + case EXP.preMinusMinus: + DFALatticeRef effect = dfaCommon.makeLatticeRef; + DFAConsequence* cctx = effect.acquireConstantAsContext; + cctx.pa = DFAPAValue(1); - DFAConsequence* c = ret.addConsequence(lhsVar); - ret.setContext(c); - c.truthiness = Truthiness.Unknown; + return walkMathAssignOp(expr.isUnaExp, effect, PAMathOp.sub); - ret.check; - return ret; + case EXP.tilde: + { + auto ue = expr.isUnaExp; - case EXP.plusPlus: - case EXP.prePlusPlus: - case EXP.minusMinus: - case EXP.preMinusMinus: - auto be = expr.isBinExp; + DFALatticeRef ret = this.walk(ue.e1); - DFALatticeRef lhs = this.walk(be.e1); - lhs.check; - - // be.e2 is actually the value 1, but we can ignore that - DFALatticeRef rhs = dfaCommon.makeLatticeRef; - rhs.acquireConstantAsContext; + if (ret.isNull) + { + ret = dfaCommon.makeLatticeRef; + ret.acquireConstantAsContext; + } + else + { + DFAConsequence* cctx = ret.getContext; + cctx.pa.bitwiseInvert(ue.type); + } - DFAVar* lhsVar = lhs.getContextVar; - DFALatticeRef ret = seeAssign(lhs, false, rhs); + return ret; + } - if (lhsVar !is null) + case EXP.comma: { - DFALatticeRef effect = dfaCommon.makeLatticeRef; - effect.acquireConstantAsContext; + auto ce = expr.isCommaExp; - lhsVar.walkRoots((root) { effect.addConsequence(root); }); + { + // We need to recognize the following AST: + // (((declaration), (loweredAssignExp)), (var)) + // arrayLengthExp - this.seeConvergeExpression(effect, true); - } + auto ce2 = ce.e1.isCommaExp; + auto var = ce.e2.isVarExp; - return ret; + if (ce2 !is null && var !is null) + { + auto de = ce2.e1.isDeclarationExp; + auto lae = ce2.e2.isLoweredAssignExp; - case EXP.tilde: - auto ue = expr.isUnaExp; + if (de !is null && lae !is null) + { + auto vd = de.declaration.isVarDeclaration; + auto laeLength = lae.e1.isArrayLengthExp; - DFALatticeRef ret = this.walk(ue.e1); - if (ret.isNull) - { - ret = dfaCommon.makeLatticeRef; - ret.acquireConstantAsContext; - } - return ret; + if (var.var.isVarDeclaration is vd && laeLength !is null) + { + // (((vd), (lae)), (var)) + // laeLength - case EXP.comma: - auto ce = expr.isCommaExp; - dfaCommon.printStateln("comma lhs"); - DFALatticeRef lhs = this.walk(ce.e1); - dfaCommon.printStateln("comma rhs"); - DFALatticeRef rhs = this.walk(ce.e2); + // ce.e1 can now be walked just fine, its ce.e2 that is the problem. - DFAVar* rhsVar = rhs.getContextVar; - DFALatticeRef ret = this.seeLogicalAnd(lhs, rhs); + dfaCommon.printStateln("comma lhs"); + DFALatticeRef lhs = this.walk(ce.e1); + dfaCommon.printStateln("comma rhs"); + DFALatticeRef rhs = this.walk(ce.e2); - if (rhsVar !is null) - ret.setContext(rhsVar); - return ret; + DFAConsequence* rhsCctx = rhs.getContext; + DFAConsequence* cctx = lhs.acquireConstantAsContext; - case EXP.structLiteral: - auto sle = expr.isStructLiteralExp; + cctx.truthiness = rhsCctx.truthiness; + cctx.nullable = rhsCctx.nullable; + cctx.pa = rhsCctx.pa; + + return lhs; + } + } + } + } + + dfaCommon.printStateln("comma lhs"); + DFALatticeRef lhs = this.walk(ce.e1); + dfaCommon.printStateln("comma rhs"); + DFALatticeRef rhs = this.walk(ce.e2); + + DFAVar* rhsVar = rhs.getContextVar; + DFALatticeRef ret = this.seeLogicalAnd(lhs, rhs); + + if (rhsVar !is null) + ret.setContext(rhsVar); + + return ret; + } - if (sle.elements !is null) + case EXP.structLiteral: { - foreach (ele; *sle.elements) - { - if (ele is null) - continue; + auto sle = expr.isStructLiteralExp; - if (auto ae = ele.isAddrExp) + if (sle.elements !is null) + { + foreach (ele; *sle.elements) { - if (auto sle2 = ae.e1.isStructLiteralExp) + if (ele is null) + continue; + + if (auto ae = ele.isAddrExp) { - if (sle.origin is sle2.origin) - continue; + if (auto sle2 = ae.e1.isStructLiteralExp) + { + if (sle.origin is sle2.origin) + continue; + } } - } - DFALatticeRef temp = this.walk(ele); - this.seeConvergeFunctionCallArgument(temp, null, 0, null, sle.loc); + DFALatticeRef temp = this.walk(ele); + this.seeConvergeFunctionCallArgument(temp, null, 0, null, sle.loc); + } } - } - DFALatticeRef ret = dfaCommon.makeLatticeRef; - ret.acquireConstantAsContext; - return ret; + DFALatticeRef ret = dfaCommon.makeLatticeRef; + ret.acquireConstantAsContext; + return ret; + } case EXP.tuple: - auto te = expr.isTupleExp; + { + auto te = expr.isTupleExp; - DFAVar* expectedContext; - DFALatticeRef inProgress; + DFAVar* expectedContext; + DFALatticeRef inProgress; - if (te.e0 !is null) - { - inProgress = this.walk(te.e0); - expectedContext = inProgress.getContextVar; - } + if (te.e0 !is null) + { + inProgress = this.walk(te.e0); + expectedContext = inProgress.getContextVar; + } - if (inProgress.isNull) - inProgress = dfaCommon.makeLatticeRef; + if (inProgress.isNull) + inProgress = dfaCommon.makeLatticeRef; - if (te.exps !is null) - { - foreach (exp; *te.exps) + if (te.exps !is null) { - inProgress = this.seeLogicalAnd(inProgress, this.walk(exp)); + foreach (exp; *te.exps) + { + inProgress = this.seeLogicalAnd(inProgress, this.walk(exp)); + } } - } - if (inProgress.isNull) - inProgress = dfaCommon.makeLatticeRef; + if (inProgress.isNull) + inProgress = dfaCommon.makeLatticeRef; - DFAConsequence* c = inProgress.addConsequence(expectedContext); - inProgress.setContext(c); + DFAConsequence* c = inProgress.addConsequence(expectedContext); + inProgress.setContext(c); - if (expectedContext is null) - { - c.nullable = Nullable.Unknown; - c.truthiness = Truthiness.Unknown; + if (expectedContext is null) + { + c.nullable = Nullable.Unknown; + c.truthiness = Truthiness.Unknown; + } + + return inProgress; } - return inProgress; case EXP.question: - auto qe = expr.isCondExp; - - auto origScope = dfaCommon.currentDFAScope; - dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) { - ob.printf("Question expression %p:%p ", dfaCommon.currentDFAScope, origScope); - appendLoc(ob, qe.loc); - ob.writestring("\n"); - }); + { + auto qe = expr.isCondExp; - bool ignoreTrueBranch, ignoreFalseBranch; - bool unknownBranchTaken; - int predicateNegation; - DFALatticeRef conditionLR; - DFAVar* conditionVar; + auto origScope = dfaCommon.currentDFAScope; + dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("Question expression %p:%p ", dfaCommon.currentDFAScope, origScope); + appendLoc(ob, qe.loc); + ob.writestring("\n"); + }); - { - stmtWalker.startScope; - dfaCommon.currentDFAScope.sideEffectFree = true; + bool ignoreTrueBranch, ignoreFalseBranch; + bool unknownBranchTaken; + int predicateNegation; + DFALatticeRef conditionLR; + DFAVar* conditionVar; - dfaCommon.printStateln("Question condition:"); - conditionLR = this.walkCondition(qe.econd, predicateNegation); - conditionVar = conditionLR.getGateConsequenceVariable; + { + stmtWalker.startScope; + dfaCommon.currentDFAScope.sideEffectFree = true; - stmtWalker.endScope; - } + dfaCommon.printStateln("Question condition:"); + conditionLR = this.walkCondition(qe.econd, predicateNegation); + conditionVar = conditionLR.getGateConsequenceVariable; - { - dfaCommon.printStateln("Question true branch:"); - stmtWalker.startScope; - dfaCommon.currentDFAScope.inConditional = true; + stmtWalker.endScope; + } - DFAConsequence* c = conditionLR.getContext; - if (c !is null) { - if (c.truthiness == Truthiness.False) - ignoreTrueBranch = true; - else if (c.truthiness == Truthiness.True) - ignoreFalseBranch = true; + dfaCommon.printStateln("Question true branch:"); + stmtWalker.startScope; + dfaCommon.currentDFAScope.inConditional = true; + + DFAConsequence* c = conditionLR.getContext; + if (c !is null) + { + if (c.truthiness == Truthiness.False) + ignoreTrueBranch = true; + else if (c.truthiness == Truthiness.True) + ignoreFalseBranch = true; + else + unknownBranchTaken = true; + } else unknownBranchTaken = true; + + DFALatticeRef trueCondition = this.adaptConditionForBranch(conditionLR.copy, + qe.econd.type, true); + this.seeSilentAssert(trueCondition, true, true); + stmtWalker.applyGateOnBranch(conditionVar, predicateNegation, true); } - else - unknownBranchTaken = true; - DFALatticeRef trueCondition = this.adaptConditionForBranch(conditionLR.copy, - qe.econd.type, true); - this.seeSilentAssert(trueCondition, true, true); - stmtWalker.applyGateOnBranch(conditionVar, predicateNegation, true); - } + DFAScopeRef scrTrue, scrFalse; + DFALatticeRef lrTrue, lrFalse; - DFAScopeRef scrTrue, scrFalse; - DFALatticeRef lrTrue, lrFalse; + if (!ignoreTrueBranch) + { + lrTrue = this.walk(qe.e1); + assert(dfaCommon.currentDFAScope !is origScope); + } - if (!ignoreTrueBranch) - { - lrTrue = this.walk(qe.e1); - assert(dfaCommon.currentDFAScope !is origScope); - } + scrTrue = stmtWalker.endScope; + scrTrue.check; - scrTrue = stmtWalker.endScope; - scrTrue.check; + assert(dfaCommon.currentDFAScope is origScope); - assert(dfaCommon.currentDFAScope is origScope); + { + dfaCommon.printStateln("Question false branch:"); + stmtWalker.startScope; + dfaCommon.currentDFAScope.inConditional = true; - { - dfaCommon.printStateln("Question false branch:"); - stmtWalker.startScope; - dfaCommon.currentDFAScope.inConditional = true; + if (!ignoreTrueBranch) + { + DFALatticeRef falseCondition = this.adaptConditionForBranch(conditionLR.copy, + qe.econd.type, false); + this.seeSilentAssert(falseCondition, true, true); + } - if (!ignoreTrueBranch) - { - DFALatticeRef falseCondition = this.adaptConditionForBranch(conditionLR.copy, - qe.econd.type, false); - this.seeSilentAssert(falseCondition, true, true); - } + stmtWalker.applyGateOnBranch(conditionVar, predicateNegation, false); - stmtWalker.applyGateOnBranch(conditionVar, predicateNegation, false); + if (!ignoreFalseBranch) + lrFalse = this.walk(qe.e2); - if (!ignoreFalseBranch) - lrFalse = this.walk(qe.e2); + scrFalse = stmtWalker.endScope; + scrFalse.check; + } - scrFalse = stmtWalker.endScope; - scrFalse.check; + return this.seeConditional(conditionLR, scrTrue, lrTrue, + scrFalse, lrFalse, unknownBranchTaken, predicateNegation); } - return this.seeConditional(conditionLR, scrTrue, lrTrue, scrFalse, - lrFalse, unknownBranchTaken, predicateNegation); - case EXP.delegate_: case EXP.function_: // known no-op return DFALatticeRef.init; case EXP.concatenate: - auto ce = expr.isCatExp; - - dfaCommon.printStateln("concatenate lhs"); - DFALatticeRef lhs = this.walk(ce.e1); - dfaCommon.printStateln("concatenate rlhs"); - DFALatticeRef rhs = this.walk(ce.e2); - - DFAConsequence* lhsCctx = lhs.getContext, rhsCctx = rhs.getContext; - const nullableResult = concatNullableResult(ce.e1.type, ce.e2.type); - Truthiness expectedTruthiness; - Nullable expectedNullable; - - if (nullableResult == 2) - { - expectedTruthiness = Truthiness.True; - expectedNullable = Nullable.NonNull; - } - else if (nullableResult == 1) { - if (lhsCctx !is null) - expectedNullable = lhsCctx.nullable; - if (rhsCctx !is null && expectedNullable < rhsCctx.nullable) - expectedNullable = rhsCctx.nullable; + auto be = expr.isBinExp; + auto beTypeBT = be.type.toBasetype; + const lhsIsArray = be.e1.type.toBasetype.equals(beTypeBT); + const rhsIsArray = be.e2.type.toBasetype.equals(beTypeBT); + const op = [3, 1, 4, 0][lhsIsArray + (rhsIsArray * 2)]; - if (expectedNullable == Nullable.NonNull) - expectedTruthiness = Truthiness.True; + return concatenateTwo(be, op); } - DFALatticeRef ret = this.seeLogicalAnd(lhs, rhs); - if (ret.isNull) - ret = dfaCommon.makeLatticeRef; - - ret.acquireConstantAsContext(expectedTruthiness, expectedNullable); - return ret; - case EXP.vector: case EXP.vectorArray: case EXP.delegatePointer: @@ -1352,7 +1341,6 @@ struct ExpressionWalker case EXP.moduleString: // __MODULE__ case EXP.functionString: // __FUNCTION__ case EXP.prettyFunction: // __PRETTY_FUNCTION__ - case EXP.pow: case EXP.voidExpression: case EXP.cantExpression: @@ -1376,22 +1364,98 @@ struct ExpressionWalker /// Walks an expression that is used for a condition i.e. and if statement. /// Tells you if the expression for the gate variable, will be exact, vs negated state. + /// Applying by test is for when (expr) > 0, use 0 for unknown, 1 is <= 0 and 2 is > 0 /// Returns: 0 for unknown negation, 1 or has been negated from gate variable or 2 if it hasn't been. DFALatticeRef walkCondition(Expression expr, out int predicateNegation) { bool allGateConditional = true; bool outComeNegated; + dfaCommon.edepth++; + scope (exit) { + dfaCommon.edepth--; + if (!allGateConditional) predicateNegation = 0; else predicateNegation = outComeNegated ? 1 : 2; } - DFALatticeRef seeExp(Expression expr, ref bool negated) + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("[%p]%3d walkCondition (%s): at ", expr, expr.op, + AllExprOpNames[expr.op].ptr); + appendLoc(ob, expr.loc); + ob.writestring("\n"); + }); + + int negateApplyByTest(int val) + { + if (val == 1) + return 2; + else if (val == 2) + return 1; + else + return 0; + } + + bool canBeInverted(Expression expr) { + switch (expr.op) + { + + case EXP.typeid_: + case EXP.arrayLiteral: + case EXP.assocArrayLiteral: + case EXP.arrayLength: + case EXP.null_: + case EXP.cast_: + case EXP.variable: + default: + return false; + + case EXP.int64: + case EXP.string_: + return true; + + case EXP.not: // !x + auto ue = expr.isUnaExp; + if (ue.e1.isInExp) + return false; + return canBeInverted(ue.e1); + + case EXP.orOr: + case EXP.notEqual: // != + case EXP.notIdentity: // !is + case EXP.equal: // == + case EXP.identity: // is + case EXP.lessThan: + case EXP.lessOrEqual: + case EXP.greaterThan: + case EXP.greaterOrEqual: + auto be = expr.isBinExp; + return canBeInverted(be.e1) && canBeInverted(be.e2); + } + } + + DFALatticeRef seeExp(Expression expr, ref bool negated, int applyByTest) + { + dfaCommon.check; + dfaCommon.edepth++; + scope (exit) + { + dfaCommon.check; + dfaCommon.edepth--; + } + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("[%p]%3d walkCondition.seeExp (%s): at ", expr, + expr.op, AllExprOpNames[expr.op].ptr); + appendLoc(ob, expr.loc); + ob.writestring("\n"); + }); + switch (expr.op) { case EXP.not: // !x @@ -1401,10 +1465,12 @@ struct ExpressionWalker if (auto ie = ue.e1.isInExp) { - DFALatticeRef lhs = this.walk(ie.e1); + allGateConditional = false; + + DFALatticeRef lhs = seeExp(ie.e1, negated, 0); lhs.check; - DFALatticeRef rhs = this.walk(ie.e2); + DFALatticeRef rhs = seeExp(ie.e2, negated, 0); rhs.check; DFAVar* rhsVar = rhs.getContextVar; @@ -1413,11 +1479,13 @@ struct ExpressionWalker if (rhsVar !is null) rhs.setContext(dfaCommon.findIndexVar(rhsVar)); - allGateConditional = false; return this.seeEqual(lhs, rhs, false, ie.e1.type, ie.e2.type); } else - return seeNegate(seeExp(ue.e1, negated)); + { + DFALatticeRef lr = seeExp(ue.e1, negated, negateApplyByTest(applyByTest)); + return (applyByTest != 0) ? lr : seeNegate(lr, ue.type); + } } case EXP.notEqual: // != @@ -1428,11 +1496,11 @@ struct ExpressionWalker bool negated2; dfaCommon.printStateln("!equal lhs"); - DFALatticeRef lhs = seeExp(be.e1, negated2); + DFALatticeRef lhs = seeExp(be.e1, negated2, 0); dfaCommon.printStateln("!equal rhs"); - DFALatticeRef rhs = seeExp(be.e2, negated2); + DFALatticeRef rhs = seeExp(be.e2, negated2, 0); - return seeEqual(lhs, rhs, false, be.e1.type, be.e2.type); + return seeEqual(lhs, rhs, applyByTest == 2, be.e1.type, be.e2.type); } case EXP.notIdentity: // !is @@ -1443,11 +1511,11 @@ struct ExpressionWalker bool negated2; dfaCommon.printStateln("!is lhs"); - DFALatticeRef lhs = seeExp(be.e1, negated2); + DFALatticeRef lhs = seeExp(be.e1, negated2, 0); dfaCommon.printStateln("!is rhs"); - DFALatticeRef rhs = seeExp(be.e2, negated2); + DFALatticeRef rhs = seeExp(be.e2, negated2, 0); - return seeEqual(lhs, rhs, false, be.e1.type, be.e2.type); + return seeEqual(lhs, rhs, applyByTest == 2, be.e1.type, be.e2.type); } case EXP.equal: // == @@ -1456,11 +1524,11 @@ struct ExpressionWalker bool negated2; dfaCommon.printStateln("equal lhs"); - DFALatticeRef lhs = seeExp(be.e1, negated2); + DFALatticeRef lhs = seeExp(be.e1, negated2, 0); dfaCommon.printStateln("equal rhs"); - DFALatticeRef rhs = seeExp(be.e2, negated2); + DFALatticeRef rhs = seeExp(be.e2, negated2, 0); - return seeEqual(lhs, rhs, true, be.e1.type, be.e2.type); + return seeEqual(lhs, rhs, applyByTest != 1, be.e1.type, be.e2.type); } case EXP.identity: // is @@ -1469,19 +1537,22 @@ struct ExpressionWalker bool negated2; dfaCommon.printStateln("is lhs"); - DFALatticeRef lhs = seeExp(be.e1, negated2); + DFALatticeRef lhs = seeExp(be.e1, negated2, 0); dfaCommon.printStateln("is rhs"); - DFALatticeRef rhs = seeExp(be.e2, negated2); + DFALatticeRef rhs = seeExp(be.e2, negated2, 0); - return seeEqual(lhs, rhs, true, be.e1.type, be.e2.type); + return seeEqual(lhs, rhs, applyByTest != 1, be.e1.type, be.e2.type); } case EXP.string_: { + auto se = expr.isStringExp; + // A string literal even when empty will be non-null and true. DFALatticeRef ret = dfaCommon.makeLatticeRef; - //ret.acquireConstantAsContext(Truthiness.True, Nullable.NonNull); - ret.acquireConstantAsContext; + DFAConsequence* cctx = ret.acquireConstantAsContext(se.len > 0 + ? Truthiness.True : Truthiness.Maybe, Nullable.NonNull); + cctx.pa = DFAPAValue(se.len); return ret; } @@ -1495,7 +1566,7 @@ struct ExpressionWalker if (auto e = isExpression(te.obj)) { // [!val] does not effect the literal, gate capabilitiy - DFALatticeRef temp = this.walk(e); + DFALatticeRef temp = seeExp(e, negated, 0); if (!ret.isNull) ret = this.seeLogicalAnd(ret, temp); @@ -1529,8 +1600,9 @@ struct ExpressionWalker { foreach (ele; *ale.elements) { - this.seeConvergeFunctionCallArgument(this.walk(ele), - null, 0, null, ele.loc); + if (ele !is null) + this.seeConvergeFunctionCallArgument(seeExp(ele, + negated, 0), null, 0, null, ele.loc); } DFAConsequence* cctx = ret.addConsequence( @@ -1538,9 +1610,10 @@ struct ExpressionWalker ret.setContext(cctx); cctx.truthiness = Truthiness.True; cctx.nullable = Nullable.NonNull; + cctx.pa = DFAPAValue(ale.elements.length); } else - ret.acquireConstantAsContext(Truthiness.False, Nullable.Null); + ret.acquireConstantAsContext(Truthiness.Maybe, Nullable.Null); return ret; } @@ -1571,7 +1644,7 @@ struct ExpressionWalker auto ue = expr.isUnaExp; - DFALatticeRef ret = seeExp(ue.e1, negated); + DFALatticeRef ret = seeExp(ue.e1, negated, 0); DFAConsequence* cctx = ret.getContext; if (ret.isNull) @@ -1587,6 +1660,8 @@ struct ExpressionWalker DFAConsequence* newCctx = ret.addConsequence(ctx); newCctx.truthiness = cctx.truthiness; + newCctx.pa = cctx.pa; + newCctx.maybe = cctx.var; ret.setContext(newCctx); } @@ -1603,6 +1678,8 @@ struct ExpressionWalker c.truthiness = Truthiness.False; c.nullable = Nullable.Null; + c.pa = DFAPAValue(0); + return ret; } @@ -1618,7 +1695,65 @@ struct ExpressionWalker DFAConsequence* c = ret.addConsequence(null); ret.setContext(c); - c.truthiness = b.get ? Truthiness.True : Truthiness.False; + auto ty = ie.type.toBasetype().ty; + + if (ty != Tpointer) + { + c.pa = DFAPAValue(0); + const value = ie.getInteger(); + + switch (ty) + { + case Tbool: + c.pa.value = value != 0; + break; + + case Tint8: + c.pa.value = cast(byte) value; + break; + + case Tchar: + case Tuns8: + c.pa.value = cast(ubyte) value; + break; + + case Tint16: + c.pa.value = cast(short) value; + break; + + case Twchar: + case Tuns16: + c.pa.value = cast(ushort) value; + break; + + case Tint32: + c.pa.value = cast(int) value; + break; + + case Tdchar: + case Tuns32: + c.pa.value = cast(uint) value; + break; + + case Tint64: + c.pa.value = cast(long) value; + break; + + case Tuns64: + c.pa.value = cast(ulong) value; + + if (value > long.max) + c.pa.kind = DFAPAValue.Kind.UnknownUpperPositive; + break; + + default: + printf("integer type %d\n", ty); + assert(0, "Unknown integer type"); + } + + c.truthiness = c.pa.value > 0 ? Truthiness.True : Truthiness.False; + } + return ret; } @@ -1630,7 +1765,7 @@ struct ExpressionWalker scope PrintPrefixType prefix) => ob.printf("cast to %d\n", ce.to !is null ? ce.to.ty : -1)); - DFALatticeRef ret = this.walk(ce.e1); + DFALatticeRef ret = seeExp(ce.e1, negated, 0); ret.check; if (ce.to is null || ce.to.isTypeClass) @@ -1654,6 +1789,11 @@ struct ExpressionWalker cctx = ret.acquireConstantAsContext(cctx.truthiness, cctx.nullable); } + + // If we're doing any kind of cast to anything that is not an integer, + // we have no idea if VRP is going to still be accurate. + if (!cctx.pa.canFitIn(ce.to)) + cctx.pa = DFAPAValue.Unknown; } return ret; @@ -1676,6 +1816,22 @@ struct ExpressionWalker { ret = dfaCommon.acquireLattice(var); ret.check; + assert(!ret.isNull); + + if (applyByTest != 0) + { + DFAConsequence* cctx = ret.getContext; + assert(cctx !is null); + + if (var.isNullable && cctx.nullable == Nullable.Unknown) + cctx.nullable = applyByTest == 2 + ? Nullable.NonNull : Nullable.Null; + + if (var.isTruthy && cctx.truthiness == Truthiness.Unknown) + cctx.truthiness = applyByTest == 2 + ? Truthiness.True : Truthiness.False; + } + return ret; } } @@ -1684,6 +1840,7 @@ struct ExpressionWalker // no other declarations really apply for the DFA ret = dfaCommon.makeLatticeRef; ret.setContext(dfaCommon.getUnknownVar); + return ret; } @@ -1693,6 +1850,85 @@ struct ExpressionWalker } } + DFALatticeRef seeExpInOr(Expression expr, bool invert) + { + dfaCommon.check; + dfaCommon.edepth++; + scope (exit) + { + dfaCommon.check; + dfaCommon.edepth--; + } + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("[%p]%3d walkCondition.seeExpInOr (%s): at ", expr, + expr.op, AllExprOpNames[expr.op].ptr); + appendLoc(ob, expr.loc); + ob.writestring("\n"); + }); + + switch (expr.op) + { + case EXP.orOr: + int predicateNegation; + DFALatticeRef ret = walkCondition(expr.isLogicalExp, predicateNegation); + if (invert) + return this.seeNegate(ret, expr.type); + else + return ret; + + case EXP.lessThan: + if (invert) + goto GreaterThan; + LessThan: + // < becomes > + auto be = expr.isBinExp; + bool negated; + + DFALatticeRef lhs = seeExp(be.e2, negated, 0); + DFALatticeRef rhs = seeExp(be.e1, negated, 0); + return this.seeGreaterThan(false, lhs, rhs); + + case EXP.lessOrEqual: + if (invert) + goto GreaterThanEqual; + LessThanEqual: + // <= becomes >= + auto be = expr.isBinExp; + bool negated; + + DFALatticeRef lhs = seeExp(be.e2, negated, 0); + DFALatticeRef rhs = seeExp(be.e1, negated, 0); + return this.seeGreaterThan(true, lhs, rhs); + + case EXP.greaterThan: + if (invert) + goto LessThan; + GreaterThan: + auto be = expr.isBinExp; + bool negated; + + DFALatticeRef lhs = seeExp(be.e1, negated, 0); + DFALatticeRef rhs = seeExp(be.e2, negated, 0); + return this.seeGreaterThan(false, lhs, rhs); + + case EXP.greaterOrEqual: + if (invert) + goto LessThanEqual; + GreaterThanEqual: + auto be = expr.isBinExp; + bool negated; + + DFALatticeRef lhs = seeExp(be.e1, negated, 0); + DFALatticeRef rhs = seeExp(be.e2, negated, 0); + return this.seeGreaterThan(true, lhs, rhs); + + default: + bool negated; + return seeExp(expr, negated, invert ? 1 : 2); + } + } + // In theory a gate condition can support more expressions, but to be on the safe side, let's call this good. switch (expr.op) { @@ -1710,13 +1946,164 @@ struct ExpressionWalker case EXP.identity: // is case EXP.notEqual: // != case EXP.notIdentity: // !is - return seeExp(expr, outComeNegated); + return seeExp(expr, outComeNegated, 0); + + case EXP.orOr: + { + const canThisBeInverted = canBeInverted(expr); + auto oe = expr.isLogicalExp; + DFALatticeRef inProgress; + + stmtWalker.startScope; + dfaCommon.currentDFAScope.sideEffectFree = true; + scope (exit) + stmtWalker.endScope; + + while (oe !is null) + { + DFALatticeRef lhs; + DFALatticeRef toNegate; + + { + // Make sure any effects converged into the scope by and expressions ext. don't effect rhs + stmtWalker.startScope; + dfaCommon.currentDFAScope.sideEffectFree = true; + + if (canThisBeInverted) + { + dfaCommon.printStructureln("Or expression lhs:"); + + lhs = seeExpInOr(oe.e1, false); + } + else + { + dfaCommon.printStructureln("Or expression lhs walk-adapt:"); + lhs = this.walk(oe.e1); + toNegate = this.adaptConditionForBranch(lhs.copy, oe.e1.type, false); + } + + lhs.printState("or lhs", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + + stmtWalker.endScope; + + if (inProgress.isNull) + inProgress = lhs; + else + inProgress = seeLogicalOr(inProgress, lhs); + } + + if (toNegate.isNull) + { + dfaCommon.printStructureln("Or expression lhs inverted:"); + this.seeSilentAssert(seeExpInOr(oe.e1, true)); + } + else + { + this.seeSilentAssert(toNegate, false, true); + } + + if (oe.e2.op == EXP.orOr) + { + oe = oe.e2.isLogicalExp; + continue; + } + else + { + // Make sure any effects converged into the scope by and expressions ext. don't effect rhs or return + stmtWalker.startScope; + dfaCommon.currentDFAScope.sideEffectFree = true; + + // e2 is the right most or expression in chain (a || b || c) where it is c + dfaCommon.printStructureln("Or expression rhs:"); + // don't care about seeExpInOr here, can just do a normal walk + DFALatticeRef rhs = this.walk(oe.e2); + rhs.printState("or rhs", dfaCommon.sdepth, + dfaCommon.currentFunction, dfaCommon.edepth); + + stmtWalker.endScope; + + inProgress = seeLogicalOr(inProgress, rhs); + break; + } + } + + return inProgress; + } default: return this.walk(expr); } } + DFALatticeRef walkMathOp(BinExp be, PAMathOp op) + { + dfaCommon.printStateln("math op lhs"); + DFALatticeRef lhs = this.walk(be.e1); + lhs.check; + + dfaCommon.printStateln("math op rhs"); + DFALatticeRef rhs = this.walk(be.e2); + rhs.check; + + DFALatticeRef ret = this.seeMathOp(lhs, rhs, be.type, op); + ret.check; + return ret; + } + + DFALatticeRef walkMathAssignOp(BinExp be, PAMathOp op) + { + dfaCommon.printStateln("math assign1 op lhs"); + DFALatticeRef lhs = this.walk(be.e1); + lhs.check; + + DFAConsequence* lhsCctx = lhs.getContext; + + assert(!lhs.isNull); + assert(lhsCctx !is null); + + dfaCommon.printStateln("math assign1 op rhs"); + DFALatticeRef rhs = this.walk(be.e2); + rhs.check; + + DFAPAValue oldPA; + bool useOldPA; + + if (op == PAMathOp.postInc) + { + op = PAMathOp.add; + oldPA = lhsCctx.pa; + } + else if (op == PAMathOp.postDec) + { + op = PAMathOp.sub; + oldPA = lhsCctx.pa; + } + + DFALatticeRef ret = this.seeMathOp(lhs.copy, rhs, be.type, op); + ret.check; + + ret = this.seeAssign(lhs, false, ret); + DFAConsequence* cctx = ret.acquireConstantAsContext; + + if (useOldPA) + cctx.pa = oldPA; + + return ret; + } + + DFALatticeRef walkMathAssignOp(UnaExp ue, DFALatticeRef rhs, PAMathOp op) + { + dfaCommon.printStateln("math assign2 op lhs"); + DFALatticeRef lhs = this.walk(ue.e1); + lhs.check; + + DFALatticeRef ret = this.seeMathOp(lhs.copy, rhs, ue.type, op); + ret.check; + + return this.seeAssign(lhs, false, ret); + } + DFALatticeRef callFunction(FuncDeclaration toCallFunction, Expression thisPointer, Expression argPrefix, Expressions* arguments, ref Loc loc) { @@ -1900,4 +2287,127 @@ struct ExpressionWalker } } } + + DFALatticeRef concatenateTwo(BinExp be, int op, bool assign = false) + { + // Whatever lhs started out as, it'll be non-null once we're done with it. + + const nullableResult = concatNullableResult(be.e1.type, be.e2.type); + dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) => ob.printf( + "concat nullableResult=%d, op=%d\n", nullableResult, op)); + + dfaCommon.printStateln("concat lhs"); + DFALatticeRef lhs = this.walk(be.e1); + dfaCommon.printStateln("concat rhs"); + DFALatticeRef rhs = this.walk(be.e2); + + DFAConsequence* lhsCctx = lhs.getContext, rhsCctx = rhs.getContext; + + if (lhsCctx is null || rhsCctx is null) + { + // We can't analyse this. + return DFALatticeRef.init; + } + + DFAPAValue pa; + + if (op == 0) + { + // T[] ~ T[] + pa = rhsCctx.pa; + pa.addFrom(lhsCctx.pa, Type.tuns64); + } + else if (op == 1) + { + // T[] ~ T + pa = lhsCctx.pa; + pa.addFrom(DFAPAValue(1), Type.tuns64); + } + else if (op == 2) + { + // T[] ~ dchar + // We have no idea how many code units the dchar will encode as + pa = DFAPAValue.Unknown; + } + else if (op == 3) + { + // T ~ T + pa = DFAPAValue(2); + } + else if (op == 4) + { + // T ~ T[] + pa = rhsCctx.pa; + pa.addFrom(DFAPAValue(1), Type.tuns64); + } + + DFALatticeRef ret; + + if (assign) + { + rhsCctx.pa = pa; + ret = this.seeAssign(lhs, false, rhs, false, nullableResult == 1 + || nullableResult == 2 ? 3 : 0); + } + else + { + + Truthiness expectedTruthiness; + Nullable expectedNullable; + + if (nullableResult == 2) + { + expectedTruthiness = Truthiness.True; + expectedNullable = Nullable.NonNull; + } + else if (nullableResult == 1) + { + expectedNullable = lhsCctx.nullable; + if (expectedNullable < rhsCctx.nullable) + expectedNullable = rhsCctx.nullable; + + if (expectedNullable == Nullable.NonNull) + expectedTruthiness = Truthiness.True; + } + + ret = this.seeLogicalAnd(lhs, rhs); + DFAConsequence* cctx = ret.acquireConstantAsContext; + + cctx.truthiness = expectedTruthiness; + cctx.nullable = expectedNullable; + cctx.pa = pa; + } + + return ret; + } + + void markUnmodellable(Expression e) + { + void perVar(VarDeclaration vd) + { + DFAVar* var = dfaCommon.findVariable(vd); + if (var !is null) + var.unmodellable = true; + } + + void perExpr(Expression expr) + { + if (auto ve = expr.isVarExp) + { + if (auto vd = ve.var.isVarDeclaration) + perVar(vd); + } + else if (auto be = expr.isBinExp) + { + perExpr(be.e1); + perExpr(be.e2); + } + else if (auto ue = expr.isUnaExp) + { + perExpr(ue.e1); + } + } + + perExpr(e); + } } diff --git a/dmd/dfa/fast/statement.d b/dmd/dfa/fast/statement.d index 6144aa7329..c382abfe0e 100644 --- a/dmd/dfa/fast/statement.d +++ b/dmd/dfa/fast/statement.d @@ -58,11 +58,36 @@ final: return this.endScope(loc); } - DFAScopeRef endScope(ref Loc endLoc) + DFAScopeRef endScope(ref Loc endLoc, bool handleLabelPopping = true) { DFAScopeRef ret = dfaCommon.popScope; dfaCommon.sdepth--; + if (handleLabelPopping) + { + while (ret.sc.label !is null) + { + Loc loc = *cast(Loc*)&ret.sc.label.loc; + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("End label scope %p:%p %s", ret.sc, + dfaCommon.currentDFAScope, ret.sc.label.ident.toChars); + if (loc.isValid) + appendLoc(ob, loc); + ob.writestring("\n"); + }); + + ret.printStructure("*=", dfaCommon.sdepth, dfaCommon.currentFunction); + ret.check; + + seeConvergeStatementLoopyLabels(ret, loc); + inLoopyLabel--; + + ret = dfaCommon.popScope; + dfaCommon.sdepth--; + } + } + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { ob.printf("End scope %p:%p", ret.sc, dfaCommon.currentDFAScope); if (endLoc.isValid) @@ -88,6 +113,28 @@ final: DFAScopeRef ret = dfaCommon.popScope; dfaCommon.sdepth--; + while (ret.sc.label !is null) + { + Loc loc = *cast(Loc*)&ret.sc.label.loc; + + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("End label scope %p:%p %s", ret.sc, + dfaCommon.currentDFAScope, ret.sc.label.ident.toChars); + if (loc.isValid) + appendLoc(ob, loc); + ob.writestring("\n"); + }); + + ret.printStructure("*=", dfaCommon.sdepth, dfaCommon.currentFunction); + ret.check; + + seeConvergeStatementLoopyLabels(ret, loc); + inLoopyLabel--; + + ret = dfaCommon.popScope; + dfaCommon.sdepth--; + } + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { ob.printf("End scope %p:%p", ret.sc, dfaCommon.currentDFAScope); if (endLoc.isValid) @@ -502,7 +549,7 @@ final: */ version (none) { - if (st.loc.linnum == 342) + if (st.loc.linnum == 180) { DFAScope* sc = dfaCommon.currentDFAScope; while (sc !is null) @@ -701,17 +748,16 @@ final: break; case STMT.Label: + // Note: it is the responsibility of endScope to handle poping these scopes off auto ls = st.isLabelStatement; dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) => ob.printf("label %s %p %p\n", ls.ident !is null ? ls.ident.toChars : null, ls.gotoTarget, ls.gotoTarget)); inLoopyLabel++; - scope (exit) - inLoopyLabel--; this.startScope; - dfaCommon.currentDFAScope.label = ls.ident; + dfaCommon.currentDFAScope.label = ls; dfaCommon.setScopeAsLoopyLabel; dfaCommon.currentDFAScope.isLoopyLabelKnownToHaveRun = true; @@ -742,21 +788,20 @@ final: // by-pass scope statement processing with a dedicated variation here. if (ls.statement is null) { - // empty block, this is ok. - scr = this.endScope; } else if (auto scs = ls.statement.isScopeStatement) { this.visit(scs.statement); - scr = this.endScope(*cast(Loc*)&ls.loc); + scr = this.endScope(*cast(Loc*)&ls.loc, false); + inLoopyLabel--; } else { this.visit(ls.statement); - scr = this.endScope; } - seeConvergeStatementLoopyLabels(scr, *cast(Loc*)&ls.loc); + if (!scr.isNull) + seeConvergeStatementLoopyLabels(scr, *cast(Loc*)&ls.loc); break; case STMT.For: @@ -785,6 +830,10 @@ final: break; } } + May also be: + for(;condition;) { + ... + } */ if (theCondition !is null) { @@ -1279,7 +1328,7 @@ final: printf("Run finalizers up to scope %p", targetHeadScope); if (targetHeadScope !is null && targetHeadScope.label !is null) - printf("%s\n", targetHeadScope.label.toChars); + printf("%s\n", targetHeadScope.label.ident.toChars); else printf("\n"); } @@ -1313,24 +1362,6 @@ final: var.unmodellable = true; } - void perExpr(Expression expr) - { - if (auto ve = expr.isVarExp) - { - if (auto vd = ve.var.isVarDeclaration) - perVar(vd); - } - else if (auto ue = expr.isUnaExp) - { - perExpr(ue.e1); - } - else if (auto be = expr.isBinExp) - { - perExpr(be.e1); - perExpr(be.e2); - } - } - - foreachExpAndVar(s, &perExpr, &perVar); + foreachExpAndVar(s, &expWalker.markUnmodellable, &perVar); } } diff --git a/dmd/dfa/fast/structure.d b/dmd/dfa/fast/structure.d index d522adac2a..e418607ad6 100644 --- a/dmd/dfa/fast/structure.d +++ b/dmd/dfa/fast/structure.d @@ -15,6 +15,7 @@ import dmd.declaration; import dmd.statement; import dmd.func; import dmd.mtype; +import dmd.typesem; import dmd.identifier; import dmd.globals; import dmd.dsymbol; @@ -747,13 +748,15 @@ struct DFACommon } else { - while (current.parent !is null && current.label !is ident) + while (current.parent !is null && (current.label is null || current + .label.ident !is ident)) { current = current.parent; } } - return (current !is null && (current.label is ident || current.controlStatement !is null)) ? current + return (current !is null && ((current.label !is null + && current.label.ident is ident) || current.controlStatement !is null)) ? current : null; } @@ -932,7 +935,7 @@ struct DFAAllocator { bucket = &childOf.childVars[(cast(size_t) cast(void*) vd) % childOf.childVars.length]; - while (*bucket !is null && cast(void*)(*bucket).next < cast(void*) vd) + while (*bucket !is null && cast(void*)(*bucket).var < cast(void*) vd) { bucket = &(*bucket).next; } @@ -995,18 +998,27 @@ struct DFAAllocator DFAConsequence* makeConsequence(DFAVar* var, DFAConsequence* copyFrom = null) { DFAConsequence* ret = allocInternal!DFAConsequence(freelistconsequence); + ret.var = var; - if (copyFrom is null) - { - ret.var = var; - } - else + if (copyFrom !is null) { *ret = *copyFrom; ret.previous = null; ret.next = null; + + ret.maybe = null; + ret.maybeTopSeen = false; + + if (var !is null) + { + if (!var.isTruthy) + ret.truthiness = Truthiness.Unknown; + if (!var.isNullable) + ret.nullable = Nullable.Unknown; + } } + ret.var = var; return ret; } @@ -1218,6 +1230,7 @@ struct DFAVar DFAVar* dereferenceVar; // child var bool unmodellable; // DO NOT REPORT!!!! + bool doNotInferNonNull; // i.e. was the rhs of > int assertedCount; ParameterDFAInfo* param; @@ -1611,7 +1624,7 @@ struct DFAScope bool sideEffectFree; // No side effects should be stored in this scope use a parent instead. Statement controlStatement; // needed to apply on iteration for continue, loops switch statements ext. - Identifier label; + LabelStatement label; CompoundStatement compoundStatement; size_t inProgressCompoundStatement; @@ -1649,8 +1662,13 @@ struct DFAScope DFAScopeVar** bucket = &this.buckets[cast(size_t) contextVar % this.buckets.length]; - while (*bucket !is null && (*bucket).var < contextVar) + DFAVar* lastVar; + + while (*bucket !is null && (*bucket).var < contextVar && lastVar < (*bucket).var) + { + lastVar = (*bucket).var; bucket = &(*bucket).next; + } if (*bucket is null || (*bucket).var !is contextVar) return null; @@ -1765,7 +1783,7 @@ struct DFAScope this.haveReturned, this.haveJumped); if (this.label !is null) - printf(", label=`%s`\n", this.label.toChars); + printf(", label=`%s`\n", this.label.ident.toChars); else printf("\n"); @@ -1840,25 +1858,18 @@ struct DFAScope { static if (DFACommon.debugVerify) { - foreach (contextVar1, l1; this) + foreach (scv; this.buckets) { - assert(l1 !is null); - - DFALatticeRef lr1; - lr1.lattice = l1; - - size_t count; - - foreach (contextVar2, l2; this) + while (scv !is null) { - if (contextVar1 is contextVar2) - count++; - } + assert(scv.lr.lattice !is null); - assert(count == 1); - lr1.check; + if (scv.next !is null) + assert(scv.next.var > scv.var); - lr1.lattice = null; + scv.lr.check; + scv = scv.next; + } } } } @@ -2209,7 +2220,13 @@ struct DFALattice if (var is null) { - ret = dfaCommon.allocator.makeConsequence(var, copyFrom); + if (this.constant is null) + { + ret = dfaCommon.allocator.makeConsequence(var, copyFrom); + } + else + ret = this.constant; + this.constant = ret; } else @@ -2228,13 +2245,7 @@ struct DFALattice ret.next = this.lastInSequence; this.lastInSequence = ret; - if (copyFrom !is null) - { - ret.invertedOnce = copyFrom.invertedOnce; - ret.protectElseNegate = copyFrom.protectElseNegate; - ret.writeOnVarAtThisPoint = copyFrom.writeOnVarAtThisPoint; - } - else + if (copyFrom is null) { ret.writeOnVarAtThisPoint = var.writeCount; } @@ -2506,6 +2517,913 @@ enum Nullable : ubyte NonNull } +enum PAMathOp : ubyte +{ + add, + sub, + mul, + div, + mod, + and, + or, + xor, + pow, + leftShift, + rightShiftSigned, + rightShiftUnsigned, + + postInc, + postDec +} + +// Point analysis, tracking of integral values such as a slice length or an integer typed variable/constant. +// Note that the math op functions here may not be correct. +// They'll just have to be fixed once a test case appears. +struct DFAPAValue +{ + enum Unknown = DFAPAValue(DFAPAValue.Kind.Unknown); + + Kind kind; + + // We use long to represent the VRP value, however this cuts off long.max .. ulong.max, represent this with UnknownUpperPositive. + // By doing long we can ignore signedness and lower negative long.min .. int.min, making things simpler. + long value; + + enum Kind : ubyte + { + Unknown, + UnknownUpperPositive, + Lower, // VRP lower inclusive + Upper, // VRP upper inclusive + Concrete + } + + this(Kind kind) + { + this.kind = kind; + } + + this(long value) + { + this.kind = Kind.Concrete; + this.value = value; + } + + int opCmp(const ref DFAPAValue other) const + { + if (this.kind != other.kind) + { + const difference = cast(int) this.kind - cast(int) other.kind; + return difference < 0 ? - 1 : 1; + } + else if (this.kind == Kind.Concrete && other.kind == Kind.Concrete) + return this.value < other.value ? - 1 : (this.value == other.value ? 0 : 1); + else + return 0; + } + + DFAPAValue meet(DFAPAValue other) + { + if (this.kind != other.kind || this.kind != Kind.Concrete || this.value != other.value) + return Unknown; + else + return this; + } + + DFAPAValue join(DFAPAValue other) + { + if (this > other) + return this; + else + return other; + } + + bool canFitIn(Type type) + { + if (this.kind < Kind.Lower) + return false; + + switch (type.ty) + { + case TY.Tint8 : return byte.min <= this.value && this.value <= byte.max; + + case TY.Tuns8 : return 0 <= this.value && this.value <= ubyte.max; + + case TY.Tint16 : return short.min <= this.value && this.value <= short.max; + + case TY.Tuns16 : return 0 <= this.value && this.value <= ushort.max; + + case TY.Tint32 : return int.min <= this.value && this.value <= int.max; + + case TY.Tuns32 : return 0 <= this.value && this.value <= uint.max; + + case TY.Tuns64 : case TY.Tuns128 : return 0 <= this.value; + + case TY.Tint64 : case TY.Tint128 : return true; + + default : return false; + } + } + + Truthiness compareEqual(ref DFAPAValue other) + { + if (this.kind == DFAPAValue.Kind.Unknown || other.kind == DFAPAValue.Kind.Unknown) + return Truthiness.Unknown; + + const lhsConcrete = this.kind == DFAPAValue.Kind.Concrete; + const rhsConcrete = other.kind == DFAPAValue.Kind.Concrete; + + if (lhsConcrete && rhsConcrete) + return this.value == other.value ? Truthiness.True : Truthiness.False; + else if ((lhsConcrete || rhsConcrete) && (this.kind == DFAPAValue.Kind.UnknownUpperPositive + || other.kind == DFAPAValue.Kind.UnknownUpperPositive)) + return Truthiness.False; + + return Truthiness.Maybe; + } + + Truthiness compareNotEqual(ref DFAPAValue other) + { + if (this.kind == DFAPAValue.Kind.Unknown || other.kind == DFAPAValue.Kind.Unknown) + return Truthiness.Unknown; + else if (this.kind < DFAPAValue.Kind.Concrete || other.kind < DFAPAValue.Kind.Concrete) + return Truthiness.Maybe; // we can't know the value at this time of development but it could be equal + + if (this.kind == DFAPAValue.Kind.Concrete && other.kind == DFAPAValue.Kind.Concrete) + return (this.value == other.value) ? Truthiness.False : Truthiness.True; + + return Truthiness.Maybe; + } + + Truthiness greaterThan(ref DFAPAValue other) + { + Truthiness ret = Truthiness.Maybe; + + if (this.kind == DFAPAValue.Kind.Concrete && other.kind == DFAPAValue.Kind.Concrete) + ret = this.value > other.value ? Truthiness.True : Truthiness.False; + else if (this.kind == DFAPAValue.Kind.Concrete + && other.kind == DFAPAValue.Kind.UnknownUpperPositive) + ret = Truthiness.False; + + if (ret == Truthiness.False) + { + this = Unknown; + other = Unknown; + } + else + { + DFAPAValue temp = other; + + if (temp.kind == DFAPAValue.Kind.Concrete) + { + if (temp.value < long.max) + temp.value++; + else + temp.kind = DFAPAValue.Kind.UnknownUpperPositive; + } + + other = other.meet(this); + this = this.join(temp); + + if (other.kind > Kind.Lower) + other.kind = Kind.Upper; + if (this.kind >= Kind.Lower) + this.kind = Kind.Lower; + } + + return ret; + } + + Truthiness greaterThanOrEqual(ref DFAPAValue other) + { + Truthiness ret = Truthiness.Maybe; + + if (this.kind == DFAPAValue.Kind.Concrete && other.kind == DFAPAValue.Kind.Concrete) + ret = this.value >= other.value ? Truthiness.True : Truthiness.False; + else if (this.kind == DFAPAValue.Kind.Concrete + && other.kind == DFAPAValue.Kind.UnknownUpperPositive) + ret = Truthiness.False; + + if (ret == Truthiness.False) + { + this = Unknown; + other = Unknown; + } + else + { + other = other.meet(this); + this = this.join(other); + + if (other.kind > Kind.Lower) + other.kind = Kind.Upper; + if (this.kind >= Kind.Lower) + this.kind = Kind.Lower; + } + + return ret; + } + + void negate(Type type) + { + if (this.kind != Kind.Concrete || type is null) + { + this.kind = Kind.Unknown; + return; + } + + switch (type.ty) + { + case TY.Tint8: + this.value = -cast(int)(cast(byte) this.value); + break; + case TY.Tint16: + this.value = -cast(int)(cast(short) this.value); + break; + case TY.Tint32: + this.value = -cast(int) this.value; + break; + case TY.Tint64: + case TY.Tint128: + this.value = -this.value; + break; + + case TY.Tuns8: + this.value = -cast(int)(cast(ubyte) this.value); + break; + case TY.Tuns16: + this.value = -cast(int)(cast(ushort) this.value); + break; + case TY.Tuns32: + this.value = -cast(uint) this.value; + break; + case TY.Tuns64: + case TY.Tuns128: + this.value = -this.value; + break; + + default: + this.kind = Kind.Unknown; + break; + } + } + + void addFrom(DFAPAValue other, Type type) + { + if (this.kind != Kind.Concrete || other.kind != Kind.Concrete) + { + this.kind = Kind.Unknown; + return; + } + + if (type.isUnsigned) + { + if (this.value > 0 && other.value > 0 && this.value > (long.max - other.value)) + { + // long.max .. ulong.max + this.kind = Kind.UnknownUpperPositive; + return; + } + } + + switch (type.ty) + { + case TY.Tint8: + this.value = cast(byte) this.value + cast(byte) other.value; + break; + case TY.Tint16: + this.value = cast(short) this.value + cast(short) other.value; + break; + case TY.Tint32: + this.value = cast(int) this.value + cast(int) other.value; + break; + case TY.Tint64: + case TY.Tint128: + this.value = this.value + other.value; + break; + + case TY.Tuns8: + this.value = cast(ubyte) this.value + cast(ubyte) other.value; + break; + case TY.Tuns16: + this.value = cast(ushort) this.value + cast(ushort) other.value; + break; + case TY.Tuns32: + this.value = cast(uint) this.value + cast(uint) other.value; + break; + case TY.Tuns64: + case TY.Tuns128: + this.value = this.value + other.value; + break; + + default: + this.kind = Kind.Unknown; + break; + } + } + + void subtractFrom(DFAPAValue other, Type type) + { + if (this.kind != Kind.Concrete || other.kind != Kind.Concrete) + { + this.kind = Kind.Unknown; + return; + } + + if (type.isUnsigned) + { + if (other.value > this.value) + { + this.kind = Kind.Unknown; + return; + } + } + + switch (type.ty) + { + case TY.Tint8: + this.value = cast(byte) this.value - cast(byte) other.value; + break; + case TY.Tint16: + this.value = cast(short) this.value - cast(short) other.value; + break; + case TY.Tint32: + this.value = cast(int) this.value - cast(int) other.value; + break; + case TY.Tint64: + case TY.Tint128: + this.value = this.value - other.value; + break; + + case TY.Tuns8: + this.value = cast(ubyte) this.value - cast(ubyte) other.value; + break; + case TY.Tuns16: + this.value = cast(ushort) this.value - cast(ushort) other.value; + break; + case TY.Tuns32: + this.value = cast(uint) this.value - cast(uint) other.value; + break; + case TY.Tuns64: + case TY.Tuns128: + this.value = this.value - other.value; + break; + + default: + this.kind = Kind.Unknown; + break; + } + } + + void multiplyFrom(DFAPAValue other, Type type) + { + if (this.kind != Kind.Concrete || other.kind != Kind.Concrete) + { + this.kind = Kind.Unknown; + return; + } + + if (type.isUnsigned) + { + if (this.value > 1 && other.value > 1 && this.value > (long.max / other.value)) + { + this.kind = Kind.UnknownUpperPositive; + return; + } + } + + switch (type.ty) + { + case TY.Tint8: + this.value = cast(byte) this.value * cast(byte) other.value; + break; + case TY.Tint16: + this.value = cast(short) this.value * cast(short) other.value; + break; + case TY.Tint32: + this.value = cast(int) this.value * cast(int) other.value; + break; + case TY.Tint64: + case TY.Tint128: + this.value = this.value * other.value; + break; + + case TY.Tuns8: + this.value = cast(ubyte) this.value * cast(ubyte) other.value; + break; + case TY.Tuns16: + this.value = cast(ushort) this.value * cast(ushort) other.value; + break; + case TY.Tuns32: + this.value = cast(uint) this.value * cast(uint) other.value; + break; + case TY.Tuns64: + case TY.Tuns128: + this.value = this.value * other.value; + break; + + default: + this.kind = Kind.Unknown; + break; + } + } + + void divideFrom(DFAPAValue other, Type type) + { + if (this.kind != Kind.Concrete || other.kind != Kind.Concrete) + { + this.kind = Kind.Unknown; + return; + } + + this.kind = Kind.Unknown; + + if (!type.isUnsigned && this.value == long.min && other.value == -1) + { + return; + } + + switch (type.ty) + { + case TY.Tint8: + if (cast(byte) other.value == 0) + return; + this.value = cast(byte) this.value / cast(byte) other.value; + break; + case TY.Tint16: + if (cast(short) other.value == 0) + return; + this.value = cast(short) this.value / cast(short) other.value; + break; + case TY.Tint32: + if (cast(int) other.value == 0) + return; + this.value = cast(int) this.value / cast(int) other.value; + break; + case TY.Tint64: + case TY.Tint128: + if (other.value == 0) + return; + this.value = this.value / other.value; + break; + + case TY.Tuns8: + if (cast(ubyte) other.value == 0) + return; + this.value = cast(ubyte) this.value / cast(ubyte) other.value; + break; + case TY.Tuns16: + if (cast(ushort) other.value == 0) + return; + this.value = cast(ushort) this.value / cast(ushort) other.value; + break; + case TY.Tuns32: + if (cast(uint) other.value == 0) + return; + this.value = cast(uint) this.value / cast(uint) other.value; + break; + case TY.Tuns64: + case TY.Tuns128: + if (cast(ulong) other.value == 0) + return; + // Must cast to ulong to perform correct unsigned 64-bit division before final assignment. + this.value = cast(long)(cast(ulong) this.value / cast(ulong) other.value); + break; + + default: + return; + } + + this.kind = Kind.Concrete; + } + + void modulasFrom(DFAPAValue other, Type type) + { + if (this.kind != Kind.Concrete || other.kind != Kind.Concrete || other.value == 0) + { + this.kind = Kind.Unknown; + return; + } + + if (!type.isUnsigned) + { + if (this.value == long.min && other.value == -1) + { + this.kind = Kind.Unknown; + return; + } + } + + switch (type.ty) + { + case TY.Tint8: + this.value = cast(byte) this.value % cast(byte) other.value; + break; + case TY.Tint16: + this.value = cast(short) this.value % cast(short) other.value; + break; + case TY.Tint32: + this.value = cast(int) this.value % cast(int) other.value; + break; + case TY.Tint64: + case TY.Tint128: + this.value = this.value % other.value; + break; + + case TY.Tuns8: + this.value = cast(ubyte) this.value % cast(ubyte) other.value; + break; + case TY.Tuns16: + this.value = cast(ushort) this.value % cast(ushort) other.value; + break; + case TY.Tuns32: + this.value = cast(uint) this.value % cast(uint) other.value; + break; + case TY.Tuns64: + case TY.Tuns128: + this.value = cast(long)(cast(ulong) this.value % cast(ulong) other.value); + break; + + default: + this.kind = Kind.Unknown; + break; + } + } + + void leftShiftBy(DFAPAValue other, Type type) + { + if (this.kind != Kind.Concrete || other.kind != Kind.Concrete || other.value < 0) + { + this.kind = Kind.Unknown; + return; + } + + switch (type.ty) + { + case TY.Tint8: + this.value = cast(byte) this.value << cast(byte) other.value; + break; + case TY.Tint16: + this.value = cast(short) this.value << cast(short) other.value; + break; + case TY.Tint32: + this.value = cast(int) this.value << cast(int) other.value; + break; + case TY.Tint64: + case TY.Tint128: + this.value = this.value << other.value; + break; + + case TY.Tuns8: + this.value = cast(ubyte) this.value << cast(ubyte) other.value; + break; + case TY.Tuns16: + this.value = cast(ushort) this.value << cast(ushort) other.value; + break; + case TY.Tuns32: + this.value = cast(uint) this.value << cast(uint) other.value; + break; + case TY.Tuns64: + case TY.Tuns128: + this.value = cast(ulong) this.value << cast(ulong) other.value; + break; + + default: + this.kind = Kind.Unknown; + break; + } + } + + void rightShiftSignedBy(DFAPAValue other, Type type) + { + if (this.kind != Kind.Concrete || other.kind != Kind.Concrete || other.value < 0) + { + this.kind = Kind.Unknown; + return; + } + + switch (type.ty) + { + case TY.Tint8: + this.value = cast(byte) this.value >> cast(byte) other.value; + break; + case TY.Tint16: + this.value = cast(short) this.value >> cast(short) other.value; + break; + case TY.Tint32: + this.value = cast(int) this.value >> cast(int) other.value; + break; + case TY.Tint64: + case TY.Tint128: + this.value = this.value >> other.value; + break; + + case TY.Tuns8: + this.value = cast(ubyte) this.value >>> cast(ubyte) other.value; + break; + case TY.Tuns16: + this.value = cast(ushort) this.value >>> cast(ushort) other.value; + break; + case TY.Tuns32: + this.value = cast(uint) this.value >>> cast(uint) other.value; + break; + case TY.Tuns64: + case TY.Tuns128: + this.value = cast(ulong) this.value >>> cast(ulong) other.value; + break; + + default: + this.kind = Kind.Unknown; + break; + } + } + + void rightShiftUnsignedBy(DFAPAValue other, Type type) + { + if (this.kind != Kind.Concrete || other.kind != Kind.Concrete || other.value < 0) + { + this.kind = Kind.Unknown; + return; + } + + switch (type.ty) + { + // We cast to the unsigned equivalent of the target size (ubyte, ushort, uint) + // to force the logical shift behavior (zero-filling). + case TY.Tint8: + case TY.Tuns8: + this.value = cast(ubyte) this.value >>> cast(ubyte) other.value; + break; + case TY.Tint16: + case TY.Tuns16: + this.value = cast(ushort) this.value >>> cast(ushort) other.value; + break; + case TY.Tint32: + case TY.Tuns32: + this.value = cast(uint) this.value >>> cast(uint) other.value; + break; + case TY.Tint64: + case TY.Tuns64: + case TY.Tint128: + case TY.Tuns128: + // For 64-bit, we use ulong to perform the logical shift before casting back to long. + this.value = cast(ulong) this.value >>> cast(ulong) other.value; + break; + + default: + this.kind = Kind.Unknown; + break; + } + } + + void powerBy(DFAPAValue other, Type type) + { + const exponent = other.value; + const base = this.value; + + if (this.kind != Kind.Concrete || other.kind != Kind.Concrete || exponent < 0) + { + this.kind = Kind.Unknown; + return; + } + else if (exponent == 0) + { + // base ^^ 0 + this.value = 1; + return; + } + else if (base == 0) + { + // 0 ^^ exponent + this.value = 0; + return; + } + else if (exponent == 1) + { + // base ^^ 1 + return; + } + + const temp = cast(ulong) base ^^ cast(ulong) exponent; + + if (temp > long.max) + { + this.kind = Kind.UnknownUpperPositive; + return; + } + + switch (type.ty) + { + case TY.Tint8: + this.value = cast(byte) temp; + break; + case TY.Tint16: + this.value = cast(short) temp; + break; + case TY.Tint32: + this.value = cast(int) temp; + break; + case TY.Tint64: + case TY.Tint128: + this.value = cast(long) temp; + break; + + case TY.Tuns8: + this.value = cast(ubyte) temp; + break; + case TY.Tuns16: + this.value = cast(ushort) temp; + break; + case TY.Tuns32: + this.value = cast(uint) temp; + break; + case TY.Tuns64: + case TY.Tuns128: + this.value = temp; + break; + + default: + this.kind = Kind.Unknown; + break; + } + } + + void bitwiseAndBy(DFAPAValue other, Type type) + { + if (this.kind != Kind.Concrete || other.kind != Kind.Concrete) + { + this.kind = Kind.Unknown; + return; + } + + switch (type.ty) + { + case TY.Tint8: + this.value = cast(byte) this.value & cast(byte) other.value; + break; + case TY.Tint16: + this.value = cast(short) this.value & cast(short) other.value; + break; + case TY.Tint32: + this.value = cast(int) this.value & cast(int) other.value; + break; + case TY.Tint64: + case TY.Tint128: + this.value = this.value & other.value; + break; + + case TY.Tuns8: + this.value = cast(ubyte) this.value & cast(ubyte) other.value; + break; + case TY.Tuns16: + this.value = cast(ushort) this.value & cast(ushort) other.value; + break; + case TY.Tuns32: + this.value = cast(uint) this.value & cast(uint) other.value; + break; + case TY.Tuns64: + case TY.Tuns128: + this.value = cast(ulong) this.value & cast(ulong) other.value; + break; + + default: + this.kind = Kind.Unknown; + break; + } + } + + void bitwiseOrBy(DFAPAValue other, Type type) + { + if (this.kind != Kind.Concrete || other.kind != Kind.Concrete) + { + this.kind = Kind.Unknown; + return; + } + + switch (type.ty) + { + case TY.Tint8: + this.value = cast(byte) this.value | cast(byte) other.value; + break; + case TY.Tint16: + this.value = cast(short) this.value | cast(short) other.value; + break; + case TY.Tint32: + this.value = cast(int) this.value | cast(int) other.value; + break; + case TY.Tint64: + case TY.Tint128: + this.value = this.value | other.value; + break; + + case TY.Tuns8: + this.value = cast(ubyte) this.value | cast(ubyte) other.value; + break; + case TY.Tuns16: + this.value = cast(ushort) this.value | cast(ushort) other.value; + break; + case TY.Tuns32: + this.value = cast(uint) this.value | cast(uint) other.value; + break; + case TY.Tuns64: + case TY.Tuns128: + this.value = cast(ulong) this.value | cast(ulong) other.value; + break; + + default: + this.kind = Kind.Unknown; + break; + } + } + + void bitwiseXorBy(DFAPAValue other, Type type) + { + if (this.kind != Kind.Concrete || other.kind != Kind.Concrete) + { + this.kind = Kind.Unknown; + return; + } + + switch (type.ty) + { + case TY.Tint8: + this.value = cast(byte) this.value ^ cast(byte) other.value; + break; + case TY.Tint16: + this.value = cast(short) this.value ^ cast(short) other.value; + break; + case TY.Tint32: + this.value = cast(int) this.value ^ cast(int) other.value; + break; + case TY.Tint64: + case TY.Tint128: + this.value = this.value ^ other.value; + break; + + case TY.Tuns8: + this.value = cast(ubyte) this.value ^ cast(ubyte) other.value; + break; + case TY.Tuns16: + this.value = cast(ushort) this.value ^ cast(ushort) other.value; + break; + case TY.Tuns32: + this.value = cast(uint) this.value ^ cast(uint) other.value; + break; + case TY.Tuns64: + case TY.Tuns128: + this.value = cast(ulong) this.value ^ cast(ulong) other.value; + break; + + default: + this.kind = Kind.Unknown; + break; + } + } + + void bitwiseInvert(Type type) + { + if (this.kind != Kind.Concrete) + { + this.kind = Kind.Unknown; + return; + } + + switch (type.ty) + { + case TY.Tint8: + this.value = ~cast(int)(cast(byte) this.value); + break; + case TY.Tint16: + this.value = ~cast(int)(cast(short) this.value); + break; + case TY.Tint32: + this.value = ~cast(int) this.value; + break; + case TY.Tint64: + case TY.Tint128: + this.value = ~this.value; + break; + + case TY.Tuns8: + this.value = ~cast(int)(cast(ubyte) this.value); + break; + case TY.Tuns16: + this.value = ~cast(int)(cast(ushort) this.value); + break; + case TY.Tuns32: + this.value = ~cast(uint) this.value; + break; + case TY.Tuns64: + case TY.Tuns128: + this.value = ~this.value; + break; + + default: + this.kind = Kind.Unknown; + break; + } + } +} + struct DFAConsequence { private @@ -2531,6 +3449,8 @@ struct DFAConsequence // When the context is maybe, look at this instead DFAVar* maybe; bool maybeTopSeen; + // Point analysis value, tracking of integral/length values + DFAPAValue pa; void meetConsequence(DFAConsequence* c1, DFAConsequence* c2, bool couldScopeNotHaveRan = false) { @@ -2545,6 +3465,7 @@ struct DFAConsequence this.invertedOnce = c.invertedOnce; this.writeOnVarAtThisPoint = c.writeOnVarAtThisPoint; + this.pa = couldScopeNotHaveRan ? DFAPAValue.Unknown : c.pa; if (this.var is null || this.var.isTruthy) this.truthiness = couldScopeNotHaveRan ? Truthiness.Unknown : c.truthiness; @@ -2569,6 +3490,8 @@ struct DFAConsequence this.invertedOnce = this.truthiness == Truthiness.Unknown ? false : (c1.invertedOnce || c2.invertedOnce); + this.pa = couldScopeNotHaveRan ? DFAPAValue.Unknown : c1.pa.meet(c2.pa); + if (this.var is null || this.var.isTruthy) { this.truthiness = (couldScopeNotHaveRan && c1.truthiness != c2.truthiness) @@ -2616,13 +3539,14 @@ struct DFAConsequence } this.invertedOnce = c.invertedOnce; + this.writeOnVarAtThisPoint = c.writeOnVarAtThisPoint; + this.maybe = c.maybe; + this.pa = c.pa; + if (this.var is null || this.var.isTruthy) this.truthiness = c.truthiness; if (this.var is null || this.var.isNullable) this.nullable = c.nullable; - - this.writeOnVarAtThisPoint = c.writeOnVarAtThisPoint; - this.maybe = c.maybe; } void doMulti(DFAConsequence* c2) @@ -2639,6 +3563,7 @@ struct DFAConsequence this.invertedOnce = c1.invertedOnce || c2.invertedOnce; this.writeOnVarAtThisPoint = c1.writeOnVarAtThisPoint < c2.writeOnVarAtThisPoint ? c2.writeOnVarAtThisPoint : c1.writeOnVarAtThisPoint; + this.pa = c1.pa.join(c2.pa); if (this.var is null || this.var.isTruthy) { @@ -2671,10 +3596,10 @@ struct DFAConsequence version (DebugJoinMeetOp) { - printf("join consequence c1=%p, c2=%p, rhsCtx=%p\n", c1, c2, rhsCtx); - printf(" vars c1=%p, c2=%p, rhsCtx=%p\n", c1 !is null - ? c1.var : null, c2 !is null ? c2.var : null, rhsCtx !is null ? rhsCtx.var - : null); + printf("join consequence c1=%p, c2=%p, rhsCtx=%p, this=%p\n", c1, c2, rhsCtx, &this); + printf(" vars c1=%p, c2=%p, rhsCtx=%p, this=%p\n", c1 !is null + ? c1.var : null, c2 !is null ? c2.var : null, rhsCtx !is null + ? rhsCtx.var : null, this.var); printf(" writeCount=%d/%d:%d\n", writeCount, c1.writeOnVarAtThisPoint, c2 !is null ? c2.writeOnVarAtThisPoint : -1); printf(" isC1Context=%d, unknownAware=%d, ignoreWriteCount=%d\n", @@ -2723,7 +3648,8 @@ struct DFAConsequence NullableStr[this.nullable], this.writeOnVarAtThisPoint); printf("maybe=%p:%d, protectElseNegate=%d, invertedOnce=%d ", maybe, maybeTopSeen, protectElseNegate, invertedOnce); - printf("previous=%p, next=%p ", this.previous, this.next); + printf("previous=%p, next=%p, pa=%03d/%lld ", this.previous, this.next, + this.pa.kind, this.pa.value); printf("%p", this.var); if (this.var !is null) diff --git a/dmd/dfa/utils.d b/dmd/dfa/utils.d index f5909162df..b9393e1623 100644 --- a/dmd/dfa/utils.d +++ b/dmd/dfa/utils.d @@ -51,6 +51,7 @@ bool isTypeTruthy(Type type) case TY.Ttag: case TY.Tsarray: case TY.Tstruct: + case TY.Tvector: return false; default: @@ -84,8 +85,25 @@ int concatNullableResult(Type lhs, Type rhs) return 0; // Unknown } -int equalityArgTypes(Type lhs, Type rhs) +enum EqualityArgType { + Unknown, + Struct, + FloatingPoint, + StaticArray, + StaticArrayLHS, + StaticArrayRHS, + DynamicArray, + AssociativeArray, + Nullable +} + +/// See_Also: EqualityArgType +EqualityArgType equalityArgTypes(Type lhs, Type rhs) +{ + // This logic originally came from dmd's glue layer. + // It was copied over and modified so that the DFA is accruate to runtime actions. + // struct // floating point // lhs && rhs static, dyamic array @@ -93,27 +111,27 @@ int equalityArgTypes(Type lhs, Type rhs) // otherwise integral if (lhs.ty == Tstruct) - return 1; + return EqualityArgType.Struct; else if (lhs.isFloating) - return 2; + return EqualityArgType.FloatingPoint; if (rhs is null) rhs = lhs; // Assume rhs is similar to lhs const lhsSArray = lhs.isTypeSArray !is null, rhsSArray = rhs.isTypeSArray !is null; if (lhsSArray && rhsSArray) - return 3; + return EqualityArgType.StaticArray; else if (lhsSArray) - return 4; + return EqualityArgType.StaticArrayLHS; else if (rhsSArray) - return 5; + return EqualityArgType.StaticArrayRHS; if (lhs.isTypeDArray || rhs.isTypeDArray) - return 6; + return EqualityArgType.DynamicArray; else if (lhs.ty == Taarray && rhs.ty == Taarray) - return 7; + return EqualityArgType.AssociativeArray; else if (isTypeNullable(lhs)) - return 8; + return EqualityArgType.Nullable; else - return 0; + return EqualityArgType.Unknown; } diff --git a/tests/dmd/compilable/fastdfa.d b/tests/dmd/compilable/fastdfa.d index d975af7fc9..bc7156a705 100644 --- a/tests/dmd/compilable/fastdfa.d +++ b/tests/dmd/compilable/fastdfa.d @@ -709,3 +709,105 @@ void orIfUnknown(bool b) @system { } } + +void gatedIfVRP(bool gate) +{ + int i; + + if (gate) + i = 3; + + assert(i == 3); // ok +} + +void orUnknownNonNull(int* ptr) +{ + if (!ptr || *ptr == 2) + { + } +} + +void sliceLength(int[] slice) +{ + assert(slice.length == 3); // ok + assert(slice.length == 2); // error +} + +struct Complex_f +{ + float re, im; + + static Complex_f sqrtc(ref Complex_f z) + { + if (z.re >= 0) + { + } + return Complex_f.init; + } +} + +void loopConditionGreaterThan(int v) +{ + int val; + + foreach (i; 0 .. 10) + { + if (v > 2) + assert(val > 0); + else + val++; + v++; + } +} + +void paArgInterval(int another) +{ + assert(1 <= another && another <= 5); + assert(another == 3); +} + +void checkNullOr(int* val2) +{ + int* val; + if ((val = val2) is null || *val) + { + } +} + +void checkNumAssignCall() +{ + int func() + { + return 3; + } + + int c = 0; + c = func(); + assert(c != -1); + assert(c == '2'); +} + +void checkPostfixPA() +{ + int i = 0; + assert(++i == 1); + assert(i++ == 1); +} + +void checkGreaterThanNoInfer() +{ + bool inferable(string s) + { + return s.length < 3 || s[2] == 'e'; + } + + assert(inferable(null)); +} + +void checkEqualAssignInt(string str) +{ + int i; + + i = (str == "hello"); + assert(i == 1); +} diff --git a/tests/dmd/fail_compilation/fastdfa.d b/tests/dmd/fail_compilation/fastdfa.d index 763c450465..d6a2c9f8aa 100644 --- a/tests/dmd/fail_compilation/fastdfa.d +++ b/tests/dmd/fail_compilation/fastdfa.d @@ -2,17 +2,27 @@ * REQUIRED_ARGS: -preview=fastdfa * TEST_OUTPUT: --- -fail_compilation/fastdfa.d(37): Error: Assert can be proven to be false -fail_compilation/fastdfa.d(47): Error: Argument is expected to be non-null but was null -fail_compilation/fastdfa.d(40): For parameter `ptr` in argument 0 -fail_compilation/fastdfa.d(54): Error: Variable `ptr` was required to be non-null and has become null -fail_compilation/fastdfa.d(75): Error: Variable `ptr` was required to be non-null and has become null -fail_compilation/fastdfa.d(90): Error: Dereference on null variable `ptr` -fail_compilation/fastdfa.d(112): Error: Dereference on null variable `ptr` -fail_compilation/fastdfa.d(129): Error: Assert can be proven to be false -fail_compilation/fastdfa.d(135): Error: Assert can be proven to be false -fail_compilation/fastdfa.d(144): Error: Dereference on null variable `ptr` -fail_compilation/fastdfa.d(159): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(47): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(57): Error: Argument is expected to be non-null but was null +fail_compilation/fastdfa.d(50): For parameter `ptr` in argument 0 +fail_compilation/fastdfa.d(64): Error: Variable `ptr` was required to be non-null and has become null +fail_compilation/fastdfa.d(85): Error: Variable `ptr` was required to be non-null and has become null +fail_compilation/fastdfa.d(100): Error: Dereference on null variable `ptr` +fail_compilation/fastdfa.d(122): Error: Dereference on null variable `ptr` +fail_compilation/fastdfa.d(139): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(145): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(154): Error: Dereference on null variable `ptr` +fail_compilation/fastdfa.d(169): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(177): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(179): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(186): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(193): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(197): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(199): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(209): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(210): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(224): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(233): Error: Assert can be proven to be false --- */ @@ -159,3 +169,67 @@ void gateDowngrade(bool gate, int* ptr) assert(ptr !is null); // error } } + +void basicVRP() +{ + int a = 2, b = 3; + assert(a == a); // ok + assert(a == b); // error + assert(a != b); // ok + assert(a != a); // error +} + +void checkVRPUpper() +{ + ulong i = ulong.max; + + assert(i == 2); // error + assert(i == ulong(long.max) + 2); // ok +} + +void paNegate() +{ + int val = 2; + assert(val == 3); // error + assert(val == 2); // no error + + val = -val; + assert(val == 3); // error + assert(val == -2); // no error + assert(val == 9); // error +} + +void paAdd() +{ + int val = 2; + + val = val + 2; + val += 1; + + assert(val == 3); // error + assert(val == 4); // error + assert(val == 5); // no error +} + + +void paBitwise() +{ + int a = 2, b = 3, c; + + c = a * b; + + int d = c & 2; + + assert(c == 6); // no error + assert(d == 6); // error + assert(d == 2); // no error +} + +void paSliceLengthAppend() +{ + string text = "hello"; + text ~= " world"; + + assert(text.length == 5); // error + assert(text.length == 11); // no error +} From 2d9b1078f820f6910b768f50e9950c210494ed27 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Tue, 9 Dec 2025 09:44:48 +0000 Subject: [PATCH 141/440] Fix: Out contract can escape local references (dlang/dmd!22205) Fixes dlang/dmd!22202. --- dmd/expressionsem.d | 2 +- tests/dmd/fail_compilation/fail6497.d | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index b0abe5d0a6..5a664b17c0 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -17664,7 +17664,7 @@ private bool checkAddressVar(Scope* sc, Expression exp, VarDeclaration v) "taking the address of local variable `%s`" : "taking the address of stack-allocated local variable `%s`"; if (sc.useDIP1000 != FeatureState.enabled && - !(v.storage_class & STC.temp) && + (!(v.storage_class & STC.temp) || v.storage_class & STC.result) && sc.setUnsafe(false, exp.loc, msg.ptr, v)) { return false; diff --git a/tests/dmd/fail_compilation/fail6497.d b/tests/dmd/fail_compilation/fail6497.d index 0fd1ff2f4e..60499f9df8 100644 --- a/tests/dmd/fail_compilation/fail6497.d +++ b/tests/dmd/fail_compilation/fail6497.d @@ -1,9 +1,10 @@ /* TEST_OUTPUT: --- -fail_compilation/fail6497.d(13): Error: taking the address of stack-allocated local variable `n` is not allowed in a `@safe` function -fail_compilation/fail6497.d(13): Error: taking the address of stack-allocated local variable `n` is not allowed in a `@safe` function -fail_compilation/fail6497.d(19): Error: taking the address of local variable `i` is not allowed in a `@safe` function +fail_compilation/fail6497.d(14): Error: taking the address of stack-allocated local variable `n` is not allowed in a `@safe` function +fail_compilation/fail6497.d(14): Error: taking the address of stack-allocated local variable `n` is not allowed in a `@safe` function +fail_compilation/fail6497.d(20): Error: taking the address of local variable `i` is not allowed in a `@safe` function +fail_compilation/fail6497.d(28): Error: taking the address of local variable `i` is not allowed in a `@safe` function --- */ @@ -18,3 +19,12 @@ void f() @safe ref i = *new int; auto b = &i; } + +const(int)* ptr; + +int g() @safe +out (i) +{ + ptr = &i; +} +do { return 0; } From 9a4e5ea85d65a96dbb70ac19d4439f3207b25ee0 Mon Sep 17 00:00:00 2001 From: Dennis Date: Wed, 10 Dec 2025 00:28:01 +0100 Subject: [PATCH 142/440] Fix 22135: ICE: Assert Error with __traits(initSymbol, ...) (dlang/dmd!22211) Co-authored-by: Dennis Korpel --- tests/dmd/runnable/traits_initSymbol.d | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/dmd/runnable/traits_initSymbol.d b/tests/dmd/runnable/traits_initSymbol.d index a224d0e3b5..e330772cf2 100644 --- a/tests/dmd/runnable/traits_initSymbol.d +++ b/tests/dmd/runnable/traits_initSymbol.d @@ -105,6 +105,19 @@ void testExternCppClass() assert(init == (cast(void*) ac)[0 .. init.length]); } +void testFuncParam() +{ + // https://github.com/dlang/dmd/issues/22135 + struct S {} + + void foo(T)(T _) {} + + void bar() + { + foo(__traits(initSymbol, S)); + } +} + void main() { testZero(); @@ -113,4 +126,5 @@ void main() testAlignedStruct(); testAlignedClass(); testExternCppClass(); + testFuncParam(); } From de190a114d6181748ed91fe8798e620362e133c9 Mon Sep 17 00:00:00 2001 From: Dennis Date: Wed, 10 Dec 2025 00:41:38 +0100 Subject: [PATCH 143/440] Improve error message for failing `override` method (dlang/dmd!22212) --- dmd/funcsem.d | 15 +++------------ tests/dmd/fail_compilation/covariant_override.d | 8 +++++--- tests/dmd/fail_compilation/diag9191.d | 11 +++++++---- tests/dmd/fail_compilation/fail18093.d | 7 ++++--- tests/dmd/fail_compilation/fail22351.d | 7 ++++--- tests/dmd/fail_compilation/fail262.d | 3 ++- tests/dmd/fail_compilation/fail8631.d | 3 ++- tests/dmd/fail_compilation/retref2.d | 6 ++++-- tests/dmd/fail_compilation/test13867.d | 6 ++++-- tests/dmd/fail_compilation/test20489.d | 7 +++---- tests/dmd/fail_compilation/test21246.d | 3 ++- 11 files changed, 40 insertions(+), 36 deletions(-) diff --git a/dmd/funcsem.d b/dmd/funcsem.d index e20a752728..84f844d827 100644 --- a/dmd/funcsem.d +++ b/dmd/funcsem.d @@ -1178,8 +1178,8 @@ Linterfaces: functionToBufferFull(cast(TypeFunction)(fd.type), buf1, new Identifier(fd.toPrettyChars()), hgs, null); - error(funcdecl.loc, "function `%s` does not override any function, did you mean to override `%s`?", - funcdeclToChars, buf1.peekChars()); + error(funcdecl.loc, "function `%s` does not override any function", funcdeclToChars); + errorSupplemental(fd.loc, "did you mean to override `%s`?", buf1.peekChars()); // Supplemental error for parameter scope differences auto tf1 = cast(TypeFunction)funcdecl.type; @@ -1192,8 +1192,6 @@ Linterfaces: if (params1.length == params2.length) { - bool hasScopeDifference = false; - for (size_t i = 0; i < params1.length; i++) { auto p1 = params1[i]; @@ -1205,14 +1203,7 @@ Linterfaces: if (!(p2.storageClass & STC.scope_)) continue; - if (!hasScopeDifference) - { - // Intended signature - errorSupplemental(funcdecl.loc, "Did you intend to override:"); - errorSupplemental(funcdecl.loc, "`%s`", buf1.peekChars()); - hasScopeDifference = true; - } - errorSupplemental(funcdecl.loc, "Parameter %d is missing `scope`", + errorSupplemental(funcdecl.loc, "parameter %d is missing `scope`", cast(int)(i + 1)); } } diff --git a/tests/dmd/fail_compilation/covariant_override.d b/tests/dmd/fail_compilation/covariant_override.d index 7738770775..9ee5342ba0 100644 --- a/tests/dmd/fail_compilation/covariant_override.d +++ b/tests/dmd/fail_compilation/covariant_override.d @@ -3,9 +3,11 @@ https://issues.dlang.org/show_bug.cgi?id=21538 TEST_OUTPUT: --- -fail_compilation/covariant_override.d(23): Error: function `@safe void covariant_override.CI.f(void delegate() @safe dg)` does not override any function, did you mean to override `@safe void covariant_override.I.f(void delegate() @system dg)`? -fail_compilation/covariant_override.d(34): Error: function `@safe void covariant_override.CA.f(void delegate() @safe dg)` does not override any function, did you mean to override `@safe void covariant_override.A.f(void delegate() @system dg)`? -fail_compilation/covariant_override.d(20): Error: class `covariant_override.CI` interface function `void f(void delegate() @system dg) @safe` is not implemented +fail_compilation/covariant_override.d(25): Error: function `@safe void covariant_override.CI.f(void delegate() @safe dg)` does not override any function +fail_compilation/covariant_override.d(19): did you mean to override `@safe void covariant_override.I.f(void delegate() @system dg)`? +fail_compilation/covariant_override.d(36): Error: function `@safe void covariant_override.CA.f(void delegate() @safe dg)` does not override any function +fail_compilation/covariant_override.d(30): did you mean to override `@safe void covariant_override.A.f(void delegate() @system dg)`? +fail_compilation/covariant_override.d(22): Error: class `covariant_override.CI` interface function `void f(void delegate() @system dg) @safe` is not implemented --- ++/ diff --git a/tests/dmd/fail_compilation/diag9191.d b/tests/dmd/fail_compilation/diag9191.d index 889d1fada2..64279815c0 100644 --- a/tests/dmd/fail_compilation/diag9191.d +++ b/tests/dmd/fail_compilation/diag9191.d @@ -1,10 +1,13 @@ /* TEST_OUTPUT: --- -fail_compilation/diag9191.d(16): Error: function `void diag9191.C1.aaa()` does not override any function, did you mean to override `void diag9191.B1.aa()`? -fail_compilation/diag9191.d(22): Error: function `diag9191.C2.aaa` does not override any function -fail_compilation/diag9191.d(33): Error: function `void diag9191.C3.foo()` does not override any function, did you mean to override `void diag9191.B2._foo()`? -fail_compilation/diag9191.d(38): Error: function `void diag9191.C4.toStringa()` does not override any function, did you mean to override `string object.Object.toString()`? +fail_compilation/diag9191.d(19): Error: function `void diag9191.C1.aaa()` does not override any function +fail_compilation/diag9191.d(15): did you mean to override `void diag9191.B1.aa()`? +fail_compilation/diag9191.d(25): Error: function `diag9191.C2.aaa` does not override any function +fail_compilation/diag9191.d(36): Error: function `void diag9191.C3.foo()` does not override any function +fail_compilation/diag9191.d(31): did you mean to override `void diag9191.B2._foo()`? +fail_compilation/diag9191.d(41): Error: function `void diag9191.C4.toStringa()` does not override any function +$p:druntime/import/object.d$($n$): did you mean to override `string object.Object.toString()`? --- */ diff --git a/tests/dmd/fail_compilation/fail18093.d b/tests/dmd/fail_compilation/fail18093.d index 4eb3663afc..ea14c44291 100644 --- a/tests/dmd/fail_compilation/fail18093.d +++ b/tests/dmd/fail_compilation/fail18093.d @@ -1,8 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/fail18093.d(19): Error: function `void fail18093.GenericTransitiveVisitor!(ASTCodegen).GenericTransitiveVisitor.ParseVisitMethods!(ASTCodegen).visit()` does not override any function, did you mean to override `extern (C++) void fail18093.ParseTimeVisitor!(ASTCodegen).ParseTimeVisitor.visit()`? -fail_compilation/fail18093.d(24): Error: mixin `fail18093.GenericTransitiveVisitor!(ASTCodegen).GenericTransitiveVisitor.ParseVisitMethods!(ASTCodegen)` error instantiating -fail_compilation/fail18093.d(27): Error: template instance `fail18093.GenericTransitiveVisitor!(ASTCodegen)` error instantiating +fail_compilation/fail18093.d(20): Error: function `void fail18093.GenericTransitiveVisitor!(ASTCodegen).GenericTransitiveVisitor.ParseVisitMethods!(ASTCodegen).visit()` does not override any function +fail_compilation/fail18093.d(16): did you mean to override `extern (C++) void fail18093.ParseTimeVisitor!(ASTCodegen).ParseTimeVisitor.visit()`? +fail_compilation/fail18093.d(25): Error: mixin `fail18093.GenericTransitiveVisitor!(ASTCodegen).GenericTransitiveVisitor.ParseVisitMethods!(ASTCodegen)` error instantiating +fail_compilation/fail18093.d(28): Error: template instance `fail18093.GenericTransitiveVisitor!(ASTCodegen)` error instantiating --- * https://issues.dlang.org/show_bug.cgi?id=18093 */ diff --git a/tests/dmd/fail_compilation/fail22351.d b/tests/dmd/fail_compilation/fail22351.d index 405ab557d7..44242a8338 100644 --- a/tests/dmd/fail_compilation/fail22351.d +++ b/tests/dmd/fail_compilation/fail22351.d @@ -2,9 +2,10 @@ REQUIRED_ARGS: -de TEST_OUTPUT: --- -fail_compilation/fail22351.d(18): Deprecation: overriding `extern(C++)` function `fail22351.C22351.func(int*)` with `const` qualified function `fail22351.Fail22351.func(const(int*))` is deprecated -fail_compilation/fail22351.d(18): Either remove `override`, or adjust the `const` qualifiers of the overriding function parameters -fail_compilation/fail22351.d(19): Error: function `extern (C++) void fail22351.Fail22351.func(const(int*)**)` does not override any function, did you mean to override `extern (C++) void fail22351.C22351.func(int*)`? +fail_compilation/fail22351.d(19): Deprecation: overriding `extern(C++)` function `fail22351.C22351.func(int*)` with `const` qualified function `fail22351.Fail22351.func(const(int*))` is deprecated +fail_compilation/fail22351.d(19): Either remove `override`, or adjust the `const` qualifiers of the overriding function parameters +fail_compilation/fail22351.d(20): Error: function `extern (C++) void fail22351.Fail22351.func(const(int*)**)` does not override any function +fail_compilation/fail22351.d(13): did you mean to override `extern (C++) void fail22351.C22351.func(int*)`? --- */ extern(C++) class C22351 diff --git a/tests/dmd/fail_compilation/fail262.d b/tests/dmd/fail_compilation/fail262.d index 7c92c7c182..7a7355931b 100644 --- a/tests/dmd/fail_compilation/fail262.d +++ b/tests/dmd/fail_compilation/fail262.d @@ -1,7 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/fail262.d(23): Error: function `const void fail262.B.f()` does not override any function, did you mean to override `shared const void fail262.A.f()`? +fail_compilation/fail262.d(24): Error: function `const void fail262.B.f()` does not override any function +fail_compilation/fail262.d(16): did you mean to override `shared const void fail262.A.f()`? --- */ diff --git a/tests/dmd/fail_compilation/fail8631.d b/tests/dmd/fail_compilation/fail8631.d index 4f5b0763d4..175553fdc6 100644 --- a/tests/dmd/fail_compilation/fail8631.d +++ b/tests/dmd/fail_compilation/fail8631.d @@ -1,7 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/fail8631.d(14): Error: function `shared const int fail8631.D.foo()` does not override any function, did you mean to override `immutable int fail8631.B.foo()`? +fail_compilation/fail8631.d(15): Error: function `shared const int fail8631.D.foo()` does not override any function +fail_compilation/fail8631.d(10): did you mean to override `immutable int fail8631.B.foo()`? --- */ diff --git a/tests/dmd/fail_compilation/retref2.d b/tests/dmd/fail_compilation/retref2.d index ca64653efa..8062cb1d07 100644 --- a/tests/dmd/fail_compilation/retref2.d +++ b/tests/dmd/fail_compilation/retref2.d @@ -1,8 +1,10 @@ /* TEST_OUTPUT: --- -fail_compilation/retref2.d(18): Error: function `ref int retref2.D.foo(return ref int)` does not override any function, did you mean to override `ref int retref2.C.foo(ref int)`? -fail_compilation/retref2.d(19): Error: function `ref int retref2.D.bar() scope return` does not override any function, did you mean to override `ref int retref2.C.bar()`? +fail_compilation/retref2.d(20): Error: function `ref int retref2.D.foo(return ref int)` does not override any function +fail_compilation/retref2.d(14): did you mean to override `ref int retref2.C.foo(ref int)`? +fail_compilation/retref2.d(21): Error: function `ref int retref2.D.bar() scope return` does not override any function +fail_compilation/retref2.d(15): did you mean to override `ref int retref2.C.bar()`? --- */ diff --git a/tests/dmd/fail_compilation/test13867.d b/tests/dmd/fail_compilation/test13867.d index 36543f92eb..59c49870b0 100644 --- a/tests/dmd/fail_compilation/test13867.d +++ b/tests/dmd/fail_compilation/test13867.d @@ -1,8 +1,10 @@ /* TEST_OUTPUT: --- -fail_compilation/test13867.d(12): Error: function `void test13867.X.blah()` does not override any function, did you mean to override `extern (C++) void test13867.Base.blah()`? -fail_compilation/test13867.d(19): Error: function `void test13867.Z.blah()` does not override any function, did you mean to override `extern (C++) void test13867.Base.blah()`? +fail_compilation/test13867.d(14): Error: function `void test13867.X.blah()` does not override any function +fail_compilation/test13867.d(11): did you mean to override `extern (C++) void test13867.Base.blah()`? +fail_compilation/test13867.d(21): Error: function `void test13867.Z.blah()` does not override any function +fail_compilation/test13867.d(11): did you mean to override `extern (C++) void test13867.Base.blah()`? --- */ extern (C++) class Base { diff --git a/tests/dmd/fail_compilation/test20489.d b/tests/dmd/fail_compilation/test20489.d index 1cd5350959..23da6a99ef 100644 --- a/tests/dmd/fail_compilation/test20489.d +++ b/tests/dmd/fail_compilation/test20489.d @@ -1,10 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/test20489.d(19): Error: function `pure nothrow @nogc @safe int test20489.D.f(int delegate(int) pure nothrow @nogc @safe body)` does not override any function, did you mean to override `pure nothrow @nogc @safe int test20489.B.f(scope int delegate(int) pure nothrow @nogc @safe)`? -fail_compilation/test20489.d(19): Did you intend to override: -fail_compilation/test20489.d(19): `pure nothrow @nogc @safe int test20489.B.f(scope int delegate(int) pure nothrow @nogc @safe)` -fail_compilation/test20489.d(19): Parameter 1 is missing `scope` +fail_compilation/test20489.d(18): Error: function `pure nothrow @nogc @safe int test20489.D.f(int delegate(int) pure nothrow @nogc @safe body)` does not override any function +fail_compilation/test20489.d(14): did you mean to override `pure nothrow @nogc @safe int test20489.B.f(scope int delegate(int) pure nothrow @nogc @safe)`? +fail_compilation/test20489.d(18): parameter 1 is missing `scope` --- */ diff --git a/tests/dmd/fail_compilation/test21246.d b/tests/dmd/fail_compilation/test21246.d index 02c0b35017..8e27d98505 100644 --- a/tests/dmd/fail_compilation/test21246.d +++ b/tests/dmd/fail_compilation/test21246.d @@ -3,7 +3,8 @@ /* TEST_OUTPUT: --- -fail_compilation/test21246.d(16): Error: function `void test21246.C.set(Clock clock)` does not override any function, did you mean to override `void imports.test21246.B.set(imports.test21246.Clock clock)`? +fail_compilation/test21246.d(17): Error: function `void test21246.C.set(Clock clock)` does not override any function +fail_compilation/imports/test21246.d(7): did you mean to override `void imports.test21246.B.set(imports.test21246.Clock clock)`? --- */ module test21246; From 942032ec6e3ed370b9761e6af252b699cd49e110 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Wed, 10 Dec 2025 23:01:01 -0800 Subject: [PATCH 144/440] fix typo and clarify edition help (dlang/dmd!22214) --- dmd/cli.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dmd/cli.d b/dmd/cli.d index 9d5afd5d81..ab7bf93d41 100644 --- a/dmd/cli.d +++ b/dmd/cli.d @@ -350,9 +350,9 @@ dmd -cov -unittest myprog.d $(LI $(I all): All) )`, ), - Option("edition[=G[]]", - "set language edition to edition year, apply to ", - "set edition to default, to a particular year NNNN, apply only to a particular $(I filename)" + Option("edition[=[]]", + "set language edition to year , apply to ", + "set edition to default which is 2023, to a particular year $(I NNNN), apply edition only to $(I filename)" ), Option("extern-std=", "set C++ name mangling compatibility with ", From 95ba4bf689227ccf356da63048ad5e09ffb92aa3 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Thu, 11 Dec 2025 00:09:49 -0800 Subject: [PATCH 145/440] allow some printf calls in @safe code (dlang/dmd!22145) --- dmd/chkformat.d | 35 +++++++++++++++++++++- dmd/expressionsem.d | 40 ++++++++++++++++++++----- dmd/targetcompiler.d | 2 +- tests/dmd/fail_compilation/safeprintf.d | 23 ++++++++++++++ 4 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 tests/dmd/fail_compilation/safeprintf.d diff --git a/dmd/chkformat.d b/dmd/chkformat.d index 8b2d5b4dd4..58144db681 100644 --- a/dmd/chkformat.d +++ b/dmd/chkformat.d @@ -25,6 +25,39 @@ import dmd.typesem; import dmd.target; +/********************************************** + * While in general printf is not @safe (and should be marked @system), many uses of printf are safe. + * This function determines if a particular call of printf is safe. + * Params: + * format = printf format string + * Returns: + * true if @safe + */ +public +bool isFormatSafe(scope const char[] format) +{ + //printf("isFormatSafe('%.*s')\n", cast(int)format.length, format.ptr); + /* Only need to check the format string, any other errors are checked + * for later with checkPrintfFormat() + */ + for (size_t i = 0; i < format.length;) + { + if (format[i] != '%') + { + ++i; + continue; + } + bool widthStar; + bool precisionStar; + size_t j = i; + const fmt = parsePrintfFormatSpecifier(format, j, widthStar, precisionStar); + i = j; + if (fmt == Format.s || fmt == Format.ls || fmt == Format.error) + return false; + } + return true; +} + /****************************************** * Check that arguments to a printf format string are compatible * with that string. Issue errors for incompatibilities. @@ -65,7 +98,7 @@ import dmd.target; public bool checkPrintfFormat(Loc loc, scope const char[] format, scope Expression[] args, bool isVa_list, ErrorSink eSink) { - //printf("checkPrintFormat('%.*s')\n", cast(int)format.length, format.ptr); + //printf("checkPrintfFormat('%.*s')\n", cast(int)format.length, format.ptr); size_t n; // index in args for (size_t i = 0; i < format.length;) { diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 75c50868b0..83cf1e2b51 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -3222,12 +3222,18 @@ private bool checkImpure(Scope* sc, Loc loc, const(char)* fmt, RootObject arg0) /********************************************* * Calling function f. - * Check the safety, i.e. if we're in a @safe function + * Check the safety, i.e. if we are in a @safe function * we can only call @safe or @trusted functions. - * Returns true if error occurs. + * Params: + * f = function being called + * loc = location for error messages + * sc = context + * arguments = array of actual arguments to function call, null for none + * Returns: true if unsafe (and diagnostic is generated) */ -private bool checkSafety(FuncDeclaration f, ref Loc loc, Scope* sc) +private bool checkSafety(FuncDeclaration f, ref Loc loc, Scope* sc, Expressions* arguments) { + //printf("checkSafety() %s\n", f.toChars()); if (sc.func == f) return false; if (sc.intypeof == 1) @@ -3256,6 +3262,23 @@ private bool checkSafety(FuncDeclaration f, ref Loc loc, Scope* sc) return false; } + if (f.printf) + { + TypeFunction tf = f.type.isTypeFunction(); + assert(tf); + const isVa_list = tf.parameterList.varargs == VarArg.none; + const nparams = tf.parameterList.length; + const nargs = arguments ? arguments.length : 0; + if (nparams == 1 && nargs) + { + if (auto se = (*arguments)[nparams - 1 - isVa_list].isStringExp()) + { + if (isFormatSafe(se.peekString())) + return false; + } + } + } + if (!f.isSafe() && !f.isTrusted()) { if (isRootTraitsCompilesScope(sc) ? sc.func.isSafeBypassingInference() : sc.func.setUnsafeCall(f)) @@ -3379,7 +3402,7 @@ private bool checkPostblit(Type t, ref Loc loc, Scope* sc) //checkAccess(sd, loc, sc, sd.postblit); // necessary? bool result = false; result |= sd.postblit.checkPurity(loc, sc); - result |= sd.postblit.checkSafety(loc, sc); + result |= sd.postblit.checkSafety(loc, sc, null); result |= sd.postblit.checkNogc(loc, sc); return result; } @@ -8185,7 +8208,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (exp.f) { exp.f.checkPurity(exp.loc, sc); - exp.f.checkSafety(exp.loc, sc); + exp.f.checkSafety(exp.loc, sc, exp.arguments); exp.f.checkNogc(exp.loc, sc); if (exp.f.checkNestedFuncReference(sc, exp.loc)) return setError(); @@ -10483,7 +10506,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { err |= !functionSemantic(cd.dtor); err |= cd.dtor.checkPurity(exp.loc, sc); - err |= cd.dtor.checkSafety(exp.loc, sc); + err |= cd.dtor.checkSafety(exp.loc, sc, null); err |= cd.dtor.checkNogc(exp.loc, sc); } if (err) @@ -17742,7 +17765,7 @@ bool checkAddressable(Expression e, Scope* sc, const(char)* action) * and usage of `deprecated` and `@disabled`-ed symbols are checked. * * Params: - * exp = expression to check attributes for + * exp = expression to check attributes for (CallExp or NewExp) * sc = scope of the function * f = function to be checked * Returns: `true` if error occur. @@ -17752,7 +17775,8 @@ private bool checkFunctionAttributes(Expression exp, Scope* sc, FuncDeclaration bool error = f.checkDisabled(exp.loc, sc); error |= f.checkDeprecated(exp.loc, sc); error |= f.checkPurity(exp.loc, sc); - error |= f.checkSafety(exp.loc, sc); + Expressions* arguments = exp.isCallExp() ? exp.isCallExp().arguments : null; + error |= f.checkSafety(exp.loc, sc, arguments); error |= f.checkNogc(exp.loc, sc); return error; } diff --git a/dmd/targetcompiler.d b/dmd/targetcompiler.d index 82e1ae50f0..8631c56d4a 100644 --- a/dmd/targetcompiler.d +++ b/dmd/targetcompiler.d @@ -84,7 +84,7 @@ else version (MARS) mixin template FuncDeclarationExtra() { VarDeclarations* alignSectionVars; /// local variables with alignment needs larger than stackAlign - import dmd.backend.cc : Symbol; + import dmd.backend.cc : Symbol; Symbol* salignSection; /// pointer to aligned section, if any } } diff --git a/tests/dmd/fail_compilation/safeprintf.d b/tests/dmd/fail_compilation/safeprintf.d new file mode 100644 index 0000000000..60bff2a879 --- /dev/null +++ b/tests/dmd/fail_compilation/safeprintf.d @@ -0,0 +1,23 @@ +/* +DISABLED: win32 win64 freebsd32 openbsd32 linux32 osx32 +TEST_OUTPUT: +--- +fail_compilation/safeprintf.d(20): Error: `@safe` function `safeprintf.func` cannot call `@system` function `safeprintf.printf` +fail_compilation/safeprintf.d(15): `safeprintf.printf` is declared here +fail_compilation/safeprintf.d(21): Error: `@safe` function `safeprintf.func` cannot call `@system` function `safeprintf.printf` +fail_compilation/safeprintf.d(15): `safeprintf.printf` is declared here +fail_compilation/safeprintf.d(22): Error: `@safe` function `safeprintf.func` cannot call `@system` function `safeprintf.printf` +fail_compilation/safeprintf.d(15): `safeprintf.printf` is declared here +fail_compilation/safeprintf.d(22): Deprecation: format specifier `"%Z"` is invalid +--- +*/ + +extern (C) @system pragma(printf) int printf(const(char)* format, ...); + +@safe void func(int i, char* s, dchar* d) +{ + printf("i: %d\n", i); + printf("s: %s\n", s); + printf("s: %S\n", d); + printf("s: %Z\n", s); +} From d6a6f96b4b5a5e9a189ea9caad14edaaa2f35148 Mon Sep 17 00:00:00 2001 From: AhmedMaged <111961041+AhmedMagedC@users.noreply.github.com> Date: Thu, 11 Dec 2025 16:12:49 +0200 Subject: [PATCH 146/440] =?UTF-8?q?Fix=20dlang/dmd!21920=20-=20cycle=20hap?= =?UTF-8?q?pens=20when=20insert=20funcroot=20instead=20of=20the=20templa?= =?UTF-8?q?=E2=80=A6=20(dlang/dmd!22216)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dmd/dsymbolsem.d | 3 --- dmd/funcsem.d | 17 ++++++++++++----- tests/dmd/runnable/overload.d | 18 ++++++++++++++++++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 61d578d477..535c88146c 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -942,9 +942,6 @@ private bool aliasOverloadInsert(AliasDeclaration ad, Dsymbol s) */ auto sa = ad.aliassym.toAlias(); - if (auto td = s.toAlias().isTemplateDeclaration()) - s = td.funcroot ? td.funcroot : td; - if (auto fd = sa.isFuncDeclaration()) { auto fa = new FuncAliasDeclaration(ad.ident, fd); diff --git a/dmd/funcsem.d b/dmd/funcsem.d index 84f844d827..383bd69296 100644 --- a/dmd/funcsem.d +++ b/dmd/funcsem.d @@ -3838,14 +3838,14 @@ extern (D) int overloadApply(Dsymbol fstart, scope int delegate(Dsymbol) dg, Sco int overloadApplyRecurse(Dsymbol fstart, scope int delegate(Dsymbol) dg, Scope* sc) { - // Detect cyclic calls. - if (visited.contains(fstart)) - return 0; - visited.push(fstart); - Dsymbol next; for (auto d = fstart; d; d = next) { + // Detect cyclic calls. + if (visited.contains(d)) + return 0; + visited.push(d); + import dmd.access : checkSymbolAccess; if (auto od = d.isOverDeclaration()) { @@ -3902,6 +3902,13 @@ extern (D) int overloadApply(Dsymbol fstart, scope int delegate(Dsymbol) dg, Sco } else if (auto td = d.isTemplateDeclaration()) { + // Sometimes funcroot is not in the .overnext chain + // in such case we have to recurse into it + if(td.funcroot) + { + if (int r = overloadApplyRecurse(td.funcroot, dg, sc)) + return r; + } if (int r = dg(td)) return r; next = td.overnext; diff --git a/tests/dmd/runnable/overload.d b/tests/dmd/runnable/overload.d index c413ade029..40fb4729e3 100644 --- a/tests/dmd/runnable/overload.d +++ b/tests/dmd/runnable/overload.d @@ -1262,6 +1262,23 @@ void test21522() /***************************************************/ +// https://github.com/dlang/dmd/issues/21920 + +struct S21920 +{ + void funB2(char a) {} + void funB(int b) {} + alias funB = funB2; + void funB()(float t) {} +} + +void test21920() +{ + static assert(__traits(getOverloads, S21920, "funB", true).length == 3); +} + +/***************************************************/ + int main() { test1528a(); @@ -1298,6 +1315,7 @@ int main() test14965(); test21481(); test21522(); + test21920(); printf("Success\n"); return 0; From 9464587ebfc4370b09e4837f4621c9037a64c82b Mon Sep 17 00:00:00 2001 From: Dennis Date: Fri, 12 Dec 2025 02:32:01 +0100 Subject: [PATCH 147/440] Fix dlang/dmd!21495 - Inconsistent behaviour of associative arrays in extern blocks (dlang/dmd!22221) --- dmd/cond.d | 1 + dmd/semantic3.d | 2 +- tests/dmd/compilable/test21495.d | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/compilable/test21495.d diff --git a/dmd/cond.d b/dmd/cond.d index a813900016..416d6bd692 100644 --- a/dmd/cond.d +++ b/dmd/cond.d @@ -149,6 +149,7 @@ extern (C++) final class StaticForeach : RootObject auto tf = new TypeFunction(ParameterList(), null, LINK.default_, STC.none); auto fd = new FuncLiteralDeclaration(loc, loc, tf, TOK.reserved, null); fd.fbody = s; + fd.skipCodegen = true; auto fe = new FuncExp(loc, fd); auto ce = new CallExp(loc, fe, new Expressions()); return ce; diff --git a/dmd/semantic3.d b/dmd/semantic3.d index 93f73eefa9..044d64e7b6 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -1403,7 +1403,7 @@ private extern(C++) final class Semantic3Visitor : Visitor return false; } - if (isCppNonMappableType(f.next.toBasetype())) + if (isCppNonMappableType(f.next.toBasetype()) && !funcdecl.skipCodegen) { .error(funcdecl.loc, "%s `%s` cannot return type `%s` because its linkage is `extern(C++)`", funcdecl.kind, funcdecl.toErrMsg(), f.next.toChars()); if (f.next.isTypeDArray()) diff --git a/tests/dmd/compilable/test21495.d b/tests/dmd/compilable/test21495.d new file mode 100644 index 0000000000..954bfa9e95 --- /dev/null +++ b/tests/dmd/compilable/test21495.d @@ -0,0 +1,15 @@ +// https://github.com/dlang/dmd/issues/21495 +extern (C++) +{ + enum string[string] meta = [ + "hellos": "worlds" + ]; + + struct metas + { + static foreach (key, value; meta) + { + mixin("enum string " ~ key ~ " = `" ~ value ~ "`;"); + } + } +} From a63f9667c8518a1b491c11826b776ff82b9ee2e4 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 12 Dec 2025 06:38:04 +0200 Subject: [PATCH 148/440] Move `FuncDeclaration.genCfunc` to `funcsem` (dlang/dmd!22222) --- dmd/cxxfrontend.d | 11 +++++------ dmd/func.d | 40 ---------------------------------------- dmd/funcsem.d | 42 ++++++++++++++++++++++++++++++++++++++++++ dmd/statementsem.d | 10 +++++----- 4 files changed, 52 insertions(+), 51 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index c2627ea771..4777117626 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -474,21 +474,20 @@ real_t toImaginary(Expression exp) } /*********************************************************** - * func.d + * funcsem.d */ FuncDeclaration genCfunc(Parameters* fparams, Type treturn, const(char)* name, StorageClass stc = STC.none) { - return FuncDeclaration.genCfunc(fparams, treturn, name, cast(STC) stc); + import dmd.funcsem; + return dmd.funcsem.genCfunc(fparams, treturn, name, cast(STC) stc); } FuncDeclaration genCfunc(Parameters* fparams, Type treturn, Identifier id, StorageClass stc = STC.none) { - return FuncDeclaration.genCfunc(fparams, treturn, id, cast(STC) stc); + import dmd.funcsem; + return dmd.funcsem.genCfunc(fparams, treturn, id, cast(STC) stc); } -/*********************************************************** - * funcsem.d - */ bool functionSemantic(FuncDeclaration fd) { import dmd.funcsem; diff --git a/dmd/func.d b/dmd/func.d index faabc7726c..62a2f6f6d5 100644 --- a/dmd/func.d +++ b/dmd/func.d @@ -752,46 +752,6 @@ extern (C++) class FuncDeclaration : Declaration return ParameterList(null, VarArg.none); } - /********************************** - * Generate a FuncDeclaration for a runtime library function. - */ - extern(D) static FuncDeclaration genCfunc(Parameters* fparams, Type treturn, const(char)* name, STC stc = STC.none) - { - return genCfunc(fparams, treturn, Identifier.idPool(name[0 .. strlen(name)]), stc); - } - - extern(D) static FuncDeclaration genCfunc(Parameters* fparams, Type treturn, Identifier id, STC stc = STC.none) - { - FuncDeclaration fd; - TypeFunction tf; - Dsymbol s; - __gshared DsymbolTable st = null; - - //printf("genCfunc(name = '%s')\n", id.toChars()); - //printf("treturn\n\t"); treturn.print(); - - // See if already in table - if (!st) - st = new DsymbolTable(); - s = st.lookup(id); - if (s) - { - fd = s.isFuncDeclaration(); - assert(fd); - assert(fd.type.nextOf().equals(treturn)); - } - else - { - tf = new TypeFunction(ParameterList(fparams), treturn, LINK.c, stc); - fd = new FuncDeclaration(Loc.initial, Loc.initial, id, STC.static_, tf); - fd.visibility = Visibility(Visibility.Kind.public_); - fd._linkage = LINK.c; - - st.insert(fd); - } - return fd; - } - inout(FuncDeclaration) toAliasFunc() inout @safe { return this; diff --git a/dmd/funcsem.d b/dmd/funcsem.d index 383bd69296..2241fea4f4 100644 --- a/dmd/funcsem.d +++ b/dmd/funcsem.d @@ -14,6 +14,7 @@ module dmd.funcsem; import core.stdc.stdio; +import core.stdc.string; import dmd.aggregate; import dmd.arraytypes; @@ -66,6 +67,47 @@ import dmd.typesem; import dmd.visitor; import dmd.visitor.statement_rewrite_walker; + +/********************************** + * Generate a FuncDeclaration for a runtime library function. + */ +FuncDeclaration genCfunc(Parameters* fparams, Type treturn, const(char)* name, STC stc = STC.none) +{ + return genCfunc(fparams, treturn, Identifier.idPool(name[0 .. strlen(name)]), stc); +} + +FuncDeclaration genCfunc(Parameters* fparams, Type treturn, Identifier id, STC stc = STC.none) +{ + FuncDeclaration fd; + TypeFunction tf; + Dsymbol s; + __gshared DsymbolTable st = null; + + //printf("genCfunc(name = '%s')\n", id.toChars()); + //printf("treturn\n\t"); treturn.print(); + + // See if already in table + if (!st) + st = new DsymbolTable(); + s = st.lookup(id); + if (s) + { + fd = s.isFuncDeclaration(); + assert(fd); + assert(fd.type.nextOf().equals(treturn)); + } + else + { + tf = new TypeFunction(ParameterList(fparams), treturn, LINK.c, stc); + fd = new FuncDeclaration(Loc.initial, Loc.initial, id, STC.static_, tf); + fd.visibility = Visibility(Visibility.Kind.public_); + fd._linkage = LINK.c; + + st.insert(fd); + } + return fd; +} + /* Tweak all return statements and dtor call for nrvo_var, for correct NRVO. */ extern (C++) final class NrvoWalker : StatementRewriteWalker diff --git a/dmd/statementsem.d b/dmd/statementsem.d index bd19ccc6f8..255d79c32d 100644 --- a/dmd/statementsem.d +++ b/dmd/statementsem.d @@ -3110,12 +3110,12 @@ Statement statementSemanticVisit(Statement s, Scope* sc) auto args = new Parameters(new Parameter(Loc.initial, STC.none, ClassDeclaration.object.type, null, null, null)); - FuncDeclaration fdenter = FuncDeclaration.genCfunc(args, Type.tvoid, Id.monitorenter); + FuncDeclaration fdenter = genCfunc(args, Type.tvoid, Id.monitorenter); Expression e = new CallExp(ss.loc, fdenter, new VarExp(ss.loc, tmp)); e.type = Type.tvoid; // do not run semantic on e cs.push(new ExpStatement(ss.loc, e)); - FuncDeclaration fdexit = FuncDeclaration.genCfunc(args, Type.tvoid, Id.monitorexit); + FuncDeclaration fdexit = genCfunc(args, Type.tvoid, Id.monitorexit); e = new CallExp(ss.loc, fdexit, new VarExp(ss.loc, tmp)); e.type = Type.tvoid; // do not run semantic on e Statement s = new ExpStatement(ss.loc, e); @@ -3150,7 +3150,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc) auto enterArgs = new Parameters(new Parameter(Loc.initial, STC.none, t.pointerTo(), null, null, null)); - FuncDeclaration fdenter = FuncDeclaration.genCfunc(enterArgs, Type.tvoid, Id.criticalenter, STC.nothrow_); + FuncDeclaration fdenter = genCfunc(enterArgs, Type.tvoid, Id.criticalenter, STC.nothrow_); Expression e = new AddrExp(ss.loc, tmpExp); e = e.expressionSemantic(sc); e = new CallExp(ss.loc, fdenter, e); @@ -3159,7 +3159,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc) auto exitArgs = new Parameters(new Parameter(Loc.initial, STC.none, t, null, null, null)); - FuncDeclaration fdexit = FuncDeclaration.genCfunc(exitArgs, Type.tvoid, Id.criticalexit, STC.nothrow_); + FuncDeclaration fdexit = genCfunc(exitArgs, Type.tvoid, Id.criticalexit, STC.nothrow_); e = new CallExp(ss.loc, fdexit, tmpExp); e.type = Type.tvoid; // do not run semantic on e Statement s = new ExpStatement(ss.loc, e); @@ -3873,7 +3873,7 @@ private extern(D) Expression applyArray(ForeachStatement fs, Expression flde, dgparams.push(new Parameter(Loc.initial, STC.none, Type.tvoidptr, null, null, null)); dgty = new TypeDelegate(new TypeFunction(ParameterList(dgparams), Type.tint32, LINK.d)); params.push(new Parameter(Loc.initial, STC.none, dgty, null, null, null)); - fdapply = FuncDeclaration.genCfunc(params, Type.tint32, fdname.ptr); + fdapply = genCfunc(params, Type.tint32, fdname.ptr); if (tab.isTypeSArray()) fs.aggr = fs.aggr.castTo(sc2, tn.arrayOf()); From fc041eef6331ff94238fb343a82a7bb8414916ff Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Fri, 12 Dec 2025 11:24:33 +0100 Subject: [PATCH 149/440] missed executing test in dlang/dmd!21547 (dlang/dmd!22224) --- tests/dmd/runnable/testpdb.d | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/dmd/runnable/testpdb.d b/tests/dmd/runnable/testpdb.d index 5814707fdc..0b206983bc 100644 --- a/tests/dmd/runnable/testpdb.d +++ b/tests/dmd/runnable/testpdb.d @@ -48,6 +48,8 @@ void main(string[] args) test19318(session, globals); + test18950(session, globals); + testE982(session, globals); test20253(session, globals); From 8019276d7e08012c2d5ba5ce47f89ed8c0be0074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Fri, 12 Dec 2025 13:12:49 +0100 Subject: [PATCH 150/440] macOS x64: Fix crash in backtrace() in Fiber contexts. Fixes dlang/dmd!21829. (dlang/dmd!22225) This keeps backtrace() from continuing to unwind past the end of the stack. The address otherwise doesn't appear to be used anywhere. Note that backtrace() gets called internally be some OS functions, such as CGLCreateContext, so the previous code lead to crashes that were difficult to avoid. --- runtime/druntime/src/core/thread/fiber/package.d | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/runtime/druntime/src/core/thread/fiber/package.d b/runtime/druntime/src/core/thread/fiber/package.d index f8af86bc70..437eca9965 100644 --- a/runtime/druntime/src/core/thread/fiber/package.d +++ b/runtime/druntime/src/core/thread/fiber/package.d @@ -1027,7 +1027,16 @@ protected: { push( 0x00000000_00000000 ); // Return address of fiber_entryPoint call push( cast(size_t) &fiber_entryPoint ); // RIP - push( cast(size_t) m_ctxt.bstack ); // RBP + version (OSX) + { + // backtrace() needs this to be null to terminate + // the stack walk on macOS x86_64 + push( 0x00000000_00000000 ); // RBP + } + else + { + push( cast(size_t) m_ctxt.bstack ); // RBP + } push( 0x00000000_00000000 ); // RBX push( 0x00000000_00000000 ); // R12 push( 0x00000000_00000000 ); // R13 From e1035043f20e54a2020776de6b6f8666aa7da25e Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 13 Dec 2025 01:20:48 -0800 Subject: [PATCH 151/440] simplify DotTemplateInstanceExp constructor (dlang/dmd!22231) --- dmd/expression.d | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/dmd/expression.d b/dmd/expression.d index 1359051736..d0bdfb1bc8 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -2317,17 +2317,16 @@ extern (C++) final class DotTemplateInstanceExp : UnaExp { TemplateInstance ti; - extern (D) this(Loc loc, Expression e, Identifier name, Objects* tiargs) + extern (D) this(Loc loc, Expression e, TemplateInstance ti) @safe { super(loc, EXP.dotTemplateInstance, e); - //printf("DotTemplateInstanceExp()\n"); - this.ti = new TemplateInstance(loc, name, tiargs); + this.ti = ti; } - extern (D) this(Loc loc, Expression e, TemplateInstance ti) @safe + extern (D) this(Loc loc, Expression e, Identifier name, Objects* tiargs) { - super(loc, EXP.dotTemplateInstance, e); - this.ti = ti; + //printf("DotTemplateInstanceExp()\n"); + this(loc, e, new TemplateInstance(loc, name, tiargs)); } override DotTemplateInstanceExp syntaxCopy() From d13cecfafd347bd0b401abe5f50b085698bfd421 Mon Sep 17 00:00:00 2001 From: Emmanuel Nyarko <57257441+Emmankoko@users.noreply.github.com> Date: Sat, 13 Dec 2025 09:21:31 +0000 Subject: [PATCH 152/440] fix issue dlang/dmd!20425 (dlang/dmd!22218) --- dmd/dcast.d | 54 +++++++++++++++++++++++++++++++++ tests/dmd/compilable/fix20425.c | 11 +++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/dmd/compilable/fix20425.c diff --git a/dmd/dcast.d b/dmd/dcast.d index 41c103ce7e..0265fc2397 100644 --- a/dmd/dcast.d +++ b/dmd/dcast.d @@ -3445,6 +3445,60 @@ Lagain: t1b = t1.toBasetype(); t2b = t2.toBasetype(); + static bool isComplexStruct(Type t) + { + if (t.ty != Tstruct) + return false; + + TypeStruct ts = t.isTypeStruct(); + + return ts.sym.toString() == "_Complex"; + } + + static bool isComplexStructOfType(Type t, Type t2) + { + if (!isComplexStruct(t)) + return false; + + TypeStruct ts = t.toBasetype().isTypeStruct(); + + Type memberType = ts.sym.fields[0].type.toBasetype(); + + /* encure the complex member types fall under one of the complex types */ + switch (memberType.toBasetype().ty) + { + case Tfloat32: + case Tfloat64: + case Tfloat80: + break; + default: + return false; + } + + switch (t2.toBasetype().ty) + { + case Tfloat32: + case Tfloat64: + case Tfloat80: + return true; + default: + return false; + } + } + + /* check for complex structure and an associate complex type in a single condexp */ + if (sc && sc.inCfile) + { + if (isComplexStructOfType(t1b, t2b)) + { + return Lret(e1.type.toBasetype()); + } + else if (isComplexStructOfType(t2b, t1b)) + { + return Lret(e2.type.toBasetype()); + } + } + const ty = implicitConvCommonTy(t1b.ty, t2b.ty); if (ty != Terror) { diff --git a/tests/dmd/compilable/fix20425.c b/tests/dmd/compilable/fix20425.c new file mode 100644 index 0000000000..0d87ec637f --- /dev/null +++ b/tests/dmd/compilable/fix20425.c @@ -0,0 +1,11 @@ +// DISABLED: win32 win64 + +#include + +void foo() { + double *a; + double _Complex *b; + double _Complex zden; + double c, d; + zden = c > d? b[0]: a[0]; +} From 5738af060ea11e2b6b45ef7643afc1b94950e583 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 13 Dec 2025 01:22:56 -0800 Subject: [PATCH 153/440] change checkType() to hasValidType() (dlang/dmd!22230) --- dmd/expression.d | 44 ++++++++++++++++++++++---------------------- dmd/expression.h | 14 +++++++------- dmd/expressionsem.d | 2 +- dmd/frontend.h | 14 +++++++------- dmd/statementsem.d | 2 +- dmd/typesem.d | 2 +- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/dmd/expression.d b/dmd/expression.d index d0bdfb1bc8..50bfc93c3a 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -297,13 +297,13 @@ extern (C++) abstract class Expression : ASTNode * Check that the expression has a valid type. * If not, generates an error "... has no type". * Returns: - * true if the expression is not valid. + * true if the expression has a valid type. * Note: - * When this function returns true, `checkValue()` should also return true. + * When this function returns false, `checkValue()` should also return true. */ - bool checkType() + bool hasValidType() { - return false; + return true; } /****************************** @@ -1557,10 +1557,10 @@ extern (C++) final class TypeExp : Expression return new TypeExp(loc, type.syntaxCopy()); } - override bool checkType() + override bool hasValidType() { error(loc, "type `%s` is not an expression", toChars()); - return true; + return false; } override void accept(Visitor v) @@ -1595,25 +1595,25 @@ extern (C++) final class ScopeExp : Expression return new ScopeExp(loc, sds.syntaxCopy(null)); } - override bool checkType() + override bool hasValidType() { if (sds.isPackage()) { error(loc, "%s `%s` has no type", sds.kind(), sds.toChars()); - return true; + return false; } auto ti = sds.isTemplateInstance(); if (!ti) - return false; + return true; //assert(ti.needsTypeInference(sc)); if (ti.tempdecl && ti.semantictiargsdone && ti.semanticRun == PASS.initial) { error(loc, "partial %s `%s` has no type", sds.kind(), toChars()); - return true; + return false; } - return false; + return true; } override void accept(Visitor v) @@ -1638,10 +1638,10 @@ extern (C++) final class TemplateExp : Expression this.fd = fd; } - override bool checkType() + override bool hasValidType() { error(loc, "%s `%s` has no type", td.kind(), toChars()); - return true; + return false; } override void accept(Visitor v) @@ -1874,14 +1874,14 @@ extern (C++) final class FuncExp : Expression return new FuncExp(loc, fd); } - override bool checkType() + override bool hasValidType() { if (td) { error(loc, "template lambda has no type"); - return true; + return false; } - return false; + return true; } override void accept(Visitor v) @@ -2274,10 +2274,10 @@ extern (C++) final class DotTemplateExp : UnaExp this.td = td; } - override bool checkType() + override bool hasValidType() { error(loc, "%s `%s` has no type", td.kind(), toChars()); - return true; + return false; } override void accept(Visitor v) @@ -2334,17 +2334,17 @@ extern (C++) final class DotTemplateInstanceExp : UnaExp return new DotTemplateInstanceExp(loc, e1.syntaxCopy(), ti.name, TemplateInstance.arraySyntaxCopy(ti.tiargs)); } - override bool checkType() + override bool hasValidType() { - // Same logic as ScopeExp.checkType() + // Same logic as ScopeExp.hasValidType() if (ti.tempdecl && ti.semantictiargsdone && ti.semanticRun == PASS.initial) { error(loc, "partial %s `%s` has no type", ti.kind(), toChars()); - return true; + return false; } - return false; + return true; } override void accept(Visitor v) diff --git a/dmd/expression.h b/dmd/expression.h index 09bf8e7f0e..35aa35dbde 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -106,7 +106,7 @@ class Expression : public ASTNode const char* toChars() const final override; - virtual bool checkType(); + virtual bool hasValidType(); Expression *addressOf(); Expression *deref(); @@ -451,7 +451,7 @@ class TypeExp final : public Expression { public: TypeExp *syntaxCopy() override; - bool checkType() override; + bool hasValidType() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -461,7 +461,7 @@ class ScopeExp final : public Expression ScopeDsymbol *sds; ScopeExp *syntaxCopy() override; - bool checkType() override; + bool hasValidType() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -471,7 +471,7 @@ class TemplateExp final : public Expression TemplateDeclaration *td; FuncDeclaration *fd; - bool checkType() override; + bool hasValidType() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -565,7 +565,7 @@ class FuncExp final : public Expression TOK tok; FuncExp *syntaxCopy() override; - bool checkType() override; + bool hasValidType() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -707,7 +707,7 @@ class DotTemplateExp final : public UnaExp public: TemplateDeclaration *td; - bool checkType() override; + bool hasValidType() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -726,7 +726,7 @@ class DotTemplateInstanceExp final : public UnaExp TemplateInstance *ti; DotTemplateInstanceExp *syntaxCopy() override; - bool checkType() override; + bool hasValidType() override; void accept(Visitor *v) override { v->visit(this); } }; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 83cf1e2b51..ac4fc4f39d 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -10598,7 +10598,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor result = e1x; return; } - if (e1x.checkType()) + if (!e1x.hasValidType()) return setError(); exp.e1 = e1x; diff --git a/dmd/frontend.h b/dmd/frontend.h index cbbc3eb49e..98716b966a 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2316,7 +2316,7 @@ class Expression : public ASTNode virtual Expression* syntaxCopy(); DYNCAST dyncast() const final override; const char* toChars() const final override; - virtual bool checkType(); + virtual bool hasValidType(); Expression* deref(); int32_t isConst(); virtual bool hasCode(); @@ -2810,7 +2810,7 @@ class DotTemplateExp final : public UnaExp { public: TemplateDeclaration* td; - bool checkType() override; + bool hasValidType() override; void accept(Visitor* v) override; }; @@ -2819,7 +2819,7 @@ class DotTemplateInstanceExp final : public UnaExp public: TemplateInstance* ti; DotTemplateInstanceExp* syntaxCopy() override; - bool checkType() override; + bool hasValidType() override; void accept(Visitor* v) override; }; @@ -3105,7 +3105,7 @@ class FuncExp final : public Expression TemplateDeclaration* td; TOK tok; FuncExp* syntaxCopy() override; - bool checkType() override; + bool hasValidType() override; void accept(Visitor* v) override; }; @@ -3406,7 +3406,7 @@ class ScopeExp final : public Expression public: ScopeDsymbol* sds; ScopeExp* syntaxCopy() override; - bool checkType() override; + bool hasValidType() override; void accept(Visitor* v) override; }; @@ -3594,7 +3594,7 @@ class TemplateExp final : public Expression public: TemplateDeclaration* td; FuncDeclaration* fd; - bool checkType() override; + bool hasValidType() override; void accept(Visitor* v) override; }; @@ -3635,7 +3635,7 @@ class TypeExp final : public Expression { public: TypeExp* syntaxCopy() override; - bool checkType() override; + bool hasValidType() override; void accept(Visitor* v) override; }; diff --git a/dmd/statementsem.d b/dmd/statementsem.d index ffc8e6c11d..35d4b1bf3f 100644 --- a/dmd/statementsem.d +++ b/dmd/statementsem.d @@ -2606,7 +2606,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc) rs.exp = resolveAliasThis(sc, rs.exp); rs.exp = resolveProperties(sc, rs.exp); - if (rs.exp.checkType()) + if (!rs.exp.hasValidType()) rs.exp = ErrorExp.get(); if (auto f = isFuncAddress(rs.exp)) { diff --git a/dmd/typesem.d b/dmd/typesem.d index 4d17996dac..0c592077d0 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -5259,7 +5259,7 @@ void resolve(Type mt, Loc loc, Scope* sc, out Expression pe, out Type pt, out Ds !mt.exp.type.isTypeTuple()) { if (!sc.inCfile && // in (extended) C typeof may be used on types as with sizeof - mt.exp.checkType()) + !mt.exp.hasValidType()) goto Lerr; /* Today, 'typeof(func)' returns void if func is a From 75947dc1242926a8849f2c78bcf368c367d12784 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 13 Dec 2025 14:48:01 -0800 Subject: [PATCH 154/440] move error message generation out of IntegerExp() (dlang/dmd!22234) --- dmd/enumsem.d | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dmd/enumsem.d b/dmd/enumsem.d index cdf8a61bd8..f00c69c451 100644 --- a/dmd/enumsem.d +++ b/dmd/enumsem.d @@ -488,21 +488,30 @@ void enumMemberSemantic(Scope* sc, EnumMember em) else if (first) { Type t; + bool terror; if (em.ed.memtype) + { t = em.ed.memtype; + if (!t.isScalar()) + { + t = Type.terror; // print more relevant error message later + terror = true; + } + } else { t = Type.tint32; if (!em.ed.isAnonymous()) em.ed.memtype = t; } + const errors = global.startGagging(); Expression e = new IntegerExp(em.loc, 0, t); e = e.ctfeInterpret(); - if (global.endGagging(errors)) + if (global.endGagging(errors) || terror) { error(em.loc, "cannot generate 0 value of type `%s` for `%s`", - t.toChars(), em.toChars()); + em.ed.memtype.toChars(), em.toChars()); } // save origValue for better json output em.origValue = e; From e8a14c77de30517c625b3d210b80e4e2d6006d42 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 13 Dec 2025 20:37:16 -0800 Subject: [PATCH 155/440] remove error message generation from IntegerExp constructor (dlang/dmd!22235) --- dmd/expression.d | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dmd/expression.d b/dmd/expression.d index 50bfc93c3a..a8ea6acdd7 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -511,13 +511,13 @@ extern (C++) final class IntegerExp : Expression super(loc, EXP.int64); //printf("IntegerExp(value = %lld, type = '%s')\n", value, type ? type.toChars() : ""); assert(type); - if (!type.isScalar()) - { - //printf("%s, loc = %d\n", toChars(), loc.linnum); - if (type.ty != Terror) - error(loc, "integral constant must be scalar type, not `%s`", type.toChars()); - type = Type.terror; - } + + /* Verify no path to the following assert failure. + * Weirdly, the isScalar() includes floats - see enumsem.enumMemberSemantic() for the + * base type. This is possibly a bug. + */ + assert(type.isScalar() || type.ty == Terror); + this.type = type; this.value = normalize(type.toBasetype().ty, value); } From 9faa8ee4de76f11105d5c38029377c0d2dcf0d2c Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sun, 14 Dec 2025 00:08:05 -0800 Subject: [PATCH 156/440] numberOfCodeUnits: push error messages upstream (dlang/dmd!22236) --- dmd/dcast.d | 10 ++++++++-- dmd/expression.d | 15 ++++++--------- dmd/expressionsem.d | 14 ++++++++++---- dmd/frontend.h | 1 - dmd/initsem.d | 14 ++++++++++---- 5 files changed, 34 insertions(+), 20 deletions(-) diff --git a/dmd/dcast.d b/dmd/dcast.d index 0265fc2397..ff604c9cce 100644 --- a/dmd/dcast.d +++ b/dmd/dcast.d @@ -680,7 +680,10 @@ MATCH implicitConvTo(Expression e, Type t) { if (e.committed && tynto != tyn) return MATCH.nomatch; - size_t fromlen = e.numberOfCodeUnits(tynto); + string s; + size_t fromlen = e.numberOfCodeUnits(tynto, s); + if (s) + error(e.loc, "%.*s", cast(int)s.length, s.ptr); size_t tolen = cast(size_t)t.isTypeSArray().dim.toInteger(); if (tolen < fromlen) return MATCH.nomatch; @@ -702,7 +705,10 @@ MATCH implicitConvTo(Expression e, Type t) { if (e.committed && tynto != tyn) return MATCH.nomatch; - size_t fromlen = e.numberOfCodeUnits(tynto); + string s; + size_t fromlen = e.numberOfCodeUnits(tynto, s); + if (s) + error(e.loc, "%.*s", cast(int)s.length, s.ptr); size_t tolen = cast(size_t)t.isTypeSArray().dim.toInteger(); if (tolen < fromlen) return MATCH.nomatch; diff --git a/dmd/expression.d b/dmd/expression.d index a8ea6acdd7..a566e1fab4 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -965,10 +965,11 @@ extern (C++) final class StringExp : Expression * as tynto. * Params: * tynto = code unit type of the target encoding + * s = set to error message on invalid string * Returns: * number of code units */ - size_t numberOfCodeUnits(int tynto = 0) const + extern (D) size_t numberOfCodeUnits(int tynto, out .string s) const { int encSize; switch (tynto) @@ -991,11 +992,9 @@ extern (C++) final class StringExp : Expression case 1: for (size_t u = 0; u < len;) { - if (const s = utf_decodeChar(string[0 .. len], u, c)) - { - error(loc, "%.*s", cast(int)s.length, s.ptr); + s = utf_decodeChar(string[0 .. len], u, c); + if (s) return 0; - } result += utf_codeLength(encSize, c); } break; @@ -1003,11 +1002,9 @@ extern (C++) final class StringExp : Expression case 2: for (size_t u = 0; u < len;) { - if (const s = utf_decodeWchar(wstring[0 .. len], u, c)) - { - error(loc, "%.*s", cast(int)s.length, s.ptr); + s = utf_decodeWchar(wstring[0 .. len], u, c); + if (s) return 0; - } result += utf_codeLength(encSize, c); } break; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index ac4fc4f39d..869ead7722 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -17989,11 +17989,17 @@ private bool fit(StructDeclaration sd, Loc loc, Scope* sc, Expressions* elements Type typeb = se.type.toBasetype(); TY tynto = tb.nextOf().ty; if (!se.committed && - typeb.isStaticOrDynamicArray() && tynto.isSomeChar && - se.numberOfCodeUnits(tynto) < (cast(TypeSArray)tb).dim.toInteger()) + typeb.isStaticOrDynamicArray() && tynto.isSomeChar) { - e = se.castTo(sc, t); - goto L1; + string s; + size_t len = se.numberOfCodeUnits(tynto, s); + if (s) + error(se.loc, "%.*s", cast(int)s.length, s.ptr); + if (len < (cast(TypeSArray)tb).dim.toInteger()) + { + e = se.castTo(sc, t); + goto L1; + } } } diff --git a/dmd/frontend.h b/dmd/frontend.h index 98716b966a..57929b46ab 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -3494,7 +3494,6 @@ class StringExp final : public Expression static StringExp* create(Loc loc, const char* s); static StringExp* create(Loc loc, const void* string, size_t len); - size_t numberOfCodeUnits(int32_t tynto = 0) const; void writeTo(void* dest, bool zero, int32_t tyto = 0) const; char32_t getCodeUnit(size_t i) const; dinteger_t getIndex(size_t i) const; diff --git a/dmd/initsem.d b/dmd/initsem.d index 9e9d46f446..43ea1cd4c4 100644 --- a/dmd/initsem.d +++ b/dmd/initsem.d @@ -447,11 +447,17 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn Type typeb = se.type.toBasetype(); TY tynto = tb.nextOf().ty; if (!se.committed && - typeb.isStaticOrDynamicArray() && tynto.isSomeChar && - se.numberOfCodeUnits(tynto) < tb.isTypeSArray().dim.toInteger()) + typeb.isStaticOrDynamicArray() && tynto.isSomeChar) { - i.exp = se.castTo(sc, t); - goto L1; + string s; + size_t len = se.numberOfCodeUnits(tynto, s); + if (s) + error(se.loc, "%.*s", cast(int)s.length, s.ptr); + if (len < tb.isTypeSArray().dim.toInteger()) + { + i.exp = se.castTo(sc, t); + goto L1; + } } /* Lop off terminating 0 of initializer for: From d3bfd630097cfce3abef6a2fb7ba8e5cb3bb8fe3 Mon Sep 17 00:00:00 2001 From: Jonathan M Davis Date: Mon, 15 Dec 2025 01:06:07 -0700 Subject: [PATCH 157/440] fix dlang/dmd!22239: Add the FreeBSD_15 version identifier. (dlang/dmd!22240) This adds the FreeBSD_15 version identifier to dmd (now that FreeBSD 15 has been released), and defines __FreeBSD_version in druntime accordingly. It also fixes __FreeBSD_version for FreeBSD 14 so that it matches the initial release of FreeBSD 14 and not the value it had when development started. --- dmd/target.d | 2 ++ runtime/druntime/src/core/sys/freebsd/config.d | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dmd/target.d b/dmd/target.d index 2a4edec85b..4575ae9355 100644 --- a/dmd/target.d +++ b/dmd/target.d @@ -83,6 +83,8 @@ ubyte defaultTargetOSMajor() @safe return 13; else version (TARGET_FREEBSD14) return 14; + else version (TARGET_FREEBSD15) + return 15; else return 0; } diff --git a/runtime/druntime/src/core/sys/freebsd/config.d b/runtime/druntime/src/core/sys/freebsd/config.d index 9d502e52e3..c57d2e4aa8 100644 --- a/runtime/druntime/src/core/sys/freebsd/config.d +++ b/runtime/druntime/src/core/sys/freebsd/config.d @@ -14,7 +14,8 @@ public import core.sys.posix.config; // NOTE: When adding newer versions of FreeBSD, verify all current versioned // bindings are still compatible with the release. - version (FreeBSD_14) enum __FreeBSD_version = 1400000; + version (FreeBSD_15) enum __FreeBSD_version = 1500063; +else version (FreeBSD_14) enum __FreeBSD_version = 1400097; else version (FreeBSD_13) enum __FreeBSD_version = 1301000; else version (FreeBSD_12) enum __FreeBSD_version = 1203000; else version (FreeBSD_11) enum __FreeBSD_version = 1104000; From 7e37938d83e758ac60e84f6e5f5d92dad61d026f Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Mon, 15 Dec 2025 21:40:16 +0000 Subject: [PATCH 158/440] fix Undefined identifer --- runtime/druntime/src/importc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtime/druntime/src/importc.h b/runtime/druntime/src/importc.h index dd2cdb87b4..f645a03790 100644 --- a/runtime/druntime/src/importc.h +++ b/runtime/druntime/src/importc.h @@ -74,6 +74,8 @@ typedef unsigned short __uint16_t; typedef unsigned int __uint32_t; typedef unsigned long long __uint64_t; +#define __FUNCTION__ __func__ + /********************* * Obsolete detritus */ From a02f5ab390ff9ae24c252c1866dfc965b414cdce Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Mon, 15 Dec 2025 21:56:41 +0000 Subject: [PATCH 159/440] parse it rather --- dmd/cparse.d | 6 ++++++ runtime/druntime/src/importc.h | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dmd/cparse.d b/dmd/cparse.d index 9c4645a991..26ed0458c5 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -752,6 +752,12 @@ final class CParser(AST) : Parser!AST const id = token.ident.toString(); if (id.length > 2 && id[0] == '_' && id[1] == '_') // leading double underscore { + if (token.ident is Id.FUNCTION) //__FUNCTION__ predefined macro + { + e = new AST.FuncInitExp(loc); + nextToken(); + break; + } if (token.ident is Id.__func__) { addFuncName = true; // implicitly declare __func__ diff --git a/runtime/druntime/src/importc.h b/runtime/druntime/src/importc.h index f645a03790..dd2cdb87b4 100644 --- a/runtime/druntime/src/importc.h +++ b/runtime/druntime/src/importc.h @@ -74,8 +74,6 @@ typedef unsigned short __uint16_t; typedef unsigned int __uint32_t; typedef unsigned long long __uint64_t; -#define __FUNCTION__ __func__ - /********************* * Obsolete detritus */ From 90f9d93433878e9fc8c7f16e851de58bf41be22a Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Mon, 15 Dec 2025 23:45:04 +0000 Subject: [PATCH 160/440] add pretty_function and add tests --- dmd/cparse.d | 2 +- tests/dmd/compilable/func.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/compilable/func.c diff --git a/dmd/cparse.d b/dmd/cparse.d index 26ed0458c5..87adf23421 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -752,7 +752,7 @@ final class CParser(AST) : Parser!AST const id = token.ident.toString(); if (id.length > 2 && id[0] == '_' && id[1] == '_') // leading double underscore { - if (token.ident is Id.FUNCTION) //__FUNCTION__ predefined macro + if (token.ident is Id.FUNCTION || token.ident is Id.PRETTY_FUNCTION) //__FUNCTION__ predefined macro { e = new AST.FuncInitExp(loc); nextToken(); diff --git a/tests/dmd/compilable/func.c b/tests/dmd/compilable/func.c new file mode 100644 index 0000000000..cfe59dfd1c --- /dev/null +++ b/tests/dmd/compilable/func.c @@ -0,0 +1,12 @@ +#include +#include +void foo() +{ + assert(strcmp(__FUNCTION__, "foo") == 0); + assert(strcmp(__PRETTY_FUNCTION__, "func.foo") == 0); +} + +int main() +{ + foo(); +} From 554e9322629b2bdc6b880761e0f163233f1a9093 Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Tue, 16 Dec 2025 12:08:46 +0000 Subject: [PATCH 161/440] correct __FUNCTION__ uodate --- tests/dmd/{compilable => runnable}/func.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename tests/dmd/{compilable => runnable}/func.c (72%) diff --git a/tests/dmd/compilable/func.c b/tests/dmd/runnable/func.c similarity index 72% rename from tests/dmd/compilable/func.c rename to tests/dmd/runnable/func.c index cfe59dfd1c..a0c8b41178 100644 --- a/tests/dmd/compilable/func.c +++ b/tests/dmd/runnable/func.c @@ -1,8 +1,9 @@ #include #include + void foo() { - assert(strcmp(__FUNCTION__, "foo") == 0); + assert(strcmp(__FUNCTION__, "func.foo") == 0); assert(strcmp(__PRETTY_FUNCTION__, "func.foo") == 0); } From 17cffa0b61708dc2a9263597be2f3c2b18d36a11 Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Tue, 16 Dec 2025 12:42:34 +0000 Subject: [PATCH 162/440] bump what the macro holds on each platform --- tests/dmd/runnable/func.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/dmd/runnable/func.c b/tests/dmd/runnable/func.c index a0c8b41178..7c9f401675 100644 --- a/tests/dmd/runnable/func.c +++ b/tests/dmd/runnable/func.c @@ -1,10 +1,14 @@ #include #include +#include void foo() { - assert(strcmp(__FUNCTION__, "func.foo") == 0); - assert(strcmp(__PRETTY_FUNCTION__, "func.foo") == 0); + //assert(strcmp(__FUNCTION__, "func.foo") == 0); + //assert(strcmp(__PRETTY_FUNCTION__, "func.foo") == 0); + printf("functions is %s\n", __FUNCTION__); + printf("pretty function is %s\n", __PRETTY_FUNCTION__); + } int main() From f41faac814e41b47ce2aff61c1640549630d08e0 Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Tue, 16 Dec 2025 15:43:53 +0000 Subject: [PATCH 163/440] update to use use __FUNCTION__ like __func__ --- dmd/cparse.d | 34 ++++++++++++++++++++-------------- tests/dmd/runnable/func.c | 6 ++---- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/dmd/cparse.d b/dmd/cparse.d index 87adf23421..20551c2229 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -36,6 +36,7 @@ final class CParser(AST) : Parser!AST AST.Dsymbols* symbols; // symbols declared in current scope bool addFuncName; /// add declaration of __func__ to function symbol table + bool refFuncName; // declaration of __FUNCTION__ bool importBuiltins; /// seen use of C compiler builtins, so import __importc_builtins; private @@ -752,12 +753,9 @@ final class CParser(AST) : Parser!AST const id = token.ident.toString(); if (id.length > 2 && id[0] == '_' && id[1] == '_') // leading double underscore { - if (token.ident is Id.FUNCTION || token.ident is Id.PRETTY_FUNCTION) //__FUNCTION__ predefined macro - { - e = new AST.FuncInitExp(loc); - nextToken(); - break; - } + if (token.ident is Id.FUNCTION) + refFuncName = true; // implicitly declare __FUNCTION__ + if (token.ident is Id.__func__) { addFuncName = true; // implicitly declare __func__ @@ -2230,7 +2228,9 @@ final class CParser(AST) : Parser!AST } } - addFuncName = false; // gets set to true if somebody references __func__ in this function + /* gets set to true if somebody references __func__ in this function, //ditto for __FUNCTION__ */ + addFuncName = false; + refFuncName = false; const locFunc = token.loc; auto body = cparseStatement(ParseStatementFlags.curly); // don't start a new scope; continue with parameter scope @@ -2241,11 +2241,17 @@ final class CParser(AST) : Parser!AST auto fd = new AST.FuncDeclaration(id.loc, prevloc, id.name, stc, ft, specifier.noreturn); specifiersToFuncDeclaration(fd, specifier); + auto stmts = new AST.Statements(); + if (addFuncName) - { - auto s = createFuncName(locFunc, id.name); - body = new AST.CompoundStatement(locFunc, s, body); - } + stmts.push(createFuncName(locFunc, id.name, Id.__func__)); + + if (refFuncName) + stmts.push(createFuncName(locFunc, id.name, Id.FUNCTION)); + + stmts.push(body); + + body = new AST.CompoundStatement(locFunc, stmts); fd.fbody = body; // TODO add `symbols` to the function's local symbol table `sc2` in FuncDeclaration::semantic3() @@ -4855,9 +4861,9 @@ final class CParser(AST) : Parser!AST * loc = location for this declaration * id = identifier of function * Returns: - * statement representing the declaration of __func__ + * statement representing the declaration of __func__, __FUNCTION__, or __PRETTY-FUNCTION__ */ - private AST.Statement createFuncName(Loc loc, Identifier id) + private AST.Statement createFuncName(Loc loc, Identifier id, Identifier cident) { const fn = id.toString(); // function-name auto efn = new AST.StringExp(loc, fn, fn.length, 1, 'c'); @@ -4866,7 +4872,7 @@ final class CParser(AST) : Parser!AST auto tfn = new AST.TypeSArray(AST.Type.tchar, lenfn); efn.type = tfn.makeImmutable(); efn.committed = true; - auto sfn = new AST.VarDeclaration(loc, tfn, Id.__func__, ifn, STC.gshared | STC.immutable_); + auto sfn = new AST.VarDeclaration(loc, tfn, cident, ifn, STC.gshared | STC.immutable_); auto e = new AST.DeclarationExp(loc, sfn); return new AST.ExpStatement(loc, e); } diff --git a/tests/dmd/runnable/func.c b/tests/dmd/runnable/func.c index 7c9f401675..f20970801f 100644 --- a/tests/dmd/runnable/func.c +++ b/tests/dmd/runnable/func.c @@ -4,10 +4,8 @@ void foo() { - //assert(strcmp(__FUNCTION__, "func.foo") == 0); - //assert(strcmp(__PRETTY_FUNCTION__, "func.foo") == 0); - printf("functions is %s\n", __FUNCTION__); - printf("pretty function is %s\n", __PRETTY_FUNCTION__); + assert(strcmp(__FUNCTION__, "foo") == 0); + //assert(strcmp(__PRETTY_FUNCTION__, "void foo") == 0); } From b36ef7a164c519bbf16f32a5e531b61a61fda762 Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Tue, 16 Dec 2025 19:14:00 +0000 Subject: [PATCH 164/440] test __PRETTY_FUNC__ --- dmd/cparse.d | 40 ++++++++++++++++++++++++++++++++++++++- tests/dmd/runnable/func.c | 10 +++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/dmd/cparse.d b/dmd/cparse.d index 20551c2229..e9495dbb9b 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -37,6 +37,7 @@ final class CParser(AST) : Parser!AST bool addFuncName; /// add declaration of __func__ to function symbol table bool refFuncName; // declaration of __FUNCTION__ + bool pretFuncName; // declaration for __PRETTY_FUNCTION__ bool importBuiltins; /// seen use of C compiler builtins, so import __importc_builtins; private @@ -756,6 +757,9 @@ final class CParser(AST) : Parser!AST if (token.ident is Id.FUNCTION) refFuncName = true; // implicitly declare __FUNCTION__ + if (token.ident is Id.PRETTY_FUNCTION) + pretFuncName = true; // implicitly declare __PRETTY_FUNCTION__ + if (token.ident is Id.__func__) { addFuncName = true; // implicitly declare __func__ @@ -2231,6 +2235,7 @@ final class CParser(AST) : Parser!AST /* gets set to true if somebody references __func__ in this function, //ditto for __FUNCTION__ */ addFuncName = false; refFuncName = false; + pretFuncName = false; const locFunc = token.loc; auto body = cparseStatement(ParseStatementFlags.curly); // don't start a new scope; continue with parameter scope @@ -2249,6 +2254,9 @@ final class CParser(AST) : Parser!AST if (refFuncName) stmts.push(createFuncName(locFunc, id.name, Id.FUNCTION)); + if (pretFuncName) + stmts.push(createPrettyFunc(locFunc, fd)); + stmts.push(body); body = new AST.CompoundStatement(locFunc, stmts); @@ -4868,7 +4876,7 @@ final class CParser(AST) : Parser!AST const fn = id.toString(); // function-name auto efn = new AST.StringExp(loc, fn, fn.length, 1, 'c'); auto ifn = new AST.ExpInitializer(loc, efn); - auto lenfn = new AST.IntegerExp(loc, fn.length + 1, AST.Type.tuns32); // +1 for terminating 0 + auto lenfn = new AST.IntegerExp(loc, fn.length + 1, AST.Type.tuns32); // +1 for terminating 0, ditto for __pretty_chars__ auto tfn = new AST.TypeSArray(AST.Type.tchar, lenfn); efn.type = tfn.makeImmutable(); efn.committed = true; @@ -4877,6 +4885,36 @@ final class CParser(AST) : Parser!AST return new AST.ExpStatement(loc, e); } + /* function for C __PRETTY_FUNCTION__ */ + private AST.Statement createPrettyFunc(Loc loc, AST.FuncDeclaration fd) + { + auto tf = fd.type.isTypeFunction(); + auto funcSig = tf.next.toString(); + funcSig ~= " "; + funcSig ~= fd.ident.toString(); + funcSig ~= "("; + + foreach (i, fparam ; tf.parameterList) + { + if (i > 0) + funcSig ~= ", "; + + AST.Type t = tf.parameterList[i].type; + funcSig ~= t.toString(); + } + funcSig ~= ")"; + + auto efn = new AST.StringExp(loc, funcSig); + auto ifn = new AST.ExpInitializer(loc, efn); + auto lenfn = new AST.IntegerExp(loc, funcSig.length + 1, AST.Type.tuns32); // +1 for terminating 0 + auto tfn = new AST.TypeSArray(AST.Type.tchar, lenfn); + efn.type = tfn.makeImmutable(); + efn.committed = true; + auto sfn = new AST.VarDeclaration(loc, tfn, Id.PRETTY_FUNCTION, ifn, STC.gshared | STC.immutable_); + auto e = new AST.DeclarationExp(loc, sfn); + return new AST.ExpStatement(loc, e); + } + /************************ * After encountering an error, scan forward until a right brace or ; is found * or the end of the file. diff --git a/tests/dmd/runnable/func.c b/tests/dmd/runnable/func.c index f20970801f..d0046c8742 100644 --- a/tests/dmd/runnable/func.c +++ b/tests/dmd/runnable/func.c @@ -5,11 +5,19 @@ void foo() { assert(strcmp(__FUNCTION__, "foo") == 0); - //assert(strcmp(__PRETTY_FUNCTION__, "void foo") == 0); + assert(strcmp(__PRETTY_FUNCTION__, "void foo()") == 0); } +int bar(int a, int b) +{ + assert(strcmp(__FUNCTION__, "bar") == 0); + assert(strcmp(__PRETTY_FUNCTION__, "int foo(int, int)") == 0); + return 0; +} + int main() { foo(); + return bar(); } From e9ba9e544b072e9a4330ad581c6e5074a9858cec Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Tue, 16 Dec 2025 19:23:36 +0000 Subject: [PATCH 165/440] fix call --- tests/dmd/runnable/func.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dmd/runnable/func.c b/tests/dmd/runnable/func.c index d0046c8742..f36df1654f 100644 --- a/tests/dmd/runnable/func.c +++ b/tests/dmd/runnable/func.c @@ -19,5 +19,5 @@ int bar(int a, int b) int main() { foo(); - return bar(); + return bar(4, 6); } From db126873e29a57b9683d0690bf71956ce98578c0 Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Tue, 16 Dec 2025 19:35:17 +0000 Subject: [PATCH 166/440] fix ident --- tests/dmd/runnable/func.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dmd/runnable/func.c b/tests/dmd/runnable/func.c index f36df1654f..bb0c078ca3 100644 --- a/tests/dmd/runnable/func.c +++ b/tests/dmd/runnable/func.c @@ -12,7 +12,7 @@ void foo() int bar(int a, int b) { assert(strcmp(__FUNCTION__, "bar") == 0); - assert(strcmp(__PRETTY_FUNCTION__, "int foo(int, int)") == 0); + assert(strcmp(__PRETTY_FUNCTION__, "int bar(int, int)") == 0); return 0; } From 54586d01944fc0c630c2d81534510a8a0a047df5 Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Tue, 16 Dec 2025 21:10:41 +0000 Subject: [PATCH 167/440] bump --- tests/dmd/runnable/func.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/dmd/runnable/func.c b/tests/dmd/runnable/func.c index bb0c078ca3..2bccb3be8d 100644 --- a/tests/dmd/runnable/func.c +++ b/tests/dmd/runnable/func.c @@ -4,6 +4,7 @@ void foo() { + printf("function is %s", __PRETTY_FUNCTION__ ); assert(strcmp(__FUNCTION__, "foo") == 0); assert(strcmp(__PRETTY_FUNCTION__, "void foo()") == 0); From 570adf95d47a109f800778d28b4e86075ea9ee61 Mon Sep 17 00:00:00 2001 From: Dennis Date: Wed, 17 Dec 2025 02:11:33 +0100 Subject: [PATCH 168/440] Fix dlang/dmd!22243 - dip1000 should explain why scope was inferred from parameter (dlang/dmd!22246) --- dmd/escape.d | 54 ++++++++++++++++---------- tests/dmd/fail_compilation/diag23295.d | 6 +-- tests/dmd/fail_compilation/fail24208.d | 2 +- tests/dmd/fail_compilation/retscope.d | 27 +++++++------ tests/dmd/fail_compilation/retscope2.d | 1 + tests/dmd/fail_compilation/retscope6.d | 10 ++--- tests/dmd/fail_compilation/test17422.d | 3 +- tests/dmd/fail_compilation/test17423.d | 5 ++- tests/dmd/fail_compilation/test18282.d | 13 ++++--- tests/dmd/fail_compilation/test19097.d | 23 +++++++---- tests/dmd/fail_compilation/test20245.d | 25 +++++++----- tests/dmd/fail_compilation/test23073.d | 2 +- tests/dmd/fail_compilation/test23982.d | 2 +- 13 files changed, 103 insertions(+), 70 deletions(-) diff --git a/dmd/escape.d b/dmd/escape.d index 392e927501..50490df4a6 100644 --- a/dmd/escape.d +++ b/dmd/escape.d @@ -28,6 +28,7 @@ import dmd.expressionsem : calledFunctionType, expToVariable; import dmd.func; import dmd.funcsem; import dmd.globals : FeatureState; +import dmd.hdrgen : toErrMsg; import dmd.id; import dmd.identifier; import dmd.init; @@ -47,14 +48,14 @@ private: package(dmd) struct EscapeState { // Maps `sequenceNumber` of a `VarDeclaration` to an object that contains the - // reason it failed to infer `scope` + // reason it inferred or didn't infer `scope` for supplemental error messages // https://issues.dlang.org/show_bug.cgi?id=23295 - private __gshared RootObject[int] scopeInferFailure; + private __gshared RootObject[int] scopeInferReason; /// Called by `initDMD` / `deinitializeDMD` to reset global state static void reset() { - scopeInferFailure = null; + scopeInferReason = null; } } @@ -283,33 +284,38 @@ bool checkAssocArrayLiteralEscape(ref Scope sc, AssocArrayLiteralExp ae, bool ga } /** - * A `scope` variable was assigned to non-scope parameter `v`. - * If applicable, print why the parameter was not inferred `scope`. + * An error occured due to `v` either being or not being `scope`. + * If applicable, print why the `v` was inferred that way. * * Params: * printFunc = error/deprecation print function to use * v = parameter that was not inferred * recursionLimit = recursion limit for printing the reason + * positive = true for telling why v is scope, false for telling why v is not scope */ private -void printScopeFailure(E)(E printFunc, VarDeclaration v, int recursionLimit) +void printScopeReason(E)(E printFunc, VarDeclaration v, int recursionLimit, bool positive) { recursionLimit--; if (recursionLimit < 0 || !v) return; - if (RootObject* o = v.sequenceNumber in EscapeState.scopeInferFailure) + if (RootObject* o = v.sequenceNumber in EscapeState.scopeInferReason) { switch ((*o).dyncast()) { case DYNCAST.expression: Expression e = cast(Expression) *o; - printFunc(e.loc, "which is not `scope` because of `%s`", e.toChars()); + if (positive) + printFunc(e.loc, "`%s` inferred `scope` because of `%s`", v.toErrMsg(), e.toErrMsg()); + else + printFunc(e.loc, "`%s` is not `scope` because of `%s`", v.toErrMsg(), e.toErrMsg()); break; case DYNCAST.dsymbol: VarDeclaration v1 = cast(VarDeclaration) *o; - printFunc(v1.loc, "which is assigned to non-scope parameter `%s`", v1.toChars()); - printScopeFailure(printFunc, v1, recursionLimit); + assert(!positive); + printFunc(v1.loc, "`%s` is assigned to non-scope parameter `%s`", v.toErrMsg(), v1.toErrMsg()); + printScopeReason(printFunc, v1, recursionLimit, positive); break; default: assert(0); @@ -373,7 +379,8 @@ bool checkParamArgumentEscape(ref Scope sc, FuncDeclaration fdc, Identifier parI sc.setUnsafeDIP1000(gag, arg.loc, msg, v, parId ? parId : fdc, fdc)) { result = true; - printScopeFailure(previewSupplementalFunc(sc.isDeprecated(), sc.useDIP1000), vPar, 10); + printScopeReason(previewSupplementalFunc(sc.isDeprecated(), sc.useDIP1000), vPar, 10, false); + printScopeReason(previewSupplementalFunc(sc.isDeprecated(), sc.useDIP1000), v, 10, true); } } @@ -715,7 +722,7 @@ bool checkAssignEscape(ref Scope sc, Expression e, bool gag, bool byRef) if (vaIsFirstRef && v.isParameter() && v.isReturn()) { // va=v, where v is `return scope` - if (inferScope(va)) + if (inferScope(va, e)) return; } @@ -749,7 +756,7 @@ bool checkAssignEscape(ref Scope sc, Expression e, bool gag, bool byRef) // v = scope, va should be scope as well const vaWasScope = va && va.isScope(); - if (inferScope(va)) + if (inferScope(va, e)) { // In case of `scope local = returnScopeParam`, do not infer return scope for `x` if (!vaWasScope && v.isReturn() && !va.isReturn()) @@ -823,7 +830,7 @@ bool checkAssignEscape(ref Scope sc, Expression e, bool gag, bool byRef) if (p != sc.func) return; - if (inferScope(va)) + if (inferScope(va, e)) { if (v.isReturn() && !va.isReturn()) va.storage_class |= STC.return_ | STC.returninferred; @@ -1211,8 +1218,12 @@ private bool checkReturnEscapeImpl(ref Scope sc, Expression e, bool refs, bool g else { // https://issues.dlang.org/show_bug.cgi?id=17029 - result |= sc.setUnsafeDIP1000(gag, e.loc, "returning scope variable `%s`", v); - return; + if (sc.setUnsafeDIP1000(gag, e.loc, "returning scope variable `%s`", v)) + { + printScopeReason(previewSupplementalFunc(sc.isDeprecated(), sc.useDIP1000), v, 10, true); + result = true; + return; + } } } } @@ -1386,16 +1397,19 @@ private bool checkReturnEscapeImpl(ref Scope sc, Expression e, bool refs, bool g * * Params: * va = variable to infer scope for + * reason = optional Expression that causes `va` to infer scope, used for supplemental error message * Returns: `true` if succesful or already `scope` */ private -bool inferScope(VarDeclaration va) +bool inferScope(VarDeclaration va, RootObject reason) { if (!va) return false; if (!va.isDataseg() && va.maybeScope && !va.isScope()) { //printf("inferring scope for %s\n", va.toChars()); + if (reason) + EscapeState.scopeInferReason[va.sequenceNumber] = reason; va.maybeScope = false; va.storage_class |= STC.scope_ | STC.scopeinferred; return true; @@ -2011,7 +2025,7 @@ private void doNotInferScope(VarDeclaration v, RootObject o) { v.maybeScope = false; if (o && v.isParameter()) - EscapeState.scopeInferFailure[v.sequenceNumber] = o; + EscapeState.scopeInferReason[v.sequenceNumber] = o; } } @@ -2049,7 +2063,7 @@ void finishScopeParamInference(FuncDeclaration funcdecl, ref TypeFunction f) foreach (u, p; f.parameterList) { auto v = (*funcdecl.parameters)[u]; - if (!v.isScope() && v.type.hasPointers() && inferScope(v)) + if (!v.isScope() && v.type.hasPointers() && inferScope(v, null)) { //printf("Inferring scope for %s\n", v.toChars()); p.storageClass |= STC.scope_ | STC.scopeinferred; @@ -2059,7 +2073,7 @@ void finishScopeParamInference(FuncDeclaration funcdecl, ref TypeFunction f) if (funcdecl.vthis) { - inferScope(funcdecl.vthis); + inferScope(funcdecl.vthis, null); f.isScopeQual = funcdecl.vthis.isScope(); f.isScopeInferred = !!(funcdecl.vthis.storage_class & STC.scopeinferred); } diff --git a/tests/dmd/fail_compilation/diag23295.d b/tests/dmd/fail_compilation/diag23295.d index 4f996b6dae..f40da8a781 100644 --- a/tests/dmd/fail_compilation/diag23295.d +++ b/tests/dmd/fail_compilation/diag23295.d @@ -3,10 +3,10 @@ REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/diag23295.d(21): Error: assigning scope variable `x` to non-scope parameter `y` calling `foo` is not allowed in a `@safe` function -fail_compilation/diag23295.d(32): which is assigned to non-scope parameter `z` -fail_compilation/diag23295.d(34): which is not `scope` because of `f = & z` +fail_compilation/diag23295.d(32): `y` is assigned to non-scope parameter `z` +fail_compilation/diag23295.d(34): `z` is not `scope` because of `f = & z` fail_compilation/diag23295.d(24): Error: assigning scope variable `ex` to non-scope parameter `e` calling `thro` is not allowed in a `@safe` function -fail_compilation/diag23295.d(39): which is not `scope` because of `throw e` +fail_compilation/diag23295.d(39): `e` is not `scope` because of `throw e` --- */ diff --git a/tests/dmd/fail_compilation/fail24208.d b/tests/dmd/fail_compilation/fail24208.d index c39676a285..a196d710f1 100644 --- a/tests/dmd/fail_compilation/fail24208.d +++ b/tests/dmd/fail_compilation/fail24208.d @@ -3,7 +3,7 @@ REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fail24208.d(19): Error: assigning reference to local variable `n` to non-scope parameter `p` calling `escape` is not allowed in a `@safe` function -fail_compilation/fail24208.d(15): which is not `scope` because of `escaped = p` +fail_compilation/fail24208.d(15): `p` is not `scope` because of `escaped = p` --- +/ void test() @safe diff --git a/tests/dmd/fail_compilation/retscope.d b/tests/dmd/fail_compilation/retscope.d index 39fa8ab57a..489a7c1a97 100644 --- a/tests/dmd/fail_compilation/retscope.d +++ b/tests/dmd/fail_compilation/retscope.d @@ -181,7 +181,8 @@ void foo11() @safe /* TEST_OUTPUT: --- -fail_compilation/retscope.d(197): Error: returning scope variable `e` is not allowed in a `@safe` function +fail_compilation/retscope.d(198): Error: returning scope variable `e` is not allowed in a `@safe` function +fail_compilation/retscope.d(197): `e` inferred `scope` because of `e.DG = d` --- */ @@ -201,7 +202,7 @@ void* escapeDg1(scope void* d) @safe /* TEST_OUTPUT: --- -fail_compilation/retscope.d(212): Error: assigning scope variable `p` to non-scope `e.e` is not allowed in a `@safe` function +fail_compilation/retscope.d(213): Error: assigning scope variable `p` to non-scope `e.e` is not allowed in a `@safe` function --- */ struct Escaper3 { void* e; } @@ -218,7 +219,7 @@ void* escape3 (scope void* p) @safe { /* TEST_OUTPUT: --- -fail_compilation/retscope.d(229): Error: scope parameter `ptr` may not be returned +fail_compilation/retscope.d(230): Error: scope parameter `ptr` may not be returned --- */ @@ -234,10 +235,10 @@ void* funretscope(scope dg_t ptr) @safe /* TEST_OUTPUT: --- -fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `() => & x` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` -fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `() => & x` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `() => & x` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `() => & x` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` +fail_compilation/retscope.d(250): Error: cannot implicitly convert expression `() => & x` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` +fail_compilation/retscope.d(250): Error: cannot implicitly convert expression `() => & x` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` --- */ @@ -254,7 +255,7 @@ void escape4() @safe /* TEST_OUTPUT: --- -fail_compilation/retscope.d(266): Error: taking address of `scope` variable `p` with pointers is not allowed in a `@safe` function +fail_compilation/retscope.d(267): Error: taking address of `scope` variable `p` with pointers is not allowed in a `@safe` function --- */ @@ -271,7 +272,7 @@ void escape5() @safe /* TEST_OUTPUT: --- -fail_compilation/retscope.d(286): Error: escaping a reference to local variable `b` by returning `foo6(& b)` is not allowed in a `@safe` function +fail_compilation/retscope.d(287): Error: escaping a reference to local variable `b` by returning `foo6(& b)` is not allowed in a `@safe` function --- */ @@ -302,9 +303,9 @@ struct S7 /* TEST_OUTPUT: --- -fail_compilation/retscope.d(315): Error: scope parameter `p` may not be returned -fail_compilation/retscope.d(316): Error: returning `p[]` escapes a reference to parameter `p` -fail_compilation/retscope.d(319): Error: scope parameter `p` may not be returned +fail_compilation/retscope.d(316): Error: scope parameter `p` may not be returned +fail_compilation/retscope.d(317): Error: returning `p[]` escapes a reference to parameter `p` +fail_compilation/retscope.d(320): Error: scope parameter `p` may not be returned --- */ @@ -323,7 +324,7 @@ ref int[3] asStatic2( scope int[] p) @safe { return p[0 .. 3]; } /* TEST_OUTPUT: --- -fail_compilation/retscope.d(335): Error: assigning reference to local variable `i` to non-scope `f` is not allowed in a `@safe` function +fail_compilation/retscope.d(336): Error: assigning reference to local variable `i` to non-scope `f` is not allowed in a `@safe` function --- */ @@ -347,7 +348,7 @@ int* bar10( scope int** ptr ) @safe /* TEST_OUTPUT: --- -fail_compilation/retscope.d(358): Error: taking address of `scope` variable `aa` with pointers is not allowed in a `@safe` function +fail_compilation/retscope.d(359): Error: taking address of `scope` variable `aa` with pointers is not allowed in a `@safe` function --- */ @@ -420,6 +421,7 @@ class Foo13 TEST_OUTPUT: --- fail_compilation/retscope.d(1205): Error: scope variable `f14` calling non-scope member function `Foo14.foo()` is not allowed in a `@safe` function +fail_compilation/retscope.d(1204): `f14` inferred `scope` because of `f14.v = & i` --- */ @@ -680,6 +682,7 @@ TEST_OUTPUT: --- fail_compilation/retscope.d(1907): Error: assigning scope variable `x` to `ref` variable `this` with longer lifetime is not allowed in a `@safe` function fail_compilation/retscope.d(1913): Error: returning scope variable `x` is not allowed in a `@safe` function +fail_compilation/retscope.d(1912): `x` inferred `scope` because of `x = __param_0` --- */ #line 1900 diff --git a/tests/dmd/fail_compilation/retscope2.d b/tests/dmd/fail_compilation/retscope2.d index 18c7fe64cc..ff8b875ba2 100644 --- a/tests/dmd/fail_compilation/retscope2.d +++ b/tests/dmd/fail_compilation/retscope2.d @@ -230,6 +230,7 @@ void test17428() @safe TEST_OUTPUT: --- fail_compilation/retscope2.d(1107): Error: returning scope variable `dg` is not allowed in a `@safe` function +fail_compilation/retscope2.d(1106): `dg` inferred `scope` because of `dg = &s.foo` --- */ diff --git a/tests/dmd/fail_compilation/retscope6.d b/tests/dmd/fail_compilation/retscope6.d index e3b734f03d..72231be291 100644 --- a/tests/dmd/fail_compilation/retscope6.d +++ b/tests/dmd/fail_compilation/retscope6.d @@ -78,11 +78,11 @@ void foo() @safe fail_compilation/retscope6.d(8016): Error: assigning address of variable `i` to `p` with longer lifetime is not allowed in a `@safe` function fail_compilation/retscope6.d(8031): Error: assigning reference to local variable `i` to non-scope parameter `p` calling `betty` is not allowed in a `@safe` function fail_compilation/retscope6.d(8031): Error: assigning reference to local variable `j` to non-scope parameter `q` calling `betty` is not allowed in a `@safe` function -fail_compilation/retscope6.d(8023): which is not `scope` because of `p = q` +fail_compilation/retscope6.d(8023): `q` is not `scope` because of `p = q` fail_compilation/retscope6.d(8048): Error: assigning reference to local variable `i` to non-scope parameter `p` calling `archie` is not allowed in a `@safe` function -fail_compilation/retscope6.d(8039): which is not `scope` because of `r = p` +fail_compilation/retscope6.d(8039): `p` is not `scope` because of `r = p` fail_compilation/retscope6.d(8048): Error: assigning reference to local variable `j` to non-scope parameter `q` calling `archie` is not allowed in a `@safe` function -fail_compilation/retscope6.d(8038): which is not `scope` because of `p = q` +fail_compilation/retscope6.d(8038): `q` is not `scope` because of `p = q` --- */ @@ -261,7 +261,7 @@ void escape_throw_20150() @safe /* TEST_OUTPUT: --- fail_compilation/retscope6.d(14019): Error: assigning scope variable `scopePtr` to non-scope parameter `x` calling `noInfer23021` is not allowed in a `@safe` function -fail_compilation/retscope6.d(14009): which is not `scope` because of `*escapeHole = cast(const(int)*)x` +fail_compilation/retscope6.d(14009): `x` is not `scope` because of `*escapeHole = cast(const(int)*)x` fail_compilation/retscope6.d(14022): Error: returning scope variable `scopePtr` is not allowed in a `@safe` function --- */ @@ -300,7 +300,7 @@ ref int escape23021() @safe /* TEST_OUTPUT: --- fail_compilation/retscope6.d(14050): Error: assigning scope variable `z` to non-scope parameter `y` calling `f23294` is not allowed in a `@safe` function -fail_compilation/retscope6.d(14044): which is not `scope` because of `x = y` +fail_compilation/retscope6.d(14044): `y` is not `scope` because of `x = y` --- */ diff --git a/tests/dmd/fail_compilation/test17422.d b/tests/dmd/fail_compilation/test17422.d index e5577ddb54..68d2f49054 100644 --- a/tests/dmd/fail_compilation/test17422.d +++ b/tests/dmd/fail_compilation/test17422.d @@ -2,7 +2,8 @@ REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- -fail_compilation/test17422.d(23): Error: returning scope variable `p` is not allowed in a `@safe` function +fail_compilation/test17422.d(24): Error: returning scope variable `p` is not allowed in a `@safe` function +fail_compilation/test17422.d(23): `p` inferred `scope` because of `p = rc.get()` --- */ struct RC diff --git a/tests/dmd/fail_compilation/test17423.d b/tests/dmd/fail_compilation/test17423.d index 785bbe7fc4..0d88931029 100644 --- a/tests/dmd/fail_compilation/test17423.d +++ b/tests/dmd/fail_compilation/test17423.d @@ -1,8 +1,9 @@ /* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- -fail_compilation/test17423.d(27): Error: assigning reference to local `this` to non-scope parameter `dlg` calling `opApply` is not allowed in a `@safe` function -fail_compilation/test17423.d(16): which is not `scope` because of `this.myDlg = dlg` +fail_compilation/test17423.d(28): Error: assigning reference to local `this` to non-scope parameter `dlg` calling `opApply` is not allowed in a `@safe` function +fail_compilation/test17423.d(17): `dlg` is not `scope` because of `this.myDlg = dlg` +fail_compilation/test17423.d(28): `this` inferred `scope` because of `int(int _) => 0` --- */ diff --git a/tests/dmd/fail_compilation/test18282.d b/tests/dmd/fail_compilation/test18282.d index f06b1bfc60..d6786d5a32 100644 --- a/tests/dmd/fail_compilation/test18282.d +++ b/tests/dmd/fail_compilation/test18282.d @@ -1,13 +1,14 @@ /* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- -fail_compilation/test18282.d(25): Error: returning scope variable `aa` is not allowed in a `@safe` function -fail_compilation/test18282.d(34): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function +fail_compilation/test18282.d(26): Error: returning scope variable `aa` is not allowed in a `@safe` function fail_compilation/test18282.d(35): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function -fail_compilation/test18282.d(36): Error: returning scope variable `staa` is not allowed in a `@safe` function -fail_compilation/test18282.d(44): Error: escaping a reference to local variable `i` by copying `S2000(& i)` into allocated memory is not allowed in a `@safe` function -fail_compilation/test18282.d(53): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function -fail_compilation/test18282.d(53): Error: escaping a reference to local variable `c` by copying `& c` into allocated memory is not allowed in a `@safe` function +fail_compilation/test18282.d(36): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function +fail_compilation/test18282.d(37): Error: returning scope variable `staa` is not allowed in a `@safe` function +fail_compilation/test18282.d(34): `staa` inferred `scope` because of `staa = [& i]` +fail_compilation/test18282.d(45): Error: escaping a reference to local variable `i` by copying `S2000(& i)` into allocated memory is not allowed in a `@safe` function +fail_compilation/test18282.d(54): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function +fail_compilation/test18282.d(54): Error: escaping a reference to local variable `c` by copying `& c` into allocated memory is not allowed in a `@safe` function --- */ diff --git a/tests/dmd/fail_compilation/test19097.d b/tests/dmd/fail_compilation/test19097.d index f415dd9207..9acea99966 100644 --- a/tests/dmd/fail_compilation/test19097.d +++ b/tests/dmd/fail_compilation/test19097.d @@ -1,14 +1,21 @@ /* REQUIRED_ARGS: -preview=dip1000 * TEST_OUTPUT: --- -fail_compilation/test19097.d(44): Error: returning scope variable `s` is not allowed in a `@safe` function -fail_compilation/test19097.d(48): Error: returning scope variable `s1` is not allowed in a `@safe` function -fail_compilation/test19097.d(77): Error: assigning scope variable `z` to `ref` variable `refPtr` with longer lifetime is not allowed in a `@safe` function -fail_compilation/test19097.d(108): Error: returning scope variable `s4` is not allowed in a `@safe` function -fail_compilation/test19097.d(126): Error: returning scope variable `s5c` is not allowed in a `@safe` function -fail_compilation/test19097.d(130): Error: returning scope variable `s5m` is not allowed in a `@safe` function -fail_compilation/test19097.d(147): Error: returning scope variable `s6c` is not allowed in a `@safe` function -fail_compilation/test19097.d(151): Error: returning scope variable `s6m` is not allowed in a `@safe` function +fail_compilation/test19097.d(51): Error: returning scope variable `s` is not allowed in a `@safe` function +fail_compilation/test19097.d(50): `s` inferred `scope` because of `s = & i` +fail_compilation/test19097.d(55): Error: returning scope variable `s1` is not allowed in a `@safe` function +fail_compilation/test19097.d(54): `s1` inferred `scope` because of `s1 = & i` +fail_compilation/test19097.d(84): Error: assigning scope variable `z` to `ref` variable `refPtr` with longer lifetime is not allowed in a `@safe` function +fail_compilation/test19097.d(115): Error: returning scope variable `s4` is not allowed in a `@safe` function +fail_compilation/test19097.d(114): `s4` inferred `scope` because of `s4 = & x` +fail_compilation/test19097.d(133): Error: returning scope variable `s5c` is not allowed in a `@safe` function +fail_compilation/test19097.d(132): `s5c` inferred `scope` because of `s5c = i` +fail_compilation/test19097.d(137): Error: returning scope variable `s5m` is not allowed in a `@safe` function +fail_compilation/test19097.d(136): `s5m` inferred `scope` because of `s5m = i` +fail_compilation/test19097.d(154): Error: returning scope variable `s6c` is not allowed in a `@safe` function +fail_compilation/test19097.d(153): `s6c` inferred `scope` because of `s6c = i` +fail_compilation/test19097.d(158): Error: returning scope variable `s6m` is not allowed in a `@safe` function +fail_compilation/test19097.d(157): `s6m` inferred `scope` because of `s6m = i` --- */ diff --git a/tests/dmd/fail_compilation/test20245.d b/tests/dmd/fail_compilation/test20245.d index 5484786d64..a37e596f9b 100644 --- a/tests/dmd/fail_compilation/test20245.d +++ b/tests/dmd/fail_compilation/test20245.d @@ -2,16 +2,21 @@ REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- -fail_compilation/test20245.d(21): Error: assigning reference to local variable `x` to non-scope parameter `ptr` calling `escape` is not allowed in a `@safe` function -fail_compilation/test20245.d(22): Error: escaping a reference to parameter `x` by copying `&x` into allocated memory is not allowed in a `@safe` function -fail_compilation/test20245.d(23): Error: returning scope variable `a` is not allowed in a `@safe` function -fail_compilation/test20245.d(27): Error: taking address of `scope` variable `x` with pointers is not allowed in a `@safe` function -fail_compilation/test20245.d(33): Error: assigning reference to local variable `x` to non-scope parameter `ptr` calling `escape` is not allowed in a `@safe` function -fail_compilation/test20245.d(34): Error: escaping a reference to parameter `x` by copying `&x` into allocated memory is not allowed in a `@safe` function -fail_compilation/test20245.d(50): Error: assigning reference to local variable `price` to non-scope `this.minPrice` is not allowed in a `@safe` function -fail_compilation/test20245.d(69): Error: reference to local variable `this.content[]` calling non-scope member function `Exception.this()` is not allowed in a `@safe` function -fail_compilation/test20245.d(89): Error: assigning reference to local variable `this` to non-scope parameter `content` calling `listUp` is not allowed in a `@safe` function -fail_compilation/test20245.d(82): which is not `scope` because of `charPtr = content` +fail_compilation/test20245.d(26): Error: assigning reference to local variable `x` to non-scope parameter `ptr` calling `escape` is not allowed in a `@safe` function +fail_compilation/test20245.d(25): `x` inferred `scope` because of `a = &x` +fail_compilation/test20245.d(27): Error: escaping a reference to parameter `x` by copying `&x` into allocated memory is not allowed in a `@safe` function +fail_compilation/test20245.d(28): Error: returning scope variable `a` is not allowed in a `@safe` function +fail_compilation/test20245.d(25): `a` inferred `scope` because of `a = &x` +fail_compilation/test20245.d(32): Error: taking address of `scope` variable `x` with pointers is not allowed in a `@safe` function +fail_compilation/test20245.d(38): Error: assigning reference to local variable `x` to non-scope parameter `ptr` calling `escape` is not allowed in a `@safe` function +fail_compilation/test20245.d(37): `x` inferred `scope` because of `a = &x` +fail_compilation/test20245.d(39): Error: escaping a reference to parameter `x` by copying `&x` into allocated memory is not allowed in a `@safe` function +fail_compilation/test20245.d(55): Error: assigning reference to local variable `price` to non-scope `this.minPrice` is not allowed in a `@safe` function +fail_compilation/test20245.d(74): Error: reference to local variable `this.content[]` calling non-scope member function `Exception.this()` is not allowed in a `@safe` function +fail_compilation/test20245.d(74): `this` inferred `scope` because of `this.content[]` +fail_compilation/test20245.d(94): Error: assigning reference to local variable `this` to non-scope parameter `content` calling `listUp` is not allowed in a `@safe` function +fail_compilation/test20245.d(87): `content` is not `scope` because of `charPtr = content` +fail_compilation/test20245.d(94): `this` inferred `scope` because of `&this.content` --- */ diff --git a/tests/dmd/fail_compilation/test23073.d b/tests/dmd/fail_compilation/test23073.d index e47569aacb..14a9ac11ad 100644 --- a/tests/dmd/fail_compilation/test23073.d +++ b/tests/dmd/fail_compilation/test23073.d @@ -3,7 +3,7 @@ REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test23073.d(28): Error: assigning scope variable `c` to non-scope parameter `c` calling `assignNext` is not allowed in a `@safe` function -fail_compilation/test23073.d(22): which is not `scope` because of `c.next = c` +fail_compilation/test23073.d(22): `c` is not `scope` because of `c.next = c` --- */ diff --git a/tests/dmd/fail_compilation/test23982.d b/tests/dmd/fail_compilation/test23982.d index dac70fd9fb..2388febce1 100644 --- a/tests/dmd/fail_compilation/test23982.d +++ b/tests/dmd/fail_compilation/test23982.d @@ -3,7 +3,7 @@ REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test23982.d(35): Error: assigning scope variable `a` to non-scope parameter `a` calling `foo2` is not allowed in a `@safe` function -fail_compilation/test23982.d(26): which is not `scope` because of `b = a` +fail_compilation/test23982.d(26): `a` is not `scope` because of `b = a` --- */ // https://issues.dlang.org/show_bug.cgi?id=23982 From a037ce6c7514ca61acc45445da3c133bf1956a0e Mon Sep 17 00:00:00 2001 From: Iskaban10 <136351084+Iskaban10@users.noreply.github.com> Date: Wed, 17 Dec 2025 14:01:29 +0530 Subject: [PATCH 169/440] fix dlang/dmd!21399 - error message for multiple character constants (dlang/dmd!22242) --- dmd/lexer.d | 8 +++++++- tests/dmd/fail_compilation/fail4544.d | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dmd/lexer.d b/dmd/lexer.d index 36a4c83b7e..fe8b0c8158 100644 --- a/dmd/lexer.d +++ b/dmd/lexer.d @@ -2235,7 +2235,13 @@ class Lexer if (*p == '\'') { - error("character constant has multiple characters"); + const(char)* s = p - 1; + while(*s != '\'') + { + s--; + } + s++; + error("character constant has multiple characters - did you mean \"%.*s\"?", cast(int) (p - s), s); p++; } else diff --git a/tests/dmd/fail_compilation/fail4544.d b/tests/dmd/fail_compilation/fail4544.d index 1cb0292cc8..4a99565a47 100644 --- a/tests/dmd/fail_compilation/fail4544.d +++ b/tests/dmd/fail_compilation/fail4544.d @@ -1,11 +1,11 @@ /* TEST_OUTPUT: --- -fail_compilation/fail4544.d(15): Error: character constant has multiple characters +fail_compilation/fail4544.d(15): Error: character constant has multiple characters - did you mean "asd"? fail_compilation/fail4544.d(16): Error: `0x` isn't a valid integer literal, use `0x0` instead fail_compilation/fail4544.d(16): Error: variable name expected after type `int`, not `0` fail_compilation/fail4544.d(17): Error: unterminated character constant -fail_compilation/fail4544.d(18): Error: character constant has multiple characters +fail_compilation/fail4544.d(18): Error: character constant has multiple characters - did you mean "asdasdsa"? --- */ From 8318e5dcb7a4d08d6d8c8abd5c68cc4c09844c1d Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Wed, 17 Dec 2025 11:02:47 +0000 Subject: [PATCH 170/440] investigate ubuntu later --- tests/dmd/runnable/func.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/dmd/runnable/func.c b/tests/dmd/runnable/func.c index 2bccb3be8d..bb0c078ca3 100644 --- a/tests/dmd/runnable/func.c +++ b/tests/dmd/runnable/func.c @@ -4,7 +4,6 @@ void foo() { - printf("function is %s", __PRETTY_FUNCTION__ ); assert(strcmp(__FUNCTION__, "foo") == 0); assert(strcmp(__PRETTY_FUNCTION__, "void foo()") == 0); From 673a0b217ddac9211ee524fcafcb9139fd61729e Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Thu, 18 Dec 2025 01:15:50 +0200 Subject: [PATCH 171/440] Eliminate the use of nextOf inside funcdeclaration (dlang/dmd!22250) --- dmd/func.d | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dmd/func.d b/dmd/func.d index 62a2f6f6d5..69be50e917 100644 --- a/dmd/func.d +++ b/dmd/func.d @@ -332,8 +332,13 @@ extern (C++) class FuncDeclaration : Declaration /* The type given for "infer the return type" is a TypeFunction with * NULL for the return type. */ - if (type && type.nextOf() is null) - this.inferRetType = true; + if (type) + { + if (auto tf = type.isTypeFunction()) + this.inferRetType = tf.next is null; + else + assert(0); // unreachable + } } static FuncDeclaration create(Loc loc, Loc endloc, Identifier id, StorageClass storage_class, Type type, bool noreturn = false) From e010c137279590ca50b25739afcf78c549f978d9 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Thu, 18 Dec 2025 01:19:38 +0200 Subject: [PATCH 172/440] Move `Type.isScalar` to `typesem` (dlang/dmd!22252) --- dmd/cxxfrontend.d | 6 ++++++ dmd/expression.d | 12 +++++++++++- dmd/frontend.h | 5 ----- dmd/mtype.d | 25 ------------------------- dmd/mtype.h | 6 +----- dmd/typesem.d | 13 +++++++++++++ 6 files changed, 31 insertions(+), 36 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index ec5932af13..c9b90bcef0 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -1035,6 +1035,12 @@ bool isFloating(Type type) return dmd.typesem.isFloating(type); } +bool isScalar(Type type) +{ + import dmd.typesem; + return dmd.typesem.isScalar(type); +} + bool isReal(Type type) { import dmd.typesem; diff --git a/dmd/expression.d b/dmd/expression.d index a566e1fab4..3a6a042f0f 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -499,6 +499,16 @@ extern (C++) abstract class Expression : ASTNode } } +// Approximate Non-semantic version of the `Type.isScalar` function in `typesem` +bool _isRoughlyScalar(Type _this) +{ + if (auto tb = _this.isTypeBasic()) + return (tb.flags & TFlags.integral | TFlags.floating) != 0; + else if (_this.ty == Tenum || _this.ty == Tpointer) // the enum is possibly scalar + return true; + return false; +} + /*********************************************************** * A compile-time known integer value */ @@ -516,7 +526,7 @@ extern (C++) final class IntegerExp : Expression * Weirdly, the isScalar() includes floats - see enumsem.enumMemberSemantic() for the * base type. This is possibly a bug. */ - assert(type.isScalar() || type.ty == Terror); + assert(_isRoughlyScalar(type) || type.ty == Terror); this.type = type; this.value = normalize(type.toBasetype().ty, value); diff --git a/dmd/frontend.h b/dmd/frontend.h index 57929b46ab..dfcc1485b9 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2070,7 +2070,6 @@ class Type : public ASTNode static void deinitialize(); void modToBuffer(OutBuffer& buf) const; char* modToChars() const; - virtual bool isScalar(); virtual bool isScopeClass(); bool isConst() const; bool isImmutable() const; @@ -4374,7 +4373,6 @@ class TypeBasic final : public Type uint32_t flags; const char* kind() const override; TypeBasic* syntaxCopy() override; - bool isScalar() override; TypeBasic* isTypeBasic() override; void accept(Visitor* v) override; }; @@ -4425,7 +4423,6 @@ class TypeEnum final : public Type EnumDeclaration* sym; const char* kind() const override; TypeEnum* syntaxCopy() override; - bool isScalar() override; Type* nextOf() override; void accept(Visitor* v) override; }; @@ -4622,7 +4619,6 @@ class TypePointer final : public TypeNext static TypePointer* create(Type* t); const char* kind() const override; TypePointer* syntaxCopy() override; - bool isScalar() override; void accept(Visitor* v) override; }; @@ -4733,7 +4729,6 @@ class TypeVector final : public Type static TypeVector* create(Type* basetype); const char* kind() const override; TypeVector* syntaxCopy() override; - bool isScalar() override; TypeBasic* elementType(); void accept(Visitor* v) override; }; diff --git a/dmd/mtype.d b/dmd/mtype.d index 2e8eae1580..5022992495 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -640,11 +640,6 @@ extern (C++) abstract class Type : ASTNode return buf.extractChars(); } - bool isScalar() - { - return false; - } - bool isScopeClass() { return false; @@ -1514,11 +1509,6 @@ extern (C++) final class TypeBasic : Type return this; } - override bool isScalar() - { - return (flags & (TFlags.integral | TFlags.floating)) != 0; - } - // For eliminating dynamic_cast override TypeBasic isTypeBasic() { @@ -1562,11 +1552,6 @@ extern (C++) final class TypeVector : Type return new TypeVector(basetype.syntaxCopy()); } - override bool isScalar() - { - return basetype.nextOf().isScalar(); - } - TypeBasic elementType() { assert(basetype.ty == Tsarray); @@ -1751,11 +1736,6 @@ extern (C++) final class TypePointer : TypeNext return result; } - override bool isScalar() - { - return true; - } - override void accept(Visitor v) { v.visit(this); @@ -2360,11 +2340,6 @@ extern (C++) final class TypeEnum : Type return this; } - override bool isScalar() - { - return this.memType().isScalar(); - } - override Type nextOf() { return this.memType().nextOf(); diff --git a/dmd/mtype.h b/dmd/mtype.h index 24dccd5292..856c86fc27 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -228,7 +228,6 @@ class Type : public ASTNode void modToBuffer(OutBuffer& buf) const; char *modToChars() const; - virtual bool isScalar(); virtual bool isScopeClass(); bool isConst() const { return (mod & MODconst) != 0; } @@ -309,7 +308,6 @@ class TypeBasic final : public Type const char *kind() override; TypeBasic *syntaxCopy() override; - bool isScalar() override; // For eliminating dynamic_cast TypeBasic *isTypeBasic() override; @@ -324,7 +322,6 @@ class TypeVector final : public Type static TypeVector *create(Type *basetype); const char *kind() override; TypeVector *syntaxCopy() override; - bool isScalar() override; TypeBasic *elementType(); void accept(Visitor *v) override { v->visit(this); } @@ -378,7 +375,6 @@ class TypePointer final : public TypeNext static TypePointer *create(Type *t); const char *kind() override; TypePointer *syntaxCopy() override; - bool isScalar() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -632,7 +628,6 @@ class TypeEnum final : public Type const char *kind() override; TypeEnum *syntaxCopy() override; - bool isScalar() override; Type *nextOf() override; void accept(Visitor *v) override { v->visit(this); } @@ -768,6 +763,7 @@ namespace dmd unsigned char deduceWild(Type* type, Type* t, bool isRef); bool isIntegral(Type* type); bool isFloating(Type* type); + bool isScalar(Type* type); bool isReal(Type* type); bool isImaginary(Type* type); bool isComplex(Type* type); diff --git a/dmd/typesem.d b/dmd/typesem.d index 0c592077d0..13885d88b6 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -143,6 +143,19 @@ bool needsNested(Type _this) return false; } +bool isScalar(Type _this) +{ + if (auto tb = _this.isTypeBasic()) + return (tb.flags & (TFlags.integral | TFlags.floating)) != 0; + else if (auto tv = _this.isTypeVector()) + return tv.basetype.nextOf().isScalar(); + else if (auto te = _this.isTypeEnum()) + return te.memType().isScalar(); + else if (_this.isTypePointer()) + return true; + return false; +} + bool isUnsigned(Type _this) { if (auto tb = _this.isTypeBasic()) From 6812a2dcc34af99339db09e98370e4bbddc71a81 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Thu, 18 Dec 2025 01:20:59 +0200 Subject: [PATCH 173/440] Replace the call to nextOf with .next as it is a TypeNext (dlang/dmd!22253) --- dmd/mtype.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmd/mtype.d b/dmd/mtype.d index 5022992495..8840648af6 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1556,7 +1556,7 @@ extern (C++) final class TypeVector : Type { assert(basetype.ty == Tsarray); TypeSArray t = cast(TypeSArray)basetype; - TypeBasic tb = t.nextOf().isTypeBasic(); + TypeBasic tb = t.next.isTypeBasic(); assert(tb); return tb; } From 1b20739f8adf7dc1e71e070564bc505dca80d3bf Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Thu, 18 Dec 2025 01:22:01 +0200 Subject: [PATCH 174/440] Move fixTo (dlang/dmd!22255) --- dmd/mtype.d | 136 -------------------------------------------------- dmd/typesem.d | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+), 136 deletions(-) diff --git a/dmd/mtype.d b/dmd/mtype.d index 8840648af6..6bf0d1f18d 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -711,142 +711,6 @@ extern (C++) abstract class Type : ASTNode return t; } - /********************************** - * For our new type 'this', which is type-constructed from t, - * fill in the cto, ito, sto, scto, wto shortcuts. - */ - extern (D) final void fixTo(Type t) - { - // If fixing this: immutable(T*) by t: immutable(T)*, - // cache t to this.xto won't break transitivity. - Type mto = null; - Type tn = nextOf(); - if (!tn || ty != Tsarray && tn.mod == t.nextOf().mod) - { - switch (t.mod) - { - case 0: - mto = t; - break; - - case MODFlags.const_: - getMcache(); - mcache.cto = t; - break; - - case MODFlags.wild: - getMcache(); - mcache.wto = t; - break; - - case MODFlags.wildconst: - getMcache(); - mcache.wcto = t; - break; - - case MODFlags.shared_: - getMcache(); - mcache.sto = t; - break; - - case MODFlags.shared_ | MODFlags.const_: - getMcache(); - mcache.scto = t; - break; - - case MODFlags.shared_ | MODFlags.wild: - getMcache(); - mcache.swto = t; - break; - - case MODFlags.shared_ | MODFlags.wildconst: - getMcache(); - mcache.swcto = t; - break; - - case MODFlags.immutable_: - getMcache(); - mcache.ito = t; - break; - - default: - break; - } - } - assert(mod != t.mod); - - if (mod) - { - getMcache(); - t.getMcache(); - } - switch (mod) - { - case 0: - break; - - case MODFlags.const_: - mcache.cto = mto; - t.mcache.cto = this; - break; - - case MODFlags.wild: - mcache.wto = mto; - t.mcache.wto = this; - break; - - case MODFlags.wildconst: - mcache.wcto = mto; - t.mcache.wcto = this; - break; - - case MODFlags.shared_: - mcache.sto = mto; - t.mcache.sto = this; - break; - - case MODFlags.shared_ | MODFlags.const_: - mcache.scto = mto; - t.mcache.scto = this; - break; - - case MODFlags.shared_ | MODFlags.wild: - mcache.swto = mto; - t.mcache.swto = this; - break; - - case MODFlags.shared_ | MODFlags.wildconst: - mcache.swcto = mto; - t.mcache.swcto = this; - break; - - case MODFlags.immutable_: - t.mcache.ito = this; - if (t.mcache.cto) - t.mcache.cto.getMcache().ito = this; - if (t.mcache.sto) - t.mcache.sto.getMcache().ito = this; - if (t.mcache.scto) - t.mcache.scto.getMcache().ito = this; - if (t.mcache.wto) - t.mcache.wto.getMcache().ito = this; - if (t.mcache.wcto) - t.mcache.wcto.getMcache().ito = this; - if (t.mcache.swto) - t.mcache.swto.getMcache().ito = this; - if (t.mcache.swcto) - t.mcache.swcto.getMcache().ito = this; - break; - - default: - assert(0); - } - - check(); - t.check(); - //printf("fixTo: %s, %s\n", toChars(), t.toChars()); - } - /*************************** * Look for bugs in constructing types. */ diff --git a/dmd/typesem.d b/dmd/typesem.d index 13885d88b6..f8d785ddcb 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -67,6 +67,142 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; +/********************************** + * For our new type '_this', which is type-constructed from t, + * fill in the cto, ito, sto, scto, wto shortcuts. + */ +void fixTo(Type _this, Type t) +{ + // If fixing this: immutable(T*) by t: immutable(T)*, + // cache t to this.xto won't break transitivity. + Type mto = null; + Type tn = _this.nextOf(); + if (!tn || _this.ty != Tsarray && tn.mod == t.nextOf().mod) + { + switch (t.mod) + { + case 0: + mto = t; + break; + + case MODFlags.const_: + _this.getMcache(); + _this.mcache.cto = t; + break; + + case MODFlags.wild: + _this.getMcache(); + _this.mcache.wto = t; + break; + + case MODFlags.wildconst: + _this.getMcache(); + _this.mcache.wcto = t; + break; + + case MODFlags.shared_: + _this.getMcache(); + _this.mcache.sto = t; + break; + + case MODFlags.shared_ | MODFlags.const_: + _this.getMcache(); + _this.mcache.scto = t; + break; + + case MODFlags.shared_ | MODFlags.wild: + _this.getMcache(); + _this.mcache.swto = t; + break; + + case MODFlags.shared_ | MODFlags.wildconst: + _this.getMcache(); + _this.mcache.swcto = t; + break; + + case MODFlags.immutable_: + _this.getMcache(); + _this.mcache.ito = t; + break; + + default: + break; + } + } + assert(_this.mod != t.mod); + + if (_this.mod) + { + _this.getMcache(); + t.getMcache(); + } + switch (_this.mod) + { + case 0: + break; + + case MODFlags.const_: + _this.mcache.cto = mto; + t.mcache.cto = _this; + break; + + case MODFlags.wild: + _this.mcache.wto = mto; + t.mcache.wto = _this; + break; + + case MODFlags.wildconst: + _this.mcache.wcto = mto; + t.mcache.wcto = _this; + break; + + case MODFlags.shared_: + _this.mcache.sto = mto; + t.mcache.sto = _this; + break; + + case MODFlags.shared_ | MODFlags.const_: + _this.mcache.scto = mto; + t.mcache.scto = _this; + break; + + case MODFlags.shared_ | MODFlags.wild: + _this.mcache.swto = mto; + t.mcache.swto = _this; + break; + + case MODFlags.shared_ | MODFlags.wildconst: + _this.mcache.swcto = mto; + t.mcache.swcto = _this; + break; + + case MODFlags.immutable_: + t.mcache.ito = _this; + if (t.mcache.cto) + t.mcache.cto.getMcache().ito = _this; + if (t.mcache.sto) + t.mcache.sto.getMcache().ito = _this; + if (t.mcache.scto) + t.mcache.scto.getMcache().ito = _this; + if (t.mcache.wto) + t.mcache.wto.getMcache().ito = _this; + if (t.mcache.wcto) + t.mcache.wcto.getMcache().ito = _this; + if (t.mcache.swto) + t.mcache.swto.getMcache().ito = _this; + if (t.mcache.swcto) + t.mcache.swcto.getMcache().ito = _this; + break; + + default: + assert(0); + } + + _this.check(); + t.check(); + //printf("fixTo: %s, %s\n", toChars(), t.toChars()); +} + void transitive(TypeNext _this) { // Invoke transitivity of type attributes From 551566eef5ff2cdf878d8f9feb8027810efed54c Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Thu, 18 Dec 2025 02:26:55 +0200 Subject: [PATCH 175/440] Move `Type.check` to `typesem` (dlang/dmd!22256) --- dmd/mtype.d | 193 ------------------------------------------------- dmd/typesem.d | 194 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 193 insertions(+), 194 deletions(-) diff --git a/dmd/mtype.d b/dmd/mtype.d index 6bf0d1f18d..1c00e6a3ae 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -711,199 +711,6 @@ extern (C++) abstract class Type : ASTNode return t; } - /*************************** - * Look for bugs in constructing types. - */ - extern (D) final void check() - { - if (mcache) - with (mcache) - switch (mod) - { - case 0: - if (cto) - assert(cto.mod == MODFlags.const_); - if (ito) - assert(ito.mod == MODFlags.immutable_); - if (sto) - assert(sto.mod == MODFlags.shared_); - if (scto) - assert(scto.mod == (MODFlags.shared_ | MODFlags.const_)); - if (wto) - assert(wto.mod == MODFlags.wild); - if (wcto) - assert(wcto.mod == MODFlags.wildconst); - if (swto) - assert(swto.mod == (MODFlags.shared_ | MODFlags.wild)); - if (swcto) - assert(swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); - break; - - case MODFlags.const_: - if (cto) - assert(cto.mod == 0); - if (ito) - assert(ito.mod == MODFlags.immutable_); - if (sto) - assert(sto.mod == MODFlags.shared_); - if (scto) - assert(scto.mod == (MODFlags.shared_ | MODFlags.const_)); - if (wto) - assert(wto.mod == MODFlags.wild); - if (wcto) - assert(wcto.mod == MODFlags.wildconst); - if (swto) - assert(swto.mod == (MODFlags.shared_ | MODFlags.wild)); - if (swcto) - assert(swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); - break; - - case MODFlags.wild: - if (cto) - assert(cto.mod == MODFlags.const_); - if (ito) - assert(ito.mod == MODFlags.immutable_); - if (sto) - assert(sto.mod == MODFlags.shared_); - if (scto) - assert(scto.mod == (MODFlags.shared_ | MODFlags.const_)); - if (wto) - assert(wto.mod == 0); - if (wcto) - assert(wcto.mod == MODFlags.wildconst); - if (swto) - assert(swto.mod == (MODFlags.shared_ | MODFlags.wild)); - if (swcto) - assert(swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); - break; - - case MODFlags.wildconst: - assert(!cto || cto.mod == MODFlags.const_); - assert(!ito || ito.mod == MODFlags.immutable_); - assert(!sto || sto.mod == MODFlags.shared_); - assert(!scto || scto.mod == (MODFlags.shared_ | MODFlags.const_)); - assert(!wto || wto.mod == MODFlags.wild); - assert(!wcto || wcto.mod == 0); - assert(!swto || swto.mod == (MODFlags.shared_ | MODFlags.wild)); - assert(!swcto || swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); - break; - - case MODFlags.shared_: - if (cto) - assert(cto.mod == MODFlags.const_); - if (ito) - assert(ito.mod == MODFlags.immutable_); - if (sto) - assert(sto.mod == 0); - if (scto) - assert(scto.mod == (MODFlags.shared_ | MODFlags.const_)); - if (wto) - assert(wto.mod == MODFlags.wild); - if (wcto) - assert(wcto.mod == MODFlags.wildconst); - if (swto) - assert(swto.mod == (MODFlags.shared_ | MODFlags.wild)); - if (swcto) - assert(swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); - break; - - case MODFlags.shared_ | MODFlags.const_: - if (cto) - assert(cto.mod == MODFlags.const_); - if (ito) - assert(ito.mod == MODFlags.immutable_); - if (sto) - assert(sto.mod == MODFlags.shared_); - if (scto) - assert(scto.mod == 0); - if (wto) - assert(wto.mod == MODFlags.wild); - if (wcto) - assert(wcto.mod == MODFlags.wildconst); - if (swto) - assert(swto.mod == (MODFlags.shared_ | MODFlags.wild)); - if (swcto) - assert(swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); - break; - - case MODFlags.shared_ | MODFlags.wild: - if (cto) - assert(cto.mod == MODFlags.const_); - if (ito) - assert(ito.mod == MODFlags.immutable_); - if (sto) - assert(sto.mod == MODFlags.shared_); - if (scto) - assert(scto.mod == (MODFlags.shared_ | MODFlags.const_)); - if (wto) - assert(wto.mod == MODFlags.wild); - if (wcto) - assert(wcto.mod == MODFlags.wildconst); - if (swto) - assert(swto.mod == 0); - if (swcto) - assert(swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); - break; - - case MODFlags.shared_ | MODFlags.wildconst: - assert(!cto || cto.mod == MODFlags.const_); - assert(!ito || ito.mod == MODFlags.immutable_); - assert(!sto || sto.mod == MODFlags.shared_); - assert(!scto || scto.mod == (MODFlags.shared_ | MODFlags.const_)); - assert(!wto || wto.mod == MODFlags.wild); - assert(!wcto || wcto.mod == MODFlags.wildconst); - assert(!swto || swto.mod == (MODFlags.shared_ | MODFlags.wild)); - assert(!swcto || swcto.mod == 0); - break; - - case MODFlags.immutable_: - if (cto) - assert(cto.mod == MODFlags.const_); - if (ito) - assert(ito.mod == 0); - if (sto) - assert(sto.mod == MODFlags.shared_); - if (scto) - assert(scto.mod == (MODFlags.shared_ | MODFlags.const_)); - if (wto) - assert(wto.mod == MODFlags.wild); - if (wcto) - assert(wcto.mod == MODFlags.wildconst); - if (swto) - assert(swto.mod == (MODFlags.shared_ | MODFlags.wild)); - if (swcto) - assert(swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); - break; - - default: - assert(0); - } - - Type tn = nextOf(); - if (tn && ty != Tfunction && tn.ty != Tfunction && ty != Tenum) - { - // Verify transitivity - switch (mod) - { - case 0: - case MODFlags.const_: - case MODFlags.wild: - case MODFlags.wildconst: - case MODFlags.shared_: - case MODFlags.shared_ | MODFlags.const_: - case MODFlags.shared_ | MODFlags.wild: - case MODFlags.shared_ | MODFlags.wildconst: - case MODFlags.immutable_: - assert(tn.mod == MODFlags.immutable_ || (tn.mod & mod) == mod); - break; - - default: - assert(0); - } - tn.check(); - } - } - /************************************* * Apply STCxxxx bits to existing type. * Use *before* semantic analysis is run. diff --git a/dmd/typesem.d b/dmd/typesem.d index f8d785ddcb..1dbeefe792 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -67,6 +67,199 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; +/*************************** + * Look for bugs in constructing types. + */ +void check(Type _this) +{ + if (_this.mcache) + with (_this.mcache) + switch (_this.mod) + { + case 0: + if (cto) + assert(cto.mod == MODFlags.const_); + if (ito) + assert(ito.mod == MODFlags.immutable_); + if (sto) + assert(sto.mod == MODFlags.shared_); + if (scto) + assert(scto.mod == (MODFlags.shared_ | MODFlags.const_)); + if (wto) + assert(wto.mod == MODFlags.wild); + if (wcto) + assert(wcto.mod == MODFlags.wildconst); + if (swto) + assert(swto.mod == (MODFlags.shared_ | MODFlags.wild)); + if (swcto) + assert(swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); + break; + + case MODFlags.const_: + if (cto) + assert(cto.mod == 0); + if (ito) + assert(ito.mod == MODFlags.immutable_); + if (sto) + assert(sto.mod == MODFlags.shared_); + if (scto) + assert(scto.mod == (MODFlags.shared_ | MODFlags.const_)); + if (wto) + assert(wto.mod == MODFlags.wild); + if (wcto) + assert(wcto.mod == MODFlags.wildconst); + if (swto) + assert(swto.mod == (MODFlags.shared_ | MODFlags.wild)); + if (swcto) + assert(swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); + break; + + case MODFlags.wild: + if (cto) + assert(cto.mod == MODFlags.const_); + if (ito) + assert(ito.mod == MODFlags.immutable_); + if (sto) + assert(sto.mod == MODFlags.shared_); + if (scto) + assert(scto.mod == (MODFlags.shared_ | MODFlags.const_)); + if (wto) + assert(wto.mod == 0); + if (wcto) + assert(wcto.mod == MODFlags.wildconst); + if (swto) + assert(swto.mod == (MODFlags.shared_ | MODFlags.wild)); + if (swcto) + assert(swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); + break; + + case MODFlags.wildconst: + assert(!cto || cto.mod == MODFlags.const_); + assert(!ito || ito.mod == MODFlags.immutable_); + assert(!sto || sto.mod == MODFlags.shared_); + assert(!scto || scto.mod == (MODFlags.shared_ | MODFlags.const_)); + assert(!wto || wto.mod == MODFlags.wild); + assert(!wcto || wcto.mod == 0); + assert(!swto || swto.mod == (MODFlags.shared_ | MODFlags.wild)); + assert(!swcto || swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); + break; + + case MODFlags.shared_: + if (cto) + assert(cto.mod == MODFlags.const_); + if (ito) + assert(ito.mod == MODFlags.immutable_); + if (sto) + assert(sto.mod == 0); + if (scto) + assert(scto.mod == (MODFlags.shared_ | MODFlags.const_)); + if (wto) + assert(wto.mod == MODFlags.wild); + if (wcto) + assert(wcto.mod == MODFlags.wildconst); + if (swto) + assert(swto.mod == (MODFlags.shared_ | MODFlags.wild)); + if (swcto) + assert(swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); + break; + + case MODFlags.shared_ | MODFlags.const_: + if (cto) + assert(cto.mod == MODFlags.const_); + if (ito) + assert(ito.mod == MODFlags.immutable_); + if (sto) + assert(sto.mod == MODFlags.shared_); + if (scto) + assert(scto.mod == 0); + if (wto) + assert(wto.mod == MODFlags.wild); + if (wcto) + assert(wcto.mod == MODFlags.wildconst); + if (swto) + assert(swto.mod == (MODFlags.shared_ | MODFlags.wild)); + if (swcto) + assert(swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); + break; + + case MODFlags.shared_ | MODFlags.wild: + if (cto) + assert(cto.mod == MODFlags.const_); + if (ito) + assert(ito.mod == MODFlags.immutable_); + if (sto) + assert(sto.mod == MODFlags.shared_); + if (scto) + assert(scto.mod == (MODFlags.shared_ | MODFlags.const_)); + if (wto) + assert(wto.mod == MODFlags.wild); + if (wcto) + assert(wcto.mod == MODFlags.wildconst); + if (swto) + assert(swto.mod == 0); + if (swcto) + assert(swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); + break; + + case MODFlags.shared_ | MODFlags.wildconst: + assert(!cto || cto.mod == MODFlags.const_); + assert(!ito || ito.mod == MODFlags.immutable_); + assert(!sto || sto.mod == MODFlags.shared_); + assert(!scto || scto.mod == (MODFlags.shared_ | MODFlags.const_)); + assert(!wto || wto.mod == MODFlags.wild); + assert(!wcto || wcto.mod == MODFlags.wildconst); + assert(!swto || swto.mod == (MODFlags.shared_ | MODFlags.wild)); + assert(!swcto || swcto.mod == 0); + break; + + case MODFlags.immutable_: + if (cto) + assert(cto.mod == MODFlags.const_); + if (ito) + assert(ito.mod == 0); + if (sto) + assert(sto.mod == MODFlags.shared_); + if (scto) + assert(scto.mod == (MODFlags.shared_ | MODFlags.const_)); + if (wto) + assert(wto.mod == MODFlags.wild); + if (wcto) + assert(wcto.mod == MODFlags.wildconst); + if (swto) + assert(swto.mod == (MODFlags.shared_ | MODFlags.wild)); + if (swcto) + assert(swcto.mod == (MODFlags.shared_ | MODFlags.wildconst)); + break; + + default: + assert(0); + } + + Type tn = _this.nextOf(); + if (tn && _this.ty != Tfunction && tn.ty != Tfunction && _this.ty != Tenum) + { + // Verify transitivity + switch (_this.mod) + { + case 0: + case MODFlags.const_: + case MODFlags.wild: + case MODFlags.wildconst: + case MODFlags.shared_: + case MODFlags.shared_ | MODFlags.const_: + case MODFlags.shared_ | MODFlags.wild: + case MODFlags.shared_ | MODFlags.wildconst: + case MODFlags.immutable_: + assert(tn.mod == MODFlags.immutable_ || (tn.mod & _this.mod) == _this.mod); + break; + + default: + assert(0); + } + tn.check(); + } +} + /********************************** * For our new type '_this', which is type-constructed from t, * fill in the cto, ito, sto, scto, wto shortcuts. @@ -197,7 +390,6 @@ void fixTo(Type _this, Type t) default: assert(0); } - _this.check(); t.check(); //printf("fixTo: %s, %s\n", toChars(), t.toChars()); From ad30054c71d2b57b78a9fc307e19ff0615f62784 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Thu, 18 Dec 2025 00:27:26 -0800 Subject: [PATCH 176/440] push SymOffExp error message upstream (dlang/dmd!22237) --- dmd/expression.d | 9 +-------- dmd/optimize.d | 15 ++++++++++++++- tests/dmd/fail_compilation/fail50.d | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/dmd/expression.d b/dmd/expression.d index 3a6a042f0f..c9cf0501c5 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -1776,14 +1776,7 @@ extern (C++) final class SymOffExp : SymbolExp { if (auto v = var.isVarDeclaration()) { - // FIXME: This error report will never be handled anyone. - // It should be done before the SymOffExp construction. - if (v.needThis()) - { - auto t = v.isThis(); - assert(t); - .error(loc, "taking the address of non-static variable `%s` requires an instance of `%s`", v.toChars(), t.toChars()); - } + assert(!v.needThis()); // make sure the error message is no longer necessary hasOverloads = false; } super(loc, EXP.symbolOffset, var, hasOverloads); diff --git a/dmd/optimize.d b/dmd/optimize.d index 88a947f6b0..5f89c4b70d 100644 --- a/dmd/optimize.d +++ b/dmd/optimize.d @@ -459,7 +459,20 @@ Expression optimize(Expression e, int result, bool keepLvalue = false) { if (!ve.var.isReference() && !ve.var.isImportedSymbol()) { - ret = new SymOffExp(e.loc, ve.var, 0, ve.hasOverloads); + bool hasOverloads = ve.hasOverloads; + if (auto v = ve.var.isVarDeclaration()) + { + if (v.needThis()) + { + auto t = v.isThis(); + assert(t); + .error(e.loc, "taking the address of non-static variable `%s` requires an instance of `%s`", v.toChars(), t.toChars()); + ret = ErrorExp.get(); + return; + } + hasOverloads = false; + } + ret = new SymOffExp(e.loc, ve.var, 0, hasOverloads); ret.type = e.type; return; } diff --git a/tests/dmd/fail_compilation/fail50.d b/tests/dmd/fail_compilation/fail50.d index c6aa178bda..ebdac471c3 100644 --- a/tests/dmd/fail_compilation/fail50.d +++ b/tests/dmd/fail_compilation/fail50.d @@ -2,10 +2,10 @@ TEST_OUTPUT: --- fail_compilation/fail50.d(12): Error: taking the address of non-static variable `a` requires an instance of `Marko` -fail_compilation/fail50.d(12): Error: variable `a` cannot be read at compile time --- */ + struct Marko { int a; From 5feb454095e27e85753a1288c520d00e456f3a17 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Thu, 18 Dec 2025 01:17:26 -0800 Subject: [PATCH 177/440] move hasValidType() out of Expression (dlang/dmd!22257) --- dmd/expression.d | 75 -------------------------------------- dmd/expression.h | 7 ---- dmd/expressionsem.d | 89 ++++++++++++++++++++++++++++++++++++++++++++- dmd/frontend.h | 7 ---- 4 files changed, 88 insertions(+), 90 deletions(-) diff --git a/dmd/expression.d b/dmd/expression.d index c9cf0501c5..1f18802a8c 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -293,19 +293,6 @@ extern (C++) abstract class Expression : ASTNode return a; } - /**************************************** - * Check that the expression has a valid type. - * If not, generates an error "... has no type". - * Returns: - * true if the expression has a valid type. - * Note: - * When this function returns false, `checkValue()` should also return true. - */ - bool hasValidType() - { - return true; - } - /****************************** * If this is a reference, dereference it. */ @@ -1564,12 +1551,6 @@ extern (C++) final class TypeExp : Expression return new TypeExp(loc, type.syntaxCopy()); } - override bool hasValidType() - { - error(loc, "type `%s` is not an expression", toChars()); - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -1602,27 +1583,6 @@ extern (C++) final class ScopeExp : Expression return new ScopeExp(loc, sds.syntaxCopy(null)); } - override bool hasValidType() - { - if (sds.isPackage()) - { - error(loc, "%s `%s` has no type", sds.kind(), sds.toChars()); - return false; - } - auto ti = sds.isTemplateInstance(); - if (!ti) - return true; - //assert(ti.needsTypeInference(sc)); - if (ti.tempdecl && - ti.semantictiargsdone && - ti.semanticRun == PASS.initial) - { - error(loc, "partial %s `%s` has no type", sds.kind(), toChars()); - return false; - } - return true; - } - override void accept(Visitor v) { v.visit(this); @@ -1645,12 +1605,6 @@ extern (C++) final class TemplateExp : Expression this.fd = fd; } - override bool hasValidType() - { - error(loc, "%s `%s` has no type", td.kind(), toChars()); - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -1874,16 +1828,6 @@ extern (C++) final class FuncExp : Expression return new FuncExp(loc, fd); } - override bool hasValidType() - { - if (td) - { - error(loc, "template lambda has no type"); - return false; - } - return true; - } - override void accept(Visitor v) { v.visit(this); @@ -2274,12 +2218,6 @@ extern (C++) final class DotTemplateExp : UnaExp this.td = td; } - override bool hasValidType() - { - error(loc, "%s `%s` has no type", td.kind(), toChars()); - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -2334,19 +2272,6 @@ extern (C++) final class DotTemplateInstanceExp : UnaExp return new DotTemplateInstanceExp(loc, e1.syntaxCopy(), ti.name, TemplateInstance.arraySyntaxCopy(ti.tiargs)); } - override bool hasValidType() - { - // Same logic as ScopeExp.hasValidType() - if (ti.tempdecl && - ti.semantictiargsdone && - ti.semanticRun == PASS.initial) - { - error(loc, "partial %s `%s` has no type", ti.kind(), toChars()); - return false; - } - return true; - } - override void accept(Visitor v) { v.visit(this); diff --git a/dmd/expression.h b/dmd/expression.h index 35aa35dbde..eddcdb0fdc 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -106,7 +106,6 @@ class Expression : public ASTNode const char* toChars() const final override; - virtual bool hasValidType(); Expression *addressOf(); Expression *deref(); @@ -451,7 +450,6 @@ class TypeExp final : public Expression { public: TypeExp *syntaxCopy() override; - bool hasValidType() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -461,7 +459,6 @@ class ScopeExp final : public Expression ScopeDsymbol *sds; ScopeExp *syntaxCopy() override; - bool hasValidType() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -471,7 +468,6 @@ class TemplateExp final : public Expression TemplateDeclaration *td; FuncDeclaration *fd; - bool hasValidType() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -565,7 +561,6 @@ class FuncExp final : public Expression TOK tok; FuncExp *syntaxCopy() override; - bool hasValidType() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -707,7 +702,6 @@ class DotTemplateExp final : public UnaExp public: TemplateDeclaration *td; - bool hasValidType() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -726,7 +720,6 @@ class DotTemplateInstanceExp final : public UnaExp TemplateInstance *ti; DotTemplateInstanceExp *syntaxCopy() override; - bool hasValidType() override; void accept(Visitor *v) override { v->visit(this); } }; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 869ead7722..086388d003 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -535,11 +535,98 @@ Optional!bool toBool(Expression _this) case EXP.slice: return _this.isSliceExp().e1.toBool(); case EXP.comma: return _this.isCommaExp().e2.toBool(); // Statically evaluate this expression to a `bool` if possible - // Returns: an optional thath either contains the value or is empty + // Returns: an optional that either contains the value or is empty default: return typeof(return)(); } } +/**************************************** + * Check that the expression `e` has a valid type. + * If not, generates an error "... has no type". + * Params: + * e = Expression to check + * Returns: + * true if the expression has a valid type. + * Note: + * When this function returns false, `checkValue()` should also return true. + */ +bool hasValidType(Expression e) +{ + static bool visitTypeExp(TypeExp e) + { + error(e.loc, "type `%s` is not an expression", e.toChars()); + return false; + } + + static bool visitScopeExp(ScopeExp e) + { + if (e.sds.isPackage()) + { + error(e.loc, "%s `%s` has no type", e.sds.kind(), e.sds.toChars()); + return false; + } + auto ti = e.sds.isTemplateInstance(); + if (!ti) + return true; + //assert(ti.needsTypeInference(sc)); + if (ti.tempdecl && + ti.semantictiargsdone && + ti.semanticRun == PASS.initial) + { + error(e.loc, "partial %s `%s` has no type", e.sds.kind(), e.toChars()); + return false; + } + return true; + } + + static bool visitTemplateExp(TemplateExp e) + { + error(e.loc, "%s `%s` has no type", e.td.kind(), e.toChars()); + return false; + } + + static bool visitFuncExp(FuncExp e) + { + if (e.td) + { + error(e.loc, "template lambda has no type"); + return false; + } + return true; + } + + static bool visitDotTemplateExp(DotTemplateExp e) + { + error(e.loc, "%s `%s` has no type", e.td.kind(), e.toChars()); + return false; + } + + static bool visitDotTemplateInstanceExp(DotTemplateInstanceExp e) + { + // Same logic as ScopeExp.hasValidType() + if (e.ti.tempdecl && + e.ti.semantictiargsdone && + e.ti.semanticRun == PASS.initial) + { + error(e.loc, "partial %s `%s` has no type", e.ti.kind(), e.toChars()); + return false; + } + return true; + } + + switch (e.op) + { + case EXP.type: return visitTypeExp(e.isTypeExp()); + case EXP.scope_: return visitScopeExp(e.isScopeExp()); + case EXP.template_: return visitTemplateExp(e.isTemplateExp()); + case EXP.function_: return visitFuncExp(e.isFuncExp()); + case EXP.dotTemplateDeclaration: return visitDotTemplateExp(e.isDotTemplateExp()); + case EXP.dotTemplateInstance: return visitDotTemplateInstanceExp(e.isDotTemplateInstanceExp()); + + default: return true; + } +} + void fillTupleExpExps(TupleExp _this, TupleDeclaration tup) { _this.exps.reserve(tup.objects.length); diff --git a/dmd/frontend.h b/dmd/frontend.h index dfcc1485b9..d854bb9be6 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2315,7 +2315,6 @@ class Expression : public ASTNode virtual Expression* syntaxCopy(); DYNCAST dyncast() const final override; const char* toChars() const final override; - virtual bool hasValidType(); Expression* deref(); int32_t isConst(); virtual bool hasCode(); @@ -2809,7 +2808,6 @@ class DotTemplateExp final : public UnaExp { public: TemplateDeclaration* td; - bool hasValidType() override; void accept(Visitor* v) override; }; @@ -2818,7 +2816,6 @@ class DotTemplateInstanceExp final : public UnaExp public: TemplateInstance* ti; DotTemplateInstanceExp* syntaxCopy() override; - bool hasValidType() override; void accept(Visitor* v) override; }; @@ -3104,7 +3101,6 @@ class FuncExp final : public Expression TemplateDeclaration* td; TOK tok; FuncExp* syntaxCopy() override; - bool hasValidType() override; void accept(Visitor* v) override; }; @@ -3405,7 +3401,6 @@ class ScopeExp final : public Expression public: ScopeDsymbol* sds; ScopeExp* syntaxCopy() override; - bool hasValidType() override; void accept(Visitor* v) override; }; @@ -3592,7 +3587,6 @@ class TemplateExp final : public Expression public: TemplateDeclaration* td; FuncDeclaration* fd; - bool hasValidType() override; void accept(Visitor* v) override; }; @@ -3633,7 +3627,6 @@ class TypeExp final : public Expression { public: TypeExp* syntaxCopy() override; - bool hasValidType() override; void accept(Visitor* v) override; }; From c838d6aa439f3de9e06a686b60d07b37dbd875ac Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Thu, 18 Dec 2025 20:56:12 +0000 Subject: [PATCH 178/440] check platform differences --- tests/dmd/runnable/func.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/dmd/runnable/func.c b/tests/dmd/runnable/func.c index bb0c078ca3..74fae4406b 100644 --- a/tests/dmd/runnable/func.c +++ b/tests/dmd/runnable/func.c @@ -5,14 +5,23 @@ void foo() { assert(strcmp(__FUNCTION__, "foo") == 0); + +#ifndef __linux__ assert(strcmp(__PRETTY_FUNCTION__, "void foo()") == 0); +#else + assert(strcmp(__PRETTY_FUNCTION__, "foo") == 0); +#endif } int bar(int a, int b) { assert(strcmp(__FUNCTION__, "bar") == 0); +#ifndef __linux__ assert(strcmp(__PRETTY_FUNCTION__, "int bar(int, int)") == 0); +#else + assert(strcmp(__PRETTY_FUNCTION__, "bar") == 0); +#endif return 0; } From 5a5ec42b02239036984790246ddf7180e71ea767 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Fri, 19 Dec 2025 01:43:33 +0000 Subject: [PATCH 179/440] Implement `-edition=YYYY` semantics (dlang/dmd!22248) Set `Module.edition` in constructor. Make `-edition=YYYYfilename` an error as it does nothing (and also wrongly sets `params.edition`). Allow a larger `-edition` to override a module declaration's edition. `-edition` cannot override ModuleDeclaration edition --- dmd/dmodule.d | 2 +- dmd/mars.d | 2 ++ tests/dmd/fail_compilation/edition_switch.d | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/fail_compilation/edition_switch.d diff --git a/dmd/dmodule.d b/dmd/dmodule.d index dc974bc7c6..e6ee54879d 100644 --- a/dmd/dmodule.d +++ b/dmd/dmodule.d @@ -437,7 +437,7 @@ extern (C++) final class Module : Package if (doHdrGen) hdrfile = setOutfilename(global.params.dihdr.name, global.params.dihdr.dir, arg, hdr_ext); - this.edition = Edition.min; + this.edition = global.params.edition; } extern (D) this(const(char)[] filename, Identifier ident, int doDocComment, int doHdrGen) diff --git a/dmd/mars.d b/dmd/mars.d index 714d2af787..c3897bd4ad 100644 --- a/dmd/mars.d +++ b/dmd/mars.d @@ -908,6 +908,8 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, out Param auto filename = p + 1+7+1+4; files.push(filename); params.editionFiles[filename] = params.edition; + // FIXME: params.edition should not be set when there's a filename + error("`-edition` is not supported with a filename yet"); } } else if (arg == "-fIBT") diff --git a/tests/dmd/fail_compilation/edition_switch.d b/tests/dmd/fail_compilation/edition_switch.d new file mode 100644 index 0000000000..48695f620b --- /dev/null +++ b/tests/dmd/fail_compilation/edition_switch.d @@ -0,0 +1,10 @@ +/* +REQUIRED_ARGS: -edition=2024 +TEST_OUTPUT: +--- +fail_compilation/edition_switch.d(10): Error: usage of identifer `body` as a keyword is obsolete. Use `do` instead. +--- +*/ + +void test() +in { } body { } From dca8c899ec1dfbcea2330ced085cb497b05d7e29 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Thu, 18 Dec 2025 21:32:57 -0800 Subject: [PATCH 180/440] add nothrows to some modules (dlang/dmd!22264) --- dmd/common/bitfields.d | 3 +++ dmd/common/file.d | 1 - dmd/root/bitarray.d | 2 ++ dmd/root/filename.d | 3 ++- dmd/root/hash.d | 3 +++ dmd/root/region.d | 2 ++ dmd/root/rmem.d | 2 ++ dmd/root/string.d | 2 ++ dmd/root/stringtable.d | 2 ++ 9 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dmd/common/bitfields.d b/dmd/common/bitfields.d index 5732f9d385..dd01e8f4fd 100644 --- a/dmd/common/bitfields.d +++ b/dmd/common/bitfields.d @@ -10,6 +10,9 @@ */ module dmd.common.bitfields; +nothrow: +@safe: + //version = Has_Bitfields; // does not work (yet) because hashOf doesn't work on bitfields version(Has_Bitfields) version = Debugger_friendly; // without Has_Bitfields, this uses more space by using S diff --git a/dmd/common/file.d b/dmd/common/file.d index 9fa339a81e..41a7f3307c 100644 --- a/dmd/common/file.d +++ b/dmd/common/file.d @@ -54,7 +54,6 @@ else - nothrow: /** diff --git a/dmd/root/bitarray.d b/dmd/root/bitarray.d index b5adaa8903..5d2c18b75f 100644 --- a/dmd/root/bitarray.d +++ b/dmd/root/bitarray.d @@ -16,6 +16,8 @@ import core.stdc.string; import dmd.root.rmem; +nothrow: + struct BitArray { diff --git a/dmd/root/filename.d b/dmd/root/filename.d index b25392b638..cb08b09476 100644 --- a/dmd/root/filename.d +++ b/dmd/root/filename.d @@ -51,8 +51,9 @@ version (CRuntime_Glibc) extern (C) char* canonicalize_file_name(const char*) nothrow; } -alias Strings = Array!(const(char)*); +nothrow: +alias Strings = Array!(const(char)*); // Check whether character is a directory separator bool isDirSeparator(char c) pure nothrow @nogc @safe diff --git a/dmd/root/hash.d b/dmd/root/hash.d index 40dc2eb197..885238461f 100644 --- a/dmd/root/hash.d +++ b/dmd/root/hash.d @@ -11,6 +11,9 @@ module dmd.root.hash; +nothrow: +@safe: + // MurmurHash2 was written by Austin Appleby, and is placed in the public // domain. The author hereby disclaims copyright to this source code. // https://github.com/aappleby/smhasher/ diff --git a/dmd/root/region.d b/dmd/root/region.d index a8efbca1e6..9d241b8cc6 100644 --- a/dmd/root/region.d +++ b/dmd/root/region.d @@ -18,6 +18,8 @@ import core.stdc.stdlib; import dmd.root.rmem; import dmd.root.array; +nothrow: + /***** * Simple region storage allocator. */ diff --git a/dmd/root/rmem.d b/dmd/root/rmem.d index 32d22d3beb..02906731e6 100644 --- a/dmd/root/rmem.d +++ b/dmd/root/rmem.d @@ -18,6 +18,8 @@ import core.stdc.string; import core.memory : GC; +nothrow: + extern (C++) struct Mem { static char* xstrdup(const(char)* s) nothrow diff --git a/dmd/root/string.d b/dmd/root/string.d index 369a79be66..7ae5128530 100644 --- a/dmd/root/string.d +++ b/dmd/root/string.d @@ -13,6 +13,8 @@ module dmd.root.string; import core.stdc.string; import dmd.root.rmem; +nothrow: + /// Slices a `\0`-terminated C-string, excluding the terminator inout(char)[] toDString (inout(char)* s) pure nothrow @nogc { diff --git a/dmd/root/stringtable.d b/dmd/root/stringtable.d index c7a2c8c56d..1d9e2e078c 100644 --- a/dmd/root/stringtable.d +++ b/dmd/root/stringtable.d @@ -14,6 +14,8 @@ module dmd.root.stringtable; import core.stdc.string; import dmd.root.rmem, dmd.root.hash; +nothrow: + private enum POOL_BITS = 12; private enum POOL_SIZE = (1U << POOL_BITS); From 9c4e065b263be8b2d2111603be46075f77e20a8e Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Thu, 18 Dec 2025 22:57:32 -0800 Subject: [PATCH 181/440] remove parse.d dependency on globals (dlang/dmd!22263) --- dmd/parse.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dmd/parse.d b/dmd/parse.d index e5f9b665a0..846051487b 100644 --- a/dmd/parse.d +++ b/dmd/parse.d @@ -8731,7 +8731,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer error("expression expected, not `%s`", token.toChars()); Lerr: // Anything for e, as long as it's not NULL - e = AST.ErrorExp.get(); + e = new AST.ErrorExp(); nextToken(); break; } @@ -8873,7 +8873,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer { error("identifier expected following `%s.`, not `%s`", t.toChars(), token.toChars()); - return AST.ErrorExp.get(); + return new AST.ErrorExp(); } e = new AST.DotIdExp(loc, new AST.TypeExp(loc, t), token.ident); nextToken(); @@ -8987,7 +8987,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer { error("identifier or new keyword expected following `(...)`."); nextToken(); - return AST.ErrorExp.get(); + return new AST.ErrorExp(); } e = new AST.TypeExp(loc, t); e.parens = true; From 959fbdff680647f07b230060e9e23a307be565ff Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 19 Dec 2025 09:48:11 +0200 Subject: [PATCH 182/440] Move `Type.nextOf` to `typesem` (dlang/dmd!22258) --- dmd/arrayop.d | 2 +- dmd/canthrow.d | 1 + dmd/cparse.d | 2 +- dmd/cxxfrontend.d | 6 ++++++ dmd/escape.d | 2 +- dmd/frontend.h | 3 --- dmd/iasm/gcc.d | 1 + dmd/inline.d | 2 +- dmd/mtype.d | 23 ----------------------- dmd/mtype.h | 4 +--- dmd/safe.d | 2 +- dmd/typesem.d | 17 +++++++++++++++++ 12 files changed, 31 insertions(+), 34 deletions(-) diff --git a/dmd/arrayop.d b/dmd/arrayop.d index c7b3bc7987..b73c18e17f 100644 --- a/dmd/arrayop.d +++ b/dmd/arrayop.d @@ -30,7 +30,7 @@ import dmd.location; import dmd.mtype; import dmd.common.outbuffer; import dmd.tokens; -import dmd.typesem : isAssignable; +import dmd.typesem : isAssignable, nextOf; import dmd.visitor; /********************************************** diff --git a/dmd/canthrow.d b/dmd/canthrow.d index 5828f0ac44..9914b83a7e 100644 --- a/dmd/canthrow.d +++ b/dmd/canthrow.d @@ -21,6 +21,7 @@ import dmd.dsymbolsem : include, toAlias; import dmd.errorsink; import dmd.expression; import dmd.expressionsem : errorSupplementalInferredAttr, isLvalue, calledFunctionType; +import dmd.typesem : nextOf; import dmd.func; import dmd.globals; import dmd.mtype; diff --git a/dmd/cparse.d b/dmd/cparse.d index 9c4645a991..bf4ac65b16 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -27,7 +27,7 @@ import dmd.root.array; import dmd.common.outbuffer; import dmd.root.rmem; import dmd.tokens; -import dmd.typesem : size, makeImmutable; +import dmd.typesem : size, makeImmutable, nextOf; /*********************************************************** */ diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index c9b90bcef0..bb81150cc3 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -1017,6 +1017,12 @@ Type makeSharedWildConst(Type type) return dmd.typesem.makeSharedWildConst(type); } +Type nextOf(Type type) +{ + import dmd.typesem; + return dmd.typesem.nextOf(type); +} + MOD deduceWild(Type type, Type t, bool isRef) { import dmd.typesem; diff --git a/dmd/escape.d b/dmd/escape.d index 50490df4a6..4c9505f9c5 100644 --- a/dmd/escape.d +++ b/dmd/escape.d @@ -38,7 +38,7 @@ import dmd.printast; import dmd.rootobject; import dmd.safe; import dmd.tokens; -import dmd.typesem : hasPointers, parameterStorageClass; +import dmd.typesem : hasPointers, parameterStorageClass, nextOf; import dmd.visitor; import dmd.arraytypes; diff --git a/dmd/frontend.h b/dmd/frontend.h index d854bb9be6..d07c2ee9d0 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2085,7 +2085,6 @@ class Type : public ASTNode Type* toBasetype(); virtual ClassDeclaration* isClassHandle(); virtual int32_t hasWild() const; - virtual Type* nextOf(); Type* baseElemOf(); virtual TypeBasic* isTypeBasic(); TypeFunction* isPtrToFunction(); @@ -4338,7 +4337,6 @@ class TypeNext : public Type public: Type* next; int32_t hasWild() const final override; - Type* nextOf() final override; void accept(Visitor* v) override; }; @@ -4416,7 +4414,6 @@ class TypeEnum final : public Type EnumDeclaration* sym; const char* kind() const override; TypeEnum* syntaxCopy() override; - Type* nextOf() override; void accept(Visitor* v) override; }; diff --git a/dmd/iasm/gcc.d b/dmd/iasm/gcc.d index d30275a095..6f4b85b1ee 100644 --- a/dmd/iasm/gcc.d +++ b/dmd/iasm/gcc.d @@ -30,6 +30,7 @@ import dmd.target; import dmd.tokens; import dmd.statement; import dmd.statementsem; +import dmd.typesem; /*********************************** * Parse and run semantic analysis on a GccAsmStatement. diff --git a/dmd/inline.d b/dmd/inline.d index 273e1b2f58..bd7608cbc6 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -46,7 +46,7 @@ import dmd.opover; import dmd.printast; import dmd.statement; import dmd.tokens; -import dmd.typesem : pointerTo, sarrayOf; +import dmd.typesem : pointerTo, sarrayOf, nextOf; import dmd.visitor; import dmd.visitor.postorder; import dmd.inlinecost; diff --git a/dmd/mtype.d b/dmd/mtype.d index 1c00e6a3ae..c0ac11366a 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -815,14 +815,6 @@ extern (C++) abstract class Type : ASTNode return mod & MODFlags.wild; } - /************************************* - * If this is a type of something, return that something. - */ - Type nextOf() - { - return null; - } - /************************************* * If this is a type of static array, return its base element type. */ @@ -1013,16 +1005,6 @@ extern (C++) abstract class TypeNext : Type return mod & MODFlags.wild || (next && next.hasWild()); } - /******************************* - * For TypeFunction, nextOf() can return NULL if the function return - * type is meant to be inferred, and semantic() hasn't yet been run - * on the function. After semantic(), it must no longer be NULL. - */ - override final Type nextOf() @safe - { - return next; - } - override void accept(Visitor v) { v.visit(this); @@ -2011,11 +1993,6 @@ extern (C++) final class TypeEnum : Type return this; } - override Type nextOf() - { - return this.memType().nextOf(); - } - override void accept(Visitor v) { v.visit(this); diff --git a/dmd/mtype.h b/dmd/mtype.h index 856c86fc27..6cd7350340 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -245,7 +245,6 @@ class Type : public ASTNode virtual ClassDeclaration *isClassHandle(); virtual int hasWild() const; - virtual Type *nextOf(); Type *baseElemOf(); TypeFunction *toTypeFunction(); @@ -296,7 +295,6 @@ class TypeNext : public Type Type *next; int hasWild() const override final; - Type *nextOf() override final; void accept(Visitor *v) override { v->visit(this); } }; @@ -628,7 +626,6 @@ class TypeEnum final : public Type const char *kind() override; TypeEnum *syntaxCopy() override; - Type *nextOf() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -760,6 +757,7 @@ namespace dmd Type *makeWildConst(Type* type); Type *makeSharedWild(Type* type); Type *makeSharedWildConst(Type* type); + Type *nextOf(Type* type); unsigned char deduceWild(Type* type, Type* t, bool isRef); bool isIntegral(Type* type); bool isFloating(Type* type); diff --git a/dmd/safe.d b/dmd/safe.d index 672acb23cd..c65291502c 100644 --- a/dmd/safe.d +++ b/dmd/safe.d @@ -38,7 +38,7 @@ import dmd.root.string : fTuple; import dmd.target; import dmd.targetcompiler; import dmd.tokens; -import dmd.typesem : hasPointers, arrayOf, size, hasUnsafeBitpatterns, hasInvariant, alignment; +import dmd.typesem; /************************************************************* * Check for unsafe access in @safe code: diff --git a/dmd/typesem.d b/dmd/typesem.d index 1dbeefe792..e8b06192c2 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -67,6 +67,23 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; +/************************************* + * If this is a type of something, return that something. + */ +Type nextOf(Type _this) +{ + /******************************* + * For TypeFunction, nextOf() can return NULL if the function return + * type is meant to be inferred, and semantic() hasn't yet been run + * on the function. After semantic(), it must no longer be NULL. + */ + if (auto tn = _this.isTypeNext()) + return tn.next; + else if (auto te = _this.isTypeEnum()) + return te.memType().nextOf(); + return null; +} + /*************************** * Look for bugs in constructing types. */ From 213bfd8fb0580db60afe2a045dfde56176fb4121 Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Fri, 19 Dec 2025 10:33:24 +0000 Subject: [PATCH 183/440] update comment --- dmd/cparse.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmd/cparse.d b/dmd/cparse.d index e9495dbb9b..05432a4e58 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -4885,7 +4885,7 @@ final class CParser(AST) : Parser!AST return new AST.ExpStatement(loc, e); } - /* function for C __PRETTY_FUNCTION__ */ + /* function for C __PRETTY_FUNCTION__ for non-linux systems */ private AST.Statement createPrettyFunc(Loc loc, AST.FuncDeclaration fd) { auto tf = fd.type.isTypeFunction(); From 4be654fead4b97c7286c95879720a79f1bd31aad Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Fri, 19 Dec 2025 04:06:50 -0800 Subject: [PATCH 184/440] add nothrows here and there (dlang/dmd!22265) --- dmd/cli.d | 19 ++++++++----------- dmd/expressionsem.d | 14 +++++++------- dmd/mtype.d | 24 ++++++++++++------------ 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/dmd/cli.d b/dmd/cli.d index ab7bf93d41..ec45908d5e 100644 --- a/dmd/cli.d +++ b/dmd/cli.d @@ -14,6 +14,8 @@ */ module dmd.cli; +nothrow @safe: + /* The enum TargetOS is an exact copy of the one in dmd.globals. * Duplicated here because this file is stand-alone. */ @@ -91,21 +93,16 @@ Params: w = ASCII i string to capitalize Returns: capitalized string */ -static string capitalize(string w) +private string capitalize(string w) @trusted { - char[] result = cast(char[]) w; - char c1 = w.length ? w[0] : '\0'; - - if (c1 >= 'a' && c1 <= 'z') + if (w.length && w[0] >= 'a' && w[0] <= 'z') { - enum adjustment = 'A' - 'a'; - - result = new char[] (w.length); - result[0] = cast(char) (c1 + adjustment); + char[] result = new char[] (w.length); + result[0] = cast(char)(w[0] + 'A' - 'a'); result[1 .. $] = w[1 .. $]; + w = cast(string) result; } - - return cast(string) result; + return w; } /** diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 086388d003..48604b883f 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -544,7 +544,7 @@ Optional!bool toBool(Expression _this) * Check that the expression `e` has a valid type. * If not, generates an error "... has no type". * Params: - * e = Expression to check + * e = Expression to check * Returns: * true if the expression has a valid type. * Note: @@ -616,12 +616,12 @@ bool hasValidType(Expression e) switch (e.op) { - case EXP.type: return visitTypeExp(e.isTypeExp()); - case EXP.scope_: return visitScopeExp(e.isScopeExp()); - case EXP.template_: return visitTemplateExp(e.isTemplateExp()); - case EXP.function_: return visitFuncExp(e.isFuncExp()); - case EXP.dotTemplateDeclaration: return visitDotTemplateExp(e.isDotTemplateExp()); - case EXP.dotTemplateInstance: return visitDotTemplateInstanceExp(e.isDotTemplateInstanceExp()); + case EXP.type: return visitTypeExp(e.isTypeExp()); + case EXP.scope_: return visitScopeExp(e.isScopeExp()); + case EXP.template_: return visitTemplateExp(e.isTemplateExp()); + case EXP.function_: return visitFuncExp(e.isFuncExp()); + case EXP.dotTemplateDeclaration: return visitDotTemplateExp(e.isDotTemplateExp()); + case EXP.dotTemplateInstance: return visitDotTemplateInstanceExp(e.isDotTemplateInstanceExp()); default: return true; } diff --git a/dmd/mtype.d b/dmd/mtype.d index c0ac11366a..075462752d 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -51,7 +51,7 @@ static if (__VERSION__ < 2095) private alias StringValueType = StringValue!Type; } -private auto X(T, U)(T m, U n) +private auto X(T, U)(T m, U n) nothrow { return (m << 4) | n; } @@ -509,7 +509,7 @@ extern (C++) abstract class Type : ASTNode return sizeTy; }(); - final extern (D) this(TY ty) scope @safe + final extern (D) this(TY ty) scope @safe nothrow { this.ty = ty; } @@ -532,7 +532,7 @@ extern (C++) abstract class Type : ASTNode assert(0); } - final bool equals(const Type t) const + final bool equals(const Type t) const nothrow { //printf("Type::equals(%s, %s)\n", toChars(), t.toChars()); if (this == t) @@ -566,20 +566,20 @@ extern (C++) abstract class Type : ASTNode } // kludge for template.isType() - override final DYNCAST dyncast() const + override final DYNCAST dyncast() const nothrow { return DYNCAST.type; } /// Returns a non-zero unique ID for this Type, or returns 0 if the Type does not (yet) have a unique ID. /// If `semantic()` has not been run, 0 is returned. - final size_t getUniqueID() const + final size_t getUniqueID() const nothrow { return cast(size_t) deco; } extern (D) - final Mcache* getMcache() + final Mcache* getMcache() nothrow { if (!mcache) mcache = cast(Mcache*) mem.xcalloc(Mcache.sizeof, 1); @@ -612,7 +612,7 @@ extern (C++) abstract class Type : ASTNode * This can be used to restore the state set by `_init` to its original * state. */ - static void deinitialize() + static void deinitialize() nothrow { stringtable = stringtable.init; } @@ -640,7 +640,7 @@ extern (C++) abstract class Type : ASTNode return buf.extractChars(); } - bool isScopeClass() + bool isScopeClass() nothrow { return false; } @@ -865,7 +865,7 @@ extern (C++) abstract class Type : ASTNode } // For eliminating dynamic_cast - TypeBasic isTypeBasic() + TypeBasic isTypeBasic() nothrow { return null; } @@ -936,7 +936,7 @@ extern (C++) abstract class Type : ASTNode v.visit(this); } - final TypeFunction toTypeFunction() + final TypeFunction toTypeFunction() nothrow { if (ty != Tfunction) assert(0); @@ -967,12 +967,12 @@ extern (C++) final class TypeError : Type super(Terror); } - override const(char)* kind() const + override const(char)* kind() const nothrow { return "error"; } - override TypeError syntaxCopy() + override TypeError syntaxCopy() nothrow { // No semantic analysis done, no need to copy return this; From feabc0b41ba7031b3b1b318871a624fb5d84245d Mon Sep 17 00:00:00 2001 From: Sergii K Date: Fri, 19 Dec 2025 16:33:24 +0300 Subject: [PATCH 185/440] Clean up semanticTypeInfoMembers using local helper (dlang/dmd!22267) --- dmd/semantic3.d | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/dmd/semantic3.d b/dmd/semantic3.d index f80ce94044..57e5a6d1ac 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -1755,25 +1755,20 @@ FuncDeclaration search_toString(StructDeclaration sd) */ void semanticTypeInfoMembers(StructDeclaration sd) { - if (sd.xeq && - sd.xeq._scope && - sd.xeq.semanticRun < PASS.semantic3done) + void runSemantic(ref FuncDeclaration fd, ref FuncDeclaration errFd) { - const errors = global.startGagging(); - sd.xeq.semantic3(sd.xeq._scope); - if (global.endGagging(errors)) - sd.xeq = sd.xerreq; + if (fd && fd._scope && fd.semanticRun < PASS.semantic3done) + { + const errors = global.startGagging(); + fd.semantic3(fd._scope); + if (global.endGagging(errors)) + fd = errFd; + } } - if (sd.xcmp && - sd.xcmp._scope && - sd.xcmp.semanticRun < PASS.semantic3done) - { - const errors = global.startGagging(); - sd.xcmp.semantic3(sd.xcmp._scope); - if (global.endGagging(errors)) - sd.xcmp = sd.xerrcmp; - } + runSemantic(sd.xeq, sd.xerreq); + runSemantic(sd.xcmp, sd.xerrcmp); + FuncDeclaration ftostr = search_toString(sd); if (ftostr && From 355298fccc3167f0605105274d465be9dbbeb4c1 Mon Sep 17 00:00:00 2001 From: Sergii Kuzko Date: Fri, 19 Dec 2025 19:00:20 +0300 Subject: [PATCH 186/440] refactoring addReturn0 --- dmd/semantic3.d | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/dmd/semantic3.d b/dmd/semantic3.d index 57e5a6d1ac..30078b0181 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -228,20 +228,6 @@ private extern(C++) final class Semantic3Visitor : Visitor timeTraceBeginEvent(TimeTraceEventType.sema3); scope (exit) timeTraceEndEvent(TimeTraceEventType.sema3, funcdecl); - /* Determine if function should add `return 0;` - */ - bool addReturn0() - { - //printf("addReturn0()\n"); - auto f = funcdecl.type.isTypeFunction(); - - // C11 5.1.2.2.3 - if (sc.inCfile && funcdecl.isCMain() && f.next.ty == Tint32) - return true; - - return f.next.ty == Tvoid && (funcdecl.isMain() || funcdecl.isCMain()); - } - VarDeclaration _arguments = null; if (!funcdecl.parent) @@ -644,7 +630,7 @@ private extern(C++) final class Semantic3Visitor : Visitor Expression exp = (*funcdecl.returns)[i].exp; if (exp.op == EXP.variable && (cast(VarExp)exp).var == funcdecl.vresult) { - if (addReturn0()) + if (fds.addReturn0()) exp.type = Type.tint32; else exp.type = f.next; @@ -836,7 +822,7 @@ private extern(C++) final class Semantic3Visitor : Visitor if (funcdecl.returns) { - bool implicit0 = addReturn0(); + bool implicit0 = fds.addReturn0(); Type tret = implicit0 ? Type.tint32 : f.next; assert(tret.ty != Tvoid); if (funcdecl.vresult || funcdecl.returnLabel) @@ -1187,7 +1173,7 @@ private extern(C++) final class Semantic3Visitor : Visitor a.push(s); } } - if (addReturn0()) + if (fds.addReturn0()) { // Add a return 0; statement Statement s = new ReturnStatement(Loc.initial, IntegerExp.literal!0); @@ -1720,6 +1706,21 @@ private struct FuncDeclSem3 } } } + + /* Determine if function should add `return 0;` + */ + bool addReturn0() + { + //printf("addReturn0()\n"); + auto f = funcdecl.type.isTypeFunction(); + if (!f) return false; + + // C11 5.1.2.2.3 + if (sc.inCfile && funcdecl.isCMain() && f.next.ty == Tint32) + return true; + + return f.next.ty == Tvoid && (funcdecl.isMain() || funcdecl.isCMain()); + } } /*************************************** From 2dbe35098b16a7e06994c29d8b46cb9dd74230dc Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 20 Dec 2025 10:09:58 +0000 Subject: [PATCH 187/440] Fix typo in void init of bool error message (dlang/dmd!22271) --- dmd/dsymbolsem.d | 2 +- tests/dmd/fail_compilation/systemvariables_void_init.d | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 37258e1d71..95b92024ff 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -2553,7 +2553,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor "`void` initializing a struct with an invariant"); else if (dsym.type.toBasetype().ty == Tbool) sc.setUnsafePreview(global.params.systemVariables, false, dsym.loc, - "void intializing a bool (which must always be 0 or 1)"); + "`void` initializing a `bool` (which must always be 0 or 1)"); else if (dsym.type.hasUnsafeBitpatterns()) sc.setUnsafePreview(global.params.systemVariables, false, dsym.loc, "`void` initializing a type with unsafe bit patterns"); diff --git a/tests/dmd/fail_compilation/systemvariables_void_init.d b/tests/dmd/fail_compilation/systemvariables_void_init.d index 43478e782f..e91af394ec 100644 --- a/tests/dmd/fail_compilation/systemvariables_void_init.d +++ b/tests/dmd/fail_compilation/systemvariables_void_init.d @@ -5,8 +5,8 @@ TEST_OUTPUT: fail_compilation/systemvariables_void_init.d(48): Error: `void` initializing a type with unsafe bit patterns is not allowed in a `@safe` function fail_compilation/systemvariables_void_init.d(49): Error: `void` initializing a type with unsafe bit patterns is not allowed in a `@safe` function fail_compilation/systemvariables_void_init.d(50): Error: `void` initializing a type with unsafe bit patterns is not allowed in a `@safe` function -fail_compilation/systemvariables_void_init.d(51): Error: void intializing a bool (which must always be 0 or 1) is not allowed in a `@safe` function -fail_compilation/systemvariables_void_init.d(52): Error: void intializing a bool (which must always be 0 or 1) is not allowed in a `@safe` function +fail_compilation/systemvariables_void_init.d(51): Error: `void` initializing a `bool` (which must always be 0 or 1) is not allowed in a `@safe` function +fail_compilation/systemvariables_void_init.d(52): Error: `void` initializing a `bool` (which must always be 0 or 1) is not allowed in a `@safe` function fail_compilation/systemvariables_void_init.d(53): Error: `void` initializing a type with unsafe bit patterns is not allowed in a `@safe` function fail_compilation/systemvariables_void_init.d(54): Error: `void` initializing a type with unsafe bit patterns is not allowed in a `@safe` function --- From 3f84f749e4df148b6950279b442747805b2ba442 Mon Sep 17 00:00:00 2001 From: Aditya Singh Date: Sat, 20 Dec 2025 15:41:07 +0530 Subject: [PATCH 188/440] Fix Issue 22170: Add abs(), rem(), urem() and improve docs (dlang/dmd!22226) --- runtime/druntime/src/core/int128.d | 63 ++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/runtime/druntime/src/core/int128.d b/runtime/druntime/src/core/int128.d index b1247891e6..8bd718ff4b 100644 --- a/runtime/druntime/src/core/int128.d +++ b/runtime/druntime/src/core/int128.d @@ -113,6 +113,20 @@ Cent neg(Cent c) return c; } +/***************************** + * Absolute value + * Note: This is a signed operation. + * Params: + * c = Cent to get absolute value of + * Returns: + * absolute value of c + */ +pure +Cent abs(Cent c) +{ + return (cast(I)c.hi < 0) ? neg(c) : c; +} + /***************************** * Increment * Params: @@ -237,6 +251,9 @@ in (n < Ubits * 2) /***************************** * Arithmetic shift right n bits + * + * Note: This is a signed shift (preserves the sign bit). + * * Params: * c = Cent to shift * n = number of bits to shift @@ -417,6 +434,7 @@ Cent sub(Cent c1, Cent c2) /**************************** * Multiply c1 * c2. + * Note: The algorithm is identical for both signed and unsigned multiplication. * Params: * c1 = operand 1 * c2 = operand 2 @@ -721,6 +739,7 @@ U udivmod(Cent c1, U c2, out U modulus) /**************************** * Signed divide c1 / c2. + * Note: Performs signed division. Use udiv() for unsigned division. * Params: * c1 = dividend * c2 = divisor @@ -768,6 +787,38 @@ Cent divmod(Cent c1, Cent c2, out Cent modulus) return udivmod(c1, c2, modulus); } +/***************************** + * Unsigned remainder c1 % c2. + * Params: + * c1 = dividend + * c2 = divisor + * Returns: + * remainder c1 % c2 + */ +pure +Cent urem(Cent c1, Cent c2) +{ + Cent modulus; + udivmod(c1, c2, modulus); + return modulus; +} + +/***************************** + * Signed remainder c1 % c2. + * Params: + * c1 = dividend + * c2 = divisor + * Returns: + * remainder c1 % c2 + */ +pure +Cent rem(Cent c1, Cent c2) +{ + Cent modulus; + divmod(c1, c2, modulus); + return modulus; +} + /**************************** * If c1 > c2 unsigned * Params: @@ -1052,4 +1103,16 @@ unittest assert(ror(C7_9, 1) == ror1(C7_9)); assert(rol(C7_9, 0) == C7_9); assert(ror(C7_9, 0) == C7_9); + + // Test abs() + assert(abs(Cm10) == C10); + assert(abs(C10) == C10); + assert(abs(C0) == C0); + + // Test rem/urem + assert(rem(C10, C3) == C1); // 10 % 3 = 1 + assert(urem(C10, C3) == C1); + assert(rem(Cm10, C3) == Cm1); // -10 % 3 = -1 + + assert(urem(Cm10, C3) == C0); } From 03bf6088910cb29a102469cd83d68f98bee9392f Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 20 Dec 2025 12:26:12 +0000 Subject: [PATCH 189/440] Disallow casting array to struct with unsafe bit patterns in safe code (dlang/dmd!22273) Casting is allowed when there's a matching constructor call. Casting to `bool` is safe. --- dmd/safe.d | 11 +++++-- tests/dmd/fail_compilation/cast_system.d | 37 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 tests/dmd/fail_compilation/cast_system.d diff --git a/dmd/safe.d b/dmd/safe.d index c65291502c..8f1ccc2dad 100644 --- a/dmd/safe.d +++ b/dmd/safe.d @@ -175,10 +175,17 @@ bool isSafeCast(Expression e, Type tfrom, Type tto, ref string msg) // Implicit conversions are always safe if (tfrom.implicitConvTo(tto)) return true; - if (!tto.hasPointers()) + { + // casting to bool is safe as it's a special op + // casting to struct with non-pointer @system field is not @safe + if (tto.ty != Tbool && tto.hasUnsafeBitpatterns()) + { + msg = "Target element type has unsafe bit patterns"; + return false; + } return true; - + } auto tfromb = tfrom.toBasetype(); auto ttob = tto.toBasetype(); diff --git a/tests/dmd/fail_compilation/cast_system.d b/tests/dmd/fail_compilation/cast_system.d new file mode 100644 index 0000000000..c8f5fd6586 --- /dev/null +++ b/tests/dmd/fail_compilation/cast_system.d @@ -0,0 +1,37 @@ +/* +REQUIRED_ARGS: -preview=systemVariables +TEST_OUTPUT: +--- +fail_compilation/cast_system.d(31): Error: cast from `int[1]` to `UniqueInt` is not allowed in a `@safe` function +fail_compilation/cast_system.d(31): Target element type has unsafe bit patterns +--- +*/ + +struct UniqueInt +{ + @system int n; + + this(int n) @safe + { + this.n = n; + } + + @disable this(ref inout UniqueInt) inout; + + ~this() @trusted + { + this.n = 0; + } +} + +void main() @safe +{ + auto s = cast(UniqueInt) 7; // OK, calls ctor + int[1] a; + s = cast(UniqueInt) a; // doesn't call ctor +} + +void ok() @safe +{ + auto b = cast(bool) 7; // OK +} From b5cf25c10b752d501d0d759fcb861ea26547cb3c Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 20 Dec 2025 22:39:37 +0200 Subject: [PATCH 190/440] Move `Parameter.isLazyArray` and `Type.sizemask` to `typesem` (dlang/dmd!22279) --- dmd/cxxfrontend.d | 6 +++++ dmd/frontend.h | 1 - dmd/intrange.d | 2 +- dmd/mtype.d | 64 ---------------------------------------------- dmd/mtype.h | 2 +- dmd/typesem.d | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 73 insertions(+), 67 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index bb81150cc3..bbbb4ebffa 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -1023,6 +1023,12 @@ Type nextOf(Type type) return dmd.typesem.nextOf(type); } +Type isLazyArray(Parameter param) +{ + import dmd.typesem; + return dmd.typesem.isLazyArray(param); +} + MOD deduceWild(Type type, Type t, bool isRef) { import dmd.typesem; diff --git a/dmd/frontend.h b/dmd/frontend.h index d07c2ee9d0..57cc811886 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -4294,7 +4294,6 @@ class Parameter final : public ASTNode UserAttributeDeclaration* userAttribDecl; static Parameter* create(Loc loc, StorageClass storageClass, Type* type, Identifier* ident, Expression* defaultArg, UserAttributeDeclaration* userAttribDecl); Parameter* syntaxCopy(); - Type* isLazyArray(); bool isLazy() const; bool isReference() const; DYNCAST dyncast() const override; diff --git a/dmd/intrange.d b/dmd/intrange.d index 462bf9b4ad..039cc9a205 100644 --- a/dmd/intrange.d +++ b/dmd/intrange.d @@ -16,7 +16,7 @@ import core.stdc.stdio; import dmd.astenums : Tdchar; import dmd.mtype : Type; import dmd.globals : uinteger_t; -import dmd.typesem : isIntegral, isUnsigned; +import dmd.typesem : isIntegral, isUnsigned, sizemask; private uinteger_t copySign(uinteger_t x, bool sign) @safe { diff --git a/dmd/mtype.d b/dmd/mtype.d index 075462752d..68bf14f3ae 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -827,43 +827,6 @@ extern (C++) abstract class Type : ASTNode return t; } - /**************************************** - * Return the mask that an integral type will - * fit into. - */ - extern (D) final ulong sizemask() - { - ulong m; - switch (toBasetype().ty) - { - case Tbool: - m = 1; - break; - case Tchar: - case Tint8: - case Tuns8: - m = 0xFF; - break; - case Twchar: - case Tint16: - case Tuns16: - m = 0xFFFFU; - break; - case Tdchar: - case Tint32: - case Tuns32: - m = 0xFFFFFFFFU; - break; - case Tint64: - case Tuns64: - m = 0xFFFFFFFFFFFFFFFFUL; - break; - default: - assert(0); - } - return m; - } - // For eliminating dynamic_cast TypeBasic isTypeBasic() nothrow { @@ -2437,33 +2400,6 @@ extern (C++) final class Parameter : ASTNode return new Parameter(loc, storageClass, type ? type.syntaxCopy() : null, ident, defaultArg ? defaultArg.syntaxCopy() : null, userAttribDecl ? userAttribDecl.syntaxCopy(null) : null); } - /**************************************************** - * Determine if parameter is a lazy array of delegates. - * If so, return the return type of those delegates. - * If not, return NULL. - * - * Returns T if the type is one of the following forms: - * T delegate()[] - * T delegate()[dim] - */ - Type isLazyArray() - { - Type tb = type.toBasetype(); - if (tb.isStaticOrDynamicArray()) - { - Type tel = (cast(TypeArray)tb).next.toBasetype(); - if (auto td = tel.isTypeDelegate()) - { - TypeFunction tf = td.next.toTypeFunction(); - if (tf.parameterList.varargs == VarArg.none && tf.parameterList.length == 0) - { - return tf.next; // return type of delegate - } - } - } - return null; - } - /// Returns: Whether the function parameter is lazy bool isLazy() const @safe pure nothrow @nogc { diff --git a/dmd/mtype.h b/dmd/mtype.h index 6cd7350340..c43fe7f3a9 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -426,7 +426,6 @@ class Parameter final : public ASTNode static Parameter *create(Loc loc, StorageClass storageClass, Type *type, Identifier *ident, Expression *defaultArg, UserAttributeDeclaration *userAttribDecl); Parameter *syntaxCopy(); - Type *isLazyArray(); bool isLazy() const; bool isReference() const; // kludge for template.isType() @@ -758,6 +757,7 @@ namespace dmd Type *makeSharedWild(Type* type); Type *makeSharedWildConst(Type* type); Type *nextOf(Type* type); + Type *isLazyArray(Parameter* param); unsigned char deduceWild(Type* type, Type* t, bool isRef); bool isIntegral(Type* type); bool isFloating(Type* type); diff --git a/dmd/typesem.d b/dmd/typesem.d index e8b06192c2..62b18eb1dc 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -67,6 +67,71 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; + +/**************************************************** + * Determine if parameter is a lazy array of delegates. + * If so, return the return type of those delegates. + * If not, return NULL. + * + * Returns T if the type is one of the following forms: + * T delegate()[] + * T delegate()[dim] + */ +Type isLazyArray(Parameter _this) +{ + Type tb = _this.type.toBasetype(); + if (tb.isStaticOrDynamicArray()) + { + Type tel = (cast(TypeArray)tb).next.toBasetype(); + if (auto td = tel.isTypeDelegate()) + { + TypeFunction tf = td.next.toTypeFunction(); + if (tf.parameterList.varargs == VarArg.none && tf.parameterList.length == 0) + { + return tf.next; // return type of delegate + } + } + } + return null; +} + +/**************************************** + * Return the mask that an integral type will + * fit into. + */ +ulong sizemask(Type _this) +{ + ulong m; + switch (_this.toBasetype().ty) + { + case Tbool: + m = 1; + break; + case Tchar: + case Tint8: + case Tuns8: + m = 0xFF; + break; + case Twchar: + case Tint16: + case Tuns16: + m = 0xFFFFU; + break; + case Tdchar: + case Tint32: + case Tuns32: + m = 0xFFFFFFFFU; + break; + case Tint64: + case Tuns64: + m = 0xFFFFFFFFFFFFFFFFUL; + break; + default: + assert(0); + } + return m; +} + /************************************* * If this is a type of something, return that something. */ From 56ff84a9bcc90414b66ea8903990fe1e14864883 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 20 Dec 2025 23:11:50 +0200 Subject: [PATCH 191/440] Move `Type.isAggregate` and `Type.isIndexableNonAggregate` to `typesem` (dlang/dmd!22280) --- dmd/cxxfrontend.d | 14 ++++++-------- dmd/iasm/gcc.d | 3 ++- dmd/inlinecost.d | 1 + dmd/mtype.d | 29 ----------------------------- dmd/typesem.d | 29 +++++++++++++++++++++++++++++ 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index bbbb4ebffa..9317153a04 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -625,14 +625,6 @@ JsonFieldFlags tryParseJsonField(const(char)* fieldName) return dmd.json.tryParseJsonField(fieldName); } -/*********************************************************** - * mtype.d - */ -AggregateDeclaration isAggregate(Type t) -{ - return dmd.mtype.isAggregate(t); -} - /*********************************************************** * optimize.d */ @@ -692,6 +684,12 @@ bool tpsemantic(TemplateParameter tp, Scope* sc, TemplateParameters* parameters) /*********************************************************** * typesem.d */ +AggregateDeclaration isAggregate(Type t) +{ + import dmd.typesem; + return dmd.typesem.isAggregate(t); +} + bool hasPointers(Type t) { import dmd.typesem; diff --git a/dmd/iasm/gcc.d b/dmd/iasm/gcc.d index 6f4b85b1ee..f7216f3575 100644 --- a/dmd/iasm/gcc.d +++ b/dmd/iasm/gcc.d @@ -189,7 +189,8 @@ Expression semanticAsmString(Scope* sc, Expression exp, const char *s) { import dmd.dcast : implicitCastTo; import dmd.dsymbolsem : resolveAliasThis; - import dmd.mtype : isAggregate, Type; + import dmd.mtype : Type; + import dmd.typesem : isAggregate; exp = expressionSemantic(exp, sc); diff --git a/dmd/inlinecost.d b/dmd/inlinecost.d index 07adab5af6..6b93b8b134 100644 --- a/dmd/inlinecost.d +++ b/dmd/inlinecost.d @@ -31,6 +31,7 @@ import dmd.id; import dmd.identifier; import dmd.init; import dmd.mtype; +import dmd.typesem; import dmd.opover; import dmd.statement; import dmd.tokens; diff --git a/dmd/mtype.d b/dmd/mtype.d index 68bf14f3ae..1f401d12b7 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -2767,35 +2767,6 @@ void attributesApply(const TypeFunction tf, void delegate(string) dg, TRUSTforma dg(trustToString(trustAttrib)); } -/** - * If the type is a class or struct, returns the symbol for it, - * else null. - */ -AggregateDeclaration isAggregate(Type t) -{ - t = t.toBasetype(); - if (auto tc = t.isTypeClass()) - return tc.sym; - if (auto ts = t.isTypeStruct()) - return ts.sym; - return null; -} - -/*************************************************** - * Determine if type t can be indexed or sliced given that it is not an - * aggregate with operator overloads. - * Params: - * t = type to check - * Returns: - * true if an expression of type t can be e1 in an array expression - */ -bool isIndexableNonAggregate(Type t) -{ - t = t.toBasetype(); - return (t.ty == Tpointer || t.isStaticOrDynamicArray() || t.ty == Taarray || - t.ty == Ttuple || t.ty == Tvector); -} - /*************************************** * Computes how a parameter may be returned. * Shrinking the representation is necessary because STC is so wide diff --git a/dmd/typesem.d b/dmd/typesem.d index 62b18eb1dc..1d98459304 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -68,6 +68,35 @@ import dmd.target; import dmd.tokens; +/*************************************************** + * Determine if type t can be indexed or sliced given that it is not an + * aggregate with operator overloads. + * Params: + * t = type to check + * Returns: + * true if an expression of type t can be e1 in an array expression + */ +bool isIndexableNonAggregate(Type t) +{ + t = t.toBasetype(); + return (t.ty == Tpointer || t.isStaticOrDynamicArray() || t.ty == Taarray || + t.ty == Ttuple || t.ty == Tvector); +} + +/** + * If the type is a class or struct, returns the symbol for it, + * else null. + */ +AggregateDeclaration isAggregate(Type t) +{ + t = t.toBasetype(); + if (auto tc = t.isTypeClass()) + return tc.sym; + if (auto ts = t.isTypeStruct()) + return ts.sym; + return null; +} + /**************************************************** * Determine if parameter is a lazy array of delegates. * If so, return the return type of those delegates. From 472355018d6fe6cf48d2c31211ba575b03b222cc Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 20 Dec 2025 23:12:35 +0200 Subject: [PATCH 192/440] Move`Type. baseElemOf` to `typesem` (dlang/dmd!22277) --- dmd/canthrow.d | 4 ++-- dmd/cxxfrontend.d | 6 ++++++ dmd/escape.d | 4 ++-- dmd/frontend.h | 1 - dmd/inline.d | 4 ++-- dmd/mtype.d | 12 ------------ dmd/mtype.h | 2 +- dmd/typesem.d | 12 ++++++++++++ 8 files changed, 25 insertions(+), 20 deletions(-) diff --git a/dmd/canthrow.d b/dmd/canthrow.d index 9914b83a7e..39536a4f77 100644 --- a/dmd/canthrow.d +++ b/dmd/canthrow.d @@ -20,8 +20,8 @@ import dmd.dsymbol; import dmd.dsymbolsem : include, toAlias; import dmd.errorsink; import dmd.expression; -import dmd.expressionsem : errorSupplementalInferredAttr, isLvalue, calledFunctionType; -import dmd.typesem : nextOf; +import dmd.expressionsem; +import dmd.typesem; import dmd.func; import dmd.globals; import dmd.mtype; diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 9317153a04..d346950f20 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -1021,6 +1021,12 @@ Type nextOf(Type type) return dmd.typesem.nextOf(type); } +Type baseElemOf(Type type) +{ + import dmd.typesem; + return dmd.typesem.baseElemOf(type); +} + Type isLazyArray(Parameter param) { import dmd.typesem; diff --git a/dmd/escape.d b/dmd/escape.d index 4c9505f9c5..678e7915c2 100644 --- a/dmd/escape.d +++ b/dmd/escape.d @@ -24,7 +24,7 @@ import dmd.dscope; import dmd.dsymbol; import dmd.errors; import dmd.expression; -import dmd.expressionsem : calledFunctionType, expToVariable; +import dmd.expressionsem; import dmd.func; import dmd.funcsem; import dmd.globals : FeatureState; @@ -38,7 +38,7 @@ import dmd.printast; import dmd.rootobject; import dmd.safe; import dmd.tokens; -import dmd.typesem : hasPointers, parameterStorageClass, nextOf; +import dmd.typesem; import dmd.visitor; import dmd.arraytypes; diff --git a/dmd/frontend.h b/dmd/frontend.h index 57cc811886..8b1eacba70 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2085,7 +2085,6 @@ class Type : public ASTNode Type* toBasetype(); virtual ClassDeclaration* isClassHandle(); virtual int32_t hasWild() const; - Type* baseElemOf(); virtual TypeBasic* isTypeBasic(); TypeFunction* isPtrToFunction(); TypeFunction* isFunction_Delegate_PtrToFunction(); diff --git a/dmd/inline.d b/dmd/inline.d index bd7608cbc6..41d1ad944f 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -26,7 +26,7 @@ import dmd.dmodule; import dmd.dscope; import dmd.dstruct; import dmd.dsymbol; -import dmd.dsymbolsem : include, toAlias, toParentP, followInstantiationContext, runDeferredSemantic3; +import dmd.dsymbolsem; import dmd.dtemplate; import dmd.expression; import dmd.expressionsem : canElideCopy, semanticTypeInfo; @@ -46,7 +46,7 @@ import dmd.opover; import dmd.printast; import dmd.statement; import dmd.tokens; -import dmd.typesem : pointerTo, sarrayOf, nextOf; +import dmd.typesem; import dmd.visitor; import dmd.visitor.postorder; import dmd.inlinecost; diff --git a/dmd/mtype.d b/dmd/mtype.d index 1f401d12b7..9465d4e58c 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -815,18 +815,6 @@ extern (C++) abstract class Type : ASTNode return mod & MODFlags.wild; } - /************************************* - * If this is a type of static array, return its base element type. - */ - final Type baseElemOf() - { - Type t = toBasetype(); - TypeSArray tsa; - while ((tsa = t.isTypeSArray()) !is null) - t = tsa.next.toBasetype(); - return t; - } - // For eliminating dynamic_cast TypeBasic isTypeBasic() nothrow { diff --git a/dmd/mtype.h b/dmd/mtype.h index c43fe7f3a9..1bb65a36e9 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -245,7 +245,6 @@ class Type : public ASTNode virtual ClassDeclaration *isClassHandle(); virtual int hasWild() const; - Type *baseElemOf(); TypeFunction *toTypeFunction(); @@ -757,6 +756,7 @@ namespace dmd Type *makeSharedWild(Type* type); Type *makeSharedWildConst(Type* type); Type *nextOf(Type* type); + Type *baseElemOf(Type* type); Type *isLazyArray(Parameter* param); unsigned char deduceWild(Type* type, Type* t, bool isRef); bool isIntegral(Type* type); diff --git a/dmd/typesem.d b/dmd/typesem.d index 1d98459304..6f4c294ac4 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -161,6 +161,18 @@ ulong sizemask(Type _this) return m; } +/************************************* + * If _this is a type of static array, return its base element type. + */ +Type baseElemOf(Type _this) +{ + Type t = _this.toBasetype(); + TypeSArray tsa; + while ((tsa = t.isTypeSArray()) !is null) + t = tsa.next.toBasetype(); + return t; +} + /************************************* * If this is a type of something, return that something. */ From de2425880f88feef206df3cf67623048983c5981 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Sat, 20 Dec 2025 15:40:34 +0000 Subject: [PATCH 193/440] core.sys.posix.sys.types: Fix blksize_t and nlink_t for CRuntime_Musl musl overrides blksize_t to int (instead of long) on aarch64, riscv64, and loongarch64. It also overrides nlink_t to uint (instead of size_t) on mips64. These arch-specific overrides are defined in musl's arch/*/bits/alltypes.h.in files and differ from the base definitions in include/alltypes.h.in. Without this fix, the D type sizes don't match the C ABI on these architectures when using musl. --- .../druntime/src/core/sys/posix/sys/types.d | 61 +++++++++++++++---- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/runtime/druntime/src/core/sys/posix/sys/types.d b/runtime/druntime/src/core/sys/posix/sys/types.d index 859c4ea0d2..7c03b2949a 100644 --- a/runtime/druntime/src/core/sys/posix/sys/types.d +++ b/runtime/druntime/src/core/sys/posix/sys/types.d @@ -99,23 +99,58 @@ version (linux) alias ulong_t ino_t; alias slong_t off_t; } - alias slong_t blksize_t; + // musl overrides blksize_t to int on some 64-bit architectures. + // Default: long (https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in?h=v1.2.3#n32) + // AArch64: int (https://git.musl-libc.org/cgit/musl/tree/arch/aarch64/bits/alltypes.h.in?h=v1.2.3#n18) + // RISCV64: int (https://git.musl-libc.org/cgit/musl/tree/arch/riscv64/bits/alltypes.h.in?h=v1.2.3#n12) + // LoongArch64: int (https://git.musl-libc.org/cgit/musl/tree/arch/loongarch64/bits/alltypes.h.in?id=522bd54e#n18) + version (CRuntime_Musl) + { + version (AArch64) + alias int blksize_t; + else version (RISCV64) + alias int blksize_t; + else version (LoongArch64) + alias int blksize_t; + else + alias slong_t blksize_t; + } + else + alias slong_t blksize_t; + alias ulong dev_t; alias uint gid_t; alias uint mode_t; - version (X86_64) - alias ulong nlink_t; - else version (S390) - alias size_t nlink_t; - else version (PPC64) - alias size_t nlink_t; - else version (MIPS64) - alias size_t nlink_t; - else version (HPPA64) - alias size_t nlink_t; - else - alias uint nlink_t; + // musl defines nlink_t as unsigned _Reg (= unsigned int on 32-bit, unsigned long on 64-bit), + // with arch-specific overrides. + // Default: unsigned _Reg (https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in?h=v1.2.3#n28) + // MIPS64: unsigned (uint) (https://git.musl-libc.org/cgit/musl/tree/arch/mips64/bits/alltypes.h.in?h=v1.2.3#n22) + // X86_64: _Reg=long, so unsigned long (https://git.musl-libc.org/cgit/musl/tree/arch/x86_64/bits/alltypes.h.in?h=v1.2.3#n3) + version (CRuntime_Musl) + { + version (MIPS64) + alias uint nlink_t; + else version (X86_64) + alias ulong nlink_t; + else + alias uint nlink_t; + } + else + { + version (X86_64) + alias ulong nlink_t; + else version (S390) + alias size_t nlink_t; + else version (PPC64) + alias size_t nlink_t; + else version (MIPS64) + alias size_t nlink_t; + else version (HPPA64) + alias size_t nlink_t; + else + alias uint nlink_t; + } alias int pid_t; //size_t (defined in core.stdc.stddef) From 3e036f2e0017da9679bf6d65242648b6315fec97 Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Sun, 21 Dec 2025 14:04:09 +0100 Subject: [PATCH 194/440] fix dlang/dmd!22281 [REG master] Wrong associative array access with alias this for key (dlang/dmd!22283) don't omit the cast in aa[cast(K)key] if key converts via alias this, so that the proper type is inferred by _d_aaGetY --- dmd/dcast.d | 8 +++++++- runtime/druntime/test/aa/src/test_aa.d | 27 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/dmd/dcast.d b/dmd/dcast.d index ff604c9cce..8ab49b3c47 100644 --- a/dmd/dcast.d +++ b/dmd/dcast.d @@ -4339,7 +4339,13 @@ extern (D) bool keyCompatibleWithoutCasting(Expression ekey, Type t2) return true; return false; } - return implicitConvTo(ekey, t2) >= MATCH.constant; + if (implicitConvTo(ekey, t2) < MATCH.constant) + return false; + if (auto ts = t1.isTypeStruct()) + return implicitConvToThroughAliasThis(ts, t2) == MATCH.nomatch; + if (auto tc = t1.isTypeClass()) + return implicitConvToThroughAliasThis(tc, t2) == MATCH.nomatch; + return true; } /******************************************************************/ diff --git a/runtime/druntime/test/aa/src/test_aa.d b/runtime/druntime/test/aa/src/test_aa.d index b870cdb568..214bc9a12b 100644 --- a/runtime/druntime/test/aa/src/test_aa.d +++ b/runtime/druntime/test/aa/src/test_aa.d @@ -45,6 +45,7 @@ void main() testTypeInfoCollect(); testNew(); testAliasThis(); + testAliasThis2(); } void testKeysValues1() @@ -1021,3 +1022,29 @@ void testAliasThis() s.remove(1); assert(S.numCopies == 0); } + +void testAliasThis2() +{ + static struct A + { + bool extra; + uint id; + } + + static struct B + { + uint id; + + A toA() const pure nothrow + { + return A(false, id); + } + + alias toA this; + } + + bool[A] aa; + aa[B(5)] = true; + assert(B(5) in aa); + assert(A(false, 5) in aa); +} From dfb4684fbb4e9a8acc3c63e9513433508da86ac6 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Sun, 21 Dec 2025 13:54:56 +0000 Subject: [PATCH 195/440] core.sys.posix: musl 32-bit ARM support (dlang/dmd!22278) * core.sys.posix.sys.stat: Fix stat_t for CRuntime_Musl on ARM musl always uses 64-bit off_t, ino_t, blkcnt_t on all architectures (LFS by default), so use explicit 64-bit types instead of the D aliases which may resolve to 32-bit on 32-bit ARM if __USE_FILE_OFFSET64 is not set during D runtime compilation. Also use uint for nlink_t since musl defines it as unsigned int, not size_t. The struct layout now matches musl's arch/arm/bits/stat.h exactly, with the static assert verifying sizeof == 152 bytes. * core.sys.posix.sys.types: Use 64-bit LFS types for CRuntime_Musl Musl always uses 64-bit off_t, blkcnt_t, ino_t, fsblkcnt_t, fsfilcnt_t on all architectures (LFS by default). Add version(CRuntime_Musl) blocks to ensure these types are always 64-bit, regardless of __USE_FILE_OFFSET64 setting. This fixes issues on 32-bit musl builds where these types would incorrectly resolve to 32-bit values. --- .../druntime/src/core/sys/posix/sys/stat.d | 40 ++++++++++++------- .../druntime/src/core/sys/posix/sys/types.d | 26 +++++++++++- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/runtime/druntime/src/core/sys/posix/sys/stat.d b/runtime/druntime/src/core/sys/posix/sys/stat.d index 762d6fcc76..67d4e83f2a 100644 --- a/runtime/druntime/src/core/sys/posix/sys/stat.d +++ b/runtime/druntime/src/core/sys/posix/sys/stat.d @@ -653,29 +653,41 @@ version (linux) { version (CRuntime_Musl) { + // Matches struct stat from musl arch/arm/bits/stat.h + // See: https://git.musl-libc.org/cgit/musl/tree/arch/arm/bits/stat.h?h=v1.2.3 + // + // Type definitions from https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in?h=v1.2.3 + // with ARM-specific _Int64=long long and _Reg=int from + // https://git.musl-libc.org/cgit/musl/tree/arch/arm/bits/alltypes.h.in?h=v1.2.3#n3 + // + // Key 64-bit LFS types (always 64-bit on musl): + // dev_t = unsigned _Int64 = unsigned long long (line 31) + // off_t = _Int64 = long long (line 29) + // ino_t = unsigned _Int64 = unsigned long long (line 30) + // blkcnt_t = _Int64 = long long (line 33) + // blksize_t = long = long (32-bit) (line 32) + // nlink_t = unsigned _Reg = unsigned int (line 28) struct stat_t { - dev_t st_dev; - ushort __pad1; - c_long __st_ino; + ulong st_dev; + int __st_dev_padding; + c_long __st_ino_truncated; mode_t st_mode; - nlink_t st_nlink; + uint st_nlink; uid_t st_uid; gid_t st_gid; - dev_t st_rdev; - ushort __pad2; - off_t st_size; - blksize_t st_blksize; - blkcnt_t st_blocks; - private struct __timespec32 + ulong st_rdev; + int __st_rdev_padding; + long st_size; + c_long st_blksize; + long st_blocks; + struct __timespec32 { c_long tv_sec; c_long tv_nsec; } - __timespec32 __st_atim32; - __timespec32 __st_mtim32; - __timespec32 __st_ctim32; - ino_t st_ino; + __timespec32 __st_atim32, __st_mtim32, __st_ctim32; + ulong st_ino; timespec st_atim; timespec st_mtim; timespec st_ctim; diff --git a/runtime/druntime/src/core/sys/posix/sys/types.d b/runtime/druntime/src/core/sys/posix/sys/types.d index 859c4ea0d2..eeed55837a 100644 --- a/runtime/druntime/src/core/sys/posix/sys/types.d +++ b/runtime/druntime/src/core/sys/posix/sys/types.d @@ -87,7 +87,19 @@ uid_t version (linux) { - static if ( __USE_FILE_OFFSET64 ) + // Musl always uses 64-bit off_t, blkcnt_t, ino_t on all arches (LFS by default). + // See: https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in?h=v1.2.3#n29 + // off_t: _Int64 -> long long (signed 64-bit) + // ino_t: unsigned _Int64 -> unsigned long long (64-bit) + // blkcnt_t: _Int64 -> long long (signed 64-bit) + // For ARM, _Int64 = long long: https://git.musl-libc.org/cgit/musl/tree/arch/arm/bits/alltypes.h.in?h=v1.2.3#n3 + version (CRuntime_Musl) + { + alias long blkcnt_t; + alias ulong ino_t; + alias long off_t; + } + else static if ( __USE_FILE_OFFSET64 ) { alias long blkcnt_t; alias ulong ino_t; @@ -313,7 +325,17 @@ useconds_t version (linux) { - static if ( __USE_FILE_OFFSET64 ) + // Musl always uses 64-bit fsblkcnt_t, fsfilcnt_t on all arches (LFS by default). + // See: https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in?h=v1.2.3#n34 + // fsblkcnt_t: unsigned _Int64 -> unsigned long long (64-bit) + // fsfilcnt_t: unsigned _Int64 -> unsigned long long (64-bit) + // For ARM, _Int64 = long long: https://git.musl-libc.org/cgit/musl/tree/arch/arm/bits/alltypes.h.in?h=v1.2.3#n3 + version (CRuntime_Musl) + { + alias ulong fsblkcnt_t; + alias ulong fsfilcnt_t; + } + else static if ( __USE_FILE_OFFSET64 ) { alias ulong fsblkcnt_t; alias ulong fsfilcnt_t; From 9f8a1923025af7220a45621af8cb2089424eed0a Mon Sep 17 00:00:00 2001 From: Claude Code Date: Sun, 21 Dec 2025 15:17:56 +0000 Subject: [PATCH 196/440] Improve scope violation error messages to show inference chain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a `@safe` function cannot call another function due to scope violations during `@safe` inference, the error message now shows WHY the callee's parameter could not be inferred as `scope`. This is similar to how `@nogc` violations already show the full inference chain, helping users understand the root cause of scope errors without needing to manually trace through template instantiations. Example output: ``` Error: `@safe` function `outer` cannot call `@system` function `inner` and assigning scope variable `w` to non-scope parameter `w` calling `callee` makes it fail to infer `@safe` `w` is not `scope` because of `globalPtr = & w` ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- dmd/escape.d | 14 ++++++-- dmd/expressionsem.d | 6 ++++ dmd/frontend.h | 4 ++- dmd/func.d | 8 +++++ dmd/safe.d | 35 ++++++++++++++++--- .../fail_compilation/scope_infer_diagnostic.d | 35 +++++++++++++++++++ 6 files changed, 94 insertions(+), 8 deletions(-) create mode 100644 tests/dmd/fail_compilation/scope_infer_diagnostic.d diff --git a/dmd/escape.d b/dmd/escape.d index 4c9505f9c5..95b0534090 100644 --- a/dmd/escape.d +++ b/dmd/escape.d @@ -293,7 +293,7 @@ bool checkAssocArrayLiteralEscape(ref Scope sc, AssocArrayLiteralExp ae, bool ga * recursionLimit = recursion limit for printing the reason * positive = true for telling why v is scope, false for telling why v is not scope */ -private +public void printScopeReason(E)(E printFunc, VarDeclaration v, int recursionLimit, bool positive) { recursionLimit--; @@ -375,8 +375,8 @@ bool checkParamArgumentEscape(ref Scope sc, FuncDeclaration fdc, Identifier parI (desc ~ " `%s` assigned to non-scope anonymous parameter"); if (isThis ? - sc.setUnsafeDIP1000(gag, arg.loc, msg, arg, fdc.toParent2(), fdc) : - sc.setUnsafeDIP1000(gag, arg.loc, msg, v, parId ? parId : fdc, fdc)) + sc.setUnsafeDIP1000(gag, arg.loc, vPar, msg, arg, fdc.toParent2(), fdc) : + sc.setUnsafeDIP1000(gag, arg.loc, vPar, msg, v, parId ? parId : fdc, fdc)) { result = true; printScopeReason(previewSupplementalFunc(sc.isDeprecated(), sc.useDIP1000), vPar, 10, false); @@ -2214,6 +2214,14 @@ bool setUnsafeDIP1000(ref Scope sc, bool gag, Loc loc, const(char)* msg, return setUnsafePreview(&sc, sc.useDIP1000, gag, loc, msg, args); } +/// Overload for scope violations that also stores the variable whose scope status caused the issue +private +bool setUnsafeDIP1000(ref Scope sc, bool gag, Loc loc, VarDeclaration scopeVar, + const(char)* msg, RootObject[] args...) +{ + return setUnsafePreview(&sc, sc.useDIP1000, gag, loc, scopeVar, msg, args); +} + /*************************************** * Check that taking the address of `v` is `@safe` * diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 48604b883f..05b3256a64 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -3164,6 +3164,12 @@ public void errorSupplementalInferredAttr(FuncDeclaration fd, int maxDepth, bool if (s.action.length > 0) { errorFunc(s.loc, "and %.*s makes it fail to infer `%.*s`", s.action.fTuple.expand, attr.fTuple.expand); + // For scope violations, also print why the target parameter is not scope + if (s.scopeVar) + { + import dmd.escape : printScopeReason; + printScopeReason(errorFunc, s.scopeVar, 10, false); + } } else if (s.fd) { diff --git a/dmd/frontend.h b/dmd/frontend.h index d07c2ee9d0..873ab6ef12 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -3708,10 +3708,12 @@ struct AttributeViolation final Loc loc; FuncDeclaration* fd; _d_dynamicArray< const char > action; + VarDeclaration* scopeVar; AttributeViolation() : loc(), fd(), - action() + action(), + scopeVar() { } }; diff --git a/dmd/func.d b/dmd/func.d index 69be50e917..b7e60aa2a1 100644 --- a/dmd/func.d +++ b/dmd/func.d @@ -1430,6 +1430,8 @@ struct AttributeViolation string action; /// Action that made the attribute fail to get inferred + VarDeclaration scopeVar; /// For scope violations: the parameter whose scope status caused the issue + this(Loc loc, FuncDeclaration fd) { this.loc = loc; this.fd = fd; } this(Loc loc, const(char)* fmt, RootObject[] args) @@ -1445,4 +1447,10 @@ struct AttributeViolation ); this.action = buf.extractSlice(); } + + this(Loc loc, const(char)* fmt, VarDeclaration scopeVar, RootObject[] args) + { + this(loc, fmt, args); + this.scopeVar = scopeVar; + } } diff --git a/dmd/safe.d b/dmd/safe.d index 8f1ccc2dad..672b1574d2 100644 --- a/dmd/safe.d +++ b/dmd/safe.d @@ -370,12 +370,22 @@ bool isTrusted(FuncDeclaration fd) */ extern (D) void reportSafeError(FuncDeclaration fd, bool gag, Loc loc, const(char)* format, RootObject[] args...) +{ + reportSafeError(fd, gag, loc, null, format, args); +} + +/// Overload that also stores the variable whose scope status caused the violation +extern (D) void reportSafeError(FuncDeclaration fd, bool gag, Loc loc, + VarDeclaration scopeVar, const(char)* format, RootObject[] args...) { if (fd.type.toTypeFunction().trust == TRUST.system) // function was just inferred to be @system { if (format) { - fd.safetyViolation = new AttributeViolation(loc, format, args); + if (scopeVar) + fd.safetyViolation = new AttributeViolation(loc, format, scopeVar, args); + else + fd.safetyViolation = new AttributeViolation(loc, format, args); } else if (args.length > 0) { @@ -460,6 +470,13 @@ extern (D) bool setUnsafeCall(FuncDeclaration fd, FuncDeclaration f) * Returns: whether there is a safe error */ bool setUnsafe(Scope* sc, bool gag, Loc loc, const(char)* format, RootObject[] args...) +{ + return sc.setUnsafe(gag, loc, null, format, args); +} + +/// Overload that also stores the variable whose scope status caused the violation +bool setUnsafe(Scope* sc, bool gag, Loc loc, VarDeclaration scopeVar, + const(char)* format, RootObject[] args...) { if (sc.intypeof) return false; // typeof(cast(int*)0) is safe @@ -504,7 +521,7 @@ bool setUnsafe(Scope* sc, bool gag, Loc loc, const(char)* format, RootObject[] a { if (format || args.length > 0) { - reportSafeError(sc.func, gag, loc, format, args); + reportSafeError(sc.func, gag, loc, scopeVar, format, args); } return sc.func.isSafe(); // it is only an error if in an @safe function } @@ -531,6 +548,13 @@ bool setUnsafe(Scope* sc, bool gag, Loc loc, const(char)* format, RootObject[] a * Returns: whether an actual safe error (not deprecation) occured */ bool setUnsafePreview(Scope* sc, FeatureState fs, bool gag, Loc loc, const(char)* format, RootObject[] args...) +{ + return setUnsafePreview(sc, fs, gag, loc, null, format, args); +} + +/// Overload for scope violations that also stores the variable whose scope status caused the issue +bool setUnsafePreview(Scope* sc, FeatureState fs, bool gag, Loc loc, VarDeclaration scopeVar, + const(char)* format, RootObject[] args...) { //printf("setUnsafePreview() fs:%d %s\n", fs, fmt); assert(format); @@ -540,7 +564,7 @@ bool setUnsafePreview(Scope* sc, FeatureState fs, bool gag, Loc loc, const(char) return false; case enabled: - return sc.setUnsafe(gag, loc, format, args); + return sc.setUnsafe(gag, loc, scopeVar, format, args); case default_: if (!sc.func) @@ -556,7 +580,10 @@ bool setUnsafePreview(Scope* sc, FeatureState fs, bool gag, Loc loc, const(char) else if (!sc.func.safetyViolation) { import dmd.func : AttributeViolation; - sc.func.safetyViolation = new AttributeViolation(loc, format, args); + if (scopeVar) + sc.func.safetyViolation = new AttributeViolation(loc, format, scopeVar, args); + else + sc.func.safetyViolation = new AttributeViolation(loc, format, args); } return false; } diff --git a/tests/dmd/fail_compilation/scope_infer_diagnostic.d b/tests/dmd/fail_compilation/scope_infer_diagnostic.d new file mode 100644 index 0000000000..50b3d323e9 --- /dev/null +++ b/tests/dmd/fail_compilation/scope_infer_diagnostic.d @@ -0,0 +1,35 @@ +/* +REQUIRED_ARGS: -preview=dip1000 +TEST_OUTPUT: +--- +fail_compilation/scope_infer_diagnostic.d(34): Error: `@safe` function `scope_infer_diagnostic.outer` cannot call `@system` function `scope_infer_diagnostic.inner!(void delegate(const(char)[]) pure nothrow @nogc @safe).inner` +fail_compilation/scope_infer_diagnostic.d(28): and assigning scope variable `w` to non-scope parameter `w` calling `callee` makes it fail to infer `@safe` +fail_compilation/scope_infer_diagnostic.d(21): `w` is not `scope` because of `globalPtr = & w` +fail_compilation/scope_infer_diagnostic.d(25): `scope_infer_diagnostic.inner!(void delegate(const(char)[]) pure nothrow @nogc @safe).inner` is declared here +--- +*/ + +// Test that scope violation error messages show WHY the callee's parameter +// is not scope when going through the @safe inference chain. +// This is similar to how @nogc violations show the full inference chain. + +void* globalPtr; + +void callee(Writer)(Writer w) @trusted +{ + // This escapes w, preventing it from being inferred as scope + globalPtr = cast(void*)&w; + w("x"); +} + +void inner(Writer)(scope Writer w) +{ + // Scope violation: passing scope w to non-scope parameter + callee(w); +} + +void outer() @safe +{ + int x; + inner((const(char)[] s) { x++; }); +} From 07fbb27e888a84abe68d96cf954bdf0efba6b6da Mon Sep 17 00:00:00 2001 From: limepoutine Date: Mon, 22 Dec 2025 17:54:15 +0800 Subject: [PATCH 197/440] Propagate NRVO variables in inliner (dlang/dmd!22189) --- dmd/inline.d | 343 +++++++++++++++++++++-------------- tests/dmd/runnable/inline4.d | 33 +++- tests/dmd/runnable/rvalue1.d | 11 +- 3 files changed, 239 insertions(+), 148 deletions(-) diff --git a/dmd/inline.d b/dmd/inline.d index 41d1ad944f..6e00558728 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -141,6 +141,7 @@ enum EXPANDINLINE_LOG = false; private final class InlineDoState { // inline context + Expression eret; // expression returned to in case of NRVO VarDeclaration vthis; Dsymbols from; // old Dsymbols Dsymbols to; // parallel array of new Dsymbols @@ -148,7 +149,7 @@ private final class InlineDoState FuncDeclaration fd; // function being inlined (old parent) // inline result bool foundReturn; - bool needsCopy; + bool propagateNRVO; this(Dsymbol parent, FuncDeclaration fd) scope { @@ -364,16 +365,6 @@ public: //printf("ReturnStatement.doInlineAs!%s() '%s'\n", Result.stringof.ptr, s.exp ? s.exp.toChars() : ""); ids.foundReturn = true; - if (!ids.needsCopy && s.exp && s.exp.type.ty == Tstruct) - { - auto tf = ids.fd.type.isTypeFunction(); - if (!ids.fd.isCtorDeclaration() && !ids.fd.nrvo_var && - !tf.isRef && !canElideCopy(s.exp, tf.nextOf())) - { - ids.needsCopy = true; - } - } - auto exp = doInlineAs!Expression(s.exp, ids); if (!exp) // https://issues.dlang.org/show_bug.cgi?id=14560 // 'return' must not leave in the expand result @@ -390,7 +381,68 @@ public: result = new ExpStatement(s.loc, exp); } else + { + if (!ids.fd || ids.fd.isNRVO) + { + result = exp; + return; + } + + if (ids.eret) + { + /* Perform RVO emplacement into eret. + * Generate: + * ( eret ) = ( exp ), ( eret ) + */ + auto ce = new ConstructExp(s.loc, ids.eret.copy(), exp); + ce.type = exp.type; + result = Expression.combine(ce, ids.eret.copy()); + return; + } + + auto tf = ids.fd.type.isTypeFunction(); + + if (exp.type.ty == Tstruct && !tf.isRef && + !ids.fd.isCtorDeclaration() && !canElideCopy(s.exp, tf.nextOf())) + { + /* If the inlined function returns a copy of a struct, + * and then the return value is used subsequently as an + * lvalue, as in a struct return that is then used as a 'this'. + * Taking the address of the return value will be taking the address + * of the original, not the copy. Fix this by assigning the return value to + * a temporary, then returning the temporary. If the temporary is used as an + * lvalue, it will work. + * This only happens with struct returns. + * See https://issues.dlang.org/show_bug.cgi?id=2127 for an example. + * + * On constructor call making __inlineretval is merely redundant, because + * the returned reference is exactly same as vthis, and the 'this' variable + * already exists at the caller side. + * + * Generate a new variable to hold the result and initialize it with the + * inlined body of the function: + * tret __inlineretval = e; + */ + auto ei = new ExpInitializer(s.loc, exp); + auto tmp = Identifier.generateId("__inlineretval"); + auto vd = new VarDeclaration(s.loc, tf.next, tmp, ei); + vd.storage_class = STC.temp | (tf.isRef ? STC.ref_ : STC.rvalue); + vd._linkage = tf.linkage; + vd.parent = ids.parent; + + ei.exp = new ConstructExp(s.loc, vd, exp); + ei.exp.type = vd.type; + + auto de = new DeclarationExp(s.loc, vd); + de.type = Type.tvoid; + + // Chain the two together: + // ( typeof(return) __inlineretval = ( inlined body )) , __inlineretval + exp = Expression.combine(de, new VarExp(s.loc, vd)); + } + result = exp; + } } override void visit(ImportStatement s) @@ -459,6 +511,23 @@ public: override void visit(SymOffExp e) { //printf("SymOffExp.doInlineAs!%s(%s)\n", Result.stringof.ptr, e.toChars()); + if (ids.eret && ids.fd && + (ids.fd.isNRVO && e.var == ids.fd.nrvo_var || e.var.nrvo)) + { + // Deoptimize here and turn SymOffExp back into (&( eret ) + offset), + // because eret might have no symbol. + result = new AddrExp(e.loc, ids.eret.copy()); + result.type = e.type; + + if (e.offset) + { + auto ie = new IntegerExp(e.loc, e.offset, Type.tsize_t); + result = new AddExp(e.loc, result, ie); + result.type = e.type; + } + + return; + } foreach (i; 0 .. ids.from.length) { if (e.var != ids.from[i]) @@ -474,6 +543,12 @@ public: override void visit(VarExp e) { //printf("VarExp.doInlineAs!%s(%s)\n", Result.stringof.ptr, e.toChars()); + if (ids.eret && ids.fd && + (ids.fd.isNRVO && e.var == ids.fd.nrvo_var || e.var.nrvo)) + { + result = ids.eret.copy(); + return; + } foreach (i; 0 .. ids.from.length) { if (e.var != ids.from[i]) @@ -664,28 +739,26 @@ public: if (vd.isStatic()) return; - if (ids.fd && vd == ids.fd.nrvo_var) + bool varIsNRVO = ids.fd && (ids.fd.isNRVO && vd == ids.fd.nrvo_var || vd.nrvo); + + if (ids.eret && varIsNRVO) { - foreach (i; 0 .. ids.from.length) + if (vd._init && !vd._init.isVoidInitializer()) { - if (vd != ids.from[i]) - continue; - if (vd._init && !vd._init.isVoidInitializer()) - { - result = vd._init.initializerToExpression(); - assert(result); - result = doInlineAs!Expression(result, ids); - } - else - result = IntegerExp.literal!0; - return; + result = vd._init.initializerToExpression(); + assert(result); + result = doInlineAs!Expression(result, ids); } + else + result = IntegerExp.literal!0; + return; } auto vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd._init); memcpy(cast(void*)vto, cast(void*)vd, __traits(classInstanceSize, VarDeclaration)); vto.parent = ids.parent; vto.csym = null; + vto.nrvo = ids.propagateNRVO && varIsNRVO; ids.from.push(vd); ids.to.push(vto); @@ -1082,7 +1155,7 @@ public: */ if (auto ce = exp.isCallExp()) { - visitCallExp(ce, null, true); + visitCallExp(ce, null, true, false); if (eresult) exp = eresult; auto s = sresult; @@ -1228,7 +1301,30 @@ public: override void visit(ReturnStatement s) { //printf("ReturnStatement.inlineScan()\n"); - inlineScan(s.exp); + + if (!s.exp) + return; + + Expression e0; + Expression elast = Expression.extractLast(s.exp, e0); + inlineScan(e0); + + if (auto ce = elast.isCallExp()) + { + visitCallExp(ce, null, false, true); + + if (eresult) + { + elast = eresult; + eresult = null; + } + } + else + { + inlineScan(elast); + } + + s.exp = Expression.combine(e0, elast); } override void visit(SynchronizedStatement s) @@ -1399,40 +1495,54 @@ public: override void visit(AssignExp e) { - // Look for NRVO, as inlining NRVO function returns require special handling - if (e.op == EXP.construct && e.e2.op == EXP.call) + void inlineConstruction(AssignExp e) { - auto ce = e.e2.isCallExp(); - if (ce.f && ce.f.isNRVO && ce.f.nrvo_var) // NRVO + Expression e0; + Expression elast = Expression.extractLast(e.e2, e0); + inlineScan(e0); // Side effects + + auto ce = elast.isCallExp(); + if (ce && ce.f) { - if (auto ve = e.e1.isVarExp()) - { - /* Inlining: - * S s = foo(); // initializing by rvalue - * S s = S(1); // constructor call - */ - Declaration d = ve.var; - if (d.storage_class & (STC.out_ | STC.ref_)) // refinit - goto L1; - } - else - { - /* Inlining: - * this.field = foo(); // inside constructor - */ - inlineScan(e.e1); - } + visitCallExp(ce, e.e1, false, false); - visitCallExp(ce, e.e1, false); if (eresult) { + eresult = Expression.combine(e0, eresult); //printf("call with nrvo: %s ==> %s\n", e.toChars(), eresult.toChars()); return; } } + + inlineScan(elast); + e.e2 = Expression.combine(e0, elast); } - L1: - visit(cast(BinExp)e); + + inlineScan(e.e1); // LHS + + // Look for NRVO and emplace the return value into LHS directly + // when expanding the function call on RHS. + if (e.op == EXP.construct && + (e.e2.type.ty == Tstruct || e.e2.type.ty == Tsarray)) + { + bool refInit = false; + + /* Inlining: + * S s = ...; // initializing by rvalue + * No NRVO on: + * ref S s = ...; + */ + if (auto ve = e.e1.isVarExp()) + refInit = (ve.var.storage_class & (STC.out_ | STC.ref_)) != 0; + + if (!refInit) + { + inlineConstruction(e); + return; + } + } + + inlineScan(e.e2); // RHS if not construction } override void visit(ConstructExp e) @@ -1451,7 +1561,7 @@ public: override void visit(CallExp e) { //printf("CallExp.inlineScan() %s\n", e.toChars()); - visitCallExp(e, null, false); + visitCallExp(e, null, false, false); } /************************************** @@ -1461,11 +1571,13 @@ public: * e = the function call * eret = if !null, then this is the lvalue of the nrvo function result * asStatements = if inline as statements rather than as an Expression + * propagateNRVO = if the parent function returns the result immediately, + * so NRVO variables have to be preserved in the parent * Returns: * this.eresult if asStatements == false * this.sresult if asStatements == true */ - void visitCallExp(CallExp e, Expression eret, bool asStatements) + void visitCallExp(CallExp e, Expression eret, bool asStatements, bool propagateNRVO) { inlineScan(e.e1); arrayInlineScan(e.arguments); @@ -1489,7 +1601,8 @@ public: if (canInline(fd, parent == fd.toParent2(), asStates, pass, eSink)) { - expandInline(e, fd, parent, eret, null, asStates, eresult, sresult, again); + expandInline(e, fd, parent, eret, null, asStates, propagateNRVO, + eresult, sresult, again); if (asStatements && eresult) { sresult = new ExpStatement(eresult.loc, eresult); @@ -1584,7 +1697,8 @@ public: if (!canInline(fd, !fd.isNested(), asStatements, pass, eSink)) return; - expandInline(e, fd, parent, eret, explicitThis, asStatements, eresult, sresult, again); + expandInline(e, fd, parent, eret, explicitThis, asStatements, + propagateNRVO, eresult, sresult, again); } else inlineFd(fd); @@ -2090,13 +2204,15 @@ Lno: * parent = function that the call to fd is being expanded into * eret = if !null then the lvalue of where the nrvo return value goes * asStatements = expand to Statements rather than Expressions + * propagateNRVO = preserve NRVO status of variables * eresult = if expanding to an expression, this is where the expression is written to * sresult = if expanding to a statement, this is where the statement is written to * again = if true, then fd can be inline scanned again because there may be * more opportunities for inlining */ -private void expandInline(CallExp ecall, FuncDeclaration fd, FuncDeclaration parent, Expression eret, - Expression ethis, bool asStatements, out Expression eresult, out Statement sresult, out bool again) +private void expandInline(CallExp ecall, FuncDeclaration fd, FuncDeclaration parent, + Expression eret, Expression ethis, bool asStatements, bool propagateNRVO, + out Expression eresult, out Statement sresult, out bool again) { Loc callLoc = ecall.loc; auto tf = fd.type.isTypeFunction(); @@ -2108,6 +2224,7 @@ private void expandInline(CallExp ecall, FuncDeclaration fd, FuncDeclaration par if (ethis) printf("\tethis = %s\n", ethis.toChars()); } scope ids = new InlineDoState(parent, fd); + ids.propagateNRVO = propagateNRVO; if (fd.isNested()) { @@ -2116,58 +2233,34 @@ private void expandInline(CallExp ecall, FuncDeclaration fd, FuncDeclaration par parent.inlinedNestedCallees.push(fd); } - VarDeclaration vret; // will be set the function call result + // Set up eret if (eret) { - if (auto ve = eret.isVarExp()) + if (eret.isVarExp()) { - vret = ve.var.isVarDeclaration(); - assert(!(vret.storage_class & (STC.out_ | STC.ref_))); + ids.eret = eret; eret = null; } else { - /* Inlining: - * this.field = foo(); // inside constructor - */ + // Use a pointer to the expression (field or static array) to be initialized. + auto ei = new ExpInitializer(callLoc, null); - auto tmp = Identifier.generateId("__retvar"); - vret = new VarDeclaration(fd.loc, eret.type, tmp, ei); - vret.storage_class |= STC.temp | STC.ref_; - vret._linkage = LINK.d; - vret.parent = parent; + auto tmp = Identifier.generateId("__retptr"); + auto vd = new VarDeclaration(fd.loc, eret.type.pointerTo(), tmp, ei); + vd.storage_class |= STC.temp; + vd._linkage = LINK.d; + vd.parent = parent; - ei.exp = new ConstructExp(fd.loc, vret, eret); - ei.exp.type = vret.type; + ei.exp = new ConstructExp(fd.loc, vd, new AddrExp(fd.loc, eret, vd.type)); + ei.exp.type = vd.type; - auto de = new DeclarationExp(fd.loc, vret); + auto de = new DeclarationExp(fd.loc, vd); de.type = Type.tvoid; - eret = de; - } - if (!asStatements && fd.nrvo_var) - { - ids.from.push(fd.nrvo_var); - ids.to.push(vret); - } - } - else - { - if (!asStatements && fd.nrvo_var) - { - auto tmp = Identifier.generateId("__retvar"); - vret = new VarDeclaration(fd.loc, fd.nrvo_var.type, tmp, new VoidInitializer(fd.loc)); - assert(!tf.isRef); - vret.storage_class = STC.temp | STC.rvalue; - vret._linkage = tf.linkage; - vret.parent = parent; - - auto de = new DeclarationExp(fd.loc, vret); - de.type = Type.tvoid; + ids.eret = new PtrExp(fd.loc, new VarExp(fd.loc, vd)); + ids.eret.type = eret.type; eret = de; - - ids.from.push(fd.nrvo_var); - ids.to.push(vret); } } @@ -2177,9 +2270,8 @@ private void expandInline(CallExp ecall, FuncDeclaration fd, FuncDeclaration par { Expression e0; ethis = Expression.extractLast(ethis, e0); - VarDeclaration vthis2 = ecall.vthis2; - assert(vthis2 || !fd.hasDualContext); - if (vthis2) + + if (VarDeclaration vthis2 = ecall.vthis2) { // void*[2] __this = [ethis, this] if (ethis.type.ty == Tstruct) @@ -2204,7 +2296,6 @@ private void expandInline(CallExp ecall, FuncDeclaration fd, FuncDeclaration par } else { - //assert(ethis.type.ty != Tpointer); if (ethis.type.ty == Tpointer) { Type t = ethis.type.nextOf(); @@ -2212,13 +2303,23 @@ private void expandInline(CallExp ecall, FuncDeclaration fd, FuncDeclaration par ethis.type = t; } - auto ei = new ExpInitializer(fd.loc, ethis); + auto ei = new ExpInitializer(fd.loc, null); vthis = new VarDeclaration(fd.loc, ethis.type, Id.This, ei); - if (ethis.type.ty != Tclass) - vthis.storage_class = STC.ref_; vthis._linkage = LINK.d; vthis.parent = parent; + if (ethis.isStructLiteralExp()) + { + vthis.storage_class = STC.rvalue; + + if (fd.isCtorDeclaration() && propagateNRVO) + vthis.nrvo = true; + } + else if (ethis.type.ty != Tclass) + { + vthis.storage_class = STC.ref_; + } + ei.exp = new ConstructExp(fd.loc, vthis, ethis); ei.exp.type = vthis.type; @@ -2358,44 +2459,6 @@ private void expandInline(CallExp ecall, FuncDeclaration fd, FuncDeclaration par if (tf.isRef) e = e.toLvalue(null, "`ref` return"); - /* If the inlined function returns a copy of a struct, - * and then the return value is used subsequently as an - * lvalue, as in a struct return that is then used as a 'this'. - * Taking the address of the return value will be taking the address - * of the original, not the copy. Fix this by assigning the return value to - * a temporary, then returning the temporary. If the temporary is used as an - * lvalue, it will work. - * This only happens with struct returns. - * See https://issues.dlang.org/show_bug.cgi?id=2127 for an example. - * - * On constructor call making __inlineretval is merely redundant, because - * the returned reference is exactly same as vthis, and the 'this' variable - * already exists at the caller side. - */ - if (ids.needsCopy) - { - /* Generate a new variable to hold the result and initialize it with the - * inlined body of the function: - * tret __inlineretval = e; - */ - auto ei = new ExpInitializer(callLoc, e); - auto tmp = Identifier.generateId("__inlineretval"); - auto vd = new VarDeclaration(callLoc, tf.next, tmp, ei); - vd.storage_class = STC.temp | (tf.isRef ? STC.ref_ : STC.rvalue); - vd._linkage = tf.linkage; - vd.parent = parent; - - ei.exp = new ConstructExp(callLoc, vd, e); - ei.exp.type = vd.type; - - auto de = new DeclarationExp(callLoc, vd); - de.type = Type.tvoid; - - // Chain the two together: - // ( typeof(return) __inlineretval = ( inlined body )) , __inlineretval - e = Expression.combine(de, new VarExp(callLoc, vd)); - } - // https://issues.dlang.org/show_bug.cgi?id=15210 if (tf.next.ty == Tvoid && e && e.type.ty != Tvoid) { diff --git a/tests/dmd/runnable/inline4.d b/tests/dmd/runnable/inline4.d index afc116bbeb..40c4553076 100644 --- a/tests/dmd/runnable/inline4.d +++ b/tests/dmd/runnable/inline4.d @@ -350,12 +350,42 @@ void testRvalueRefReturn() class Test22157 { override string toString() - { + { auto e = { return cast() super; } (); return null; } } +/************************************/ +// https://issues.dlang.org/show_bug.cgi?id=22089 + +struct S22089 +{ + @disable this(ref return scope typeof(this) rhs); + @disable this(this); + void* cons; + this(int i) + { + cons = cast(void*)&this; + } + void start() + { + void* s = cast(void*)&this; + assert(cons == s); + } +} + +auto fun22089() +{ + return S22089(42); +} + +void test22089() +{ + auto op = fun22089(); + op.start(); +} + /************************************/ void main() @@ -363,4 +393,5 @@ void main() testValueReturn(); testRefReturn(); testRvalueRefReturn(); + test22089(); } diff --git a/tests/dmd/runnable/rvalue1.d b/tests/dmd/runnable/rvalue1.d index 084ce3b9c3..e50ccd0839 100644 --- a/tests/dmd/runnable/rvalue1.d +++ b/tests/dmd/runnable/rvalue1.d @@ -288,19 +288,15 @@ struct V12 this(int) { s = S12(1); } } -void foo(S12 s) -{ - assert(&s == s.ptr); -} - -S12 bar() +S12 foo12() { return __rvalue(V12(1).s); } void test12() { - foo(bar()); + S12 s = foo12(); + assert(&s == s.ptr); } /********************************/ @@ -318,6 +314,7 @@ int main() test9(); test10(); test11(); + test12(); return 0; } From 66c0e357d320fa2431d6883958b12b201b0129d8 Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Mon, 22 Dec 2025 21:25:14 +0000 Subject: [PATCH 198/440] simplify tests for pretty func runtime differences --- tests/dmd/runnable/func.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/dmd/runnable/func.c b/tests/dmd/runnable/func.c index 74fae4406b..7a4e3b9f0e 100644 --- a/tests/dmd/runnable/func.c +++ b/tests/dmd/runnable/func.c @@ -5,23 +5,13 @@ void foo() { assert(strcmp(__FUNCTION__, "foo") == 0); - -#ifndef __linux__ - assert(strcmp(__PRETTY_FUNCTION__, "void foo()") == 0); -#else - assert(strcmp(__PRETTY_FUNCTION__, "foo") == 0); -#endif - + assert(strstr(__PRETTY_FUNCTION__, "foo")); } int bar(int a, int b) { assert(strcmp(__FUNCTION__, "bar") == 0); -#ifndef __linux__ - assert(strcmp(__PRETTY_FUNCTION__, "int bar(int, int)") == 0); -#else - assert(strcmp(__PRETTY_FUNCTION__, "bar") == 0); -#endif + assert(strstr(__PRETTY_FUNCTION__, "bar")); return 0; } From 523055da0d935bd0b9e198b2f1295b17c16a00f2 Mon Sep 17 00:00:00 2001 From: Johan Engelen Date: Tue, 23 Dec 2025 00:43:57 +0100 Subject: [PATCH 199/440] Optimize `getTypePointerBitmap` for large static arrays without pointers. (dlang/dmd!22288) This reduces semantic analysis (`-c -o-`) from ~0.8sec to ~0.3sec on my machine for the following testcase: ``` struct S { int[200000000] x; } ``` --- dmd/traits.d | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dmd/traits.d b/dmd/traits.d index 568fe08077..8ea04c1c38 100644 --- a/dmd/traits.d +++ b/dmd/traits.d @@ -165,11 +165,14 @@ ulong getTypePointerBitmap(Loc loc, Type t, ref Array!(ulong) data, ErrorSink eS ulong nextsize = t.next.size(); if (nextsize == SIZE_INVALID) error = true; - ulong dim = t.dim.toInteger(); - for (ulong i = 0; i < dim; i++) + if (t.hasPointers) { - offset = arrayoff + i * nextsize; - visit(t.next); + ulong dim = t.dim.toInteger(); + for (ulong i = 0; i < dim; i++) + { + offset = arrayoff + i * nextsize; + visit(t.next); + } } offset = arrayoff; } From b5e2d561cd3f3a49a270081bd8d3b7b0be813a07 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Tue, 23 Dec 2025 09:39:25 +0800 Subject: [PATCH 200/440] Fix dlang/dmd!22290 wrong value of `IN_ACCESS` in `core.sys.linux`'s `inotify` (dlang/dmd!22291) --- runtime/druntime/src/core/sys/linux/sys/inotify.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/druntime/src/core/sys/linux/sys/inotify.d b/runtime/druntime/src/core/sys/linux/sys/inotify.d index 727471e455..3e582262f1 100644 --- a/runtime/druntime/src/core/sys/linux/sys/inotify.d +++ b/runtime/druntime/src/core/sys/linux/sys/inotify.d @@ -54,7 +54,7 @@ struct inotify_event enum: uint { - IN_ACCESS = 0x00000000, + IN_ACCESS = 0x00000001, IN_MODIFY = 0x00000002, IN_ATTRIB = 0x00000004, IN_CLOSE_WRITE = 0x00000008, From f050ac4147e843785c6989e8c8a298b49917ab9e Mon Sep 17 00:00:00 2001 From: limepoutine Date: Tue, 23 Dec 2025 13:05:03 +0800 Subject: [PATCH 201/440] Fix dlang/dmd!22292 - check dtor when inlining member function calls (dlang/dmd!22293) --- dmd/inline.d | 35 ++++++++++++++++++++++------------- tests/dmd/runnable/test28.d | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/dmd/inline.d b/dmd/inline.d index 6e00558728..b981120ff5 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -1582,7 +1582,7 @@ public: inlineScan(e.e1); arrayInlineScan(e.arguments); - void inlineFd(FuncDeclaration fd) + void inlineFd(FuncDeclaration fd, Expression explicitThis) { /* If the arguments generate temporaries that need destruction, the destruction * must be done after the function body is executed. @@ -1599,9 +1599,27 @@ public: asStates = false; } - if (canInline(fd, parent == fd.toParent2(), asStates, pass, eSink)) + bool hasThis; + if (explicitThis) { - expandInline(e, fd, parent, eret, null, asStates, propagateNRVO, + /* If ethis is explicitly given by a DotVarExp, fd can be inlined + * as long as it does not require another `this` pointer. + * Inlining the case where one pointer can be accessed from another + * is not implemented yet. + */ + hasThis = !fd.isNested(); + } + else + { + /* Otherwise, `this` pointer is captured from parent. Only allow + * immediate nested functions to reference `this` pointer. + */ + hasThis = parent == fd.toParent2(); + } + + if (canInline(fd, hasThis, asStates, pass, eSink)) + { + expandInline(e, fd, parent, eret, explicitThis, asStates, propagateNRVO, eresult, sresult, again); if (asStatements && eresult) { @@ -1692,16 +1710,7 @@ public: if (!fd || fd == parent) return; - if (explicitThis) - { - if (!canInline(fd, !fd.isNested(), asStatements, pass, eSink)) - return; - - expandInline(e, fd, parent, eret, explicitThis, asStatements, - propagateNRVO, eresult, sresult, again); - } - else - inlineFd(fd); + inlineFd(fd, explicitThis); if (global.params.v.verbose && (eresult || sresult)) message("inlined %s =>\n %s", fd.toPrettyChars(), parent.toPrettyChars()); diff --git a/tests/dmd/runnable/test28.d b/tests/dmd/runnable/test28.d index 4c50611601..845a54a1a1 100644 --- a/tests/dmd/runnable/test28.d +++ b/tests/dmd/runnable/test28.d @@ -1357,6 +1357,40 @@ void test22160() bar22160(putInSequence(Vector22160!ubyte())); } +/*******************************************/ +// https://github.com/dlang/dmd/issues/22292 + +struct Vector22292(T) +{ + T[] payload = [1]; + + ~this() nothrow + { + payload = null; + } + + void check(ref Vector22292 val) + { + assert(val.payload.length == 1); + } +} + +struct DEREncoder2 +{ + ref Vector22292!int getContentsUnlocked() + { + return m_contents; + } + + Vector22292!int m_contents; +} + +void test22292() +{ + Vector22292!int o; + o.check(DEREncoder2().getContentsUnlocked()); +} + /*******************************************/ void main() @@ -1425,6 +1459,7 @@ void main() test18576(); test67(); test22160(); + test22292(); printf("Success\n"); } From d2a41b4430b046acbbb6cd4d1e5e1167bfdf59cd Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Tue, 23 Dec 2025 08:39:20 +0000 Subject: [PATCH 202/440] no functional changes intended --- tests/dmd/runnable/func.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dmd/runnable/func.c b/tests/dmd/runnable/func.c index 7a4e3b9f0e..150b144ed9 100644 --- a/tests/dmd/runnable/func.c +++ b/tests/dmd/runnable/func.c @@ -5,7 +5,7 @@ void foo() { assert(strcmp(__FUNCTION__, "foo") == 0); - assert(strstr(__PRETTY_FUNCTION__, "foo")); + assert(strstr(__PRETTY_FUNCTION__, "foo")); // make room for runtime differences } int bar(int a, int b) From 4e928e0854a3fe7792f940c3c19b9ef3803adbba Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Tue, 23 Dec 2025 09:32:09 +0000 Subject: [PATCH 203/440] no functional change --- tests/dmd/runnable/func.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dmd/runnable/func.c b/tests/dmd/runnable/func.c index 150b144ed9..be556d1b71 100644 --- a/tests/dmd/runnable/func.c +++ b/tests/dmd/runnable/func.c @@ -11,7 +11,7 @@ void foo() int bar(int a, int b) { assert(strcmp(__FUNCTION__, "bar") == 0); - assert(strstr(__PRETTY_FUNCTION__, "bar")); + assert(strstr(__PRETTY_FUNCTION__, "bar")); // ditto for bar return 0; } From 2b1df3f5003053cb3f43e5a70bf6da5d99eb6599 Mon Sep 17 00:00:00 2001 From: Sergii Kuzko Date: Wed, 24 Dec 2025 11:24:13 +0300 Subject: [PATCH 204/440] refactoring --- dmd/semantic3.d | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/dmd/semantic3.d b/dmd/semantic3.d index 30078b0181..daaaec19c6 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -60,6 +60,7 @@ import dmd.opover; import dmd.optimize; import dmd.parse; import dmd.root.filename; +import dmd.root.array; import dmd.common.outbuffer; import dmd.root.rmem; import dmd.rootobject; @@ -1887,21 +1888,16 @@ extern (D) bool checkClosure(FuncDeclaration fd) auto fx = s.isFuncDeclaration(); if (!fx) continue; - if (fx.isThis() || - fx.tookAddressOf || - checkEscapingSiblings(fx, fd)) + if (fx.isThis() || fx.tookAddressOf || checkEscapingSiblings(fx, fd)) { - foreach (f2; a) + if (!a.contains(f)) { - if (f2 == f) - break LcheckAncestorsOfANestedRef; + a.push(f); + .errorSupplemental(f.loc, "%s `%s` closes over variable `%s`", + f.kind, f.toErrMsg(), v.toChars()); + if (v.ident != Id.This) + .errorSupplemental(v.loc, "`%s` declared here", v.toChars()); } - a.push(f); - .errorSupplemental(f.loc, "%s `%s` closes over variable `%s`", - f.kind, f.toErrMsg(), v.toChars()); - if (v.ident != Id.This) - .errorSupplemental(v.loc, "`%s` declared here", v.toChars()); - break LcheckAncestorsOfANestedRef; } } From 49e090e47a280bc5b0c5a61613526dc4baf8080f Mon Sep 17 00:00:00 2001 From: Sergii Kuzko Date: Wed, 24 Dec 2025 12:04:46 +0300 Subject: [PATCH 205/440] refactoring --- dmd/root/array.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dmd/root/array.d b/dmd/root/array.d index ee35e805d6..217945e6be 100644 --- a/dmd/root/array.d +++ b/dmd/root/array.d @@ -16,7 +16,7 @@ import core.stdc.stdlib : _compare_fp_t; import core.stdc.string; import dmd.root.rmem; -import dmd.root.string; +import dmd.root.string : toDString; // `qsort` is only `nothrow` since 2.081.0 private extern(C) void qsort(scope void* base, size_t nmemb, size_t size, _compare_fp_t compar) nothrow @nogc; @@ -908,7 +908,7 @@ bool equal(Range1, Range2)(Range1 range1, Range2 range2) else { - static if (hasLength!Range1 && hasLength!Range2 && is(typeof(r1.length == r2.length))) + static if (hasLength!Range1 && hasLength!Range2 && is(typeof(range1.length == range2.length))) { if (range1.length != range2.length) return false; From 68f7ea9926bc03b7d4a222b7861257697a5f21e1 Mon Sep 17 00:00:00 2001 From: Aryan Dadwal Date: Thu, 25 Dec 2025 08:16:52 +0530 Subject: [PATCH 206/440] Fix the 'ambigous' typo in comment about return attachment (dlang/dmd!22304) --- dmd/astenums.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmd/astenums.d b/dmd/astenums.d index 417cb9f396..1a5fcb8a55 100644 --- a/dmd/astenums.d +++ b/dmd/astenums.d @@ -150,7 +150,7 @@ enum STC : ulong // transfer changes to declaration.h alias StorageClass = ulong; /******** - * Determine if it's the ambigous case of where `return` attaches to. + * Determine if it's the ambiguous case of where `return` attaches to. * Params: * stc = STC flags * Returns: From 55dea5f4137321335444efd746a4e306c28e06bc Mon Sep 17 00:00:00 2001 From: vindexbit <92019484+vindexbit@users.noreply.github.com> Date: Thu, 25 Dec 2025 05:58:30 +0300 Subject: [PATCH 207/440] Fix issue dlang/dmd!21323 - DMD miscompiles real[1] (dlang/dmd!22303) --- tests/dmd/runnable/test_real_array_param.d | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/dmd/runnable/test_real_array_param.d diff --git a/tests/dmd/runnable/test_real_array_param.d b/tests/dmd/runnable/test_real_array_param.d new file mode 100644 index 0000000000..327cccc4af --- /dev/null +++ b/tests/dmd/runnable/test_real_array_param.d @@ -0,0 +1,16 @@ +void fn(int* x, real[1] arr) +{ + auto y = *x; // should not segfault + assert(y == 42, "x parameter corrupted"); + assert(arr[0] == 1.0, "arr (real[1]) corrupted"); +} + +void main() +{ + real[1] arr = [1.0]; + int x = 42; + fn(&x, arr); + + assert(x == 42, "x value corrupted"); + assert(arr[0] == 1.0, "arr (real[1]) value corrupted"); +} From 2b3b9dd7d5fd19efe79e6e06be2367d2bcebc3f6 Mon Sep 17 00:00:00 2001 From: Eugene 'Vindex' Stulin <92019484+vindexbit@users.noreply.github.com> Date: Fri, 26 Dec 2025 01:39:40 +0300 Subject: [PATCH 208/440] Fix issue dlang/dmd!20145 - Segfault wrt. implicit function => delegate conversion in static initializers (dlang/dmd!22307) --- tests/dmd/runnable/test_delegate_init_in_struct.d | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/dmd/runnable/test_delegate_init_in_struct.d diff --git a/tests/dmd/runnable/test_delegate_init_in_struct.d b/tests/dmd/runnable/test_delegate_init_in_struct.d new file mode 100644 index 0000000000..9e74d35b95 --- /dev/null +++ b/tests/dmd/runnable/test_delegate_init_in_struct.d @@ -0,0 +1,15 @@ +struct S +{ + string[] delegate() dg; +} + +S s = { + dg: () => ["hello"] // SEGFAULT without explicit `delegate` +}; + +void main() +{ + auto result = s.dg(); + assert(result.length == 1); + assert(result[0] == "hello"); +} From c3efedbeeaa692a1dbfc8b004a7b8f4d99e16021 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 26 Dec 2025 00:42:48 +0200 Subject: [PATCH 209/440] Remove call (dlang/dmd!22308) --- dmd/mtype.d | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dmd/mtype.d b/dmd/mtype.d index 9465d4e58c..b20d788b00 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -2520,8 +2520,7 @@ extern (C++) final class Parameter : ASTNode if (eparam is null) return 0; - Type t = eparam.type.toBasetype(); - if (auto tu = t.isTypeTuple()) + if (auto tu = eparam.type.isTypeTuple()) { // Check for empty tuples if (tu.arguments is null) From 6a8a65e95003db84ae4cade765a39c4b98ec6f27 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 26 Dec 2025 00:47:24 +0200 Subject: [PATCH 210/440] Remove `toBaseype` calls in `hdrgen` (dlang/dmd!22309) --- dmd/hdrgen.d | 5 +++-- dmd/mtype.d | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dmd/hdrgen.d b/dmd/hdrgen.d index 22d469b3c7..a5d9f0ff3f 100644 --- a/dmd/hdrgen.d +++ b/dmd/hdrgen.d @@ -3184,7 +3184,8 @@ void floatToBuffer(Type type, const real_t value, ref OutBuffer buf, const bool if (type) { - Type t = type.toBasetype(); + Type t = type.toBaseTypeNonSemantic(); + switch (t.ty) { case Tfloat32: @@ -4340,7 +4341,7 @@ private void typeToBufferx(Type t, ref OutBuffer buf, ref HdrGenState hgs) void visitDArray(TypeDArray t) { - auto basetype = t.next.toBasetype(); + auto basetype = t.next; if (hgs.declstring) goto L1; if (basetype.ty == Tchar && basetype.isImmutable()) diff --git a/dmd/mtype.d b/dmd/mtype.d index b20d788b00..dc594085e7 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -64,6 +64,17 @@ bool isImaginaryNonSemantic(Type _this) return false; } +Type toBaseTypeNonSemantic(Type _this) +{ + if (auto te = _this.isTypeEnum()) + { + if (!te.sym.members && !te.sym.memtype) + return te; + return te.sym.memtype.toBaseTypeNonSemantic(); + } + return _this; +} + /* Helper function for `typeToExpression`. Contains common code * for TypeQualified derived classes. */ From d6bdb5906b557473c463e612398e1be4563da03e Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 26 Dec 2025 01:42:42 +0200 Subject: [PATCH 211/440] Move `Type.addSTC` to `typesem` (dlang/dmd!22129) --- dmd/astcodegen.d | 3 +- dmd/cparse.d | 4 +-- dmd/mtype.d | 72 ------------------------------------------------ dmd/parse.d | 16 +++++------ dmd/typesem.d | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 83 deletions(-) diff --git a/dmd/astcodegen.d b/dmd/astcodegen.d index 53afd53de9..ae0c362917 100644 --- a/dmd/astcodegen.d +++ b/dmd/astcodegen.d @@ -33,8 +33,9 @@ struct ASTCodegen public import dmd.statement; public import dmd.staticassert; public import dmd.init : Designator; + public import dmd.typesem; - + alias addSTC = dmd.typesem.addSTC; alias initializerToExpression = dmd.initsem.initializerToExpression; alias typeToExpression = dmd.mtype.typeToExpression; alias UserAttributeDeclaration = dmd.attrib.UserAttributeDeclaration; diff --git a/dmd/cparse.d b/dmd/cparse.d index c55dbf75da..05f0edaa0c 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -4937,7 +4937,7 @@ final class CParser(AST) : Parser!AST // `const` is always applied to the return type, not the // type function itself. if (auto tf = t.isTypeFunction()) - tf.next = tf.next.addSTC(STC.const_); + tf.next = AST.addSTC(tf.next, STC.const_); else if (auto tt = t.isTypeTag()) tt.mod |= MODFlags.const_; else @@ -4946,7 +4946,7 @@ final class CParser(AST) : Parser!AST */ auto tn = t.nextOf(); if (!tn || tn.isConst()) - t = t.addSTC(STC.const_); + t = AST.addSTC(t, STC.const_); } return t; } diff --git a/dmd/mtype.d b/dmd/mtype.d index dc594085e7..1d9f732036 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -722,78 +722,6 @@ extern (C++) abstract class Type : ASTNode return t; } - /************************************* - * Apply STCxxxx bits to existing type. - * Use *before* semantic analysis is run. - */ - extern (D) final Type addSTC(STC stc) - { - Type t = this; - if (t.isImmutable()) - { - return t; - } - else if (stc & STC.immutable_) - { - t = t.makeImmutable(); - return t; - } - - if ((stc & STC.shared_) && !t.isShared()) - { - if (t.isWild()) - { - if (t.isConst()) - t = t.makeSharedWildConst(); - else - t = t.makeSharedWild(); - } - else - { - if (t.isConst()) - t = t.makeSharedConst(); - else - t = t.makeShared(); - } - } - if ((stc & STC.const_) && !t.isConst()) - { - if (t.isShared()) - { - if (t.isWild()) - t = t.makeSharedWildConst(); - else - t = t.makeSharedConst(); - } - else - { - if (t.isWild()) - t = t.makeWildConst(); - else - t = t.makeConst(); - } - } - if ((stc & STC.wild) && !t.isWild()) - { - if (t.isShared()) - { - if (t.isConst()) - t = t.makeSharedWildConst(); - else - t = t.makeSharedWild(); - } - else - { - if (t.isConst()) - t = t.makeWildConst(); - else - t = t.makeWild(); - } - } - - return t; - } - final bool hasDeprecatedAliasThis() { auto ad = isAggregate(this); diff --git a/dmd/parse.d b/dmd/parse.d index 846051487b..419b0ae8a8 100644 --- a/dmd/parse.d +++ b/dmd/parse.d @@ -2552,7 +2552,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer AST.Expression constraint = tpl ? parseConstraint() : null; AST.Type tf = new AST.TypeFunction(parameterList, null, linkage, stc); // ReturnType -> auto - tf = tf.addSTC(stc); + tf = AST.addSTC(tf, stc); auto f = new AST.CtorDeclaration(loc, Loc.initial, stc, tf); AST.Dsymbol s = parseContracts(f, !!tpl); @@ -3654,7 +3654,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer t = parseDeclarator(t, alt, pident, null); checkCstyleTypeSyntax(typeLoc, t, alt, pident ? *pident : null); - t = t.addSTC(stc); + t = AST.addSTC(t, stc); return t; } @@ -4095,7 +4095,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer if (save == TOK.function_) error("`const`/`immutable`/`shared`/`inout`/`return` attributes are only valid for non-static member functions"); else - tf = cast(AST.TypeFunction)tf.addSTC(stc); + tf = cast(AST.TypeFunction)AST.addSTC(tf, stc); } t = save == TOK.delegate_ ? new AST.TypeDelegate(tf) : new AST.TypePointer(tf); // pointer to function continue; @@ -4269,7 +4269,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer STC stc = parsePostfix(storageClass, pudas); AST.Type tf = new AST.TypeFunction(parameterList, t, linkage, stc); - tf = tf.addSTC(stc); + tf = AST.addSTC(tf, stc); if (pdisable) *pdisable = stc & STC.disable ? true : false; @@ -5280,7 +5280,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer } auto tf = new AST.TypeFunction(parameterList, tret, linkage, stc); - tf = cast(AST.TypeFunction)tf.addSTC(stc); + tf = cast(AST.TypeFunction)AST.addSTC(tf, stc); auto fd = new AST.FuncLiteralDeclaration(loc, Loc.initial, tf, save, null, null, stc & STC.auto_); if (token.value == TOK.goesTo) @@ -8849,7 +8849,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer else { AST.Type t = parseType(); // cast( type ) - t = t.addSTC(AST.ModToStc(m)); // cast( const type ) + t = AST.addSTC(t, AST.ModToStc(m)); // cast( const type ) check(TOK.rightParenthesis); e = parseUnaryExp(); e = new AST.CastExp(loc, e, t); @@ -8864,7 +8864,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer STC stc = parseTypeCtor(); AST.Type t = parseBasicType(); - t = t.addSTC(stc); + t = AST.addSTC(t, stc); if (stc == 0 && token.value == TOK.dot) { @@ -9636,7 +9636,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer const stc = parseTypeCtor(); auto t = parseBasicType(true); t = parseTypeSuffixes(t); - t = t.addSTC(stc); + t = AST.addSTC(t, stc); if (t.ty == Taarray) { AST.TypeAArray taa = cast(AST.TypeAArray)t; diff --git a/dmd/typesem.d b/dmd/typesem.d index 6f4c294ac4..a0c8f38407 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -67,6 +67,77 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; +/************************************* + * Apply STCxxxx bits to existing type. + * Use *before* semantic analysis is run. + */ +Type addSTC(Type _this, STC stc) +{ + Type t = _this; + if (t.isImmutable()) + { + return t; + } + else if (stc & STC.immutable_) + { + t = t.makeImmutable(); + return t; + } + + if ((stc & STC.shared_) && !t.isShared()) + { + if (t.isWild()) + { + if (t.isConst()) + t = t.makeSharedWildConst(); + else + t = t.makeSharedWild(); + } + else + { + if (t.isConst()) + t = t.makeSharedConst(); + else + t = t.makeShared(); + } + } + if ((stc & STC.const_) && !t.isConst()) + { + if (t.isShared()) + { + if (t.isWild()) + t = t.makeSharedWildConst(); + else + t = t.makeSharedConst(); + } + else + { + if (t.isWild()) + t = t.makeWildConst(); + else + t = t.makeConst(); + } + } + if ((stc & STC.wild) && !t.isWild()) + { + if (t.isShared()) + { + if (t.isConst()) + t = t.makeSharedWildConst(); + else + t = t.makeSharedWild(); + } + else + { + if (t.isConst()) + t = t.makeWildConst(); + else + t = t.makeWild(); + } + } + + return t; +} /*************************************************** * Determine if type t can be indexed or sliced given that it is not an From 14234783882f2b28e70bdec89374e26f6159da69 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 26 Dec 2025 01:44:52 +0200 Subject: [PATCH 212/440] Use toBaseNonSemantic instead of toBasetype in IntegerExp (dlang/dmd!22311) --- dmd/expression.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dmd/expression.d b/dmd/expression.d index 1f18802a8c..d7bbdbd3b0 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -516,7 +516,7 @@ extern (C++) final class IntegerExp : Expression assert(_isRoughlyScalar(type) || type.ty == Terror); this.type = type; - this.value = normalize(type.toBasetype().ty, value); + this.value = normalize(type.toBaseTypeNonSemantic().ty, value); } extern (D) this(dinteger_t value) @@ -543,7 +543,7 @@ extern (C++) final class IntegerExp : Expression extern (D) void setInteger(dinteger_t value) { - this.value = normalize(type.toBasetype().ty, value); + this.value = normalize(type.toBaseTypeNonSemantic().ty, value); } extern (D) static dinteger_t normalize(TY ty, dinteger_t value) From 97f7d84b10537e6c49239ae3b77c232ae423e5dd Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 26 Dec 2025 02:04:47 +0200 Subject: [PATCH 213/440] Move `Type.toBasetype` to `typesem` (dlang/dmd!22312) --- dmd/arrayop.d | 2 +- dmd/blockexit.d | 1 + dmd/builtin.d | 2 +- dmd/cxxfrontend.d | 6 ++++++ dmd/dfa/fast/expression.d | 1 + dmd/dfa/fast/statement.d | 1 + dmd/frontend.h | 1 - dmd/intrange.d | 2 +- dmd/mtype.d | 13 ------------- dmd/mtype.h | 2 +- dmd/nogc.d | 2 +- dmd/typesem.d | 14 ++++++++++++++ 12 files changed, 28 insertions(+), 19 deletions(-) diff --git a/dmd/arrayop.d b/dmd/arrayop.d index b73c18e17f..d052cd588f 100644 --- a/dmd/arrayop.d +++ b/dmd/arrayop.d @@ -30,7 +30,7 @@ import dmd.location; import dmd.mtype; import dmd.common.outbuffer; import dmd.tokens; -import dmd.typesem : isAssignable, nextOf; +import dmd.typesem : isAssignable, nextOf, toBasetype; import dmd.visitor; /********************************************** diff --git a/dmd/blockexit.d b/dmd/blockexit.d index aaf2517c93..3f06a24a31 100644 --- a/dmd/blockexit.d +++ b/dmd/blockexit.d @@ -21,6 +21,7 @@ import dmd.declaration; import dmd.errorsink; import dmd.expression; import dmd.expressionsem : toBool; +import dmd.typesem : toBasetype; import dmd.func; import dmd.globals; import dmd.id; diff --git a/dmd/builtin.d b/dmd/builtin.d index 3f814244e0..35c53d556e 100644 --- a/dmd/builtin.d +++ b/dmd/builtin.d @@ -18,7 +18,7 @@ import dmd.astenums; import dmd.errors; import dmd.expression; import dmd.expressionsem : toInteger, toReal; -import dmd.typesem : isFloating; +import dmd.typesem : isFloating, toBasetype; import dmd.func; import dmd.location; import dmd.mangle; diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index d346950f20..af78398d02 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -720,6 +720,12 @@ Type merge2(Type type) return dmd.typesem.merge2(type); } +Type toBasetype(Type type) +{ + import dmd.typesem; + return dmd.typesem.toBasetype(type); +} + Expression defaultInit(Type mt, Loc loc, const bool isCfile = false) { import dmd.typesem; diff --git a/dmd/dfa/fast/expression.d b/dmd/dfa/fast/expression.d index 0c349c3dd6..627e4e0628 100644 --- a/dmd/dfa/fast/expression.d +++ b/dmd/dfa/fast/expression.d @@ -18,6 +18,7 @@ import dmd.common.outbuffer; import dmd.location; import dmd.expression; import dmd.expressionsem; +import dmd.typesem; import dmd.astenums; import dmd.tokens; import dmd.func; diff --git a/dmd/dfa/fast/statement.d b/dmd/dfa/fast/statement.d index c382abfe0e..6875010ec3 100644 --- a/dmd/dfa/fast/statement.d +++ b/dmd/dfa/fast/statement.d @@ -22,6 +22,7 @@ import dmd.func; import dmd.identifier; import dmd.statement; import dmd.expression; +import dmd.typesem; import dmd.timetrace; import dmd.astenums; import dmd.mtype; diff --git a/dmd/frontend.h b/dmd/frontend.h index 02b4ae72af..f06f2044d6 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2082,7 +2082,6 @@ class Type : public ASTNode bool isNaked() const; Type* nullAttributes() const; bool hasDeprecatedAliasThis(); - Type* toBasetype(); virtual ClassDeclaration* isClassHandle(); virtual int32_t hasWild() const; virtual TypeBasic* isTypeBasic(); diff --git a/dmd/intrange.d b/dmd/intrange.d index 039cc9a205..9f4cd955bd 100644 --- a/dmd/intrange.d +++ b/dmd/intrange.d @@ -16,7 +16,7 @@ import core.stdc.stdio; import dmd.astenums : Tdchar; import dmd.mtype : Type; import dmd.globals : uinteger_t; -import dmd.typesem : isIntegral, isUnsigned, sizemask; +import dmd.typesem; private uinteger_t copySign(uinteger_t x, bool sign) @safe { diff --git a/dmd/mtype.d b/dmd/mtype.d index 1d9f732036..b77757b886 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -728,19 +728,6 @@ extern (C++) abstract class Type : ASTNode return ad && ad.aliasthis && (ad.aliasthis.isDeprecated || ad.aliasthis.sym.isDeprecated); } - /******************************* - * If this is a shell around another type, - * get that other type. - */ - final Type toBasetype() - { - /* This function is used heavily. - * De-virtualize it so it can be easily inlined. - */ - TypeEnum te; - return ((te = isTypeEnum()) !is null) ? te.toBasetype2() : this; - } - inout(ClassDeclaration) isClassHandle() inout { return null; diff --git a/dmd/mtype.h b/dmd/mtype.h index 1bb65a36e9..f3c81d8040 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -241,7 +241,6 @@ class Type : public ASTNode bool isNaked() const { return mod == 0; } Type *nullAttributes() const; bool hasDeprecatedAliasThis(); - Type *toBasetype(); virtual ClassDeclaration *isClassHandle(); virtual int hasWild() const; @@ -734,6 +733,7 @@ namespace dmd Type *addMod(Type *type, MOD mod); Type *addStorageClass(Type *type, StorageClass stc); Type *substWildTo(Type *type, unsigned mod); + Type *toBasetype(Type *type); uinteger_t size(Type *type); uinteger_t size(Type *type, Loc loc); MATCH implicitConvTo(Type* from, Type* to); diff --git a/dmd/nogc.d b/dmd/nogc.d index 5ac90e2f89..3221f55107 100644 --- a/dmd/nogc.d +++ b/dmd/nogc.d @@ -40,7 +40,7 @@ import dmd.rootobject : RootObject, DYNCAST; import dmd.semantic2; import dmd.semantic3; import dmd.tokens; -import dmd.typesem : unqualify; +import dmd.typesem : unqualify, toBasetype; import dmd.visitor; import dmd.visitor.postorder; diff --git a/dmd/typesem.d b/dmd/typesem.d index a0c8f38407..f1567a1963 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -1127,6 +1127,20 @@ Type makeConst(Type _this) return defaultMakeConst(_this); } +/******************************* + * If _this is a shell around another type, + * get that other type. + */ +Type toBasetype(Type _this) +{ + /* This function is used heavily. + * De-virtualize it so it can be easily inlined. + */ + if (auto te = _this.isTypeEnum()) + return te.toBasetype2(); + return _this; +} + Type toBasetype2(TypeEnum _this) { if (!_this.sym.members && !_this.sym.memtype) From c612bc58111db06db293283695d54b44ebe968a7 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Fri, 26 Dec 2025 05:08:55 +0200 Subject: [PATCH 214/440] Break semantic dependency of `mtype` on `typesem` (dlang/dmd!22313) --- dmd/cxxfrontend.d | 6 ++++++ dmd/frontend.h | 1 - dmd/mtype.d | 7 ------- dmd/mtype.h | 2 +- dmd/typesem.d | 6 ++++++ 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index af78398d02..caca78c050 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -684,6 +684,12 @@ bool tpsemantic(TemplateParameter tp, Scope* sc, TemplateParameters* parameters) /*********************************************************** * typesem.d */ +bool hasDeprecatedAliasThis(Type type) +{ + import dmd.typesem; + return dmd.typesem.hasDeprecatedAliasThis(type); +} + AggregateDeclaration isAggregate(Type t) { import dmd.typesem; diff --git a/dmd/frontend.h b/dmd/frontend.h index f06f2044d6..a2a6d35ec2 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2081,7 +2081,6 @@ class Type : public ASTNode bool isSharedWild() const; bool isNaked() const; Type* nullAttributes() const; - bool hasDeprecatedAliasThis(); virtual ClassDeclaration* isClassHandle(); virtual int32_t hasWild() const; virtual TypeBasic* isTypeBasic(); diff --git a/dmd/mtype.d b/dmd/mtype.d index b77757b886..e568ebda56 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -37,7 +37,6 @@ import dmd.root.rmem; import dmd.rootobject; import dmd.root.stringtable; import dmd.tokens; -import dmd.typesem; import dmd.visitor; enum LOGDOTEXP = 0; // log ::dotExp() @@ -722,12 +721,6 @@ extern (C++) abstract class Type : ASTNode return t; } - final bool hasDeprecatedAliasThis() - { - auto ad = isAggregate(this); - return ad && ad.aliasthis && (ad.aliasthis.isDeprecated || ad.aliasthis.sym.isDeprecated); - } - inout(ClassDeclaration) isClassHandle() inout { return null; diff --git a/dmd/mtype.h b/dmd/mtype.h index f3c81d8040..86e9425268 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -240,7 +240,6 @@ class Type : public ASTNode bool isSharedWild() const { return (mod & (MODshared | MODwild)) == (MODshared | MODwild); } bool isNaked() const { return mod == 0; } Type *nullAttributes() const; - bool hasDeprecatedAliasThis(); virtual ClassDeclaration *isClassHandle(); virtual int hasWild() const; @@ -771,4 +770,5 @@ namespace dmd bool needsNested(Type* type); bool needsDestruction(Type* type); bool needsCopyOrPostblit(Type* type); + bool hasDeprecatedAliasThis(Type* type); } diff --git a/dmd/typesem.d b/dmd/typesem.d index f1567a1963..606e38e603 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -67,6 +67,12 @@ import dmd.sideeffect; import dmd.target; import dmd.tokens; +bool hasDeprecatedAliasThis(Type _this) +{ + auto ad = isAggregate(_this); + return ad && ad.aliasthis && (ad.aliasthis.isDeprecated || ad.aliasthis.sym.isDeprecated); +} + /************************************* * Apply STCxxxx bits to existing type. * Use *before* semantic analysis is run. From 15643bf4951992ed99748db94d7312cf1b5a19b6 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 27 Dec 2025 00:39:45 +0200 Subject: [PATCH 215/440] Break dependency of dmodule on opover (dlang/dmd!22318) --- dmd/cxxfrontend.d | 14 ++++++-------- dmd/dmodule.d | 32 -------------------------------- dmd/dsymbolsem.d | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 40 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index caca78c050..1b52042e8f 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -113,14 +113,6 @@ void mangleToBuffer(TemplateInstance ti, ref OutBuffer buf) return dmd.mangle.mangleToBuffer(ti, buf); } -/*********************************************************** - * dmodule.d - */ -FuncDeclaration findGetMembers(ScopeDsymbol dsym) -{ - return dmd.dmodule.findGetMembers(dsym); -} - /*********************************************************** * doc.d */ @@ -311,6 +303,12 @@ Dsymbol search(Scope* sc, Loc loc, Identifier ident, out Dsymbol pscopesym, return dmd.dsymbolsem.search(sc, loc, ident, pscopesym, flags); } +FuncDeclaration findGetMembers(ScopeDsymbol dsym) +{ + import dmd.dsymbolsem; + return dmd.dsymbolsem.findGetMembers(dsym); +} + /*********************************************************** * dtemplate.d */ diff --git a/dmd/dmodule.d b/dmd/dmodule.d index e6ee54879d..9b99718700 100644 --- a/dmd/dmodule.d +++ b/dmd/dmodule.d @@ -1261,35 +1261,3 @@ private const(char)[] processSource (const(ubyte)[] src, Module mod) return buf; } - -/******************************************* - * Look for member of the form: - * const(MemberInfo)[] getMembers(string); - * Returns NULL if not found - */ -FuncDeclaration findGetMembers(ScopeDsymbol dsym) -{ - import dmd.opover : search_function; - Dsymbol s = search_function(dsym, Id.getmembers); - FuncDeclaration fdx = s ? s.isFuncDeclaration() : null; - version (none) - { - // Finish - __gshared TypeFunction tfgetmembers; - if (!tfgetmembers) - { - Scope sc; - sc.eSink = global.errorSink; - Parameters* p = new Parameter(STC.in_, Type.tchar.constOf().arrayOf(), null, null); - auto parameters = new Parameters(p); - Type tret = null; - TypeFunction tf = new TypeFunction(parameters, tret, VarArg.none, LINK.d); - tfgetmembers = tf.dsymbolSemantic(Loc.initial, &sc).isTypeFunction(); - } - if (fdx) - fdx = fdx.overloadExactMatch(tfgetmembers); - } - if (fdx && fdx.isVirtual()) - fdx = null; - return fdx; -} diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 95b92024ff..a145c75373 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -83,6 +83,38 @@ import dmd.visitor; enum LOG = false; +/******************************************* + * Look for member of the form: + * const(MemberInfo)[] getMembers(string); + * Returns NULL if not found + */ +FuncDeclaration findGetMembers(ScopeDsymbol dsym) +{ + import dmd.opover : search_function; + Dsymbol s = search_function(dsym, Id.getmembers); + FuncDeclaration fdx = s ? s.isFuncDeclaration() : null; + version (none) + { + // Finish + __gshared TypeFunction tfgetmembers; + if (!tfgetmembers) + { + Scope sc; + sc.eSink = global.errorSink; + Parameters* p = new Parameter(STC.in_, Type.tchar.constOf().arrayOf(), null, null); + auto parameters = new Parameters(p); + Type tret = null; + TypeFunction tf = new TypeFunction(parameters, tret, VarArg.none, LINK.d); + tfgetmembers = tf.dsymbolSemantic(Loc.initial, &sc).isTypeFunction(); + } + if (fdx) + fdx = fdx.overloadExactMatch(tfgetmembers); + } + if (fdx && fdx.isVirtual()) + fdx = null; + return fdx; +} + /*********************************** * Retrieve the .min or .max values. * Only valid after semantic analysis. From f5fbccfc19a437f1d2bf47820b0a248a17a64c91 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 27 Dec 2025 01:46:24 +0200 Subject: [PATCH 216/440] Break dependency of `dscope` on `importc` and `target` (dlang/dmd!22317) --- dmd/dscope.d | 91 --------------------------------------------- dmd/dsymbolsem.d | 83 +++++++++++++++++++++++++++++++++++++++++ dmd/expressionsem.d | 2 +- dmd/mtype.d | 1 - dmd/typesem.d | 2 +- 5 files changed, 85 insertions(+), 94 deletions(-) diff --git a/dmd/dscope.d b/dmd/dscope.d index 9edf2590db..cdec3218b0 100644 --- a/dmd/dscope.d +++ b/dmd/dscope.d @@ -16,7 +16,6 @@ module dmd.dscope; import core.stdc.stdio; import core.stdc.string; import dmd.aggregate; -import dmd.arraytypes; import dmd.astenums; import dmd.attrib; import dmd.ctorflow; @@ -27,20 +26,12 @@ import dmd.doc; import dmd.dstruct; import dmd.dsymbol; import dmd.dtemplate; -import dmd.expression; -import dmd.errors; import dmd.errorsink; import dmd.func; import dmd.globals; -import dmd.id; import dmd.identifier; -import dmd.importc; -import dmd.location; -import dmd.common.outbuffer; import dmd.root.rmem; import dmd.statement; -import dmd.target; -import dmd.tokens; //version=LOGSEARCH; @@ -361,33 +352,6 @@ extern (C++) struct Scope return pop(); } - /************************************ - * Maybe `ident` was a C or C++ name. Check for that, - * and suggest the D equivalent. - * Params: - * ident = unknown identifier - * Returns: - * D identifier string if found, null if not - */ - extern (D) static const(char)* search_correct_C(Identifier ident) - { - import dmd.astenums : Twchar; - TOK tok; - if (ident == Id.NULL) - tok = TOK.null_; - else if (ident == Id.TRUE) - tok = TOK.true_; - else if (ident == Id.FALSE) - tok = TOK.false_; - else if (ident == Id.unsigned) - tok = TOK.uns32; - else if (ident == Id.wchar_t) - tok = target.c.wchar_tsize == 2 ? TOK.wchar_ : TOK.dchar_; - else - return null; - return Token.toChars(tok); - } - /*************************** * Find the innermost scope with a symbol table. * Returns: @@ -403,61 +367,6 @@ extern (C++) struct Scope return null; } - /****************************** - * Add symbol s to innermost symbol table. - * Params: - * s = symbol to insert - * Returns: - * null if already in table, `s` if not - */ - extern (D) Dsymbol insert(Dsymbol s) - { - //printf("insert() %s\n", s.toChars()); - if (VarDeclaration vd = s.isVarDeclaration()) - { - if (lastVar) - vd.lastVar = lastVar; - lastVar = vd; - } - else if (WithScopeSymbol ss = s.isWithScopeSymbol()) - { - if (VarDeclaration vd = ss.withstate.wthis) - { - if (lastVar) - vd.lastVar = lastVar; - lastVar = vd; - } - return null; - } - - auto scopesym = inner().scopesym; - //printf("\t\tscopesym = %p\n", scopesym); - if (!scopesym.symtab) - scopesym.symtab = new DsymbolTable(); - if (!this.inCfile) - return scopesym.symtabInsert(s); - - // ImportC insert - if (!scopesym.symtabInsert(s)) // if already in table - { - Dsymbol s2 = scopesym.symtabLookup(s, s.ident); // s2 is existing entry - - auto svar = s.isVarDeclaration(); - auto s2var = s2.isVarDeclaration(); - if (((svar && svar.storage_class & STC.extern_) && - (s2var && s2var.storage_class & STC.extern_) && this.func) || - s.isFuncDeclaration()) - { - return handleSymbolRedeclarations(this, s, s2, scopesym); - } - else // aside externs and func decls, we should be free to handle tags - { - return handleTagSymbols(this, s, s2, scopesym); - } - } - return s; // inserted - } - /******************************************** * Search enclosing scopes for ScopeDsymbol. */ diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index a145c75373..69493dd7c6 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -83,6 +83,89 @@ import dmd.visitor; enum LOG = false; +/************************************ + * Maybe `ident` was a C or C++ name. Check for that, + * and suggest the D equivalent. + * Params: + * ident = unknown identifier + * Returns: + * D identifier string if found, null if not + */ +const(char)* search_correct_C(Identifier ident) +{ + import dmd.astenums : Twchar; + TOK tok; + if (ident == Id.NULL) + tok = TOK.null_; + else if (ident == Id.TRUE) + tok = TOK.true_; + else if (ident == Id.FALSE) + tok = TOK.false_; + else if (ident == Id.unsigned) + tok = TOK.uns32; + else if (ident == Id.wchar_t) + tok = target.c.wchar_tsize == 2 ? TOK.wchar_ : TOK.dchar_; + else + return null; + return Token.toChars(tok); +} + +/****************************** + * Add symbol s to innermost symbol table. + * Params: + * _this = scope object + * s = symbol to insert + * Returns: + * null if already in table, `s` if not + */ +Dsymbol insert(Scope* _this, Dsymbol s) +{ + //printf("insert() %s\n", s.toChars()); + if (VarDeclaration vd = s.isVarDeclaration()) + { + if (_this.lastVar) + vd.lastVar = _this.lastVar; + _this.lastVar = vd; + } + else if (WithScopeSymbol ss = s.isWithScopeSymbol()) + { + if (VarDeclaration vd = ss.withstate.wthis) + { + if (_this.lastVar) + vd.lastVar = _this.lastVar; + _this.lastVar = vd; + } + return null; + } + + auto scopesym = _this.inner().scopesym; + //printf("\t\tscopesym = %p\n", scopesym); + if (!scopesym.symtab) + scopesym.symtab = new DsymbolTable(); + if (!_this.inCfile) + return scopesym.symtabInsert(s); + + // ImportC insert + if (!scopesym.symtabInsert(s)) // if already in table + { + Dsymbol s2 = scopesym.symtabLookup(s, s.ident); // s2 is existing entry + + auto svar = s.isVarDeclaration(); + auto s2var = s2.isVarDeclaration(); + if (((svar && svar.storage_class & STC.extern_) && + (s2var && s2var.storage_class & STC.extern_) && _this.func) || + s.isFuncDeclaration()) + { + return handleSymbolRedeclarations(*_this, s, s2, scopesym); + } + else // aside externs and func decls, we should be free to handle tags + { + return handleTagSymbols(*_this, s, s2, scopesym); + } + } + return s; // inserted +} + /******************************************* * Look for member of the form: * const(MemberInfo)[] getMembers(string); diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 05b3256a64..10432b7580 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -5566,7 +5566,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor error(exp.loc, "`%s` is not defined, perhaps `import %.*s;` is needed?", exp.ident.toChars(), cast(int)n.length, n.ptr); else if (auto s2 = sc.search_correct(exp.ident)) error(exp.loc, "undefined identifier `%s`, did you mean %s `%s`?", exp.ident.toChars(), s2.kind(), s2.toChars()); - else if (const p = Scope.search_correct_C(exp.ident)) + else if (const p = search_correct_C(exp.ident)) error(exp.loc, "undefined identifier `%s`, did you mean `%s`?", exp.ident.toChars(), p); else if (exp.ident == Id.dollar) error(exp.loc, "undefined identifier `$`"); diff --git a/dmd/mtype.d b/dmd/mtype.d index e568ebda56..d562c103d0 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -17,7 +17,6 @@ import core.stdc.stdio; import core.stdc.stdlib; import core.stdc.string; -import dmd.aggregate; import dmd.arraytypes; import dmd.astenums; import dmd.ast_node; diff --git a/dmd/typesem.d b/dmd/typesem.d index 606e38e603..5ea3327c3a 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -1517,7 +1517,7 @@ private void resolveHelper(TypeQualified mt, Loc loc, Scope* sc, Dsymbol s, Dsym error(loc, "`%s` is not defined, perhaps `import %.*s;` ?", p, cast(int)n.length, n.ptr); else if (auto s2 = sc.search_correct(id)) error(loc, "undefined identifier `%s`, did you mean %s `%s`?", p, s2.kind(), s2.toChars()); - else if (const q = Scope.search_correct_C(id)) + else if (const q = search_correct_C(id)) error(loc, "undefined identifier `%s`, did you mean `%s`?", p, q); else if ((id == Id.This && sc.getStructClassScope()) || (id == Id._super && sc.getClassScope())) From 6c26b5249e01511677bde9f2c7ed2bd98236a339 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 27 Dec 2025 01:47:42 +0200 Subject: [PATCH 217/440] Break dependency of `attrib` on `objc` (dlang/dmd!22319) --- dmd/aggregate.h | 2 -- dmd/attrib.d | 8 -------- dmd/cxxfrontend.d | 6 ++++++ dmd/dclass.d | 7 ------- dmd/dsymbol.d | 4 ---- dmd/dsymbol.h | 2 +- dmd/dsymbolsem.d | 8 ++++++++ dmd/frontend.h | 3 --- 8 files changed, 15 insertions(+), 25 deletions(-) diff --git a/dmd/aggregate.h b/dmd/aggregate.h index 3fbf4cc470..2a4c6cc1a0 100644 --- a/dmd/aggregate.h +++ b/dmd/aggregate.h @@ -288,8 +288,6 @@ class ClassDeclaration : public AggregateDeclaration virtual int vtblOffset() const; const char *kind() const override; - void addObjcSymbols(ClassDeclarations *classes, ClassDeclarations *categories) override final; - // Back end Dsymbol *vtblsym; diff --git a/dmd/attrib.d b/dmd/attrib.d index 1a429dccfc..8c2202358c 100644 --- a/dmd/attrib.d +++ b/dmd/attrib.d @@ -35,7 +35,6 @@ import dmd.hdrgen : visibilityToBuffer; import dmd.id; import dmd.identifier; import dmd.location; -import dmd.objc; // for objc.addSymbols import dmd.common.outbuffer; import dmd.visitor; @@ -103,13 +102,6 @@ extern (C++) abstract class AttribDeclaration : Dsymbol return "attribute"; } - /**************************************** - */ - override final void addObjcSymbols(ClassDeclarations* classes, ClassDeclarations* categories) - { - objc.addSymbols(this, classes, categories); - } - override void accept(Visitor v) { v.visit(this); diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 1b52042e8f..b203cf83e5 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -303,6 +303,12 @@ Dsymbol search(Scope* sc, Loc loc, Identifier ident, out Dsymbol pscopesym, return dmd.dsymbolsem.search(sc, loc, ident, pscopesym, flags); } +void addObjcSymbols(Dsymbol sym, ClassDeclarations* classes, ClassDeclarations* categories) +{ + import dmd.dsymbolsem; + return dmd.dsymbolsem.addObjcSymbols(sym, classes, categories); +} + FuncDeclaration findGetMembers(ScopeDsymbol dsym) { import dmd.dsymbolsem; diff --git a/dmd/dclass.d b/dmd/dclass.d index 0b27fae02d..60bd170d5c 100644 --- a/dmd/dclass.d +++ b/dmd/dclass.d @@ -398,13 +398,6 @@ extern (C++) class ClassDeclaration : AggregateDeclaration return "class"; } - /**************************************** - */ - override final void addObjcSymbols(ClassDeclarations* classes, ClassDeclarations* categories) - { - .objc.addSymbols(this, classes, categories); - } - // Back end Dsymbol vtblsym; diff --git a/dmd/dsymbol.d b/dmd/dsymbol.d index 7eaba6e0cd..640eda90e5 100644 --- a/dmd/dsymbol.d +++ b/dmd/dsymbol.d @@ -765,10 +765,6 @@ extern (C++) class Dsymbol : ASTNode assert(0); } - void addObjcSymbols(ClassDeclarations* classes, ClassDeclarations* categories) - { - } - /**************************************** * Add documentation comment to Dsymbol. * Ignore NULL comments. diff --git a/dmd/dsymbol.h b/dmd/dsymbol.h index fdf1aa60f5..b4ca8f5056 100644 --- a/dmd/dsymbol.h +++ b/dmd/dsymbol.h @@ -241,7 +241,6 @@ class Dsymbol : public ASTNode virtual bool needThis(); // need a 'this' pointer? virtual Visibility visible(); virtual Dsymbol *syntaxCopy(Dsymbol *s); // copy only syntax trees - virtual void addObjcSymbols(ClassDeclarations *, ClassDeclarations *) { } virtual void addComment(const utf8_t *comment); const utf8_t *comment(); // current value of comment @@ -437,4 +436,5 @@ namespace dmd void runDeferredSemantic3(); bool isOverlappedWith(VarDeclaration *vd, VarDeclaration *v); Dsymbol* search(Scope *sc, Loc loc, Identifier* ident, Dsymbol*& pscopesym, uint32_t flags = 0u); + void addObjcSymbols(Dsymbol *s, ClassDeclarations *, ClassDeclarations *); } diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 69493dd7c6..633fd6ff68 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -83,6 +83,14 @@ import dmd.visitor; enum LOG = false; +void addObjcSymbols(Dsymbol _this, ClassDeclarations* classes, ClassDeclarations* categories) +{ + if (auto ad = _this.isAttribDeclaration()) + objc.addSymbols(ad, classes, categories); + else if (auto cd = _this.isClassDeclaration()) + objc.addSymbols(cd, classes, categories); +} + /************************************ * Maybe `ident` was a C or C++ name. Check for that, * and suggest the D equivalent. diff --git a/dmd/frontend.h b/dmd/frontend.h index a2a6d35ec2..12927b1b8c 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -615,7 +615,6 @@ class Dsymbol : public ASTNode virtual bool needThis(); virtual Visibility visible(); virtual Dsymbol* syntaxCopy(Dsymbol* s); - virtual void addObjcSymbols(Array* classes, Array* categories); virtual void addComment(const char* comment); const char* comment(); void comment(const char* comment); @@ -6228,7 +6227,6 @@ class AttribDeclaration : public Dsymbol public: Array* decl; const char* kind() const override; - void addObjcSymbols(Array* classes, Array* categories) final override; void accept(Visitor* v) override; }; @@ -6514,7 +6512,6 @@ class ClassDeclaration : public AggregateDeclaration virtual bool isCPPinterface() const; virtual int32_t vtblOffset() const; const char* kind() const override; - void addObjcSymbols(Array* classes, Array* categories) final override; Dsymbol* vtblsym; void accept(Visitor* v) override; }; From df84027b9f9f2901a1308c5da1f11425e4a60dd5 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 27 Dec 2025 03:31:03 +0200 Subject: [PATCH 218/440] Break dependency of `dclass` on `target` (dlang/dmd!22320) --- dmd/aggregate.d | 18 ---------------- dmd/aggregate.h | 3 --- dmd/cxxfrontend.d | 9 +++++++- dmd/dclass.d | 27 ------------------------ dmd/dsymbol.h | 1 + dmd/dsymbolsem.d | 52 +++++++++++++++++++++++++++++++++++++++++++++++ dmd/frontend.h | 7 ++----- 7 files changed, 63 insertions(+), 54 deletions(-) diff --git a/dmd/aggregate.d b/dmd/aggregate.d index 794ececb03..a29ae0334a 100644 --- a/dmd/aggregate.d +++ b/dmd/aggregate.d @@ -152,24 +152,6 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol visibility = Visibility(Visibility.Kind.public_); } - /*************************************** - * Create a new scope from sc. - * semantic, semantic2 and semantic3 will use this for aggregate members. - */ - Scope* newScope(Scope* sc) - { - auto sc2 = sc.push(this); - sc2.stc &= STC.flowThruAggregate; - sc2.parent = this; - sc2.inunion = isUnionDeclaration(); - sc2.visibility = Visibility(Visibility.Kind.public_); - sc2.explicitVisibility = false; - sc2.aligndecl = null; - sc2.userAttribDecl = null; - sc2.namespace = null; - return sc2; - } - /*************************************** * Returns: * The total number of fields minus the number of hidden fields. diff --git a/dmd/aggregate.h b/dmd/aggregate.h index 2a4c6cc1a0..c1fdf761df 100644 --- a/dmd/aggregate.h +++ b/dmd/aggregate.h @@ -121,7 +121,6 @@ class AggregateDeclaration : public ScopeDsymbol d_bool disableNew; // disallow allocations using `new` Sizeok sizeok; // set when structsize contains valid data - virtual Scope *newScope(Scope *sc); bool isDeprecated() const override final; // is aggregate deprecated? bool isNested() const; bool isExport() const override final; @@ -273,7 +272,6 @@ class ClassDeclaration : public AggregateDeclaration static ClassDeclaration *create(Loc loc, Identifier *id, BaseClasses *baseclasses, Dsymbols *members, bool inObject); const char *toPrettyChars(bool QualifyTypes = false) override; ClassDeclaration *syntaxCopy(Dsymbol *s) override; - Scope *newScope(Scope *sc) override; #define OFFSET_RUNTIME 0x76543210 #define OFFSET_FWDREF 0x76543211 @@ -298,7 +296,6 @@ class InterfaceDeclaration final : public ClassDeclaration { public: InterfaceDeclaration *syntaxCopy(Dsymbol *s) override; - Scope *newScope(Scope *sc) override; bool isBaseOf(ClassDeclaration *cd, int *poffset) override; const char *kind() const override; int vtblOffset() const override; diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index b203cf83e5..eb25405efb 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -291,11 +291,18 @@ void runDeferredSemantic3() return dmd.dsymbolsem.runDeferredSemantic3(); } -bool isOverlappedWith(VarDeclaration vd, VarDeclaration v){ +bool isOverlappedWith(VarDeclaration vd, VarDeclaration v) +{ import dmd.dsymbolsem; return dmd.dsymbolsem.isOverlappedWith(vd, v); } +Scope* newScope(AggregateDeclaration ad, Scope* sc) +{ + import dmd.dsymbolsem; + return dmd.dsymbolsem.newScope(ad, sc); +} + Dsymbol search(Scope* sc, Loc loc, Identifier ident, out Dsymbol pscopesym, SearchOptFlags flags = SearchOpt.all) { diff --git a/dmd/dclass.d b/dmd/dclass.d index 60bd170d5c..dcbad395d9 100644 --- a/dmd/dclass.d +++ b/dmd/dclass.d @@ -30,7 +30,6 @@ import dmd.location; import dmd.mtype; import dmd.objc; import dmd.root.rmem; -import dmd.target; import dmd.visitor; /*********************************************************** @@ -261,19 +260,6 @@ extern (C++) class ClassDeclaration : AggregateDeclaration return cd; } - override Scope* newScope(Scope* sc) - { - auto sc2 = super.newScope(sc); - if (isCOMclass()) - { - /* This enables us to use COM objects under Linux and - * work with things like XPCOM - */ - sc2.linkage = target.systemLinkage(); - } - return sc2; - } - /********************************************* * Determine if 'this' is a base class of cd. * This is used to detect circular inheritance only. @@ -436,19 +422,6 @@ extern (C++) final class InterfaceDeclaration : ClassDeclaration return id; } - - override Scope* newScope(Scope* sc) - { - auto sc2 = super.newScope(sc); - if (com) - sc2.linkage = LINK.windows; - else if (classKind == ClassKind.cpp) - sc2.linkage = LINK.cpp; - else if (classKind == ClassKind.objc) - sc2.linkage = LINK.objc; - return sc2; - } - /******************************************* * Determine if 'this' is a base class of cd. * (Actually, if it is an interface supported by cd) diff --git a/dmd/dsymbol.h b/dmd/dsymbol.h index b4ca8f5056..a22a93c53c 100644 --- a/dmd/dsymbol.h +++ b/dmd/dsymbol.h @@ -436,5 +436,6 @@ namespace dmd void runDeferredSemantic3(); bool isOverlappedWith(VarDeclaration *vd, VarDeclaration *v); Dsymbol* search(Scope *sc, Loc loc, Identifier* ident, Dsymbol*& pscopesym, uint32_t flags = 0u); + Scope *newScope(AggregateDeclaration * ad, Scope *sc); void addObjcSymbols(Dsymbol *s, ClassDeclarations *, ClassDeclarations *); } diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 633fd6ff68..eb7620da72 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -83,6 +83,58 @@ import dmd.visitor; enum LOG = false; +/*************************************** + * Create a new scope from sc. + * semantic, semantic2 and semantic3 will use this for aggregate members. + */ +Scope* newScope(AggregateDeclaration _this, Scope* sc) +{ + static Scope* defaultNewScope(AggregateDeclaration _this, Scope* sc) + { + auto sc2 = sc.push(_this); + sc2.stc &= STC.flowThruAggregate; + sc2.parent = _this; + sc2.inunion = _this.isUnionDeclaration(); + sc2.visibility = Visibility(Visibility.Kind.public_); + sc2.explicitVisibility = false; + sc2.aligndecl = null; + sc2.userAttribDecl = null; + sc2.namespace = null; + return sc2; + } + + static Scope* classNewScope(ClassDeclaration _this, Scope* sc) + { + auto sc2 = defaultNewScope(_this, sc); + if (_this.isCOMclass()) + { + /* This enables us to use COM objects under Linux and + * work with things like XPCOM + */ + sc2.linkage = target.systemLinkage(); + } + return sc2; + } + + static Scope* interfaceNewScope(InterfaceDeclaration _this, Scope* sc) + { + auto sc2 = classNewScope(_this, sc); + if (_this.com) + sc2.linkage = LINK.windows; + else if (_this.classKind == ClassKind.cpp) + sc2.linkage = LINK.cpp; + else if (_this.classKind == ClassKind.objc) + sc2.linkage = LINK.objc; + return sc2; + } + + if (auto _id = _this.isInterfaceDeclaration()) + return interfaceNewScope(_id, sc); + else if (auto cd = _this.isClassDeclaration()) + return classNewScope(cd, sc); + return defaultNewScope(_this, sc); +} + void addObjcSymbols(Dsymbol _this, ClassDeclarations* classes, ClassDeclarations* categories) { if (auto ad = _this.isAttribDeclaration()) diff --git a/dmd/frontend.h b/dmd/frontend.h index 12927b1b8c..1fee00408f 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -50,8 +50,6 @@ class AggregateDeclaration; class LabelDsymbol; class ClassDeclaration; class Package; -template -struct Array; class UnitTestDeclaration; class EnumMember; class TemplateDeclaration; @@ -102,6 +100,8 @@ class MixinDeclaration; class StaticAssert; class StaticIfDeclaration; class CAsmDeclaration; +template +struct Array; class DsymbolTable; class Type; struct MangleOverride; @@ -6156,7 +6156,6 @@ class AggregateDeclaration : public ScopeDsymbol bool noDefaultCtor; bool disableNew; Sizeok sizeok; - virtual Scope* newScope(Scope* sc); bool isDeprecated() const final override; bool isNested() const; bool isExport() const final override; @@ -6498,7 +6497,6 @@ class ClassDeclaration : public AggregateDeclaration static ClassDeclaration* create(Loc loc, Identifier* id, Array* baseclasses, Array* members, bool inObject); const char* toPrettyChars(bool qualifyTypes = false) override; ClassDeclaration* syntaxCopy(Dsymbol* s) override; - Scope* newScope(Scope* sc) override; enum : int32_t { OFFSET_RUNTIME = 1985229328 }; enum : int32_t { OFFSET_FWDREF = 1985229329 }; @@ -6520,7 +6518,6 @@ class InterfaceDeclaration final : public ClassDeclaration { public: InterfaceDeclaration* syntaxCopy(Dsymbol* s) override; - Scope* newScope(Scope* sc) override; bool isBaseOf(ClassDeclaration* cd, int32_t* poffset) override; const char* kind() const override; int32_t vtblOffset() const override; From 13e06261f32e7696de2554a3ce4875d977fc196a Mon Sep 17 00:00:00 2001 From: Eugene 'Vindex' Stulin <92019484+vindexbit@users.noreply.github.com> Date: Sat, 27 Dec 2025 15:31:18 +0300 Subject: [PATCH 219/440] Fix dlang/dmd!19163 - ICE with delegate in UDA (dlang/dmd!22316) --- tests/dmd/compilable/issue19163.d | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/dmd/compilable/issue19163.d diff --git a/tests/dmd/compilable/issue19163.d b/tests/dmd/compilable/issue19163.d new file mode 100644 index 0000000000..26c1c44932 --- /dev/null +++ b/tests/dmd/compilable/issue19163.d @@ -0,0 +1,20 @@ +struct NameAttribute +{ + int delegate() foo; +} + +static NameAttribute getNamedAttribute(alias S)() +{ + return __traits(getAttributes, S)[0]; +} + +struct TestStruct +{ + @NameAttribute({ return 42; }) int a; +} + +void test() +{ + TestStruct m; + enum nameAttr = getNamedAttribute!(m.a); +} From e50f9eae46c21c7d9b94360ce4e31fe3526a08d2 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Mon, 29 Dec 2025 17:51:40 +0800 Subject: [PATCH 220/440] Ensure contracts are run on the returned object (dlang/dmd!22203) --- dmd/funcsem.d | 2 ++ dmd/semantic3.d | 6 +++++- tests/dmd/runnable/test28.d | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dmd/funcsem.d b/dmd/funcsem.d index 2241fea4f4..d4e660ce66 100644 --- a/dmd/funcsem.d +++ b/dmd/funcsem.d @@ -2593,6 +2593,8 @@ void buildResultVar(FuncDeclaration fd, Scope* sc, Type tret) TypeFunction tf = fd.type.toTypeFunction(); if (tf.isRef) fd.vresult.storage_class |= STC.ref_; + else if (target.isReturnOnStack(tf, fd.needThis())) + fd.vresult.nrvo = true; fd.vresult.type = tret; fd.vresult.dsymbolSemantic(sc); if (!sc.insert(fd.vresult)) diff --git a/dmd/semantic3.d b/dmd/semantic3.d index daaaec19c6..b55eb37429 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -969,7 +969,11 @@ private extern(C++) final class Semantic3Visitor : Visitor if (funcdecl.vresult) { // Create: return vresult = exp; - exp = new BlitExp(rs.loc, funcdecl.vresult, exp); + if (canElideCopy(exp, funcdecl.vresult.type, false)) + exp = new ConstructExp(rs.loc, funcdecl.vresult, exp); + else + exp = new BlitExp(rs.loc, funcdecl.vresult, exp); + exp.type = funcdecl.vresult.type; if (rs.caseDim) diff --git a/tests/dmd/runnable/test28.d b/tests/dmd/runnable/test28.d index 845a54a1a1..06c77467c2 100644 --- a/tests/dmd/runnable/test28.d +++ b/tests/dmd/runnable/test28.d @@ -1296,6 +1296,7 @@ S67 make67() __gshared int i67; S67 f67() +out (s; s.ptr == &s) { i67++; return make67(); From 759acb68f5f8872cbb830d9e5f0e25305b12e7be Mon Sep 17 00:00:00 2001 From: Aditya Singh Date: Mon, 29 Dec 2025 15:51:04 +0530 Subject: [PATCH 221/440] dmd/dfa: Add documentation to the Data Flow Analysis (DFA) engine (dlang/dmd!22286) --- dmd/dfa/entry.d | 30 +++++++++++++++- dmd/dfa/fast/analysis.d | 74 ++++++++++++++++++++++++++++++++++++++- dmd/dfa/fast/expression.d | 45 ++++++++++++++++++++++++ dmd/dfa/fast/report.d | 42 ++++++++++++++++++++++ dmd/dfa/fast/statement.d | 35 ++++++++++++++++++ dmd/dfa/fast/structure.d | 47 +++++++++++++++++++++++++ dmd/dfa/utils.d | 26 ++++++++++++++ 7 files changed, 297 insertions(+), 2 deletions(-) diff --git a/dmd/dfa/entry.d b/dmd/dfa/entry.d index 290c88076d..98462d531d 100644 --- a/dmd/dfa/entry.d +++ b/dmd/dfa/entry.d @@ -1,6 +1,19 @@ /** * Entry point into Data Flow Analysis engine. * + * This engine performs a structural analysis of the code to detect + * issues like nullability and truthiness. + * + * Design: + * - Structural Definition Algorithm: It performs a single forward pass + * over the AST (O(1) cost per node), minimizing compilation time. + * - Non-Iterative: Unlike "chaotic iteration" solvers (which can be O(n^2)), + * this engine does not loop until convergence. It tries to limit its visitation of each node to once. + * + * See_Also: + * https://forum.dlang.org/post/xmssfygefvldeiyodfya@forum.dlang.org + * (Why we should not enable a slow DFA by default) + * * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) @@ -41,7 +54,22 @@ void dfaEntry(FuncDeclaration fd, Scope* sc) } private: - +/*********************************************************** + * Performs the fast Data Flow Analysis on a function declaration. + * + * This function acts as the coordinator. It: + * 1. Checks if the function needs analysis (skips CTFE-only code). + * 2. Instantiates the components: + * - StatementWalker: Traverses statements (if, while, return). + * - ExpressionWalker: Traverses expressions (a + b, func()). + * - DFAAnalyzer: Tracks the state of variables (The Brain). + * 3. Wires them together but separates them for separation of concerns reasons. + * 4. Starts the single-pass walk. + * + * Params: + * fd = The function to analyze. + * sc = The scope of the function. + */ void fastDFA(FuncDeclaration fd, Scope* sc) { import dmd.dfa.fast.structure; diff --git a/dmd/dfa/fast/analysis.d b/dmd/dfa/fast/analysis.d index 76f1ee51d0..c69b134b3c 100644 --- a/dmd/dfa/fast/analysis.d +++ b/dmd/dfa/fast/analysis.d @@ -1,6 +1,15 @@ /** * Analysis engine for the fast Data Flow Analysis engine. * + * This module implements the mathematical core of the DFA. + * It is responsible for: + * 1. Transfer Functions: Calculating how specific operations (Assign, Math, Equal) + * transform the abstract state (Lattice) of variables. + * 2. Convergence (Confluence): Merging states from different control flow paths + * (e.g., merging the "True" and "False" branches of an if-statement). + * 3. Loop Approximation: Handling loops in O(1) time by making conservative + * assumptions rather than iterating to a fixed point. + * * Has the convergence and transfer functions. * * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved @@ -26,6 +35,16 @@ import core.stdc.stdio; //version = DebugJoinMeetOp; +/*********************************************************** + * The core analyzer that manipulates the Lattice state. + * + * This struct provides the overarching join/meet logic, while the specific + * merge logic is handled in `DFAConsequence`. + * + * It is responsible for: + * - Orchestrating the convergence of scopes (calculating the final state after a block exits). + * - Managing high-level state transfers between the AST walkers and the internal lattice. + */ struct DFAAnalyzer { DFACommon* dfaCommon; @@ -95,6 +114,23 @@ struct DFAAnalyzer return ret; } + /*********************************************************** + * Merges the states from the True and False branches of an If statement. + * + * This handles the "Diamond" control flow pattern. + * 1. It compares the state at the end of the "True" block vs the "False" block. + * 2. It identifies "Gates" (variables used in the condition, e.g., `if (ptr)`). + * 3. It calculates the union (Join) of the states to determine the state + * after the If statement completes. + * + * Params: + * condition = The lattice state of the condition expression. + * scrTrue = The final state of the True scope. + * scrFalse = The final state of the False scope. + * haveFalseBody = True if the if-statement has an `else` block. + * unknownBranchTaken = True if the condition result is not statically known (Maybe). + * predicateNegation = State of the predicate negation (0: unknown, 1: negated, 2: not negated). + */ void convergeStatementIf(DFALatticeRef condition, DFAScopeRef scrTrue, DFAScopeRef scrFalse, bool haveFalseBody, bool unknownBranchTaken, int predicateNegation) @@ -552,7 +588,18 @@ struct DFAAnalyzer handle(scv.lrGateNegatedPredicate); } } - + /*********************************************************** + * Converges a loop or labelled block. + * + * Fast-DFA Optimization: + * Unlike traditional "Slow DFAs" which iterate a loop until the state settles + * (Fixed Point Iteration), this engine visits the loop body once. + * + * To ensure safety without iteration: + * 1. It checks if variables modified in the loop are used inconsistently. + * 2. If a variable is modified in a way that creates uncertainty (e.g., incrementing), + * it assumes the "Worst Case" (Unknown state) for that variable after the loop. + */ void convergeStatementLoopyLabels(DFAScopeRef containing, ref Loc loc) { const scopeHaveRun = containing.sc.isLoopyLabelKnownToHaveRun; @@ -1047,6 +1094,17 @@ struct DFAAnalyzer } } + /*********************************************************** + * Updates the state of a variable after an assignment (`a = b`). + * + * This moves the state from the RHS (Right Hand Side) lattice to the + * LHS (Left Hand Side) variable. + * + * Logic: + * - Direct Assignment: `a = 5` (a becomes 5). + * - Pointer Assignment: `*p = 5` (We don't change `p`, we assume memory at `p` changed). + * - Construct: `int a = 5` (Initialization). + */ DFALatticeRef transferAssign(DFALatticeRef assignTo, bool construct, bool isBlit, DFALatticeRef lr, int alteredState, DFALatticeRef indexLR = DFALatticeRef.init) { @@ -2047,6 +2105,13 @@ private: // Converge, see Lattice (Abstract algebra) meet operation (lower bound) // Operates on a given lattice to converge into current scope's variable state + /*********************************************************** + * The Lattice 'Meet' operation (Intersection / Lower Bound). + * + * Used when we are combining facts that MUST be true. + * Example: If `x` is NonNull in path A AND `x` is NonNull in path B, + * then `x` is NonNull. + */ DFALatticeRef meet(DFALatticeRef lhs, DFALatticeRef rhs, int filterDepthOfVariable = 0, bool couldScopeNotHaveRan = false) { @@ -2110,6 +2175,13 @@ private: // Converge, see Lattice (Abstract algebra) meet operation (upper bound) // Operates on a given lattice to converge into current scope's variable state + /*********************************************************** + * The Lattice 'Join' operation (Union / Upper Bound). + * + * Used when merging diverging paths where EITHER could have happened. + * Example: If `x` is 5 in path A, and `x` is 6 in path B. + * Join(A, B) -> `x` is "Unknown Integer" (because it could be either). + */ DFALatticeRef join(DFALatticeRef lhs, DFALatticeRef rhs, int filterDepthOfVariable = 0, DFAVar* ignoreLHSCtx = null, bool ignoreWriteCount = false, bool unknownAware = false) { diff --git a/dmd/dfa/fast/expression.d b/dmd/dfa/fast/expression.d index 627e4e0628..d450c7c875 100644 --- a/dmd/dfa/fast/expression.d +++ b/dmd/dfa/fast/expression.d @@ -1,6 +1,13 @@ /** * Expression walker for the fast Data Flow Analysis engine. * + * This module tracks how values flow through expressions. + * It is responsible for: + * 1. Tracking Assignments: Updating the state of variables when they are written to. + * 2. Inferring Facts: Learning about variables from conditions (e.g., `if (ptr)`). + * 3. Handling Function Calls: Managing side effects and return values. + * 4. Modeling Arithmetic: Tracking ranges of values (Point Analysis) to detect overflows. + * * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) @@ -29,6 +36,12 @@ import dmd.arraytypes; import dmd.rootobject; import core.stdc.stdio; +/*********************************************************** + * Visits Expression nodes to track data flow. + * + * This struct implements the logic for how expressions affect the DFA state. + * It translates AST operations (like `+`, `=`, `==`) into `DFALatticeRef` updates. + */ struct ExpressionWalker { DFACommon* dfaCommon; @@ -68,6 +81,19 @@ struct ExpressionWalker dfaCommon.currentDFAScope.check; } + /*********************************************************** + * Handles variable assignment (e.g., `x = y`). + * + * This function updates the `assignTo` variable in the current scope + * to reflect the new state derived from `lr` (the right-hand side). + * + * Params: + * assignTo = The variable being written to. + * construct = True if this is an initialization (e.g., `int x = 5;`), false if reassignment. + * lr = The lattice state of the value being assigned. + * isBlit = True if the assignment is a bitwise copy (blit). + * alteredState = An integer representing a specific state alteration or flag. + */ DFALatticeRef seeAssign(DFAVar* assignTo, bool construct, DFALatticeRef lr, bool isBlit = false, int alteredState = 0) { @@ -108,6 +134,13 @@ struct ExpressionWalker return ret; } + /*********************************************************** + * Handles equality checks (e.g., `x == y` or `x is y`). + * + * This is critical for control flow. If the DFA sees `if (x == null)`, + * this function records that relationship so the `StatementWalker` can + * create a scope where `x` is known to be null. + */ DFALatticeRef seeEqual(DFALatticeRef lhs, DFALatticeRef rhs, bool truthiness, Type lhsType, Type rhsType) { @@ -347,6 +380,15 @@ struct ExpressionWalker return ret; } + /*********************************************************** + * The main dispatch loop for expressions. + * + * Visits an expression node and returns the resulting Lattice state. + * This handles the recursion for complex expressions like `(a + b) * c`. + * + * Returns: + * A `DFALatticeRef` representing the computed value/state of the expression. + */ DFALatticeRef walk(Expression expr) { if (expr is null || dfaCommon.currentDFAScope.haveJumped) @@ -776,6 +818,9 @@ struct ExpressionWalker } case EXP.assert_: + // User assertions act as facts for the DFA. + // `assert(x != null)` tells the engine that `x` is NonNull + // for all subsequent code in this scope. auto ae = expr.isAssertExp; DFALatticeRef lr = this.walk(ae.e1); seeAssert(lr, ae.e1.loc); diff --git a/dmd/dfa/fast/report.d b/dmd/dfa/fast/report.d index 147710f08d..49676accc9 100644 --- a/dmd/dfa/fast/report.d +++ b/dmd/dfa/fast/report.d @@ -1,6 +1,12 @@ /** * Reporting mechanism for the fast Data Flow Analysis engine. * + * This module translates the abstract state of the DFA into concrete compiler errors. + * It is responsible for: + * 1. Null Checks: Reporting errors when null pointers are dereferenced. + * 2. Contract Validation: Ensuring functions fulfill their `out` contracts (e.g., returning non-null). + * 3. Logic Errors: Detecting assertions that are provably false at compile time. + * * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) @@ -18,11 +24,28 @@ import core.stdc.stdio; alias Fact = ParameterDFAInfo.Fact; +/*********************************************************** + * The interface for reporting DFA errors and warnings. + * + * This struct acts as the sink for all findings. It checks if a specific + * violation (like a null dereference) should be reported based on the + * variable's modellability and depth, then sends it to the global `ErrorSink`. + */ struct DFAReporter { DFACommon* dfaCommon; ErrorSink errorSink; + /*********************************************************** + * Reports an error if a variable is dereferenced while known to be null. + * + * This is triggered by expressions like `*ptr` or `ptr.field` when the DFA + * determines `ptr` has a `Nullable.Null` state. + * + * Params: + * on = The consequence containing the variable state (must be Nullable). + * loc = The source location of the dereference. + */ void onDereference(DFAConsequence* on, ref Loc loc) { if (!dfaCommon.debugUnknownAST && on is null) @@ -57,6 +80,14 @@ struct DFAReporter var.var.ident.toChars); } + /*********************************************************** + * Validates constraints at the end of a scope. + * + * This checks if output parameters (like `out` or `ref` parameters) meet their + * guaranteed post-conditions. For example, if a function parameter is marked + * to guarantee a non-null output, this ensures the variable is actually non-null + * when the scope exits. + */ void onEndOfScope(FuncDeclaration fd, ref Loc loc) { // this is where we validate escapes, for a specific location @@ -159,6 +190,12 @@ struct DFAReporter }); } + /*********************************************************** + * Reports an error if an assertion is statically provable to be false. + * + * If the DFA determines that the condition `x` in `assert(x)` is definitively false + * (e.g., `assert(null)` or `assert(0)` after analysis), it reports this logic error. + */ void onAssertIsFalse(ref DFALatticeRef lr, ref Loc loc) { DFAConsequence* cctx; @@ -168,6 +205,11 @@ struct DFAReporter errorSink.error(loc, "Assert can be proven to be false"); } + /*********************************************************** + * Reports an error if a function argument violates the callee's expectations. + * + * Example: Passing `null` to a function parameter marked as requiring non-null. + */ void onFunctionCallArgumentLessThan(DFAConsequence* c, ParameterDFAInfo* paramInfo, FuncDeclaration calling, ref Loc loc) { diff --git a/dmd/dfa/fast/statement.d b/dmd/dfa/fast/statement.d index 6875010ec3..d39b110bc1 100644 --- a/dmd/dfa/fast/statement.d +++ b/dmd/dfa/fast/statement.d @@ -1,6 +1,13 @@ /** * Statement walker for the fast Data Flow Analysis engine. * + * This module implements the AST visitor that handles Control Flow. + * It is responsible for: + * 1. Managing Scopes: Pushing and popping `DFAScope` as it enters/leaves blocks. + * 2. Handling Branching: Splitting execution for `if` and `switch` statements. + * 3. Handling Loops: Managing state for `for`, `while`, and `do` loops. + * 4. Handling Jumps: Resolving `break`, `continue`, `goto`, and `return`. + * * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) @@ -29,6 +36,17 @@ import dmd.mtype; import dmd.declaration; import core.stdc.stdio; +/*********************************************************** + * Visits Statement nodes to drive the Data Flow Analysis. + * + * This class navigates the structure of the function. When it encounters + * control flow (like an `if` statement), it acts as a traffic director: + * 1. It creates a new Scope for the "True" branch. + * 2. It analyzes that branch. + * 3. It creates a new Scope for the "False" branch. + * 4. It analyzes that branch. + * 5. It calls `analyzer.converge...` to merge the results back together. + */ extern (D) class StatementWalker : SemanticTimeTransitiveVisitor { alias visit = SemanticTimeTransitiveVisitor.visit; @@ -581,6 +599,8 @@ final: expWalker.seeConvergeExpression(walkExpression(null, dfaCommon.getReturnVariable, exp)); + // Mark the current scope as having returned. + // This signals that no code after this point in the current block is reachable. dfaCommon.currentDFAScope.haveJumped = true; dfaCommon.currentDFAScope.haveReturned = true; analyzer.reporter.onEndOfScope(dfaCommon.currentFunction, exp.loc); @@ -627,6 +647,13 @@ final: ob.writestring("\n"); }); + // CRITICAL: We split the analysis here. + // 1. We analyze the condition to see if it implies anything about variables + // (e.g., `if (ptr)` implies `ptr` is NonNull in the true branch). + // 2. We visit the `ifbody` with that knowledge. + // 3. We visit the `elsebody` (if it exists). + // 4. We merge the resulting states from both branches. + bool ignoreTrueBranch, ignoreFalseBranch; bool unknownBranchTaken; @@ -815,6 +842,14 @@ final: ob.writestring("\n"); }); + // Loops are handled by creating a "LoopyLabel" scope. + // This allows `break` and `continue` statements inside the loop + // to find this scope and update the state accordingly. + // + // Since this is a single-pass engine, we do not iterate until convergence. + // Instead, we analyze the body once, and then use `convergeStatementLoopyLabels` + // to assume the worst-case scenario for variables modified in the loop. + inLoopyLabel++; scope (exit) inLoopyLabel--; diff --git a/dmd/dfa/fast/structure.d b/dmd/dfa/fast/structure.d index e418607ad6..442029d35f 100644 --- a/dmd/dfa/fast/structure.d +++ b/dmd/dfa/fast/structure.d @@ -41,6 +41,17 @@ enum DFACleanup = __VERSION__ >= 2102; //version = DebugJoinMeetOp; + +/*********************************************************** + * The central context for a DFA run. + * + * This structure manages the memory allocator, holds references to global + * variables (like return values), and tracks the current scope being analyzed. + * + * Performance Note: + * It uses a custom `DFAAllocator` (bump-pointer allocator) to avoid the overhead + * of the GC or standard `malloc` for the thousands of tiny nodes created during analysis. + */ struct DFACommon { DFAAllocator allocator; @@ -1194,6 +1205,17 @@ struct DFACaseState DFAScopeRef jumpedTo; // When its jumped to this case, this is the meet'd state } +/*********************************************************** + * Represents the identity of a variable being tracked. + * + * This does NOT store the current value of the variable (that changes depending on + * where you are in the code). Instead, it stores immutable properties like: + * - Is it a boolean? (`isBoolean`) + * - Can it be null? (`isNullable`) + * - Is it a reference to another variable? (`base1`, `indexVar`) + * + * Think of this as the "Key" in a map, where the "Value" is the DFALattice. + */ struct DFAVar { private @@ -1602,6 +1624,16 @@ struct DFAScopeRef } } +/*********************************************************** + * Represents a specific region of code execution (a scope). + * + * As the DFA walks through the code, it pushes and pops scopes. + * Each scope holds a table (`buckets`) of the current state of variables + * within that block. + * + * When the analysis branches (e.g., inside an `if`), a new child scope is + * created to track the state changes specific to that branch. + */ struct DFAScope { private @@ -2187,6 +2219,13 @@ struct DFALatticeRef } } +/*********************************************************** + * The collection of values and facts known about a variable. + * + * A DFALattice contains one or more `DFAConsequence` nodes. + * Each `DFAConsequence` represents the state of a variable at the current + * point in time. + */ struct DFALattice { private @@ -3424,6 +3463,14 @@ struct DFAPAValue } } +/*********************************************************** + * A specific fact known about a variable at the current point in time. + * + * Examples of consequences: + * - "This variable is definitely not null" (`nullable == NonNull`) + * - "This variable is True" (`truthiness == True`) + * - "This variable has the integer value 5" (`pa` - Point Analysis) + */ struct DFAConsequence { private diff --git a/dmd/dfa/utils.d b/dmd/dfa/utils.d index b9393e1623..8965008b8f 100644 --- a/dmd/dfa/utils.d +++ b/dmd/dfa/utils.d @@ -17,6 +17,15 @@ import dmd.identifier; import dmd.expression; import dmd.typesem : isFloating; +/*********************************************************** + * Checks if a type is capable of being null at runtime. + * + * The DFA uses this to determine if a null-check is required + * for a specific variable. + * + * Returns: + * true if the type is a pointer, array, class, delegate, etc. + */ bool isTypeNullable(Type type) { if (type is null) @@ -33,6 +42,16 @@ bool isTypeNullable(Type type) } } +/*********************************************************** + * Checks if a type can be evaluated as a boolean (truthy/falsey). + * + * Used by the DFA to determine if control flow (like `if` statements) + * depends on this variable. + * + * Returns: + * false for types like `void` (noreturn) or `struct` (unless they define opCast), + * true for integers, pointers, bools, etc. + */ bool isTypeTruthy(Type type) { if (type is null) @@ -98,6 +117,13 @@ enum EqualityArgType Nullable } +/*********************************************************** + * Classifies how two types are compared for equality at runtime. + * + * This mirrors the logic in the compiler backend/glue layer. + * The DFA needs this to accurately predict if an equality check (`==`) + * involves simple integer comparison, array comparison, or struct comparison. + */ /// See_Also: EqualityArgType EqualityArgType equalityArgTypes(Type lhs, Type rhs) { From e76e59d6698b76ac5589c21dc29a90915423a8f7 Mon Sep 17 00:00:00 2001 From: apz28 Date: Mon, 29 Dec 2025 21:47:41 -0500 Subject: [PATCH 222/440] Add missing mbstate_t for Windows (dlang/dmd!22326) * Fix dlang/dmd!17483: Fix Windows portion using ...Windows Kits\10\Include\10.0.14393.0\ucrt\locale.h * Add missing mbstate_t for Windows --- runtime/druntime/src/core/stdc/wchar_.d | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/runtime/druntime/src/core/stdc/wchar_.d b/runtime/druntime/src/core/stdc/wchar_.d index 6ed2dfe831..cd6192b057 100644 --- a/runtime/druntime/src/core/stdc/wchar_.d +++ b/runtime/druntime/src/core/stdc/wchar_.d @@ -129,6 +129,23 @@ else version (CRuntime_UClibc) wchar_t __wc = 0; } } +else version (Windows) +{ + /// + struct __mbstate_t + { + int __count; + union ___value + { + wint_t __wch = 0; + char[4] __wchb; + } + ___value __value; + } + + /// + alias mbstate_t = __mbstate_t; +} else { /// From 735727149c3183a0d621ce34277576b8f7ceb85c Mon Sep 17 00:00:00 2001 From: Emmanuel Nyarko <57257441+Emmankoko@users.noreply.github.com> Date: Tue, 30 Dec 2025 12:14:39 +0000 Subject: [PATCH 223/440] importC: convert C complex types to use D fundamental complex and not complex library struct. (dlang/dmd!22238) * issue dlang/dmd!22247, basic for now * Add complex real to known warnings for x86 windows since c_long_double is a (1o bytes) known mismatch, complex real similarly falls in that category since it is simple two long doubles * check issue dlang/dmd!22259.c * make new complex structure work with Cinitializer using the fundamental complex interferes with this a little when compiling s7 library.this fixes it. --- dmd/expressionsem.d | 33 ++----------------- dmd/initsem.d | 31 +++++++++++++++++ dmd/typesem.d | 8 +---- .../importc_compare/src/importc_compare.d | 2 ++ tests/dmd/compilable/testcomplex.c | 13 ++++++++ tests/dmd/runnable/testc22259.c | 21 ++++++++++++ tests/dmd/runnable/testcomplexinit.c | 28 ++++++++++++++++ 7 files changed, 99 insertions(+), 37 deletions(-) create mode 100644 tests/dmd/compilable/testcomplex.c create mode 100644 tests/dmd/runnable/testc22259.c create mode 100644 tests/dmd/runnable/testcomplexinit.c diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 10432b7580..902b0563d4 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -5306,37 +5306,10 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { if (!e.type) e.type = Type.tfloat64; - else if (!e.type.isImaginary || !sc.inCfile) - { - e.type = e.type.typeSemantic(e.loc, sc); - result = e; - return; - } - /* Convert to core.stdc.config.complex - */ - Type t = getComplexLibraryType(e.loc, sc, e.type.ty); - if (t.ty == Terror) - return setError(); - - Type tf; - switch (e.type.ty) - { - case Timaginary32: tf = Type.tfloat32; break; - case Timaginary64: tf = Type.tfloat64; break; - case Timaginary80: tf = Type.tfloat80; break; - default: - assert(0); - } - - /* Construct ts{re : 0.0, im : e} - */ - TypeStruct ts = t.isTypeStruct; - Expressions* elements = new Expressions(2); - (*elements)[0] = new RealExp(e.loc, CTFloat.zero, tf); - (*elements)[1] = new RealExp(e.loc, e.toImaginary(), tf); - Expression sle = new StructLiteralExp(e.loc, ts.sym, elements); - result = sle.expressionSemantic(sc); + e.type = e.type.typeSemantic(e.loc, sc); + result = e; + return; } override void visit(ComplexExp e) diff --git a/dmd/initsem.d b/dmd/initsem.d index 43ea1cd4c4..00de258451 100644 --- a/dmd/initsem.d +++ b/dmd/initsem.d @@ -631,6 +631,19 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn */ t = t.toBasetype(); + bool isComplexInitilaizer() + { + switch (t.ty) + { + case Tcomplex32: + case Tcomplex64: + case Tcomplex80: + return true; + default: + return false; + } + } + if (auto tv = t.isTypeVector()) t = tv.basetype; @@ -1146,6 +1159,24 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn { return visitExp(ei); } + else if (isComplexInitilaizer()) + { + /* just convert _Complex = { a, b} to _Complex =. a + b*i */ + if (ci.initializerList[].length != 2) + { + error(ci.loc, "only two initializers required for complex type `%s`", t.toChars()); + return err(); + } + auto rexp = ci.initializerList[0].initializer.initializerToExpression(); + auto imexp = ci.initializerList[1].initializer.initializerToExpression(); + + import dmd.root.ctfloat; + auto newExpr = new AddExp(ci.loc, rexp, + new MulExp(ci.loc, imexp, new RealExp(ci.loc, CTFloat.one, Type.timaginary64))); + + auto ce = new ExpInitializer(ci.loc, newExpr); + return ce.initializerSemantic(sc, t, needInterpret); + } else { error(ci.loc, "unrecognized C initializer `%s` for type `%s`", toChars(ci), t.toChars()); diff --git a/dmd/typesem.d b/dmd/typesem.d index 5ea3327c3a..37bfc4a9db 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -3226,13 +3226,7 @@ Type typeSemantic(Type type, Loc loc, Scope* sc) Type visitComplex(TypeBasic t) { - if (!sc.inCfile) - return visitType(t); - - auto tc = getComplexLibraryType(loc, sc, t.ty); - if (tc.ty == Terror) - return tc; - return tc.addMod(t.mod).merge(); + return visitType(t); } Type visitVector(TypeVector mtype) diff --git a/runtime/druntime/test/importc_compare/src/importc_compare.d b/runtime/druntime/test/importc_compare/src/importc_compare.d index 54081a23f1..bf3fd14172 100644 --- a/runtime/druntime/test/importc_compare/src/importc_compare.d +++ b/runtime/druntime/test/importc_compare/src/importc_compare.d @@ -29,6 +29,8 @@ immutable string[] growingTypes = [ // warnings for now. immutable ErrorFilter[] knownProblems = [ ErrorFilter("core.stdc.config.c_long_double", "", "Windows", 32, ""), + ErrorFilter("core.stdc.config.c_complex_real", "", "Windows", 32, ""), // complex real is two long doubles so same for x86 Windows + ErrorFilter("core.stdc.config.__c_complex_real", "", "Windows", 32, ""), ErrorFilter("core.stdc.fenv.fenv_t", "", "FreeBSD", 0, ""), ErrorFilter("core.stdc.locale.lconv", "", "Apple", 0, "https://issues.dlang.org/show_bug.cgi?id=24652"), ErrorFilter("core.stdc.locale.lconv", "", "FreeBSD", 0, "https://issues.dlang.org/show_bug.cgi?id=24652"), diff --git a/tests/dmd/compilable/testcomplex.c b/tests/dmd/compilable/testcomplex.c new file mode 100644 index 0000000000..2be4cfd3e4 --- /dev/null +++ b/tests/dmd/compilable/testcomplex.c @@ -0,0 +1,13 @@ +#include + +void foo(_Complex double z) +{ + return; +} + + +int main() +{ + double z; + foo(z); +} diff --git a/tests/dmd/runnable/testc22259.c b/tests/dmd/runnable/testc22259.c new file mode 100644 index 0000000000..e8b8c9a520 --- /dev/null +++ b/tests/dmd/runnable/testc22259.c @@ -0,0 +1,21 @@ +// DISABLED: win32 win64 + +// https://github.com/dlang/dmd/issues/22259 + +#include +#include +#include + +void foo() +{ + _Complex double x = 1 + 1.0if; + assert(creal(x) == 1.000000); + assert(cimag(x) == 1.000000); + return; +} + +int main() +{ + foo(); + return 0; +} diff --git a/tests/dmd/runnable/testcomplexinit.c b/tests/dmd/runnable/testcomplexinit.c new file mode 100644 index 0000000000..f8a33a445d --- /dev/null +++ b/tests/dmd/runnable/testcomplexinit.c @@ -0,0 +1,28 @@ +// DISABLED: win32 win64 + +#include +#include +#include + +struct com +{ + int r; + int c; +}; + +void foo() +{ + struct com obj = { 1, 3}; + _Complex double x = { obj.r, obj.c}; //real + im*i; + + assert(creal(x) == 1.000000); + assert(cimag(x) == 3.000000); + return; +} + + +int main() +{ + foo(); + return 0; +} From e311fcb5368641af4069f0e8b7a5e704d1acc0f2 Mon Sep 17 00:00:00 2001 From: Eugene 'Vindex' Stulin <92019484+vindexbit@users.noreply.github.com> Date: Wed, 31 Dec 2025 01:34:16 +0300 Subject: [PATCH 224/440] Fix dlang/dmd!22322 - converting real to float uses double rounding for 64-bit code causing unexpected results (dlang/dmd!22325) --- tests/dmd/runnable/real_to_float.d | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/dmd/runnable/real_to_float.d diff --git a/tests/dmd/runnable/real_to_float.d b/tests/dmd/runnable/real_to_float.d new file mode 100644 index 0000000000..8b5c9701b9 --- /dev/null +++ b/tests/dmd/runnable/real_to_float.d @@ -0,0 +1,28 @@ +/* The test related to https://github.com/dlang/dmd/issues/22322 + * The issue title: + * "converting real to float uses double rounding for 64-bit code + * causing unexpected results" + */ +pragma(inline, false) +void test(real r) +{ + assert(r == 0x1.000002fffffffcp-1); + double d = r; + assert(d == 0x1.000003p-1); + float f = r; + assert(f == 0x1.000002p-1); + float fd = d; + assert(fd == 0x1.000004p-1); + real rd = d; + assert(rd == 0x1.000003p-1); + float frd = rd; + assert(frd == 0x1.000004p-1); +} + +void main() +{ + static if (real.sizeof > 8) + { + test(0x1.000002fffffffcp-1); + } +} From 9ea17529d0aae8a6b7ee1882631b09603e5d7387 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Wed, 31 Dec 2025 21:06:50 +0100 Subject: [PATCH 225/440] mtype.h: Add convenience methods back to Type class (dlang/dmd!22333) --- dmd/mtype.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dmd/mtype.h b/dmd/mtype.h index 86e9425268..3a78228f7f 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -42,9 +42,13 @@ typedef struct TYPE type; namespace dmd { + void Type_init(); Type *typeSemantic(Type *t, Loc loc, Scope *sc); Type *merge(Type *type); Expression *defaultInitLiteral(Type *t, Loc loc); + Type *toBasetype(Type *type); + Type *nextOf(Type* type); + Type *baseElemOf(Type* type); } enum class TY : uint8_t @@ -215,6 +219,8 @@ class Type : public ASTNode static Type *basic[(int)TY::TMAX]; + static void _init() { return dmd::Type_init(); } + virtual const char *kind(); Type *copy() const; virtual Type *syntaxCopy(); @@ -241,6 +247,10 @@ class Type : public ASTNode bool isNaked() const { return mod == 0; } Type *nullAttributes() const; + Type *toBasetype() { return dmd::toBasetype(this); } + Type *nextOf() { return dmd::nextOf(this); } + Type *baseElemOf() { return dmd::baseElemOf(this); } + virtual ClassDeclaration *isClassHandle(); virtual int hasWild() const; @@ -732,7 +742,6 @@ namespace dmd Type *addMod(Type *type, MOD mod); Type *addStorageClass(Type *type, StorageClass stc); Type *substWildTo(Type *type, unsigned mod); - Type *toBasetype(Type *type); uinteger_t size(Type *type); uinteger_t size(Type *type, Loc loc); MATCH implicitConvTo(Type* from, Type* to); @@ -740,7 +749,6 @@ namespace dmd bool hasUnsafeBitpatterns(Type* type); bool hasInvariant(Type* type); bool hasVoidInitPointers(Type* type); - void Type_init(); void transitive(TypeNext* type); structalign_t alignment(Type* type); Type* memType(TypeEnum* type); @@ -754,8 +762,6 @@ namespace dmd Type *makeWildConst(Type* type); Type *makeSharedWild(Type* type); Type *makeSharedWildConst(Type* type); - Type *nextOf(Type* type); - Type *baseElemOf(Type* type); Type *isLazyArray(Parameter* param); unsigned char deduceWild(Type* type, Type* t, bool isRef); bool isIntegral(Type* type); From e681f4db9de1e469e0fd6d81314d176e901e61ca Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Wed, 31 Dec 2025 21:08:12 +0100 Subject: [PATCH 226/440] core.internal.vararg.gnu: Fix module implementation (dlang/dmd!22332) --- .../druntime/src/core/internal/vararg/gnu.d | 32 ++----------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/runtime/druntime/src/core/internal/vararg/gnu.d b/runtime/druntime/src/core/internal/vararg/gnu.d index 0218490f2c..be3d6991e3 100644 --- a/runtime/druntime/src/core/internal/vararg/gnu.d +++ b/runtime/druntime/src/core/internal/vararg/gnu.d @@ -14,36 +14,10 @@ module core.internal.vararg.gnu; version (GNU): -// Uses gcc.builtins +import gcc.builtins; -T alignUp(size_t alignment = size_t.sizeof, T)(T base) pure -{ - enum mask = alignment - 1; - static assert(alignment > 0 && (alignment & mask) == 0, "alignment must be a power of 2"); - auto b = cast(size_t) base; - b = (b + mask) & ~mask; - return cast(T) b; -} - -unittest -{ - assert(1.alignUp == size_t.sizeof); - assert(31.alignUp!16 == 32); - assert(32.alignUp!16 == 32); - assert(33.alignUp!16 == 48); - assert((-9).alignUp!8 == -8); -} - - -version (BigEndian) -{ - // Adjusts a size_t-aligned pointer for types smaller than size_t. - T* adjustForBigEndian(T)(T* p, size_t size) pure - { - return size >= size_t.sizeof ? p : - cast(T*) ((cast(void*) p) + (size_t.sizeof - size)); - } -} +@nogc: +nothrow: /** * The argument pointer type. From 43843fbd042795dc299a435103d88097251b8046 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Wed, 31 Dec 2025 21:09:31 +0100 Subject: [PATCH 227/440] globals.h: Add missing useFastDFA field (dlang/dmd!22330) --- dmd/globals.h | 1 + 1 file changed, 1 insertion(+) diff --git a/dmd/globals.h b/dmd/globals.h index f637e22ab9..10651ae1d6 100644 --- a/dmd/globals.h +++ b/dmd/globals.h @@ -232,6 +232,7 @@ struct Param FeatureState dtorFields; // destruct fields of partially constructed objects // https://issues.dlang.org/show_bug.cgi?id=14246 FeatureState systemVariables; // limit access to variables marked @system from @safe code + d_bool useFastDFA; // Use fast data flow analysis engine CHECKENABLE useInvariants; // generate class invariant checks CHECKENABLE useIn; // generate precondition checks From 3f3ff27d2138d03badd9a1707cc54be8ed7f3ec0 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Wed, 31 Dec 2025 21:10:14 +0100 Subject: [PATCH 228/440] expression.h: Fix signature of dmd::isLvalue (dlang/dmd!22329) --- dmd/expression.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmd/expression.h b/dmd/expression.h index eddcdb0fdc..7af0992ef8 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -61,7 +61,7 @@ namespace dmd Expression *optimize(Expression *exp, int result, bool keepLvalue = false); bool isIdentical(const Expression *exp, const Expression *e); bool equals(const Expression *exp, const Expression *e); - bool isLvalue(const Expression *exp); + bool isLvalue(Expression *exp); int32_t getFieldIndex(ClassReferenceExp *cre, Type *fieldtype, uint32_t fieldoffset); void fillTupleExpExps(TupleExp *te, TupleDeclaration *tup); Optional toBool(Expression *exp); From e0936169450390223c7d80394db86ead81593751 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Thu, 1 Jan 2026 10:48:45 +0200 Subject: [PATCH 229/440] Move `FuncDeclaration.isVirtualMethod` and `FuncDeclaration.hasNestedFrameRefs` to `funcsem` (dlang/dmd!22331) --- dmd/cxxfrontend.d | 12 ++++++++++++ dmd/declaration.h | 4 ++-- dmd/frontend.h | 2 -- dmd/func.d | 49 ----------------------------------------------- dmd/funcsem.d | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 53 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index eb25405efb..c91f0794f7 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -529,6 +529,18 @@ bool needsClosure(FuncDeclaration fd) return dmd.funcsem.needsClosure(fd); } +bool hasNestedFrameRefs(FuncDeclaration fd) +{ + import dmd.funcsem; + return dmd.funcsem.hasNestedFrameRefs(fd); +} + +bool isVirtualMethod(FuncDeclaration fd) +{ + import dmd.funcsem; + return dmd.funcsem.isVirtualMethod(fd); +} + /*********************************************************** * hdrgen.d */ diff --git a/dmd/declaration.h b/dmd/declaration.h index fbca3074fe..6882c28b7c 100644 --- a/dmd/declaration.h +++ b/dmd/declaration.h @@ -43,6 +43,8 @@ namespace dmd bool isAbstract(ClassDeclaration *cd); bool overloadInsert(Dsymbol *ds, Dsymbol *s); bool equals(const Dsymbol * const ds, const Dsymbol * const s); + bool hasNestedFrameRefs(FuncDeclaration *fd); + bool isVirtualMethod(FuncDeclaration *fd); } //enum STC : ulong from astenums.d: @@ -714,13 +716,11 @@ class FuncDeclaration : public Declaration virtual bool isNested() const; AggregateDeclaration *isThis() override; bool needThis() override final; - bool isVirtualMethod(); virtual bool isVirtual() const; bool isFinalFunc() const; virtual bool addPreInvariant(); virtual bool addPostInvariant(); const char *kind() const override; - bool hasNestedFrameRefs(); ParameterList getParameterList(); virtual FuncDeclaration *toAliasFunc() { return this; } diff --git a/dmd/frontend.h b/dmd/frontend.h index 1fee00408f..41d95b11af 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -3919,13 +3919,11 @@ class FuncDeclaration : public Declaration virtual bool isNested() const; AggregateDeclaration* isThis() override; bool needThis() final override; - bool isVirtualMethod(); virtual bool isVirtual() const; bool isFinalFunc() const; virtual bool addPreInvariant(); virtual bool addPostInvariant(); const char* kind() const override; - bool hasNestedFrameRefs(); ParameterList getParameterList(); virtual FuncDeclaration* toAliasFunc(); void accept(Visitor* v) override; diff --git a/dmd/func.d b/dmd/func.d index b7e60aa2a1..f80fd4600f 100644 --- a/dmd/func.d +++ b/dmd/func.d @@ -631,23 +631,6 @@ extern (C++) class FuncDeclaration : Declaration return toAliasFunc().isThis() !is null; } - // Determine if a function is pedantically virtual - final bool isVirtualMethod() - { - if (toAliasFunc() != this) - return toAliasFunc().isVirtualMethod(); - - //printf("FuncDeclaration::isVirtualMethod() %s\n", toChars()); - if (!isVirtual()) - return false; - // If it's a final method, and does not override anything, then it is not virtual - if (isFinalFunc() && foverrides.length == 0) - { - return false; - } - return true; - } - // Determine if function goes into virtual function pointer table bool isVirtual() const { @@ -710,38 +693,6 @@ extern (C++) class FuncDeclaration : Declaration return this.isGenerated ? "generated function" : "function"; } - /*********************************************** - * Determine if function's variables are referenced by a function - * nested within it. - */ - final bool hasNestedFrameRefs() - { - if (closureVars.length) - return true; - - /* If a virtual function has contracts, assume its variables are referenced - * by those contracts, even if they aren't. Because they might be referenced - * by the overridden or overriding function's contracts. - * This can happen because frequire and fensure are implemented as nested functions, - * and they can be called directly by an overriding function and the overriding function's - * context had better match, or - * https://issues.dlang.org/show_bug.cgi?id=7335 will bite. - */ - if (fdrequire || fdensure) - return true; - - if (foverrides.length && isVirtualMethod()) - { - for (size_t i = 0; i < foverrides.length; i++) - { - FuncDeclaration fdv = foverrides[i]; - if (fdv.hasNestedFrameRefs()) - return true; - } - } - return false; - } - /********************************************* * Returns: the function's parameter list, and whether * it is variadic or not. diff --git a/dmd/funcsem.d b/dmd/funcsem.d index d4e660ce66..517c2f2389 100644 --- a/dmd/funcsem.d +++ b/dmd/funcsem.d @@ -67,6 +67,55 @@ import dmd.typesem; import dmd.visitor; import dmd.visitor.statement_rewrite_walker; +// Determine if a function is pedantically virtual +bool isVirtualMethod(FuncDeclaration _this) +{ + if (_this.toAliasFunc() != _this) + return _this.toAliasFunc().isVirtualMethod(); + + //printf("FuncDeclaration::isVirtualMethod() %s\n", toChars()); + if (!_this.isVirtual()) + return false; + + // If it's a final method, and does not override anything, then it is not virtual + if (_this.isFinalFunc() && _this.foverrides.length == 0) + { + return false; + } + return true; +} + +/*********************************************** + * Determine if function's variables are referenced by a function + * nested within it. + */ +bool hasNestedFrameRefs(FuncDeclaration _this) +{ + if (_this.closureVars.length) + return true; + + /* If a virtual function has contracts, assume its variables are referenced + * by those contracts, even if they aren't. Because they might be referenced + * by the overridden or overriding function's contracts. + * This can happen because frequire and fensure are implemented as nested functions, + * and they can be called directly by an overriding function and the overriding function's + * context had better match, or + * https://issues.dlang.org/show_bug.cgi?id=7335 will bite. + */ + if (_this.fdrequire || _this.fdensure) + return true; + + if (_this.foverrides.length && _this.isVirtualMethod()) + { + for (size_t i = 0; i < _this.foverrides.length; i++) + { + FuncDeclaration fdv = _this.foverrides[i]; + if (fdv.hasNestedFrameRefs()) + return true; + } + } + return false; +} /********************************** * Generate a FuncDeclaration for a runtime library function. From 5139cc1e4e9486afcf6bb726f2a049d4bbf9ffd3 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Thu, 1 Jan 2026 13:13:27 +0100 Subject: [PATCH 230/440] aggregate.h: Add StructDeclaration::hasCopyConstruction binding (dlang/dmd!22335) --- dmd/aggregate.h | 1 + 1 file changed, 1 insertion(+) diff --git a/dmd/aggregate.h b/dmd/aggregate.h index c1fdf761df..4a5f664ca8 100644 --- a/dmd/aggregate.h +++ b/dmd/aggregate.h @@ -170,6 +170,7 @@ class StructDeclaration : public AggregateDeclaration static StructDeclaration *create(Loc loc, Identifier *id, bool inObject); StructDeclaration *syntaxCopy(Dsymbol *s) override; const char *kind() const override; + bool hasCopyConstruction(); bool zeroInit() const; // !=0 if initialize with 0 fill bool zeroInit(bool v); bool hasIdentityAssign() const; // true if has identity opAssign From 397435436376906a731d155030dc941bdea59672 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Thu, 1 Jan 2026 13:14:30 +0100 Subject: [PATCH 231/440] pragma(mangle): Fix unbalanced backticks in error (dlang/dmd!22334) --- dmd/pragmasem.d | 2 +- tests/dmd/fail_compilation/pragmamangle1.d | 2 +- tests/dmd/fail_compilation/pragmamangle2.d | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dmd/pragmasem.d b/dmd/pragmasem.d index 917f886ac1..71d6770785 100644 --- a/dmd/pragmasem.d +++ b/dmd/pragmasem.d @@ -687,7 +687,7 @@ private bool pragmaMangleSemantic(Loc loc, Scope* sc, Expressions* args, Dsymbol } if (args.length > 2) { - error(loc, "pragma(mangle)` expects 1 or 2 arguments"); + error(loc, "`pragma(mangle)` expects 1 or 2 arguments"); return false; } diff --git a/tests/dmd/fail_compilation/pragmamangle1.d b/tests/dmd/fail_compilation/pragmamangle1.d index d959705ac1..a69770691c 100644 --- a/tests/dmd/fail_compilation/pragmamangle1.d +++ b/tests/dmd/fail_compilation/pragmamangle1.d @@ -7,7 +7,7 @@ fail_compilation/pragmamangle1.d(44): Error: `pragma(mangle)` must be attached t fail_compilation/pragmamangle1.d(46): Error: `pragma(mangle)` must be attached to a declaration fail_compilation/pragmamangle1.d(53): Error: `pragma(mangle)` expects string literal argument for mangled name fail_compilation/pragmamangle1.d(56): Error: `pragma(mangle)` zero-length string not allowed for mangled name -fail_compilation/pragmamangle1.d(59): Error: pragma(mangle)` expects 1 or 2 arguments +fail_compilation/pragmamangle1.d(59): Error: `pragma(mangle)` expects 1 or 2 arguments fail_compilation/pragmamangle1.d(62): Error: `pragma(mangle)` cannot apply to a template declaration fail_compilation/pragmamangle1.d(62): use `template cannot_apply(Args...) { pragma(mangle, "template") ... }` fail_compilation/pragmamangle1.d(65): Error: `pragma(mangle)` takes a single argument that must be a string literal diff --git a/tests/dmd/fail_compilation/pragmamangle2.d b/tests/dmd/fail_compilation/pragmamangle2.d index 85c461af10..a5235157b0 100644 --- a/tests/dmd/fail_compilation/pragmamangle2.d +++ b/tests/dmd/fail_compilation/pragmamangle2.d @@ -7,7 +7,7 @@ fail_compilation/pragmamangle2.d(46): Error: `pragma(mangle)` must be attached t fail_compilation/pragmamangle2.d(48): Error: `pragma(mangle)` must be attached to a declaration fail_compilation/pragmamangle2.d(55): Error: `pragma(mangle)` expects string literal argument for mangled name fail_compilation/pragmamangle2.d(58): Error: `pragma(mangle)` zero-length string not allowed for mangled name -fail_compilation/pragmamangle2.d(61): Error: pragma(mangle)` expects 1 or 2 arguments +fail_compilation/pragmamangle2.d(61): Error: `pragma(mangle)` expects 1 or 2 arguments fail_compilation/pragmamangle2.d(64): Error: `pragma(mangle)` cannot apply to a template declaration fail_compilation/pragmamangle2.d(64): use `template cannot_apply(Args...) { pragma(mangle, "template") ... }` fail_compilation/pragmamangle2.d(67): Error: `pragma(mangle)` takes a single argument that must be a string literal From ee957a8af27a24ec2dcc9d2cef2dfb2f8bf54dbe Mon Sep 17 00:00:00 2001 From: Iskaban10 Date: Fri, 2 Jan 2026 15:42:18 +0530 Subject: [PATCH 232/440] fix dlang/dmd!21381 for location of undefined identifier --- dmd/typesem.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmd/typesem.d b/dmd/typesem.d index 37bfc4a9db..127b8bd9e0 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -1516,7 +1516,7 @@ private void resolveHelper(TypeQualified mt, Loc loc, Scope* sc, Dsymbol s, Dsym if (const n = importHint(id.toString())) error(loc, "`%s` is not defined, perhaps `import %.*s;` ?", p, cast(int)n.length, n.ptr); else if (auto s2 = sc.search_correct(id)) - error(loc, "undefined identifier `%s`, did you mean %s `%s`?", p, s2.kind(), s2.toChars()); + error(mt.loc, "undefined identifier `%s`, did you mean %s `%s`?", p, s2.kind(), s2.toChars()); else if (const q = search_correct_C(id)) error(loc, "undefined identifier `%s`, did you mean `%s`?", p, q); else if ((id == Id.This && sc.getStructClassScope()) || From 87f270d8584879cefaa2e71ff711c116ebf3c3be Mon Sep 17 00:00:00 2001 From: Iskaban10 Date: Fri, 2 Jan 2026 16:41:53 +0530 Subject: [PATCH 233/440] Updated test --- tests/dmd/fail_compilation/b23686.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dmd/fail_compilation/b23686.d b/tests/dmd/fail_compilation/b23686.d index 5838f5c8e1..680c91a100 100644 --- a/tests/dmd/fail_compilation/b23686.d +++ b/tests/dmd/fail_compilation/b23686.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/b23686.d(107): Error: undefined identifier `eFN1`, did you mean template `eFN0()()`? +fail_compilation/b23686.d-mixin-107(107): Error: undefined identifier `eFN1`, did you mean template `eFN0()()`? fail_compilation/b23686.d(107): Error: `mixin(_error_)` does not give a valid type fail_compilation/b23686.d(115): while looking for match for `eload!(int, 1)` fail_compilation/b23686.d-mixin-121(121): Error: undefined identifier `FNwtf` From 47bac983c2985db9c5f6f742393f349e9c185d86 Mon Sep 17 00:00:00 2001 From: Iskaban10 Date: Fri, 2 Jan 2026 17:00:29 +0530 Subject: [PATCH 234/440] loc changed to mt.loc --- dmd/typesem.d | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dmd/typesem.d b/dmd/typesem.d index 127b8bd9e0..402119e6e6 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -1514,24 +1514,24 @@ private void resolveHelper(TypeQualified mt, Loc loc, Scope* sc, Dsymbol s, Dsym if (!(sc && sc.inCfile)) { if (const n = importHint(id.toString())) - error(loc, "`%s` is not defined, perhaps `import %.*s;` ?", p, cast(int)n.length, n.ptr); + error(mt.loc, "`%s` is not defined, perhaps `import %.*s;` ?", p, cast(int)n.length, n.ptr); else if (auto s2 = sc.search_correct(id)) error(mt.loc, "undefined identifier `%s`, did you mean %s `%s`?", p, s2.kind(), s2.toChars()); else if (const q = search_correct_C(id)) - error(loc, "undefined identifier `%s`, did you mean `%s`?", p, q); + error(mt.loc, "undefined identifier `%s`, did you mean `%s`?", p, q); else if ((id == Id.This && sc.getStructClassScope()) || (id == Id._super && sc.getClassScope())) - error(loc, "undefined identifier `%s`, did you mean `typeof(%s)`?", p, p); + error(mt.loc, "undefined identifier `%s`, did you mean `typeof(%s)`?", p, p); else error(mt.loc, "undefined identifier `%s`", p); } else { if (const n = cIncludeHint(id.toString())) - error(loc, "`%s` is not defined, perhaps `#include %.*s` ?", p, cast(int)n.length, n.ptr); + error(mt.loc, "`%s` is not defined, perhaps `#include %.*s` ?", p, cast(int)n.length, n.ptr); else if (auto s2 = sc.search_correct(id)) - error(loc, "undefined identifier `%s`, did you mean %s `%s`?", p, s2.kind(), s2.toChars()); + error(mt.loc, "undefined identifier `%s`, did you mean %s `%s`?", p, s2.kind(), s2.toChars()); else - error(loc, "undefined identifier `%s`", p); + error(mt.loc, "undefined identifier `%s`", p); } pt = Type.terror; From b12ff121ab432827b7aa4204b5336920c6c5a507 Mon Sep 17 00:00:00 2001 From: Iskaban10 Date: Fri, 2 Jan 2026 23:48:31 +0530 Subject: [PATCH 235/440] Updated --- dmd/typesem.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dmd/typesem.d b/dmd/typesem.d index 402119e6e6..e5a08798a3 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -1514,7 +1514,7 @@ private void resolveHelper(TypeQualified mt, Loc loc, Scope* sc, Dsymbol s, Dsym if (!(sc && sc.inCfile)) { if (const n = importHint(id.toString())) - error(mt.loc, "`%s` is not defined, perhaps `import %.*s;` ?", p, cast(int)n.length, n.ptr); + error(loc, "`%s` is not defined, perhaps `import %.*s;` ?", p, cast(int)n.length, n.ptr); else if (auto s2 = sc.search_correct(id)) error(mt.loc, "undefined identifier `%s`, did you mean %s `%s`?", p, s2.kind(), s2.toChars()); else if (const q = search_correct_C(id)) @@ -1527,7 +1527,7 @@ private void resolveHelper(TypeQualified mt, Loc loc, Scope* sc, Dsymbol s, Dsym } else { if (const n = cIncludeHint(id.toString())) - error(mt.loc, "`%s` is not defined, perhaps `#include %.*s` ?", p, cast(int)n.length, n.ptr); + error(loc, "`%s` is not defined, perhaps `#include %.*s` ?", p, cast(int)n.length, n.ptr); else if (auto s2 = sc.search_correct(id)) error(mt.loc, "undefined identifier `%s`, did you mean %s `%s`?", p, s2.kind(), s2.toChars()); else From d3b990a6d144efee4bb1e9d4623b34574d872fc7 Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Fri, 2 Jan 2026 23:18:28 +0100 Subject: [PATCH 236/440] Fix dlang/dmd!18316 - Inaccurate parsing of floating-point literals (dlang/dmd!22343) Fix dlang/dmd!19733 - wrong real literals on windows use _atoldbl() from the MS runtime instead of strtold_dm to parse decimal floating point literals --- dmd/frontend.h | 1 + dmd/root/ctfloat.d | 18 +++-------- dmd/root/port.d | 39 ++++++++++++++++++++++++ tests/dmd/runnable/real_to_float.d | 48 ++++++++++++++++++++++++++++-- 4 files changed, 89 insertions(+), 17 deletions(-) diff --git a/dmd/frontend.h b/dmd/frontend.h index 41d95b11af..daf8cf35ca 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -9069,6 +9069,7 @@ struct Port final static char* strupr(char* s); static bool isFloat32LiteralOutOfRange(const char* s); static bool isFloat64LiteralOutOfRange(const char* s); + static _d_real strtold(const char* p); static void writelongLE(uint32_t value, void* buffer); static uint32_t readlongLE(const void* const buffer); static void writelongBE(uint32_t value, void* buffer); diff --git a/dmd/root/ctfloat.d b/dmd/root/ctfloat.d index 39ab18f922..1da114bd65 100644 --- a/dmd/root/ctfloat.d +++ b/dmd/root/ctfloat.d @@ -21,15 +21,15 @@ nothrow: // Type used by the front-end for compile-time reals public import dmd.root.longdouble : real_t = longdouble; +import dmd.root.port; private { version(CRuntime_DigitalMars) __gshared extern (C) extern const(char)* __locale_decpoint; - version(CRuntime_Microsoft) extern (C++) + version(CRuntime_Microsoft) { public import dmd.root.longdouble : longdouble_soft, ld_sprint; - import dmd.root.strtold; } } @@ -167,22 +167,12 @@ extern (C++) struct CTFloat return isIdentical(fabs(r), real_t.infinity); } + @system static real_t parse(const(char)* literal, out bool isOutOfRange) { errno = 0; - version(CRuntime_DigitalMars) - { - auto save = __locale_decpoint; - __locale_decpoint = "."; - } - version(CRuntime_Microsoft) - { - auto r = cast(real_t) strtold_dm(literal, null); - } - else - auto r = strtold(literal, null); - version(CRuntime_DigitalMars) __locale_decpoint = save; + auto r = Port.strtold(literal); isOutOfRange = (errno == ERANGE); return r; } diff --git a/dmd/root/port.d b/dmd/root/port.d index c96ac86fd0..5a90e2f49f 100644 --- a/dmd/root/port.d +++ b/dmd/root/port.d @@ -11,6 +11,8 @@ module dmd.root.port; +import dmd.root.longdouble; + import core.stdc.ctype; import core.stdc.errno; import core.stdc.string; @@ -31,6 +33,8 @@ private extern (C) int _atoflt(float* value, const(char)* str); int _atodbl(double* value, const(char)* str); + + int _atoldbl(longdouble_soft* value, const(char)* str); } } @@ -135,6 +139,41 @@ extern (C++) struct Port } } + static longdouble strtold(const(char) *p) + { + version (CRuntime_DigitalMars) + { + auto save = __locale_decpoint; + __locale_decpoint = "."; + scope(exit) + __locale_decpoint = save; + } + version (CRuntime_Microsoft) + { + longdouble_soft r; + if (p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) + { + // _atoldbl() limits hex exponents by decimal max/min eponents + import dmd.root.strtold; + r = strtold_dm(p, null); + } + else + { + // strtold_dm() does not properly round decimal numbers + int res = _atoldbl(&r, p); + if (r.exponent() == 0x7fff && r.mantissa == 0) + r.mantissa = 0x8000_0000_0000_0000UL; // pseudo-infinity -> infinity + if (res == _UNDERFLOW || res == _OVERFLOW) + errno = ERANGE; + } + return cast(longdouble) r; + } + else + { + return .strtold(p, null); + } + } + // Little endian static void writelongLE(uint value, scope void* buffer) pure { diff --git a/tests/dmd/runnable/real_to_float.d b/tests/dmd/runnable/real_to_float.d index 8b5c9701b9..7d42b52f32 100644 --- a/tests/dmd/runnable/real_to_float.d +++ b/tests/dmd/runnable/real_to_float.d @@ -3,8 +3,9 @@ * "converting real to float uses double rounding for 64-bit code * causing unexpected results" */ + pragma(inline, false) -void test(real r) +void test22322(real r) { assert(r == 0x1.000002fffffffcp-1); double d = r; @@ -19,10 +20,51 @@ void test(real r) assert(frd == 0x1.000004p-1); } +// https://github.com/dlang/dmd/issues/18316 +pragma(inline, false) +void test18316(real closest) +{ + // Approximations to pi^2, accurate to 18 digits: + // real closest = 0x9.de9e64df22ef2d2p+0L; + real next = 0x9.de9e64df22ef2d3p+0L; + assert(closest != next); + + // A literal with 23 digits maps to the correct + // representation. + real dig23 = 9.86960_44010_89358_61883_45L; + assert (dig23 == closest); + + // 22 digits should also be (more than) sufficient, + // but no... + real dig22 = 9.86960_44010_89358_61883_5L; + assert (dig22 == closest); // Fails; should pass +} + +// https://github.com/dlang/dmd/issues/19733 +pragma(inline, false) +void test19733(real r) +{ + assert(r == 0x1FFFFFFFFFFFFFFFDp0L); +} + +pragma(inline, false) +void testDenormal(real rx) +{ + enum rd = 8.4052578577802337657e-4933L; + real r1 = rx; + real r2 = rd; + assert(r1 > 0); + assert(r1 == r2); +} + void main() { - static if (real.sizeof > 8) + static if (real.mant_dig == 64) { - test(0x1.000002fffffffcp-1); + // values must be passed to non-inlineable function to avoid "optimization" to double + test22322(0.5000000894069671353303618843710864894092082977294921875); + test18316(0x9.de9e64df22ef2d2p+0L); + test19733(36893488147419103229.0L); + testDenormal(0x1p-16384L); } } From b2df543db8b5e7618c71eba64f5746a82b3f9471 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 3 Jan 2026 01:12:13 +0200 Subject: [PATCH 237/440] Move `FuncDeclaration.addPreInvariant` and `FuncDeclaration.addPostInvariant` to `funcsem` (dlang/dmd!22341) --- dmd/declaration.h | 20 --------- dmd/frontend.h | 20 --------- dmd/func.d | 102 ---------------------------------------------- dmd/funcsem.d | 78 +++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 142 deletions(-) diff --git a/dmd/declaration.h b/dmd/declaration.h index 6882c28b7c..004df525f3 100644 --- a/dmd/declaration.h +++ b/dmd/declaration.h @@ -718,8 +718,6 @@ class FuncDeclaration : public Declaration bool needThis() override final; virtual bool isVirtual() const; bool isFinalFunc() const; - virtual bool addPreInvariant(); - virtual bool addPostInvariant(); const char *kind() const override; ParameterList getParameterList(); @@ -752,8 +750,6 @@ class FuncLiteralDeclaration final : public FuncDeclaration bool isNested() const override; AggregateDeclaration *isThis() override; bool isVirtual() const override; - bool addPreInvariant() override; - bool addPostInvariant() override; const char *kind() const override; const char *toPrettyChars(bool QualifyTypes = false) override; @@ -768,8 +764,6 @@ class CtorDeclaration final : public FuncDeclaration CtorDeclaration *syntaxCopy(Dsymbol *) override; const char *kind() const override; bool isVirtual() const override; - bool addPreInvariant() override; - bool addPostInvariant() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -779,8 +773,6 @@ class PostBlitDeclaration final : public FuncDeclaration public: PostBlitDeclaration *syntaxCopy(Dsymbol *) override; bool isVirtual() const override; - bool addPreInvariant() override; - bool addPostInvariant() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -791,8 +783,6 @@ class DtorDeclaration final : public FuncDeclaration DtorDeclaration *syntaxCopy(Dsymbol *) override; const char *kind() const override; bool isVirtual() const override; - bool addPreInvariant() override; - bool addPostInvariant() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -803,8 +793,6 @@ class StaticCtorDeclaration : public FuncDeclaration StaticCtorDeclaration *syntaxCopy(Dsymbol *) override; AggregateDeclaration *isThis() override final; bool isVirtual() const override final; - bool addPreInvariant() override final; - bool addPostInvariant() override final; void accept(Visitor *v) override { v->visit(this); } }; @@ -826,8 +814,6 @@ class StaticDtorDeclaration : public FuncDeclaration StaticDtorDeclaration *syntaxCopy(Dsymbol *) override; AggregateDeclaration *isThis() override final; bool isVirtual() const override final; - bool addPreInvariant() override final; - bool addPostInvariant() override final; void accept(Visitor *v) override { v->visit(this); } }; @@ -845,8 +831,6 @@ class InvariantDeclaration final : public FuncDeclaration public: InvariantDeclaration *syntaxCopy(Dsymbol *) override; bool isVirtual() const override; - bool addPreInvariant() override; - bool addPostInvariant() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -862,8 +846,6 @@ class UnitTestDeclaration final : public FuncDeclaration UnitTestDeclaration *syntaxCopy(Dsymbol *) override; AggregateDeclaration *isThis() override; bool isVirtual() const override; - bool addPreInvariant() override; - bool addPostInvariant() override; void accept(Visitor *v) override { v->visit(this); } }; @@ -874,8 +856,6 @@ class NewDeclaration final : public FuncDeclaration NewDeclaration *syntaxCopy(Dsymbol *) override; const char *kind() const override; bool isVirtual() const override; - bool addPreInvariant() override; - bool addPostInvariant() override; void accept(Visitor *v) override { v->visit(this); } }; diff --git a/dmd/frontend.h b/dmd/frontend.h index daf8cf35ca..1ba303802d 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -3921,8 +3921,6 @@ class FuncDeclaration : public Declaration bool needThis() final override; virtual bool isVirtual() const; bool isFinalFunc() const; - virtual bool addPreInvariant(); - virtual bool addPostInvariant(); const char* kind() const override; ParameterList getParameterList(); virtual FuncDeclaration* toAliasFunc(); @@ -3937,8 +3935,6 @@ class CtorDeclaration final : public FuncDeclaration CtorDeclaration* syntaxCopy(Dsymbol* s) override; const char* kind() const override; bool isVirtual() const override; - bool addPreInvariant() override; - bool addPostInvariant() override; void accept(Visitor* v) override; }; @@ -3948,8 +3944,6 @@ class DtorDeclaration final : public FuncDeclaration DtorDeclaration* syntaxCopy(Dsymbol* s) override; const char* kind() const override; bool isVirtual() const override; - bool addPreInvariant() override; - bool addPostInvariant() override; void accept(Visitor* v) override; }; @@ -3973,8 +3967,6 @@ class FuncLiteralDeclaration final : public FuncDeclaration bool isNested() const override; AggregateDeclaration* isThis() override; bool isVirtual() const override; - bool addPreInvariant() override; - bool addPostInvariant() override; const char* kind() const override; const char* toPrettyChars(bool QualifyTypes = false) override; void accept(Visitor* v) override; @@ -3985,8 +3977,6 @@ class InvariantDeclaration final : public FuncDeclaration public: InvariantDeclaration* syntaxCopy(Dsymbol* s) override; bool isVirtual() const override; - bool addPreInvariant() override; - bool addPostInvariant() override; void accept(Visitor* v) override; }; @@ -3996,8 +3986,6 @@ class NewDeclaration final : public FuncDeclaration NewDeclaration* syntaxCopy(Dsymbol* s) override; const char* kind() const override; bool isVirtual() const override; - bool addPreInvariant() override; - bool addPostInvariant() override; void accept(Visitor* v) override; }; @@ -4050,8 +4038,6 @@ class PostBlitDeclaration final : public FuncDeclaration public: PostBlitDeclaration* syntaxCopy(Dsymbol* s) override; bool isVirtual() const override; - bool addPreInvariant() override; - bool addPostInvariant() override; void accept(Visitor* v) override; }; @@ -4061,8 +4047,6 @@ class StaticCtorDeclaration : public FuncDeclaration StaticCtorDeclaration* syntaxCopy(Dsymbol* s) override; AggregateDeclaration* isThis() final override; bool isVirtual() const final override; - bool addPreInvariant() final override; - bool addPostInvariant() final override; void accept(Visitor* v) override; }; @@ -4081,8 +4065,6 @@ class StaticDtorDeclaration : public FuncDeclaration StaticDtorDeclaration* syntaxCopy(Dsymbol* s) override; AggregateDeclaration* isThis() final override; bool isVirtual() const final override; - bool addPreInvariant() final override; - bool addPostInvariant() final override; void accept(Visitor* v) override; }; @@ -4101,8 +4083,6 @@ class UnitTestDeclaration final : public FuncDeclaration UnitTestDeclaration* syntaxCopy(Dsymbol* s) override; AggregateDeclaration* isThis() override; bool isVirtual() const override; - bool addPreInvariant() override; - bool addPostInvariant() override; void accept(Visitor* v) override; }; diff --git a/dmd/func.d b/dmd/func.d index f80fd4600f..164863488f 100644 --- a/dmd/func.d +++ b/dmd/func.d @@ -676,18 +676,6 @@ extern (C++) class FuncDeclaration : Declaration return (cd !is null) && (cd.storage_class & STC.final_); } - bool addPreInvariant() - { - auto ad = isThis(); - return (ad && global.params.useInvariants == CHECKENABLE.on && (visibility.kind == Visibility.Kind.protected_ || visibility.kind == Visibility.Kind.public_ || visibility.kind == Visibility.Kind.export_) && !this.isNaked); - } - - bool addPostInvariant() - { - auto ad = isThis(); - return (ad && ad.inv && global.params.useInvariants == CHECKENABLE.on && (visibility.kind == Visibility.Kind.protected_ || visibility.kind == Visibility.Kind.public_ || visibility.kind == Visibility.Kind.export_) && !this.isNaked); - } - override const(char)* kind() const { return this.isGenerated ? "generated function" : "function"; @@ -895,16 +883,6 @@ extern (C++) final class FuncLiteralDeclaration : FuncDeclaration return false; } - override bool addPreInvariant() - { - return false; - } - - override bool addPostInvariant() - { - return false; - } - override const(char)* kind() const { // GCC requires the (char*) casts @@ -959,16 +937,6 @@ extern (C++) final class CtorDeclaration : FuncDeclaration return false; } - override bool addPreInvariant() - { - return false; - } - - override bool addPostInvariant() - { - return (isThis() && vthis && global.params.useInvariants == CHECKENABLE.on); - } - override void accept(Visitor v) { v.visit(this); @@ -998,16 +966,6 @@ extern (C++) final class PostBlitDeclaration : FuncDeclaration return false; } - override bool addPreInvariant() - { - return false; - } - - override bool addPostInvariant() - { - return (isThis() && vthis && global.params.useInvariants == CHECKENABLE.on); - } - override void accept(Visitor v) { v.visit(this); @@ -1050,16 +1008,6 @@ extern (C++) final class DtorDeclaration : FuncDeclaration return vtblIndex != -1; } - override bool addPreInvariant() - { - return (isThis() && vthis && global.params.useInvariants == CHECKENABLE.on); - } - - override bool addPostInvariant() - { - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -1100,16 +1048,6 @@ extern (C++) class StaticCtorDeclaration : FuncDeclaration return false; } - override final bool addPreInvariant() @nogc nothrow pure @safe - { - return false; - } - - override final bool addPostInvariant() @nogc nothrow pure @safe - { - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -1179,16 +1117,6 @@ extern (C++) class StaticDtorDeclaration : FuncDeclaration return false; } - override final bool addPreInvariant() - { - return false; - } - - override final bool addPostInvariant() - { - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -1244,16 +1172,6 @@ extern (C++) final class InvariantDeclaration : FuncDeclaration return false; } - override bool addPreInvariant() - { - return false; - } - - override bool addPostInvariant() - { - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -1304,16 +1222,6 @@ extern (C++) final class UnitTestDeclaration : FuncDeclaration return false; } - override bool addPreInvariant() - { - return false; - } - - override bool addPostInvariant() - { - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -1348,16 +1256,6 @@ extern (C++) final class NewDeclaration : FuncDeclaration return false; } - override bool addPreInvariant() - { - return false; - } - - override bool addPostInvariant() - { - return false; - } - override void accept(Visitor v) { v.visit(this); diff --git a/dmd/funcsem.d b/dmd/funcsem.d index 517c2f2389..2eb6690aa9 100644 --- a/dmd/funcsem.d +++ b/dmd/funcsem.d @@ -67,6 +67,84 @@ import dmd.typesem; import dmd.visitor; import dmd.visitor.statement_rewrite_walker; +bool addPostInvariant(FuncDeclaration _this) +{ + static bool visitFuncDeclaration(FuncDeclaration _this) + { + auto ad = _this.isThis(); + return ( + ad && + ad.inv && + global.params.useInvariants == CHECKENABLE.on && + (_this.visibility.kind == Visibility.Kind.protected_ || + _this.visibility.kind == Visibility.Kind.public_ || + _this.visibility.kind == Visibility.Kind.export_) && + !_this.isNaked + ); + } + + switch(_this.dsym) + { + case DSYM.funcLiteralDeclaration: + case DSYM.dtorDeclaration: + case DSYM.staticCtorDeclaration: + case DSYM.sharedStaticCtorDeclaration: + case DSYM.staticDtorDeclaration: + case DSYM.sharedStaticDtorDeclaration: + case DSYM.invariantDeclaration: + case DSYM.unitTestDeclaration: + case DSYM.newDeclaration: + return false; + case DSYM.ctorDeclaration: + { + auto cd = _this.isCtorDeclaration(); + return (cd.isThis() && cd.vthis && global.params.useInvariants == CHECKENABLE.on); + } + case DSYM.postBlitDeclaration: + { + auto dd = _this.isPostBlitDeclaration(); + return (dd.isThis() && dd.vthis && global.params.useInvariants == CHECKENABLE.on); + } + default: return visitFuncDeclaration(_this); + } +} + +bool addPreInvariant(FuncDeclaration _this) +{ + static bool visitFuncDeclaration(FuncDeclaration _this) + { + return ( + _this.isThis() && + global.params.useInvariants == CHECKENABLE.on && + (_this.visibility.kind == Visibility.Kind.protected_ || + _this.visibility.kind == Visibility.Kind.public_ || + _this.visibility.kind == Visibility.Kind.export_) && + !_this.isNaked + ); + } + + switch(_this.dsym) + { + case DSYM.funcLiteralDeclaration: + case DSYM.ctorDeclaration: + case DSYM.postBlitDeclaration: + case DSYM.staticCtorDeclaration: + case DSYM.sharedStaticCtorDeclaration: + case DSYM.staticDtorDeclaration: + case DSYM.sharedStaticDtorDeclaration: + case DSYM.invariantDeclaration: + case DSYM.unitTestDeclaration: + case DSYM.newDeclaration: + return false; + case DSYM.dtorDeclaration: + { + auto dd = _this.isDtorDeclaration(); + return (dd.isThis() && dd.vthis && global.params.useInvariants == CHECKENABLE.on); + } + default: return visitFuncDeclaration(_this); + } +} + // Determine if a function is pedantically virtual bool isVirtualMethod(FuncDeclaration _this) { From 637073a1cf2a31be093947ce962a2081fbaabd1e Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Sat, 3 Jan 2026 14:33:31 +0200 Subject: [PATCH 238/440] Move `FuncDeclaration.isVirtual` to `funcsem` (dlang/dmd!22340) --- dmd/cxxfrontend.d | 6 ++++ dmd/declaration.h | 13 ++------- dmd/dtoh.d | 1 + dmd/frontend.h | 10 ------- dmd/func.d | 70 ----------------------------------------------- dmd/funcsem.d | 61 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 71 insertions(+), 90 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index c91f0794f7..441affe92a 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -541,6 +541,12 @@ bool isVirtualMethod(FuncDeclaration fd) return dmd.funcsem.isVirtualMethod(fd); } +bool isVirtual(const FuncDeclaration fd) +{ + import dmd.funcsem; + return dmd.funcsem.isVirtual(fd); +} + /*********************************************************** * hdrgen.d */ diff --git a/dmd/declaration.h b/dmd/declaration.h index 004df525f3..d2e04b5f9a 100644 --- a/dmd/declaration.h +++ b/dmd/declaration.h @@ -45,6 +45,7 @@ namespace dmd bool equals(const Dsymbol * const ds, const Dsymbol * const s); bool hasNestedFrameRefs(FuncDeclaration *fd); bool isVirtualMethod(FuncDeclaration *fd); + bool isVirtual(const FuncDeclaration *fd); } //enum STC : ulong from astenums.d: @@ -716,7 +717,7 @@ class FuncDeclaration : public Declaration virtual bool isNested() const; AggregateDeclaration *isThis() override; bool needThis() override final; - virtual bool isVirtual() const; + bool isVirtual() const { return dmd::isVirtual(this); }; bool isFinalFunc() const; const char *kind() const override; ParameterList getParameterList(); @@ -749,7 +750,6 @@ class FuncLiteralDeclaration final : public FuncDeclaration FuncLiteralDeclaration *syntaxCopy(Dsymbol *) override; bool isNested() const override; AggregateDeclaration *isThis() override; - bool isVirtual() const override; const char *kind() const override; const char *toPrettyChars(bool QualifyTypes = false) override; @@ -763,7 +763,6 @@ class CtorDeclaration final : public FuncDeclaration d_bool isMoveCtor; CtorDeclaration *syntaxCopy(Dsymbol *) override; const char *kind() const override; - bool isVirtual() const override; void accept(Visitor *v) override { v->visit(this); } }; @@ -772,7 +771,6 @@ class PostBlitDeclaration final : public FuncDeclaration { public: PostBlitDeclaration *syntaxCopy(Dsymbol *) override; - bool isVirtual() const override; void accept(Visitor *v) override { v->visit(this); } }; @@ -782,7 +780,6 @@ class DtorDeclaration final : public FuncDeclaration public: DtorDeclaration *syntaxCopy(Dsymbol *) override; const char *kind() const override; - bool isVirtual() const override; void accept(Visitor *v) override { v->visit(this); } }; @@ -792,7 +789,6 @@ class StaticCtorDeclaration : public FuncDeclaration public: StaticCtorDeclaration *syntaxCopy(Dsymbol *) override; AggregateDeclaration *isThis() override final; - bool isVirtual() const override final; void accept(Visitor *v) override { v->visit(this); } }; @@ -813,7 +809,6 @@ class StaticDtorDeclaration : public FuncDeclaration StaticDtorDeclaration *syntaxCopy(Dsymbol *) override; AggregateDeclaration *isThis() override final; - bool isVirtual() const override final; void accept(Visitor *v) override { v->visit(this); } }; @@ -830,7 +825,7 @@ class InvariantDeclaration final : public FuncDeclaration { public: InvariantDeclaration *syntaxCopy(Dsymbol *) override; - bool isVirtual() const override; + void accept(Visitor *v) override { v->visit(this); } }; @@ -845,7 +840,6 @@ class UnitTestDeclaration final : public FuncDeclaration UnitTestDeclaration *syntaxCopy(Dsymbol *) override; AggregateDeclaration *isThis() override; - bool isVirtual() const override; void accept(Visitor *v) override { v->visit(this); } }; @@ -855,7 +849,6 @@ class NewDeclaration final : public FuncDeclaration public: NewDeclaration *syntaxCopy(Dsymbol *) override; const char *kind() const override; - bool isVirtual() const override; void accept(Visitor *v) override { v->visit(this); } }; diff --git a/dmd/dtoh.d b/dmd/dtoh.d index 839127ca42..a17bfe6706 100644 --- a/dmd/dtoh.d +++ b/dmd/dtoh.d @@ -21,6 +21,7 @@ import dmd.arraytypes; import dmd.dsymbolsem; import dmd.templatesem : computeOneMember; import dmd.expressionsem : toInteger; +import dmd.funcsem : isVirtual; import dmd.errors; import dmd.errorsink; import dmd.globals; diff --git a/dmd/frontend.h b/dmd/frontend.h index 1ba303802d..bbd9447782 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -3919,7 +3919,6 @@ class FuncDeclaration : public Declaration virtual bool isNested() const; AggregateDeclaration* isThis() override; bool needThis() final override; - virtual bool isVirtual() const; bool isFinalFunc() const; const char* kind() const override; ParameterList getParameterList(); @@ -3934,7 +3933,6 @@ class CtorDeclaration final : public FuncDeclaration bool isMoveCtor; CtorDeclaration* syntaxCopy(Dsymbol* s) override; const char* kind() const override; - bool isVirtual() const override; void accept(Visitor* v) override; }; @@ -3943,7 +3941,6 @@ class DtorDeclaration final : public FuncDeclaration public: DtorDeclaration* syntaxCopy(Dsymbol* s) override; const char* kind() const override; - bool isVirtual() const override; void accept(Visitor* v) override; }; @@ -3966,7 +3963,6 @@ class FuncLiteralDeclaration final : public FuncDeclaration FuncLiteralDeclaration* syntaxCopy(Dsymbol* s) override; bool isNested() const override; AggregateDeclaration* isThis() override; - bool isVirtual() const override; const char* kind() const override; const char* toPrettyChars(bool QualifyTypes = false) override; void accept(Visitor* v) override; @@ -3976,7 +3972,6 @@ class InvariantDeclaration final : public FuncDeclaration { public: InvariantDeclaration* syntaxCopy(Dsymbol* s) override; - bool isVirtual() const override; void accept(Visitor* v) override; }; @@ -3985,7 +3980,6 @@ class NewDeclaration final : public FuncDeclaration public: NewDeclaration* syntaxCopy(Dsymbol* s) override; const char* kind() const override; - bool isVirtual() const override; void accept(Visitor* v) override; }; @@ -4037,7 +4031,6 @@ class PostBlitDeclaration final : public FuncDeclaration { public: PostBlitDeclaration* syntaxCopy(Dsymbol* s) override; - bool isVirtual() const override; void accept(Visitor* v) override; }; @@ -4046,7 +4039,6 @@ class StaticCtorDeclaration : public FuncDeclaration public: StaticCtorDeclaration* syntaxCopy(Dsymbol* s) override; AggregateDeclaration* isThis() final override; - bool isVirtual() const final override; void accept(Visitor* v) override; }; @@ -4064,7 +4056,6 @@ class StaticDtorDeclaration : public FuncDeclaration VarDeclaration* vgate; StaticDtorDeclaration* syntaxCopy(Dsymbol* s) override; AggregateDeclaration* isThis() final override; - bool isVirtual() const final override; void accept(Visitor* v) override; }; @@ -4082,7 +4073,6 @@ class UnitTestDeclaration final : public FuncDeclaration Array deferredNested; UnitTestDeclaration* syntaxCopy(Dsymbol* s) override; AggregateDeclaration* isThis() override; - bool isVirtual() const override; void accept(Visitor* v) override; }; diff --git a/dmd/func.d b/dmd/func.d index 164863488f..9b397970ec 100644 --- a/dmd/func.d +++ b/dmd/func.d @@ -631,29 +631,6 @@ extern (C++) class FuncDeclaration : Declaration return toAliasFunc().isThis() !is null; } - // Determine if function goes into virtual function pointer table - bool isVirtual() const - { - if (toAliasFunc() != this) - return toAliasFunc().isVirtual(); - - auto p = toParent(); - - if (!isMember || !p.isClassDeclaration) - return false; - - if (p.isClassDeclaration.classKind == ClassKind.objc) - return .objc.isVirtual(this); - - version (none) - { - printf("FuncDeclaration::isVirtual(%s)\n", toChars()); - printf("isMember:%p isStatic:%d private:%d ctor:%d !Dlinkage:%d\n", isMember(), isStatic(), visibility == Visibility.Kind.private_, isCtorDeclaration(), linkage != LINK.d); - printf("result is %d\n", isMember() && !(isStatic() || visibility == Visibility.Kind.private_ || visibility == Visibility.Kind.package_) && p.isClassDeclaration() && !(p.isInterfaceDeclaration() && isFinalFunc())); - } - return !(isStatic() || visibility.kind == Visibility.Kind.private_ || visibility.kind == Visibility.Kind.package_) && !(p.isInterfaceDeclaration() && isFinalFunc()); - } - final bool isFinalFunc() const { if (toAliasFunc() != this) @@ -878,11 +855,6 @@ extern (C++) final class FuncLiteralDeclaration : FuncDeclaration return tok == TOK.delegate_ ? super.isThis() : null; } - override bool isVirtual() const - { - return false; - } - override const(char)* kind() const { // GCC requires the (char*) casts @@ -932,11 +904,6 @@ extern (C++) final class CtorDeclaration : FuncDeclaration isMoveCtor ? "move constructor" : "constructor"; } - override bool isVirtual() const - { - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -961,11 +928,6 @@ extern (C++) final class PostBlitDeclaration : FuncDeclaration return dd; } - override bool isVirtual() const - { - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -1001,13 +963,6 @@ extern (C++) final class DtorDeclaration : FuncDeclaration return "destructor"; } - override bool isVirtual() const - { - // D dtor's don't get put into the vtbl[] - // this is a hack so that extern(C++) destructors report as virtual, which are manually added to the vtable - return vtblIndex != -1; - } - override void accept(Visitor v) { v.visit(this); @@ -1043,11 +998,6 @@ extern (C++) class StaticCtorDeclaration : FuncDeclaration return null; } - override final bool isVirtual() const @nogc nothrow pure @safe - { - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -1112,11 +1062,6 @@ extern (C++) class StaticDtorDeclaration : FuncDeclaration return null; } - override final bool isVirtual() const - { - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -1167,11 +1112,6 @@ extern (C++) final class InvariantDeclaration : FuncDeclaration return id; } - override bool isVirtual() const - { - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -1217,11 +1157,6 @@ extern (C++) final class UnitTestDeclaration : FuncDeclaration return null; } - override bool isVirtual() const - { - return false; - } - override void accept(Visitor v) { v.visit(this); @@ -1251,11 +1186,6 @@ extern (C++) final class NewDeclaration : FuncDeclaration return "allocator"; } - override bool isVirtual() const - { - return false; - } - override void accept(Visitor v) { v.visit(this); diff --git a/dmd/funcsem.d b/dmd/funcsem.d index 2eb6690aa9..81ea608641 100644 --- a/dmd/funcsem.d +++ b/dmd/funcsem.d @@ -145,6 +145,67 @@ bool addPreInvariant(FuncDeclaration _this) } } +// Determine if function goes into virtual function pointer table +bool isVirtual(const FuncDeclaration _this) +{ + static bool visitFuncDeclaration(const FuncDeclaration _this) + { + if (_this.toAliasFunc() != _this) + return _this.toAliasFunc().isVirtual(); + + auto p = _this.toParent(); + + if (!_this.isMember || !p.isClassDeclaration) + return false; + + if (p.isClassDeclaration.classKind == ClassKind.objc) + return objc.isVirtual(_this); + + version (none) + { + printf("FuncDeclaration::isVirtual(%s)\n", _this.toChars()); + printf("isMember:%p isStatic:%d private:%d ctor:%d !Dlinkage:%d\n", + _this.isMember(), + _this.isStatic(), + _this.visibility.kind == Visibility.Kind.private_, + _this.isCtorDeclaration() !is null, + _this._linkage != LINK.d + ); + printf("result is %d\n", + _this.isMember() && + !(_this.isStatic() || _this.visibility.kind == Visibility.Kind.private_ || _this.visibility.kind == Visibility.Kind.package_) && + p.isClassDeclaration() && + !(p.isInterfaceDeclaration() && _this.isFinalFunc()) + ); + } + + return !(_this.isStatic() || + _this.visibility.kind == Visibility.Kind.private_ || + _this.visibility.kind == Visibility.Kind.package_) && + !(p.isInterfaceDeclaration() && _this.isFinalFunc()); + } + + switch(_this.dsym) + { + case DSYM.funcLiteralDeclaration: + case DSYM.ctorDeclaration: + case DSYM.postBlitDeclaration: + case DSYM.staticCtorDeclaration: + case DSYM.sharedStaticCtorDeclaration: + case DSYM.staticDtorDeclaration: + case DSYM.sharedStaticDtorDeclaration: + case DSYM.invariantDeclaration: + case DSYM.unitTestDeclaration: + case DSYM.newDeclaration: + return false; + // D dtor's don't get put into the vtbl[] + // this is a hack so that extern(C++) destructors report as virtual + // which are manually added to the vtable + case DSYM.dtorDeclaration: return _this.vtblIndex != -1; + default: return visitFuncDeclaration(_this); + } +} + // Determine if a function is pedantically virtual bool isVirtualMethod(FuncDeclaration _this) { From 8964ad23118a826ecd83b00a17e9184a6ed83e7c Mon Sep 17 00:00:00 2001 From: Iskaban10 Date: Sat, 3 Jan 2026 18:23:45 +0530 Subject: [PATCH 239/440] Added issue test case --- tests/dmd/fail_compilation/diag21381.d | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/dmd/fail_compilation/diag21381.d diff --git a/tests/dmd/fail_compilation/diag21381.d b/tests/dmd/fail_compilation/diag21381.d new file mode 100644 index 0000000000..b0c2adee57 --- /dev/null +++ b/tests/dmd/fail_compilation/diag21381.d @@ -0,0 +1,15 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/diag21381.d(15): Error: undefined identifier `xyx`, did you mean struct `xyz`? +--- +*/ +// https://github.com/dlang/dmd/issues/21381 + +enum plusOne(int x) = x + 1; +struct xyz{} + +alias PlusOne = + plusOne + ! + xyx; \ No newline at end of file From 874ed4f66d043df9fb33026c2f68a1e5e021d540 Mon Sep 17 00:00:00 2001 From: Iskaban10 Date: Sat, 3 Jan 2026 18:28:27 +0530 Subject: [PATCH 240/440] Updated issue test case --- tests/dmd/fail_compilation/diag21381.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/dmd/fail_compilation/diag21381.d b/tests/dmd/fail_compilation/diag21381.d index b0c2adee57..3f7ff991c9 100644 --- a/tests/dmd/fail_compilation/diag21381.d +++ b/tests/dmd/fail_compilation/diag21381.d @@ -12,4 +12,5 @@ struct xyz{} alias PlusOne = plusOne ! - xyx; \ No newline at end of file + xyx; + \ No newline at end of file From 2fbfae1259c2766c70acbef4583a676de7dd7834 Mon Sep 17 00:00:00 2001 From: Iskaban10 Date: Sat, 3 Jan 2026 18:29:45 +0530 Subject: [PATCH 241/440] Updated issue test case --- tests/dmd/fail_compilation/diag21381.d | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/dmd/fail_compilation/diag21381.d b/tests/dmd/fail_compilation/diag21381.d index 3f7ff991c9..b0c2adee57 100644 --- a/tests/dmd/fail_compilation/diag21381.d +++ b/tests/dmd/fail_compilation/diag21381.d @@ -12,5 +12,4 @@ struct xyz{} alias PlusOne = plusOne ! - xyx; - \ No newline at end of file + xyx; \ No newline at end of file From 97c44c7b5cd3b788d368a6bd76cdcc9de1a6d92a Mon Sep 17 00:00:00 2001 From: Iskaban10 Date: Sat, 3 Jan 2026 18:31:58 +0530 Subject: [PATCH 242/440] Updated issue test case --- tests/dmd/fail_compilation/diag21381.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dmd/fail_compilation/diag21381.d b/tests/dmd/fail_compilation/diag21381.d index b0c2adee57..0b59a553a5 100644 --- a/tests/dmd/fail_compilation/diag21381.d +++ b/tests/dmd/fail_compilation/diag21381.d @@ -12,4 +12,4 @@ struct xyz{} alias PlusOne = plusOne ! - xyx; \ No newline at end of file + xyx; \ No newline at end of file From 9ce5c7f6a7024f01462cb1d216eaa7c5e95092d8 Mon Sep 17 00:00:00 2001 From: Iskaban10 Date: Sat, 3 Jan 2026 18:34:04 +0530 Subject: [PATCH 243/440] Updated issue test case --- tests/dmd/fail_compilation/diag21381.d | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/dmd/fail_compilation/diag21381.d b/tests/dmd/fail_compilation/diag21381.d index 0b59a553a5..b2c0caf9c9 100644 --- a/tests/dmd/fail_compilation/diag21381.d +++ b/tests/dmd/fail_compilation/diag21381.d @@ -12,4 +12,7 @@ struct xyz{} alias PlusOne = plusOne ! - xyx; \ No newline at end of file + xyx; + + + From 6ffdeaecf99edfc93f8439f5fd59da5264f19e34 Mon Sep 17 00:00:00 2001 From: Iskaban10 Date: Sat, 3 Jan 2026 18:38:53 +0530 Subject: [PATCH 244/440] Updated issue test case --- tests/dmd/fail_compilation/diag21381.d | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/dmd/fail_compilation/diag21381.d b/tests/dmd/fail_compilation/diag21381.d index b2c0caf9c9..b0c2adee57 100644 --- a/tests/dmd/fail_compilation/diag21381.d +++ b/tests/dmd/fail_compilation/diag21381.d @@ -12,7 +12,4 @@ struct xyz{} alias PlusOne = plusOne ! - xyx; - - - + xyx; \ No newline at end of file From cf63baa45fd51020f73105eac2769b971cc7be25 Mon Sep 17 00:00:00 2001 From: Iskaban10 Date: Sat, 3 Jan 2026 18:40:48 +0530 Subject: [PATCH 245/440] Updated issue test case --- tests/dmd/fail_compilation/diag21381.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dmd/fail_compilation/diag21381.d b/tests/dmd/fail_compilation/diag21381.d index b0c2adee57..1a36ec584a 100644 --- a/tests/dmd/fail_compilation/diag21381.d +++ b/tests/dmd/fail_compilation/diag21381.d @@ -12,4 +12,4 @@ struct xyz{} alias PlusOne = plusOne ! - xyx; \ No newline at end of file + xyx; From ca24db388de93f4b2b1f4126f9491944c76f4884 Mon Sep 17 00:00:00 2001 From: Iskaban10 Date: Sat, 3 Jan 2026 20:19:41 +0530 Subject: [PATCH 246/440] Added Test --- tests/dmd/fail_compilation/diag21413.d | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/dmd/fail_compilation/diag21413.d diff --git a/tests/dmd/fail_compilation/diag21413.d b/tests/dmd/fail_compilation/diag21413.d new file mode 100644 index 0000000000..9f7c8e9e0f --- /dev/null +++ b/tests/dmd/fail_compilation/diag21413.d @@ -0,0 +1,15 @@ +/* +TEST_OUTPUT: +--- +fail_compilation\diag21413.d(13): Error: undefined identifier `Potato` +--- +*/ +// https://github.com/dlang/dmd/issues/21413 + +void main() +{ + throw + new + Potato + (); +} From 28ffc12cc27006a31c44c8e6663df0371b7831a3 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Mon, 5 Jan 2026 20:57:57 +0800 Subject: [PATCH 247/440] Implement `with(auto x = ...)` (dlang/dmd!22196) --- dmd/frontend.h | 1 + dmd/parse.d | 21 +++++++++++---------- dmd/statement.d | 10 ++++++++-- dmd/statement.h | 1 + dmd/statementsem.d | 26 ++++++++++++++++++++++++++ tests/dmd/runnable/with.d | 15 +++++++++++++++ 6 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 tests/dmd/runnable/with.d diff --git a/dmd/frontend.h b/dmd/frontend.h index bbd9447782..1cb55a76fc 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -5321,6 +5321,7 @@ class WhileStatement final : public Statement class WithStatement final : public Statement { public: + Parameter* prm; Expression* exp; Statement* _body; VarDeclaration* wthis; diff --git a/dmd/parse.d b/dmd/parse.d index 419b0ae8a8..0d87ecfaa9 100644 --- a/dmd/parse.d +++ b/dmd/parse.d @@ -5758,14 +5758,13 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer } /*** - * Parse an assignment condition for `if`, `switch` or `while` statements. + * Parse an assignment condition for `if`, `switch`, `while` or `with` statements. * * Returns: * The variable that is declared inside the condition */ - AST.Parameter parseAssignCondition() + AST.Parameter parseAssignCondition(bool _with = false) { - AST.Parameter param = null; STC storageClass = STC.none; STC stc = STC.none; Lwhile: @@ -5834,7 +5833,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer const aloc = token.loc; nextToken(); check(TOK.assign); - param = new AST.Parameter(aloc, storageClass, at, ai, null, null); + return new AST.Parameter(aloc, storageClass, at, ai, null, null); } else if (isDeclaration(&token, NeedDeclaratorId.must, TOK.assign, null)) { @@ -5842,12 +5841,13 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer const aloc = token.loc; AST.Type at = parseType(&ai); check(TOK.assign); - param = new AST.Parameter(aloc, storageClass, at, ai, null, null); + return new AST.Parameter(aloc, storageClass, at, ai, null, null); } - else if (storageClass != 0) + else if (storageClass != 0 && !_with) + { error("found `%s` while expecting `=` or identifier", n.toChars()); - - return param; + } + return null; } /***************************************** @@ -6659,10 +6659,11 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer nextToken(); check(TOK.leftParenthesis); + auto param = parseAssignCondition(true); exp = parseExpression(); - closeCondition("with", null, exp); + closeCondition("with", param, exp); _body = parseStatement(ParseStatementFlags.scope_, null, &endloc); - s = new AST.WithStatement(loc, exp, _body, endloc); + s = new AST.WithStatement(loc, param, exp, _body, endloc); break; } case TOK.try_: diff --git a/dmd/statement.d b/dmd/statement.d index baf928a13f..890a5d4aa0 100644 --- a/dmd/statement.d +++ b/dmd/statement.d @@ -1416,14 +1416,16 @@ extern (C++) final class SynchronizedStatement : Statement */ extern (C++) final class WithStatement : Statement { + Parameter prm; Expression exp; Statement _body; VarDeclaration wthis; Loc endloc; - extern (D) this(Loc loc, Expression exp, Statement _body, Loc endloc) @safe + extern (D) this(Loc loc, Parameter prm, Expression exp, Statement _body, Loc endloc) @safe { super(loc, STMT.With); + this.prm = prm; this.exp = exp; this._body = _body; this.endloc = endloc; @@ -1431,7 +1433,11 @@ extern (C++) final class WithStatement : Statement override WithStatement syntaxCopy() { - return new WithStatement(loc, exp.syntaxCopy(), _body ? _body.syntaxCopy() : null, endloc); + return new WithStatement(loc, + prm ? prm.syntaxCopy() : null, + exp.syntaxCopy(), + _body ? _body.syntaxCopy() : null, + endloc); } override void accept(Visitor v) diff --git a/dmd/statement.h b/dmd/statement.h index c7d941d343..469e3902e9 100644 --- a/dmd/statement.h +++ b/dmd/statement.h @@ -561,6 +561,7 @@ class SynchronizedStatement final : public Statement class WithStatement final : public Statement { public: + Parameter *prm; Expression *exp; Statement *_body; VarDeclaration *wthis; diff --git a/dmd/statementsem.d b/dmd/statementsem.d index 35d4b1bf3f..8ce4b43663 100644 --- a/dmd/statementsem.d +++ b/dmd/statementsem.d @@ -3232,6 +3232,32 @@ Statement statementSemanticVisit(Statement s, Scope* sc) sym.parent = sc.scopesym; sym.endlinnum = ws.endloc.linnum; } + else if (ws.prm) + { + /* Re-write to + * { + * auto prm = exp + * with(prm) + * { + * ... + * } + * } + */ + auto tmp_init = new ExpInitializer(ws.loc, ws.exp); + auto tmp = new VarDeclaration(ws.loc, ws.prm.type, ws.prm.ident, tmp_init); + // tmp.storage_class |= STC.temp; //NOTE(mojo): idk + tmp.dsymbolSemantic(sc); + + auto es = new ExpStatement(ws.loc, tmp); + ws.exp = new VarExp(ws.loc, tmp); + + ws.prm = null; + auto cs = new CompoundStatement(ws.loc, es, ws); + Statement ss = new ScopeStatement(ws.loc, cs, ws.endloc); + result = ss.statementSemantic(sc); + + return; + } else { Type texp = ws.exp.type; diff --git a/tests/dmd/runnable/with.d b/tests/dmd/runnable/with.d new file mode 100644 index 0000000000..2f946622d2 --- /dev/null +++ b/tests/dmd/runnable/with.d @@ -0,0 +1,15 @@ + +struct S +{ + int x; +} +S s; +void main() +{ + with(auto ss = S()) + { + x = 42; + s.x = x; + } + assert(s.x == 42); +} From c1119d3766cb4bec09f8bfb0d5f6a25b926c56d9 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 5 Jan 2026 13:12:41 +0000 Subject: [PATCH 248/440] ImportC: Support bare function-like macro calls in #define (dlang/dmd!22347) Convert object-like macros whose value is a bare function-like macro invocation (without outer parentheses): #define FUNC(x) ((x) * 2) #define RESULT FUNC(5) // Now converted to D Previously only the parenthesized form was recognized: #define RESULT (FUNC(5)) // Already worked This is restricted to bare function calls only (not expressions like `FUNC(5) + 1`) to preserve C semantics - function call `()` has highest precedence in C, so bare calls have identical behavior in both languages. --- dmd/cparse.d | 58 ++++++++++++++++++++------ tests/dmd/compilable/imports/defines.c | 5 +++ tests/dmd/compilable/testdefines.d | 5 +++ 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/dmd/cparse.d b/dmd/cparse.d index 05f0edaa0c..53f5b46f35 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -5629,6 +5629,24 @@ final class CParser(AST) : Parser!AST ++p; // advance to start of next line } + /* Create a nullary template function from an expression: + * auto id()() { return exp; } + */ + void addNullaryTemplate(AST.Expression exp, Identifier id) + { + auto ret = new AST.ReturnStatement(exp.loc, exp); + auto parameterList = AST.ParameterList(new AST.Parameters(), VarArg.none, STC.none); + STC stc = STC.auto_; + auto tf = new AST.TypeFunction(parameterList, null, LINK.d, stc); + auto fd = new AST.FuncDeclaration(exp.loc, exp.loc, id, stc, tf, 0); + fd.fbody = ret; + AST.Dsymbols* decldefs = new AST.Dsymbols(); + decldefs.push(fd); + AST.TemplateParameters* tpl = new AST.TemplateParameters(); + auto tempdecl = new AST.TemplateDeclaration(exp.loc, id, tpl, null, decldefs, false); + addSym(tempdecl); + } + while (p < endp) { //printf("|%s|\n", p); @@ -5752,6 +5770,33 @@ final class CParser(AST) : Parser!AST } break; + case TOK.identifier: + { + /* Look for: + * #define ID identifier ( args ) + * where the macro body is exactly a function-like macro call + * (no additional operators that could cause precedence issues). + * Rewrite to a template function: + * auto ID()() { return identifier(args); } + */ + if (params) + break; // function-like macro with params handled elsewhere + eLatch.sawErrors = false; + auto exp = cparseExpression(); + if (eLatch.sawErrors) // parsing errors + break; // abandon this #define + if (token.value != TOK.endOfFile) // did not consume the entire line + break; + // Only allow bare function calls to avoid precedence issues. + // E.g., `#define X FUNC(5)` is safe, but `#define X FUNC(5) + 1` + // would have different semantics in D vs C when used as `X * 2`. + if (!exp.isCallExp()) + break; + addNullaryTemplate(exp, id); + ++p; + continue; + } + case TOK.leftParenthesis: { /* Look for: @@ -5771,18 +5816,7 @@ final class CParser(AST) : Parser!AST nextToken(); if (token.value != TOK.endOfFile) break; - auto ret = new AST.ReturnStatement(exp.loc, exp); - auto parameterList = AST.ParameterList(new AST.Parameters(), VarArg.none, STC.none); - STC stc = STC.auto_; - auto tf = new AST.TypeFunction(parameterList, null, LINK.d, stc); - auto fd = new AST.FuncDeclaration(exp.loc, exp.loc, id, stc, tf, 0); - fd.fbody = ret; - AST.Dsymbols* decldefs = new AST.Dsymbols(); - decldefs.push(fd); - AST.TemplateParameters* tpl = new AST.TemplateParameters(); - AST.Expression constraint = null; - auto tempdecl = new AST.TemplateDeclaration(exp.loc, id, tpl, constraint, decldefs, false); - addSym(tempdecl); + addNullaryTemplate(exp, id); ++p; continue; } diff --git a/tests/dmd/compilable/imports/defines.c b/tests/dmd/compilable/imports/defines.c index 420679a4fc..38f57b0c6e 100644 --- a/tests/dmd/compilable/imports/defines.c +++ b/tests/dmd/compilable/imports/defines.c @@ -63,3 +63,8 @@ int pr16199c() #define NEGATIVE_U64 -4LLU #define NEGATIVE_F32 -5.0f #define NEGATIVE_F64 -6.0 + +// https://github.com/dlang/dmd/pull/22347 - bare function-like macro calls +#define DOUBLE(x) ((x) * 2) +#define BARE_CALL DOUBLE(5) // bare function-like macro call (no outer parens) +#define PAREN_CALL (DOUBLE(5)) // parenthesized call (already works) diff --git a/tests/dmd/compilable/testdefines.d b/tests/dmd/compilable/testdefines.d index 58eefb7256..e159c8c687 100644 --- a/tests/dmd/compilable/testdefines.d +++ b/tests/dmd/compilable/testdefines.d @@ -39,3 +39,8 @@ static assert(is(typeof(NEGATIVE_I64) == long)); static assert(is(typeof(NEGATIVE_U64) == ulong)); static assert(is(typeof(NEGATIVE_F32) == float)); static assert(is(typeof(NEGATIVE_F64) == double)); + +// https://github.com/dlang/dmd/pull/22347 - bare function-like macro calls +static assert(DOUBLE(5) == 10); +static assert(BARE_CALL == 10); // bare call now works +static assert(PAREN_CALL == 10); // parenthesized already worked From 1d0a469ea10bd7dfc89f8fade0f0c1f49a08bfb1 Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Mon, 5 Jan 2026 14:18:11 +0100 Subject: [PATCH 249/440] refactor: move Port.strtold as strtold_ms to strtold.d to make life easier for GDC (dlang/dmd!22346) --- dmd/frontend.h | 1 - dmd/root/ctfloat.d | 7 +++---- dmd/root/port.d | 39 --------------------------------------- 3 files changed, 3 insertions(+), 44 deletions(-) diff --git a/dmd/frontend.h b/dmd/frontend.h index 1cb55a76fc..985209ace8 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -9040,7 +9040,6 @@ struct Port final static char* strupr(char* s); static bool isFloat32LiteralOutOfRange(const char* s); static bool isFloat64LiteralOutOfRange(const char* s); - static _d_real strtold(const char* p); static void writelongLE(uint32_t value, void* buffer); static uint32_t readlongLE(const void* const buffer); static void writelongBE(uint32_t value, void* buffer); diff --git a/dmd/root/ctfloat.d b/dmd/root/ctfloat.d index 1da114bd65..0a59771afc 100644 --- a/dmd/root/ctfloat.d +++ b/dmd/root/ctfloat.d @@ -25,11 +25,10 @@ import dmd.root.port; private { - version(CRuntime_DigitalMars) __gshared extern (C) extern const(char)* __locale_decpoint; - version(CRuntime_Microsoft) { - public import dmd.root.longdouble : longdouble_soft, ld_sprint; + import dmd.root.longdouble : longdouble_soft, ld_sprint; + import dmd.root.strtold : strtold = strtold_ms; } } @@ -172,7 +171,7 @@ extern (C++) struct CTFloat static real_t parse(const(char)* literal, out bool isOutOfRange) { errno = 0; - auto r = Port.strtold(literal); + auto r = strtold(literal, null); isOutOfRange = (errno == ERANGE); return r; } diff --git a/dmd/root/port.d b/dmd/root/port.d index 5a90e2f49f..c96ac86fd0 100644 --- a/dmd/root/port.d +++ b/dmd/root/port.d @@ -11,8 +11,6 @@ module dmd.root.port; -import dmd.root.longdouble; - import core.stdc.ctype; import core.stdc.errno; import core.stdc.string; @@ -33,8 +31,6 @@ private extern (C) int _atoflt(float* value, const(char)* str); int _atodbl(double* value, const(char)* str); - - int _atoldbl(longdouble_soft* value, const(char)* str); } } @@ -139,41 +135,6 @@ extern (C++) struct Port } } - static longdouble strtold(const(char) *p) - { - version (CRuntime_DigitalMars) - { - auto save = __locale_decpoint; - __locale_decpoint = "."; - scope(exit) - __locale_decpoint = save; - } - version (CRuntime_Microsoft) - { - longdouble_soft r; - if (p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) - { - // _atoldbl() limits hex exponents by decimal max/min eponents - import dmd.root.strtold; - r = strtold_dm(p, null); - } - else - { - // strtold_dm() does not properly round decimal numbers - int res = _atoldbl(&r, p); - if (r.exponent() == 0x7fff && r.mantissa == 0) - r.mantissa = 0x8000_0000_0000_0000UL; // pseudo-infinity -> infinity - if (res == _UNDERFLOW || res == _OVERFLOW) - errno = ERANGE; - } - return cast(longdouble) r; - } - else - { - return .strtold(p, null); - } - } - // Little endian static void writelongLE(uint value, scope void* buffer) pure { From 0c758138a9eed23a4623a13339c8dd8531351b8f Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 5 Jan 2026 23:17:34 +0000 Subject: [PATCH 250/440] ImportC: Add test for function-like macro calling another macro (dlang/dmd!22349) * ImportC: Add test for function-like macro calling another macro Tests the `if (params) break;` branch in TOK.identifier case, ensuring function-like macros with identifier bodies are handled by caseFunctionLike, not the new nullary template path. * ImportC: Replace unreachable branch with assertion When we reach TOK.identifier case, params is always false because if params were true (macro name followed by '('), the next token would be TOK.leftParenthesis, not TOK.identifier. --- dmd/cparse.d | 3 +-- tests/dmd/compilable/imports/defines.c | 1 + tests/dmd/compilable/testdefines.d | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dmd/cparse.d b/dmd/cparse.d index 53f5b46f35..3c0b9af163 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -5779,8 +5779,7 @@ final class CParser(AST) : Parser!AST * Rewrite to a template function: * auto ID()() { return identifier(args); } */ - if (params) - break; // function-like macro with params handled elsewhere + assert(!params); // would be TOK.leftParenthesis eLatch.sawErrors = false; auto exp = cparseExpression(); if (eLatch.sawErrors) // parsing errors diff --git a/tests/dmd/compilable/imports/defines.c b/tests/dmd/compilable/imports/defines.c index 38f57b0c6e..a805627db6 100644 --- a/tests/dmd/compilable/imports/defines.c +++ b/tests/dmd/compilable/imports/defines.c @@ -68,3 +68,4 @@ int pr16199c() #define DOUBLE(x) ((x) * 2) #define BARE_CALL DOUBLE(5) // bare function-like macro call (no outer parens) #define PAREN_CALL (DOUBLE(5)) // parenthesized call (already works) +#define WRAPPER(x) DOUBLE(x) // function-like macro calling another macro diff --git a/tests/dmd/compilable/testdefines.d b/tests/dmd/compilable/testdefines.d index e159c8c687..ba193d2fda 100644 --- a/tests/dmd/compilable/testdefines.d +++ b/tests/dmd/compilable/testdefines.d @@ -44,3 +44,4 @@ static assert(is(typeof(NEGATIVE_F64) == double)); static assert(DOUBLE(5) == 10); static assert(BARE_CALL == 10); // bare call now works static assert(PAREN_CALL == 10); // parenthesized already worked +static assert(WRAPPER(3) == 6); // function-like macro calling another macro From 678ad09cfc30acd6f74213444f7b13421ddf8274 Mon Sep 17 00:00:00 2001 From: Sergii Kuzko Date: Tue, 6 Jan 2026 10:36:31 +0300 Subject: [PATCH 251/440] fixroot_array_memset_v2 --- dmd/root/array.d | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/dmd/root/array.d b/dmd/root/array.d index 217945e6be..5f8c01a0f9 100644 --- a/dmd/root/array.d +++ b/dmd/root/array.d @@ -51,7 +51,11 @@ public: ~this() pure nothrow { - debug (stomp) memset(data.ptr, 0xFF, data.length); + debug (stomp) + { + if (data.ptr) + memset(data.ptr, 0xFF, data.length * T.sizeof); + } if (data.ptr && data.ptr != &smallarray[0]) mem.xfree(data.ptr); } @@ -209,14 +213,22 @@ public: debug (stomp) { - if (length < data.length) - memset(data.ptr + length, 0xFF, (data.length - length) * T.sizeof); + if (data.ptr) + { + if (length < data.length) + memset(data.ptr + length, 0xFF, (data.length - length) * T.sizeof); + } } else { if (mem.isGCEnabled) - if (length < data.length) - memset(data.ptr + length, 0xFF, (data.length - length) * T.sizeof); + { + if (data.ptr) + { + if (length < data.length) + memset(data.ptr + length, 0xFF, (data.length - length) * T.sizeof); + } + } } } From a23f37430a137b7cc3424814096371c5e3ef6a6e Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Tue, 6 Jan 2026 12:41:53 +0100 Subject: [PATCH 252/440] Update copyright years to 2026 (dlang/dmd!22350) --- dmd/access.d | 2 +- dmd/aggregate.d | 2 +- dmd/aggregate.h | 2 +- dmd/aliasthis.d | 2 +- dmd/aliasthis.h | 2 +- dmd/argtypes.h | 2 +- dmd/argtypes_aarch64.d | 2 +- dmd/argtypes_sysv_x64.d | 2 +- dmd/argtypes_x86.d | 2 +- dmd/arrayop.d | 2 +- dmd/arraytypes.d | 2 +- dmd/arraytypes.h | 2 +- dmd/ast_node.d | 2 +- dmd/ast_node.h | 2 +- dmd/astenums.d | 2 +- dmd/asttypename.d | 2 +- dmd/attrib.d | 2 +- dmd/attrib.h | 2 +- dmd/attribsem.d | 2 +- dmd/blockexit.d | 2 +- dmd/builtin.d | 2 +- dmd/canthrow.d | 2 +- dmd/chkformat.d | 2 +- dmd/cli.d | 2 +- dmd/clone.d | 2 +- dmd/common/bitfields.d | 2 +- dmd/common/charactertables.d | 2 +- dmd/common/charactertables.h | 2 +- dmd/common/file.d | 2 +- dmd/common/int128.d | 2 +- dmd/common/outbuffer.d | 2 +- dmd/common/outbuffer.h | 2 +- dmd/common/smallbuffer.d | 2 +- dmd/compiler.d | 2 +- dmd/compiler.h | 2 +- dmd/cond.d | 2 +- dmd/cond.h | 2 +- dmd/console.d | 2 +- dmd/constfold.d | 2 +- dmd/cparse.d | 2 +- dmd/ctfe.h | 2 +- dmd/ctfeexpr.d | 2 +- dmd/ctorflow.d | 2 +- dmd/cxxfrontend.d | 2 +- dmd/dcast.d | 2 +- dmd/dclass.d | 2 +- dmd/declaration.d | 2 +- dmd/declaration.h | 2 +- dmd/delegatize.d | 2 +- dmd/denum.d | 2 +- dmd/deps.d | 2 +- dmd/dfa/entry.d | 2 +- dmd/dfa/fast/analysis.d | 2 +- dmd/dfa/fast/expression.d | 2 +- dmd/dfa/fast/report.d | 2 +- dmd/dfa/fast/statement.d | 2 +- dmd/dfa/fast/structure.d | 2 +- dmd/dfa/utils.d | 2 +- dmd/dimport.d | 2 +- dmd/dinterpret.d | 2 +- dmd/dmacro.d | 2 +- dmd/dmodule.d | 2 +- dmd/doc.d | 2 +- dmd/doc.h | 2 +- dmd/dscope.d | 2 +- dmd/dstruct.d | 2 +- dmd/dsymbol.d | 2 +- dmd/dsymbol.h | 2 +- dmd/dsymbolsem.d | 2 +- dmd/dtemplate.d | 2 +- dmd/dtoh.d | 2 +- dmd/dversion.d | 2 +- dmd/entity.d | 2 +- dmd/enum.h | 2 +- dmd/enumsem.d | 2 +- dmd/errors.d | 2 +- dmd/errors.h | 2 +- dmd/errorsink.d | 2 +- dmd/escape.d | 2 +- dmd/expression.d | 2 +- dmd/expression.h | 2 +- dmd/expressionsem.d | 2 +- dmd/file_manager.d | 2 +- dmd/frontend.h | 4 ++-- dmd/func.d | 2 +- dmd/funcsem.d | 2 +- dmd/globals.d | 4 ++-- dmd/globals.h | 2 +- dmd/hdrgen.d | 2 +- dmd/hdrgen.h | 2 +- dmd/iasm/gcc.d | 2 +- dmd/id.d | 2 +- dmd/id.h | 2 +- dmd/identifier.d | 2 +- dmd/identifier.h | 2 +- dmd/impcnvtab.d | 2 +- dmd/imphint.d | 2 +- dmd/import.h | 2 +- dmd/importc.d | 2 +- dmd/init.d | 2 +- dmd/init.h | 2 +- dmd/initsem.d | 2 +- dmd/inline.d | 2 +- dmd/inlinecost.d | 2 +- dmd/intrange.d | 2 +- dmd/json.d | 2 +- dmd/json.h | 2 +- dmd/lambdacomp.d | 2 +- dmd/lexer.d | 2 +- dmd/location.d | 2 +- dmd/main.d | 2 +- dmd/mangle.h | 2 +- dmd/mangle/basic.d | 2 +- dmd/mangle/cpp.d | 2 +- dmd/mangle/cppwin.d | 2 +- dmd/mangle/package.d | 2 +- dmd/mars.d | 2 +- dmd/module.h | 2 +- dmd/mtype.d | 2 +- dmd/mtype.h | 2 +- dmd/mustuse.d | 2 +- dmd/nogc.d | 2 +- dmd/nspace.d | 2 +- dmd/nspace.h | 2 +- dmd/ob.d | 2 +- dmd/objc.d | 2 +- dmd/objc.h | 2 +- dmd/opover.d | 2 +- dmd/optimize.d | 2 +- dmd/parse.d | 2 +- dmd/pragmasem.d | 2 +- dmd/printast.d | 2 +- dmd/root/aav.d | 2 +- dmd/root/array.d | 2 +- dmd/root/array.h | 2 +- dmd/root/bitarray.d | 2 +- dmd/root/bitarray.h | 2 +- dmd/root/complex.d | 2 +- dmd/root/complex_t.h | 2 +- dmd/root/ctfloat.d | 2 +- dmd/root/ctfloat.h | 2 +- dmd/root/dcompat.h | 2 +- dmd/root/dsystem.h | 2 +- dmd/root/file.d | 2 +- dmd/root/filename.d | 2 +- dmd/root/filename.h | 2 +- dmd/root/hash.d | 2 +- dmd/root/longdouble.d | 2 +- dmd/root/longdouble.h | 2 +- dmd/root/man.d | 2 +- dmd/root/optional.d | 2 +- dmd/root/optional.h | 2 +- dmd/root/port.d | 2 +- dmd/root/port.h | 2 +- dmd/root/region.d | 2 +- dmd/root/rmem.d | 2 +- dmd/root/rmem.h | 2 +- dmd/root/speller.d | 2 +- dmd/root/string.d | 2 +- dmd/root/stringtable.d | 2 +- dmd/root/utf.d | 2 +- dmd/rootobject.d | 2 +- dmd/rootobject.h | 2 +- dmd/safe.d | 2 +- dmd/sarif.d | 2 +- dmd/scope.h | 2 +- dmd/semantic2.d | 2 +- dmd/semantic3.d | 2 +- dmd/sideeffect.d | 2 +- dmd/statement.d | 2 +- dmd/statement.h | 2 +- dmd/statementsem.d | 2 +- dmd/staticassert.d | 2 +- dmd/staticassert.h | 2 +- dmd/staticcond.d | 2 +- dmd/stmtstate.d | 2 +- dmd/target.d | 2 +- dmd/target.h | 2 +- dmd/targetcompiler.d | 2 +- dmd/template.h | 2 +- dmd/templateparamsem.d | 2 +- dmd/templatesem.d | 2 +- dmd/timetrace.d | 2 +- dmd/tokens.d | 2 +- dmd/tokens.h | 2 +- dmd/traits.d | 2 +- dmd/typesem.d | 2 +- dmd/typinf.d | 2 +- dmd/typinf.h | 2 +- dmd/utils.d | 2 +- dmd/version.h | 2 +- dmd/visitor.h | 2 +- dmd/visitor/foreachvar.d | 2 +- dmd/visitor/package.d | 2 +- dmd/visitor/postorder.d | 2 +- dmd/visitor/statement_rewrite_walker.d | 2 +- dmd/vsoptions.d | 2 +- dmd/vsoptions.h | 2 +- 198 files changed, 200 insertions(+), 200 deletions(-) diff --git a/dmd/access.d b/dmd/access.d index 1871f601b6..09515ac3a5 100644 --- a/dmd/access.d +++ b/dmd/access.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/attribute.html#visibility_attributes, Visibility Attributes) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/access.d, _access.d) diff --git a/dmd/aggregate.d b/dmd/aggregate.d index a29ae0334a..668b61b4cc 100644 --- a/dmd/aggregate.d +++ b/dmd/aggregate.d @@ -4,7 +4,7 @@ * Specification: $(LINK2 https://dlang.org/spec/struct.html, Structs, Unions), * $(LINK2 https://dlang.org/spec/class.html, Class). * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/aggregate.d, _aggregate.d) diff --git a/dmd/aggregate.h b/dmd/aggregate.h index 4a5f664ca8..a421eaf8fc 100644 --- a/dmd/aggregate.h +++ b/dmd/aggregate.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/aliasthis.d b/dmd/aliasthis.d index 632cf95e80..bb1fcd0203 100644 --- a/dmd/aliasthis.d +++ b/dmd/aliasthis.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/class.html#alias-this, Alias This) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/aliasthis.d, _aliasthis.d) diff --git a/dmd/aliasthis.h b/dmd/aliasthis.h index 249da70fd6..ae90722983 100644 --- a/dmd/aliasthis.h +++ b/dmd/aliasthis.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 2009-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 2009-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/argtypes.h b/dmd/argtypes.h index 968bf5d627..91e4a5cdd9 100644 --- a/dmd/argtypes.h +++ b/dmd/argtypes.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/argtypes_aarch64.d b/dmd/argtypes_aarch64.d index dd502bd22f..ef87edf320 100644 --- a/dmd/argtypes_aarch64.d +++ b/dmd/argtypes_aarch64.d @@ -1,7 +1,7 @@ /** * Break down a D type into basic (register) types for the AArch64 ABI. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Martin Kinkelin * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/argtypes_aarch64.d, _argtypes_aarch64.d) diff --git a/dmd/argtypes_sysv_x64.d b/dmd/argtypes_sysv_x64.d index 40cfca3ad9..622a069de8 100644 --- a/dmd/argtypes_sysv_x64.d +++ b/dmd/argtypes_sysv_x64.d @@ -1,7 +1,7 @@ /** * Break down a D type into basic (register) types for the x86_64 System V ABI. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Martin Kinkelin * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/argtypes_sysv_x64.d, _argtypes_sysv_x64.d) diff --git a/dmd/argtypes_x86.d b/dmd/argtypes_x86.d index 89591e5645..c05f2bdb68 100644 --- a/dmd/argtypes_x86.d +++ b/dmd/argtypes_x86.d @@ -1,7 +1,7 @@ /** * Break down a D type into basic (register) types for the 32-bit x86 ABI. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/argtypes_x86.d, _argtypes_x86.d) diff --git a/dmd/arrayop.d b/dmd/arrayop.d index d052cd588f..c877690157 100644 --- a/dmd/arrayop.d +++ b/dmd/arrayop.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/arrays.html#array-operations, Array Operations) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/arrayop.d, _arrayop.d) diff --git a/dmd/arraytypes.d b/dmd/arraytypes.d index bed684b3a4..1d73cfc175 100644 --- a/dmd/arraytypes.d +++ b/dmd/arraytypes.d @@ -1,7 +1,7 @@ /** * Provide aliases for arrays of certain declarations or statements. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/arraytypes.d, _arraytypes.d) diff --git a/dmd/arraytypes.h b/dmd/arraytypes.h index a06144332d..2ab5ea07bb 100644 --- a/dmd/arraytypes.h +++ b/dmd/arraytypes.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 2006-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 2006-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/ast_node.d b/dmd/ast_node.d index ad49169947..2693fcb9bb 100644 --- a/dmd/ast_node.d +++ b/dmd/ast_node.d @@ -1,7 +1,7 @@ /** * Defines the base class for all nodes which are part of the AST. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast_node.d, _ast_node.d) diff --git a/dmd/ast_node.h b/dmd/ast_node.h index 0782d7eb46..ff7ad1c6ae 100644 --- a/dmd/ast_node.h +++ b/dmd/ast_node.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/astenums.d b/dmd/astenums.d index 1a5fcb8a55..756d249d66 100644 --- a/dmd/astenums.d +++ b/dmd/astenums.d @@ -1,7 +1,7 @@ /** * Defines enums common to dmd and dmd as parse library. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/astenums.d, _astenums.d) * Documentation: https://dlang.org/phobos/dmd_astenums.html diff --git a/dmd/asttypename.d b/dmd/asttypename.d index 8642288f58..b8070a4788 100644 --- a/dmd/asttypename.d +++ b/dmd/asttypename.d @@ -1,7 +1,7 @@ /** * Development utility for printing AST nodes by their internal name, instead of as D source code. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Stefan Koch * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/asttypename.d, _asttypename.d) diff --git a/dmd/attrib.d b/dmd/attrib.d index 8c2202358c..687fba8e78 100644 --- a/dmd/attrib.d +++ b/dmd/attrib.d @@ -14,7 +14,7 @@ * - Protection (`private`, `public`) * - Deprecated declarations (`@deprecated`) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/attrib.d, _attrib.d) diff --git a/dmd/attrib.h b/dmd/attrib.h index 24d91abc62..630131fd00 100644 --- a/dmd/attrib.h +++ b/dmd/attrib.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/attribsem.d b/dmd/attribsem.d index bc966bb8eb..0059884d54 100644 --- a/dmd/attribsem.d +++ b/dmd/attribsem.d @@ -14,7 +14,7 @@ * - Protection (`private`, `public`) * - Deprecated declarations (`@deprecated`) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/attribsem.d, _attrib.d) diff --git a/dmd/blockexit.d b/dmd/blockexit.d index 3f06a24a31..935fc1edf5 100644 --- a/dmd/blockexit.d +++ b/dmd/blockexit.d @@ -1,7 +1,7 @@ /** * Find out in what ways control flow can exit a statement block. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/blockexit.d, _blockexit.d) diff --git a/dmd/builtin.d b/dmd/builtin.d index 35c53d556e..28933ca6c8 100644 --- a/dmd/builtin.d +++ b/dmd/builtin.d @@ -3,7 +3,7 @@ * * Currently includes functions from `std.math`, `core.math` and `core.bitop`. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/builtin.d, _builtin.d) diff --git a/dmd/canthrow.d b/dmd/canthrow.d index 39536a4f77..2780f81a51 100644 --- a/dmd/canthrow.d +++ b/dmd/canthrow.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/function.html#nothrow-functions, Nothrow Functions) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/canthrow.d, _canthrow.d) diff --git a/dmd/chkformat.d b/dmd/chkformat.d index 58144db681..2a62fb3dc9 100644 --- a/dmd/chkformat.d +++ b/dmd/chkformat.d @@ -1,7 +1,7 @@ /** * Check the arguments to `printf` and `scanf` against the `format` string. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/chkformat.d, _chkformat.d) diff --git a/dmd/cli.d b/dmd/cli.d index ec45908d5e..1a8e00876a 100644 --- a/dmd/cli.d +++ b/dmd/cli.d @@ -5,7 +5,7 @@ * However, this file will be used to generate the * $(LINK2 https://dlang.org/dmd-linux.html, online documentation) and MAN pages. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/cli.d, _cli.d) diff --git a/dmd/clone.d b/dmd/clone.d index f3f359ee31..610dd756ec 100644 --- a/dmd/clone.d +++ b/dmd/clone.d @@ -2,7 +2,7 @@ * Builds struct member functions if needed and not defined by the user. * Includes `opEquals`, `opAssign`, post blit, copy constructor and destructor. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/clone.d, _clone.d) diff --git a/dmd/common/bitfields.d b/dmd/common/bitfields.d index dd01e8f4fd..ce2c938636 100644 --- a/dmd/common/bitfields.d +++ b/dmd/common/bitfields.d @@ -1,7 +1,7 @@ /** * A library bitfields utility * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Dennis Korpel * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/common/bitfields.d, common/bitfields.d) diff --git a/dmd/common/charactertables.d b/dmd/common/charactertables.d index 7df5234904..baa1262032 100644 --- a/dmd/common/charactertables.d +++ b/dmd/common/charactertables.d @@ -3,7 +3,7 @@ * * Supports UAX31, C99, C11 and least restrictive (All). * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/common/charactertables.d, common/charactertables.d) diff --git a/dmd/common/charactertables.h b/dmd/common/charactertables.h index b38409e302..86558a1862 100644 --- a/dmd/common/charactertables.h +++ b/dmd/common/charactertables.h @@ -3,7 +3,7 @@ * * Supports UAX31, C99, C11 and least restrictive (All). * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/common/charactertables.h, common/charactertables.d) diff --git a/dmd/common/file.d b/dmd/common/file.d index 41a7f3307c..dad41de13e 100644 --- a/dmd/common/file.d +++ b/dmd/common/file.d @@ -4,7 +4,7 @@ * Functions and objects dedicated to file I/O and management. TODO: Move here artifacts * from places such as root/ so both the frontend and the backend have access to them. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/common/file.d, common/_file.d) diff --git a/dmd/common/int128.d b/dmd/common/int128.d index aaf38c5157..865cb1e3fe 100644 --- a/dmd/common/int128.d +++ b/dmd/common/int128.d @@ -2,7 +2,7 @@ * * Not optimized for speed. * - * Copyright: Copyright (C) 2022-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 2022-2026 by The D Language Foundation, All Rights Reserved * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Authors: Walter Bright * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/common/int128.d, root/_int128.d) diff --git a/dmd/common/outbuffer.d b/dmd/common/outbuffer.d index a5340ef805..d569c98b3f 100644 --- a/dmd/common/outbuffer.d +++ b/dmd/common/outbuffer.d @@ -1,7 +1,7 @@ /** * An expandable buffer in which you can write text or binary data. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/common/outbuffer.d, root/_outbuffer.d) diff --git a/dmd/common/outbuffer.h b/dmd/common/outbuffer.h index 9630f12201..435193d716 100644 --- a/dmd/common/outbuffer.h +++ b/dmd/common/outbuffer.h @@ -1,5 +1,5 @@ -/* Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved +/* Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/common/smallbuffer.d b/dmd/common/smallbuffer.d index 085c0e3434..cbcd6e1380 100644 --- a/dmd/common/smallbuffer.d +++ b/dmd/common/smallbuffer.d @@ -1,7 +1,7 @@ /** * Common string functions including filename manipulation. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/common/smallbuffer.d, common/_smallbuffer.d) diff --git a/dmd/compiler.d b/dmd/compiler.d index 9f6b88a74c..e61a7138e3 100644 --- a/dmd/compiler.d +++ b/dmd/compiler.d @@ -1,7 +1,7 @@ /** * Describes a back-end compiler and implements compiler-specific actions. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/compiler.d, _compiler.d) diff --git a/dmd/compiler.h b/dmd/compiler.h index ca085c6649..ac9d60630b 100644 --- a/dmd/compiler.h +++ b/dmd/compiler.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/cond.d b/dmd/cond.d index 416d6bd692..b1cdbbcade 100644 --- a/dmd/cond.d +++ b/dmd/cond.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/version.html, Conditional Compilation) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/cond.d, _cond.d) diff --git a/dmd/cond.h b/dmd/cond.h index 0afa042f9d..1892d2c9cf 100644 --- a/dmd/cond.h +++ b/dmd/cond.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/console.d b/dmd/console.d index 29dc9fb300..cc78b083dd 100644 --- a/dmd/console.d +++ b/dmd/console.d @@ -2,7 +2,7 @@ * Control the various text mode attributes, such as color, when writing text * to the console. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/console.d, _console.d) diff --git a/dmd/constfold.d b/dmd/constfold.d index d7db3c3bf3..1dc6c4ca2d 100644 --- a/dmd/constfold.d +++ b/dmd/constfold.d @@ -5,7 +5,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/float.html#fp_const_folding, Floating Point Constant Folding) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/constfold.d, _constfold.d) diff --git a/dmd/cparse.d b/dmd/cparse.d index 3c0b9af163..32b4e0146a 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -3,7 +3,7 @@ * * Specification: C11 * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/cparse.d, _cparse.d) diff --git a/dmd/ctfe.h b/dmd/ctfe.h index e022d7c2a2..cff61f880c 100644 --- a/dmd/ctfe.h +++ b/dmd/ctfe.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/ctfeexpr.d b/dmd/ctfeexpr.d index 8087db2d25..6cd32bd5e2 100644 --- a/dmd/ctfeexpr.d +++ b/dmd/ctfeexpr.d @@ -1,7 +1,7 @@ /** * CTFE for expressions involving pointers, slices, array concatenation etc. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ctfeexpr.d, _ctfeexpr.d) diff --git a/dmd/ctorflow.d b/dmd/ctorflow.d index e604700e1f..4207c681e2 100644 --- a/dmd/ctorflow.d +++ b/dmd/ctorflow.d @@ -1,7 +1,7 @@ /** * Manage flow analysis for constructors. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ctorflow.d, _ctorflow.d) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index 441affe92a..b4524a465b 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -1,7 +1,7 @@ /** * Contains C++ interfaces for interacting with DMD as a library. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/cxxfrontend.d, _cxxfrontend.d) diff --git a/dmd/dcast.d b/dmd/dcast.d index 8ab49b3c47..73cfca8a5d 100644 --- a/dmd/dcast.d +++ b/dmd/dcast.d @@ -1,7 +1,7 @@ /** * Semantic analysis for cast-expressions. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dcast.d, _dcast.d) diff --git a/dmd/dclass.d b/dmd/dclass.d index dcbad395d9..6385265f9f 100644 --- a/dmd/dclass.d +++ b/dmd/dclass.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/class.html, Classes) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dclass.d, _dclass.d) diff --git a/dmd/declaration.d b/dmd/declaration.d index faeab44ed1..537e51e9a6 100644 --- a/dmd/declaration.d +++ b/dmd/declaration.d @@ -2,7 +2,7 @@ * Miscellaneous declarations, including typedef, alias, variable declarations including the * implicit this declaration, type tuples, ClassInfo, ModuleInfo and various TypeInfos. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/declaration.d, _declaration.d) diff --git a/dmd/declaration.h b/dmd/declaration.h index d2e04b5f9a..759e533543 100644 --- a/dmd/declaration.h +++ b/dmd/declaration.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/delegatize.d b/dmd/delegatize.d index c28af9ba07..ff44d5895d 100644 --- a/dmd/delegatize.d +++ b/dmd/delegatize.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/function.html#lazy-params, Lazy Parameters) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/delegatize.d, _delegatize.d) diff --git a/dmd/denum.d b/dmd/denum.d index a48308c5ff..f065580a35 100644 --- a/dmd/denum.d +++ b/dmd/denum.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/enum.html, Enums) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/denum.d, _denum.d) diff --git a/dmd/deps.d b/dmd/deps.d index d62d670938..e70f5374c0 100644 --- a/dmd/deps.d +++ b/dmd/deps.d @@ -22,7 +22,7 @@ * source/importb.d * --- * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/deps.d, makedeps.d) * Documentation: https://dlang.org/phobos/dmd_deps.html diff --git a/dmd/dfa/entry.d b/dmd/dfa/entry.d index 98462d531d..f6a5b8f36d 100644 --- a/dmd/dfa/entry.d +++ b/dmd/dfa/entry.d @@ -14,7 +14,7 @@ * https://forum.dlang.org/post/xmssfygefvldeiyodfya@forum.dlang.org * (Why we should not enable a slow DFA by default) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dfa/entry.d, dfa/entry.d) diff --git a/dmd/dfa/fast/analysis.d b/dmd/dfa/fast/analysis.d index c69b134b3c..b5e5f69a41 100644 --- a/dmd/dfa/fast/analysis.d +++ b/dmd/dfa/fast/analysis.d @@ -12,7 +12,7 @@ * * Has the convergence and transfer functions. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dfa/fast/analysis.d, dfa/fast/analysis.d) diff --git a/dmd/dfa/fast/expression.d b/dmd/dfa/fast/expression.d index d450c7c875..188e83a232 100644 --- a/dmd/dfa/fast/expression.d +++ b/dmd/dfa/fast/expression.d @@ -8,7 +8,7 @@ * 3. Handling Function Calls: Managing side effects and return values. * 4. Modeling Arithmetic: Tracking ranges of values (Point Analysis) to detect overflows. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dfa/fast/expression.d, dfa/fast/expression.d) diff --git a/dmd/dfa/fast/report.d b/dmd/dfa/fast/report.d index 49676accc9..cb26fdd2ec 100644 --- a/dmd/dfa/fast/report.d +++ b/dmd/dfa/fast/report.d @@ -7,7 +7,7 @@ * 2. Contract Validation: Ensuring functions fulfill their `out` contracts (e.g., returning non-null). * 3. Logic Errors: Detecting assertions that are provably false at compile time. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dfa/fast/report.d, dfa/fast/report.d) diff --git a/dmd/dfa/fast/statement.d b/dmd/dfa/fast/statement.d index d39b110bc1..114015f840 100644 --- a/dmd/dfa/fast/statement.d +++ b/dmd/dfa/fast/statement.d @@ -8,7 +8,7 @@ * 3. Handling Loops: Managing state for `for`, `while`, and `do` loops. * 4. Handling Jumps: Resolving `break`, `continue`, `goto`, and `return`. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dfa/fast/statement.d, dfa/fast/statement.d) diff --git a/dmd/dfa/fast/structure.d b/dmd/dfa/fast/structure.d index 442029d35f..64ace4924f 100644 --- a/dmd/dfa/fast/structure.d +++ b/dmd/dfa/fast/structure.d @@ -1,7 +1,7 @@ /** * Structure and representation of the fast Data Flow Analysis engine. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dfa/fast/structure.d, dfa/fast/structure.d) diff --git a/dmd/dfa/utils.d b/dmd/dfa/utils.d index 8965008b8f..74da0a3e40 100644 --- a/dmd/dfa/utils.d +++ b/dmd/dfa/utils.d @@ -1,7 +1,7 @@ /** * Utilities for Data Flow Analysis. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://cattermole.co.nz, Richard (Rikki) Andrew Cattermole) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dfa/utils.d, dfa/utils.d) diff --git a/dmd/dimport.d b/dmd/dimport.d index e634081e86..201ab010ce 100644 --- a/dmd/dimport.d +++ b/dmd/dimport.d @@ -1,7 +1,7 @@ /** * A `Dsymbol` representing a renamed import. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dimport.d, _dimport.d) diff --git a/dmd/dinterpret.d b/dmd/dinterpret.d index 61088e02bb..fb07953ace 100644 --- a/dmd/dinterpret.d +++ b/dmd/dinterpret.d @@ -3,7 +3,7 @@ * * Specification: ($LINK2 https://dlang.org/spec/function.html#interpretation, Compile Time Function Execution (CTFE)) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dinterpret.d, _dinterpret.d) diff --git a/dmd/dmacro.d b/dmd/dmacro.d index 307b43fb63..f42ef3f783 100644 --- a/dmd/dmacro.d +++ b/dmd/dmacro.d @@ -1,7 +1,7 @@ /** * Text macro processor for Ddoc. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dmacro.d, _dmacro.d) diff --git a/dmd/dmodule.d b/dmd/dmodule.d index 9b99718700..4ddbe925ab 100644 --- a/dmd/dmodule.d +++ b/dmd/dmodule.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/module.html, Modules) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dmodule.d, _dmodule.d) diff --git a/dmd/doc.d b/dmd/doc.d index 4328391d69..ada57729b0 100644 --- a/dmd/doc.d +++ b/dmd/doc.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/ddoc.html, Documentation Generator) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/doc.d, _doc.d) diff --git a/dmd/doc.h b/dmd/doc.h index 61a51a0b82..142374da1f 100644 --- a/dmd/doc.h +++ b/dmd/doc.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/dscope.d b/dmd/dscope.d index cdec3218b0..71442c48ba 100644 --- a/dmd/dscope.d +++ b/dmd/dscope.d @@ -3,7 +3,7 @@ * * Not to be confused with the `scope` storage class. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dscope.d, _dscope.d) diff --git a/dmd/dstruct.d b/dmd/dstruct.d index ac5ee046cc..089307968d 100644 --- a/dmd/dstruct.d +++ b/dmd/dstruct.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/struct.html, Structs, Unions) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dstruct.d, _dstruct.d) diff --git a/dmd/dsymbol.d b/dmd/dsymbol.d index 640eda90e5..ed02ead4cf 100644 --- a/dmd/dsymbol.d +++ b/dmd/dsymbol.d @@ -1,7 +1,7 @@ /** * The base class for a D symbol, which can be a module, variable, function, enum, etc. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dsymbol.d, _dsymbol.d) diff --git a/dmd/dsymbol.h b/dmd/dsymbol.h index a22a93c53c..f6665c5922 100644 --- a/dmd/dsymbol.h +++ b/dmd/dsymbol.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index eb7620da72..ce4c8f6b42 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -2,7 +2,7 @@ * Does the semantic 1 pass on the AST, which looks at symbol declarations but not initializers * or function bodies. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dsymbolsem.d, _dsymbolsem.d) diff --git a/dmd/dtemplate.d b/dmd/dtemplate.d index f68c92811c..40f1f07cbb 100644 --- a/dmd/dtemplate.d +++ b/dmd/dtemplate.d @@ -28,7 +28,7 @@ * arguments, and uses it if found. * - Otherwise, the rest of semantic is run on the `TemplateInstance`. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dtemplate.d, _dtemplate.d) diff --git a/dmd/dtoh.d b/dmd/dtoh.d index a17bfe6706..10a4824d57 100644 --- a/dmd/dtoh.d +++ b/dmd/dtoh.d @@ -2,7 +2,7 @@ * This module contains the implementation of the C++ header generation available through * the command line switch -Hc. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dtoh.d, _dtoh.d) diff --git a/dmd/dversion.d b/dmd/dversion.d index 166eb92fe3..17d888b17e 100644 --- a/dmd/dversion.d +++ b/dmd/dversion.d @@ -4,7 +4,7 @@ * Specification: $(LINK2 https://dlang.org/spec/version.html#version-specification, Version Specification), * $(LINK2 https://dlang.org/spec/version.html#debug_specification, Debug Specification). * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dversion.d, _dversion.d) diff --git a/dmd/entity.d b/dmd/entity.d index a70029b374..6ae71b4513 100644 --- a/dmd/entity.d +++ b/dmd/entity.d @@ -3,7 +3,7 @@ * * Specification $(LINK2 https://dlang.org/spec/entity.html, Named Character Entities) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/entity.d, _entity.d) diff --git a/dmd/enum.h b/dmd/enum.h index 5d59534bcf..c889141f3d 100644 --- a/dmd/enum.h +++ b/dmd/enum.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/enumsem.d b/dmd/enumsem.d index f00c69c451..99aaa6c8c9 100644 --- a/dmd/enumsem.d +++ b/dmd/enumsem.d @@ -1,7 +1,7 @@ /** * Does the semantic passes on enums. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/enumsem.d, _enumsem.d) diff --git a/dmd/errors.d b/dmd/errors.d index 3a0e8fb3ec..a6f63dc40f 100644 --- a/dmd/errors.d +++ b/dmd/errors.d @@ -1,7 +1,7 @@ /** * Functions for raising errors. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/errors.d, _errors.d) diff --git a/dmd/errors.h b/dmd/errors.h index a2d0f36e03..13a716c030 100644 --- a/dmd/errors.h +++ b/dmd/errors.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/errorsink.d b/dmd/errorsink.d index 5793ef1c0e..0d4a3d4b77 100644 --- a/dmd/errorsink.d +++ b/dmd/errorsink.d @@ -1,7 +1,7 @@ /** * Provides an abstraction for what to do with error messages. * - * Copyright: Copyright (C) 2023-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 2023-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/errorsink.d, _errorsink.d) diff --git a/dmd/escape.d b/dmd/escape.d index 1b50cdea5b..3a2297d161 100644 --- a/dmd/escape.d +++ b/dmd/escape.d @@ -1,7 +1,7 @@ /** * Most of the logic to implement scoped pointers and scoped references is here. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/escape.d, _escape.d) diff --git a/dmd/expression.d b/dmd/expression.d index d7bbdbd3b0..98d1a8ee34 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -3,7 +3,7 @@ * * Specification: ($LINK2 https://dlang.org/spec/expression.html, Expressions) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/expression.d, _expression.d) diff --git a/dmd/expression.h b/dmd/expression.h index 7af0992ef8..d6577d6451 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 902b0563d4..00bddf86de 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -3,7 +3,7 @@ * * Specification: ($LINK2 https://dlang.org/spec/expression.html, Expressions) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/expressionsem.d, _expressionsem.d) diff --git a/dmd/file_manager.d b/dmd/file_manager.d index c63dbc6699..4650c2b600 100644 --- a/dmd/file_manager.d +++ b/dmd/file_manager.d @@ -1,7 +1,7 @@ /** * Read a file from disk and store it in memory. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/file_manager.d, _file_manager.d) * Documentation: https://dlang.org/phobos/dmd_file_manager.html diff --git a/dmd/frontend.h b/dmd/frontend.h index 985209ace8..f55298f78a 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -8465,7 +8465,7 @@ struct Global final const char* const versionChars(); Global() : inifilename(), - copyright(73, "Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved"), + copyright(73, "Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved"), written(24, "written by Walter Bright"), path(), importPaths(), @@ -8489,7 +8489,7 @@ struct Global final preprocess() { } - Global(_d_dynamicArray< const char > inifilename, _d_dynamicArray< const char > copyright = { 73, "Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved" }, _d_dynamicArray< const char > written = { 24, "written by Walter Bright" }, Array path = Array(), Array importPaths = Array(), Array filePath = Array(), CompileEnv compileEnv = CompileEnv(), Param params = Param(), uint32_t errors = 0u, uint32_t deprecations = 0u, uint32_t warnings = 0u, uint32_t gag = 0u, uint32_t gaggedErrors = 0u, uint32_t gaggedDeprecations = 0u, void* console = nullptr, Array versionids = Array(), Array debugids = Array(), bool hasMainFunction = false, uint32_t varSequenceNumber = 1u, FileManager* fileManager = nullptr, ErrorSink* errorSink = nullptr, ErrorSink* errorSinkNull = nullptr, DArray(*preprocess)(FileName , Loc , OutBuffer& ) = nullptr) : + Global(_d_dynamicArray< const char > inifilename, _d_dynamicArray< const char > copyright = { 73, "Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved" }, _d_dynamicArray< const char > written = { 24, "written by Walter Bright" }, Array path = Array(), Array importPaths = Array(), Array filePath = Array(), CompileEnv compileEnv = CompileEnv(), Param params = Param(), uint32_t errors = 0u, uint32_t deprecations = 0u, uint32_t warnings = 0u, uint32_t gag = 0u, uint32_t gaggedErrors = 0u, uint32_t gaggedDeprecations = 0u, void* console = nullptr, Array versionids = Array(), Array debugids = Array(), bool hasMainFunction = false, uint32_t varSequenceNumber = 1u, FileManager* fileManager = nullptr, ErrorSink* errorSink = nullptr, ErrorSink* errorSinkNull = nullptr, DArray(*preprocess)(FileName , Loc , OutBuffer& ) = nullptr) : inifilename(inifilename), copyright(copyright), written(written), diff --git a/dmd/func.d b/dmd/func.d index 9b397970ec..1f902e4f18 100644 --- a/dmd/func.d +++ b/dmd/func.d @@ -8,7 +8,7 @@ * - `invariant` * - `unittest` * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/func.d, _func.d) diff --git a/dmd/funcsem.d b/dmd/funcsem.d index 81ea608641..c077850f16 100644 --- a/dmd/funcsem.d +++ b/dmd/funcsem.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/function.html, Functions) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/funcsem.d, _funcsem.d) diff --git a/dmd/globals.d b/dmd/globals.d index a825cb8b5d..e1d74cf5cd 100644 --- a/dmd/globals.d +++ b/dmd/globals.d @@ -1,7 +1,7 @@ /** * Stores command line options and contains other miscellaneous declarations. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/globals.d, _globals.d) @@ -300,7 +300,7 @@ extern (C++) struct Global { const(char)[] inifilename; /// filename of configuration file as given by `-conf=`, or default value - string copyright = "Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved"; + string copyright = "Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved"; string written = "written by Walter Bright"; Array!(ImportPathInfo) path; /// Array of path informations which form the import lookup path diff --git a/dmd/globals.h b/dmd/globals.h index 10651ae1d6..576654ee82 100644 --- a/dmd/globals.h +++ b/dmd/globals.h @@ -1,5 +1,5 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/hdrgen.d b/dmd/hdrgen.d index a5d9f0ff3f..a79822a43b 100644 --- a/dmd/hdrgen.d +++ b/dmd/hdrgen.d @@ -3,7 +3,7 @@ * * Also used to convert AST nodes to D code in general, e.g. for error messages or `printf` debugging. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/hdrgen.d, _hdrgen.d) diff --git a/dmd/hdrgen.h b/dmd/hdrgen.h index 2bc355908d..7c7fb764ec 100644 --- a/dmd/hdrgen.h +++ b/dmd/hdrgen.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Dave Fladebo * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/iasm/gcc.d b/dmd/iasm/gcc.d index f7216f3575..2f5d7aaf9f 100644 --- a/dmd/iasm/gcc.d +++ b/dmd/iasm/gcc.d @@ -1,7 +1,7 @@ /** * Inline assembler for the GCC D compiler. * - * Copyright (C) 2018-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 2018-2026 by The D Language Foundation, All Rights Reserved * Authors: Iain Buclaw * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/iasmgcc.d, _iasmgcc.d) diff --git a/dmd/id.d b/dmd/id.d index ed7423d433..beb3de62b3 100644 --- a/dmd/id.d +++ b/dmd/id.d @@ -1,7 +1,7 @@ /** * Contains the `Id` struct with a list of predefined symbols the compiler knows about. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/id.d, _id.d) diff --git a/dmd/id.h b/dmd/id.h index cab42bf55c..77eb667379 100644 --- a/dmd/id.h +++ b/dmd/id.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 2017-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 2017-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/identifier.d b/dmd/identifier.d index 5f2deb9233..64ffeb9152 100644 --- a/dmd/identifier.d +++ b/dmd/identifier.d @@ -1,7 +1,7 @@ /** * Defines an identifier, which is the name of a `Dsymbol`. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/identifier.d, _identifier.d) diff --git a/dmd/identifier.h b/dmd/identifier.h index 02b55b6502..9e88efc3a7 100644 --- a/dmd/identifier.h +++ b/dmd/identifier.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/impcnvtab.d b/dmd/impcnvtab.d index b2ab919f1b..767b7b2395 100644 --- a/dmd/impcnvtab.d +++ b/dmd/impcnvtab.d @@ -6,7 +6,7 @@ * Specification: $(LINK2 https://dlang.org/spec/type.html#integer-promotions, Integer Promotions), * $(LINK2 https://dlang.org/spec/type.html#usual-arithmetic-conversions, Usual Arithmetic Conversions). * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/impcnvtab.d, _impcnvtab.d) diff --git a/dmd/imphint.d b/dmd/imphint.d index 1b2d51d794..524d269cc1 100644 --- a/dmd/imphint.d +++ b/dmd/imphint.d @@ -3,7 +3,7 @@ * * For example, prompt to `import std.stdio` when using `writeln`. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/imphint.d, _imphint.d) diff --git a/dmd/import.h b/dmd/import.h index 06b212f054..d0e81e2357 100644 --- a/dmd/import.h +++ b/dmd/import.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/importc.d b/dmd/importc.d index db16ce763d..cf94b632a8 100644 --- a/dmd/importc.d +++ b/dmd/importc.d @@ -3,7 +3,7 @@ * * Specification: C11 * - * Copyright: Copyright (C) 2021-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 2021-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/importc.d, _importc.d) diff --git a/dmd/init.d b/dmd/init.d index 55fb6f3485..9a118bb3d6 100644 --- a/dmd/init.d +++ b/dmd/init.d @@ -1,7 +1,7 @@ /** * Defines initializers of variables, e.g. the array literal in `int[3] x = [0, 1, 2]`. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/init.d, _init.d) diff --git a/dmd/init.h b/dmd/init.h index a832b9ed4d..142af9c736 100644 --- a/dmd/init.h +++ b/dmd/init.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/initsem.d b/dmd/initsem.d index 00de258451..9ddf5508eb 100644 --- a/dmd/initsem.d +++ b/dmd/initsem.d @@ -1,7 +1,7 @@ /** * Semantic analysis of initializers. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/initsem.d, _initsem.d) diff --git a/dmd/inline.d b/dmd/inline.d index b981120ff5..59c1b5012f 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -4,7 +4,7 @@ * The AST is traversed, and every function call is considered for inlining using `inlinecost.d`. * The function call is then inlined if this cost is below a threshold. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/inline.d, _inline.d) diff --git a/dmd/inlinecost.d b/dmd/inlinecost.d index 6b93b8b134..1be5a4a6aa 100644 --- a/dmd/inlinecost.d +++ b/dmd/inlinecost.d @@ -1,7 +1,7 @@ /** * Compute the cost of inlining a function call by counting expressions. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/inlinecost.d, _inlinecost.d) diff --git a/dmd/intrange.d b/dmd/intrange.d index 9f4cd955bd..4f8af92433 100644 --- a/dmd/intrange.d +++ b/dmd/intrange.d @@ -1,7 +1,7 @@ /** * Implement $(LINK2 https://digitalmars.com/articles/b62.html, Value Range Propagation). * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/intrange.d, _intrange.d) diff --git a/dmd/json.d b/dmd/json.d index 839ac81bb5..512b4dc757 100644 --- a/dmd/json.d +++ b/dmd/json.d @@ -1,7 +1,7 @@ /** * Code for generating .json descriptions of the module when passing the `-X` flag to dmd. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/json.d, _json.d) diff --git a/dmd/json.h b/dmd/json.h index 821150935a..734f20f394 100644 --- a/dmd/json.h +++ b/dmd/json.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/lambdacomp.d b/dmd/lambdacomp.d index 445ddd69d7..12b1d6582b 100644 --- a/dmd/lambdacomp.d +++ b/dmd/lambdacomp.d @@ -5,7 +5,7 @@ * The serialization is a string which contains the type of the parameters and the string * represantation of the lambda expression. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/lambdacomp.d, _lambdacomp.d) diff --git a/dmd/lexer.d b/dmd/lexer.d index fe8b0c8158..b5b82a91df 100644 --- a/dmd/lexer.d +++ b/dmd/lexer.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/lex.html, Lexical) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/lexer.d, _lexer.d) diff --git a/dmd/location.d b/dmd/location.d index daff06f3d2..102d443602 100644 --- a/dmd/location.d +++ b/dmd/location.d @@ -1,7 +1,7 @@ /** * Encapsulates file/line/column locations. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/location.d, _location.d) diff --git a/dmd/main.d b/dmd/main.d index edb150bc5c..7bb3a150df 100644 --- a/dmd/main.d +++ b/dmd/main.d @@ -6,7 +6,7 @@ * utilities needed for arguments parsing, path manipulation, etc... * This file is not shared with other compilers which use the DMD front-end. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/main.d, _main.d) diff --git a/dmd/mangle.h b/dmd/mangle.h index 97875c5ddd..488755e5ab 100644 --- a/dmd/mangle.h +++ b/dmd/mangle.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/mangle/basic.d b/dmd/mangle/basic.d index 263dd5ed46..f50faaa9b5 100644 --- a/dmd/mangle/basic.d +++ b/dmd/mangle/basic.d @@ -1,7 +1,7 @@ /** * Defines the building blocks for creating the mangled names for basic types. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/mangle/basic.d, _basicmangle.d) * Documentation: https://dlang.org/phobos/dmd_basicmangle.html diff --git a/dmd/mangle/cpp.d b/dmd/mangle/cpp.d index ae0e60bd24..bf7c46e19c 100644 --- a/dmd/mangle/cpp.d +++ b/dmd/mangle/cpp.d @@ -4,7 +4,7 @@ * This is the POSIX side of the implementation. * It exports two functions to C++, `toCppMangleItanium` and `cppTypeInfoMangleItanium`. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/mangle/cpp.d, _cppmangle.d) diff --git a/dmd/mangle/cppwin.d b/dmd/mangle/cppwin.d index a0bd4cc670..388aaed1e3 100644 --- a/dmd/mangle/cppwin.d +++ b/dmd/mangle/cppwin.d @@ -1,7 +1,7 @@ /** * Do mangling for C++ linkage for Digital Mars C++ and Microsoft Visual C++. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/mangle/cppwin.d, _cppmanglewin.d) diff --git a/dmd/mangle/package.d b/dmd/mangle/package.d index 8b68ac87a4..8a3f59cae9 100644 --- a/dmd/mangle/package.d +++ b/dmd/mangle/package.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/abi.html#name_mangling, Name Mangling) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/mangle/package.d, _dmangle.d) diff --git a/dmd/mars.d b/dmd/mars.d index c3897bd4ad..9a1aa7dd12 100644 --- a/dmd/mars.d +++ b/dmd/mars.d @@ -4,7 +4,7 @@ * utilities needed for arguments parsing, path manipulation, etc... * This file is not shared with other compilers which use the DMD front-end. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/mars.d, _mars.d) diff --git a/dmd/module.h b/dmd/module.h index 51eb981a9f..6a010722e4 100644 --- a/dmd/module.h +++ b/dmd/module.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/mtype.d b/dmd/mtype.d index d562c103d0..74364d05e3 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -1,7 +1,7 @@ /** * Defines a D type. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/mtype.d, _mtype.d) diff --git a/dmd/mtype.h b/dmd/mtype.h index 3a78228f7f..e2edcd996a 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/mustuse.d b/dmd/mustuse.d index 84a991e693..2125206322 100644 --- a/dmd/mustuse.d +++ b/dmd/mustuse.d @@ -1,7 +1,7 @@ /** * Compile-time checks associated with the @mustuse attribute. * - * Copyright: Copyright (C) 2022-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 2022-2026 by The D Language Foundation, All Rights Reserved * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/mustuse.d, _mustuse.d) * Documentation: https://dlang.org/phobos/dmd_mustuse.html diff --git a/dmd/nogc.d b/dmd/nogc.d index 3221f55107..79098cae3f 100644 --- a/dmd/nogc.d +++ b/dmd/nogc.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/function.html#nogc-functions, No-GC Functions) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/nogc.d, _nogc.d) diff --git a/dmd/nspace.d b/dmd/nspace.d index b8116343d6..aa09097a7b 100644 --- a/dmd/nspace.d +++ b/dmd/nspace.d @@ -36,7 +36,7 @@ * are valid D identifier. * * See_Also: https://github.com/dlang/dmd/pull/10031 - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/nspace.d, _nspace.d) diff --git a/dmd/nspace.h b/dmd/nspace.h index 782688b9de..7575a1387c 100644 --- a/dmd/nspace.h +++ b/dmd/nspace.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/ob.d b/dmd/ob.d index 7e48b28150..43279187e8 100644 --- a/dmd/ob.d +++ b/dmd/ob.d @@ -1,7 +1,7 @@ /** * Flow analysis for Ownership/Borrowing * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ob.d, _ob.d) diff --git a/dmd/objc.d b/dmd/objc.d index 604487d405..741febe551 100644 --- a/dmd/objc.d +++ b/dmd/objc.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/objc_interface.html, Interfacing to Objective-C) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/objc.d, _objc.d) diff --git a/dmd/objc.h b/dmd/objc.h index af6f2e457e..601139fc06 100644 --- a/dmd/objc.h +++ b/dmd/objc.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 2015-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 2015-2026 by The D Language Foundation, All Rights Reserved * written by Michel Fortin * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/opover.d b/dmd/opover.d index 0fd85726a3..868b22b29c 100644 --- a/dmd/opover.d +++ b/dmd/opover.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/operatoroverloading.html, Operator Overloading) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/opover.d, _opover.d) diff --git a/dmd/optimize.d b/dmd/optimize.d index 5f89c4b70d..05a3aae519 100644 --- a/dmd/optimize.d +++ b/dmd/optimize.d @@ -1,7 +1,7 @@ /** * Perform constant folding. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/optimize.d, _optimize.d) diff --git a/dmd/parse.d b/dmd/parse.d index 0d87ecfaa9..ccc52f692b 100644 --- a/dmd/parse.d +++ b/dmd/parse.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/grammar.html, D Grammar) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/parse.d, _parse.d) diff --git a/dmd/pragmasem.d b/dmd/pragmasem.d index 71d6770785..d94414d9b5 100644 --- a/dmd/pragmasem.d +++ b/dmd/pragmasem.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/pragma.html, Pragmas) * - * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/pragmasem.d, _pragmasem.d) diff --git a/dmd/printast.d b/dmd/printast.d index 80995d4103..ef97306c5a 100644 --- a/dmd/printast.d +++ b/dmd/printast.d @@ -1,7 +1,7 @@ /** * Provides an AST printer for debugging. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/printast.d, _printast.d) diff --git a/dmd/root/aav.d b/dmd/root/aav.d index 014d4a579c..381a97988b 100644 --- a/dmd/root/aav.d +++ b/dmd/root/aav.d @@ -1,7 +1,7 @@ /** * Associative array implementation. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/aav.d, root/_aav.d) diff --git a/dmd/root/array.d b/dmd/root/array.d index 5f8c01a0f9..fb931cc210 100644 --- a/dmd/root/array.d +++ b/dmd/root/array.d @@ -2,7 +2,7 @@ /** * Dynamic array implementation. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/array.d, root/_array.d) diff --git a/dmd/root/array.h b/dmd/root/array.h index 6b761cf5ba..0bc09fe861 100644 --- a/dmd/root/array.h +++ b/dmd/root/array.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2011-2025 by The D Language Foundation, All Rights Reserved +/* Copyright (C) 2011-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/root/bitarray.d b/dmd/root/bitarray.d index 5d2c18b75f..e5ffb4df13 100644 --- a/dmd/root/bitarray.d +++ b/dmd/root/bitarray.d @@ -1,7 +1,7 @@ /** * Implementation of a bit array. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/bitarray.d, root/_bitarray.d) diff --git a/dmd/root/bitarray.h b/dmd/root/bitarray.h index c50247f35f..5a449e4b74 100644 --- a/dmd/root/bitarray.h +++ b/dmd/root/bitarray.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2011-2025 by The D Language Foundation, All Rights Reserved +/* Copyright (C) 2011-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/root/complex.d b/dmd/root/complex.d index 777c103ae9..35b45bf34b 100644 --- a/dmd/root/complex.d +++ b/dmd/root/complex.d @@ -1,7 +1,7 @@ /** * Implements a complex number type. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/complex.d, _complex.d) diff --git a/dmd/root/complex_t.h b/dmd/root/complex_t.h index 58a0705398..e13336d109 100644 --- a/dmd/root/complex_t.h +++ b/dmd/root/complex_t.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/root/ctfloat.d b/dmd/root/ctfloat.d index 0a59771afc..67eb031b06 100644 --- a/dmd/root/ctfloat.d +++ b/dmd/root/ctfloat.d @@ -1,7 +1,7 @@ /** * Collects functions for compile-time floating-point calculations. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/ctfloat.d, root/_ctfloat.d) diff --git a/dmd/root/ctfloat.h b/dmd/root/ctfloat.h index 815839c40a..cdb300c33f 100644 --- a/dmd/root/ctfloat.h +++ b/dmd/root/ctfloat.h @@ -1,5 +1,5 @@ -/* Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved +/* Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/root/dcompat.h b/dmd/root/dcompat.h index 1c89b570ac..a4a8ceba1d 100644 --- a/dmd/root/dcompat.h +++ b/dmd/root/dcompat.h @@ -1,5 +1,5 @@ -/* Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved +/* Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/root/dsystem.h b/dmd/root/dsystem.h index aee288a419..2649435ed5 100644 --- a/dmd/root/dsystem.h +++ b/dmd/root/dsystem.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/root/file.d b/dmd/root/file.d index 9e3d0cf870..700e709af4 100644 --- a/dmd/root/file.d +++ b/dmd/root/file.d @@ -1,7 +1,7 @@ /** * Read a file from disk and store it in memory. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/file.d, root/_file.d) diff --git a/dmd/root/filename.d b/dmd/root/filename.d index cb08b09476..a1d603762c 100644 --- a/dmd/root/filename.d +++ b/dmd/root/filename.d @@ -1,7 +1,7 @@ /** * Encapsulate path and file names. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/filename.d, root/_filename.d) diff --git a/dmd/root/filename.h b/dmd/root/filename.h index 4f7822194a..de96fda874 100644 --- a/dmd/root/filename.h +++ b/dmd/root/filename.h @@ -1,5 +1,5 @@ -/* Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved +/* Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/root/hash.d b/dmd/root/hash.d index 885238461f..48b5012197 100644 --- a/dmd/root/hash.d +++ b/dmd/root/hash.d @@ -1,7 +1,7 @@ /** * Hash functions for arbitrary binary data. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Martin Nowak, Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/hash.d, root/_hash.d) diff --git a/dmd/root/longdouble.d b/dmd/root/longdouble.d index b012ac7076..5d468f2752 100644 --- a/dmd/root/longdouble.d +++ b/dmd/root/longdouble.d @@ -1,7 +1,7 @@ /** * 80-bit floating point value implementation if the C/D compiler does not support them natively. * - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * All Rights Reserved, written by Rainer Schuetze * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/root/longdouble.h b/dmd/root/longdouble.h index d058d32eec..c18af41bb3 100644 --- a/dmd/root/longdouble.h +++ b/dmd/root/longdouble.h @@ -1,5 +1,5 @@ -/* Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved +/* Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Rainer Schuetze * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/root/man.d b/dmd/root/man.d index 2ec7de7615..ad5225a1d1 100644 --- a/dmd/root/man.d +++ b/dmd/root/man.d @@ -1,7 +1,7 @@ /** * Open an online manual page. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/man.d, root/_man.d) diff --git a/dmd/root/optional.d b/dmd/root/optional.d index 2b518eb8b1..7ba38d4e27 100644 --- a/dmd/root/optional.d +++ b/dmd/root/optional.d @@ -1,7 +1,7 @@ /** * Implementation of an 'Optional' type * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/optional.d, root/_optional.d) diff --git a/dmd/root/optional.h b/dmd/root/optional.h index 12891f879b..2f7ccf3585 100644 --- a/dmd/root/optional.h +++ b/dmd/root/optional.h @@ -3,7 +3,7 @@ /** * Optional implementation. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/optional.h, root/_optional.h) diff --git a/dmd/root/port.d b/dmd/root/port.d index c96ac86fd0..fea630fef6 100644 --- a/dmd/root/port.d +++ b/dmd/root/port.d @@ -1,7 +1,7 @@ /** * Portable routines for functions that have different implementations on different platforms. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/port.d, root/_port.d) diff --git a/dmd/root/port.h b/dmd/root/port.h index dfb56b0fef..2f7b3dc396 100644 --- a/dmd/root/port.h +++ b/dmd/root/port.h @@ -1,5 +1,5 @@ -/* Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved +/* Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/root/region.d b/dmd/root/region.d index 9d241b8cc6..357663ff16 100644 --- a/dmd/root/region.d +++ b/dmd/root/region.d @@ -1,7 +1,7 @@ /** * Region storage allocator implementation. * - * Copyright: Copyright (C) 2019-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 2019-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/region.d, root/_region.d) diff --git a/dmd/root/rmem.d b/dmd/root/rmem.d index 02906731e6..45d0a26fe0 100644 --- a/dmd/root/rmem.d +++ b/dmd/root/rmem.d @@ -1,7 +1,7 @@ /** * Allocate memory using `malloc` or the GC depending on the configuration. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/rmem.d, root/_rmem.d) diff --git a/dmd/root/rmem.h b/dmd/root/rmem.h index b6645ec129..3bbb96a199 100644 --- a/dmd/root/rmem.h +++ b/dmd/root/rmem.h @@ -1,5 +1,5 @@ -/* Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved +/* Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/root/speller.d b/dmd/root/speller.d index a2151106d0..55dfbad2ae 100644 --- a/dmd/root/speller.d +++ b/dmd/root/speller.d @@ -3,7 +3,7 @@ * * Does not have any dependencies on the rest of DMD. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/speller.d, root/_speller.d) diff --git a/dmd/root/string.d b/dmd/root/string.d index 7ae5128530..5c7b69cf5f 100644 --- a/dmd/root/string.d +++ b/dmd/root/string.d @@ -1,7 +1,7 @@ /** * Contains various string related functions. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/string.d, root/_string.d) diff --git a/dmd/root/stringtable.d b/dmd/root/stringtable.d index 1d9e2e078c..00c6d24acf 100644 --- a/dmd/root/stringtable.d +++ b/dmd/root/stringtable.d @@ -1,7 +1,7 @@ /** * A specialized associative array with string keys stored in a variable length structure. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/stringtable.d, root/_stringtable.d) diff --git a/dmd/root/utf.d b/dmd/root/utf.d index 5b2c42f4ee..229f3991c6 100644 --- a/dmd/root/utf.d +++ b/dmd/root/utf.d @@ -1,7 +1,7 @@ /** * Functions related to UTF encoding. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/root/utf.d, _utf.d) diff --git a/dmd/rootobject.d b/dmd/rootobject.d index 7101374e25..3596d73737 100644 --- a/dmd/rootobject.d +++ b/dmd/rootobject.d @@ -1,7 +1,7 @@ /** * Provide the root object that AST classes in dmd inherit from. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: Walter Bright, https://www.digitalmars.com * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/rootobject.d, _rootobject.d) diff --git a/dmd/rootobject.h b/dmd/rootobject.h index 297f852e37..3238ea30a2 100644 --- a/dmd/rootobject.h +++ b/dmd/rootobject.h @@ -1,5 +1,5 @@ -/* Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved +/* Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/safe.d b/dmd/safe.d index 672b1574d2..c11ea23c03 100644 --- a/dmd/safe.d +++ b/dmd/safe.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/function.html#function-safety, Function Safety) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/safe.d, _safe.d) diff --git a/dmd/sarif.d b/dmd/sarif.d index f596b788b3..e7f48bda3c 100644 --- a/dmd/sarif.d +++ b/dmd/sarif.d @@ -1,7 +1,7 @@ /** * Provides SARIF (Static Analysis Results Interchange Format) reporting functionality. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/sarif.d, sarif.d) diff --git a/dmd/scope.h b/dmd/scope.h index afd9f6c00a..6c54319e20 100644 --- a/dmd/scope.h +++ b/dmd/scope.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/semantic2.d b/dmd/semantic2.d index cca8dcea38..2a42668cf5 100644 --- a/dmd/semantic2.d +++ b/dmd/semantic2.d @@ -1,7 +1,7 @@ /** * Performs the semantic2 stage, which deals with initializer expressions. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/semantic2.d, _semantic2.d) diff --git a/dmd/semantic3.d b/dmd/semantic3.d index b55eb37429..b22ab8c0af 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -3,7 +3,7 @@ * function bodies and late semantic checks for templates, mixins, * aggregates, and special members. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/semantic3.d, _semantic3.d) diff --git a/dmd/sideeffect.d b/dmd/sideeffect.d index 402a74c0f9..344ef05402 100644 --- a/dmd/sideeffect.d +++ b/dmd/sideeffect.d @@ -1,7 +1,7 @@ /** * Find side-effects of expressions. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/sideeffect.d, _sideeffect.d) diff --git a/dmd/statement.d b/dmd/statement.d index 890a5d4aa0..f8ec344f7a 100644 --- a/dmd/statement.d +++ b/dmd/statement.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/statement.html, Statements) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/statement.d, _statement.d) diff --git a/dmd/statement.h b/dmd/statement.h index 469e3902e9..d49f4e47db 100644 --- a/dmd/statement.h +++ b/dmd/statement.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/statementsem.d b/dmd/statementsem.d index 8ce4b43663..9bcc9c4a50 100644 --- a/dmd/statementsem.d +++ b/dmd/statementsem.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/statement.html, Statements) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/statementsem.d, _statementsem.d) diff --git a/dmd/staticassert.d b/dmd/staticassert.d index 2957fa6e8f..97bd8e5202 100644 --- a/dmd/staticassert.d +++ b/dmd/staticassert.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/version.html#static-assert, Static Assert) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/staticassert.d, _staticassert.d) diff --git a/dmd/staticassert.h b/dmd/staticassert.h index 1ef72850a7..471ff00fab 100644 --- a/dmd/staticassert.h +++ b/dmd/staticassert.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/staticcond.d b/dmd/staticcond.d index c2e87c7bf3..75a059640d 100644 --- a/dmd/staticcond.d +++ b/dmd/staticcond.d @@ -1,7 +1,7 @@ /** * Lazily evaluate static conditions for `static if`, `static assert` and template constraints. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/staticcond.d, _staticcond.d) diff --git a/dmd/stmtstate.d b/dmd/stmtstate.d index 1c1fd080ee..d75538e53e 100644 --- a/dmd/stmtstate.d +++ b/dmd/stmtstate.d @@ -1,7 +1,7 @@ /** * Used to help transform statement AST into flow graph. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/stmtstate.d, _stmtstate.d) diff --git a/dmd/target.d b/dmd/target.d index 4575ae9355..c7cab55604 100644 --- a/dmd/target.d +++ b/dmd/target.d @@ -15,7 +15,7 @@ * - $(LINK2 https://github.com/ldc-developers/ldc, LDC repository) * - $(LINK2 https://github.com/D-Programming-GDC/gcc, GDC repository) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/target.d, _target.d) diff --git a/dmd/target.h b/dmd/target.h index 596560935b..f7a267ab08 100644 --- a/dmd/target.h +++ b/dmd/target.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 2013-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 2013-2026 by The D Language Foundation, All Rights Reserved * written by Iain Buclaw * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/targetcompiler.d b/dmd/targetcompiler.d index 8631c56d4a..f47b116771 100644 --- a/dmd/targetcompiler.d +++ b/dmd/targetcompiler.d @@ -1,7 +1,7 @@ /** * Encapsulates the vagaries of which of the three D compilers (gdc, ldc or dmd) is being built * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/mars.d, _targetcompiler.d) diff --git a/dmd/template.h b/dmd/template.h index c38a630d7c..6285ee439b 100644 --- a/dmd/template.h +++ b/dmd/template.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/templateparamsem.d b/dmd/templateparamsem.d index 4954b1d2be..6779ca982a 100644 --- a/dmd/templateparamsem.d +++ b/dmd/templateparamsem.d @@ -1,7 +1,7 @@ /** * Semantic analysis of template parameters. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/templateparamsem.d, _templateparamsem.d) diff --git a/dmd/templatesem.d b/dmd/templatesem.d index ac107b0492..3144c2a139 100644 --- a/dmd/templatesem.d +++ b/dmd/templatesem.d @@ -1,7 +1,7 @@ /** * Template semantics. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/templatesem.d, _templatesem.d) diff --git a/dmd/timetrace.d b/dmd/timetrace.d index a29c4027be..4d3ced3f21 100644 --- a/dmd/timetrace.d +++ b/dmd/timetrace.d @@ -6,7 +6,7 @@ here: https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKch This file is originally from LDC (the LLVM D compiler). -Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved +Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved Authors: Johan Engelen, Max Haughton, Dennis Korpel License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/timetrace.d, common/_timetrace.d) diff --git a/dmd/tokens.d b/dmd/tokens.d index 05f413b51c..c1f7b05987 100644 --- a/dmd/tokens.d +++ b/dmd/tokens.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/lex.html#tokens, Tokens) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/tokens.d, _tokens.d) diff --git a/dmd/tokens.h b/dmd/tokens.h index baa3317b02..1ce4b24fbf 100644 --- a/dmd/tokens.h +++ b/dmd/tokens.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/traits.d b/dmd/traits.d index 8ea04c1c38..5867480633 100644 --- a/dmd/traits.d +++ b/dmd/traits.d @@ -3,7 +3,7 @@ * * Specification: $(LINK2 https://dlang.org/spec/traits.html, Traits) * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/traits.d, _traits.d) diff --git a/dmd/typesem.d b/dmd/typesem.d index e5a08798a3..22c997e0dc 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -1,7 +1,7 @@ /** * Semantic analysis for D types. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/typesem.d, _typesem.d) diff --git a/dmd/typinf.d b/dmd/typinf.d index 5125e30933..086597aff3 100644 --- a/dmd/typinf.d +++ b/dmd/typinf.d @@ -1,7 +1,7 @@ /** * Generate `TypeInfo` objects, which are needed for run-time introspection of types. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/typinf.d, _typinf.d) diff --git a/dmd/typinf.h b/dmd/typinf.h index c34494da2f..f13dcc8675 100644 --- a/dmd/typinf.h +++ b/dmd/typinf.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/utils.d b/dmd/utils.d index bfa197aca3..96347712e0 100644 --- a/dmd/utils.d +++ b/dmd/utils.d @@ -1,7 +1,7 @@ /** * This module defines some utility functions for DMD. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/utils.d, _utils.d) diff --git a/dmd/version.h b/dmd/version.h index 1200b2e5ee..ce554a350b 100644 --- a/dmd/version.h +++ b/dmd/version.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. diff --git a/dmd/visitor.h b/dmd/visitor.h index 94fd29402f..d359d51746 100644 --- a/dmd/visitor.h +++ b/dmd/visitor.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 2013-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 2013-2026 by The D Language Foundation, All Rights Reserved * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. * https://www.boost.org/LICENSE_1_0.txt diff --git a/dmd/visitor/foreachvar.d b/dmd/visitor/foreachvar.d index 73d7c3ef9d..4cedf04906 100644 --- a/dmd/visitor/foreachvar.d +++ b/dmd/visitor/foreachvar.d @@ -1,7 +1,7 @@ /** * Utility to visit every variable in an expression. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/visitor/foreachvar.d, _foreachvar.d) diff --git a/dmd/visitor/package.d b/dmd/visitor/package.d index 50b5a54520..2f2e31beec 100644 --- a/dmd/visitor/package.d +++ b/dmd/visitor/package.d @@ -1,7 +1,7 @@ /** * Provides a visitor class visiting all AST nodes present in the compiler. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/visitor/package.d, _visitor.d) diff --git a/dmd/visitor/postorder.d b/dmd/visitor/postorder.d index f7c1f8dccf..1a45e61d56 100644 --- a/dmd/visitor/postorder.d +++ b/dmd/visitor/postorder.d @@ -1,7 +1,7 @@ /** * A depth-first visitor for expressions and statements. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/visitor/postorder.d, _apply.d) diff --git a/dmd/visitor/statement_rewrite_walker.d b/dmd/visitor/statement_rewrite_walker.d index 25e4c736bb..31fd7ff0ae 100644 --- a/dmd/visitor/statement_rewrite_walker.d +++ b/dmd/visitor/statement_rewrite_walker.d @@ -1,7 +1,7 @@ /** * Provides a visitor for statements that allows rewriting the currently visited node. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/visitor/statement_rewrite_walker.d, _statement_rewrite_walker.d) diff --git a/dmd/vsoptions.d b/dmd/vsoptions.d index 4537109920..16635e3df1 100644 --- a/dmd/vsoptions.d +++ b/dmd/vsoptions.d @@ -1,7 +1,7 @@ /** * When compiling on Windows with the Microsoft toolchain, try to detect the Visual Studio setup. * - * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved + * Copyright: Copyright (C) 1999-2026 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/vsoptions.d, _vsoptions.d) diff --git a/dmd/vsoptions.h b/dmd/vsoptions.h index f087e50e60..eda4961909 100644 --- a/dmd/vsoptions.h +++ b/dmd/vsoptions.h @@ -1,6 +1,6 @@ /* Compiler implementation of the D programming language - * Copyright (C) 2009-2025 by The D Language Foundation, All Rights Reserved + * Copyright (C) 2009-2026 by The D Language Foundation, All Rights Reserved * written by Walter Bright * https://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. From e3c8975664f962a671eaf91c85e85e52191bfb5c Mon Sep 17 00:00:00 2001 From: Sergii Kuzko Date: Tue, 6 Jan 2026 16:04:49 +0300 Subject: [PATCH 253/440] fixroot_array --- dmd/root/array.d | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dmd/root/array.d b/dmd/root/array.d index 5f8c01a0f9..2420cd76fa 100644 --- a/dmd/root/array.d +++ b/dmd/root/array.d @@ -205,10 +205,13 @@ public: memcpy(p, data.ptr, length * T.sizeof); memset(data.ptr, 0xFF, data.length * T.sizeof); mem.xfree(data.ptr); + data = p[0 .. allocdim]; } else + { auto p = cast(T*)mem.xrealloc(data.ptr, allocdim * T.sizeof); - data = p[0 .. allocdim]; + data = p[0 .. allocdim]; + } } debug (stomp) From 7a70e0b655f0a61248dae6b1fad6663b477a38eb Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Tue, 6 Jan 2026 19:03:05 +0100 Subject: [PATCH 254/440] Move enum class Edition to globals.h --- dmd/globals.h | 9 ++++++++- dmd/module.h | 7 ------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dmd/globals.h b/dmd/globals.h index 576654ee82..e06c9bf7ad 100644 --- a/dmd/globals.h +++ b/dmd/globals.h @@ -66,6 +66,13 @@ enum JsonFieldFlags semantics = (1 << 3) }; +enum class Edition : uint16_t +{ + v2023 = 2023, + v2024, + v2025, +}; + enum CppStdRevision { CppStdRevisionCpp98 = 199711, @@ -204,7 +211,7 @@ struct Param Help help; Verbose v; - unsigned short edition; // edition year + Edition edition; // edition year void* editionFiles; // Edition corresponding to a filespec // Options for `-preview=/-revert=` diff --git a/dmd/module.h b/dmd/module.h index 6a010722e4..e23851acd5 100644 --- a/dmd/module.h +++ b/dmd/module.h @@ -30,13 +30,6 @@ enum PKG PKGpackage // already determined that's an actual package }; -enum class Edition : uint16_t -{ - v2023 = 2023, - v2024, - v2025, -}; - class Package : public ScopeDsymbol { public: From 0f440b6ac30bc2d22437592a0334e70a753d4bee Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Tue, 6 Jan 2026 23:55:18 +0100 Subject: [PATCH 255/440] _d_cast: Don't generate lowering for casts to extern(C++) class (dlang/dmd!22353) --- dmd/expressionsem.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 00bddf86de..4c564b7761 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -4924,7 +4924,7 @@ private void lowerCastExp(CastExp cex, Scope* sc) int offset; if ((cdto.isBaseOf(cdfrom, &offset) && offset != ClassDeclaration.OFFSET_RUNTIME) - || cdfrom.classKind == ClassKind.cpp) + || cdfrom.classKind == ClassKind.cpp || cdto.classKind == ClassKind.cpp) return; Identifier hook = Id._d_cast; From 163dc4f306659d52b290a473cd57710d8058c40c Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Wed, 7 Jan 2026 03:05:07 +0200 Subject: [PATCH 256/440] Move funcs (dlang/dmd!22356) --- dmd/dcast.d | 52 ++++++++++++++++++++++++++++++++++++++++++---- dmd/importc.d | 2 +- dmd/intrange.d | 45 --------------------------------------- dmd/statementsem.d | 6 +++--- 4 files changed, 52 insertions(+), 53 deletions(-) diff --git a/dmd/dcast.d b/dmd/dcast.d index 73cfca8a5d..09cf803838 100644 --- a/dmd/dcast.d +++ b/dmd/dcast.d @@ -50,6 +50,50 @@ import dmd.typesem; enum LOG = false; +IntRange _cast(IntRange _this, Type type) +{ + if (!type.isIntegral() || type.toBasetype().isTypeVector()) + return _this; + if (!type.isUnsigned()) + return _this.castSigned(type.sizemask()); + if (type.toBasetype().ty == Tdchar) + return _this.castDchar(); + return _this.castUnsigned(type.sizemask()); +} + +IntRange castUnsigned(IntRange _this, Type type) +{ + if (!type.isIntegral() || type.toBasetype().isTypeVector()) + return _this.castUnsigned(ulong.max); + if (type.toBasetype().ty == Tdchar) + return _this.castDchar(); + return _this.castUnsigned(type.sizemask()); +} + +IntRange intRangeFromType(Type type) +{ + return intRangeFromType(type, type.isUnsigned()); +} + +IntRange intRangeFromType(Type type, bool isUnsigned) +{ + if (!type.isIntegral() || type.toBasetype().isTypeVector()) + return IntRange.widest(); + + uinteger_t mask = type.sizemask(); + auto lower = SignExtendedNumber(0); + auto upper = SignExtendedNumber(mask); + if (type.toBasetype().ty == Tdchar) + upper.value = 0x10FFFFUL; + else if (!isUnsigned) + { + lower.value = ~(mask >> 1); + lower.negative = true; + upper.value = (mask >> 1); + } + return IntRange(lower, upper); +} + /** * Attempt to implicitly cast the expression into type `t`. * @@ -304,7 +348,7 @@ MATCH implicitConvTo(Expression e, Type t) if (e.type.isIntegral() && t.isIntegral() && e.type.isTypeBasic() && t.isTypeBasic()) { IntRange src = getIntRange(e); - IntRange target = IntRange.fromType(t); + IntRange target = intRangeFromType(t); if (target.contains(src)) { return MATCH.convert; @@ -4358,7 +4402,7 @@ IntRange getIntRange(Expression e) { IntRange visit(Expression e) { - return IntRange.fromType(e.type); + return intRangeFromType(e.type); } IntRange visitInteger(IntegerExp e) @@ -4462,7 +4506,7 @@ IntRange getIntRange(Expression e) IntRange visitUshr(UshrExp e) { - IntRange ir1 = getIntRange(e.e1).castUnsigned(e.e1.type); + IntRange ir1 = castUnsigned(getIntRange(e.e1), e.e1.type); IntRange ir2 = getIntRange(e.e2); return (ir1 >>> ir2)._cast(e.type); @@ -4486,7 +4530,7 @@ IntRange getIntRange(Expression e) Expression ie; VarDeclaration vd = e.var.isVarDeclaration(); if (vd && vd.range) - return vd.range._cast(e.type); + return _cast(*vd.range, e.type); if (vd && vd._init && !vd.type.isMutable() && (ie = vd.getConstInitializer()) !is null) return getIntRange(ie); return visit(e); diff --git a/dmd/importc.d b/dmd/importc.d index cf94b632a8..6b4695a9f1 100644 --- a/dmd/importc.d +++ b/dmd/importc.d @@ -631,7 +631,7 @@ void cEnumSemantic(Scope* sc, EnumDeclaration ed) // C11 6.7.2.2-2 value must be representable as an int. // The sizemask represents all values that int will fit into, // from 0..uint.max. We want to cover int.min..uint.max. - IntRange ir = IntRange.fromType(commonType); + IntRange ir = intRangeFromType(commonType); void emSemantic(EnumMember em, ref ulong nextValue) { diff --git a/dmd/intrange.d b/dmd/intrange.d index 4f8af92433..cc69373d12 100644 --- a/dmd/intrange.d +++ b/dmd/intrange.d @@ -16,7 +16,6 @@ import core.stdc.stdio; import dmd.astenums : Tdchar; import dmd.mtype : Type; import dmd.globals : uinteger_t; -import dmd.typesem; private uinteger_t copySign(uinteger_t x, bool sign) @safe { @@ -315,30 +314,6 @@ struct IntRange imax = upper; } - static IntRange fromType(Type type) - { - return fromType(type, type.isUnsigned()); - } - - static IntRange fromType(Type type, bool isUnsigned) - { - if (!type.isIntegral() || type.toBasetype().isTypeVector()) - return widest(); - - uinteger_t mask = type.sizemask(); - auto lower = SignExtendedNumber(0); - auto upper = SignExtendedNumber(mask); - if (type.toBasetype().ty == Tdchar) - upper.value = 0x10FFFFUL; - else if (!isUnsigned) - { - lower.value = ~(mask >> 1); - lower.negative = true; - upper.value = (mask >> 1); - } - return IntRange(lower, upper); - } - static IntRange fromNumbers2(SignExtendedNumber* numbers) { if (numbers[0] < numbers[1]) @@ -442,26 +417,6 @@ struct IntRange return this; } - IntRange _cast(Type type) - { - if (!type.isIntegral() || type.toBasetype().isTypeVector()) - return this; - if (!type.isUnsigned()) - return castSigned(type.sizemask()); - if (type.toBasetype().ty == Tdchar) - return castDchar(); - return castUnsigned(type.sizemask()); - } - - IntRange castUnsigned(Type type) - { - if (!type.isIntegral() || type.toBasetype().isTypeVector()) - return castUnsigned(ulong.max); - if (type.toBasetype().ty == Tdchar) - return castDchar(); - return castUnsigned(type.sizemask()); - } - bool contains(IntRange a) @safe { return imin <= a.imin && imax >= a.imax; diff --git a/dmd/statementsem.d b/dmd/statementsem.d index 9bcc9c4a50..d602f8d30e 100644 --- a/dmd/statementsem.d +++ b/dmd/statementsem.d @@ -1019,7 +1019,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc) if (tab.isTypeDArray()) { // check if overflow is possible - const maxLen = IntRange.fromType(tindex).imax.value + 1; + const maxLen = intRangeFromType(tindex).imax.value + 1; if (auto ale = fs.aggr.isArrayLiteralExp()) err = ale.elements.length > maxLen; else if (auto se = fs.aggr.isSliceExp()) @@ -1082,7 +1082,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc) IntRange dimrange = getIntRange(ta.dim); // https://issues.dlang.org/show_bug.cgi?id=12504 dimrange.imax = SignExtendedNumber(dimrange.imax.value-1); - if (!IntRange.fromType(fs.key.type).contains(dimrange)) + if (!intRangeFromType(fs.key.type).contains(dimrange)) { error(fs.loc, "index type `%s` cannot cover index range 0..%llu", p.type.toChars(), ta.dim.toInteger()); @@ -4489,7 +4489,7 @@ public auto makeTupleForeach(Scope* sc, bool isStatic, bool isDecl, ForeachState IntRange dimrange = IntRange(SignExtendedNumber(length))._cast(Type.tsize_t); // https://issues.dlang.org/show_bug.cgi?id=12504 dimrange.imax = SignExtendedNumber(dimrange.imax.value-1); - if (!IntRange.fromType(p.type).contains(dimrange)) + if (!intRangeFromType(p.type).contains(dimrange)) { error(fs.loc, "index type `%s` cannot cover index range 0..%llu", p.type.toChars(), cast(ulong)length); From 136e8e541f6d7dfcb1f27ae088402d59528efcef Mon Sep 17 00:00:00 2001 From: Emmanuel Nyarko <57257441+Emmankoko@users.noreply.github.com> Date: Fri, 9 Jan 2026 00:25:33 +0000 Subject: [PATCH 257/440] fix dlang/dmd!22153 and dlang/dmd!20152 (dlang/dmd!22360) --- dmd/importc.d | 40 ++++++++++++++++++++++++++++++--- tests/dmd/compilable/fix22153.c | 15 +++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 tests/dmd/compilable/fix22153.c diff --git a/dmd/importc.d b/dmd/importc.d index 6b4695a9f1..4c26147d82 100644 --- a/dmd/importc.d +++ b/dmd/importc.d @@ -575,16 +575,50 @@ Dsymbol handleSymbolRedeclarations(ref Scope sc, Dsymbol s, Dsymbol s2, ScopeDsy if (fd.fbody) // fd is the definition { if (log) printf(" replace existing with new\n"); - sds.symtab.update(fd); // replace fd2 in symbol table with fd + + /* transfer definition to the declaration + * for internal resolution for static library + * only if they're already matching + */ + + if (fd.storage_class & STC.static_ && + fd2.storage_class & STC.static_ ) + { + fd.type = typeSemantic(fd.type, fd.loc, &sc); + fd2.type = typeSemantic(fd2.type, fd2.loc, &sc); + + auto tfunc1 = fd.type.isTypeFunction(); + auto tfunc2 = fd2.type.isTypeFunction(); + + if ( !cTypeEquivalence(tfunc1.next, tfunc2.next) || !cFuncEquivalence(tfunc1, tfunc2)) + { + .error(fd.loc, "%s `%s` redeclaration with different type", fd.kind, fd.toPrettyChars); + } + + fd2.fbody = fd.fbody; + fd.fbody = null; + + fd2.type = fd.type; + fd2.parameters = fd.parameters; + fd2._linkage = fd._linkage; + fd2.storage_class |= fd.storage_class; + + fd.storage_class |= STC.disable; // disable previous definition for backend + } + else + { + sds.symtab.update(fd); + } + fd.overnext = fd2; /* If fd2 is covering a tag symbol, then fd has to cover the same one */ auto ps = cast(void*)fd2 in sc._module.tagSymTab; if (ps) - sc._module.tagSymTab[cast(void*)fd] = *ps; + sc._module.tagSymTab[cast(void*)fd2] = *ps; - return fd; + return fd2; } /* Just like with VarDeclaration, the types should match, which needs semantic() to be run on it. diff --git a/tests/dmd/compilable/fix22153.c b/tests/dmd/compilable/fix22153.c new file mode 100644 index 0000000000..237939b637 --- /dev/null +++ b/tests/dmd/compilable/fix22153.c @@ -0,0 +1,15 @@ +// REQUIRED_ARGS: -lib + +// https://github.com/dlang/dmd/issues/22153 + + +static void static_fun(); + +void lib_fun() +{ + static_fun(); +} + +static void static_fun() +{ +} From 45e1a860592dd56430bd27b1e09680b632056601 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Fri, 9 Jan 2026 15:39:43 +0800 Subject: [PATCH 258/440] Remove branches if the condition is noreturn (dlang/dmd!22362) This is a better fix than https://github.com/dlang/dmd/pull/22359 because it is a more direct fix, rather than the rpair test. --- tests/dmd/compilable/issue22254.d | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/dmd/compilable/issue22254.d diff --git a/tests/dmd/compilable/issue22254.d b/tests/dmd/compilable/issue22254.d new file mode 100644 index 0000000000..94025c18da --- /dev/null +++ b/tests/dmd/compilable/issue22254.d @@ -0,0 +1,6 @@ +// https://github.com/dlang/dmd/issues/22254 + +void main() +{ + assert(assert(0, ""), ""); +} From c75b572e3f1826793f92f61e83d015cb9e7ff44f Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Fri, 9 Jan 2026 09:46:42 +0100 Subject: [PATCH 259/440] Adjust offsets for all nameless fields in anon declaration For example, structs with mixed named and anonymous bitfields had their bit offset correctly set, but only named fields had their byte offset adjusted, which would incorrectly inform backend targets where in the layout the explicit padding is. --- dmd/dsymbolsem.d | 54 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index ce4c8f6b42..b9afe21268 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -8656,14 +8656,56 @@ private extern(C++) class SetFieldOffsetVisitor : Visitor isunion); // Add to the anon fields the base offset of this anonymous aggregate - //printf("anon fields, anonoffset = %d\n", anonoffset); - foreach (const i; fieldstart .. ad.fields.length) + //printf("anon fields, anonoffset = %d\n", anond.anonoffset); + if (anond.anonoffset) + anond.decl.foreachDsymbol( (s) => s.adjustBaseOffset(anond.anonoffset) ); + } + } +} + +// Adds `offset` as the new base offset of all field members in `d`. +private void adjustBaseOffset(Dsymbol d, uint offset) +{ + switch (d.dsym) + { + case DSYM.nspace: + auto ns = cast(Nspace)d; + ns.members.foreachDsymbol( s => s.adjustBaseOffset(offset) ); + break; + + case DSYM.templateMixin: + auto tm = cast(TemplateMixin)d; + tm.members.foreachDsymbol( s => s.adjustBaseOffset(offset) ); + break; + + case DSYM.anonDeclaration: + auto ad = cast(AnonDeclaration)d; + if (ad.decl) + ad.decl.foreachDsymbol( s => s.adjustBaseOffset(offset) ); + break; + + case DSYM.bitFieldDeclaration: + auto bfd = cast(BitFieldDeclaration)d; + bfd.offset += offset; + //printf("\t%s %d : %d\n", bfd.toChars(), bfd.offset, bfd.bitOffset); + break; + + default: + if (auto vd = d.isVarDeclaration()) + { + if (vd.aliasTuple) + vd.aliasTuple.foreachVar( s => s.adjustBaseOffset(offset) ); + else if (vd.isField()) + { + vd.offset += offset; + //printf("\t%s %d\n", vd.toChars(), vd.offset); + } + } + else if (auto atd = d.isAttribDeclaration()) { - VarDeclaration v = ad.fields[i]; - //printf("\t[%d] %s %d\n", i, v.toChars(), v.offset); - v.offset += anond.anonoffset; + atd.include(null).foreachDsymbol( s => s.adjustBaseOffset(offset) ); } - } + break; } } From 97364e472222b9f15a029fed69b158bfbdacfe1e Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Sat, 10 Jan 2026 17:52:15 +1300 Subject: [PATCH 260/440] Improve error message when symbol lookup fails, show where the suggested symbol is located at --- dmd/expressionsem.d | 3 +++ tests/dmd/fail_compilation/diag14235.d | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index feee84989c..3bf5e4e2dd 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -15144,7 +15144,10 @@ Expression dotIdSemanticProp(DotIdExp exp, Scope* sc, bool gag) if (s.isPackage()) error(exp.loc, "undefined identifier `%s` in %s `%s`, perhaps add `static import %s;`", exp.ident.toChars(), ie.sds.kind(), ie.sds.toPrettyChars(), s.toPrettyChars()); else + { error(exp.loc, "undefined identifier `%s` in %s `%s`, did you mean %s `%s`?", exp.ident.toChars(), ie.sds.kind(), ie.sds.toPrettyChars(), s.kind(), s.toChars()); + errorSupplemental(s.loc, "`%s` located here", s.toPrettyChars(true)); + } } else error(exp.loc, "undefined identifier `%s` in %s `%s`", exp.ident.toChars(), ie.sds.kind(), ie.sds.toPrettyChars()); diff --git a/tests/dmd/fail_compilation/diag14235.d b/tests/dmd/fail_compilation/diag14235.d index 8c563ba44c..51ffa47a18 100644 --- a/tests/dmd/fail_compilation/diag14235.d +++ b/tests/dmd/fail_compilation/diag14235.d @@ -2,9 +2,10 @@ EXTRA_FILES: imports/a14235.d TEST_OUTPUT: --- -fail_compilation/diag14235.d(12): Error: undefined identifier `Undefined` in module `imports.a14235` -fail_compilation/diag14235.d(13): Error: undefined identifier `Something` in module `imports.a14235`, did you mean struct `SomeThing(T...)`? -fail_compilation/diag14235.d(14): Error: `SomeClass` isn't a template +fail_compilation/diag14235.d(13): Error: undefined identifier `Undefined` in module `imports.a14235` +fail_compilation/diag14235.d(14): Error: undefined identifier `Something` in module `imports.a14235`, did you mean struct `SomeThing(T...)`? +fail_compilation/imports/a14235.d(3): `imports.a14235.SomeThing(T...)` located here +fail_compilation/diag14235.d(15): Error: `SomeClass` isn't a template --- */ From abada15ba1c0e984d17d887338705061449d2117 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 10 Jan 2026 15:58:31 +0000 Subject: [PATCH 261/440] Check noreturn access for typeid and in condition --- dmd/expressionsem.d | 11 ++++++++++- tests/dmd/runnable/noreturn2.d | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 902b0563d4..a336946dad 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -8705,9 +8705,14 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (ea) { if (auto sym = getDsymbol(ea)) + { ea = symbolToExp(sym, exp.loc, sc, false); + if (ea.type.ty == Tnoreturn) + ea = checkNoreturnVarAccess(ea); + } else ea = ea.expressionSemantic(sc); + ea = resolveProperties(sc, ea); ta = ea.type; if (ea.op == EXP.type) @@ -18225,7 +18230,11 @@ Expression toBoolean(Expression exp, Scope* sc) break; } - if (!t.isBoolean()) + if (t.ty == Tnoreturn) + { + e = checkNoreturnVarAccess(e); + } + else if (!t.isBoolean()) { if (tb != Type.terror) { diff --git a/tests/dmd/runnable/noreturn2.d b/tests/dmd/runnable/noreturn2.d index ef0627202c..82f25f8e82 100644 --- a/tests/dmd/runnable/noreturn2.d +++ b/tests/dmd/runnable/noreturn2.d @@ -145,6 +145,20 @@ void testAccess() foo(a); assert(false, "Unreachable!"); // Ditto }); + + testAssertFailure(__LINE__ + 3, msg, + { + noreturn v; + auto id = typeid(v); + }); + + // test condition + testAssertFailure(__LINE__ + 3, msg, + { + noreturn v; + if (v) + return; + }); } /*****************************************/ From 70254dd4e38a88c0e30d7f2b5613e64899eedd24 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 10 Jan 2026 20:01:04 +0000 Subject: [PATCH 262/440] Remove unnecessary check for `Tnoreturn` --- dmd/expressionsem.d | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index a336946dad..2739758892 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -8707,8 +8707,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (auto sym = getDsymbol(ea)) { ea = symbolToExp(sym, exp.loc, sc, false); - if (ea.type.ty == Tnoreturn) - ea = checkNoreturnVarAccess(ea); + ea = checkNoreturnVarAccess(ea); } else ea = ea.expressionSemantic(sc); @@ -18230,11 +18229,8 @@ Expression toBoolean(Expression exp, Scope* sc) break; } - if (t.ty == Tnoreturn) - { - e = checkNoreturnVarAccess(e); - } - else if (!t.isBoolean()) + e = checkNoreturnVarAccess(e); + if (!t.isBoolean()) { if (tb != Type.terror) { From d9f4341eabfde281a598a8337045fa13b8cf7b9a Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 10 Jan 2026 19:46:52 -0800 Subject: [PATCH 263/440] refactor reportSafeError() --- dmd/safe.d | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/dmd/safe.d b/dmd/safe.d index 672b1574d2..d7da38cda8 100644 --- a/dmd/safe.d +++ b/dmd/safe.d @@ -25,10 +25,11 @@ import dmd.dscope; import dmd.dsymbol; import dmd.dsymbolsem : determineSize; import dmd.errors; +import dmd.errorsink; import dmd.expression; import dmd.func; import dmd.funcsem : isRootTraitsCompilesScope; -import dmd.globals : FeatureState; +import dmd.globals : FeatureState, global; import dmd.id; import dmd.identifier; import dmd.location; @@ -365,19 +366,15 @@ bool isTrusted(FuncDeclaration fd) * fd = function we are gonna rat on * gag = suppress error message (used in escape.d) * loc = location of error + * scopeVar = if not null, is the variable whose scope status caused the violation * format = printf-style format string * args = arguments for %s format specifier */ -extern (D) void reportSafeError(FuncDeclaration fd, bool gag, Loc loc, - const(char)* format, RootObject[] args...) -{ - reportSafeError(fd, gag, loc, null, format, args); -} - -/// Overload that also stores the variable whose scope status caused the violation -extern (D) void reportSafeError(FuncDeclaration fd, bool gag, Loc loc, +private +void reportSafeError(FuncDeclaration fd, bool gag, Loc loc, VarDeclaration scopeVar, const(char)* format, RootObject[] args...) { + ErrorSink eSink = global.errorSink; if (fd.type.toTypeFunction().trust == TRUST.system) // function was just inferred to be @system { if (format) @@ -407,7 +404,7 @@ extern (D) void reportSafeError(FuncDeclaration fd, bool gag, Loc loc, { buf.printf(" is not allowed in a function with default safety with `-%spreview=safer`", SwitchPrefix.ptr); } - .error(loc, "%s", buf.extractChars()); + eSink.error(loc, "%s", buf.extractChars()); } } } @@ -451,7 +448,7 @@ extern (D) bool setUnsafeCall(FuncDeclaration fd, FuncDeclaration f) { if (setFunctionToUnsafe(fd)) { - reportSafeError(fd, false, f.loc, null, f, null); + reportSafeError(fd, false, f.loc, null, null, f, null); return fd.isSafe(); } return false; From 73307b8a158a7077603a2e5084745f377c268176 Mon Sep 17 00:00:00 2001 From: Rainer Date: Sun, 11 Jan 2026 09:15:50 +0100 Subject: [PATCH 264/440] allow including core.sys.linux.net.if_ and core.sys.linux.hdlc.ioctl in the build on platforms other than linux selective imports require the requested symbol to be defined, but it is not for mismatched versions --- runtime/druntime/src/core/sys/linux/hdlc/ioctl.d | 2 +- runtime/druntime/src/core/sys/linux/net/if_.d | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/druntime/src/core/sys/linux/hdlc/ioctl.d b/runtime/druntime/src/core/sys/linux/hdlc/ioctl.d index f879aae70a..78992964b6 100644 --- a/runtime/druntime/src/core/sys/linux/hdlc/ioctl.d +++ b/runtime/druntime/src/core/sys/linux/hdlc/ioctl.d @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ module core.sys.linux.hdlc.ioctl; +version (linux): import core.sys.linux.net.if_ : IFNAMSIZ; -version (linux): extern(C): @nogc: nothrow: diff --git a/runtime/druntime/src/core/sys/linux/net/if_.d b/runtime/druntime/src/core/sys/linux/net/if_.d index 62d247f125..ba6fc84f13 100644 --- a/runtime/druntime/src/core/sys/linux/net/if_.d +++ b/runtime/druntime/src/core/sys/linux/net/if_.d @@ -6,10 +6,10 @@ +/ module core.sys.linux.net.if_; +version (linux): public import core.sys.posix.sys.socket : sockaddr; public import core.sys.linux.hdlc.ioctl; -version (linux): extern(C): @nogc: nothrow: From 56b9afae8d838b6baf19e55f6a8ba14908cee698 Mon Sep 17 00:00:00 2001 From: Rainer Date: Sun, 11 Jan 2026 15:47:27 +0100 Subject: [PATCH 265/440] fix dlang/dmd!22381 - out-of-bounds access when masking ushort ignoring access width is only valid for registers, not for memory --- tests/dmd/compilable/test22381.d | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/dmd/compilable/test22381.d diff --git a/tests/dmd/compilable/test22381.d b/tests/dmd/compilable/test22381.d new file mode 100644 index 0000000000..6554f98f14 --- /dev/null +++ b/tests/dmd/compilable/test22381.d @@ -0,0 +1,17 @@ +/* +DISABLED: osx +REQUIRED_ARGS: -vasm +TEST_OUTPUT: +--- +_D9test223814maskFPtZv: +0000: $r:[0-9A-F ]*$and word ptr [$r:[A-Z]*$],0FFFEh +0005: C3 ret +--- +*/ + +// https://github.com/dlang/dmd/issues/22381 + +void mask(ushort* p) +{ + *p &= 0xfffe; +} From be8369a5a2ac9ccf8ff32d2ff531072002dda2ef Mon Sep 17 00:00:00 2001 From: Emmankoko Date: Fri, 12 Dec 2025 09:03:10 +0000 Subject: [PATCH 266/440] properly fix dlang/dmd!22153 --- dmd/importc.d | 40 +++------------------------------ tests/dmd/compilable/fix22153.c | 2 ++ 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/dmd/importc.d b/dmd/importc.d index 4c26147d82..6fc3a51731 100644 --- a/dmd/importc.d +++ b/dmd/importc.d @@ -575,50 +575,16 @@ Dsymbol handleSymbolRedeclarations(ref Scope sc, Dsymbol s, Dsymbol s2, ScopeDsy if (fd.fbody) // fd is the definition { if (log) printf(" replace existing with new\n"); - - /* transfer definition to the declaration - * for internal resolution for static library - * only if they're already matching - */ - - if (fd.storage_class & STC.static_ && - fd2.storage_class & STC.static_ ) - { - fd.type = typeSemantic(fd.type, fd.loc, &sc); - fd2.type = typeSemantic(fd2.type, fd2.loc, &sc); - - auto tfunc1 = fd.type.isTypeFunction(); - auto tfunc2 = fd2.type.isTypeFunction(); - - if ( !cTypeEquivalence(tfunc1.next, tfunc2.next) || !cFuncEquivalence(tfunc1, tfunc2)) - { - .error(fd.loc, "%s `%s` redeclaration with different type", fd.kind, fd.toPrettyChars); - } - - fd2.fbody = fd.fbody; - fd.fbody = null; - - fd2.type = fd.type; - fd2.parameters = fd.parameters; - fd2._linkage = fd._linkage; - fd2.storage_class |= fd.storage_class; - - fd.storage_class |= STC.disable; // disable previous definition for backend - } - else - { - sds.symtab.update(fd); - } - + sds.symtab.update(fd); // replace fd2 in symbol table with fd fd.overnext = fd2; /* If fd2 is covering a tag symbol, then fd has to cover the same one */ auto ps = cast(void*)fd2 in sc._module.tagSymTab; if (ps) - sc._module.tagSymTab[cast(void*)fd2] = *ps; + sc._module.tagSymTab[cast(void*)fd] = *ps; - return fd2; + return fd; } /* Just like with VarDeclaration, the types should match, which needs semantic() to be run on it. diff --git a/tests/dmd/compilable/fix22153.c b/tests/dmd/compilable/fix22153.c index 237939b637..cf423cdba9 100644 --- a/tests/dmd/compilable/fix22153.c +++ b/tests/dmd/compilable/fix22153.c @@ -5,6 +5,8 @@ static void static_fun(); +void (*funcptr)() = &static_fun; + void lib_fun() { static_fun(); From d321a193e666cd97a3d56638a5a35bdcbe21067d Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Mon, 12 Jan 2026 10:15:31 -0800 Subject: [PATCH 267/440] Fix dlang/dmd!22282 Applying a UDA to a File-type variable causes DMD to crash (dlang/dmd!22385) --- tests/dmd/runnable/uda.d | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/dmd/runnable/uda.d b/tests/dmd/runnable/uda.d index 133ae05457..713f36405a 100644 --- a/tests/dmd/runnable/uda.d +++ b/tests/dmd/runnable/uda.d @@ -749,6 +749,22 @@ template test15804() alias a15804 = test15804!(); +/************************************************/ +// https://github.com/dlang/dmd/issues/22282 + +struct S22282 +{ + int a,b; + this(string a, string b) { } + ~this() { } +} + +void issue22282() +{ + enum var; + @var S22282 file = S22282("tmp", "w"); +} + /************************************************/ int main() @@ -773,6 +789,7 @@ int main() test18(); test19(); test20(); + issue22282(); printf("Success\n"); return 0; From c09a5897f3447fd9989fbcf04af2a9652b29ccc0 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy Date: Tue, 13 Jan 2026 01:04:57 +0200 Subject: [PATCH 268/440] Change the lastdc type ptr to void --- dmd/doc.d | 4 ++-- dmd/dscope.d | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/dmd/doc.d b/dmd/doc.d index ada57729b0..a8b0de3223 100644 --- a/dmd/doc.d +++ b/dmd/doc.d @@ -1381,11 +1381,11 @@ void emitComment(Dsymbol s, ref OutBuffer buf, Scope* sc) { if (s && sc.lastdc && isDitto(com)) { - sc.lastdc.a.push(s); + (cast(DocComment*) sc.lastdc).a.push(s); return; } // Put previous doc comment if exists - if (DocComment* dc = sc.lastdc) + if (auto dc = cast(DocComment*) sc.lastdc) { assert(dc.a.length > 0, "Expects at least one declaration for a" ~ "documentation comment"); diff --git a/dmd/dscope.d b/dmd/dscope.d index 71442c48ba..f6be0f8273 100644 --- a/dmd/dscope.d +++ b/dmd/dscope.d @@ -22,7 +22,6 @@ import dmd.ctorflow; import dmd.dclass; import dmd.declaration; import dmd.dmodule; -import dmd.doc; import dmd.dstruct; import dmd.dsymbol; import dmd.dtemplate; @@ -190,7 +189,7 @@ extern (C++) struct Scope // user defined attributes UserAttributeDeclaration userAttribDecl; - DocComment* lastdc; /// documentation comment for last symbol at this scope + void* lastdc; /// documentation comment for last symbol at this scope (DocComment*) uint[void*] anchorCounts; /// lookup duplicate anchor name count Identifier prevAnchor; /// qualified symbol name of last doc anchor From fa99cdbd08cbd65f8ee46cc3f759275edfffecda Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy Date: Tue, 13 Jan 2026 01:05:10 +0200 Subject: [PATCH 269/440] Update headers --- dmd/frontend.h | 2 +- dmd/scope.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dmd/frontend.h b/dmd/frontend.h index f55298f78a..a504ded397 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -7045,7 +7045,7 @@ struct Scope final bool explicitVisibility(bool v); Previews previews; UserAttributeDeclaration* userAttribDecl; - DocComment* lastdc; + void* lastdc; void* anchorCounts; Identifier* prevAnchor; AliasDeclaration* aliasAsg; diff --git a/dmd/scope.h b/dmd/scope.h index 6c54319e20..94eeee803d 100644 --- a/dmd/scope.h +++ b/dmd/scope.h @@ -131,7 +131,7 @@ struct Scope final UserAttributeDeclaration *userAttribDecl; // user defined attributes - DocComment *lastdc; // documentation comment for last symbol at this scope + void *lastdc; // documentation comment for last symbol at this scope (DocComment*) AA *anchorCounts; // lookup duplicate anchor name count Identifier *prevAnchor; // qualified symbol name of last doc anchor From 5d8c1cea343dc0b30324f6ed57a18fe7665ca969 Mon Sep 17 00:00:00 2001 From: Mohamed El Shorbagy <59314933+elshorbagyx@users.noreply.github.com> Date: Tue, 13 Jan 2026 08:59:29 +0200 Subject: [PATCH 270/440] Break dependency of `dmodule` on `doc` (dlang/dmd!22389) --- dmd/dmodule.d | 12 +------ dmd/doc.d | 86 ++++++++++++++++++++++++++++---------------------- dmd/frontend.h | 6 ++-- dmd/module.h | 2 +- 4 files changed, 52 insertions(+), 54 deletions(-) diff --git a/dmd/dmodule.d b/dmd/dmodule.d index 4ddbe925ab..1baf39b075 100644 --- a/dmd/dmodule.d +++ b/dmd/dmodule.d @@ -26,7 +26,6 @@ import dmd.compiler; import dmd.cparse; import dmd.declaration; import dmd.dmacro; -import dmd.doc; import dmd.dsymbol; import dmd.errors; import dmd.expression; @@ -394,7 +393,7 @@ extern (C++) final class Module : Package Identifiers* versionidsNot; // forward referenced version identifiers MacroTable macrotable; // document comment macros - Escape* _escapetable; // document comment escapes + void* _escapetable; // document comment escapes (Escape*) size_t nameoffset; // offset of module name from start of ModuleInfo size_t namelen; // length of module name in characters @@ -1020,15 +1019,6 @@ extern (C++) final class Module : Package } } - /** Lazily initializes and returns the escape table. - Turns out it eats a lot of memory. - */ - extern(D) Escape* escapetable() nothrow - { - if (!_escapetable) - _escapetable = new Escape(); - return _escapetable; - } } /*********************************************************** diff --git a/dmd/doc.d b/dmd/doc.d index a8b0de3223..fe887f91d9 100644 --- a/dmd/doc.d +++ b/dmd/doc.d @@ -53,6 +53,7 @@ import dmd.root.utf; import dmd.tokens; import dmd.visitor; + /**************************************************** * Generate Ddoc text for Module `m` and append it to `outbuf`. * Params: @@ -212,44 +213,6 @@ void gendocfile(Module m, const char* ddoctext_ptr, size_t ddoctext_length, cons gendocfile(m, ddoctext_ptr[0 .. ddoctext_length], datetime, eSink, outbuf); } -public -struct Escape -{ - const(char)[][char.max] strings; - - /*************************************** - * Find character string to replace c with. - */ - const(char)[] escapeChar(char c) @safe - { - version (all) - { - //printf("escapeChar('%c') => %p, %p\n", c, strings, strings[c].ptr); - return strings[c]; - } - else - { - const(char)[] s; - switch (c) - { - case '<': - s = "<"; - break; - case '>': - s = ">"; - break; - case '&': - s = "&"; - break; - default: - s = null; - break; - } - return s; - } - } -} - /*********************************************************** */ public @@ -660,6 +623,53 @@ struct DocComment private: +/** Lazily initializes and returns the escape table. +Turns out it eats a lot of memory. +*/ +Escape* escapetable(Module _this) nothrow +{ + if (!_this._escapetable) + _this._escapetable = new Escape(); + return cast(Escape*) _this._escapetable; +} + +struct Escape +{ + const(char)[][char.max] strings; + + /*************************************** + * Find character string to replace c with. + */ + const(char)[] escapeChar(char c) @safe + { + version (all) + { + //printf("escapeChar('%c') => %p, %p\n", c, strings, strings[c].ptr); + return strings[c]; + } + else + { + const(char)[] s; + switch (c) + { + case '<': + s = "<"; + break; + case '>': + s = ">"; + break; + case '&': + s = "&"; + break; + default: + s = null; + break; + } + return s; + } + } +} + /*********************************************************** */ class Section diff --git a/dmd/frontend.h b/dmd/frontend.h index a504ded397..4baab543d1 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -123,14 +123,12 @@ struct IntRange; struct ModuleDeclaration; template struct FileMapping; -struct Escape; class LabelStatement; class SwitchStatement; class Statement; class TryFinallyStatement; class ScopeGuardStatement; class ErrorSink; -struct DocComment; class WithStatement; struct AA; class CaseStatement; @@ -6929,7 +6927,7 @@ class Module final : public Package Array* versionids; Array* versionidsNot; MacroTable macrotable; - Escape* _escapetable; + void* _escapetable; size_t nameoffset; size_t namelen; static Module* create(const char* filename, Identifier* ident, int32_t doDocComment, int32_t doHdrGen); @@ -7089,7 +7087,7 @@ struct Scope final argStruct() { } - Scope(Scope* enclosing, Module* _module = nullptr, ScopeDsymbol* scopesym = nullptr, FuncDeclaration* func = nullptr, VarDeclaration* varDecl = nullptr, Dsymbol* parent = nullptr, LabelStatement* slabel = nullptr, SwitchStatement* switchStatement = nullptr, Statement* tryBody = nullptr, TryFinallyStatement* tryFinally = nullptr, ScopeGuardStatement* scopeGuard = nullptr, Statement* sbreak = nullptr, Statement* scontinue = nullptr, ForeachStatement* fes = nullptr, Scope* callsc = nullptr, Dsymbol* inunion = nullptr, VarDeclaration* lastVar = nullptr, ErrorSink* eSink = nullptr, Module* minst = nullptr, TemplateInstance* tinst = nullptr, CtorFlow ctorflow = CtorFlow(), AlignDeclaration* aligndecl = nullptr, CPPNamespaceDeclaration* namespace_ = nullptr, LINK linkage = (LINK)1u, CPPMANGLE cppmangle = (CPPMANGLE)0u, PragmaDeclaration* inlining = nullptr, Visibility visibility = Visibility((Visibility::Kind)5u, nullptr), STC stc = (STC)0LLU, DeprecatedDeclaration* depdecl = nullptr, uint16_t bitFields = 0u, uint16_t bitFields2 = 0u, Previews previews = Previews(), UserAttributeDeclaration* userAttribDecl = nullptr, DocComment* lastdc = nullptr, void* anchorCounts = nullptr, Identifier* prevAnchor = nullptr, AliasDeclaration* aliasAsg = nullptr, StructDeclaration* argStruct = nullptr) : + Scope(Scope* enclosing, Module* _module = nullptr, ScopeDsymbol* scopesym = nullptr, FuncDeclaration* func = nullptr, VarDeclaration* varDecl = nullptr, Dsymbol* parent = nullptr, LabelStatement* slabel = nullptr, SwitchStatement* switchStatement = nullptr, Statement* tryBody = nullptr, TryFinallyStatement* tryFinally = nullptr, ScopeGuardStatement* scopeGuard = nullptr, Statement* sbreak = nullptr, Statement* scontinue = nullptr, ForeachStatement* fes = nullptr, Scope* callsc = nullptr, Dsymbol* inunion = nullptr, VarDeclaration* lastVar = nullptr, ErrorSink* eSink = nullptr, Module* minst = nullptr, TemplateInstance* tinst = nullptr, CtorFlow ctorflow = CtorFlow(), AlignDeclaration* aligndecl = nullptr, CPPNamespaceDeclaration* namespace_ = nullptr, LINK linkage = (LINK)1u, CPPMANGLE cppmangle = (CPPMANGLE)0u, PragmaDeclaration* inlining = nullptr, Visibility visibility = Visibility((Visibility::Kind)5u, nullptr), STC stc = (STC)0LLU, DeprecatedDeclaration* depdecl = nullptr, uint16_t bitFields = 0u, uint16_t bitFields2 = 0u, Previews previews = Previews(), UserAttributeDeclaration* userAttribDecl = nullptr, void* lastdc = nullptr, void* anchorCounts = nullptr, Identifier* prevAnchor = nullptr, AliasDeclaration* aliasAsg = nullptr, StructDeclaration* argStruct = nullptr) : enclosing(enclosing), _module(_module), scopesym(scopesym), diff --git a/dmd/module.h b/dmd/module.h index e23851acd5..7ed9819996 100644 --- a/dmd/module.h +++ b/dmd/module.h @@ -108,7 +108,7 @@ class Module final : public Package Identifiers *versionidsNot; // forward referenced version identifiers MacroTable macrotable; // document comment macros - Escape *escapetable; // document comment escapes + void *escapetable; // document comment escapes (Escape*) size_t nameoffset; // offset of module name from start of ModuleInfo size_t namelen; // length of module name in characters From 9866a9cf18d4393ac5cbce7a31749968b2578ecd Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Tue, 13 Jan 2026 23:32:39 +0100 Subject: [PATCH 271/440] fix dlang/dmd!22393 - bitfield .init value contains void elements (dlang/dmd!22395) --- dmd/typesem.d | 15 ++++++++++++--- tests/dmd/compilable/test22383.d | 12 ++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 tests/dmd/compilable/test22383.d diff --git a/dmd/typesem.d b/dmd/typesem.d index 22c997e0dc..110267cb7f 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -4919,7 +4919,7 @@ Expression defaultInitLiteral(Type t, Loc loc) return ErrorExp.get(); auto structelems = new Expressions(ts.sym.nonHiddenFields()); - uint offset = 0; + ulong bitoffset = 0; foreach (j; 0 .. structelems.length) { VarDeclaration vd = ts.sym.fields[j]; @@ -4929,7 +4929,11 @@ Expression defaultInitLiteral(Type t, Loc loc) error(loc, "circular reference to `%s`", vd.toPrettyChars()); return ErrorExp.get(); } - if (vd.offset < offset || vd.type.size() == 0) + ulong vbitoffset = vd.offset * 8; + auto vbf = vd.isBitFieldDeclaration(); + if (vbf) + vbitoffset += vbf.bitOffset; + if (vbitoffset < bitoffset || vd.type.size() == 0) e = null; else if (vd._init) { @@ -4943,7 +4947,12 @@ Expression defaultInitLiteral(Type t, Loc loc) if (e && e.op == EXP.error) return e; if (e) - offset = vd.offset + cast(uint)vd.type.size(); + { + if (vbf) + bitoffset = vbitoffset + vbf.fieldWidth; + else + bitoffset = vbitoffset + vd.type.size() * 8; + } (*structelems)[j] = e; } auto structinit = new StructLiteralExp(loc, ts.sym, structelems); diff --git a/tests/dmd/compilable/test22383.d b/tests/dmd/compilable/test22383.d new file mode 100644 index 0000000000..8106ab1839 --- /dev/null +++ b/tests/dmd/compilable/test22383.d @@ -0,0 +1,12 @@ +struct T22383 +{ + int a = 4; + int b : 16; + int c : 8; + int d : 4; + int e : 2; + int f : 1; + int g : 1; + int h = 8; +} +static assert(T22383.init == T22383(4,0,0,0,0,0,0,8)); From ee9e8e6a45da4753513c5331b124954b72c678da Mon Sep 17 00:00:00 2001 From: Madhur Kumar Date: Thu, 15 Jan 2026 02:49:27 +0530 Subject: [PATCH 272/440] Fix 22397 - Internal Error: array literal with UDA cause failure The 'checkGC' visitor was not traversing into declarations wrapped Signed-off-by attributes (UDA, align, extern etc.) causing two bugs: 1.Array literal in UDA-annotated variables were not lowered, leading two "Internal Error: array literal should have been lowered" crashes in the backend 2.@nogc safety check were silentrly skipped for such varirables, allowing GC allocation that should have been errors. Signed-off-by: Madhur Kumar --- dmd/nogc.d | 29 +++++++++++++++++++++----- tests/dmd/compilable/issue22397.d | 14 +++++++++++++ tests/dmd/fail_compilation/test22397.d | 16 ++++++++++++++ 3 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 tests/dmd/compilable/issue22397.d create mode 100644 tests/dmd/fail_compilation/test22397.d diff --git a/dmd/nogc.d b/dmd/nogc.d index 79098cae3f..c9b8a0275b 100644 --- a/dmd/nogc.d +++ b/dmd/nogc.d @@ -18,11 +18,12 @@ import core.stdc.stdio; import dmd.aggregate; import dmd.arraytypes; import dmd.astenums; +import dmd.attrib; import dmd.common.outbuffer; import dmd.declaration; import dmd.dmodule; import dmd.dscope; -import dmd.dsymbol : PASS; +import dmd.dsymbol : PASS, Dsymbol; import dmd.dtemplate : isDsymbol; import dmd.errors; import dmd.escape; @@ -76,14 +77,32 @@ public: override void visit(DeclarationExp e) { // Note that, walkPostorder does not support DeclarationExp today. - VarDeclaration v = e.declaration.isVarDeclaration(); - if (v && !(v.storage_class & STC.manifest) && !v.isDataseg() && v._init) + void visitDecl(Dsymbol d) { - if (ExpInitializer ei = v._init.isExpInitializer()) + if (VarDeclaration v = d.isVarDeclaration()) { - doCond(ei.exp); + if (!(v.storage_class & STC.manifest) && !v.isDataseg() && v._init && !v.isCsymbol()) + { + if (ExpInitializer ei = v._init.isExpInitializer()) + { + doCond(ei.exp); + } + } + } + else if (AttribDeclaration ad = d.isAttribDeclaration()) + { + // Don't recurse into anonymous declarations (unions/structs) + // as their members aren't meant to be processed here + if (ad.isAnonDeclaration()) + return; + if (ad.decl) + { + foreach (s; *ad.decl) + visitDecl(s); + } } } + visitDecl(e.declaration); } /** diff --git a/tests/dmd/compilable/issue22397.d b/tests/dmd/compilable/issue22397.d new file mode 100644 index 0000000000..5e2c54c6bf --- /dev/null +++ b/tests/dmd/compilable/issue22397.d @@ -0,0 +1,14 @@ +// REQUIRED_ARGS: +/* +TEST_OUTPUT: +--- +--- +*/ +void main() +{ + enum var = true; + @var string[] list = ["A", "B", "C"]; + + // Also test explicitly with @(value) syntax + @(1) int[] list2 = [1, 2, 3]; +} diff --git a/tests/dmd/fail_compilation/test22397.d b/tests/dmd/fail_compilation/test22397.d new file mode 100644 index 0000000000..a1a89799bf --- /dev/null +++ b/tests/dmd/fail_compilation/test22397.d @@ -0,0 +1,16 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/test22397.d(13): Error: this array literal causes a GC allocation in `@nogc` function `main` +fail_compilation/test22397.d(14): Error: this array literal causes a GC allocation in `@nogc` function `main` +fail_compilation/test22397.d(15): Error: this array literal causes a GC allocation in `@nogc` function `main` +--- +*/ + +// https://issues.dlang.org/show_bug.cgi?id=22397 +@nogc void main() +{ + @("uda") int[] a = [1, 2]; // should error + align(8) int[] b = [3, 4]; // should error + extern(C) int[] c = [5, 6]; // should error +} From 21fe24a3a809af0b3600d842dcd694b2aa1b6baf Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Thu, 15 Jan 2026 23:35:58 +0100 Subject: [PATCH 273/440] Fix source location of bitfield declarations (dlang/dmd!22402) --- dmd/dsymbolsem.d | 2 +- dmd/parse.d | 2 +- tests/dmd/fail_compilation/biterrors2.d | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index b9afe21268..57e36b663d 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -3195,7 +3195,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (!dsym.type.isIntegral()) { // C11 6.7.2.1-5 - error(width.loc, "bitfield type `%s` is not an integer type", dsym.type.toChars()); + error(dsym.loc, "bitfield type `%s` is not an integer type", dsym.type.toChars()); dsym.errors = true; } if (!width.isIntegerExp()) diff --git a/dmd/parse.d b/dmd/parse.d index ccc52f692b..31f7b900e4 100644 --- a/dmd/parse.d +++ b/dmd/parse.d @@ -4796,7 +4796,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer error("initializer not allowed for bitfield declaration"); if (storage_class) error("storage class not allowed for bitfield declaration"); - s = new AST.BitFieldDeclaration(width.loc, t, ident, width); + s = new AST.BitFieldDeclaration(loc, t, ident, width); } else { diff --git a/tests/dmd/fail_compilation/biterrors2.d b/tests/dmd/fail_compilation/biterrors2.d index 7c7de33946..56cb8cc5f4 100644 --- a/tests/dmd/fail_compilation/biterrors2.d +++ b/tests/dmd/fail_compilation/biterrors2.d @@ -1,9 +1,15 @@ -/* +/* REQUIRED_ARGS: -verrors=context * TEST_OUTPUT: --- fail_compilation/biterrors2.d(100): Error: variable `biterrors2.a` - bitfield must be member of struct, union, or class +int a : 2; + ^ fail_compilation/biterrors2.d(104): Error: bitfield `b` has zero width + int b:0; + ^ fail_compilation/biterrors2.d(105): Error: bitfield type `float` is not an integer type + float c:3; + ^ --- */ From 05d4fff7430ae5083f585321a0da68c0c207761a Mon Sep 17 00:00:00 2001 From: Iskaban10 <136351084+Iskaban10@users.noreply.github.com> Date: Fri, 16 Jan 2026 21:47:50 +0530 Subject: [PATCH 274/440] fix for wrong location for incompatible argument error (dlang/dmd!22370) --- dmd/expressionsem.d | 8 ++++---- dmd/funcsem.d | 8 ++++---- dmd/templatesem.d | 2 +- dmd/typesem.d | 12 ++++++++++-- tests/dmd/fail_compilation/diag21167.d | 21 +++++++++++++++++++++ tests/dmd/fail_compilation/test21634.d | 2 +- 6 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 tests/dmd/fail_compilation/diag21167.d diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index f5aeb61318..b1b4df4b43 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -8251,7 +8251,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor return setError(); } - void errorHelper(const(char)* failMessage) scope + void errorHelper(const(char)* failMessage, Loc argloc) scope { OutBuffer buf; buf.writeByte('('); @@ -8264,7 +8264,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor .error(exp.loc, "%s `%s` is not callable using argument types `%s`", p, exp.e1.toErrMsg(), buf.peekChars()); if (failMessage) - errorSupplemental(exp.loc, "%s", failMessage); + errorSupplemental((argloc !is Loc.initial) ? argloc : exp.loc, "%s", failMessage); } if (callMatch(exp.f, tf, null, exp.argumentList, 0, &errorHelper, sc) == MATCH.nomatch) @@ -8327,7 +8327,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor exp.f = exp.f.toAliasFunc(); TypeFunction tf = cast(TypeFunction)exp.f.type; - void errorHelper2(const(char)* failMessage) scope + void errorHelper2(const(char)* failMessage, Loc argloc) scope { OutBuffer buf; buf.writeByte('('); @@ -8345,7 +8345,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor .error(exp.loc, "%s `%s` is not callable using argument types `%s`", exp.f.kind(), exp.f.toErrMsg(), buf.peekChars()); if (failMessage) - errorSupplemental(exp.loc, "%s", failMessage); + errorSupplemental((argloc !is Loc.initial) ? argloc : exp.loc, "%s", failMessage); .errorSupplemental(exp.f.loc, "`%s%s` declared here", exp.f.toPrettyChars(), parametersTypeToChars(tf.parameterList)); exp.f = null; } diff --git a/dmd/funcsem.d b/dmd/funcsem.d index c077850f16..e725b6f6f4 100644 --- a/dmd/funcsem.d +++ b/dmd/funcsem.d @@ -2096,12 +2096,12 @@ FuncDeclaration resolveFuncCall(Loc loc, Scope* sc, Dsymbol s, } bool calledHelper; - void errorHelper(const(char)* failMessage) scope + void errorHelper(const(char)* failMessage, Loc argloc = Loc.initial) scope { .error(loc, "%s `%s%s%s` is not callable using argument types `%s`", fd.kind(), fd.toPrettyChars(), parametersTypeToChars(tf.parameterList), tf.modToChars(), fargsBuf.peekChars()); - errorSupplemental(loc, failMessage); + errorSupplemental((argloc !is Loc.initial) ? argloc : loc, failMessage); calledHelper = true; } @@ -2169,9 +2169,9 @@ FuncDeclaration resolveFuncCall(Loc loc, Scope* sc, Dsymbol s, } } - void errorHelper2(const(char)* failMessage) scope + void errorHelper2(const(char)* failMessage, Loc argloc = Loc.initial) scope { - errorSupplemental(loc, failMessage); + errorSupplemental((argloc !is Loc.initial) ? argloc : loc, failMessage); } functionResolve(m, orig_s, loc, sc, tiargs, tthis, argumentList, &errorHelper2); diff --git a/dmd/templatesem.d b/dmd/templatesem.d index 3144c2a139..d42a437637 100644 --- a/dmd/templatesem.d +++ b/dmd/templatesem.d @@ -5569,7 +5569,7 @@ bool TemplateInstance_semanticTiargs(Loc loc, Scope* sc, Objects* tiargs, int fl * errorHelper = delegate to send error message to if not null */ void functionResolve(ref MatchAccumulator m, Dsymbol dstart, Loc loc, Scope* sc, Objects* tiargs, - Type tthis, ArgumentList argumentList, void delegate(const(char)*) scope errorHelper = null) + Type tthis, ArgumentList argumentList, void delegate(const(char)*, Loc argloc = Loc.initial) scope errorHelper = null) { version (none) { diff --git a/dmd/typesem.d b/dmd/typesem.d index 110267cb7f..779e6bfd7f 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -2165,7 +2165,7 @@ extern(D) Expressions* resolveNamedArgs(TypeFunction tf, ArgumentList argumentLi * MATCHxxxx */ extern (D) MATCH callMatch(FuncDeclaration fd, TypeFunction tf, Type tthis, ArgumentList argumentList, - int flag = 0, void delegate(const(char)*) scope errorHelper = null, Scope* sc = null) + int flag = 0, void delegate(const(char)*, Loc argloc = Loc.initial) scope errorHelper = null, Scope* sc = null) { //printf("callMatch() fd: %s, tf: %s\n", fd ? fd.ident.toChars() : "null", toChars(tf)); MATCH match = MATCH.exact; // assume exact match @@ -2330,12 +2330,20 @@ extern (D) MATCH callMatch(FuncDeclaration fd, TypeFunction tf, Type tthis, Argu if (errorHelper) { if (u >= args.length) + { getMatchError(buf, "missing argument for parameter #%d: `%s`", u + 1, parameterToChars(p, tf, false)); + } // If an error happened previously, `pMessage` was already filled else if (buf.length == 0) + { buf.writestring(tf.getParamError(args[u], p)); - + if(args[u].loc !is Loc.initial) + { + errorHelper(buf.peekChars(),args[u].loc); + return MATCH.nomatch; + } + } errorHelper(buf.peekChars()); } return MATCH.nomatch; diff --git a/tests/dmd/fail_compilation/diag21167.d b/tests/dmd/fail_compilation/diag21167.d new file mode 100644 index 0000000000..f400a194e8 --- /dev/null +++ b/tests/dmd/fail_compilation/diag21167.d @@ -0,0 +1,21 @@ +/* +TEST_OUTPUT: +--- +fail_compilation\diag21167.d(15): Error: function `f` is not callable using argument types `(int, string, int)` +fail_compilation\diag21167.d(17): cannot pass argument `"foo"` of type `string` to parameter `int __param_1` +fail_compilation\diag21167.d(11): `diag21167.f(int __param_0, int __param_1, int __param_2)` declared here +--- +*/ +// https://github.com/dlang/dmd/issues/21167 + +void f(int, int, int){} + +void main() +{ + f( + 1, + "foo", + 3 + ); + +} diff --git a/tests/dmd/fail_compilation/test21634.d b/tests/dmd/fail_compilation/test21634.d index 2cf2a7b4ac..30bce99191 100644 --- a/tests/dmd/fail_compilation/test21634.d +++ b/tests/dmd/fail_compilation/test21634.d @@ -7,7 +7,7 @@ fail_compilation/test21634.d(22): Error: function literal `(int x) { }` is not c ^ fail_compilation/test21634.d(22): cannot pass argument `"%s"` of type `string` to parameter `int x` (int x) {} ("%s"); - ^ + ^ fail_compilation/test21634.d(24): Error: declaration `test21634.main.foo` is already defined int foo; ^ From 84970ec461a2969ec291a18e30cc10b2c3168d6c Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Fri, 16 Jan 2026 08:51:00 -0800 Subject: [PATCH 275/440] set WithArgTypes for AArch64 (dlang/dmd!22404) --- dmd/dsymbolsem.d | 4 ++-- dmd/target.d | 2 ++ runtime/druntime/src/object.d | 3 ++- tests/dmd/fail_compilation/fail_opover.d | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 57e36b663d..b91451e207 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -8398,8 +8398,8 @@ private extern(C++) class SetFieldOffsetVisitor : Visitor ad.structsize, ad.alignsize, isunion); - //printf("\t%s: memalignsize = %d\n", toChars(), memalignsize); - //printf(" addField '%s' to '%s' at offset %d, size = %d\n", toChars(), ad.toChars(), offset, memsize); + //printf("\t%s: memalignsize = %d\n", vd.toChars(), memalignsize); + //printf(" addField '%s' to '%s' at offset %d, size = %d\n", vd.toChars(), ad.toChars(), fieldState.offset, memsize); } override void visit(BitFieldDeclaration bfd) diff --git a/dmd/target.d b/dmd/target.d index c7cab55604..ead2c7d46f 100644 --- a/dmd/target.d +++ b/dmd/target.d @@ -457,6 +457,8 @@ extern (C++) struct Target if (isLP64 || isAArch64) { ptrsize = 8; + /* This is affected by version WithArgTypes in object.d + */ classinfosize = 0x98+16; // 168 } diff --git a/runtime/druntime/src/object.d b/runtime/druntime/src/object.d index 96fd06b59e..bb0c3d3c27 100644 --- a/runtime/druntime/src/object.d +++ b/runtime/druntime/src/object.d @@ -97,7 +97,8 @@ else version (X86_64) else version (AArch64) { // Apple uses a trivial varargs implementation - version (OSX) {} + version (DigitalMars) version = WithArgTypes; // is this needed? + else version (OSX) {} else version (iOS) {} else version (TVOS) {} else version (WatchOS) {} diff --git a/tests/dmd/fail_compilation/fail_opover.d b/tests/dmd/fail_compilation/fail_opover.d index 1a0c9e1ac1..a58b2bdd90 100644 --- a/tests/dmd/fail_compilation/fail_opover.d +++ b/tests/dmd/fail_compilation/fail_opover.d @@ -4,7 +4,7 @@ TEST_OUTPUT: --- fail_compilation/fail_opover.d(39): Error: no `[]` operator overload for type `object.Object` -$p:object.d$(110): perhaps define `auto opIndex() {}` for `object.Object` +$p:object.d$(111): perhaps define `auto opIndex() {}` for `object.Object` fail_compilation/fail_opover.d(43): Error: no `[]` operator overload for type `TestS` fail_compilation/fail_opover.d(41): perhaps define `auto opIndex() {}` for `fail_opover.test1.TestS` fail_compilation/fail_opover.d(55): Error: no `[]` operator overload for type `S` From 677f9caa3b16fbd7a3f9be0de341947ddeaee96c Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Mon, 19 Jan 2026 13:22:35 +0000 Subject: [PATCH 276/440] Assert when passing `noreturn` argument to function (dlang/dmd!22413) --- dmd/expression.d | 1 + dmd/expression.h | 1 + dmd/expressionsem.d | 8 +++++++- dmd/frontend.h | 1 + dmd/hdrgen.d | 3 +++ tests/dmd/runnable/noreturn2.d | 27 +++++++++++++++++---------- 6 files changed, 30 insertions(+), 11 deletions(-) diff --git a/dmd/expression.d b/dmd/expression.d index 98d1a8ee34..097769bb60 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -2137,6 +2137,7 @@ extern (C++) final class ImportExp : UnaExp extern (C++) final class AssertExp : UnaExp { Expression msg; + Expression loweredFrom; extern (D) this(Loc loc, Expression e, Expression msg = null) @safe { diff --git a/dmd/expression.h b/dmd/expression.h index d6577d6451..a8e1c9fb92 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -671,6 +671,7 @@ class AssertExp final : public UnaExp { public: Expression *msg; + Expression* loweredFrom; AssertExp *syntaxCopy() override; diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index b1b4df4b43..c7cfb4a7dd 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -2072,7 +2072,9 @@ Expression checkNoreturnVarAccess(Expression exp) { auto msg = new StringExp(exp.loc, "Accessed expression of type `noreturn`"); msg.type = Type.tstring; - result = new AssertExp(exp.loc, IntegerExp.literal!0, msg); + auto ae = new AssertExp(exp.loc, IntegerExp.literal!0, msg); + ae.loweredFrom = exp; + result = ae; result.type = exp.type; } @@ -4187,6 +4189,10 @@ private bool functionParameters(Loc loc, Scope* sc, arg = arg.resolveLoc(loc, sc); (*arguments)[i] = arg; } + else if (!(p.storageClass & (STC.ref_ | STC.out_))) + { + (*arguments)[i] = checkNoreturnVarAccess(arg); + } if (tf.parameterList.varargs == VarArg.typesafe && i + 1 == nparams) // https://dlang.org/spec/function.html#variadic { diff --git a/dmd/frontend.h b/dmd/frontend.h index 4baab543d1..a33c4de300 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2542,6 +2542,7 @@ class AssertExp final : public UnaExp { public: Expression* msg; + Expression* loweredFrom; AssertExp* syntaxCopy() override; void accept(Visitor* v) override; }; diff --git a/dmd/hdrgen.d b/dmd/hdrgen.d index a79822a43b..7b50af1685 100644 --- a/dmd/hdrgen.d +++ b/dmd/hdrgen.d @@ -2799,6 +2799,9 @@ private void expressionPrettyPrint(Expression e, ref OutBuffer buf, ref HdrGenSt void visitAssert(AssertExp e) { + if (e.loweredFrom) + return e.loweredFrom.expressionPrettyPrint(buf, hgs); + buf.put("assert("); expToBuffer(e.e1, PREC.assign, buf, hgs); if (e.msg) diff --git a/tests/dmd/runnable/noreturn2.d b/tests/dmd/runnable/noreturn2.d index 82f25f8e82..dea4e942ab 100644 --- a/tests/dmd/runnable/noreturn2.d +++ b/tests/dmd/runnable/noreturn2.d @@ -102,20 +102,16 @@ void testAccess() { enum msg = "Accessed expression of type `noreturn`"; - // FIXME: Another assertion failure in the backend trying to generate noreturn.sizeof = 0 byte assignment - version (FIXME) - testAssertFailure(__LINE__ + 3, msg, function noreturn() + testAssertFailure(__LINE__ + 3, msg, { noreturn a; noreturn b = a; }); - if (false) // read does not assert! - testAssertFailure(__LINE__ + 3, msg, function noreturn() + testAssertFailure(__LINE__ + 3, msg, { noreturn a; int b = a; - assert(false, "Unreachable!"); // Statement above not detected as noreturn }); testAssertFailure(__LINE__ + 2, msg, function noreturn() @@ -123,21 +119,21 @@ void testAccess() cast(noreturn) 1; }); - version (FIXME) - testAssertFailure(__LINE__ + 3, msg, function noreturn() + testAssertFailure(__LINE__ + 3, msg, { noreturn a; noreturn b = cast(noreturn) 1; }); - if (false) // Read does not assert testAssertFailure(__LINE__ + 3, msg, function noreturn() { noreturn a; return a; }); - if (false) // Read does not assert + // FIXME: assertion failure in the backend in paramsize() - noreturn.sizeof = 0 + // https://github.com/dlang/dmd/issues/20286 + version (FIXME) testAssertFailure(__LINE__ + 4, msg, function noreturn() { static void foo(noreturn) {} @@ -146,6 +142,17 @@ void testAccess() assert(false, "Unreachable!"); // Ditto }); + testAssertFailure(__LINE__ + 5, msg, + { + static fv(int) {} + static fr(ref noreturn a) + { + fv(a); // asserts + } + noreturn a; + fr(a); // OK, passes &a + }); + testAssertFailure(__LINE__ + 3, msg, { noreturn v; From 5987de51fa878bfdfffad436da8b334cb20d25fb Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Mon, 19 Jan 2026 22:59:14 +0000 Subject: [PATCH 277/440] Disallow discarding assignment to indexed array literal (dlang/dmd!22425) --- dmd/sideeffect.d | 17 ++++++++++++++ .../fail_compilation/array_literal_assign.d | 22 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/dmd/fail_compilation/array_literal_assign.d diff --git a/dmd/sideeffect.d b/dmd/sideeffect.d index 344ef05402..e7d54d917a 100644 --- a/dmd/sideeffect.d +++ b/dmd/sideeffect.d @@ -242,7 +242,24 @@ private bool lambdaHasSideEffect(Expression e, bool assumeImpureCalls = false) bool discardValue(Expression e) { if (lambdaHasSideEffect(e)) // check side-effect shallowly + { + // check for e.g. `arrayLiteral[index] = expr;` + if (e.isAssignExp() || e.isBinAssignExp() || e.isPostExp()) + { + Expression e1; + if (auto be = e.isBinExp()) // includes PostExp + e1 = be.e1; + else if (auto ce = e.isPreExp()) + e1 = ce.e1; + + if (auto ie = e1 ? e1.isIndexExp() : null) + { + if (ie.e1.isArrayLiteralExp()) + error(e.loc, "discarded assignment to indexed array literal"); + } + } return false; + } switch (e.op) { case EXP.cast_: diff --git a/tests/dmd/fail_compilation/array_literal_assign.d b/tests/dmd/fail_compilation/array_literal_assign.d new file mode 100644 index 0000000000..f10b5d63c1 --- /dev/null +++ b/tests/dmd/fail_compilation/array_literal_assign.d @@ -0,0 +1,22 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/array_literal_assign.d(13): Error: discarded assignment to indexed array literal +fail_compilation/array_literal_assign.d(15): Error: discarded assignment to indexed array literal +fail_compilation/array_literal_assign.d(16): Error: discarded assignment to indexed array literal +fail_compilation/array_literal_assign.d(17): Error: discarded assignment to indexed array literal +--- +*/ + +void main() +{ + [1, 2, 3][2] = 4; + enum e = [1, 2]; + e[0]++; + ++e[0]; + e[0] += 1; + + ref x = (e[0] = 4); // OK + x++; + assert(x == 5); +} From 731a1f68194f4e09d50e537aa56fe762ae51c539 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Tue, 20 Jan 2026 10:16:27 +0000 Subject: [PATCH 278/440] Revert "core.sys.posix: musl 32-bit ARM support (dlang/dmd!22278)" This reverts commit dfb4684fbb4e9a8acc3c63e9513433508da86ac6. --- .../druntime/src/core/sys/posix/sys/stat.d | 40 +++++++------------ .../druntime/src/core/sys/posix/sys/types.d | 26 +----------- 2 files changed, 16 insertions(+), 50 deletions(-) diff --git a/runtime/druntime/src/core/sys/posix/sys/stat.d b/runtime/druntime/src/core/sys/posix/sys/stat.d index 67d4e83f2a..762d6fcc76 100644 --- a/runtime/druntime/src/core/sys/posix/sys/stat.d +++ b/runtime/druntime/src/core/sys/posix/sys/stat.d @@ -653,41 +653,29 @@ version (linux) { version (CRuntime_Musl) { - // Matches struct stat from musl arch/arm/bits/stat.h - // See: https://git.musl-libc.org/cgit/musl/tree/arch/arm/bits/stat.h?h=v1.2.3 - // - // Type definitions from https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in?h=v1.2.3 - // with ARM-specific _Int64=long long and _Reg=int from - // https://git.musl-libc.org/cgit/musl/tree/arch/arm/bits/alltypes.h.in?h=v1.2.3#n3 - // - // Key 64-bit LFS types (always 64-bit on musl): - // dev_t = unsigned _Int64 = unsigned long long (line 31) - // off_t = _Int64 = long long (line 29) - // ino_t = unsigned _Int64 = unsigned long long (line 30) - // blkcnt_t = _Int64 = long long (line 33) - // blksize_t = long = long (32-bit) (line 32) - // nlink_t = unsigned _Reg = unsigned int (line 28) struct stat_t { - ulong st_dev; - int __st_dev_padding; - c_long __st_ino_truncated; + dev_t st_dev; + ushort __pad1; + c_long __st_ino; mode_t st_mode; - uint st_nlink; + nlink_t st_nlink; uid_t st_uid; gid_t st_gid; - ulong st_rdev; - int __st_rdev_padding; - long st_size; - c_long st_blksize; - long st_blocks; - struct __timespec32 + dev_t st_rdev; + ushort __pad2; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + private struct __timespec32 { c_long tv_sec; c_long tv_nsec; } - __timespec32 __st_atim32, __st_mtim32, __st_ctim32; - ulong st_ino; + __timespec32 __st_atim32; + __timespec32 __st_mtim32; + __timespec32 __st_ctim32; + ino_t st_ino; timespec st_atim; timespec st_mtim; timespec st_ctim; diff --git a/runtime/druntime/src/core/sys/posix/sys/types.d b/runtime/druntime/src/core/sys/posix/sys/types.d index b8a5868546..7c03b2949a 100644 --- a/runtime/druntime/src/core/sys/posix/sys/types.d +++ b/runtime/druntime/src/core/sys/posix/sys/types.d @@ -87,19 +87,7 @@ uid_t version (linux) { - // Musl always uses 64-bit off_t, blkcnt_t, ino_t on all arches (LFS by default). - // See: https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in?h=v1.2.3#n29 - // off_t: _Int64 -> long long (signed 64-bit) - // ino_t: unsigned _Int64 -> unsigned long long (64-bit) - // blkcnt_t: _Int64 -> long long (signed 64-bit) - // For ARM, _Int64 = long long: https://git.musl-libc.org/cgit/musl/tree/arch/arm/bits/alltypes.h.in?h=v1.2.3#n3 - version (CRuntime_Musl) - { - alias long blkcnt_t; - alias ulong ino_t; - alias long off_t; - } - else static if ( __USE_FILE_OFFSET64 ) + static if ( __USE_FILE_OFFSET64 ) { alias long blkcnt_t; alias ulong ino_t; @@ -360,17 +348,7 @@ useconds_t version (linux) { - // Musl always uses 64-bit fsblkcnt_t, fsfilcnt_t on all arches (LFS by default). - // See: https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in?h=v1.2.3#n34 - // fsblkcnt_t: unsigned _Int64 -> unsigned long long (64-bit) - // fsfilcnt_t: unsigned _Int64 -> unsigned long long (64-bit) - // For ARM, _Int64 = long long: https://git.musl-libc.org/cgit/musl/tree/arch/arm/bits/alltypes.h.in?h=v1.2.3#n3 - version (CRuntime_Musl) - { - alias ulong fsblkcnt_t; - alias ulong fsfilcnt_t; - } - else static if ( __USE_FILE_OFFSET64 ) + static if ( __USE_FILE_OFFSET64 ) { alias ulong fsblkcnt_t; alias ulong fsfilcnt_t; From 16e69aa6404ef28088fdb7a347f0cc1891a8bd3e Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Tue, 20 Jan 2026 10:16:39 +0000 Subject: [PATCH 279/440] core.sys.posix.sys.stat: Fix musl ARM stat_t to match musl source --- runtime/druntime/src/core/sys/posix/sys/stat.d | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime/druntime/src/core/sys/posix/sys/stat.d b/runtime/druntime/src/core/sys/posix/sys/stat.d index 762d6fcc76..7493b64486 100644 --- a/runtime/druntime/src/core/sys/posix/sys/stat.d +++ b/runtime/druntime/src/core/sys/posix/sys/stat.d @@ -653,17 +653,19 @@ version (linux) { version (CRuntime_Musl) { + // Matches struct stat from musl arch/arm/bits/stat.h + // See: https://git.musl-libc.org/cgit/musl/tree/arch/arm/bits/stat.h?h=v1.2.3 struct stat_t { dev_t st_dev; - ushort __pad1; - c_long __st_ino; + int __st_dev_padding; + c_long __st_ino_truncated; mode_t st_mode; nlink_t st_nlink; uid_t st_uid; gid_t st_gid; dev_t st_rdev; - ushort __pad2; + int __st_rdev_padding; off_t st_size; blksize_t st_blksize; blkcnt_t st_blocks; From 149c5508ca93dfad4b9bcc69c24d5763365e652e Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Mon, 19 Jan 2026 18:59:56 -0800 Subject: [PATCH 280/440] fix kludge regarding 0 sized structs on parameter stack --- dmd/dsymbolsem.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index b91451e207..8725002411 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -9921,7 +9921,7 @@ private extern(C++) class FinalizeSizeVisitor : Visitor override void visit(StructDeclaration sd) { - //printf("StructDeclaration::finalizeSize() %s, sizeok = %d\n", toChars(), sizeok); + //printf("StructDeclaration::finalizeSize() %s, sizeok = %d\n", sd.toChars(), sd.sizeok); assert(sd.sizeok != Sizeok.done); if (sd.sizeok == Sizeok.inProcess) From 6d6eb36459c5236d79b54058d0d2dd67ca413a38 Mon Sep 17 00:00:00 2001 From: Madhur Kumar <152476790+MadhurKumar004@users.noreply.github.com> Date: Wed, 21 Jan 2026 15:55:17 +0530 Subject: [PATCH 281/440] fix kludge regarding 0 sized structs on parameter stack (dlang/dmd!22396) --- dmd/declaration.d | 6 ++-- dmd/dsymbolsem.d | 6 ++++ dmd/parse.d | 4 +-- dmd/semantic2.d | 36 +++++++++++++++++++ tests/dmd/fail_compilation/biterrors.d | 1 - tests/dmd/fail_compilation/fail22384.d | 47 ++++++++++++++++++++++++ tests/dmd/runnable/test22384.d | 49 ++++++++++++++++++++++++++ 7 files changed, 142 insertions(+), 7 deletions(-) create mode 100644 tests/dmd/fail_compilation/fail22384.d create mode 100644 tests/dmd/runnable/test22384.d diff --git a/dmd/declaration.d b/dmd/declaration.d index 537e51e9a6..f937980051 100644 --- a/dmd/declaration.d +++ b/dmd/declaration.d @@ -663,9 +663,9 @@ extern (C++) class BitFieldDeclaration : VarDeclaration uint fieldWidth; uint bitOffset; - final extern (D) this(Loc loc, Type type, Identifier ident, Expression width) + final extern (D) this(Loc loc, Type type, Identifier ident, Expression width, Initializer _init = null) { - super(loc, type, ident, null); + super(loc, type, ident, _init); this.dsym = DSYM.bitFieldDeclaration; this.width = width; this.storage_class |= STC.field; @@ -675,7 +675,7 @@ extern (C++) class BitFieldDeclaration : VarDeclaration { //printf("BitFieldDeclaration::syntaxCopy(%s)\n", toChars()); assert(!s); - auto bf = new BitFieldDeclaration(loc, type ? type.syntaxCopy() : null, ident, width.syntaxCopy()); + auto bf = new BitFieldDeclaration(loc, type ? type.syntaxCopy() : null, ident, width.syntaxCopy(), _init ? _init.syntaxCopy() : null); bf.comment = comment; return bf; } diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 8725002411..ad5b58442d 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -3174,6 +3174,12 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (dsym.semanticRun >= PASS.semanticdone) return; + if (dsym.isAnonymous() && dsym._init) + { + .error(dsym.loc, "anonymous bitfield cannot have default initializer"); + dsym._init = null; + } + visit(cast(VarDeclaration)dsym); if (dsym.errors) return; diff --git a/dmd/parse.d b/dmd/parse.d index 31f7b900e4..499fa1d651 100644 --- a/dmd/parse.d +++ b/dmd/parse.d @@ -4792,11 +4792,9 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer AST.Dsymbol s; if (width) { - if (_init) - error("initializer not allowed for bitfield declaration"); if (storage_class) error("storage class not allowed for bitfield declaration"); - s = new AST.BitFieldDeclaration(loc, t, ident, width); + s = new AST.BitFieldDeclaration(loc, t, ident, width, _init); } else { diff --git a/dmd/semantic2.d b/dmd/semantic2.d index 2a42668cf5..64244b6228 100644 --- a/dmd/semantic2.d +++ b/dmd/semantic2.d @@ -320,6 +320,42 @@ private extern(C++) final class Semantic2Visitor : Visitor vd.semanticRun = PASS.semantic2done; } + override void visit(BitFieldDeclaration bfd) + { + visit(cast(VarDeclaration)bfd); + if (bfd.semanticRun != PASS.semantic2done) + return; + + if (bfd.fieldWidth == 0) + return; + + if (!bfd._init) + return; + + auto ei = bfd._init.isExpInitializer(); + if (!ei) + return; + + if (!ei.exp.isIntegerExp()) + return; + + import dmd.intrange; + auto value = getIntRange(ei.exp); + + const bool isUnsigned = bfd.type.isUnsigned(); + auto bounds = IntRange( + SignExtendedNumber(bfd.getMinMax(Id.min), !isUnsigned), + SignExtendedNumber(bfd.getMinMax(Id.max), false) + ); + + if (!bounds.contains(value)) + { + const uwidth = bfd.fieldWidth; + error(ei.loc, "bitfield initializer `%s` does not fit in %d bit%s", + ei.exp.toChars(), cast(int) uwidth, uwidth == 1 ? "".ptr : "s".ptr); + } + } + override void visit(Module mod) { //printf("Module::semantic2('%s'): parent = %p\n", toChars(), parent); diff --git a/tests/dmd/fail_compilation/biterrors.d b/tests/dmd/fail_compilation/biterrors.d index e14001b1b9..91a067295a 100644 --- a/tests/dmd/fail_compilation/biterrors.d +++ b/tests/dmd/fail_compilation/biterrors.d @@ -1,7 +1,6 @@ /* * TEST_OUTPUT: --- -fail_compilation/biterrors.d(103): Error: initializer not allowed for bitfield declaration fail_compilation/biterrors.d(104): Error: storage class not allowed for bitfield declaration --- */ diff --git a/tests/dmd/fail_compilation/fail22384.d b/tests/dmd/fail_compilation/fail22384.d new file mode 100644 index 0000000000..898aef59b3 --- /dev/null +++ b/tests/dmd/fail_compilation/fail22384.d @@ -0,0 +1,47 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/fail22384.d(32): Error: bitfield `z` has zero width +fail_compilation/fail22384.d(36): Error: bitfield type `float` is not an integer type +fail_compilation/fail22384.d(36): Error: bitfield `f` has zero width +fail_compilation/fail22384.d(37): Error: bitfield type `float` is not an integer type +fail_compilation/fail22384.d(38): Error: bitfield type `float` is not an integer type +fail_compilation/fail22384.d(39): Error: bitfield type `float` is not an integer type +fail_compilation/fail22384.d(44): Error: anonymous bitfield cannot have default initializer +fail_compilation/fail22384.d(21): Error: bitfield initializer `4294967295u` does not fit in 4 bits +fail_compilation/fail22384.d(26): Error: bitfield initializer `E.B` does not fit in 2 bits +fail_compilation/fail22384.d(30): Error: bitfield initializer `4` does not fit in 3 bits +fail_compilation/fail22384.d(31): Error: bitfield initializer `65` does not fit in 7 bits +fail_compilation/fail22384.d(43): Error: cannot implicitly convert expression `4.2F` of type `float` to `int` +fail_compilation/fail22384.d(45): Error: bitfield initializer `65` does not fit in 7 bits +fail_compilation/fail22384.d(46): Error: cannot implicitly convert expression `42` of type `int` to `bool` +--- +*/ +struct S { + uint d : 4 = -1; +} + +enum E : int { A = 1, B = 2 } +struct EFail { + E b : 2 = E.B; +} + +struct IFail { + int x : 3 = 4; + int y : 7 = 65; + int z : 0 = 1; +} + +struct FloatFail { + float f : 0; + float f2 : 7; + float f3 : 7 = 4; + float f4 : 7 = 4.2f; +} + +struct InitFail { + int i : 7 = 4.2f; + ubyte : 8 = 4.2f; + int j : 7 = 'A'; + bool b : 7 = 42; +} diff --git a/tests/dmd/runnable/test22384.d b/tests/dmd/runnable/test22384.d new file mode 100644 index 0000000000..9a48263e38 --- /dev/null +++ b/tests/dmd/runnable/test22384.d @@ -0,0 +1,49 @@ +//https://github.com/dlang/dmd/issues/22384 +struct S +{ + int a = 1; + int b : 16 = 2; + int c : 16 = 3; + int d = 4; +} + +struct T +{ + int a = 1; // .long 1 + int b : 4 = 2; // .byte 0x32 (b=2, c=3 merged) + int c : 4 = 3; + int d : 8 = 4; // .byte 0x04 + int e : 4 = 5; // .byte 0x65 (e=5, f_low=6 merged) + int f : 12 = 6; // .byte 0x00 (f_high) + int g = 7; // .long 7 +} + +struct M +{ + int a : 4 = 1; + int : 4; + int b : 4 = 2; +} + +S s; +T t; +M m; + +void main() +{ + assert(s.a == 1); + assert(s.b == 2); + assert(s.c == 3); + assert(s.d == 4); + + assert(t.a == 1); + assert(t.b == 2); + assert(t.c == 3); + assert(t.d == 4); + assert(t.e == 5); + assert(t.f == 6); + assert(t.g == 7); + + assert(m.a == 1); + assert(m.b == 2); +} From 8f2e789e1f87946b68cf1303c15673b159531c0e Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Thu, 22 Jan 2026 01:28:25 +1300 Subject: [PATCH 282/440] Implement null dereference check (dlang/dmd!22040) --- dmd/cli.d | 1 + dmd/dfa/fast/report.d | 4 +- dmd/dfa/fast/statement.d | 5 +- dmd/frontend.h | 5 +- dmd/funcsem.d | 35 +++++++- dmd/globals.d | 1 + dmd/globals.h | 1 + dmd/main.d | 6 ++ dmd/mars.d | 7 +- runtime/druntime/src/core/exception.d | 82 +++++++++++++++++++ runtime/druntime/src/etc/linux/memoryerror.d | 68 +-------------- runtime/druntime/test/exceptions/Makefile | 7 +- .../src/linux_memory_error_handler.d | 43 ++++++++++ tests/dmd/dshell/cpp_header_gen.d | 3 +- tests/dmd/runnable/cdvecfill.sh | 6 +- tests/dmd/runnable/gdb22590.c | 2 +- tests/dmd/runnable/minimal2.d | 2 +- tests/dmd/runnable/nullderefcheck.d | 52 ++++++++++++ 18 files changed, 246 insertions(+), 84 deletions(-) create mode 100644 runtime/druntime/test/exceptions/src/linux_memory_error_handler.d create mode 100644 tests/dmd/runnable/nullderefcheck.d diff --git a/dmd/cli.d b/dmd/cli.d index 1a8e00876a..558f186890 100644 --- a/dmd/cli.d +++ b/dmd/cli.d @@ -1187,6 +1187,7 @@ struct CLIUsage =invariant[=[on|off]] Class/struct invariants =out[=[on|off]] Out contracts =switch[=[on|off]] Final switch failure checking + =nullderef[=[on|off]] Null dereference error =on Enable all assertion checking (default for non-release builds) =off Disable all assertion checking diff --git a/dmd/dfa/fast/report.d b/dmd/dfa/fast/report.d index cb26fdd2ec..be0cc4cd40 100644 --- a/dmd/dfa/fast/report.d +++ b/dmd/dfa/fast/report.d @@ -71,7 +71,7 @@ struct DFAReporter } } - void onLoopyLabelLessNullThan(DFAVar* var, ref const(Loc) loc) + void onLoopyLabelLessNullThan(DFAVar* var, ref const Loc loc) { if (var !is null && !var.isModellable) return; @@ -88,7 +88,7 @@ struct DFAReporter * to guarantee a non-null output, this ensures the variable is actually non-null * when the scope exits. */ - void onEndOfScope(FuncDeclaration fd, ref Loc loc) + void onEndOfScope(FuncDeclaration fd, ref const Loc loc) { // this is where we validate escapes, for a specific location diff --git a/dmd/dfa/fast/statement.d b/dmd/dfa/fast/statement.d index 114015f840..6163b5c681 100644 --- a/dmd/dfa/fast/statement.d +++ b/dmd/dfa/fast/statement.d @@ -603,7 +603,7 @@ final: // This signals that no code after this point in the current block is reachable. dfaCommon.currentDFAScope.haveJumped = true; dfaCommon.currentDFAScope.haveReturned = true; - analyzer.reporter.onEndOfScope(dfaCommon.currentFunction, exp.loc); + analyzer.reporter.onEndOfScope(dfaCommon.currentFunction, st.loc); break; case STMT.Compound: @@ -895,6 +895,7 @@ final: dfaCommon.currentDFAScope.inConditional = true; dfaCommon.setScopeAsLoopyLabel; + if (theCondition !is null) { dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) => ob.writestring("For condition:\n")); @@ -909,6 +910,8 @@ final: expWalker.seeAssert(lrCondition, theCondition.loc, true); } + else + dfaCommon.currentDFAScope.isLoopyLabelKnownToHaveRun = true; dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) => ob.writestring("For body:\n")); diff --git a/dmd/frontend.h b/dmd/frontend.h index a33c4de300..17cd86e1c7 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -8210,6 +8210,7 @@ struct Param final CHECKENABLE useIn; CHECKENABLE useOut; CHECKENABLE useArrayBounds; + CHECKENABLE useNullCheck; CHECKENABLE useAssert; CHECKENABLE useSwitchError; CHECKENABLE boundscheck; @@ -8293,6 +8294,7 @@ struct Param final useIn((CHECKENABLE)0u), useOut((CHECKENABLE)0u), useArrayBounds((CHECKENABLE)0u), + useNullCheck((CHECKENABLE)0u), useAssert((CHECKENABLE)0u), useSwitchError((CHECKENABLE)0u), boundscheck((CHECKENABLE)0u), @@ -8333,7 +8335,7 @@ struct Param final timeTraceFile() { } - Param(bool obj, bool readStdin = false, bool multiobj = false, bool trace = false, bool tracegc = false, bool vcg_ast = false, DiagnosticReporting useDeprecated = (DiagnosticReporting)1u, bool useUnitTests = false, bool useInline = false, bool release = false, bool preservePaths = false, DiagnosticReporting useWarnings = (DiagnosticReporting)2u, bool cov = false, uint8_t covPercent = 0u, bool ctfe_cov = false, bool ignoreUnsupportedPragmas = true, bool useModuleInfo = true, bool useTypeInfo = true, bool useExceptions = true, bool useGC = true, bool betterC = false, bool addMain = false, bool allInst = false, bool bitfields = true, bool rewriteNoExceptionToSeq = false, CppStdRevision cplusplus = (CppStdRevision)201103u, Help help = Help(), Verbose v = Verbose(), Edition edition = (Edition)2023u, void* editionFiles = nullptr, FeatureState useDIP25 = (FeatureState)2u, FeatureState useDIP1000 = (FeatureState)0u, bool ehnogc = false, bool useDIP1021 = false, FeatureState fieldwise = (FeatureState)0u, bool fixAliasThis = false, FeatureState rvalueRefParam = (FeatureState)0u, FeatureState safer = (FeatureState)0u, FeatureState noSharedAccess = (FeatureState)0u, bool previewIn = false, bool inclusiveInContracts = false, bool shortenedMethods = true, bool fixImmutableConv = false, bool fix16997 = true, FeatureState dtorFields = (FeatureState)0u, FeatureState systemVariables = (FeatureState)0u, bool useFastDFA = false, CHECKENABLE useInvariants = (CHECKENABLE)0u, CHECKENABLE useIn = (CHECKENABLE)0u, CHECKENABLE useOut = (CHECKENABLE)0u, CHECKENABLE useArrayBounds = (CHECKENABLE)0u, CHECKENABLE useAssert = (CHECKENABLE)0u, CHECKENABLE useSwitchError = (CHECKENABLE)0u, CHECKENABLE boundscheck = (CHECKENABLE)0u, CHECKACTION checkAction = (CHECKACTION)0u, CLIIdentifierTable dIdentifierTable = (CLIIdentifierTable)0u, CLIIdentifierTable cIdentifierTable = (CLIIdentifierTable)0u, _d_dynamicArray< const char > argv0 = {}, Array modFileAliasStrings = Array(), Array imppath = Array(), Array fileImppath = Array(), _d_dynamicArray< const char > objdir = {}, _d_dynamicArray< const char > objname = {}, _d_dynamicArray< const char > libname = {}, Output ddoc = Output(), Output dihdr = Output(), Output cxxhdr = Output(), Output json = Output(), JsonFieldFlags jsonFieldFlags = (JsonFieldFlags)0u, Output makeDeps = Output(), Output mixinOut = Output(), Output moduleDeps = Output(), bool debugEnabled = false, bool run = false, Array runargs = Array(), Array cppswitches = Array(), const char* cpp = nullptr, Array objfiles = Array(), Array linkswitches = Array(), Array linkswitchIsForCC = Array(), Array libfiles = Array(), Array dllfiles = Array(), _d_dynamicArray< const char > deffile = {}, _d_dynamicArray< const char > resfile = {}, _d_dynamicArray< const char > exefile = {}, _d_dynamicArray< const char > mapfile = {}, bool fullyQualifiedObjectFiles = false, bool timeTrace = false, uint32_t timeTraceGranularityUs = 500u, const char* timeTraceFile = nullptr) : + Param(bool obj, bool readStdin = false, bool multiobj = false, bool trace = false, bool tracegc = false, bool vcg_ast = false, DiagnosticReporting useDeprecated = (DiagnosticReporting)1u, bool useUnitTests = false, bool useInline = false, bool release = false, bool preservePaths = false, DiagnosticReporting useWarnings = (DiagnosticReporting)2u, bool cov = false, uint8_t covPercent = 0u, bool ctfe_cov = false, bool ignoreUnsupportedPragmas = true, bool useModuleInfo = true, bool useTypeInfo = true, bool useExceptions = true, bool useGC = true, bool betterC = false, bool addMain = false, bool allInst = false, bool bitfields = true, bool rewriteNoExceptionToSeq = false, CppStdRevision cplusplus = (CppStdRevision)201103u, Help help = Help(), Verbose v = Verbose(), Edition edition = (Edition)2023u, void* editionFiles = nullptr, FeatureState useDIP25 = (FeatureState)2u, FeatureState useDIP1000 = (FeatureState)0u, bool ehnogc = false, bool useDIP1021 = false, FeatureState fieldwise = (FeatureState)0u, bool fixAliasThis = false, FeatureState rvalueRefParam = (FeatureState)0u, FeatureState safer = (FeatureState)0u, FeatureState noSharedAccess = (FeatureState)0u, bool previewIn = false, bool inclusiveInContracts = false, bool shortenedMethods = true, bool fixImmutableConv = false, bool fix16997 = true, FeatureState dtorFields = (FeatureState)0u, FeatureState systemVariables = (FeatureState)0u, bool useFastDFA = false, CHECKENABLE useInvariants = (CHECKENABLE)0u, CHECKENABLE useIn = (CHECKENABLE)0u, CHECKENABLE useOut = (CHECKENABLE)0u, CHECKENABLE useArrayBounds = (CHECKENABLE)0u, CHECKENABLE useNullCheck = (CHECKENABLE)0u, CHECKENABLE useAssert = (CHECKENABLE)0u, CHECKENABLE useSwitchError = (CHECKENABLE)0u, CHECKENABLE boundscheck = (CHECKENABLE)0u, CHECKACTION checkAction = (CHECKACTION)0u, CLIIdentifierTable dIdentifierTable = (CLIIdentifierTable)0u, CLIIdentifierTable cIdentifierTable = (CLIIdentifierTable)0u, _d_dynamicArray< const char > argv0 = {}, Array modFileAliasStrings = Array(), Array imppath = Array(), Array fileImppath = Array(), _d_dynamicArray< const char > objdir = {}, _d_dynamicArray< const char > objname = {}, _d_dynamicArray< const char > libname = {}, Output ddoc = Output(), Output dihdr = Output(), Output cxxhdr = Output(), Output json = Output(), JsonFieldFlags jsonFieldFlags = (JsonFieldFlags)0u, Output makeDeps = Output(), Output mixinOut = Output(), Output moduleDeps = Output(), bool debugEnabled = false, bool run = false, Array runargs = Array(), Array cppswitches = Array(), const char* cpp = nullptr, Array objfiles = Array(), Array linkswitches = Array(), Array linkswitchIsForCC = Array(), Array libfiles = Array(), Array dllfiles = Array(), _d_dynamicArray< const char > deffile = {}, _d_dynamicArray< const char > resfile = {}, _d_dynamicArray< const char > exefile = {}, _d_dynamicArray< const char > mapfile = {}, bool fullyQualifiedObjectFiles = false, bool timeTrace = false, uint32_t timeTraceGranularityUs = 500u, const char* timeTraceFile = nullptr) : obj(obj), readStdin(readStdin), multiobj(multiobj), @@ -8385,6 +8387,7 @@ struct Param final useIn(useIn), useOut(useOut), useArrayBounds(useArrayBounds), + useNullCheck(useNullCheck), useAssert(useAssert), useSwitchError(useSwitchError), boundscheck(boundscheck), diff --git a/dmd/funcsem.d b/dmd/funcsem.d index e725b6f6f4..e153e11067 100644 --- a/dmd/funcsem.d +++ b/dmd/funcsem.d @@ -4282,16 +4282,43 @@ bool arrayBoundsCheck(FuncDeclaration fd) case CHECKENABLE.on: return true; case CHECKENABLE.safeonly: + if (fd) { + Type t = fd.type; + if (t.isTypeFunction() && t.isTypeFunction().trust == TRUST.safe) + return true; + } + return false; + case CHECKENABLE._default: + assert(0); + } +} + +/********************** + * Check to see if null dereference checking code has to be generated + * + * Params: + * fd = function for which code is to be generated + * Returns: + * true if do null dereference checking for the given function + */ +bool nullDerefCheck(FuncDeclaration fd) +{ + final switch (global.params.useNullCheck) + { + case CHECKENABLE.off: + return false; + case CHECKENABLE.on: + return true; + case CHECKENABLE.safeonly: if (fd) { Type t = fd.type; - if (t.ty == Tfunction && (cast(TypeFunction)t).trust == TRUST.safe) + if (t.isTypeFunction() && t.isTypeFunction().trust == TRUST.safe) return true; } return false; - } - case CHECKENABLE._default: - assert(0); + case CHECKENABLE._default: + assert(0); } } diff --git a/dmd/globals.d b/dmd/globals.d index e1d74cf5cd..a7c9472597 100644 --- a/dmd/globals.d +++ b/dmd/globals.d @@ -224,6 +224,7 @@ extern (C++) struct Param CHECKENABLE useIn = CHECKENABLE._default; // generate precondition checks CHECKENABLE useOut = CHECKENABLE._default; // generate postcondition checks CHECKENABLE useArrayBounds = CHECKENABLE._default; // when to generate code for array bounds checks + CHECKENABLE useNullCheck = CHECKENABLE._default; // when to generate code for null dereference checks CHECKENABLE useAssert = CHECKENABLE._default; // when to generate code for assert()'s CHECKENABLE useSwitchError = CHECKENABLE._default; // check for switches without a default CHECKENABLE boundscheck = CHECKENABLE._default; // state of -boundscheck switch diff --git a/dmd/globals.h b/dmd/globals.h index e06c9bf7ad..40894f256a 100644 --- a/dmd/globals.h +++ b/dmd/globals.h @@ -245,6 +245,7 @@ struct Param CHECKENABLE useIn; // generate precondition checks CHECKENABLE useOut; // generate postcondition checks CHECKENABLE useArrayBounds; // when to generate code for array bounds checks + CHECKENABLE useNullCheck; // when to generate code for null dereference checks CHECKENABLE useAssert; // when to generate code for assert()'s CHECKENABLE useSwitchError; // check for switches without a default CHECKENABLE boundscheck; // state of -boundscheck switch diff --git a/dmd/main.d b/dmd/main.d index 7bb3a150df..7d6b4ff7aa 100644 --- a/dmd/main.d +++ b/dmd/main.d @@ -1101,6 +1101,9 @@ void reconcileCommands(ref Param params, ref Target target) if (params.useSwitchError == CHECKENABLE._default) params.useSwitchError = CHECKENABLE.off; + + if (params.useNullCheck == CHECKENABLE._default) + params.useNullCheck = CHECKENABLE.off; } else { @@ -1121,6 +1124,9 @@ void reconcileCommands(ref Param params, ref Target target) if (params.useSwitchError == CHECKENABLE._default) params.useSwitchError = CHECKENABLE.on; + + if (params.useNullCheck == CHECKENABLE._default) + params.useNullCheck = CHECKENABLE.off; } if (params.betterC) diff --git a/dmd/mars.d b/dmd/mars.d index 9a1aa7dd12..ad7ce89869 100644 --- a/dmd/mars.d +++ b/dmd/mars.d @@ -739,7 +739,7 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, out Param mixin(checkOptionsMixin("check", "`-check=` requires an action")); /* Parse: - * -check=[assert|bounds|in|invariant|out|switch][=[on|off]] + * -check=[assert|bounds|in|invariant|out|switch|nullderef][=[on|off]] */ // Check for legal option string; return true if so @@ -774,6 +774,7 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, out Param params.useInvariants = CHECKENABLE.on; params.useOut = CHECKENABLE.on; params.useSwitchError = CHECKENABLE.on; + params.useNullCheck = CHECKENABLE.on; } else if (checkarg == "off") { @@ -783,13 +784,15 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, out Param params.useInvariants = CHECKENABLE.off; params.useOut = CHECKENABLE.off; params.useSwitchError = CHECKENABLE.off; + params.useNullCheck = CHECKENABLE.off; } else if (!(check(checkarg, "assert", params.useAssert) || check(checkarg, "bounds", params.useArrayBounds) || check(checkarg, "in", params.useIn ) || check(checkarg, "invariant", params.useInvariants ) || check(checkarg, "out", params.useOut ) || - check(checkarg, "switch", params.useSwitchError))) + check(checkarg, "switch", params.useSwitchError) || + check(checkarg, "nullderef", params.useNullCheck))) { errorInvalidSwitch(p); params.help.check = true; diff --git a/runtime/druntime/src/core/exception.d b/runtime/druntime/src/core/exception.d index e1b69583e0..cf9289c292 100644 --- a/runtime/druntime/src/core/exception.d +++ b/runtime/druntime/src/core/exception.d @@ -275,6 +275,49 @@ unittest } } +/** + * When an unmapped pointer is accessed this may be thrown via a signal handler. + */ +class InvalidPointerError : Error +{ + @safe pure nothrow @nogc this(string file, size_t line) + { + this(file, line, cast(Throwable)null); + } + + @safe pure nothrow @nogc this(string file = __FILE__, size_t line = __LINE__, Throwable next = null) + { + this("Invalid pointer access", file, line, next); + } + + @safe pure nothrow @nogc this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null) + { + super(msg, file, line, next); + } +} + +/** + * Thrown when a null dereference may occur. + * + * Depends upon null dereference check, or a signal handler to throw. + */ +class NullPointerError : InvalidPointerError +{ + @safe pure nothrow @nogc this(string file, size_t line) + { + this(file, line, cast(Throwable)null); + } + + @safe pure nothrow @nogc this(string file = __FILE__, size_t line = __LINE__, Throwable next = null) + { + this("Null pointer dereference", file, line, next); + } + + @safe pure nothrow @nogc this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null) + { + super(msg, file, line, next); + } +} /** * Thrown on finalize error. @@ -532,6 +575,7 @@ private __gshared { AssertHandler _assertHandler = null; FilterThreadThrowableHandler _filterThreadThrowableHandler = null; + NullDerefHandler _nullDerefHandler = null; } @@ -569,6 +613,23 @@ alias FilterThreadThrowableHandler = void function(ref Throwable) @system nothro _filterThreadThrowableHandler = handler; } +/** +Gets/sets null dereference handler. null means the default handler is used. +*/ +alias NullDerefHandler = void function(string file, size_t line) nothrow; + +/// ditto +@property NullDerefHandler nullDerefHandler() @trusted nothrow @nogc +{ + return _nullDerefHandler; +} + +/// ditto +@property void nullDerefHandler(NullDerefHandler handler) @trusted nothrow @nogc +{ + _nullDerefHandler = handler; +} + /////////////////////////////////////////////////////////////////////////////// // Overridable Callbacks /////////////////////////////////////////////////////////////////////////////// @@ -608,6 +669,21 @@ extern (C) void onAssertErrorMsg( string file, size_t line, string msg ) nothrow _assertHandler( file, line, msg ); } +/** + * A callback for null dereference errors in D. + * The user-supplied dereference handler will be called if one has been supplied, + * otherwise an $(LREF NullPointerError) will be thrown. + * + * Params: + * file = The name of the file that signaled this error. + * line = The line number on which this error occured. + */ +extern(C) void onNullPointerError(string file = __FILE__, size_t line = __LINE__) nothrow +{ + if (_nullDerefHandler is null) + throw staticError!NullPointerError(file, line); + _nullDerefHandler(file, line); +} /** * A callback for unittest errors in D. The user-supplied unittest handler @@ -884,6 +960,12 @@ extern (C) { onArrayIndexError(index, length, file, line); } + + void _d_nullpointerp(immutable(char*) file, uint line) + { + import core.stdc.string : strlen; + onNullPointerError(file[0 .. strlen(file)], line); + } } // TLS storage shared for all errors, chaining might create circular reference diff --git a/runtime/druntime/src/etc/linux/memoryerror.d b/runtime/druntime/src/etc/linux/memoryerror.d index b44a7f6d68..db6a0eab86 100644 --- a/runtime/druntime/src/etc/linux/memoryerror.d +++ b/runtime/druntime/src/etc/linux/memoryerror.d @@ -9,6 +9,7 @@ */ module etc.linux.memoryerror; +public import core.exception : InvalidPointerError, NullPointerError; version (linux) { @@ -94,73 +95,6 @@ version (MemoryErrorSupported) return !sigaction(SIGSEGV, oldptr, null); } - /** - * Thrown on POSIX systems when a SIGSEGV signal is received. - */ - class InvalidPointerError : Error - { - this(string file = __FILE__, size_t line = __LINE__, Throwable next = null) nothrow - { - super("", file, line, next); - } - - this(Throwable next, string file = __FILE__, size_t line = __LINE__) nothrow - { - super("", file, line, next); - } - } - - /** - * Thrown on null pointer dereferences. - */ - class NullPointerError : InvalidPointerError - { - this(string file = __FILE__, size_t line = __LINE__, Throwable next = null) nothrow - { - super(file, line, next); - } - - this(Throwable next, string file = __FILE__, size_t line = __LINE__) nothrow - { - super(file, line, next); - } - } - - unittest - { - int* getNull() { return null; } - - assert(registerMemoryErrorHandler()); - - bool b; - - try - { - *getNull() = 42; - } - catch (NullPointerError) - { - b = true; - } - - assert(b); - - b = false; - - try - { - *getNull() = 42; - } - catch (InvalidPointerError) - { - b = true; - } - - assert(b); - - assert(deregisterMemoryErrorHandler()); - } - // Signal handler space. private: diff --git a/runtime/druntime/test/exceptions/Makefile b/runtime/druntime/test/exceptions/Makefile index 0772d596cb..f1b318aa69 100644 --- a/runtime/druntime/test/exceptions/Makefile +++ b/runtime/druntime/test/exceptions/Makefile @@ -17,7 +17,7 @@ SED:=sed GDB:=gdb ifeq ($(OS),linux) - TESTS+=line_trace line_trace_21656 long_backtrace_trunc rt_trap_exceptions cpp_demangle + TESTS+=line_trace line_trace_21656 long_backtrace_trunc rt_trap_exceptions cpp_demangle linux_memory_error_handler # registerMemoryAssertHandler requires glibc ifndef IS_MUSL TESTS+=memoryerror_null_read memoryerror_null_write memoryerror_null_call memoryerror_stackoverflow @@ -102,6 +102,7 @@ $(ROOT)/memoryerror_null_write.done: stderr_exp="segmentation fault: null pointe $(ROOT)/memoryerror_null_call.done: stderr_exp="segmentation fault: null pointer read/write operation" $(ROOT)/memoryerror_null_call.done: stderr_exp2="uncaught exception reached top of stack" $(ROOT)/memoryerror_stackoverflow.done: stderr_exp="segmentation fault: call stack overflow" +$(ROOT)/linux_memory_error_handler.done: stderr_exp="success." $(ROOT)/%.done: $(ROOT)/%$(DOTEXE) @echo Testing $* @@ -155,3 +156,7 @@ $(ROOT)/rt_trap_exceptions_drt$(DOTEXE): extra_dflags += -g $(ROOT)/refcounted$(DOTEXE): extra_dflags+=-dip1008 $(ROOT)/cpp_demangle$(DOTEXE): extra_ldflags.d+=$(line_trace_dflags) $(ROOT)/cpp_demangle$(DOTEXE): extra_ldlibs.d+=-L-lstdc++ +$(ROOT)/memoryerror_null_read$(DOTEXE): extra_dflags += -check=nullderef=off +$(ROOT)/memoryerror_null_write$(DOTEXE): extra_dflags += -check=nullderef=off +$(ROOT)/memoryerror_null_call$(DOTEXE): extra_dflags += -check=nullderef=off +$(ROOT)/linux_memory_error_handler$(DOTEXE): extra_dflags += -check=nullderef=off diff --git a/runtime/druntime/test/exceptions/src/linux_memory_error_handler.d b/runtime/druntime/test/exceptions/src/linux_memory_error_handler.d new file mode 100644 index 0000000000..64a78ed971 --- /dev/null +++ b/runtime/druntime/test/exceptions/src/linux_memory_error_handler.d @@ -0,0 +1,43 @@ +import etc.linux.memoryerror; +import core.stdc.stdio : fprintf, stderr; + +void main() +{ + static if (is(registerMemoryErrorHandler)) + { + int* getNull() { + return null; + } + + assert(registerMemoryErrorHandler()); + + bool b; + + try + { + *getNull() = 42; + } + catch (NullPointerError) + { + b = true; + } + + assert(b); + + b = false; + + try + { + *getNull() = 42; + } + catch (InvalidPointerError) + { + b = true; + } + + assert(b); + + assert(deregisterMemoryErrorHandler()); + } + fprintf(stderr, "success.\n"); +} diff --git a/tests/dmd/dshell/cpp_header_gen.d b/tests/dmd/dshell/cpp_header_gen.d index d0ec226a54..69e7bce095 100644 --- a/tests/dmd/dshell/cpp_header_gen.d +++ b/tests/dmd/dshell/cpp_header_gen.d @@ -15,7 +15,8 @@ int main() Vars.set("CPP_OBJ", "$OUTPUT_BASE/cpp$OBJ"); Vars.set("HEADER_EXE", "$OUTPUT_BASE/test$EXE"); - run("$DMD -m$MODEL -c -lib -of=$LIB -HC=verbose -HCf=$OUTPUT_BASE/library.h $SOURCE_DIR/library.d"); + // This particular test passes a null pointer from c++ and gets "dereferenced" in D, and will trigger null dereference check to error. + run("$DMD -m$MODEL -c -lib -of=$LIB -check=nullderef=off -HC=verbose -HCf=$OUTPUT_BASE/library.h $SOURCE_DIR/library.d"); // Dump header if any of the following step fails scope (failure) diff --git a/tests/dmd/runnable/cdvecfill.sh b/tests/dmd/runnable/cdvecfill.sh index c199f5316e..b3f6933ec9 100644 --- a/tests/dmd/runnable/cdvecfill.sh +++ b/tests/dmd/runnable/cdvecfill.sh @@ -9,17 +9,17 @@ tmp_file=${RESULTS_TEST_DIR}/${TEST_NAME}.out obj_file=${RESULTS_TEST_DIR}/${TEST_NAME}.o if [ $OS == "linux" ] && [ $MODEL == "64" ]; then - $DMD -betterC -c -O -m64 ${src_file} -of${obj_file} + $DMD -betterC -c -O -m64 ${src_file} -of${obj_file} -check=nullderef=off objdump --disassemble --disassembler-options=intel ${obj_file} | tail -n+3 | sed 's/[ \t]\s*$//' > ${tmp_file} diff ${expect_file} ${tmp_file} rm_retry ${obj_file} ${tmp_file} - $DMD -betterC -c -O -m64 -mcpu=avx ${src_file} -of${obj_file} + $DMD -betterC -c -O -m64 -mcpu=avx ${src_file} -of${obj_file} -check=nullderef=off objdump --disassemble --disassembler-options=intel ${obj_file} | tail -n+3 | sed 's/[ \t]\s*$//' > ${tmp_file} diff ${expect_file_avx} ${tmp_file} rm_retry ${obj_file} ${tmp_file} - $DMD -betterC -c -O -m64 -mcpu=avx2 ${src_file} -of${obj_file} + $DMD -betterC -c -O -m64 -mcpu=avx2 ${src_file} -of${obj_file} -check=nullderef=off objdump --disassemble --disassembler-options=intel ${obj_file} | tail -n+3 | sed 's/[ \t]\s*$//' > ${tmp_file} diff ${expect_file_avx2} ${tmp_file} rm_retry ${obj_file} ${tmp_file} diff --git a/tests/dmd/runnable/gdb22590.c b/tests/dmd/runnable/gdb22590.c index afd5767509..8b8446820e 100644 --- a/tests/dmd/runnable/gdb22590.c +++ b/tests/dmd/runnable/gdb22590.c @@ -1,5 +1,5 @@ /* -REQUIRED_ARGS: -g +REQUIRED_ARGS: -g -check=nullderef=off PERMUTE_ARGS: GDB_SCRIPT: --- diff --git a/tests/dmd/runnable/minimal2.d b/tests/dmd/runnable/minimal2.d index 7319463e92..af8fdf4fb1 100644 --- a/tests/dmd/runnable/minimal2.d +++ b/tests/dmd/runnable/minimal2.d @@ -1,5 +1,5 @@ // DFLAGS: -// REQUIRED_ARGS: -defaultlib= +// REQUIRED_ARGS: -defaultlib= -check=nullderef=off // EXTRA_SOURCES: extra-files/minimal/object.d // This test ensures that interfaces and classes can be used in a minimal diff --git a/tests/dmd/runnable/nullderefcheck.d b/tests/dmd/runnable/nullderefcheck.d new file mode 100644 index 0000000000..1e35503c8b --- /dev/null +++ b/tests/dmd/runnable/nullderefcheck.d @@ -0,0 +1,52 @@ +// REQUIRED_ARGS: -check=nullderef=on +// PERMUTE_ARGS: + +struct Struct +{ + int field; +} + +void aLazyFunc(lazy int val) +{ + int storage = val; +} + +void main() +{ + wrap!(() { Struct* ptr; int val = ptr.field; })(__LINE__); + wrap!(() { int* ptr; int val = *ptr; })(__LINE__); + wrap!(() { Object ptr; auto del = &ptr.toString; del(); })(__LINE__); + wrap!(() { Object obj; obj.toString(); })(__LINE__); + wrap!(() { void function() func; func(); })(__LINE__); + wrap!(() { void delegate() del; del(); })(__LINE__); + + int val = 2; + val.aLazyFunc(); +} + +void wrap(alias test)(int expectedLine) +{ + gotFile = null; + gotLine = 0; + try + { + test(); + } + catch (Error) + { + } + assert(gotFile == __FILE__); + assert(gotLine == expectedLine); +} + +string gotFile; +uint gotLine; + +extern (C) void _d_nullpointerp(immutable(char*) file, uint line) +{ + import core.stdc.string : strlen; + + gotFile = file[0 .. strlen(file)]; + gotLine = line; + throw new Error(""); +} From 60637bd6dad63d51c473a4f785b3830359125b19 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Wed, 21 Jan 2026 13:03:27 +0000 Subject: [PATCH 283/440] Allow ref variable initialized from noreturn (dlang/dmd!22432) * Allow `ref` variable initialized from noreturn * Document that a VarDeclaration in a function will assign to a VarExp And that VarDeclaration will be in an ExpStatement. --- dmd/declaration.d | 2 ++ dmd/expressionsem.d | 11 +++++++---- dmd/statement.d | 4 ++++ tests/dmd/runnable/noreturn2.d | 14 ++++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/dmd/declaration.d b/dmd/declaration.d index f937980051..d9eab5b764 100644 --- a/dmd/declaration.d +++ b/dmd/declaration.d @@ -421,6 +421,8 @@ extern (C++) final class OverDeclaration : Declaration } /*********************************************************** + * Note: dsymbolSemantic turns a VarDeclaration inside a function into + * AssignExp(e1: VarExp, e2: ConstructExp or BlitExp). */ extern (C++) class VarDeclaration : Declaration { diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index c7cfb4a7dd..eb6cca75a8 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -12082,10 +12082,13 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor e2x.checkSharedAccess(sc)) return setError(); - auto etmp = checkNoreturnVarAccess(e2x); - if (etmp != e2x) - return setResult(etmp); - + // taking address of noreturn instance is OK + if (!(exp.e1.isVarExp() && exp.e1.isVarExp().var.storage_class & STC.ref_)) + { + auto etmp = checkNoreturnVarAccess(e2x); + if (etmp != e2x) + return setResult(etmp); + } exp.e2 = e2x; } diff --git a/dmd/statement.d b/dmd/statement.d index f8ec344f7a..0641c0a85c 100644 --- a/dmd/statement.d +++ b/dmd/statement.d @@ -383,6 +383,10 @@ extern (C++) class ExpStatement : Statement this.exp = exp; } + /******************************* + * Creates a DeclarationExp inside a statement. + * Use in place of *DeclarationStatement* from D grammar. + */ final extern (D) this(Loc loc, Dsymbol declaration) @safe { super(loc, STMT.Exp); diff --git a/tests/dmd/runnable/noreturn2.d b/tests/dmd/runnable/noreturn2.d index dea4e942ab..853fd90b1d 100644 --- a/tests/dmd/runnable/noreturn2.d +++ b/tests/dmd/runnable/noreturn2.d @@ -114,6 +114,20 @@ void testAccess() int b = a; }); + testAssertFailure(__LINE__ + 4, msg, + { + noreturn a; + auto p = &a; // OK + int b = *p; + }); + + testAssertFailure(__LINE__ + 4, msg, + { + noreturn a; + ref r = a; // OK, reads &a + int b = r; // asserts + }); + testAssertFailure(__LINE__ + 2, msg, function noreturn() { cast(noreturn) 1; From eb76bbcce63357c9230d032b0fbe7aebfdabcca6 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Tue, 20 Jan 2026 22:08:03 +0100 Subject: [PATCH 284/440] Fix dlang/dmd!22427 - Premature removal of ternary of type noreturn Correctly handle conditional and comma expression constructs in checkNoreturnVarAccess. When inspecting the lowering of a noreturn ternary expression, it was found to be needlessly inserting an `assert(0)` into the if-true result of the expression. (cond) ? noreturn(), assert(0) : noreturn(); Don't insert any casts to noreturn or void if both operands are the same type, as such casts are no-op. Closes dlang/dmd!22427 --- dmd/dcast.d | 2 +- dmd/expressionsem.d | 47 +++++++++++++++++++++++++--------- tests/dmd/runnable/test22427.d | 18 +++++++++++++ 3 files changed, 54 insertions(+), 13 deletions(-) create mode 100644 tests/dmd/runnable/test22427.d diff --git a/dmd/dcast.d b/dmd/dcast.d index 09cf803838..66c0b8a8c2 100644 --- a/dmd/dcast.d +++ b/dmd/dcast.d @@ -4585,7 +4585,7 @@ IntRange getIntRange(Expression e) * However, the dmd backend does not like a naive cast from a noreturn expression * (particularly an `assert(0)`) so this function generates: * - * `(assert(0), value)` instead of `cast(to)(assert(0))`. + * `(value, assert(0))` instead of `cast(to)(assert(0))`. * * `value` is currently `to.init` however it cannot be read so could be made simpler. * Params: diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index eb6cca75a8..106ac628b9 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -2066,19 +2066,36 @@ Expression checkNoreturnVarAccess(Expression exp) { assert(exp.type); - Expression result = exp; - if (exp.type.isTypeNoreturn() && !exp.isAssertExp() && - !exp.isThrowExp() && !exp.isCallExp()) + if (!exp.type.isTypeNoreturn()) + return exp; + + switch (exp.op) { + case EXP.assert_: + case EXP.throw_: + case EXP.call: + return exp; + + case EXP.question: + CondExp ce = cast(CondExp)exp; + ce.e1 = checkNoreturnVarAccess(ce.e1); + ce.e2 = checkNoreturnVarAccess(ce.e2); + return ce; + + case EXP.comma: + CommaExp ce = cast(CommaExp)exp; + ce.e1 = checkNoreturnVarAccess(ce.e1); + ce.e2 = checkNoreturnVarAccess(ce.e2); + return ce; + + default: auto msg = new StringExp(exp.loc, "Accessed expression of type `noreturn`"); msg.type = Type.tstring; auto ae = new AssertExp(exp.loc, IntegerExp.literal!0, msg); ae.loweredFrom = exp; - result = ae; - result.type = exp.type; + ae.type = exp.type; + return ae; } - - return result; } /****************************** @@ -15223,15 +15240,23 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor rewriteCNull(exp.e2, t2); } - if (t1.ty == Tnoreturn) + if (t1 == t2) + { + exp.type = t1; + } + // If only one of the operands is noreturn, cast it to the type of + // the other operand. + else if (t1.ty == Tnoreturn) { exp.type = t2; - exp.e1 = specialNoreturnCast(exp.e1, exp.type); + if (t2.ty != Tnoreturn) + exp.e1 = specialNoreturnCast(exp.e1, exp.type); } else if (t2.ty == Tnoreturn) { exp.type = t1; - exp.e2 = specialNoreturnCast(exp.e2, exp.type); + if (t1.ty != Tnoreturn) + exp.e2 = specialNoreturnCast(exp.e2, exp.type); } // If either operand is void the result is void, we have to cast both // the expression to void so that we explicitly discard the expression @@ -15243,8 +15268,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor exp.e1 = exp.e1.castTo(sc, exp.type); exp.e2 = exp.e2.castTo(sc, exp.type); } - else if (t1 == t2) - exp.type = t1; else { if (Expression ex = typeCombine(exp, sc)) diff --git a/tests/dmd/runnable/test22427.d b/tests/dmd/runnable/test22427.d new file mode 100644 index 0000000000..7b7b5f1b9a --- /dev/null +++ b/tests/dmd/runnable/test22427.d @@ -0,0 +1,18 @@ +// https://github.com/dlang/dmd/issues/22427 + +void main() +{ + try + { + scope exitProgram = (bool failure) @trusted { + return failure + ? throw new Exception("exit(1)") + : throw new Exception("exit(0)"); + }; + exitProgram(false); + } + catch (Exception e) + { + assert(e.message == "exit(0)"); + } +} From 74372e799a7d2ba0c9fd0c522eea12a476092ef8 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Wed, 21 Jan 2026 21:35:46 +0100 Subject: [PATCH 285/440] Fix dlang/dmd!22430 - noreturn evaluation in ConditionalExpression is ignored (dlang/dmd!22434) Closes dlang/dmd!22430 --- dmd/expressionsem.d | 8 ++++---- tests/dmd/runnable/noreturn2.d | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 106ac628b9..2f38c4b848 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -2064,10 +2064,7 @@ Returns: Expression checkNoreturnVarAccess(Expression exp) { - assert(exp.type); - - if (!exp.type.isTypeNoreturn()) - return exp; + assert(exp); switch (exp.op) { @@ -2089,6 +2086,9 @@ Expression checkNoreturnVarAccess(Expression exp) return ce; default: + if (!exp.type || !exp.type.isTypeNoreturn()) + return exp; + auto msg = new StringExp(exp.loc, "Accessed expression of type `noreturn`"); msg.type = Type.tstring; auto ae = new AssertExp(exp.loc, IntegerExp.literal!0, msg); diff --git a/tests/dmd/runnable/noreturn2.d b/tests/dmd/runnable/noreturn2.d index 853fd90b1d..c25ab984c3 100644 --- a/tests/dmd/runnable/noreturn2.d +++ b/tests/dmd/runnable/noreturn2.d @@ -180,6 +180,13 @@ void testAccess() if (v) return; }); + + // https://github.com/dlang/dmd/issues/22430 + testAssertFailure(__LINE__ + 3, msg, + { + noreturn a; + auto b = true ? a : 1; + }); } /*****************************************/ From 5704477ce82650b7be1296c87c5ce0f9da39b976 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Thu, 22 Jan 2026 00:30:15 +0100 Subject: [PATCH 286/440] Disable DFA when compiling IN_GCC (dlang/dmd!22435) --- dmd/semantic3.d | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/dmd/semantic3.d b/dmd/semantic3.d index b22ab8c0af..a1c7662592 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -76,7 +76,12 @@ import dmd.targetcompiler; import dmd.templateparamsem; import dmd.typesem; import dmd.visitor; -import dmd.dfa.entry; + +version (IN_GCC) { /* Not using Fast DFA */ } +else version = FastDFA; + +version (FastDFA) + import dmd.dfa.entry; enum LOG = false; @@ -1421,11 +1426,14 @@ private extern(C++) final class Semantic3Visitor : Visitor oblive(funcdecl); } - if (global.params.useFastDFA && global.errors == oldErrors && funcdecl.fbody && funcdecl.type.ty != Terror) + version (FastDFA) { - // Don't run DFA if there are errors, - // this is a costly enough operation that it warrents the explicit check. - dfaEntry(funcdecl, sc); + if (global.params.useFastDFA && global.errors == oldErrors && funcdecl.fbody && funcdecl.type.ty != Terror) + { + // Don't run DFA if there are errors, + // this is a costly enough operation that it warrents the explicit check. + dfaEntry(funcdecl, sc); + } } /* If this function had instantiated with gagging, error reproduction will be From 4b14e46d3b7df2cffcac4a1be1f26aef20549e94 Mon Sep 17 00:00:00 2001 From: Aditya Singh Date: Thu, 22 Jan 2026 05:00:44 +0530 Subject: [PATCH 287/440] Fix Issue 22394 - Show instantiation trace for lambda errors (dlang/dmd!22405) --- dmd/expressionsem.d | 4 ++++ tests/dmd/fail_compilation/ice11850.d | 2 +- tests/dmd/fail_compilation/issue22394.d | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/fail_compilation/issue22394.d diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 2f38c4b848..fef1a40bdc 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -1463,6 +1463,10 @@ extern (D) Expression incompatibleTypes(BinExp e, Scope* sc = null) error(e.loc, "incompatible types for `(%s) %s (%s)`: `%s` and `%s`", e.e1.toErrMsg(), thisOp, e.e2.toErrMsg(), ts[0], ts[1]); } + + if (sc && sc.tinst) + sc.tinst.printInstantiationTrace(); + return ErrorExp.get(); } diff --git a/tests/dmd/fail_compilation/ice11850.d b/tests/dmd/fail_compilation/ice11850.d index 510fe0aae8..6e88ff95f5 100644 --- a/tests/dmd/fail_compilation/ice11850.d +++ b/tests/dmd/fail_compilation/ice11850.d @@ -1,8 +1,8 @@ /* -EXTRA_FILES: imports/a11850.d TEST_OUTPUT: --- fail_compilation/ice11850.d(15): Error: incompatible types for `(a) < ([0])`: `uint[]` and `int[]` +fail_compilation/imports/a11850.d(23): instantiated from here: `__lambda_L15_C13!(uint[])` fail_compilation/imports/a11850.d(9): instantiated from here: `FilterResult!(__lambda_L15_C13, uint[][])` fail_compilation/ice11850.d(15): instantiated from here: `filter!(uint[][])` --- diff --git a/tests/dmd/fail_compilation/issue22394.d b/tests/dmd/fail_compilation/issue22394.d new file mode 100644 index 0000000000..cc37adf72e --- /dev/null +++ b/tests/dmd/fail_compilation/issue22394.d @@ -0,0 +1,16 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/issue22394.d(11): Error: incompatible types for `(a) + (1)`: `string` and `int` +fail_compilation/issue22394.d(15): instantiated from here: `__lambda_L11_C1!string` +--- +*/ + +// https://issues.dlang.org/show_bug.cgi?id=22394 + +alias l = a => a + 1; + +void f() +{ + l(""); +} From f529233667cdd1048e95e9cf53bc051f6c52fc09 Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Thu, 22 Jan 2026 00:31:57 +0100 Subject: [PATCH 288/440] fix dlang/dmd!22399 - Low-level threading support on Windows DLLs are broken (dlang/dmd!22417) also monitor DLLs that share the runtime and have threads with unload callbacks not in the runtime. Avoid memory leak if starting thread fails. --- runtime/druntime/src/core/thread/osthread.d | 147 ++++++++++++++------ runtime/druntime/src/core/thread/types.d | 3 + runtime/druntime/test/shared/Makefile | 3 +- runtime/druntime/test/shared/src/dllgc.d | 4 +- 4 files changed, 110 insertions(+), 47 deletions(-) diff --git a/runtime/druntime/src/core/thread/osthread.d b/runtime/druntime/src/core/thread/osthread.d index 8c29018da3..a19eda61d5 100644 --- a/runtime/druntime/src/core/thread/osthread.d +++ b/runtime/druntime/src/core/thread/osthread.d @@ -2777,43 +2777,38 @@ private version (CRuntime_Microsoft) extern(C) extern __gshared ubyte msvcUsesUCRT; // from rt/msvc.d + extern(C) extern __gshared void* __ImageBase; // symbol at the beginning of module, added by linker + enum HMODULE runtimeModule = &__ImageBase; /// set during termination of a DLL on Windows, i.e. while executing DllMain(DLL_PROCESS_DETACH) public __gshared bool thread_DLLProcessDetaching; - __gshared HMODULE ll_dllModule; __gshared ThreadID ll_dllMonitorThread; - int ll_countLowLevelThreadsWithDLLUnloadCallback() nothrow + int ll_countLowLevelThreadsWithDLLUnloadCallback(HMODULE hMod) nothrow { lowlevelLock.lock_nothrow(); scope(exit) lowlevelLock.unlock_nothrow(); int cnt = 0; foreach (i; 0 .. ll_nThreads) - if (ll_pThreads[i].cbDllUnload) + if (ll_pThreads[i].cbDllUnload && ll_pThreads[i].hMod == hMod) cnt++; return cnt; } - bool ll_dllHasExternalReferences() nothrow + bool ll_dllHasExternalReferences(HMODULE hMod) nothrow { - int internalReferences = msvcUsesUCRT ? 1 + ll_countLowLevelThreadsWithDLLUnloadCallback() : 1; - int refcnt = dll_getRefCount(ll_dllModule); + int unloadCallbacks = ll_countLowLevelThreadsWithDLLUnloadCallback(hMod); + int internalReferences = hMod != runtimeModule ? unloadCallbacks + : (ll_dllMonitorThread ? 1 : 0) + (msvcUsesUCRT ? unloadCallbacks : 0); + int refcnt = dll_getRefCount(hMod); return refcnt > internalReferences; } - private void monitorDLLRefCnt() nothrow + void notifyUnloadLowLevelThreads(HMODULE hMod) nothrow { - // this thread keeps the DLL alive until all external references are gone - while (ll_dllHasExternalReferences()) - { - Thread.sleep(100.msecs); - } - - // the current thread will be terminated below - ll_removeThread(GetCurrentThreadId()); - + HMODULE toFree; for (;;) { ThreadID tid; @@ -2823,36 +2818,70 @@ private scope(exit) lowlevelLock.unlock_nothrow(); foreach (i; 0 .. ll_nThreads) - if (ll_pThreads[i].cbDllUnload) + if (ll_pThreads[i].cbDllUnload && ll_pThreads[i].hMod == hMod) { + if (!toFree) + toFree = ll_getModuleHandle(hMod, true); // keep the module alive until the callback returns cbDllUnload = ll_pThreads[i].cbDllUnload; - tid = ll_pThreads[0].tid; + tid = ll_pThreads[i].tid; + break; } } if (!cbDllUnload) break; - cbDllUnload(); + cbDllUnload(); // must wait for thread termination assert(!findLowLevelThread(tid)); } + if (toFree) + FreeLibrary(toFree); + } + + private void monitorDLLRefCnt() nothrow + { + // this thread keeps the DLL alive until all external references are gone + // (including those from DLLs using druntime in a shared DLL) + while (ll_dllHasExternalReferences(runtimeModule)) + { + // find and unload module that only has internal references left + HMODULE hMod; + { + lowlevelLock.lock_nothrow(); + scope(exit) lowlevelLock.unlock_nothrow(); + + foreach (i; 0 .. ll_nThreads) + if (ll_pThreads[i].cbDllUnload && ll_pThreads[i].hMod != runtimeModule) + if (!ll_dllHasExternalReferences(ll_pThreads[i].hMod)) + { + hMod = ll_pThreads[i].hMod; + break; + } + } + if (hMod) + notifyUnloadLowLevelThreads(hMod); + else + Thread.sleep(100.msecs); + } + + notifyUnloadLowLevelThreads(runtimeModule); + + // the current thread will be terminated without cleanup within the thread + ll_removeThread(GetCurrentThreadId()); - FreeLibraryAndExitThread(ll_dllModule, 0); + FreeLibraryAndExitThread(runtimeModule, 0); } - int ll_getDLLRefCount() nothrow @nogc + HMODULE ll_getModuleHandle(void* funcptr, bool addref = false) nothrow @nogc { - if (!ll_dllModule && - !GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - cast(const(wchar)*) &ll_getDLLRefCount, &ll_dllModule)) - return -1; - return dll_getRefCount(ll_dllModule); + HMODULE hmod; + DWORD refflag = addref ? 0 : GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT; + if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | refflag, + cast(const(wchar)*) funcptr, &hmod)) + return null; + return hmod; } bool ll_startDLLUnloadThread() nothrow @nogc { - int refcnt = ll_getDLLRefCount(); - if (refcnt < 0) - return false; // not a dynamically loaded DLL - if (ll_dllMonitorThread !is ThreadID.init) return true; @@ -2860,13 +2889,10 @@ private // to avoid the DLL being unloaded while the thread is still running. Mimick this behavior here for all // runtimes not doing this bool needRef = !msvcUsesUCRT; - if (needRef) - { - HMODULE hmod; - GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, cast(const(wchar)*) &ll_getDLLRefCount, &hmod); - } + ll_getModuleHandle(runtimeModule, true); + // the monitor thread must be a low-level thread so the runtime does not attach to it ll_dllMonitorThread = createLowLevelThread(() { monitorDLLRefCnt(); }); return ll_dllMonitorThread != ThreadID.init; } @@ -2890,8 +2916,15 @@ private ThreadID createLowLevelThread(void delegate() nothrow dg, uint stacksize = 0, void delegate() nothrow cbDllUnload = null) nothrow @nogc { - void delegate() nothrow* context = cast(void delegate() nothrow*)malloc(dg.sizeof); - *context = dg; + static struct Context + { + void delegate() nothrow dg; + version (Windows) + HMODULE cbMod; + } + auto context = cast(Context*)malloc(Context.sizeof); + scope(exit) free(context); + context.dg = dg; ThreadID tid; version (Windows) @@ -2899,14 +2932,30 @@ ThreadID createLowLevelThread(void delegate() nothrow dg, uint stacksize = 0, // the thread won't start until after the DLL is unloaded if (thread_DLLProcessDetaching) return ThreadID.init; + context.cbMod = cbDllUnload ? ll_getModuleHandle(cbDllUnload.funcptr) : null; + if (context.cbMod) + { + int refcnt = dll_getRefCount(context.cbMod); + if (refcnt < 0) + { + // not a dynamically loaded DLL, so never unloaded + cbDllUnload = null; + context.cbMod = null; + } + if (refcnt == 0) + return ThreadID.init; // createLowLevelThread called while DLL is unloading + } static extern (Windows) uint thread_lowlevelEntry(void* ctx) nothrow { - auto dg = *cast(void delegate() nothrow*)ctx; + auto context = *cast(Context*)ctx; free(ctx); - dg(); + context.dg(); + ll_removeThread(GetCurrentThreadId()); + if (context.cbMod && context.cbMod != runtimeModule) + FreeLibrary(context.cbMod); return 0; } @@ -2922,11 +2971,20 @@ ThreadID createLowLevelThread(void delegate() nothrow dg, uint stacksize = 0, ll_nThreads++; ll_pThreads = cast(ll_ThreadData*)realloc(ll_pThreads, ll_ThreadData.sizeof * ll_nThreads); + ll_pThreads[ll_nThreads - 1] = ll_ThreadData.init; version (Windows) { ll_pThreads[ll_nThreads - 1].tid = tid; - ll_pThreads[ll_nThreads - 1].cbDllUnload = cbDllUnload; + // ignore callback if not a dynamically loaded DLL + if (cbDllUnload) + { + ll_pThreads[ll_nThreads - 1].cbDllUnload = cbDllUnload; + ll_pThreads[ll_nThreads - 1].hMod = context.cbMod; + if (context.cbMod != runtimeModule) + ll_getModuleHandle(context.cbMod, true); // increment ref count + } + if (ResumeThread(hThread) == -1) onThreadError("Error resuming thread"); CloseHandle(hThread); @@ -2938,10 +2996,10 @@ ThreadID createLowLevelThread(void delegate() nothrow dg, uint stacksize = 0, { static extern (C) void* thread_lowlevelEntry(void* ctx) nothrow { - auto dg = *cast(void delegate() nothrow*)ctx; + auto context = *cast(Context*)ctx; free(ctx); - dg(); + context.dg(); ll_removeThread(pthread_self()); return null; } @@ -2957,11 +3015,12 @@ ThreadID createLowLevelThread(void delegate() nothrow dg, uint stacksize = 0, return ThreadID.init; if ((rc = pthread_create(&tid, &attr, &thread_lowlevelEntry, context)) != 0) return ThreadID.init; - if ((rc = pthread_attr_destroy(&attr)) != 0) - return ThreadID.init; + rc = pthread_attr_destroy(&attr); + assert(rc == 0); ll_pThreads[ll_nThreads - 1].tid = tid; } + context = null; // free'd in thread return tid; } diff --git a/runtime/druntime/src/core/thread/types.d b/runtime/druntime/src/core/thread/types.d index 4d0b3649ec..c816010e5c 100644 --- a/runtime/druntime/src/core/thread/types.d +++ b/runtime/druntime/src/core/thread/types.d @@ -29,7 +29,10 @@ struct ll_ThreadData { ThreadID tid; version (Windows) + { void delegate() nothrow cbDllUnload; + void* hMod; // HMODULE containing the unload callback + } } version (GNU) diff --git a/runtime/druntime/test/shared/Makefile b/runtime/druntime/test/shared/Makefile index 8553f12c4b..8f5ffe853a 100644 --- a/runtime/druntime/test/shared/Makefile +++ b/runtime/druntime/test/shared/Makefile @@ -33,7 +33,8 @@ PATH := $(dir $(DRUNTIMESO));$(PATH) endif $(ROOT)/dllgc$(DOTEXE): $(ROOT)/dllgc$(DOTDLL) -$(ROOT)/dllgc$(DOTDLL): private extra_dflags += -version=DLL -od=$(ROOT)/dll +$(ROOT)/dllgc$(DOTDLL): private extra_dflags += -version=DLL -od=$(ROOT)/dll -L/PDB:$(ROOT)/dllgc_dll.pdb +$(ROOT)/dynamiccast$(DOTDLL): private extra_dflags += -L/PDB:$(ROOT)/dynamiccast_dll.pdb endif # Windows $(ROOT)/dynamiccast.done: $(ROOT)/%.done: $(ROOT)/%$(DOTEXE) $(ROOT)/%$(DOTDLL) diff --git a/runtime/druntime/test/shared/src/dllgc.d b/runtime/druntime/test/shared/src/dllgc.d index 928e1479cc..de060abd49 100644 --- a/runtime/druntime/test/shared/src/dllgc.d +++ b/runtime/druntime/test/shared/src/dllgc.d @@ -42,9 +42,9 @@ version(DLL) static ~this() { - // creating thread in shutdown should fail when statically linked + // creating thread in shutdown should fail (term no longer available) auto tsk = new Task; - assert((tsk.tid != ThreadID.init) == isSharedDRuntime()); + assert(tsk.tid == ThreadID.init); } } else From 07645f3d9122b01cacde95239fdcb8858055ae98 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Wed, 21 Jan 2026 23:33:00 +0000 Subject: [PATCH 289/440] Don't drop aggregate type qualifier for alias parameter (dlang/dmd!22393) Fixes https://github.com/dlang/dmd/issues/17959. --- dmd/templatesem.d | 4 +++- tests/dmd/compilable/alias_param_qual.d | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/compilable/alias_param_qual.d diff --git a/dmd/templatesem.d b/dmd/templatesem.d index d42a437637..0b0fd1b7af 100644 --- a/dmd/templatesem.d +++ b/dmd/templatesem.d @@ -2778,7 +2778,9 @@ private MATCH matchArg(TemplateParameter tp, Scope* sc, RootObject oarg, size_t if (!sa || si != sa) return matchArgNoMatch(); } - dedtypes[i] = sa; + // Note: Dsymbol can't have type qualifiers, so use type if it has them + // https://github.com/dlang/dmd/issues/17959 + dedtypes[i] = ta && ta.mod ? ta : sa; if (psparam) { diff --git a/tests/dmd/compilable/alias_param_qual.d b/tests/dmd/compilable/alias_param_qual.d new file mode 100644 index 0000000000..ac902e7d2c --- /dev/null +++ b/tests/dmd/compilable/alias_param_qual.d @@ -0,0 +1,7 @@ +alias t(alias a) = a; + +static assert(is(t!(const Object) == const Object)); +static assert(is(t!(shared(Object)) == shared Object)); +static assert(is(t!(immutable S) == immutable(S))); + +struct S {} From b4edc095bf097392059f8371adfd054ea4796b07 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Wed, 21 Jan 2026 23:34:57 +0000 Subject: [PATCH 290/440] Fix dlang/dmd!19905 - expand type tuples in delegate params during IFTI (dlang/dmd!22262) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When matching a lambda against a delegate type like `R delegate(Args)` during IFTI, parameter types that resolve to TypeTuples (e.g. from AliasSeq) were not being expanded before comparing parameter counts. This caused IFTI to fail for lambdas like `(a) => a.m()` when matched against `R delegate(AliasSeq!S)`, even though explicit instantiation `fun!void((a) => a.m())` worked correctly. The fix resolves and expands TypeTuple parameters before comparing counts, similar to what TypeFunction.typeSemantic does, but only for parameters that don't rely on template parameters being deduced. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude --- dmd/templatesem.d | 50 +++++++++++++++++++++++++++----- tests/dmd/compilable/test19905.d | 29 ++++++++++++++++++ 2 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 tests/dmd/compilable/test19905.d diff --git a/dmd/templatesem.d b/dmd/templatesem.d index 0b0fd1b7af..a2bed8a7cd 100644 --- a/dmd/templatesem.d +++ b/dmd/templatesem.d @@ -7600,7 +7600,39 @@ MATCH deduceType(scope RootObject o, scope Scope* sc, scope Type tparam, //printf("\ttf = %s\n", tf.toChars()); const dim = tf.parameterList.length; - if (tof.parameterList.length != dim || tof.parameterList.varargs != tf.parameterList.varargs) + if (tof.parameterList.varargs != tf.parameterList.varargs) + return; + + // https://github.com/dlang/dmd/issues/19905 + // Resolve and expand TypeTuples (e.g. from AliasSeq) in tof's parameters + // before comparing counts. We can't call TypeFunction.typeSemantic because + // the return type may contain unresolved template parameters. + Types* expandedTypes; + foreach (pto; *tof.parameterList.parameters) + { + Type pt = pto.type; + if (!reliesOnTemplateParameters(pt, parameters[inferStart .. parameters.length])) + { + pt = pt.syntaxCopy().typeSemantic(e.loc, sc); + if (pt.ty == Terror) + return; + } + if (auto tt = pt.isTypeTuple()) + { + if (!expandedTypes) + expandedTypes = new Types(); + foreach (arg; *tt.arguments) + expandedTypes.push(arg.type); + } + else + { + if (!expandedTypes) + expandedTypes = new Types(); + expandedTypes.push(pt); + } + } + + if (!expandedTypes || expandedTypes.length != dim) return; auto tiargs = new Objects(); @@ -7616,15 +7648,19 @@ MATCH deduceType(scope RootObject o, scope Scope* sc, scope Type tparam, ++u; } assert(u < dim); - Parameter pto = tof.parameterList[u]; - if (!pto) + Type t = (*expandedTypes)[u]; + if (!t) break; - Type t = pto.type.syntaxCopy(); // https://issues.dlang.org/show_bug.cgi?id=11774 if (reliesOnTemplateParameters(t, parameters[inferStart .. parameters.length])) return; - t = t.typeSemantic(e.loc, sc); - if (t.ty == Terror) - return; + // https://issues.dlang.org/show_bug.cgi?id=11774 + t = t.syntaxCopy(); + if (!t.deco) + { + t = t.typeSemantic(e.loc, sc); + if (t.ty == Terror) + return; + } tiargs.push(t); } diff --git a/tests/dmd/compilable/test19905.d b/tests/dmd/compilable/test19905.d new file mode 100644 index 0000000000..f8c1757c86 --- /dev/null +++ b/tests/dmd/compilable/test19905.d @@ -0,0 +1,29 @@ +// https://github.com/dlang/dmd/issues/19905 +// Type list (tuple) not expanded in delegate during IFTI + +alias AliasSeq(TList...) = TList; + +struct S +{ + void m() {} +} + +void fun1(R)(R delegate(AliasSeq!S) dg) {} +void fun2(R)(R delegate(AliasSeq!(S, S)) dg) {} +void fun3(R)(R delegate(AliasSeq!(S, S, S)) dg) {} +void fun0(R)(R delegate(AliasSeq!()) dg) {} + +void main() +{ + // Explicit template argument always worked + fun1!void((a) { a.m(); }); + fun2!void((a, b) { a.m(); b.m(); }); + fun3!void((a, b, c) { a.m(); b.m(); c.m(); }); + fun0!void(() {}); + + // IFTI with tuple expansion - was broken, now fixed + fun1((a) { a.m(); }); + fun2((a, b) { a.m(); b.m(); }); + fun3((a, b, c) { a.m(); b.m(); c.m(); }); + fun0(() {}); +} From 9e61620623c01f60e469858270aedc10f939cf78 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Wed, 21 Jan 2026 23:36:48 +0000 Subject: [PATCH 291/440] [2024 edition] Disallow `alias ... ident;` syntax (dlang/dmd!22244) --- dmd/parse.d | 11 +++++++---- tests/dmd/fail_compilation/obsolete_body.d | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dmd/parse.d b/dmd/parse.d index 499fa1d651..d8e4458f83 100644 --- a/dmd/parse.d +++ b/dmd/parse.d @@ -4641,9 +4641,11 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer if (isAliasDeclaration) { - AST.Declaration v; - AST.Initializer _init = null; - + if (ident && mod.edition >= Edition.v2024) + { + eSink.error(token.loc, "use `alias %s = ...;` syntax instead of `alias ... %s;`", + ident.toChars(), ident.toChars()); + } /* Aliases can no longer have multiple declarators, storage classes, * linkages, or auto declarations. * These never made any sense, anyway. @@ -4654,6 +4656,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer if (udas) error("user-defined attributes not allowed for `alias` declarations"); + AST.Initializer _init = null; if (token.value == TOK.assign) { nextToken(); @@ -4663,7 +4666,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer { error("alias cannot have initializer"); } - v = new AST.AliasDeclaration(aliasLoc, ident, t); + AST.Declaration v = new AST.AliasDeclaration(aliasLoc, ident, t); v.storage_class = storage_class; if (pAttrs) diff --git a/tests/dmd/fail_compilation/obsolete_body.d b/tests/dmd/fail_compilation/obsolete_body.d index 86d8bbc5d3..d429635928 100644 --- a/tests/dmd/fail_compilation/obsolete_body.d +++ b/tests/dmd/fail_compilation/obsolete_body.d @@ -2,10 +2,12 @@ TEST_OUTPUT: --- fail_compilation/obsolete_body.d(11): Error: usage of identifer `body` as a keyword is obsolete. Use `do` instead. +fail_compilation/obsolete_body.d(13): Error: use `alias i32 = ...;` syntax instead of `alias ... i32;` --- */ -@__edition_latest_do_not_use -module m; +module m 2024; void test() in { } body { } + +alias int i32; From 9c27bbbd0ce67ccef3a0ed90cf0ce0b842b93415 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Fri, 23 Jan 2026 01:33:12 +0100 Subject: [PATCH 292/440] Improve wording of some errors around bitfields (dlang/dmd!22439) --- dmd/dsymbolsem.d | 65 ++++++++++++++++++------- dmd/parse.d | 3 +- dmd/semantic2.d | 10 +++- tests/dmd/fail_compilation/biterrors2.d | 6 +-- tests/dmd/fail_compilation/biterrors6.d | 24 +++++++++ tests/dmd/fail_compilation/biterrors7.d | 15 ++++++ tests/dmd/fail_compilation/bitfields2.c | 4 +- tests/dmd/fail_compilation/fail20779.d | 2 +- tests/dmd/fail_compilation/fail22384.d | 32 ++++++------ tests/dmd/fail_compilation/fail8691.d | 2 +- 10 files changed, 121 insertions(+), 42 deletions(-) create mode 100644 tests/dmd/fail_compilation/biterrors6.d create mode 100644 tests/dmd/fail_compilation/biterrors7.d diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index ad5b58442d..c36cea2d6a 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -3174,10 +3174,12 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (dsym.semanticRun >= PASS.semanticdone) return; - if (dsym.isAnonymous() && dsym._init) + const bool isAnonymous = dsym.isAnonymous(); + if (isAnonymous && dsym._init) { - .error(dsym.loc, "anonymous bitfield cannot have default initializer"); + .error(dsym._init.loc, "anonymous bitfield cannot have default initializer"); dsym._init = null; + dsym.errors = true; } visit(cast(VarDeclaration)dsym); @@ -3201,8 +3203,12 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (!dsym.type.isIntegral()) { // C11 6.7.2.1-5 - error(dsym.loc, "bitfield type `%s` is not an integer type", dsym.type.toChars()); + if (isAnonymous) + error(dsym.loc, "anonymous bitfield cannot be of non-integral type `%s`", dsym.type.toChars()); + else + error(dsym.loc, "bitfield `%s` cannot be of non-integral type `%s`", dsym.toChars(), dsym.type.toChars()); dsym.errors = true; + return; } if (!width.isIntegerExp()) { @@ -3210,20 +3216,34 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor dsym.errors = true; } const uwidth = width.toInteger(); // uwidth is unsigned - if (uwidth == 0 && !dsym.isAnonymous()) + if (uwidth == 0 && !isAnonymous) { - error(width.loc, "bitfield `%s` has zero width", dsym.toChars()); + error(dsym.loc, "bitfield `%s` cannot have zero width", dsym.toChars()); dsym.errors = true; } - const sz = dsym.type.size(); - if (sz == SIZE_INVALID) - dsym.errors = true; - const max_width = sz * 8; - if (uwidth > max_width) + if (cast(long)uwidth < 0) { - error(width.loc, "width `%lld` of bitfield `%s` does not fit in type `%s`", cast(long)uwidth, dsym.toChars(), dsym.type.toChars()); + if (isAnonymous) + error(width.loc, "anonymous bitfield has negative width `%lld`", cast(long)uwidth); + else + error(width.loc, "bitfield `%s` has negative width `%lld`", dsym.toChars(), cast(long)uwidth); dsym.errors = true; } + else + { + const sz = dsym.type.size(); + if (sz == SIZE_INVALID) + dsym.errors = true; + const max_width = sz * 8; + if (uwidth > max_width) + { + if (isAnonymous) + error(width.loc, "width `%lld` of anonymous bitfield does not fit in type `%s`", cast(long)uwidth, dsym.type.toChars()); + else + error(width.loc, "width `%lld` of bitfield `%s` does not fit in type `%s`", cast(long)uwidth, dsym.toChars(), dsym.type.toChars()); + dsym.errors = true; + } + } dsym.fieldWidth = cast(uint)uwidth; } @@ -7046,10 +7066,20 @@ bool determineFields(AggregateDeclaration ad) { if (ad == tvs.sym) { + if (ad.type.ty == Terror || ad.errors) + return 1; // failed already + const(char)* psz = (v.type.toBasetype().ty == Tsarray) ? "static array of " : ""; - .error(ad.loc, "%s `%s` cannot have field `%s` with %ssame struct type", ad.kind, ad.toPrettyChars, v.toChars(), psz); - ad.type = Type.terror; - ad.errors = true; + if (!v.isAnonymous()) + .error(v.loc, "%s `%s` cannot have field `%s` with %ssame struct type", ad.kind, ad.toPrettyChars, v.toChars(), psz); + else + .error(v.loc, "%s `%s` cannot have anonymous field with %ssame struct type", ad.kind, ad.toPrettyChars, psz); + // Don't cache errors from speculative semantic + if (!global.gag) + { + ad.type = Type.terror; + ad.errors = true; + } return 1; } } @@ -8439,10 +8469,9 @@ private extern(C++) class SetFieldOffsetVisitor : Visitor uint memalignsize = target.fieldalign(t); // size of member for alignment purposes if (log) printf(" memsize: %u memalignsize: %u\n", memsize, memalignsize); - if (bfd.fieldWidth == 0 && !anon) - error(bfd.loc, "named bit fields cannot have 0 width"); - if (bfd.fieldWidth > memsize * 8) - error(bfd.loc, "bit field width %d is larger than type", bfd.fieldWidth); + // Handled in dsymbolSemantic as errors + assert(bfd.fieldWidth != 0 || anon, "named bit fields cannot have 0 width"); + assert(bfd.fieldWidth <= memsize * 8, "bit field width is larger than type"); const style = target.c.bitFieldStyle; if (style != TargetC.BitFieldStyle.MS && style != TargetC.BitFieldStyle.Gcc_Clang) diff --git a/dmd/parse.d b/dmd/parse.d index d8e4458f83..c8ca3a1a0f 100644 --- a/dmd/parse.d +++ b/dmd/parse.d @@ -4505,6 +4505,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer isAliasDeclaration = true; } + const typeLoc = token.loc; AST.Type ts; if (!autodecl) @@ -4797,7 +4798,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer { if (storage_class) error("storage class not allowed for bitfield declaration"); - s = new AST.BitFieldDeclaration(loc, t, ident, width, _init); + s = new AST.BitFieldDeclaration(ident.isAnonymous() ? typeLoc : loc, t, ident, width, _init); } else { diff --git a/dmd/semantic2.d b/dmd/semantic2.d index 64244b6228..46d4a92ebc 100644 --- a/dmd/semantic2.d +++ b/dmd/semantic2.d @@ -351,8 +351,14 @@ private extern(C++) final class Semantic2Visitor : Visitor if (!bounds.contains(value)) { const uwidth = bfd.fieldWidth; - error(ei.loc, "bitfield initializer `%s` does not fit in %d bit%s", - ei.exp.toChars(), cast(int) uwidth, uwidth == 1 ? "".ptr : "s".ptr); + error(ei.loc, "default initializer `%s` is not representable as bitfield type `%s:%lld`", + ei.exp.toChars(), bfd.type.toBasetype().toChars(), cast(long)uwidth); + if (isUnsigned) + errorSupplemental(bfd.loc, "bitfield `%s` default initializer must be a value between `%llu..%llu`", + bfd.toChars(), bounds.imin.value, bounds.imax.value); + else + errorSupplemental(bfd.loc, "bitfield `%s` default initializer must be a value between `%lld..%lld`", + bfd.toChars(), bounds.imin.value, bounds.imax.value); } } diff --git a/tests/dmd/fail_compilation/biterrors2.d b/tests/dmd/fail_compilation/biterrors2.d index 56cb8cc5f4..2c240b53d1 100644 --- a/tests/dmd/fail_compilation/biterrors2.d +++ b/tests/dmd/fail_compilation/biterrors2.d @@ -4,10 +4,10 @@ fail_compilation/biterrors2.d(100): Error: variable `biterrors2.a` - bitfield must be member of struct, union, or class int a : 2; ^ -fail_compilation/biterrors2.d(104): Error: bitfield `b` has zero width +fail_compilation/biterrors2.d(104): Error: bitfield `b` cannot have zero width int b:0; - ^ -fail_compilation/biterrors2.d(105): Error: bitfield type `float` is not an integer type + ^ +fail_compilation/biterrors2.d(105): Error: bitfield `c` cannot be of non-integral type `float` float c:3; ^ --- diff --git a/tests/dmd/fail_compilation/biterrors6.d b/tests/dmd/fail_compilation/biterrors6.d new file mode 100644 index 0000000000..d10c1e1b21 --- /dev/null +++ b/tests/dmd/fail_compilation/biterrors6.d @@ -0,0 +1,24 @@ +/* REQUIRED_ARGS: -verrors=context + * TEST_OUTPUT: +--- +fail_compilation/biterrors6.d(20): Error: anonymous bitfield cannot be of non-integral type `noreturn` + noreturn : -1; + ^ +fail_compilation/biterrors6.d(21): Error: anonymous bitfield has negative width `-1` + int : -1; + ^ +fail_compilation/biterrors6.d(22): Error: bitfield `n` cannot be of non-integral type `noreturn` + noreturn n : -500; + ^ +fail_compilation/biterrors6.d(23): Error: bitfield `i` has negative width `-500` + int i : -500; + ^ +--- +*/ +struct S +{ + noreturn : -1; + int : -1; + noreturn n : -500; + int i : -500; +} diff --git a/tests/dmd/fail_compilation/biterrors7.d b/tests/dmd/fail_compilation/biterrors7.d new file mode 100644 index 0000000000..2ecb91530d --- /dev/null +++ b/tests/dmd/fail_compilation/biterrors7.d @@ -0,0 +1,15 @@ +/* REQUIRED_ARGS: -verrors=context + * TEST_OUTPUT: +--- +fail_compilation/biterrors7.d(14): Error: struct `biterrors7.S` cannot have anonymous field with same struct type + S : S(); + ^ +fail_compilation/biterrors7.d(14): Error: anonymous bitfield cannot be of non-integral type `S` + S : S(); + ^ +--- +*/ +struct S +{ + S : S(); +} diff --git a/tests/dmd/fail_compilation/bitfields2.c b/tests/dmd/fail_compilation/bitfields2.c index e9f644ba46..3f6977b23a 100644 --- a/tests/dmd/fail_compilation/bitfields2.c +++ b/tests/dmd/fail_compilation/bitfields2.c @@ -1,8 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/bitfields2.c(103): Error: bitfield type `float` is not an integer type +fail_compilation/bitfields2.c(103): Error: bitfield `a` cannot be of non-integral type `float` fail_compilation/bitfields2.c(104): Error: bitfield width `3.0` is not an integer constant -fail_compilation/bitfields2.c(105): Error: bitfield `c` has zero width +fail_compilation/bitfields2.c(105): Error: bitfield `c` cannot have zero width fail_compilation/bitfields2.c(106): Error: width `60` of bitfield `d` does not fit in type `int` --- */ diff --git a/tests/dmd/fail_compilation/fail20779.d b/tests/dmd/fail_compilation/fail20779.d index 945803d53f..7b3b07af1e 100644 --- a/tests/dmd/fail_compilation/fail20779.d +++ b/tests/dmd/fail_compilation/fail20779.d @@ -3,7 +3,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail20779.d(12): Error: struct `fail20779.X` cannot have field `x` with same struct type +fail_compilation/fail20779.d(14): Error: struct `fail20779.X` cannot have field `x` with same struct type --- */ diff --git a/tests/dmd/fail_compilation/fail22384.d b/tests/dmd/fail_compilation/fail22384.d index 898aef59b3..71881f4193 100644 --- a/tests/dmd/fail_compilation/fail22384.d +++ b/tests/dmd/fail_compilation/fail22384.d @@ -1,20 +1,24 @@ /* TEST_OUTPUT: --- -fail_compilation/fail22384.d(32): Error: bitfield `z` has zero width -fail_compilation/fail22384.d(36): Error: bitfield type `float` is not an integer type -fail_compilation/fail22384.d(36): Error: bitfield `f` has zero width -fail_compilation/fail22384.d(37): Error: bitfield type `float` is not an integer type -fail_compilation/fail22384.d(38): Error: bitfield type `float` is not an integer type -fail_compilation/fail22384.d(39): Error: bitfield type `float` is not an integer type -fail_compilation/fail22384.d(44): Error: anonymous bitfield cannot have default initializer -fail_compilation/fail22384.d(21): Error: bitfield initializer `4294967295u` does not fit in 4 bits -fail_compilation/fail22384.d(26): Error: bitfield initializer `E.B` does not fit in 2 bits -fail_compilation/fail22384.d(30): Error: bitfield initializer `4` does not fit in 3 bits -fail_compilation/fail22384.d(31): Error: bitfield initializer `65` does not fit in 7 bits -fail_compilation/fail22384.d(43): Error: cannot implicitly convert expression `4.2F` of type `float` to `int` -fail_compilation/fail22384.d(45): Error: bitfield initializer `65` does not fit in 7 bits -fail_compilation/fail22384.d(46): Error: cannot implicitly convert expression `42` of type `int` to `bool` +fail_compilation/fail22384.d(36): Error: bitfield `z` cannot have zero width +fail_compilation/fail22384.d(40): Error: bitfield `f` cannot be of non-integral type `float` +fail_compilation/fail22384.d(41): Error: bitfield `f2` cannot be of non-integral type `float` +fail_compilation/fail22384.d(42): Error: bitfield `f3` cannot be of non-integral type `float` +fail_compilation/fail22384.d(43): Error: bitfield `f4` cannot be of non-integral type `float` +fail_compilation/fail22384.d(48): Error: anonymous bitfield cannot have default initializer +fail_compilation/fail22384.d(25): Error: default initializer `4294967295u` is not representable as bitfield type `uint:4` +fail_compilation/fail22384.d(25): bitfield `d` default initializer must be a value between `0..15` +fail_compilation/fail22384.d(30): Error: default initializer `E.B` is not representable as bitfield type `int:2` +fail_compilation/fail22384.d(30): bitfield `b` default initializer must be a value between `-2..1` +fail_compilation/fail22384.d(34): Error: default initializer `4` is not representable as bitfield type `int:3` +fail_compilation/fail22384.d(34): bitfield `x` default initializer must be a value between `-4..3` +fail_compilation/fail22384.d(35): Error: default initializer `65` is not representable as bitfield type `int:7` +fail_compilation/fail22384.d(35): bitfield `y` default initializer must be a value between `-64..63` +fail_compilation/fail22384.d(47): Error: cannot implicitly convert expression `4.2F` of type `float` to `int` +fail_compilation/fail22384.d(49): Error: default initializer `65` is not representable as bitfield type `int:7` +fail_compilation/fail22384.d(49): bitfield `j` default initializer must be a value between `-64..63` +fail_compilation/fail22384.d(50): Error: cannot implicitly convert expression `42` of type `int` to `bool` --- */ struct S { diff --git a/tests/dmd/fail_compilation/fail8691.d b/tests/dmd/fail_compilation/fail8691.d index 8e46023d3b..043039911f 100644 --- a/tests/dmd/fail_compilation/fail8691.d +++ b/tests/dmd/fail_compilation/fail8691.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail8691.d(7): Error: struct `fail8691.Foo` cannot have field `f` with static array of same struct type +fail_compilation/fail8691.d(9): Error: struct `fail8691.Foo` cannot have field `f` with static array of same struct type --- */ struct Foo From 6ec1b0506f82adfee5fd1e1f4444db1f5cf625a0 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Thu, 22 Jan 2026 17:27:08 -0800 Subject: [PATCH 293/440] SIMD not supported on AArch64 yet (dlang/dmd!22440) --- dmd/target.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dmd/target.d b/dmd/target.d index ead2c7d46f..8fdda4d356 100644 --- a/dmd/target.d +++ b/dmd/target.d @@ -171,7 +171,7 @@ void addPredefinedGlobalIdentifiers(const ref Target tgt) import dmd.cond : VersionCondition; alias predef = VersionCondition.addPredefinedGlobalIdent; - if (tgt.cpu >= CPU.sse2) + if ((tgt.isX86_64 || tgt.isX86) && tgt.cpu >= CPU.sse2) { predef("D_SIMD"); if (tgt.cpu >= CPU.avx) @@ -1351,7 +1351,7 @@ extern (C++) struct Target */ extern (D) bool isXmmSupported() @safe { - return (isX86_64 || isAArch64) || (isX86 && os == Target.OS.OSX); + return (isX86_64 /*|| isAArch64*/) || (isX86 && os == Target.OS.OSX); } /** From ac2d62867af12a06fa92632eda9bd19cdbe5d801 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Fri, 23 Jan 2026 13:19:54 +0000 Subject: [PATCH 294/440] Disallow discarding an assignment to a struct rvalue (dlang/dmd!22369) Error applies when struct has no pointer fields. (This could be tightened to apply when a pointer field is not tail mutable). My plan is to enable this for the 2024 edition, as it can break a user-defined op overload which has a (non-pointer) field but mutates a global. That should be a rare case and the compiler suggests workarounds. Note that requiring weak purity (for e.g. `opAssign`) would mean the error wouldn't detect bug-prone cases that aren't marked/inferred pure. Require 2024 edition for error --- dmd/expression.d | 1 + dmd/expressionsem.d | 42 +++++-------- dmd/frontend.h | 1 + dmd/sideeffect.d | 17 +++++ .../fail_compilation/struct_rvalue_assign.d | 62 +++++++++++++++++++ 5 files changed, 98 insertions(+), 25 deletions(-) create mode 100644 tests/dmd/fail_compilation/struct_rvalue_assign.d diff --git a/dmd/expression.d b/dmd/expression.d index 097769bb60..f5fbf805de 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -2363,6 +2363,7 @@ extern (C++) final class CallExp : UnaExp bool inDebugStatement; /// true if this was in a debug statement bool ignoreAttributes; /// don't enforce attributes (e.g. call @gc function in @nogc code) bool isUfcsRewrite; /// the first argument was pushed in here by a UFCS rewrite + bool fromOpAssignment; // set when operator overload method call from assignment (2024 edition) VarDeclaration vthis2; // container for multi-context Expression loweredFrom; // set if this is the result of a lowering diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index fef1a40bdc..3dec8c5e74 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -5301,6 +5301,17 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor setError(); } + // `e` calls opAssign, opOpAssign, opUnary!++, opUnary!-- when lowered from an assignment + private void setOpOverloadAssign(Expression e) + { + result = e; + auto ce = e.isCallExp(); + // rvalue error in discardValue from 2024 edition + if (!ce || !sc.hasEdition(Edition.v2024)) + return; + ce.fromOpAssignment = true; + } + /************************** * Semantically analyze Expression. * Determine types, fold constants, etc. @@ -9171,10 +9182,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { if (Expression e = exp.opOverloadBinaryAssign(sc, aliasThisStop)) - { - result = e; - return; - } + return setOpOverloadAssign(e); Expression e; if (exp.e1.op == EXP.arrayLength) @@ -11811,10 +11819,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor // printf("PreExp::semantic('%s')\n", toChars()); if (Expression e = exp.opOverloadUnary(sc)) - { - result = e; - return; - } + return setOpOverloadAssign(e); // Rewrite as e1+=1 or e1-=1 Expression e; @@ -12554,10 +12559,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor else if (exp.op == EXP.assign) { if (Expression e = exp.isAssignExp().opOverloadAssign(sc, aliasThisStop)) - { - result = e; - return; - } + return setOpOverloadAssign(e); } else assert(exp.op == EXP.blit); @@ -12574,10 +12576,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (exp.op == EXP.assign && !exp.e2.implicitConvTo(exp.e1.type)) { if (Expression e = exp.isAssignExp().opOverloadAssign(sc, aliasThisStop)) - { - result = e; - return; - } + return setOpOverloadAssign(e); } if (exp.e2.checkValue()) return setError(); @@ -13242,10 +13241,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor override void visit(PowAssignExp exp) { if (Expression e = exp.opOverloadBinaryAssign(sc, aliasThisStop)) - { - result = e; - return; - } + return setOpOverloadAssign(e); if (exp.suggestOpOpAssign(sc, parent) || exp.e1.checkReadModifyWrite(exp.op, exp.e2)) @@ -13319,13 +13315,9 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor override void visit(CatAssignExp exp) { - //printf("CatAssignExp::semantic() %s\n", exp.toChars()); if (Expression e = exp.opOverloadBinaryAssign(sc, aliasThisStop)) - { - result = e; - return; - } + return setOpOverloadAssign(e); if (exp.suggestOpOpAssign(sc, parent)) return setError(); diff --git a/dmd/frontend.h b/dmd/frontend.h index 17cd86e1c7..0b32ea3ecd 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -2594,6 +2594,7 @@ class CallExp final : public UnaExp bool inDebugStatement; bool ignoreAttributes; bool isUfcsRewrite; + bool fromOpAssignment; VarDeclaration* vthis2; Expression* loweredFrom; static CallExp* create(Loc loc, Expression* e, Array* exps); diff --git a/dmd/sideeffect.d b/dmd/sideeffect.d index e7d54d917a..2e579972d3 100644 --- a/dmd/sideeffect.d +++ b/dmd/sideeffect.d @@ -258,6 +258,23 @@ bool discardValue(Expression e) error(e.loc, "discarded assignment to indexed array literal"); } } + // check assignment to struct rvalue + auto ce = e.isCallExp(); + if (ce && ce.fromOpAssignment) + { + if (auto dve = ce.e1.isDotVarExp()) + { + auto lhs = dve.e1; + auto ts = lhs.type.isTypeStruct(); + if (ts && !lhs.isLvalue() && !ts.sym.hasPointerField) // Don't disallow writing to data through a pointer field + { + error(lhs.loc, "assignment to struct rvalue `%s` is discarded", + lhs.toChars()); + errorSupplemental(e.loc, "if the assignment is needed to modify a global, call `%s` directly or use an lvalue", + dve.var.toChars()); + } + } + } return false; } switch (e.op) diff --git a/tests/dmd/fail_compilation/struct_rvalue_assign.d b/tests/dmd/fail_compilation/struct_rvalue_assign.d new file mode 100644 index 0000000000..4245176864 --- /dev/null +++ b/tests/dmd/fail_compilation/struct_rvalue_assign.d @@ -0,0 +1,62 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/struct_rvalue_assign.d(16): Error: assignment to struct rvalue `foo()` is discarded +fail_compilation/struct_rvalue_assign.d(16): if the assignment is needed to modify a global, call `opAssign` directly or use an lvalue +fail_compilation/struct_rvalue_assign.d(17): Error: assignment to struct rvalue `foo()` is discarded +fail_compilation/struct_rvalue_assign.d(17): if the assignment is needed to modify a global, call `opOpAssign` directly or use an lvalue +fail_compilation/struct_rvalue_assign.d(18): Error: assignment to struct rvalue `foo()` is discarded +fail_compilation/struct_rvalue_assign.d(18): if the assignment is needed to modify a global, call `opUnary` directly or use an lvalue +--- +*/ +module sra 2024; + +void main() +{ + foo() = S.init; + foo() += 5; + ++foo(); + *foo(); // other unary ops may be OK + + // allowed + foo().opAssign(S.init); + foo().opOpAssign!"+"(5); + foo().opUnary!"++"(); +} + +S foo() => S.init; + +struct S +{ + int i; + + void opAssign(S s); + void opOpAssign(string op : "+")(int); + void opUnary(string op : "++")(); + void opUnary(string op : "*")(); +} + +void test() +{ + int i; + + static struct Ptr + { + int* p; + void opAssign(int rhs) { *p = rhs; } + } + Ptr(&i) = 1; // allowed + + struct Nested + { + void opAssign(int rhs) { i = rhs; } + } + Nested() = 1; // allowed + + static struct StaticOp + { + static si = 0; + static void opAssign(int rhs) { si = rhs; } + } + StaticOp() = 1; // allowed +} From 8f60ad45146b505bf63eba9be4d537b25fdf8ce4 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Fri, 23 Jan 2026 21:16:31 +0000 Subject: [PATCH 295/440] `__traits(isSame, Object, const Object)` should not be true (dlang/dmd!22443) --- dmd/traits.d | 4 ++-- tests/dmd/compilable/b12001.d | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dmd/traits.d b/dmd/traits.d index 5867480633..ecb38c660c 100644 --- a/dmd/traits.d +++ b/dmd/traits.d @@ -2242,8 +2242,8 @@ private bool isSame(RootObject o1, RootObject o2, Scope* sc) // https://issues.dlang.org/show_bug.cgi?id=12001, allow isSame, , Type t1 = isType(o1); Type t2 = isType(o2); - if (t1 && t2 && t1.equals(t2)) - return true; + if (t1 && t2) + return t1.equals(t2); auto s1 = getDsymbol(o1); auto s2 = getDsymbol(o2); diff --git a/tests/dmd/compilable/b12001.d b/tests/dmd/compilable/b12001.d index f67c895751..c3ef089627 100644 --- a/tests/dmd/compilable/b12001.d +++ b/tests/dmd/compilable/b12001.d @@ -6,4 +6,8 @@ void main() static assert(!__traits(isSame, bool*, bool[])); static assert(!__traits(isSame, float, double)); + + // https://github.com/dlang/dmd/issues/22442 + static assert(!__traits(isSame, int, const int)); + static assert(!__traits(isSame, Object, const Object)); } From 643f38d3c85a8d0e94e26d12d14d5591d67e3126 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Mon, 26 Jan 2026 08:47:16 +0800 Subject: [PATCH 296/440] Don't emit REP MOVSQ/STOSQ on x64 (dlang/dmd!22449) * Don't emit REP STOSQ * Fix streq too --- tests/dmd/compilable/issue22448.d | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/dmd/compilable/issue22448.d diff --git a/tests/dmd/compilable/issue22448.d b/tests/dmd/compilable/issue22448.d new file mode 100644 index 0000000000..6fa23f80db --- /dev/null +++ b/tests/dmd/compilable/issue22448.d @@ -0,0 +1,8 @@ +// PERMUTE_ARGS: -O + +void sliceAssign() +{ + enum size_t len = 2_147_483_648UL; + char* src, dst; + dst[0 .. len] = src[0 .. len]; +} From 71e756d425529e0fcf8cae4b244bcbcca0b66519 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sun, 25 Jan 2026 20:08:41 -0800 Subject: [PATCH 297/440] remove rt/memset.d's dependency on rt/util/utility.d (dlang/dmd!22455) --- runtime/druntime/src/rt/memset.d | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/runtime/druntime/src/rt/memset.d b/runtime/druntime/src/rt/memset.d index 9a0cd5f595..e583ea8fde 100644 --- a/runtime/druntime/src/rt/memset.d +++ b/runtime/druntime/src/rt/memset.d @@ -1,21 +1,14 @@ /** * Contains a memset implementation used by compiler-generated code. * - * Copyright: Copyright Digital Mars 2004 - 2010. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). + * Copyright: Copyright Digital Mars 2004 - 2026 + * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Authors: Walter Bright * Source: $(DRUNTIMESRC rt/_memset.d) */ -/* Copyright Digital Mars 2004 - 2010. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ module rt.memset; -import rt.util.utility : d_cdouble, d_creal; - extern (C) { // Functions from the C library. @@ -70,6 +63,8 @@ long *_memset64(long *p, long value, size_t count) return pstart; } +struct d_cdouble { double re, im; } + d_cdouble *_memset128(d_cdouble *p, d_cdouble value, size_t count) { d_cdouble *pstart = p; @@ -100,6 +95,8 @@ real *_memset80(real *p, real value, size_t count) return pstart; } +struct d_creal { real re, im; } + d_creal *_memset160(d_creal *p, d_creal value, size_t count) { d_creal *pstart = p; From 0679d38ded816120665e8f89cfb0cce5ad2ee28b Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Mon, 26 Jan 2026 16:25:23 +0100 Subject: [PATCH 298/440] arm64: Fix alignment of structs with only zero sized fields (dlang/dmd!22445) --- dmd/dsymbolsem.d | 18 +++- dmd/target.d | 2 +- tests/dmd/compilable/zerosize2.d | 178 +++++++++++++++++++++++++++++++ 3 files changed, 195 insertions(+), 3 deletions(-) create mode 100644 tests/dmd/compilable/zerosize2.d diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index c36cea2d6a..5beee82a0b 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -9987,16 +9987,30 @@ private extern(C++) class FinalizeSizeVisitor : Visitor if (sd.structsize == 0) { sd.hasNoFields = true; - sd.alignsize = 1; + + // alignsize has already been set when the struct consists only of + // zero sized fields. + if (sd.alignsize == 0) + sd.alignsize = 1; // A fine mess of what size a zero sized struct should be final switch (sd.classKind) { case ClassKind.d: - case ClassKind.cpp: sd.structsize = 1; break; + case ClassKind.cpp: + if (sd.fields.length == 0 || + target.c.bitFieldStyle == TargetC.BitFieldStyle.MS) + { + // Give struct a size when there's no named fields + sd.structsize = 1; + } + else + sd.structsize = 0; + break; + case ClassKind.c: case ClassKind.objc: if (target.c.bitFieldStyle == TargetC.BitFieldStyle.MS) diff --git a/dmd/target.d b/dmd/target.d index 8fdda4d356..848844e6ed 100644 --- a/dmd/target.d +++ b/dmd/target.d @@ -1491,7 +1491,7 @@ struct TargetC if (bitFieldStyle == BitFieldStyle.Gcc_Clang) { // sufficient for DMD's currently supported architectures - return !bfd.isAnonymous(); + return !bfd.isAnonymous() || target.isAArch64; } assert(0); } diff --git a/tests/dmd/compilable/zerosize2.d b/tests/dmd/compilable/zerosize2.d new file mode 100644 index 0000000000..8f418dc4f4 --- /dev/null +++ b/tests/dmd/compilable/zerosize2.d @@ -0,0 +1,178 @@ +// Test zero sized fields where TargetC.contributesToAlignment +extern(D) +{ + struct D0 { } + struct D1 { byte : 0; } + struct D2 { short : 0; } + struct D3 { int : 0; } + struct D4 { long : 0; } + struct D5 { byte[0] f; } + struct D6 { short[0] f; } + struct D7 { int[0] f; } + struct D8 { long[0] f; } + struct D9 { int : 0; short[0] f; } + align(16) + { + struct D10 { } + struct D11 { byte : 0; } + struct D12 { short : 0; } + struct D13 { int : 0; } + struct D14 { long : 0; } + struct D15 { byte[0] f; } + struct D16 { short[0] f; } + struct D17 { int[0] f; } + struct D18 { long[0] f; } + struct D19 { int : 0; short[0] f; } + } +} + +extern(C) +{ + struct C0 { } + struct C1 { byte : 0; } + struct C2 { short : 0; } + struct C3 { int : 0; } + struct C4 { long : 0; } + struct C5 { byte[0] f; } + struct C6 { short[0] f; } + struct C7 { int[0] f; } + struct C8 { long[0] f; } + struct C9 { int : 0; short[0] f; } + align(16) + { + struct C10 { } + struct C11 { byte : 0; } + struct C12 { short : 0; } + struct C13 { int : 0; } + struct C14 { long : 0; } + struct C15 { byte[0] f; } + struct C16 { short[0] f; } + struct C17 { int[0] f; } + struct C18 { long[0] f; } + struct C19 { int : 0; short[0] f; } + } +} + +version (Posix): + +// Anonymous bitfields don't contribute to alignment. +version (X86_64) +{ + // Empty + static assert(D0.sizeof == 1 && D0.alignof == 1); + static assert(D10.sizeof == 16 && D10.alignof == 16); + + // Zero width bitfields + static assert(D1.sizeof == 1 && D1.alignof == 1); + static assert(D2.sizeof == 1 && D2.alignof == 1); + static assert(D3.sizeof == 1 && D3.alignof == 1); + static assert(D4.sizeof == 1 && D4.alignof == 1); + static assert(D11.sizeof == 16 && D11.alignof == 16); + static assert(D12.sizeof == 16 && D12.alignof == 16); + static assert(D13.sizeof == 16 && D13.alignof == 16); + static assert(D14.sizeof == 16 && D14.alignof == 16); + + // Zero sized arrays + static assert(D5.sizeof == 1 && D5.alignof == 1); + static assert(D6.sizeof == 2 && D6.alignof == 2); + static assert(D7.sizeof == 4 && D7.alignof == 4); + static assert(D8.sizeof == 8 && D8.alignof == 8); + static assert(D15.sizeof == 16 && D15.alignof == 16); + static assert(D16.sizeof == 16 && D16.alignof == 16); + static assert(D17.sizeof == 16 && D17.alignof == 16); + static assert(D18.sizeof == 16 && D18.alignof == 16); + + // Mixed zero sized bitfields and arrays + static assert(D9.sizeof == 2 && D9.alignof == 2); + static assert(D19.sizeof == 16 && D19.alignof == 16); + + // Empty + static assert(C0.sizeof == 0 && C0.alignof == 1); + static assert(C10.sizeof == 0 && C10.alignof == 16); + + // Zero width bitfields + static assert(C1.sizeof == 0 && C1.alignof == 1); + static assert(C2.sizeof == 0 && C2.alignof == 1); + static assert(C3.sizeof == 0 && C3.alignof == 1); + static assert(C4.sizeof == 0 && C4.alignof == 1); + static assert(C11.sizeof == 0 && C11.alignof == 16); + static assert(C12.sizeof == 0 && C12.alignof == 16); + static assert(C13.sizeof == 0 && C13.alignof == 16); + static assert(C14.sizeof == 0 && C14.alignof == 16); + + // Zero sized arrays + static assert(C5.sizeof == 0 && C5.alignof == 1); + static assert(C6.sizeof == 0 && C6.alignof == 2); + static assert(C7.sizeof == 0 && C7.alignof == 4); + static assert(C8.sizeof == 0 && C8.alignof == 8); + static assert(C15.sizeof == 0 && C15.alignof == 16); + static assert(C16.sizeof == 0 && C16.alignof == 16); + static assert(C17.sizeof == 0 && C17.alignof == 16); + static assert(C18.sizeof == 0 && C18.alignof == 16); + + // Mixed zero sized bitfields and arrays + static assert(C9.sizeof == 0 && C9.alignof == 2); + static assert(C19.sizeof == 0 && C19.alignof == 16); +} + +// Anonymous bitfields *do* contribute to alignment. +version (AArch64) +{ + // Empty + static assert(D0.sizeof == 1 && D0.alignof == 1); + static assert(D10.sizeof == 16 && D10.alignof == 16); + + // Zero width bitfields + static assert(D1.sizeof == 1 && D1.alignof == 1); + static assert(D2.sizeof == 2 && D2.alignof == 2); + static assert(D3.sizeof == 4 && D3.alignof == 4); + static assert(D4.sizeof == 8 && D4.alignof == 8); + static assert(D11.sizeof == 16 && D11.alignof == 16); + static assert(D12.sizeof == 16 && D12.alignof == 16); + static assert(D13.sizeof == 16 && D13.alignof == 16); + static assert(D14.sizeof == 16 && D14.alignof == 16); + + // Zero sized arrays + static assert(D5.sizeof == 1 && D5.alignof == 1); + static assert(D6.sizeof == 2 && D6.alignof == 2); + static assert(D7.sizeof == 3 && D7.alignof == 4); + static assert(D8.sizeof == 4 && D8.alignof == 8); + static assert(D15.sizeof == 16 && D15.alignof == 16); + static assert(D16.sizeof == 16 && D16.alignof == 16); + static assert(D17.sizeof == 16 && D17.alignof == 16); + static assert(D18.sizeof == 16 && D18.alignof == 16); + + // Mixed zero sized bitfields and arrays + static assert(D9.sizeof == 4 && D9.alignof == 4); + static assert(D19.sizeof == 16 && D19.alignof == 16); + + /// extern(C): + + // Empty + static assert(C0.sizeof == 0 && C0.alignof == 1); + static assert(C10.sizeof == 0 && C10.alignof == 16); + + // Zero width bitfields + static assert(C1.sizeof == 0 && C1.alignof == 1); + static assert(C2.sizeof == 0 && C2.alignof == 2); + static assert(C3.sizeof == 0 && C3.alignof == 4); + static assert(C4.sizeof == 0 && C4.alignof == 8); + static assert(C11.sizeof == 0 && C11.alignof == 16); + static assert(C12.sizeof == 0 && C12.alignof == 16); + static assert(C13.sizeof == 0 && C13.alignof == 16); + static assert(C14.sizeof == 0 && C14.alignof == 16); + + // Zero sized arrays + static assert(C5.sizeof == 0 && C5.alignof == 1); + static assert(C6.sizeof == 0 && C6.alignof == 2); + static assert(C7.sizeof == 0 && C7.alignof == 4); + static assert(C8.sizeof == 0 && C8.alignof == 8); + static assert(C15.sizeof == 0 && C15.alignof == 16); + static assert(C16.sizeof == 0 && C16.alignof == 16); + static assert(C17.sizeof == 0 && C17.alignof == 16); + static assert(C18.sizeof == 0 && C18.alignof == 16); + + // Mixed zero sized bitfields and arrays + static assert(C9.sizeof == 0 && C9.alignof == 4); + static assert(C19.sizeof == 0 && C19.alignof == 16); +} From 8d0ff32cdfbfac2c77dbc15d0c7c2bd8ba3f57bc Mon Sep 17 00:00:00 2001 From: limepoutine Date: Thu, 22 Jan 2026 11:40:14 +0800 Subject: [PATCH 299/440] Remove backend optimization converting call to jmp --- tests/dmd/runnable/test22427.d | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/dmd/runnable/test22427.d b/tests/dmd/runnable/test22427.d index 7b7b5f1b9a..15d9fc0037 100644 --- a/tests/dmd/runnable/test22427.d +++ b/tests/dmd/runnable/test22427.d @@ -1,5 +1,15 @@ // https://github.com/dlang/dmd/issues/22427 +noreturn exit1() +{ + throw new Exception("exit(1)"); +} + +noreturn exit0() +{ + throw new Exception("exit(0)"); +} + void main() { try @@ -15,4 +25,16 @@ void main() { assert(e.message == "exit(0)"); } + + try + { + scope exitProgram = (bool failure) @trusted { + return failure ? exit1() : exit0(); + }; + exitProgram(false); + } + catch (Exception e) + { + assert(e.message == "exit(0)"); + } } From 2c288730267163ed3d34f6e92537bdf459a4dd41 Mon Sep 17 00:00:00 2001 From: Dennis Korpel Date: Tue, 9 Dec 2025 16:45:51 +0100 Subject: [PATCH 300/440] Fix diff-based AUTO_UPDATE for Windows --- tests/dmd/tools/d_do_test.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dmd/tools/d_do_test.d b/tests/dmd/tools/d_do_test.d index 7d7cb879bd..497cdf8d41 100755 --- a/tests/dmd/tools/d_do_test.d +++ b/tests/dmd/tools/d_do_test.d @@ -1992,7 +1992,7 @@ int tryMain(string[] args) { try { - string diffUpdatedText = replaceFromDiff(existingText, ce.diff); + string diffUpdatedText = replaceFromDiff(existingText, ce.diff.unifyDirSep("/")); std.file.write(input_file, diffUpdatedText); writefln("\n==> `%s_OUTPUT` of %s has been updated by applying a diff", type, input_file); return Result.returnRerun; From 8c4ca64f71b42d9f665e2a48cbef3654e04a80ad Mon Sep 17 00:00:00 2001 From: Dennis Korpel Date: Tue, 27 Jan 2026 11:25:36 +0100 Subject: [PATCH 301/440] Add supplemental location message for deprecated symbols --- dmd/dsymbolsem.d | 2 + tests/dmd/compilable/depmsg.d | 39 ++++++++---- tests/dmd/compilable/deprecationlimit.d | 9 ++- tests/dmd/compilable/diag20916.d | 3 + tests/dmd/compilable/test9701.d | 6 +- tests/dmd/fail_compilation/cdeprecated.i | 12 ++-- tests/dmd/fail_compilation/depmsg.d | 60 ++++++++++++------- tests/dmd/fail_compilation/depmsg15814.d | 3 +- tests/dmd/fail_compilation/depmsg15815.d | 3 +- .../dmd/fail_compilation/deprecatedImports.d | 21 ++++--- .../fail_compilation/deprecatedTemplates.d | 4 ++ tests/dmd/fail_compilation/deprecations.d | 15 +++-- tests/dmd/fail_compilation/diag14875.d | 27 +++++---- tests/dmd/fail_compilation/diag14876.d | 23 ++++--- tests/dmd/fail_compilation/fail19202.d | 3 +- tests/dmd/fail_compilation/fail199.d | 6 +- tests/dmd/fail_compilation/fail200.d | 6 +- tests/dmd/fail_compilation/fail21830.d | 3 + tests/dmd/fail_compilation/fail21831.d | 3 + tests/dmd/fail_compilation/fail21832.d | 2 + tests/dmd/fail_compilation/fail23822.d | 3 +- tests/dmd/fail_compilation/fail23826.d | 3 +- tests/dmd/fail_compilation/fail243.d | 15 +++-- tests/dmd/fail_compilation/fail244.d | 30 ++++++---- tests/dmd/fail_compilation/fail245.d | 30 ++++++---- tests/dmd/fail_compilation/ice11822.d | 9 +-- tests/dmd/fail_compilation/test19193.d | 3 +- tests/dmd/fail_compilation/test20515.d | 5 +- tests/dmd/fail_compilation/test21259.d | 12 ++-- tests/dmd/fail_compilation/test23968.d | 3 +- tests/dmd/fail_compilation/test9701b.d | 6 +- 31 files changed, 247 insertions(+), 122 deletions(-) diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 5beee82a0b..7ad2c2172f 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -1613,6 +1613,8 @@ bool checkDeprecated(Dsymbol d, Loc loc, Scope* sc) else deprecation(loc, "%s `%s` is deprecated", d.kind, d.toPrettyChars); + deprecationSupplemental(d.loc, "`%s` is declared here", d.toErrMsg); + if (auto ti = sc.parent ? sc.parent.isInstantiated() : null) ti.printInstantiationTrace(Classification.deprecation); else if (auto ti = sc.parent ? sc.parent.isTemplateInstance() : null) diff --git a/tests/dmd/compilable/depmsg.d b/tests/dmd/compilable/depmsg.d index 2c29e05a58..ed90a62c72 100644 --- a/tests/dmd/compilable/depmsg.d +++ b/tests/dmd/compilable/depmsg.d @@ -2,19 +2,32 @@ REQUIRED_ARGS: -verrors=simple -dw TEST_OUTPUT: --- -compilable/depmsg.d(39): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message! -compilable/depmsg.d(39): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message! -compilable/depmsg.d(40): Deprecation: class `depmsg.main.Inner.B` is deprecated - With message! -compilable/depmsg.d(40): Deprecation: class `depmsg.main.Inner.B` is deprecated - With message! -compilable/depmsg.d(41): Deprecation: interface `depmsg.main.Inner.C` is deprecated - With message! -compilable/depmsg.d(41): Deprecation: interface `depmsg.main.Inner.C` is deprecated - With message! -compilable/depmsg.d(42): Deprecation: union `depmsg.main.Inner.D` is deprecated - With message! -compilable/depmsg.d(42): Deprecation: union `depmsg.main.Inner.D` is deprecated - With message! -compilable/depmsg.d(43): Deprecation: enum `depmsg.main.Inner.E` is deprecated - With message! -compilable/depmsg.d(43): Deprecation: enum `depmsg.main.Inner.E` is deprecated - With message! -compilable/depmsg.d(45): Deprecation: alias `depmsg.main.Inner.G` is deprecated - With message! -compilable/depmsg.d(46): Deprecation: variable `depmsg.main.Inner.H` is deprecated - With message! -compilable/depmsg.d(47): Deprecation: class `depmsg.main.Inner.I()` is deprecated - With message! +compilable/depmsg.d(52): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message! +compilable/depmsg.d(39): `A` is declared here +compilable/depmsg.d(52): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message! +compilable/depmsg.d(39): `A` is declared here +compilable/depmsg.d(53): Deprecation: class `depmsg.main.Inner.B` is deprecated - With message! +compilable/depmsg.d(40): `B` is declared here +compilable/depmsg.d(53): Deprecation: class `depmsg.main.Inner.B` is deprecated - With message! +compilable/depmsg.d(40): `B` is declared here +compilable/depmsg.d(54): Deprecation: interface `depmsg.main.Inner.C` is deprecated - With message! +compilable/depmsg.d(41): `C` is declared here +compilable/depmsg.d(54): Deprecation: interface `depmsg.main.Inner.C` is deprecated - With message! +compilable/depmsg.d(41): `C` is declared here +compilable/depmsg.d(55): Deprecation: union `depmsg.main.Inner.D` is deprecated - With message! +compilable/depmsg.d(42): `D` is declared here +compilable/depmsg.d(55): Deprecation: union `depmsg.main.Inner.D` is deprecated - With message! +compilable/depmsg.d(42): `D` is declared here +compilable/depmsg.d(56): Deprecation: enum `depmsg.main.Inner.E` is deprecated - With message! +compilable/depmsg.d(43): `E` is declared here +compilable/depmsg.d(56): Deprecation: enum `depmsg.main.Inner.E` is deprecated - With message! +compilable/depmsg.d(43): `E` is declared here +compilable/depmsg.d(58): Deprecation: alias `depmsg.main.Inner.G` is deprecated - With message! +compilable/depmsg.d(45): `G` is declared here +compilable/depmsg.d(59): Deprecation: variable `depmsg.main.Inner.H` is deprecated - With message! +compilable/depmsg.d(46): `H` is declared here +compilable/depmsg.d(60): Deprecation: class `depmsg.main.Inner.I()` is deprecated - With message! +compilable/depmsg.d(47): `I()` is declared here --- */ void main() diff --git a/tests/dmd/compilable/deprecationlimit.d b/tests/dmd/compilable/deprecationlimit.d index 2b7d45c393..f749d7ff32 100644 --- a/tests/dmd/compilable/deprecationlimit.d +++ b/tests/dmd/compilable/deprecationlimit.d @@ -2,9 +2,12 @@ REQUIRED_ARGS: -verrors=simple -verrors=3 TEST_OUTPUT: --- -compilable/deprecationlimit.d(18): Deprecation: function `deprecationlimit.f` is deprecated -compilable/deprecationlimit.d(19): Deprecation: function `deprecationlimit.f` is deprecated -compilable/deprecationlimit.d(20): Deprecation: function `deprecationlimit.f` is deprecated +compilable/deprecationlimit.d(21): Deprecation: function `deprecationlimit.f` is deprecated +compilable/deprecationlimit.d(15): `f` is declared here +compilable/deprecationlimit.d(22): Deprecation: function `deprecationlimit.f` is deprecated +compilable/deprecationlimit.d(15): `f` is declared here +compilable/deprecationlimit.d(23): Deprecation: function `deprecationlimit.f` is deprecated +compilable/deprecationlimit.d(15): `f` is declared here 1 deprecation warning omitted, use `-verrors=0` to show all --- */ diff --git a/tests/dmd/compilable/diag20916.d b/tests/dmd/compilable/diag20916.d index aa30c94fcf..a832132007 100644 --- a/tests/dmd/compilable/diag20916.d +++ b/tests/dmd/compilable/diag20916.d @@ -6,12 +6,15 @@ compilable/diag20916.d(32): Deprecation: `alias fb this` is deprecated compilable/diag20916.d(37): instantiated from here: `jump2!(Foo)` compilable/diag20916.d(42): instantiated from here: `jump1!(Foo)` compilable/diag20916.d(32): Deprecation: function `diag20916.FooBar.toString` is deprecated +compilable/diag20916.d(3): `toString` is declared here compilable/diag20916.d(37): instantiated from here: `jump2!(Foo)` compilable/diag20916.d(42): instantiated from here: `jump1!(Foo)` compilable/diag20916.d(32): Deprecation: template `diag20916.Bar.toString()() const` is deprecated +compilable/diag20916.d(15): `toString()() const` is declared here compilable/diag20916.d(37): instantiated from here: `jump2!(Bar)` compilable/diag20916.d(43): instantiated from here: `jump1!(Bar)` compilable/diag20916.d(21): Deprecation: variable `diag20916.Something.something` is deprecated +compilable/diag20916.d(28): `something` is declared here compilable/diag20916.d(24): instantiated from here: `nestedCheck!(Something)` --- */ diff --git a/tests/dmd/compilable/test9701.d b/tests/dmd/compilable/test9701.d index 81b56bdb65..39fd4da998 100644 --- a/tests/dmd/compilable/test9701.d +++ b/tests/dmd/compilable/test9701.d @@ -3,8 +3,10 @@ /* TEST_OUTPUT: --- -compilable/test9701.d(69): Deprecation: enum member `test9701.Enum.value7` is deprecated -compilable/test9701.d(69): Deprecation: enum member `test9701.Enum.value8` is deprecated - message +compilable/test9701.d(71): Deprecation: enum member `test9701.Enum.value7` is deprecated +compilable/test9701.d(36): `value7` is declared here +compilable/test9701.d(71): Deprecation: enum member `test9701.Enum.value8` is deprecated - message +compilable/test9701.d(37): `value8` is declared here --- */ diff --git a/tests/dmd/fail_compilation/cdeprecated.i b/tests/dmd/fail_compilation/cdeprecated.i index 75ce2acbe6..afad04453b 100644 --- a/tests/dmd/fail_compilation/cdeprecated.i +++ b/tests/dmd/fail_compilation/cdeprecated.i @@ -1,10 +1,14 @@ /* REQUIRED_ARGS: -de TEST_OUTPUT: --- -fail_compilation/cdeprecated.i(18): Deprecation: function `cdeprecated.mars` is deprecated -fail_compilation/cdeprecated.i(19): Deprecation: function `cdeprecated.jupiter` is deprecated - jumping jupiter -fail_compilation/cdeprecated.i(20): Deprecation: function `cdeprecated.saturn` is deprecated -fail_compilation/cdeprecated.i(21): Deprecation: function `cdeprecated.neptune` is deprecated - spinning neptune +fail_compilation/cdeprecated.i(22): Deprecation: function `cdeprecated.mars` is deprecated +fail_compilation/cdeprecated.i(14): `mars` is declared here +fail_compilation/cdeprecated.i(23): Deprecation: function `cdeprecated.jupiter` is deprecated - jumping jupiter +fail_compilation/cdeprecated.i(15): `jupiter` is declared here +fail_compilation/cdeprecated.i(24): Deprecation: function `cdeprecated.saturn` is deprecated +fail_compilation/cdeprecated.i(16): `saturn` is declared here +fail_compilation/cdeprecated.i(25): Deprecation: function `cdeprecated.neptune` is deprecated - spinning neptune +fail_compilation/cdeprecated.i(17): `neptune` is declared here --- */ __declspec(deprecated) int mars(); diff --git a/tests/dmd/fail_compilation/depmsg.d b/tests/dmd/fail_compilation/depmsg.d index b0c2b2e6a8..01437d1f73 100644 --- a/tests/dmd/fail_compilation/depmsg.d +++ b/tests/dmd/fail_compilation/depmsg.d @@ -2,19 +2,32 @@ /* TEST_OUTPUT: --- -fail_compilation/depmsg.d(40): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message! -fail_compilation/depmsg.d(40): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message! -fail_compilation/depmsg.d(41): Deprecation: class `depmsg.main.Inner.B` is deprecated - With message! -fail_compilation/depmsg.d(41): Deprecation: class `depmsg.main.Inner.B` is deprecated - With message! -fail_compilation/depmsg.d(42): Deprecation: interface `depmsg.main.Inner.C` is deprecated - With message! -fail_compilation/depmsg.d(42): Deprecation: interface `depmsg.main.Inner.C` is deprecated - With message! -fail_compilation/depmsg.d(43): Deprecation: union `depmsg.main.Inner.D` is deprecated - With message! -fail_compilation/depmsg.d(43): Deprecation: union `depmsg.main.Inner.D` is deprecated - With message! -fail_compilation/depmsg.d(44): Deprecation: enum `depmsg.main.Inner.E` is deprecated - With message! -fail_compilation/depmsg.d(44): Deprecation: enum `depmsg.main.Inner.E` is deprecated - With message! -fail_compilation/depmsg.d(46): Deprecation: alias `depmsg.main.Inner.G` is deprecated - With message! -fail_compilation/depmsg.d(47): Deprecation: variable `depmsg.main.Inner.H` is deprecated - With message! -fail_compilation/depmsg.d(48): Deprecation: class `depmsg.main.Inner.I()` is deprecated - With message! +fail_compilation/depmsg.d(53): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message! +fail_compilation/depmsg.d(40): `A` is declared here +fail_compilation/depmsg.d(53): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message! +fail_compilation/depmsg.d(40): `A` is declared here +fail_compilation/depmsg.d(54): Deprecation: class `depmsg.main.Inner.B` is deprecated - With message! +fail_compilation/depmsg.d(41): `B` is declared here +fail_compilation/depmsg.d(54): Deprecation: class `depmsg.main.Inner.B` is deprecated - With message! +fail_compilation/depmsg.d(41): `B` is declared here +fail_compilation/depmsg.d(55): Deprecation: interface `depmsg.main.Inner.C` is deprecated - With message! +fail_compilation/depmsg.d(42): `C` is declared here +fail_compilation/depmsg.d(55): Deprecation: interface `depmsg.main.Inner.C` is deprecated - With message! +fail_compilation/depmsg.d(42): `C` is declared here +fail_compilation/depmsg.d(56): Deprecation: union `depmsg.main.Inner.D` is deprecated - With message! +fail_compilation/depmsg.d(43): `D` is declared here +fail_compilation/depmsg.d(56): Deprecation: union `depmsg.main.Inner.D` is deprecated - With message! +fail_compilation/depmsg.d(43): `D` is declared here +fail_compilation/depmsg.d(57): Deprecation: enum `depmsg.main.Inner.E` is deprecated - With message! +fail_compilation/depmsg.d(44): `E` is declared here +fail_compilation/depmsg.d(57): Deprecation: enum `depmsg.main.Inner.E` is deprecated - With message! +fail_compilation/depmsg.d(44): `E` is declared here +fail_compilation/depmsg.d(59): Deprecation: alias `depmsg.main.Inner.G` is deprecated - With message! +fail_compilation/depmsg.d(46): `G` is declared here +fail_compilation/depmsg.d(60): Deprecation: variable `depmsg.main.Inner.H` is deprecated - With message! +fail_compilation/depmsg.d(47): `H` is declared here +fail_compilation/depmsg.d(61): Deprecation: class `depmsg.main.Inner.I()` is deprecated - With message! +fail_compilation/depmsg.d(48): `I()` is declared here --- */ @@ -52,13 +65,20 @@ void main() /* TEST_OUTPUT: --- -fail_compilation/depmsg.d(94): Deprecation: function `depmsg.test12954.Foo.bar1` is deprecated - [C] Use Foo.bar42 instead -fail_compilation/depmsg.d(95): Deprecation: function `depmsg.test12954.Foo.bar2` is deprecated - [E] Use Foo.bar42 instead -fail_compilation/depmsg.d(96): Deprecation: function `depmsg.test12954.Foo.bar3` is deprecated - [S] Use Foo.bar42 instead -fail_compilation/depmsg.d(97): Deprecation: function `depmsg.test12954.Foo.bar4` is deprecated - [F] Use Foo.bar42 instead -fail_compilation/depmsg.d(98): Deprecation: variable `depmsg.test12954.Foo.v2` is deprecated - Forward reference -fail_compilation/depmsg.d(105): Deprecation: class `depmsg.test12954.Obsolete` is deprecated -fail_compilation/depmsg.d(105): Deprecation: function `depmsg.test12954.Obsolete.obs` is deprecated - Function is obsolete +fail_compilation/depmsg.d(114): Deprecation: function `depmsg.test12954.Foo.bar1` is deprecated - [C] Use Foo.bar42 instead +fail_compilation/depmsg.d(98): `bar1` is declared here +fail_compilation/depmsg.d(115): Deprecation: function `depmsg.test12954.Foo.bar2` is deprecated - [E] Use Foo.bar42 instead +fail_compilation/depmsg.d(101): `bar2` is declared here +fail_compilation/depmsg.d(116): Deprecation: function `depmsg.test12954.Foo.bar3` is deprecated - [S] Use Foo.bar42 instead +fail_compilation/depmsg.d(104): `bar3` is declared here +fail_compilation/depmsg.d(117): Deprecation: function `depmsg.test12954.Foo.bar4` is deprecated - [F] Use Foo.bar42 instead +fail_compilation/depmsg.d(107): `bar4` is declared here +fail_compilation/depmsg.d(118): Deprecation: variable `depmsg.test12954.Foo.v2` is deprecated - Forward reference +fail_compilation/depmsg.d(109): `v2` is declared here +fail_compilation/depmsg.d(125): Deprecation: class `depmsg.test12954.Obsolete` is deprecated +fail_compilation/depmsg.d(120): `Obsolete` is declared here +fail_compilation/depmsg.d(125): Deprecation: function `depmsg.test12954.Obsolete.obs` is deprecated - Function is obsolete +fail_compilation/depmsg.d(122): `obs` is declared here --- */ void test12954() diff --git a/tests/dmd/fail_compilation/depmsg15814.d b/tests/dmd/fail_compilation/depmsg15814.d index 613576c256..19f49a2471 100644 --- a/tests/dmd/fail_compilation/depmsg15814.d +++ b/tests/dmd/fail_compilation/depmsg15814.d @@ -2,7 +2,8 @@ /* TEST_OUTPUT: --- -fail_compilation/depmsg15814.d(9): Deprecation: function `depmsg15814.get15814` is deprecated - bug15814 +fail_compilation/depmsg15814.d(10): Deprecation: function `depmsg15814.get15814` is deprecated - bug15814 +fail_compilation/depmsg15814.d(9): `get15814` is declared here --- */ deprecated("bug15814") int get15814() { return 0; } diff --git a/tests/dmd/fail_compilation/depmsg15815.d b/tests/dmd/fail_compilation/depmsg15815.d index 0b19687ad5..f98d4f255b 100644 --- a/tests/dmd/fail_compilation/depmsg15815.d +++ b/tests/dmd/fail_compilation/depmsg15815.d @@ -2,7 +2,8 @@ /* TEST_OUTPUT: --- -fail_compilation/depmsg15815.d(23): Deprecation: template `depmsg15815.Alias(T)` is deprecated - message +fail_compilation/depmsg15815.d(24): Deprecation: template `depmsg15815.Alias(T)` is deprecated - message +fail_compilation/depmsg15815.d(18): `Alias(T)` is declared here Foo --- */ diff --git a/tests/dmd/fail_compilation/deprecatedImports.d b/tests/dmd/fail_compilation/deprecatedImports.d index bd68a9d4e3..b50e2981f1 100644 --- a/tests/dmd/fail_compilation/deprecatedImports.d +++ b/tests/dmd/fail_compilation/deprecatedImports.d @@ -4,13 +4,20 @@ EXTRA_FILES: imports/deprecatedImporta.d imports/deprecatedImportb.d TEST_OUTPUT: ---- -fail_compilation/deprecatedImports.d(19): Deprecation: alias `deprecatedImporta.foo` is deprecated - Please import deprecatedImportb directly! -fail_compilation/deprecatedImports.d(21): Deprecation: alias `deprecatedImporta.bar` is deprecated - Please import deprecatedImportb directly! -fail_compilation/deprecatedImports.d(23): Deprecation: alias `deprecatedImporta.AliasSeq` is deprecated - Please import deprecatedImportb directly! -fail_compilation/deprecatedImports.d(27): Deprecation: alias `deprecatedImporta.S` is deprecated - Please import deprecatedImportb directly! -fail_compilation/deprecatedImports.d(29): Deprecation: alias `deprecatedImporta.C` is deprecated - Please import deprecatedImportb directly! -fail_compilation/deprecatedImports.d(31): Deprecation: alias `deprecatedImporta.I` is deprecated - Please import deprecatedImportb directly! -fail_compilation/deprecatedImports.d(25): Deprecation: alias `deprecatedImporta.E` is deprecated - Please import deprecatedImportb directly! +fail_compilation/deprecatedImports.d(26): Deprecation: alias `deprecatedImporta.foo` is deprecated - Please import deprecatedImportb directly! +fail_compilation/imports/deprecatedImporta.d(2): `foo` is declared here +fail_compilation/deprecatedImports.d(28): Deprecation: alias `deprecatedImporta.bar` is deprecated - Please import deprecatedImportb directly! +fail_compilation/imports/deprecatedImporta.d(2): `bar` is declared here +fail_compilation/deprecatedImports.d(30): Deprecation: alias `deprecatedImporta.AliasSeq` is deprecated - Please import deprecatedImportb directly! +fail_compilation/imports/deprecatedImporta.d(2): `AliasSeq` is declared here +fail_compilation/deprecatedImports.d(34): Deprecation: alias `deprecatedImporta.S` is deprecated - Please import deprecatedImportb directly! +fail_compilation/imports/deprecatedImporta.d(2): `S` is declared here +fail_compilation/deprecatedImports.d(36): Deprecation: alias `deprecatedImporta.C` is deprecated - Please import deprecatedImportb directly! +fail_compilation/imports/deprecatedImporta.d(2): `C` is declared here +fail_compilation/deprecatedImports.d(38): Deprecation: alias `deprecatedImporta.I` is deprecated - Please import deprecatedImportb directly! +fail_compilation/imports/deprecatedImporta.d(2): `I` is declared here +fail_compilation/deprecatedImports.d(32): Deprecation: alias `deprecatedImporta.E` is deprecated - Please import deprecatedImportb directly! +fail_compilation/imports/deprecatedImporta.d(2): `E` is declared here ---- */ diff --git a/tests/dmd/fail_compilation/deprecatedTemplates.d b/tests/dmd/fail_compilation/deprecatedTemplates.d index d905479866..e735c9004f 100644 --- a/tests/dmd/fail_compilation/deprecatedTemplates.d +++ b/tests/dmd/fail_compilation/deprecatedTemplates.d @@ -4,8 +4,11 @@ REQUIRED_ARGS: -de TEST_OUTPUT: ---- fail_compilation/deprecatedTemplates.d(103): Deprecation: template `deprecatedTemplates.AliasSeq(V...)` is deprecated +fail_compilation/deprecatedTemplates.d(101): `AliasSeq(V...)` is declared here fail_compilation/deprecatedTemplates.d(107): Deprecation: struct `deprecatedTemplates.S1(V...)` is deprecated +fail_compilation/deprecatedTemplates.d(105): `S1(V...)` is declared here fail_compilation/deprecatedTemplates.d(115): Deprecation: template `deprecatedTemplates.C(V...)` is deprecated +fail_compilation/deprecatedTemplates.d(109): `C(V...)` is declared here ---- */ #line 100 @@ -30,6 +33,7 @@ alias D = C!(); TEST_OUTPUT: ---- fail_compilation/deprecatedTemplates.d(202): Deprecation: template `deprecatedTemplates.AliasSeqMsg(V...)` is deprecated - Reason +fail_compilation/deprecatedTemplates.d(200): `AliasSeqMsg(V...)` is declared here ---- */ #line 200 diff --git a/tests/dmd/fail_compilation/deprecations.d b/tests/dmd/fail_compilation/deprecations.d index 19adab7e3a..85ca0b83a4 100644 --- a/tests/dmd/fail_compilation/deprecations.d +++ b/tests/dmd/fail_compilation/deprecations.d @@ -2,12 +2,15 @@ REQUIRED_ARGS: -de TEST_OUTPUT: --- -fail_compilation/deprecations.d(43): Deprecation: struct `deprecations.S` is deprecated -fail_compilation/deprecations.d(64): instantiated from here: `otherPar!()` -fail_compilation/deprecations.d(55): Deprecation: struct `deprecations.S` is deprecated -fail_compilation/deprecations.d(65): instantiated from here: `otherVar!()` -fail_compilation/deprecations.d(55): Deprecation: struct `deprecations.S` is deprecated -fail_compilation/deprecations.d(65): instantiated from here: `otherVar!()` +fail_compilation/deprecations.d(46): Deprecation: struct `deprecations.S` is deprecated +fail_compilation/deprecations.d(19): `S` is declared here +fail_compilation/deprecations.d(67): instantiated from here: `otherPar!()` +fail_compilation/deprecations.d(58): Deprecation: struct `deprecations.S` is deprecated +fail_compilation/deprecations.d(19): `S` is declared here +fail_compilation/deprecations.d(68): instantiated from here: `otherVar!()` +fail_compilation/deprecations.d(58): Deprecation: struct `deprecations.S` is deprecated +fail_compilation/deprecations.d(19): `S` is declared here +fail_compilation/deprecations.d(68): instantiated from here: `otherVar!()` --- https://issues.dlang.org/show_bug.cgi?id=20474 diff --git a/tests/dmd/fail_compilation/diag14875.d b/tests/dmd/fail_compilation/diag14875.d index a4d4abe9e1..b6ef8c77e4 100644 --- a/tests/dmd/fail_compilation/diag14875.d +++ b/tests/dmd/fail_compilation/diag14875.d @@ -6,7 +6,8 @@ deprecated immutable int depVar = 10; /* TEST_OUTPUT: --- -fail_compilation/diag14875.d(16): Deprecation: class `diag14875.Dep` is deprecated +fail_compilation/diag14875.d(17): Deprecation: class `diag14875.Dep` is deprecated +fail_compilation/diag14875.d(3): `Dep` is declared here 1: Dep 2: Dep 3: Dep @@ -36,16 +37,20 @@ template Baz(T) /* TEST_OUTPUT: --- -fail_compilation/diag14875.d(52): Deprecation: class `diag14875.Dep` is deprecated -fail_compilation/diag14875.d(56): Deprecation: variable `diag14875.depVar` is deprecated -fail_compilation/diag14875.d(52): instantiated from here: `Voo!(Dep)` +fail_compilation/diag14875.d(57): Deprecation: class `diag14875.Dep` is deprecated +fail_compilation/diag14875.d(3): `Dep` is declared here +fail_compilation/diag14875.d(61): Deprecation: variable `diag14875.depVar` is deprecated +fail_compilation/diag14875.d(4): `depVar` is declared here +fail_compilation/diag14875.d(57): instantiated from here: `Voo!(Dep)` 4: Dep -fail_compilation/diag14875.d(63): Deprecation: variable `diag14875.depVar` is deprecated -fail_compilation/diag14875.d(59): instantiated from here: `Var!(Dep)` -fail_compilation/diag14875.d(52): instantiated from here: `Voo!(Dep)` -fail_compilation/diag14875.d(64): Deprecation: template `diag14875.Vaz(T)` is deprecated -fail_compilation/diag14875.d(59): instantiated from here: `Var!(Dep)` -fail_compilation/diag14875.d(52): instantiated from here: `Voo!(Dep)` +fail_compilation/diag14875.d(68): Deprecation: variable `diag14875.depVar` is deprecated +fail_compilation/diag14875.d(4): `depVar` is declared here +fail_compilation/diag14875.d(64): instantiated from here: `Var!(Dep)` +fail_compilation/diag14875.d(57): instantiated from here: `Voo!(Dep)` +fail_compilation/diag14875.d(69): Deprecation: template `diag14875.Vaz(T)` is deprecated +fail_compilation/diag14875.d(71): `Vaz(T)` is declared here +fail_compilation/diag14875.d(64): instantiated from here: `Var!(Dep)` +fail_compilation/diag14875.d(57): instantiated from here: `Voo!(Dep)` --- */ @@ -72,7 +77,7 @@ deprecated template Vaz(T) /* TEST_OUTPUT: --- -fail_compilation/diag14875.d(80): Error: static assert: `0` is false +fail_compilation/diag14875.d(85): Error: static assert: `0` is false --- */ void main() diff --git a/tests/dmd/fail_compilation/diag14876.d b/tests/dmd/fail_compilation/diag14876.d index 4beea95900..9579467eaf 100644 --- a/tests/dmd/fail_compilation/diag14876.d +++ b/tests/dmd/fail_compilation/diag14876.d @@ -1,14 +1,21 @@ /* TEST_OUTPUT: --- -fail_compilation/diag14876.d(17): Deprecation: class `diag14876.Dep` is deprecated -fail_compilation/diag14876.d(18): Deprecation: class `diag14876.Dep` is deprecated -fail_compilation/diag14876.d(19): Deprecation: class `diag14876.Dep` is deprecated -fail_compilation/diag14876.d(20): Deprecation: class `diag14876.Dep` is deprecated -fail_compilation/diag14876.d(21): Deprecation: class `diag14876.Dep` is deprecated -fail_compilation/diag14876.d(22): Deprecation: class `diag14876.Dep` is deprecated -fail_compilation/diag14876.d(23): Deprecation: class `diag14876.Dep` is deprecated -fail_compilation/diag14876.d(23): Error: can only slice type sequences, not `diag14876.Dep` +fail_compilation/diag14876.d(24): Deprecation: class `diag14876.Dep` is deprecated +fail_compilation/diag14876.d(22): `Dep` is declared here +fail_compilation/diag14876.d(25): Deprecation: class `diag14876.Dep` is deprecated +fail_compilation/diag14876.d(22): `Dep` is declared here +fail_compilation/diag14876.d(26): Deprecation: class `diag14876.Dep` is deprecated +fail_compilation/diag14876.d(22): `Dep` is declared here +fail_compilation/diag14876.d(27): Deprecation: class `diag14876.Dep` is deprecated +fail_compilation/diag14876.d(22): `Dep` is declared here +fail_compilation/diag14876.d(28): Deprecation: class `diag14876.Dep` is deprecated +fail_compilation/diag14876.d(22): `Dep` is declared here +fail_compilation/diag14876.d(29): Deprecation: class `diag14876.Dep` is deprecated +fail_compilation/diag14876.d(22): `Dep` is declared here +fail_compilation/diag14876.d(30): Deprecation: class `diag14876.Dep` is deprecated +fail_compilation/diag14876.d(22): `Dep` is declared here +fail_compilation/diag14876.d(30): Error: can only slice type sequences, not `diag14876.Dep` --- */ diff --git a/tests/dmd/fail_compilation/fail19202.d b/tests/dmd/fail_compilation/fail19202.d index f19bc181f4..a5b773fc06 100644 --- a/tests/dmd/fail_compilation/fail19202.d +++ b/tests/dmd/fail_compilation/fail19202.d @@ -2,7 +2,8 @@ /* TEST_OUTPUT: --- -fail_compilation/fail19202.d(11): Deprecation: variable `fail19202.X!().X` is deprecated +fail_compilation/fail19202.d(12): Deprecation: variable `fail19202.X!().X` is deprecated +fail_compilation/fail19202.d(17): `X` is declared here --- */ diff --git a/tests/dmd/fail_compilation/fail199.d b/tests/dmd/fail_compilation/fail199.d index 9cb14b801c..ab57b3401d 100644 --- a/tests/dmd/fail_compilation/fail199.d +++ b/tests/dmd/fail_compilation/fail199.d @@ -2,8 +2,10 @@ /* TEST_OUTPUT: --- -fail_compilation/fail199.d(20): Deprecation: class `fail199.DepClass` is deprecated -fail_compilation/fail199.d(20): Deprecation: class `fail199.DepClass` is deprecated +fail_compilation/fail199.d(22): Deprecation: class `fail199.DepClass` is deprecated +fail_compilation/fail199.d(14): `DepClass` is declared here +fail_compilation/fail199.d(22): Deprecation: class `fail199.DepClass` is deprecated +fail_compilation/fail199.d(14): `DepClass` is declared here --- */ diff --git a/tests/dmd/fail_compilation/fail200.d b/tests/dmd/fail_compilation/fail200.d index 9d804a916b..07ea04371f 100644 --- a/tests/dmd/fail_compilation/fail200.d +++ b/tests/dmd/fail_compilation/fail200.d @@ -2,8 +2,10 @@ /* TEST_OUTPUT: --- -fail_compilation/fail200.d(17): Deprecation: interface `fail200.DepClass` is deprecated -fail_compilation/fail200.d(17): Deprecation: interface `fail200.DepClass` is deprecated +fail_compilation/fail200.d(19): Deprecation: interface `fail200.DepClass` is deprecated +fail_compilation/fail200.d(14): `DepClass` is declared here +fail_compilation/fail200.d(19): Deprecation: interface `fail200.DepClass` is deprecated +fail_compilation/fail200.d(14): `DepClass` is declared here --- */ diff --git a/tests/dmd/fail_compilation/fail21830.d b/tests/dmd/fail_compilation/fail21830.d index 2e0f84b777..dda0140aad 100644 --- a/tests/dmd/fail_compilation/fail21830.d +++ b/tests/dmd/fail_compilation/fail21830.d @@ -2,8 +2,11 @@ TEST_OUTPUT: --- fail_compilation/fail21830.d(24): Deprecation: struct `fail21830.OldS21830` is deprecated - Deprecated type +fail_compilation/fail21830.d(2): `OldS21830` is declared here fail_compilation/fail21830.d(24): Deprecation: template `fail21830.test21830(T)(T t) if (is(T == OldS21830))` is deprecated - Deprecated template +fail_compilation/fail21830.d(16): `test21830(T)(T t) if (is(T == OldS21830))` is declared here fail_compilation/fail21830.d(24): Deprecation: struct `fail21830.OldS21830` is deprecated - Deprecated type +fail_compilation/fail21830.d(2): `OldS21830` is declared here --- */ #line 1 diff --git a/tests/dmd/fail_compilation/fail21831.d b/tests/dmd/fail_compilation/fail21831.d index 39551332e9..642c6d3f49 100644 --- a/tests/dmd/fail_compilation/fail21831.d +++ b/tests/dmd/fail_compilation/fail21831.d @@ -2,8 +2,11 @@ TEST_OUTPUT: --- fail_compilation/fail21831.d(19): Deprecation: struct `fail21831.S21831` is deprecated - Deprecated type +fail_compilation/fail21831.d(2): `S21831` is declared here fail_compilation/fail21831.d(19): Deprecation: template `fail21831.test21831(T)(T t) if (__traits(isDeprecated, T))` is deprecated - Deprecated template +fail_compilation/fail21831.d(11): `test21831(T)(T t) if (__traits(isDeprecated, T))` is declared here fail_compilation/fail21831.d(19): Deprecation: struct `fail21831.S21831` is deprecated - Deprecated type +fail_compilation/fail21831.d(2): `S21831` is declared here --- */ #line 1 diff --git a/tests/dmd/fail_compilation/fail21832.d b/tests/dmd/fail_compilation/fail21832.d index 98f3df71a1..690dbdae8d 100644 --- a/tests/dmd/fail_compilation/fail21832.d +++ b/tests/dmd/fail_compilation/fail21832.d @@ -4,7 +4,9 @@ TEST_OUTPUT: --- fail_compilation/fail21832.d(4): Deprecation: function `imports.imp21832.fun` is deprecated +fail_compilation/imports/imp21832.d(16): `fun` is declared here fail_compilation/fail21832.d(10): Deprecation: template `imports.imp21832.tpl()(char a)` is deprecated +fail_compilation/imports/imp21832.d(20): `tpl()(char a)` is declared here --- */ #line 1 diff --git a/tests/dmd/fail_compilation/fail23822.d b/tests/dmd/fail_compilation/fail23822.d index 5cdd1fe050..57e6bc035a 100644 --- a/tests/dmd/fail_compilation/fail23822.d +++ b/tests/dmd/fail_compilation/fail23822.d @@ -5,7 +5,8 @@ /* TEST_OUTPUT: --- -fail_compilation/fail23822.d(21): Deprecation: alias `fail23822.S.value` is deprecated +fail_compilation/fail23822.d(22): Deprecation: alias `fail23822.S.value` is deprecated +fail_compilation/fail23822.d(17): `value` is declared here --- */ diff --git a/tests/dmd/fail_compilation/fail23826.d b/tests/dmd/fail_compilation/fail23826.d index 3db243a3ce..d66f941fdc 100644 --- a/tests/dmd/fail_compilation/fail23826.d +++ b/tests/dmd/fail_compilation/fail23826.d @@ -5,7 +5,8 @@ /* TEST_OUTPUT: --- -fail_compilation/fail23826.d(23): Deprecation: alias `fail23826.S.value` is deprecated +fail_compilation/fail23826.d(24): Deprecation: alias `fail23826.S.value` is deprecated +fail_compilation/fail23826.d(17): `value` is declared here --- */ diff --git a/tests/dmd/fail_compilation/fail243.d b/tests/dmd/fail_compilation/fail243.d index d9852ffc47..46cfa52ee4 100644 --- a/tests/dmd/fail_compilation/fail243.d +++ b/tests/dmd/fail_compilation/fail243.d @@ -2,11 +2,16 @@ /* TEST_OUTPUT: --- -fail_compilation/fail243.d(23): Deprecation: class `fail243.DepClass` is deprecated -fail_compilation/fail243.d(24): Deprecation: struct `fail243.DepStruct` is deprecated -fail_compilation/fail243.d(25): Deprecation: union `fail243.DepUnion` is deprecated -fail_compilation/fail243.d(26): Deprecation: enum `fail243.DepEnum` is deprecated -fail_compilation/fail243.d(27): Deprecation: alias `fail243.DepAlias` is deprecated +fail_compilation/fail243.d(28): Deprecation: class `fail243.DepClass` is deprecated +fail_compilation/fail243.d(20): `DepClass` is declared here +fail_compilation/fail243.d(29): Deprecation: struct `fail243.DepStruct` is deprecated +fail_compilation/fail243.d(21): `DepStruct` is declared here +fail_compilation/fail243.d(30): Deprecation: union `fail243.DepUnion` is deprecated +fail_compilation/fail243.d(22): `DepUnion` is declared here +fail_compilation/fail243.d(31): Deprecation: enum `fail243.DepEnum` is deprecated +fail_compilation/fail243.d(23): `DepEnum` is declared here +fail_compilation/fail243.d(32): Deprecation: alias `fail243.DepAlias` is deprecated +fail_compilation/fail243.d(24): `DepAlias` is declared here --- */ diff --git a/tests/dmd/fail_compilation/fail244.d b/tests/dmd/fail_compilation/fail244.d index 757eb2bdbb..a9bb36549f 100644 --- a/tests/dmd/fail_compilation/fail244.d +++ b/tests/dmd/fail_compilation/fail244.d @@ -2,16 +2,26 @@ /* TEST_OUTPUT: --- -fail_compilation/fail244.d(27): Deprecation: variable `fail244.StructWithDeps.value` is deprecated -fail_compilation/fail244.d(28): Deprecation: variable `fail244.StructWithDeps.value` is deprecated -fail_compilation/fail244.d(29): Deprecation: variable `fail244.StructWithDeps.value` is deprecated -fail_compilation/fail244.d(30): Deprecation: variable `fail244.StructWithDeps.value` is deprecated -fail_compilation/fail244.d(32): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated -fail_compilation/fail244.d(33): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated -fail_compilation/fail244.d(34): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated -fail_compilation/fail244.d(35): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated -fail_compilation/fail244.d(36): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated -fail_compilation/fail244.d(37): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated +fail_compilation/fail244.d(37): Deprecation: variable `fail244.StructWithDeps.value` is deprecated +fail_compilation/fail244.d(32): `value` is declared here +fail_compilation/fail244.d(38): Deprecation: variable `fail244.StructWithDeps.value` is deprecated +fail_compilation/fail244.d(32): `value` is declared here +fail_compilation/fail244.d(39): Deprecation: variable `fail244.StructWithDeps.value` is deprecated +fail_compilation/fail244.d(32): `value` is declared here +fail_compilation/fail244.d(40): Deprecation: variable `fail244.StructWithDeps.value` is deprecated +fail_compilation/fail244.d(32): `value` is declared here +fail_compilation/fail244.d(42): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated +fail_compilation/fail244.d(33): `staticValue` is declared here +fail_compilation/fail244.d(43): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated +fail_compilation/fail244.d(33): `staticValue` is declared here +fail_compilation/fail244.d(44): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated +fail_compilation/fail244.d(33): `staticValue` is declared here +fail_compilation/fail244.d(45): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated +fail_compilation/fail244.d(33): `staticValue` is declared here +fail_compilation/fail244.d(46): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated +fail_compilation/fail244.d(33): `staticValue` is declared here +fail_compilation/fail244.d(47): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated +fail_compilation/fail244.d(33): `staticValue` is declared here --- */ diff --git a/tests/dmd/fail_compilation/fail245.d b/tests/dmd/fail_compilation/fail245.d index 927f941320..90b6f7c47f 100644 --- a/tests/dmd/fail_compilation/fail245.d +++ b/tests/dmd/fail_compilation/fail245.d @@ -2,16 +2,26 @@ /* TEST_OUTPUT: --- -fail_compilation/fail245.d(27): Deprecation: variable `fail245.ClassWithDeps.value` is deprecated -fail_compilation/fail245.d(28): Deprecation: variable `fail245.ClassWithDeps.value` is deprecated -fail_compilation/fail245.d(29): Deprecation: variable `fail245.ClassWithDeps.value` is deprecated -fail_compilation/fail245.d(30): Deprecation: variable `fail245.ClassWithDeps.value` is deprecated -fail_compilation/fail245.d(32): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated -fail_compilation/fail245.d(33): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated -fail_compilation/fail245.d(34): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated -fail_compilation/fail245.d(35): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated -fail_compilation/fail245.d(36): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated -fail_compilation/fail245.d(37): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated +fail_compilation/fail245.d(37): Deprecation: variable `fail245.ClassWithDeps.value` is deprecated +fail_compilation/fail245.d(32): `value` is declared here +fail_compilation/fail245.d(38): Deprecation: variable `fail245.ClassWithDeps.value` is deprecated +fail_compilation/fail245.d(32): `value` is declared here +fail_compilation/fail245.d(39): Deprecation: variable `fail245.ClassWithDeps.value` is deprecated +fail_compilation/fail245.d(32): `value` is declared here +fail_compilation/fail245.d(40): Deprecation: variable `fail245.ClassWithDeps.value` is deprecated +fail_compilation/fail245.d(32): `value` is declared here +fail_compilation/fail245.d(42): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated +fail_compilation/fail245.d(33): `staticValue` is declared here +fail_compilation/fail245.d(43): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated +fail_compilation/fail245.d(33): `staticValue` is declared here +fail_compilation/fail245.d(44): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated +fail_compilation/fail245.d(33): `staticValue` is declared here +fail_compilation/fail245.d(45): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated +fail_compilation/fail245.d(33): `staticValue` is declared here +fail_compilation/fail245.d(46): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated +fail_compilation/fail245.d(33): `staticValue` is declared here +fail_compilation/fail245.d(47): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated +fail_compilation/fail245.d(33): `staticValue` is declared here --- */ diff --git a/tests/dmd/fail_compilation/ice11822.d b/tests/dmd/fail_compilation/ice11822.d index a673a6b2dd..632571feb3 100644 --- a/tests/dmd/fail_compilation/ice11822.d +++ b/tests/dmd/fail_compilation/ice11822.d @@ -4,10 +4,11 @@ /* TEST_OUTPUT: --- -fail_compilation/ice11822.d(33): Deprecation: function `ice11822.d` is deprecated -fail_compilation/ice11822.d(16): instantiated from here: `__lambda_L33_C15!int` -fail_compilation/ice11822.d(22): instantiated from here: `S!(__lambda_L33_C15)` -fail_compilation/ice11822.d(33): instantiated from here: `g!((n) => d(i))` +fail_compilation/ice11822.d(34): Deprecation: function `ice11822.d` is deprecated +fail_compilation/ice11822.d(26): `d` is declared here +fail_compilation/ice11822.d(17): instantiated from here: `__lambda_L34_C15!int` +fail_compilation/ice11822.d(23): instantiated from here: `S!(__lambda_L34_C15)` +fail_compilation/ice11822.d(34): instantiated from here: `g!((n) => d(i))` --- */ diff --git a/tests/dmd/fail_compilation/test19193.d b/tests/dmd/fail_compilation/test19193.d index e75d90e5a9..9c4d7e4979 100644 --- a/tests/dmd/fail_compilation/test19193.d +++ b/tests/dmd/fail_compilation/test19193.d @@ -2,7 +2,8 @@ REQUIRED_ARGS: -de TEST_OUTPUT: --- -fail_compilation/test19193.d(13): Deprecation: enum member `test19193.T19193!int.A.b` is deprecated +fail_compilation/test19193.d(14): Deprecation: enum member `test19193.T19193!int.A.b` is deprecated +fail_compilation/test19193.d(21): `b` is declared here --- */ diff --git a/tests/dmd/fail_compilation/test20515.d b/tests/dmd/fail_compilation/test20515.d index cf4bbde58d..b753db3a5d 100644 --- a/tests/dmd/fail_compilation/test20515.d +++ b/tests/dmd/fail_compilation/test20515.d @@ -2,8 +2,9 @@ /* TEST_OUTPUT: --- -fail_compilation/test20515.d:16: Deprecation: function `test20515.foo` is deprecated -fail_compilation/test20515.d:17: Error: undefined identifier `bar` +fail_compilation/test20515.d:17: Deprecation: function `test20515.foo` is deprecated +fail_compilation/test20515.d:13: `foo` is declared here +fail_compilation/test20515.d:18: Error: undefined identifier `bar` --- */ diff --git a/tests/dmd/fail_compilation/test21259.d b/tests/dmd/fail_compilation/test21259.d index 31dba3d52c..c928bab7e7 100644 --- a/tests/dmd/fail_compilation/test21259.d +++ b/tests/dmd/fail_compilation/test21259.d @@ -3,10 +3,14 @@ /* TEST_OUTPUT: --- -fail_compilation/test21259.d(39): Deprecation: alias `test21259.Foo.width` is deprecated -fail_compilation/test21259.d(40): Deprecation: alias `test21259.Foo2.width` is deprecated -fail_compilation/test21259.d(41): Deprecation: variable `test21259.Foo3.bar` is deprecated -fail_compilation/test21259.d(42): Deprecation: alias `test21259.Foo4.width` is deprecated +fail_compilation/test21259.d(43): Deprecation: alias `test21259.Foo.width` is deprecated +fail_compilation/test21259.d(20): `width` is declared here +fail_compilation/test21259.d(44): Deprecation: alias `test21259.Foo2.width` is deprecated +fail_compilation/test21259.d(26): `width` is declared here +fail_compilation/test21259.d(45): Deprecation: variable `test21259.Foo3.bar` is deprecated +fail_compilation/test21259.d(31): `bar` is declared here +fail_compilation/test21259.d(46): Deprecation: alias `test21259.Foo4.width` is deprecated +fail_compilation/test21259.d(38): `width` is declared here --- */ diff --git a/tests/dmd/fail_compilation/test23968.d b/tests/dmd/fail_compilation/test23968.d index 4456e75c70..f371618f60 100644 --- a/tests/dmd/fail_compilation/test23968.d +++ b/tests/dmd/fail_compilation/test23968.d @@ -5,7 +5,8 @@ /* TEST_OUTPUT: --- -fail_compilation/test23968.d(22): Deprecation: alias `test23968.a` is deprecated +fail_compilation/test23968.d(23): Deprecation: alias `test23968.a` is deprecated +fail_compilation/test23968.d(18): `a` is declared here --- */ diff --git a/tests/dmd/fail_compilation/test9701b.d b/tests/dmd/fail_compilation/test9701b.d index 725a4cd0ea..ce2e54c3ef 100644 --- a/tests/dmd/fail_compilation/test9701b.d +++ b/tests/dmd/fail_compilation/test9701b.d @@ -2,8 +2,10 @@ REQUIRED_ARGS: -de TEST_OUTPUT: --- -fail_compilation/test9701b.d(20): Deprecation: enum member `test9701b.Enum.e0` is deprecated -fail_compilation/test9701b.d(21): Deprecation: enum member `test9701b.Enum.e1` is deprecated - message +fail_compilation/test9701b.d(22): Deprecation: enum member `test9701b.Enum.e0` is deprecated +fail_compilation/test9701b.d(16): `e0` is declared here +fail_compilation/test9701b.d(23): Deprecation: enum member `test9701b.Enum.e1` is deprecated - message +fail_compilation/test9701b.d(17): `e1` is declared here --- */ From f9588e30dbfbd67189e91eccbe5128e3bc1a942a Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Wed, 28 Jan 2026 09:42:28 +0100 Subject: [PATCH 302/440] fix dlang/dmd!22463 - SOURCE_DATE_EPOCH parsing incorrectly affected by system timezone --- dmd/globals.d | 14 +++++++++----- tests/dmd/dshell/issue20444_SOURCE_DATE_EPOCH.d | 1 - 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dmd/globals.d b/dmd/globals.d index a7c9472597..020d24786c 100644 --- a/dmd/globals.d +++ b/dmd/globals.d @@ -309,7 +309,7 @@ extern (C++) struct Global Array!(const(char)*) filePath; /// Array of char*'s which form the file import lookup path private enum string _version = import("VERSION"); - char[26] datetime; /// string returned by ctime() + char[26] datetime; /// string returned by asctime() CompileEnv compileEnv; Param params; /// command line parameters @@ -408,15 +408,19 @@ extern (C++) struct Global import core.stdc.stdlib : getenv; time_t ct; + const(char)* p; // https://issues.dlang.org/show_bug.cgi?id=20444 - if (auto p = getenv("SOURCE_DATE_EPOCH")) + if (auto epoch = getenv("SOURCE_DATE_EPOCH")) { - if (!ct.parseDigits(p[0 .. strlen(p)])) - errorSink.error(Loc.initial, "value of environment variable `SOURCE_DATE_EPOCH` should be a valid UNIX timestamp, not: `%s`", p); + if (!ct.parseDigits(epoch[0 .. strlen(epoch)])) + errorSink.error(Loc.initial, "value of environment variable `SOURCE_DATE_EPOCH` should be a valid UNIX timestamp, not: `%s`", epoch); + p = asctime(gmtime(&ct)); } else + { core.stdc.time.time(&ct); - const p = ctime(&ct); + p = ctime(&ct); // asctime(localtime(&ct)) + } assert(p); datetime[] = p[0 .. 26]; diff --git a/tests/dmd/dshell/issue20444_SOURCE_DATE_EPOCH.d b/tests/dmd/dshell/issue20444_SOURCE_DATE_EPOCH.d index ba8765065c..1a4da3e855 100644 --- a/tests/dmd/dshell/issue20444_SOURCE_DATE_EPOCH.d +++ b/tests/dmd/dshell/issue20444_SOURCE_DATE_EPOCH.d @@ -10,7 +10,6 @@ void main () { string[string] env = [ "SOURCE_DATE_EPOCH": "704124840", - "TZ": "UTC", "LC_ALL": "C", ]; From 50621640310dfac05cbcfd58a53384af285eef26 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Fri, 30 Jan 2026 14:20:13 +0800 Subject: [PATCH 303/440] Fix dlang/dmd!20578 - don't inline enum variable declaration --- dmd/inline.d | 3 ++- tests/dmd/runnable/issue20578.d | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/runnable/issue20578.d diff --git a/dmd/inline.d b/dmd/inline.d index 59c1b5012f..e199a598a1 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -736,7 +736,8 @@ public: return; } } - if (vd.isStatic()) + + if (vd.isStatic() || (vd.storage_class & STC.manifest)) return; bool varIsNRVO = ids.fd && (ids.fd.isNRVO && vd == ids.fd.nrvo_var || vd.nrvo); diff --git a/tests/dmd/runnable/issue20578.d b/tests/dmd/runnable/issue20578.d new file mode 100644 index 0000000000..899dc3a8eb --- /dev/null +++ b/tests/dmd/runnable/issue20578.d @@ -0,0 +1,14 @@ +// REQUIRED_ARGS: -inline + +int fun(string[]) +{ + if (false) + static foreach(m; [1,2,3] ) { } + + return 0; +} + +int main(string[] args) +{ + return fun(args); +} From 0cf9749894d7675806c29783ef4503e6d183c85a Mon Sep 17 00:00:00 2001 From: Claude Code Date: Fri, 30 Jan 2026 17:43:58 +0000 Subject: [PATCH 304/440] Add 'used in initialization here' message for type initializer errors When a type is incorrectly used as an initializer (e.g., in an enum declaration getting attributes via __traits), show where the initialization was requested if it differs from the error location. This helps users understand the connection between the error location (e.g., a UDA definition) and where it was triggered (e.g., an enum declaration using __traits(getAttributes)). The dsymbolsem.d change preserves the original initializer location during tuple expansion, so the supplemental message can point to the correct declaration site. Co-Authored-By: Claude Opus 4.5 --- dmd/dsymbolsem.d | 4 +++- dmd/initsem.d | 3 +++ tests/dmd/fail_compilation/ice11919.d | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 7ad2c2172f..3e372b58e9 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -2481,7 +2481,9 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (i == 0) einit = Expression.combine(te.e0, einit); } - ti = new ExpInitializer(einit.loc, einit); + // Use the original initializer location, not the tuple element's location, + // so error messages point to the declaration site + ti = new ExpInitializer(dsym._init ? dsym._init.loc : einit.loc, einit); } else ti = dsym._init ? dsym._init.syntaxCopy() : null; diff --git a/dmd/initsem.d b/dmd/initsem.d index 9ddf5508eb..cb5c381956 100644 --- a/dmd/initsem.d +++ b/dmd/initsem.d @@ -422,6 +422,9 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn if (i.exp.op == EXP.type) { error(i.exp.loc, "initializer must be an expression, not `%s`", i.exp.toChars()); + // If the error location differs from the initializer location, show where it was used + if (i.exp.loc != i.loc) + errorSupplemental(i.loc, "used in initialization here"); return err(); } // Make sure all pointers are constants diff --git a/tests/dmd/fail_compilation/ice11919.d b/tests/dmd/fail_compilation/ice11919.d index e6b4f70884..4319020391 100644 --- a/tests/dmd/fail_compilation/ice11919.d +++ b/tests/dmd/fail_compilation/ice11919.d @@ -2,10 +2,11 @@ EXTRA_FILES: imports/a11919.d TEST_OUTPUT: --- -fail_compilation/ice11919.d(18): Error: initializer must be an expression, not `foo` +fail_compilation/ice11919.d(19): Error: initializer must be an expression, not `foo` +fail_compilation/imports/a11919.d(16): used in initialization here fail_compilation/imports/a11919.d(4): Error: template instance `a11919.doBar!(Foo).doBar.zoo!(t)` error instantiating fail_compilation/imports/a11919.d(11): instantiated from here: `doBar!(Foo)` -fail_compilation/ice11919.d(26): instantiated from here: `doBar!(Bar)` +fail_compilation/ice11919.d(27): instantiated from here: `doBar!(Bar)` --- */ From 1b49a70b462520356797ec3412a289a4a995b1ab Mon Sep 17 00:00:00 2001 From: Claude Code Date: Fri, 30 Jan 2026 17:45:48 +0000 Subject: [PATCH 305/440] Add 'perhaps use X()' hint for struct/class type initializer errors When a type is incorrectly used as an initializer (e.g., `enum var = s;` where `s` is a struct type), suggest constructing an instance: For structs: - "perhaps use `s()` to construct a value" if default-constructible - "perhaps use `s(...)` to construct a value" if requires arguments - No hint if has copy constructor (can't construct) For classes: - "perhaps use `new C()` to construct a value" if default-constructible - "perhaps use `new C(...)` to construct a value" if requires arguments Co-Authored-By: Claude Opus 4.5 --- dmd/initsem.d | 17 ++++++ tests/dmd/fail_compilation/fail4206.d | 3 +- tests/dmd/fail_compilation/fail8262.d | 7 +-- .../fail_compilation/type_as_initializer.d | 52 +++++++++++++++++++ 4 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 tests/dmd/fail_compilation/type_as_initializer.d diff --git a/dmd/initsem.d b/dmd/initsem.d index cb5c381956..21ad68fb6c 100644 --- a/dmd/initsem.d +++ b/dmd/initsem.d @@ -425,6 +425,23 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn // If the error location differs from the initializer location, show where it was used if (i.exp.loc != i.loc) errorSupplemental(i.loc, "used in initialization here"); + // If the type is a struct or class, suggest adding () to construct an instance + if (auto ts = i.exp.type.isTypeStruct()) + { + // Check if the struct can be default-constructed (no required args) + if (!ts.sym.hasCopyCtor && (!ts.sym.ctor || ts.sym.defaultCtor)) + errorSupplemental(i.exp.loc, "perhaps use `%s()` to construct a value of the type", i.exp.toChars()); + else if (ts.sym.ctor && !ts.sym.hasCopyCtor) + errorSupplemental(i.exp.loc, "perhaps use `%s(...)` to construct a value of the type", i.exp.toChars()); + } + else if (auto tc = i.exp.type.isTypeClass()) + { + // Check if the class can be default-constructed + if (!tc.sym.noDefaultCtor && (!tc.sym.ctor || tc.sym.defaultCtor)) + errorSupplemental(i.exp.loc, "perhaps use `new %s()` to construct a value of the type", i.exp.toChars()); + else if (tc.sym.ctor) + errorSupplemental(i.exp.loc, "perhaps use `new %s(...)` to construct a value of the type", i.exp.toChars()); + } return err(); } // Make sure all pointers are constants diff --git a/tests/dmd/fail_compilation/fail4206.d b/tests/dmd/fail_compilation/fail4206.d index b9c1671d78..4db260bc89 100644 --- a/tests/dmd/fail_compilation/fail4206.d +++ b/tests/dmd/fail_compilation/fail4206.d @@ -1,7 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/fail4206.d(9): Error: initializer must be an expression, not `s` +fail_compilation/fail4206.d(10): Error: initializer must be an expression, not `s` +fail_compilation/fail4206.d(10): perhaps use `s()` to construct a value of the type --- */ diff --git a/tests/dmd/fail_compilation/fail8262.d b/tests/dmd/fail_compilation/fail8262.d index 2df1bca4fe..aeb5ad226d 100644 --- a/tests/dmd/fail_compilation/fail8262.d +++ b/tests/dmd/fail_compilation/fail8262.d @@ -1,8 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/fail8262.d(32): Error: initializer must be an expression, not `Tuple8262!1` -fail_compilation/fail8262.d(27): Error: template instance `fail8262.T8262!(Tuple8262!1)` error instantiating -fail_compilation/fail8262.d(19): Error: cannot implicitly convert expression `S(0)` of type `S` to `int` +fail_compilation/fail8262.d(33): Error: initializer must be an expression, not `Tuple8262!1` +fail_compilation/fail8262.d(33): perhaps use `Tuple8262!1()` to construct a value of the type +fail_compilation/fail8262.d(28): Error: template instance `fail8262.T8262!(Tuple8262!1)` error instantiating +fail_compilation/fail8262.d(20): Error: cannot implicitly convert expression `S(0)` of type `S` to `int` --- * https://issues.dlang.org/show_bug.cgi?id=8262 */ diff --git a/tests/dmd/fail_compilation/type_as_initializer.d b/tests/dmd/fail_compilation/type_as_initializer.d new file mode 100644 index 0000000000..57be109ba0 --- /dev/null +++ b/tests/dmd/fail_compilation/type_as_initializer.d @@ -0,0 +1,52 @@ +/* TEST_OUTPUT: +--- +fail_compilation/type_as_initializer.d(40): Error: initializer must be an expression, not `S1` +fail_compilation/type_as_initializer.d(40): perhaps use `S1()` to construct a value of the type +fail_compilation/type_as_initializer.d(43): Error: initializer must be an expression, not `S2` +fail_compilation/type_as_initializer.d(46): Error: initializer must be an expression, not `S3` +fail_compilation/type_as_initializer.d(46): perhaps use `S3(...)` to construct a value of the type +fail_compilation/type_as_initializer.d(49): Error: initializer must be an expression, not `C1` +fail_compilation/type_as_initializer.d(49): perhaps use `new C1()` to construct a value of the type +fail_compilation/type_as_initializer.d(52): Error: initializer must be an expression, not `C2` +fail_compilation/type_as_initializer.d(52): perhaps use `new C2(...)` to construct a value of the type +--- +*/ + +// Struct with no constructors - hint with () +struct S1 {} + +// Struct with copy constructor - no hint (can't default construct) +struct S2 +{ + this(ref S2) {} +} + +// Struct with required-arg constructor only - hint with (...) +struct S3 +{ + this(int x) {} +} + +// Class with no constructors - hint with new () +class C1 {} + +// Class with required-arg constructor only - hint with new (...) +class C2 +{ + this(int x) {} +} + +// Test cases +enum e1 = S1; // line 44 + +// Copy constructor - no hint +enum e2 = S2; // line 47 + +// Required args - hint with (...) +enum e3 = S3; // line 50 + +// Class with no ctor - hint with new () +enum e4 = C1; // line 53 + +// Class with required args - hint with new (...) +enum e5 = C2; // line 56 From 60c5b38de3e39c562a36fd400f76161f66ddddcb Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Fri, 30 Jan 2026 22:47:50 -0800 Subject: [PATCH 306/440] remove phobos dependency from test suite --- tests/dmd/runnable/stress.d | 51 ------------------------------------- 1 file changed, 51 deletions(-) diff --git a/tests/dmd/runnable/stress.d b/tests/dmd/runnable/stress.d index 66373c4270..078041aced 100644 --- a/tests/dmd/runnable/stress.d +++ b/tests/dmd/runnable/stress.d @@ -2,8 +2,6 @@ // PERMUTE_ARGS: import core.stdc.stdio : printf; -import std.string : splitLines; -import std.utf : toUTF16, toUTF32; /***********************************************/ @@ -106,19 +104,6 @@ void MDCHAR() foreach(char[] s; str) { tmp = tmp ~ s; } - - foreach(s; splitLines(cast(string)tmp)) { - size_t lstart; - foreach(size_t idx, char c; s) { - if(c == '\n') { - if(s[lstart..idx] != "TEST LINE") { - printf("Error testing character array\n"); - break; - } - lstart = idx + 1; - } - } - } } void CHAR() @@ -151,24 +136,6 @@ void WCHAR() const int ITERS = 1000; alias wchar typ; typ[] str; - - for(int idx = 0; idx < ITERS; idx++) { - str = str ~ toUTF16(cast(char[])"TEST LINE\n"); - } - - if(str.length != (ITERS * 10)) printf("Length Error: %zd\n",str.length); - if(str.sizeof != (typ[]).sizeof) printf("Size Error: %zd\n",str.sizeof); - - size_t lstart; - foreach(size_t idx, char c; str) { - if(c == '\n') { - if(str[lstart..idx] != toUTF16(cast(char[])"TEST LINE")) { - printf("Error testing character array\n"); - break; - } - lstart = idx + 1; - } - } } void DCHAR() @@ -176,24 +143,6 @@ void DCHAR() const int ITERS = 1000; alias dchar typ; typ[] str; - - for(int idx = 0; idx < ITERS; idx++) { - str = str ~ toUTF32(cast(char[])"TEST LINE\n"); - } - - if(str.length != (ITERS * 10)) printf("Length Error: %zd\n",str.length); - if(str.sizeof != (typ[]).sizeof) printf("Size Error: %zd\n",str.sizeof); - - size_t lstart; - foreach(size_t idx, char c; str) { - if(c == '\n') { - if(str[lstart..idx] != toUTF32(cast(char[])"TEST LINE")) { - printf("Error testing character array\n"); - break; - } - lstart = idx + 1; - } - } } void BYTE() From 8f11b07c55e68d2ec7e1a6e954c3ca69c8967877 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Sat, 31 Jan 2026 15:31:23 +0800 Subject: [PATCH 307/440] Fix dlang/dmd!22481 - inliner silently removes return in loops --- dmd/inlinecost.d | 4 ++++ tests/dmd/runnable/issue22481.d | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/dmd/runnable/issue22481.d diff --git a/dmd/inlinecost.d b/dmd/inlinecost.d index 1be5a4a6aa..ea792f77ce 100644 --- a/dmd/inlinecost.d +++ b/dmd/inlinecost.d @@ -313,7 +313,11 @@ public: if (s.increment) s.increment.accept(this); if (s._body) + { + nested += 1; s._body.accept(this); + nested -= 1; + } //printf("ForStatement: inlineCost = %d\n", cost); } diff --git a/tests/dmd/runnable/issue22481.d b/tests/dmd/runnable/issue22481.d new file mode 100644 index 0000000000..bbd0338f0e --- /dev/null +++ b/tests/dmd/runnable/issue22481.d @@ -0,0 +1,18 @@ +// REQUIRED_ARGS: -inline + +int v; + +void f() +{ + for (int i = 1; i < 5; i++) + { + v = i; + return; + } +} + +void main() +{ + f(); + assert(v == 1); +} From 99ddcb3d4c769ea889928e4dd3f28f7d3b669f9d Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sun, 25 Jan 2026 19:59:21 +0000 Subject: [PATCH 308/440] [druntime] Replace old AliasDeclaration syntax for 2024 edition See https://github.com/dlang/dmd/pull/22244. I used `dfix` with some updates: https://github.com/dlang-community/dfix/pull/63 I did: * revert a few unrelated diff hunks it produced (`core/sys/linux/ input.d`) * manually update a mixin in `core/sys/linux/link.d` * put a stripped out comment back in `core/sys/windows/basetyps.d`: `alias UUID = GUID, /*IID, CLSID, */FMTID = GUID, uuid_t = GUID;` There's at least 2 long aliases with multiple components that could be broken up: * at the start of `core/sys/windows/commdlg.d` * in `core/sys/windows/wincrypt.d` --- .../src/core/internal/backtrace/unwind.d | 18 +- .../src/core/internal/container/array.d | 2 +- runtime/druntime/src/core/internal/gc/bits.d | 2 +- .../core/internal/gc/impl/conservative/gc.d | 2 +- runtime/druntime/src/core/internal/gc/os.d | 2 +- runtime/druntime/src/core/internal/qsort.d | 12 +- runtime/druntime/src/core/internal/traits.d | 4 +- runtime/druntime/src/core/internal/utf.d | 2 +- .../src/core/internal/vararg/sysv_x64.d | 6 +- runtime/druntime/src/core/simd.d | 96 +- runtime/druntime/src/core/stdc/complex.d | 4 +- runtime/druntime/src/core/stdc/config.d | 104 +- runtime/druntime/src/core/stdc/fenv.d | 46 +- runtime/druntime/src/core/stdc/inttypes.d | 2 +- runtime/druntime/src/core/stdc/math.d | 4 +- runtime/druntime/src/core/stdc/signal.d | 4 +- runtime/druntime/src/core/stdc/stddef.d | 6 +- runtime/druntime/src/core/stdc/stdio.d | 126 +- runtime/druntime/src/core/stdc/stdlib.d | 2 +- runtime/druntime/src/core/stdc/tgmath.d | 1388 ++++++++--------- runtime/druntime/src/core/stdc/wchar_.d | 4 +- runtime/druntime/src/core/stdc/wctype.d | 4 +- .../src/core/sys/darwin/mach/kern_return.d | 2 +- .../src/core/sys/darwin/mach/semaphore.d | 10 +- .../src/core/sys/darwin/mach/thread_act.d | 12 +- .../druntime/src/core/sys/darwin/sys/attr.d | 2 +- .../src/core/sys/dragonflybsd/sys/elf32.d | 10 +- .../src/core/sys/dragonflybsd/sys/elf64.d | 10 +- .../core/sys/dragonflybsd/sys/elf_common.d | 4 +- .../src/core/sys/dragonflybsd/sys/link_elf.d | 6 +- runtime/druntime/src/core/sys/elf/package.d | 50 +- .../druntime/src/core/sys/freebsd/sys/elf32.d | 10 +- .../druntime/src/core/sys/freebsd/sys/elf64.d | 10 +- .../src/core/sys/freebsd/sys/elf_common.d | 4 +- .../src/core/sys/freebsd/sys/link_elf.d | 6 +- runtime/druntime/src/core/sys/linux/dlfcn.d | 2 +- runtime/druntime/src/core/sys/linux/elf.d | 2 +- runtime/druntime/src/core/sys/linux/link.d | 50 +- runtime/druntime/src/core/sys/linux/sched.d | 2 +- runtime/druntime/src/core/sys/linux/stdio.d | 8 +- .../druntime/src/core/sys/linux/sys/eventfd.d | 2 +- .../druntime/src/core/sys/netbsd/sys/elf32.d | 10 +- .../druntime/src/core/sys/netbsd/sys/elf64.d | 10 +- .../src/core/sys/netbsd/sys/elf_common.d | 4 +- .../src/core/sys/netbsd/sys/link_elf.d | 6 +- .../druntime/src/core/sys/openbsd/sys/elf32.d | 10 +- .../druntime/src/core/sys/openbsd/sys/elf64.d | 10 +- .../src/core/sys/openbsd/sys/elf_common.d | 4 +- .../src/core/sys/openbsd/sys/link_elf.d | 4 +- .../druntime/src/core/sys/posix/arpa/inet.d | 38 +- runtime/druntime/src/core/sys/posix/dirent.d | 26 +- runtime/druntime/src/core/sys/posix/fcntl.d | 24 +- runtime/druntime/src/core/sys/posix/iconv.d | 2 +- runtime/druntime/src/core/sys/posix/mqueue.d | 2 +- runtime/druntime/src/core/sys/posix/poll.d | 20 +- runtime/druntime/src/core/sys/posix/pthread.d | 4 +- runtime/druntime/src/core/sys/posix/pwd.d | 4 +- .../druntime/src/core/sys/posix/semaphore.d | 6 +- runtime/druntime/src/core/sys/posix/setjmp.d | 50 +- runtime/druntime/src/core/sys/posix/signal.d | 28 +- runtime/druntime/src/core/sys/posix/stdio.d | 32 +- runtime/druntime/src/core/sys/posix/stdlib.d | 10 +- .../src/core/sys/posix/sys/resource.d | 36 +- .../druntime/src/core/sys/posix/sys/select.d | 18 +- runtime/druntime/src/core/sys/posix/sys/shm.d | 14 +- .../druntime/src/core/sys/posix/sys/socket.d | 30 +- .../druntime/src/core/sys/posix/sys/stat.d | 52 +- .../druntime/src/core/sys/posix/sys/statvfs.d | 4 +- .../druntime/src/core/sys/posix/sys/types.d | 514 +++--- .../druntime/src/core/sys/posix/sys/wait.d | 2 +- runtime/druntime/src/core/sys/posix/termios.d | 36 +- runtime/druntime/src/core/sys/posix/time.d | 40 +- .../druntime/src/core/sys/posix/ucontext.d | 64 +- runtime/druntime/src/core/sys/posix/unistd.d | 54 +- runtime/druntime/src/core/sys/solaris/dlfcn.d | 2 +- runtime/druntime/src/core/sys/solaris/link.d | 12 +- .../druntime/src/core/sys/solaris/sys/elf.d | 16 +- .../src/core/sys/solaris/sys/elftypes.d | 4 +- .../druntime/src/core/sys/solaris/sys/link.d | 4 +- .../druntime/src/core/sys/solaris/sys/types.d | 2 +- .../druntime/src/core/sys/windows/accctrl.d | 136 +- .../druntime/src/core/sys/windows/aclapi.d | 82 +- runtime/druntime/src/core/sys/windows/aclui.d | 8 +- .../druntime/src/core/sys/windows/basetsd.d | 92 +- .../druntime/src/core/sys/windows/basetyps.d | 8 +- .../druntime/src/core/sys/windows/comcat.d | 30 +- .../druntime/src/core/sys/windows/commctrl.d | 1139 +++++++------- .../druntime/src/core/sys/windows/commdlg.d | 132 +- runtime/druntime/src/core/sys/windows/cpl.d | 18 +- .../druntime/src/core/sys/windows/custcntl.d | 54 +- .../druntime/src/core/sys/windows/dbghelp.d | 46 +- .../src/core/sys/windows/dbghelp_types.d | 12 +- runtime/druntime/src/core/sys/windows/dbt.d | 28 +- runtime/druntime/src/core/sys/windows/ddeml.d | 34 +- .../druntime/src/core/sys/windows/dhcpcsdk.d | 6 +- runtime/druntime/src/core/sys/windows/dll.d | 8 +- .../druntime/src/core/sys/windows/docobj.d | 4 +- .../druntime/src/core/sys/windows/errorrep.d | 4 +- .../druntime/src/core/sys/windows/httpext.d | 16 +- .../druntime/src/core/sys/windows/imagehlp.d | 52 +- runtime/druntime/src/core/sys/windows/imm.d | 126 +- .../druntime/src/core/sys/windows/intshcut.d | 19 +- .../druntime/src/core/sys/windows/ipexport.d | 12 +- .../druntime/src/core/sys/windows/iprtrmib.d | 36 +- .../druntime/src/core/sys/windows/iptypes.d | 12 +- .../druntime/src/core/sys/windows/lmaccess.d | 130 +- .../druntime/src/core/sys/windows/lmalert.d | 10 +- runtime/druntime/src/core/sys/windows/lmat.d | 4 +- .../druntime/src/core/sys/windows/lmaudit.d | 40 +- .../druntime/src/core/sys/windows/lmbrowsr.d | 6 +- .../druntime/src/core/sys/windows/lmchdev.d | 14 +- .../druntime/src/core/sys/windows/lmconfig.d | 2 +- .../druntime/src/core/sys/windows/lmcons.d | 10 +- .../druntime/src/core/sys/windows/lmerrlog.d | 2 +- runtime/druntime/src/core/sys/windows/lmmsg.d | 4 +- .../druntime/src/core/sys/windows/lmremutl.d | 6 +- .../druntime/src/core/sys/windows/lmrepl.d | 24 +- .../druntime/src/core/sys/windows/lmserver.d | 179 ++- .../druntime/src/core/sys/windows/lmshare.d | 32 +- .../druntime/src/core/sys/windows/lmstats.d | 4 +- runtime/druntime/src/core/sys/windows/lmsvc.d | 6 +- runtime/druntime/src/core/sys/windows/lmuse.d | 6 +- .../druntime/src/core/sys/windows/lmwksta.d | 84 +- .../druntime/src/core/sys/windows/lzexpand.d | 8 +- runtime/druntime/src/core/sys/windows/mapi.d | 52 +- runtime/druntime/src/core/sys/windows/mcx.d | 4 +- .../druntime/src/core/sys/windows/mgmtapi.d | 2 +- .../druntime/src/core/sys/windows/mmsystem.d | 486 +++--- runtime/druntime/src/core/sys/windows/msacm.d | 72 +- .../druntime/src/core/sys/windows/mshtml.d | 36 +- .../druntime/src/core/sys/windows/mswsock.d | 10 +- runtime/druntime/src/core/sys/windows/nb30.d | 18 +- .../druntime/src/core/sys/windows/nddeapi.d | 52 +- .../druntime/src/core/sys/windows/nspapi.d | 30 +- runtime/druntime/src/core/sys/windows/ntdef.d | 18 +- .../druntime/src/core/sys/windows/ntsecapi.d | 160 +- .../druntime/src/core/sys/windows/ntsecpkg.d | 304 ++-- runtime/druntime/src/core/sys/windows/oaidl.d | 72 +- .../druntime/src/core/sys/windows/objbase.d | 8 +- .../druntime/src/core/sys/windows/objfwd.d | 84 +- .../druntime/src/core/sys/windows/objidl.d | 24 +- runtime/druntime/src/core/sys/windows/ocidl.d | 52 +- .../druntime/src/core/sys/windows/odbcinst.d | 46 +- runtime/druntime/src/core/sys/windows/ole.d | 28 +- runtime/druntime/src/core/sys/windows/ole2.d | 4 +- .../druntime/src/core/sys/windows/oleacc.d | 14 +- .../druntime/src/core/sys/windows/oleauto.d | 14 +- .../druntime/src/core/sys/windows/olectl.d | 64 +- .../druntime/src/core/sys/windows/oledlg.d | 282 ++-- .../druntime/src/core/sys/windows/oleidl.d | 50 +- .../druntime/src/core/sys/windows/powrprof.d | 21 +- runtime/druntime/src/core/sys/windows/prsht.d | 73 +- runtime/druntime/src/core/sys/windows/psapi.d | 50 +- runtime/druntime/src/core/sys/windows/rapi.d | 2 +- runtime/druntime/src/core/sys/windows/ras.d | 358 ++--- .../druntime/src/core/sys/windows/rasdlg.d | 48 +- .../druntime/src/core/sys/windows/rassapi.d | 12 +- .../druntime/src/core/sys/windows/regstr.d | 2 +- .../druntime/src/core/sys/windows/richedit.d | 30 +- .../druntime/src/core/sys/windows/richole.d | 4 +- runtime/druntime/src/core/sys/windows/rpc.d | 4 +- .../druntime/src/core/sys/windows/rpcdce.d | 164 +- .../druntime/src/core/sys/windows/rpcdce2.d | 8 +- .../druntime/src/core/sys/windows/rpcdcep.d | 26 +- .../druntime/src/core/sys/windows/rpcndr.d | 84 +- .../druntime/src/core/sys/windows/rpcnsi.d | 80 +- .../druntime/src/core/sys/windows/rpcnsip.d | 2 +- .../druntime/src/core/sys/windows/schannel.d | 12 +- .../druntime/src/core/sys/windows/secext.d | 14 +- .../druntime/src/core/sys/windows/setupapi.d | 782 +++++----- .../druntime/src/core/sys/windows/shellapi.d | 92 +- .../druntime/src/core/sys/windows/shldisp.d | 4 +- .../druntime/src/core/sys/windows/shlobj.d | 236 +-- .../druntime/src/core/sys/windows/shlwapi.d | 536 +++---- runtime/druntime/src/core/sys/windows/snmp.d | 83 +- .../druntime/src/core/sys/windows/sqltypes.d | 66 +- .../druntime/src/core/sys/windows/sqlucode.d | 74 +- runtime/druntime/src/core/sys/windows/sspi.d | 224 +-- .../src/core/sys/windows/stacktrace.d | 2 +- .../druntime/src/core/sys/windows/stdc/time.d | 4 +- .../druntime/src/core/sys/windows/subauth.d | 42 +- .../druntime/src/core/sys/windows/threadaux.d | 14 +- .../druntime/src/core/sys/windows/tlhelp32.d | 48 +- .../druntime/src/core/sys/windows/unknwn.d | 4 +- runtime/druntime/src/core/sys/windows/vfw.d | 194 +-- .../druntime/src/core/sys/windows/winbase.d | 796 +++++----- .../druntime/src/core/sys/windows/winber.d | 8 +- .../druntime/src/core/sys/windows/wincon.d | 78 +- .../druntime/src/core/sys/windows/wincrypt.d | 116 +- .../druntime/src/core/sys/windows/windef.d | 48 +- .../druntime/src/core/sys/windows/winerror.d | 2 +- .../druntime/src/core/sys/windows/wingdi.d | 928 +++++------ .../druntime/src/core/sys/windows/winhttp.d | 2 +- .../druntime/src/core/sys/windows/wininet.d | 345 ++-- .../druntime/src/core/sys/windows/winioctl.d | 88 +- .../druntime/src/core/sys/windows/winldap.d | 372 ++--- .../druntime/src/core/sys/windows/winnetwk.d | 160 +- .../druntime/src/core/sys/windows/winnls.d | 220 ++- runtime/druntime/src/core/sys/windows/winnt.d | 456 +++--- .../druntime/src/core/sys/windows/winperf.d | 16 +- .../druntime/src/core/sys/windows/winreg.d | 114 +- .../druntime/src/core/sys/windows/winsock2.d | 12 +- .../druntime/src/core/sys/windows/winspool.d | 402 ++--- .../druntime/src/core/sys/windows/winsvc.d | 160 +- .../druntime/src/core/sys/windows/winuser.d | 1012 ++++++------ .../druntime/src/core/sys/windows/winver.d | 28 +- .../druntime/src/core/sys/windows/wtsapi32.d | 104 +- .../druntime/src/core/sys/windows/wtypes.d | 28 +- runtime/druntime/src/core/time.d | 6 +- runtime/druntime/src/rt/deh_win32.d | 12 +- runtime/druntime/src/rt/deh_win64_posix.d | 2 +- runtime/druntime/src/rt/dmain2.d | 8 +- runtime/druntime/src/rt/lifetime.d | 4 +- runtime/druntime/src/rt/sections_elf_shared.d | 2 +- runtime/druntime/src/rt/sections_win64.d | 4 +- runtime/druntime/src/rt/tlsgc.d | 2 +- runtime/druntime/src/rt/trace.d | 2 +- 217 files changed, 8401 insertions(+), 8456 deletions(-) diff --git a/runtime/druntime/src/core/internal/backtrace/unwind.d b/runtime/druntime/src/core/internal/backtrace/unwind.d index 6c88d78c19..3cd91f2196 100644 --- a/runtime/druntime/src/core/internal/backtrace/unwind.d +++ b/runtime/druntime/src/core/internal/backtrace/unwind.d @@ -21,17 +21,17 @@ version (X86_64) version = X86_Any; extern (C): -alias uintptr_t _Unwind_Word; -alias intptr_t _Unwind_Sword; -alias uintptr_t _Unwind_Ptr; -alias uintptr_t _Unwind_Internal_Ptr; +alias _Unwind_Word = uintptr_t; +alias _Unwind_Sword = intptr_t; +alias _Unwind_Ptr = uintptr_t; +alias _Unwind_Internal_Ptr = uintptr_t; -alias ulong _Unwind_Exception_Class; +alias _Unwind_Exception_Class = ulong; -alias uintptr_t _uleb128_t; -alias intptr_t _sleb128_t; +alias _uleb128_t = uintptr_t; +alias _sleb128_t = intptr_t; -alias int _Unwind_Reason_Code; +alias _Unwind_Reason_Code = int; enum { _URC_NO_REASON = 0, @@ -47,7 +47,7 @@ enum version (ARM_EABI_UNWINDER) enum _URC_FAILURE = 9; -alias int _Unwind_Action; +alias _Unwind_Action = int; enum _Unwind_Action _UA_SEARCH_PHASE = 1; enum _Unwind_Action _UA_CLEANUP_PHASE = 2; enum _Unwind_Action _UA_HANDLER_FRAME = 4; diff --git a/runtime/druntime/src/core/internal/container/array.d b/runtime/druntime/src/core/internal/container/array.d index f1a7e5b28a..c36ba28d72 100644 --- a/runtime/druntime/src/core/internal/container/array.d +++ b/runtime/druntime/src/core/internal/container/array.d @@ -89,7 +89,7 @@ nothrow: return _ptr[a .. b]; } - alias length opDollar; + alias opDollar = length; void insertBack()(auto ref T val) { diff --git a/runtime/druntime/src/core/internal/gc/bits.d b/runtime/druntime/src/core/internal/gc/bits.d index f38e5cbe55..8aabf9e393 100644 --- a/runtime/druntime/src/core/internal/gc/bits.d +++ b/runtime/druntime/src/core/internal/gc/bits.d @@ -21,7 +21,7 @@ import core.stdc.string : memcpy, memset; struct GCBits { @nogc: - alias size_t wordtype; + alias wordtype = size_t; enum BITS_PER_WORD = (wordtype.sizeof * 8); enum BITS_SHIFT = (wordtype.sizeof == 8 ? 6 : 5); diff --git a/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d b/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d index af7ea7901f..ae40bd363d 100644 --- a/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d +++ b/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d @@ -105,7 +105,7 @@ private } } -alias GC gc_t; +alias gc_t = GC; /* ============================ GC =============================== */ diff --git a/runtime/druntime/src/core/internal/gc/os.d b/runtime/druntime/src/core/internal/gc/os.d index e9a253369e..914b7b903c 100644 --- a/runtime/druntime/src/core/internal/gc/os.d +++ b/runtime/druntime/src/core/internal/gc/os.d @@ -13,7 +13,7 @@ version (Windows) import core.sys.windows.winbase : GetCurrentThreadId, VirtualAlloc, VirtualFree; import core.sys.windows.winnt : MEM_COMMIT, MEM_RELEASE, MEM_RESERVE, PAGE_READWRITE; - alias int pthread_t; + alias pthread_t = int; pthread_t pthread_self() nothrow { diff --git a/runtime/druntime/src/core/internal/qsort.d b/runtime/druntime/src/core/internal/qsort.d index 8e789e7051..e9982262ae 100644 --- a/runtime/druntime/src/core/internal/qsort.d +++ b/runtime/druntime/src/core/internal/qsort.d @@ -41,7 +41,7 @@ else static if (Glibc_Qsort_R) { - alias extern (C) int function(scope const void *, scope const void *, scope void *) Cmp; + alias Cmp = extern (C) int function(scope const void *, scope const void *, scope void *); extern (C) void qsort_r(scope void *base, size_t nmemb, size_t size, Cmp cmp, scope void *arg); extern (C) void[] _adSort(return scope void[] a, TypeInfo ti) @@ -61,7 +61,7 @@ else version (FreeBSD) static if (__FreeBSD_version >= 1400000) { // FreeBSD changed qsort_r function signature to POSIX in FreeBSD 14.0 - alias extern (C) int function(scope const void*, scope const void*, scope void*) Cmp; + alias Cmp = extern (C) int function(scope const void*, scope const void*, scope void*); extern (C) void qsort_r(scope void* base, size_t nmemb, size_t size, Cmp cmp, scope void* thunk); extern (C) void[] _adSort(return scope void[] a, TypeInfo ti) @@ -76,7 +76,7 @@ else version (FreeBSD) } else { - alias extern (C) int function(scope void *, scope const void *, scope const void *) Cmp; + alias Cmp = extern (C) int function(scope void *, scope const void *, scope const void *); extern (C) void qsort_r(scope void* base, size_t nmemb, size_t size, scope void* thunk, Cmp cmp); extern (C) void[] _adSort(return scope void[] a, TypeInfo ti) @@ -92,7 +92,7 @@ else version (FreeBSD) } else version (DragonFlyBSD) { - alias extern (C) int function(scope void *, scope const void *, scope const void *) Cmp; + alias Cmp = extern (C) int function(scope void *, scope const void *, scope const void *); extern (C) void qsort_r(scope void *base, size_t nmemb, size_t size, scope void *thunk, Cmp cmp); extern (C) void[] _adSort(return scope void[] a, TypeInfo ti) @@ -107,7 +107,7 @@ else version (DragonFlyBSD) } else version (Darwin) { - alias extern (C) int function(scope void *, scope const void *, scope const void *) Cmp; + alias Cmp = extern (C) int function(scope void *, scope const void *, scope const void *); extern (C) void qsort_r(scope void *base, size_t nmemb, size_t size, scope void *thunk, Cmp cmp); extern (C) void[] _adSort(return scope void[] a, TypeInfo ti) @@ -122,7 +122,7 @@ else version (Darwin) } else version (CRuntime_UClibc) { - alias extern (C) int function(scope const void *, scope const void *, scope void *) __compar_d_fn_t; + alias __compar_d_fn_t = extern (C) int function(scope const void *, scope const void *, scope void *); extern (C) void qsort_r(scope void *base, size_t nmemb, size_t size, __compar_d_fn_t cmp, scope void *arg); extern (C) void[] _adSort(return scope void[] a, TypeInfo ti) diff --git a/runtime/druntime/src/core/internal/traits.d b/runtime/druntime/src/core/internal/traits.d index 52e3307256..7ffee2ec0b 100644 --- a/runtime/druntime/src/core/internal/traits.d +++ b/runtime/druntime/src/core/internal/traits.d @@ -1041,8 +1041,8 @@ if (func.length == 1 /*&& isCallable!func*/) static assert(is( typeof(test) == FunctionTypeOf!test )); static assert(is( typeof(test) == FunctionTypeOf!test_fp )); static assert(is( typeof(test) == FunctionTypeOf!test_dg )); - alias int GetterType() @property; - alias int SetterType(int) @property; + alias GetterType = int() @property; + alias SetterType = int(int) @property; static assert(is( FunctionTypeOf!propGet == GetterType )); static assert(is( FunctionTypeOf!propSet == SetterType )); diff --git a/runtime/druntime/src/core/internal/utf.d b/runtime/druntime/src/core/internal/utf.d index 71c3211947..88c985a763 100644 --- a/runtime/druntime/src/core/internal/utf.d +++ b/runtime/druntime/src/core/internal/utf.d @@ -755,7 +755,7 @@ wstring toUTF16(const scope char[] s) return cast(wstring)r; } -alias const(wchar)* wptr; +alias wptr = const(wchar)*; /** ditto */ @safe pure wptr toUTF16z(const scope char[] s) diff --git a/runtime/druntime/src/core/internal/vararg/sysv_x64.d b/runtime/druntime/src/core/internal/vararg/sysv_x64.d index 795de87459..b9459265ad 100644 --- a/runtime/druntime/src/core/internal/vararg/sysv_x64.d +++ b/runtime/druntime/src/core/internal/vararg/sysv_x64.d @@ -65,7 +65,7 @@ T va_arg(T)(va_list ap) } else static if (U.length == 1) { // Arg is passed in one register - alias U[0] T1; + alias T1 = U[0]; static if (is(T1 == double) || is(T1 == float) || is(T1 == __vector)) { // Passed in XMM register if (ap.offset_fpregs < (6 * 8 + 16 * 8)) @@ -99,8 +99,8 @@ T va_arg(T)(va_list ap) } else static if (U.length == 2) { // Arg is passed in two registers - alias U[0] T1; - alias U[1] T2; + alias T1 = U[0]; + alias T2 = U[1]; T result = void; auto p1 = cast(T1*) &result; diff --git a/runtime/druntime/src/core/simd.d b/runtime/druntime/src/core/simd.d index c2b343a084..a735ffcb37 100644 --- a/runtime/druntime/src/core/simd.d +++ b/runtime/druntime/src/core/simd.d @@ -34,58 +34,58 @@ template Vector(T) /* __vector is compiler magic, hide it behind a template. * The compiler will reject T's that don't work. */ - alias __vector(T) Vector; + alias Vector = __vector(T); } /* Handy aliases */ -static if (is(Vector!(void[8]))) alias Vector!(void[8]) void8; /// -static if (is(Vector!(double[1]))) alias Vector!(double[1]) double1; /// -static if (is(Vector!(float[2]))) alias Vector!(float[2]) float2; /// -static if (is(Vector!(byte[8]))) alias Vector!(byte[8]) byte8; /// -static if (is(Vector!(ubyte[8]))) alias Vector!(ubyte[8]) ubyte8; /// -static if (is(Vector!(short[4]))) alias Vector!(short[4]) short4; /// -static if (is(Vector!(ushort[4]))) alias Vector!(ushort[4]) ushort4; /// -static if (is(Vector!(int[2]))) alias Vector!(int[2]) int2; /// -static if (is(Vector!(uint[2]))) alias Vector!(uint[2]) uint2; /// -static if (is(Vector!(long[1]))) alias Vector!(long[1]) long1; /// -static if (is(Vector!(ulong[1]))) alias Vector!(ulong[1]) ulong1; /// - -static if (is(Vector!(void[16]))) alias Vector!(void[16]) void16; /// -static if (is(Vector!(double[2]))) alias Vector!(double[2]) double2; /// -static if (is(Vector!(float[4]))) alias Vector!(float[4]) float4; /// -static if (is(Vector!(byte[16]))) alias Vector!(byte[16]) byte16; /// -static if (is(Vector!(ubyte[16]))) alias Vector!(ubyte[16]) ubyte16; /// -static if (is(Vector!(short[8]))) alias Vector!(short[8]) short8; /// -static if (is(Vector!(ushort[8]))) alias Vector!(ushort[8]) ushort8; /// -static if (is(Vector!(int[4]))) alias Vector!(int[4]) int4; /// -static if (is(Vector!(uint[4]))) alias Vector!(uint[4]) uint4; /// -static if (is(Vector!(long[2]))) alias Vector!(long[2]) long2; /// -static if (is(Vector!(ulong[2]))) alias Vector!(ulong[2]) ulong2; /// - -static if (is(Vector!(void[32]))) alias Vector!(void[32]) void32; /// -static if (is(Vector!(double[4]))) alias Vector!(double[4]) double4; /// -static if (is(Vector!(float[8]))) alias Vector!(float[8]) float8; /// -static if (is(Vector!(byte[32]))) alias Vector!(byte[32]) byte32; /// -static if (is(Vector!(ubyte[32]))) alias Vector!(ubyte[32]) ubyte32; /// -static if (is(Vector!(short[16]))) alias Vector!(short[16]) short16; /// -static if (is(Vector!(ushort[16]))) alias Vector!(ushort[16]) ushort16; /// -static if (is(Vector!(int[8]))) alias Vector!(int[8]) int8; /// -static if (is(Vector!(uint[8]))) alias Vector!(uint[8]) uint8; /// -static if (is(Vector!(long[4]))) alias Vector!(long[4]) long4; /// -static if (is(Vector!(ulong[4]))) alias Vector!(ulong[4]) ulong4; /// - -static if (is(Vector!(void[64]))) alias Vector!(void[64]) void64; /// -static if (is(Vector!(double[8]))) alias Vector!(double[8]) double8; /// -static if (is(Vector!(float[16]))) alias Vector!(float[16]) float16; /// -static if (is(Vector!(byte[64]))) alias Vector!(byte[64]) byte64; /// -static if (is(Vector!(ubyte[64]))) alias Vector!(ubyte[64]) ubyte64; /// -static if (is(Vector!(short[32]))) alias Vector!(short[32]) short32; /// -static if (is(Vector!(ushort[32]))) alias Vector!(ushort[32]) ushort32; /// -static if (is(Vector!(int[16]))) alias Vector!(int[16]) int16; /// -static if (is(Vector!(uint[16]))) alias Vector!(uint[16]) uint16; /// -static if (is(Vector!(long[8]))) alias Vector!(long[8]) long8; /// -static if (is(Vector!(ulong[8]))) alias Vector!(ulong[8]) ulong8; /// +static if (is(Vector!(void[8]))) alias void8 = Vector!(void[8]); /// +static if (is(Vector!(double[1]))) alias double1 = Vector!(double[1]); /// +static if (is(Vector!(float[2]))) alias float2 = Vector!(float[2]); /// +static if (is(Vector!(byte[8]))) alias byte8 = Vector!(byte[8]); /// +static if (is(Vector!(ubyte[8]))) alias ubyte8 = Vector!(ubyte[8]); /// +static if (is(Vector!(short[4]))) alias short4 = Vector!(short[4]); /// +static if (is(Vector!(ushort[4]))) alias ushort4 = Vector!(ushort[4]); /// +static if (is(Vector!(int[2]))) alias int2 = Vector!(int[2]); /// +static if (is(Vector!(uint[2]))) alias uint2 = Vector!(uint[2]); /// +static if (is(Vector!(long[1]))) alias long1 = Vector!(long[1]); /// +static if (is(Vector!(ulong[1]))) alias ulong1 = Vector!(ulong[1]); /// + +static if (is(Vector!(void[16]))) alias void16 = Vector!(void[16]); /// +static if (is(Vector!(double[2]))) alias double2 = Vector!(double[2]); /// +static if (is(Vector!(float[4]))) alias float4 = Vector!(float[4]); /// +static if (is(Vector!(byte[16]))) alias byte16 = Vector!(byte[16]); /// +static if (is(Vector!(ubyte[16]))) alias ubyte16 = Vector!(ubyte[16]); /// +static if (is(Vector!(short[8]))) alias short8 = Vector!(short[8]); /// +static if (is(Vector!(ushort[8]))) alias ushort8 = Vector!(ushort[8]); /// +static if (is(Vector!(int[4]))) alias int4 = Vector!(int[4]); /// +static if (is(Vector!(uint[4]))) alias uint4 = Vector!(uint[4]); /// +static if (is(Vector!(long[2]))) alias long2 = Vector!(long[2]); /// +static if (is(Vector!(ulong[2]))) alias ulong2 = Vector!(ulong[2]); /// + +static if (is(Vector!(void[32]))) alias void32 = Vector!(void[32]); /// +static if (is(Vector!(double[4]))) alias double4 = Vector!(double[4]); /// +static if (is(Vector!(float[8]))) alias float8 = Vector!(float[8]); /// +static if (is(Vector!(byte[32]))) alias byte32 = Vector!(byte[32]); /// +static if (is(Vector!(ubyte[32]))) alias ubyte32 = Vector!(ubyte[32]); /// +static if (is(Vector!(short[16]))) alias short16 = Vector!(short[16]); /// +static if (is(Vector!(ushort[16]))) alias ushort16 = Vector!(ushort[16]); /// +static if (is(Vector!(int[8]))) alias int8 = Vector!(int[8]); /// +static if (is(Vector!(uint[8]))) alias uint8 = Vector!(uint[8]); /// +static if (is(Vector!(long[4]))) alias long4 = Vector!(long[4]); /// +static if (is(Vector!(ulong[4]))) alias ulong4 = Vector!(ulong[4]); /// + +static if (is(Vector!(void[64]))) alias void64 = Vector!(void[64]); /// +static if (is(Vector!(double[8]))) alias double8 = Vector!(double[8]); /// +static if (is(Vector!(float[16]))) alias float16 = Vector!(float[16]); /// +static if (is(Vector!(byte[64]))) alias byte64 = Vector!(byte[64]); /// +static if (is(Vector!(ubyte[64]))) alias ubyte64 = Vector!(ubyte[64]); /// +static if (is(Vector!(short[32]))) alias short32 = Vector!(short[32]); /// +static if (is(Vector!(ushort[32]))) alias ushort32 = Vector!(ushort[32]); /// +static if (is(Vector!(int[16]))) alias int16 = Vector!(int[16]); /// +static if (is(Vector!(uint[16]))) alias uint16 = Vector!(uint[16]); /// +static if (is(Vector!(long[8]))) alias long8 = Vector!(long[8]); /// +static if (is(Vector!(ulong[8]))) alias ulong8 = Vector!(ulong[8]); /// version (D_SIMD) { diff --git a/runtime/druntime/src/core/stdc/complex.d b/runtime/druntime/src/core/stdc/complex.d index b84651f3f1..4009c21230 100644 --- a/runtime/druntime/src/core/stdc/complex.d +++ b/runtime/druntime/src/core/stdc/complex.d @@ -21,8 +21,8 @@ nothrow: // @@@DEPRECATED_2.105@@@ deprecated: -alias creal complex; -alias ireal imaginary; +alias complex = creal; +alias imaginary = ireal; cdouble cacos(cdouble z); cfloat cacosf(cfloat z); creal cacosl(creal z); diff --git a/runtime/druntime/src/core/stdc/config.d b/runtime/druntime/src/core/stdc/config.d index 952ceacb21..7c5b53df1f 100644 --- a/runtime/druntime/src/core/stdc/config.d +++ b/runtime/druntime/src/core/stdc/config.d @@ -122,34 +122,34 @@ version (GNU) { import gcc.builtins; - alias __builtin_clong c_long; - alias __builtin_culong c_ulong; + alias c_long = __builtin_clong; + alias c_ulong = __builtin_culong; enum __c_long : __builtin_clong; enum __c_ulong : __builtin_culong; - alias __c_long cpp_long; - alias __c_ulong cpp_ulong; + alias cpp_long = __c_long; + alias cpp_ulong = __c_ulong; enum __c_longlong : __builtin_clonglong; enum __c_ulonglong : __builtin_culonglong; - alias __c_longlong cpp_longlong; - alias __c_ulonglong cpp_ulonglong; + alias cpp_longlong = __c_longlong; + alias cpp_ulonglong = __c_ulonglong; } else version (Windows) { enum __c_long : int; enum __c_ulong : uint; - alias int c_long; - alias uint c_ulong; + alias c_long = int; + alias c_ulong = uint; - alias __c_long cpp_long; - alias __c_ulong cpp_ulong; + alias cpp_long = __c_long; + alias cpp_ulong = __c_ulong; - alias long cpp_longlong; - alias ulong cpp_ulonglong; + alias cpp_longlong = long; + alias cpp_ulonglong = ulong; } else version (Posix) { @@ -158,28 +158,28 @@ else version (Posix) enum __c_longlong : long; enum __c_ulonglong : ulong; - alias long c_long; - alias ulong c_ulong; + alias c_long = long; + alias c_ulong = ulong; - alias long cpp_long; - alias ulong cpp_ulong; + alias cpp_long = long; + alias cpp_ulong = ulong; - alias __c_longlong cpp_longlong; - alias __c_ulonglong cpp_ulonglong; + alias cpp_longlong = __c_longlong; + alias cpp_ulonglong = __c_ulonglong; } else { enum __c_long : int; enum __c_ulong : uint; - alias int c_long; - alias uint c_ulong; + alias c_long = int; + alias c_ulong = uint; - alias __c_long cpp_long; - alias __c_ulong cpp_ulong; + alias cpp_long = __c_long; + alias cpp_ulong = __c_ulong; - alias long cpp_longlong; - alias ulong cpp_ulonglong; + alias cpp_longlong = long; + alias cpp_ulonglong = ulong; } } else version (WASI) @@ -189,28 +189,28 @@ else version (WASI) enum __c_longlong : long; enum __c_ulonglong : ulong; - alias long c_long; - alias ulong c_ulong; + alias c_long = long; + alias c_ulong = ulong; - alias long cpp_long; - alias ulong cpp_ulong; + alias cpp_long = long; + alias cpp_ulong = ulong; - alias __c_longlong cpp_longlong; - alias __c_ulonglong cpp_ulonglong; + alias cpp_longlong = __c_longlong; + alias cpp_ulonglong = __c_ulonglong; } else { enum __c_long : int; enum __c_ulong : uint; - alias int c_long; - alias uint c_ulong; + alias c_long = int; + alias c_ulong = uint; - alias __c_long cpp_long; - alias __c_ulong cpp_ulong; + alias cpp_long = __c_long; + alias cpp_ulong = __c_ulong; - alias long cpp_longlong; - alias ulong cpp_ulonglong; + alias cpp_longlong = long; + alias cpp_ulonglong = ulong; } } @@ -235,47 +235,47 @@ else version (CRuntime_Microsoft) */ enum __c_long_double : double; - alias __c_long_double c_long_double; + alias c_long_double = __c_long_double; } else version (DigitalMars) { version (X86) { - alias real c_long_double; + alias c_long_double = real; } else version (X86_64) { version (linux) - alias real c_long_double; + alias c_long_double = real; else version (FreeBSD) - alias real c_long_double; + alias c_long_double = real; else version (OpenBSD) - alias real c_long_double; + alias c_long_double = real; else version (NetBSD) - alias real c_long_double; + alias c_long_double = real; else version (DragonFlyBSD) - alias real c_long_double; + alias c_long_double = real; else version (Solaris) - alias real c_long_double; + alias c_long_double = real; else version (Darwin) - alias real c_long_double; + alias c_long_double = real; } else version (AArch64) { version (linux) - alias real c_long_double; + alias c_long_double = real; else version (FreeBSD) - alias real c_long_double; + alias c_long_double = real; else version (OpenBSD) - alias real c_long_double; + alias c_long_double = real; else version (NetBSD) - alias real c_long_double; + alias c_long_double = real; else version (DragonFlyBSD) - alias real c_long_double; + alias c_long_double = real; else version (Solaris) - alias real c_long_double; + alias c_long_double = real; else version (Darwin) - alias real c_long_double; + alias c_long_double = real; } } diff --git a/runtime/druntime/src/core/stdc/fenv.d b/runtime/druntime/src/core/stdc/fenv.d index 7d42d5c8c0..1c49d84906 100644 --- a/runtime/druntime/src/core/stdc/fenv.d +++ b/runtime/druntime/src/core/stdc/fenv.d @@ -194,8 +194,8 @@ else version (Darwin) { version (BigEndian) { - alias uint fenv_t; - alias uint fexcept_t; + alias fenv_t = uint; + alias fexcept_t = uint; } version (LittleEndian) { @@ -207,7 +207,7 @@ else version (Darwin) byte[8] __reserved; } - alias ushort fexcept_t; + alias fexcept_t = ushort; } } else version (FreeBSD) @@ -222,7 +222,7 @@ else version (FreeBSD) byte[16] __other; } - alias ushort fexcept_t; + alias fexcept_t = ushort; } else version (NetBSD) { @@ -262,7 +262,7 @@ else version (NetBSD) } - alias uint fexcept_t; + alias fexcept_t = uint; } else version (OpenBSD) { @@ -296,7 +296,7 @@ else version (DragonFlyBSD) uint mxcsr; } - alias uint fexcept_t; + alias fexcept_t = uint; } else version (CRuntime_Bionic) { @@ -312,12 +312,12 @@ else version (CRuntime_Bionic) byte[16] __other; } - alias ushort fexcept_t; + alias fexcept_t = ushort; } else version (ARM) { - alias uint fenv_t; - alias uint fexcept_t; + alias fenv_t = uint; + alias fexcept_t = uint; } else version (AArch64) { @@ -327,7 +327,7 @@ else version (CRuntime_Bionic) uint __status; } - alias uint fexcept_t; + alias fexcept_t = uint; } else version (X86_64) { @@ -345,7 +345,7 @@ else version (CRuntime_Bionic) uint __mxcsr; } - alias uint fexcept_t; + alias fexcept_t = uint; } else { @@ -370,7 +370,7 @@ else version (Solaris) c_ulong __fsr; } - alias int fexcept_t; + alias fexcept_t = int; } else version (CRuntime_Musl) { @@ -381,7 +381,7 @@ else version (CRuntime_Musl) uint __fpcr; uint __fpsr; } - alias uint fexcept_t; + alias fexcept_t = uint; } else version (ARM) { @@ -391,12 +391,12 @@ else version (CRuntime_Musl) { c_ulong __cw; } - alias c_ulong fexcept_t; + alias fexcept_t = c_ulong; } else version (IBMZ_Any) { - alias uint fenv_t; - alias uint fexcept_t; + alias fenv_t = uint; + alias fexcept_t = uint; } else version (MIPS_Any) { @@ -404,12 +404,12 @@ else version (CRuntime_Musl) { uint __cw; } - alias ushort fexcept_t; + alias fexcept_t = ushort; } else version (PPC_Any) { - alias double fenv_t; - alias uint fexcept_t; + alias fenv_t = double; + alias fexcept_t = uint; } else version (X86_Any) { @@ -430,7 +430,7 @@ else version (CRuntime_Musl) version (X86_64) uint __mxcsr; } - alias ushort fexcept_t; + alias fexcept_t = ushort; } else version (LoongArch64) { @@ -438,12 +438,12 @@ else version (CRuntime_Musl) { uint __cw; } - alias uint fexcept_t; + alias fexcept_t = uint; } else version (RICV64) { - alias uint fenv_t; - alias uint fexcept_t; + alias fenv_t = uint; + alias fexcept_t = uint; } else { diff --git a/runtime/druntime/src/core/stdc/inttypes.d b/runtime/druntime/src/core/stdc/inttypes.d index 7f30e38ab9..042716d308 100644 --- a/runtime/druntime/src/core/stdc/inttypes.d +++ b/runtime/druntime/src/core/stdc/inttypes.d @@ -29,7 +29,7 @@ struct imaxdiv_t rem; } -private alias immutable(char)* _cstr; +private alias _cstr = immutable(char)*; /// enum _cstr PRId8 = "hhd"; diff --git a/runtime/druntime/src/core/stdc/math.d b/runtime/druntime/src/core/stdc/math.d index 5b78d6f61f..29c0169a9a 100644 --- a/runtime/druntime/src/core/stdc/math.d +++ b/runtime/druntime/src/core/stdc/math.d @@ -46,9 +46,9 @@ nothrow: @nogc: /// -alias float float_t; +alias float_t = float; /// -alias double double_t; +alias double_t = double; /// enum double HUGE_VAL = double.infinity; diff --git a/runtime/druntime/src/core/stdc/signal.d b/runtime/druntime/src/core/stdc/signal.d index 13c6f9efbe..acd5ff9cbb 100644 --- a/runtime/druntime/src/core/stdc/signal.d +++ b/runtime/druntime/src/core/stdc/signal.d @@ -20,9 +20,9 @@ nothrow: // this should be volatile /// -alias int sig_atomic_t; +alias sig_atomic_t = int; -private alias void function(int) sigfn_t; +private alias sigfn_t = void function(int); version (Posix) { diff --git a/runtime/druntime/src/core/stdc/stddef.d b/runtime/druntime/src/core/stdc/stddef.d index 56b3c9b3f9..828ccb42a8 100644 --- a/runtime/druntime/src/core/stdc/stddef.d +++ b/runtime/druntime/src/core/stdc/stddef.d @@ -27,15 +27,15 @@ alias nullptr_t = typeof(null); version (Windows) { /// - alias wchar wchar_t; + alias wchar_t = wchar; } else version (Posix) { /// - alias dchar wchar_t; + alias wchar_t = dchar; } else version (WASI) { /// - alias dchar wchar_t; + alias wchar_t = dchar; } diff --git a/runtime/druntime/src/core/stdc/stdio.d b/runtime/druntime/src/core/stdc/stdio.d index 0c4e02f70e..fcecb9ed56 100644 --- a/runtime/druntime/src/core/stdc/stdio.d +++ b/runtime/druntime/src/core/stdc/stdio.d @@ -373,7 +373,7 @@ enum version (CRuntime_Microsoft) { /// - alias long fpos_t; + alias fpos_t = long; /// struct _iobuf @@ -382,7 +382,7 @@ version (CRuntime_Microsoft) } /// - alias shared(_iobuf) FILE; + alias FILE = shared(_iobuf); } else version (CRuntime_Glibc) { @@ -432,9 +432,9 @@ else version (CRuntime_Glibc) } /// - alias _IO_FILE _iobuf; + alias _iobuf = _IO_FILE; /// - alias shared(_IO_FILE) FILE; + alias FILE = shared(_IO_FILE); } else version (WASI) { @@ -446,9 +446,9 @@ else version (WASI) struct _IO_FILE; /// - alias _IO_FILE _iobuf; // needed for phobos + alias _iobuf = _IO_FILE; // needed for phobos /// - alias shared(_IO_FILE) FILE; + alias FILE = shared(_IO_FILE); } else version (CRuntime_Musl) { @@ -460,14 +460,14 @@ else version (CRuntime_Musl) struct _IO_FILE; /// - alias _IO_FILE _iobuf; // needed for phobos + alias _iobuf = _IO_FILE; // needed for phobos /// - alias shared(_IO_FILE) FILE; + alias FILE = shared(_IO_FILE); } else version (Darwin) { /// - alias long fpos_t; + alias fpos_t = long; /// struct __sFILE @@ -500,9 +500,9 @@ else version (Darwin) } /// - alias __sFILE _iobuf; + alias _iobuf = __sFILE; /// - alias shared(__sFILE) FILE; + alias FILE = shared(__sFILE); } else version (FreeBSD) { @@ -510,7 +510,7 @@ else version (FreeBSD) import core.stdc.wchar_ : mbstate_t; /// - alias off_t fpos_t; + alias fpos_t = off_t; /// struct __sFILE @@ -549,14 +549,14 @@ else version (FreeBSD) } /// - alias __sFILE _iobuf; + alias _iobuf = __sFILE; /// - alias shared(__sFILE) FILE; + alias FILE = shared(__sFILE); } else version (NetBSD) { /// - alias off_t fpos_t; + alias fpos_t = off_t; /// struct __sFILE @@ -593,9 +593,9 @@ else version (NetBSD) } /// - alias __sFILE _iobuf; + alias _iobuf = __sFILE; /// - alias shared(__sFILE) FILE; + alias FILE = shared(__sFILE); } else version (OpenBSD) { @@ -609,13 +609,13 @@ else version (OpenBSD) } /// - alias __sFILE _iobuf; + alias _iobuf = __sFILE; /// - alias shared(__sFILE) FILE; + alias FILE = shared(__sFILE); } else version (DragonFlyBSD) { - alias off_t fpos_t; + alias fpos_t = off_t; /// See /usr/include/stdio.h struct __FILE_public @@ -628,15 +628,15 @@ else version (DragonFlyBSD) ssize_t _lbfsize; /* 0 or -_bf._size, for inline putc */ } - alias __FILE_public _iobuf; - alias shared(__FILE_public) FILE; + alias _iobuf = __FILE_public; + alias FILE = shared(__FILE_public); } else version (Solaris) { import core.stdc.wchar_ : mbstate_t; /// - alias c_long fpos_t; + alias fpos_t = c_long; version (D_LP64) { @@ -673,12 +673,12 @@ else version (Solaris) } } /// - alias shared(_iobuf) FILE; + alias FILE = shared(_iobuf); } else version (CRuntime_Bionic) { /// - alias c_long fpos_t; // couldn't use off_t because of static if issue + alias fpos_t = c_long; // couldn't use off_t because of static if issue /// struct __sFILE @@ -711,9 +711,9 @@ else version (CRuntime_Bionic) } /// - alias __sFILE _iobuf; + alias _iobuf = __sFILE; /// - alias shared(__sFILE) FILE; + alias FILE = shared(__sFILE); } else version (CRuntime_Newlib) { @@ -762,9 +762,9 @@ else version (CRuntime_Newlib) } /// - alias __sFILE _iobuf; // needed for phobos + alias _iobuf = __sFILE; // needed for phobos /// - alias shared(__sFILE) FILE; + alias FILE = shared(__sFILE); } else version (CRuntime_UClibc) { @@ -788,7 +788,7 @@ else version (CRuntime_UClibc) int function(void* __cookie) close; } - alias _IO_cookie_io_functions_t cookie_io_functions_t; + alias cookie_io_functions_t = _IO_cookie_io_functions_t; /// struct __STDIO_FILE_STRUCT @@ -813,9 +813,9 @@ else version (CRuntime_UClibc) } /// - alias __STDIO_FILE_STRUCT _iobuf; + alias _iobuf = __STDIO_FILE_STRUCT; /// - alias shared(__STDIO_FILE_STRUCT) FILE; + alias FILE = shared(__STDIO_FILE_STRUCT); } else { @@ -925,11 +925,11 @@ else version (Darwin) private extern shared FILE* __stderrp; /// - alias __stdinp stdin; + alias stdin = __stdinp; /// - alias __stdoutp stdout; + alias stdout = __stdoutp; /// - alias __stderrp stderr; + alias stderr = __stderrp; } else version (FreeBSD) { @@ -948,11 +948,11 @@ else version (FreeBSD) private extern shared FILE* __stderrp; /// - alias __stdinp stdin; + alias stdin = __stdinp; /// - alias __stdoutp stdout; + alias stdout = __stdoutp; /// - alias __stderrp stderr; + alias stderr = __stderrp; } else version (NetBSD) { @@ -971,11 +971,11 @@ else version (NetBSD) @property auto __stdout()() { return &__sF[1]; } @property auto __stderr()() { return &__sF[2]; } /// - alias __stdin stdin; + alias stdin = __stdin; /// - alias __stdout stdout; + alias stdout = __stdout; /// - alias __stderr stderr; + alias stderr = __stderr; } else version (OpenBSD) { @@ -1000,11 +1000,11 @@ else version (OpenBSD) @property auto __stderr1()() { return cast(FILE*)__stderr; } /// - alias __stdin1 stdin; + alias stdin = __stdin1; /// - alias __stdout1 stdout; + alias stdout = __stdout1; /// - alias __stderr1 stderr; + alias stderr = __stderr1; } else version (DragonFlyBSD) { @@ -1019,9 +1019,9 @@ else version (DragonFlyBSD) private extern shared FILE* __stdoutp; private extern shared FILE* __stderrp; - alias __stdinp stdin; - alias __stdoutp stdout; - alias __stderrp stderr; + alias stdin = __stdinp; + alias stdout = __stdoutp; + alias stderr = __stderrp; } else version (Solaris) { @@ -1209,73 +1209,73 @@ version (MinGW) pragma(printf) int __mingw_fprintf(FILE* stream, scope const char* format, scope const ...); /// - alias __mingw_fprintf fprintf; + alias fprintf = __mingw_fprintf; /// pragma(scanf) int __mingw_fscanf(FILE* stream, scope const char* format, scope ...); /// - alias __mingw_fscanf fscanf; + alias fscanf = __mingw_fscanf; /// pragma(printf) int __mingw_sprintf(scope char* s, scope const char* format, scope const ...); /// - alias __mingw_sprintf sprintf; + alias sprintf = __mingw_sprintf; /// pragma(scanf) int __mingw_sscanf(scope const char* s, scope const char* format, scope ...); /// - alias __mingw_sscanf sscanf; + alias sscanf = __mingw_sscanf; /// pragma(printf) int __mingw_vfprintf(FILE* stream, scope const char* format, va_list arg); /// - alias __mingw_vfprintf vfprintf; + alias vfprintf = __mingw_vfprintf; /// pragma(scanf) int __mingw_vfscanf(FILE* stream, scope const char* format, va_list arg); /// - alias __mingw_vfscanf vfscanf; + alias vfscanf = __mingw_vfscanf; /// pragma(printf) int __mingw_vsprintf(scope char* s, scope const char* format, va_list arg); /// - alias __mingw_vsprintf vsprintf; + alias vsprintf = __mingw_vsprintf; /// pragma(scanf) int __mingw_vsscanf(scope const char* s, scope const char* format, va_list arg); /// - alias __mingw_vsscanf vsscanf; + alias vsscanf = __mingw_vsscanf; /// pragma(printf) int __mingw_vprintf(scope const char* format, va_list arg); /// - alias __mingw_vprintf vprintf; + alias vprintf = __mingw_vprintf; /// pragma(scanf) int __mingw_vscanf(scope const char* format, va_list arg); /// - alias __mingw_vscanf vscanf; + alias vscanf = __mingw_vscanf; /// pragma(printf) int __mingw_printf(scope const char* format, scope const ...); /// - alias __mingw_printf printf; + alias printf = __mingw_printf; /// pragma(scanf) int __mingw_scanf(scope const char* format, scope ...); /// - alias __mingw_scanf scanf; + alias scanf = __mingw_scanf; } else version (CRuntime_Glibc) { @@ -1508,17 +1508,17 @@ version (CRuntime_Microsoft) pragma(printf) int __mingw_snprintf(scope char* s, size_t n, scope const char* fmt, scope const ...); /// - alias __mingw_snprintf _snprintf; + alias _snprintf = __mingw_snprintf; /// - alias __mingw_snprintf snprintf; + alias snprintf = __mingw_snprintf; /// pragma(printf) int __mingw_vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); /// - alias __mingw_vsnprintf _vsnprintf; + alias _vsnprintf = __mingw_vsnprintf; /// - alias __mingw_vsnprintf vsnprintf; + alias vsnprintf = __mingw_vsnprintf; } else { diff --git a/runtime/druntime/src/core/stdc/stdlib.d b/runtime/druntime/src/core/stdc/stdlib.d index 52fa1d0f70..fba91609f1 100644 --- a/runtime/druntime/src/core/stdc/stdlib.d +++ b/runtime/druntime/src/core/stdc/stdlib.d @@ -133,7 +133,7 @@ version (CRuntime_Microsoft) /// real __mingw_strtold(scope inout(char)* nptr, scope inout(char)** endptr); /// - alias __mingw_strtold strtold; + alias strtold = __mingw_strtold; } else { diff --git a/runtime/druntime/src/core/stdc/tgmath.d b/runtime/druntime/src/core/stdc/tgmath.d index 2d1a198543..692912f576 100644 --- a/runtime/druntime/src/core/stdc/tgmath.d +++ b/runtime/druntime/src/core/stdc/tgmath.d @@ -26,498 +26,498 @@ nothrow: version (NetBSD) { /// - alias core.stdc.math.acos acos; + alias acos = core.stdc.math.acos; /// - alias core.stdc.math.acosf acos; + alias acos = core.stdc.math.acosf; /// - alias core.stdc.math.acosl acos; + alias acos = core.stdc.math.acosl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cacos acos; - deprecated alias core.stdc.complex.cacosf acos; - deprecated alias core.stdc.complex.cacosl acos; + deprecated alias acos = core.stdc.complex.cacos; + deprecated alias acos = core.stdc.complex.cacosf; + deprecated alias acos = core.stdc.complex.cacosl; /// - alias core.stdc.math.asin asin; + alias asin = core.stdc.math.asin; /// - alias core.stdc.math.asinf asin; + alias asin = core.stdc.math.asinf; /// - alias core.stdc.math.asinl asin; + alias asin = core.stdc.math.asinl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.casin asin; - deprecated alias core.stdc.complex.casinf asin; - deprecated alias core.stdc.complex.casinl asin; + deprecated alias asin = core.stdc.complex.casin; + deprecated alias asin = core.stdc.complex.casinf; + deprecated alias asin = core.stdc.complex.casinl; /// - alias core.stdc.math.atan atan; + alias atan = core.stdc.math.atan; /// - alias core.stdc.math.atanf atan; + alias atan = core.stdc.math.atanf; /// - alias core.stdc.math.atanl atan; + alias atan = core.stdc.math.atanl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.catan atan; - deprecated alias core.stdc.complex.catanf atan; - deprecated alias core.stdc.complex.catanl atan; + deprecated alias atan = core.stdc.complex.catan; + deprecated alias atan = core.stdc.complex.catanf; + deprecated alias atan = core.stdc.complex.catanl; /// - alias core.stdc.math.atan2 atan2; + alias atan2 = core.stdc.math.atan2; /// - alias core.stdc.math.atan2f atan2; + alias atan2 = core.stdc.math.atan2f; /// - alias core.stdc.math.atan2l atan2; + alias atan2 = core.stdc.math.atan2l; /// - alias core.stdc.math.cos cos; + alias cos = core.stdc.math.cos; /// - alias core.stdc.math.cosf cos; + alias cos = core.stdc.math.cosf; /// - alias core.stdc.math.cosl cos; + alias cos = core.stdc.math.cosl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.ccos cos; - deprecated alias core.stdc.complex.ccosf cos; - deprecated alias core.stdc.complex.ccosl cos; + deprecated alias cos = core.stdc.complex.ccos; + deprecated alias cos = core.stdc.complex.ccosf; + deprecated alias cos = core.stdc.complex.ccosl; /// - alias core.stdc.math.sin sin; + alias sin = core.stdc.math.sin; /// - alias core.stdc.math.sinf sin; + alias sin = core.stdc.math.sinf; /// - alias core.stdc.math.sinl sin; + alias sin = core.stdc.math.sinl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.csin csin; - deprecated alias core.stdc.complex.csinf csin; - deprecated alias core.stdc.complex.csinl csin; + deprecated alias csin = core.stdc.complex.csin; + deprecated alias csin = core.stdc.complex.csinf; + deprecated alias csin = core.stdc.complex.csinl; /// - alias core.stdc.math.tan tan; + alias tan = core.stdc.math.tan; /// - alias core.stdc.math.tanf tan; + alias tan = core.stdc.math.tanf; /// - alias core.stdc.math.tanl tan; + alias tan = core.stdc.math.tanl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.ctan tan; - deprecated alias core.stdc.complex.ctanf tan; - deprecated alias core.stdc.complex.ctanl tan; + deprecated alias tan = core.stdc.complex.ctan; + deprecated alias tan = core.stdc.complex.ctanf; + deprecated alias tan = core.stdc.complex.ctanl; /// - alias core.stdc.math.acosh acosh; + alias acosh = core.stdc.math.acosh; /// - alias core.stdc.math.acoshf acosh; + alias acosh = core.stdc.math.acoshf; /// - alias core.stdc.math.acoshl acosh; + alias acosh = core.stdc.math.acoshl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cacosh acosh; - deprecated alias core.stdc.complex.cacoshf acosh; - deprecated alias core.stdc.complex.cacoshl acosh; + deprecated alias acosh = core.stdc.complex.cacosh; + deprecated alias acosh = core.stdc.complex.cacoshf; + deprecated alias acosh = core.stdc.complex.cacoshl; /// - alias core.stdc.math.asinh asinh; + alias asinh = core.stdc.math.asinh; /// - alias core.stdc.math.asinhf asinh; + alias asinh = core.stdc.math.asinhf; /// - alias core.stdc.math.asinhl asinh; + alias asinh = core.stdc.math.asinhl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.casinh asinh; - deprecated alias core.stdc.complex.casinhf asinh; - deprecated alias core.stdc.complex.casinhl asinh; + deprecated alias asinh = core.stdc.complex.casinh; + deprecated alias asinh = core.stdc.complex.casinhf; + deprecated alias asinh = core.stdc.complex.casinhl; /// - alias core.stdc.math.atanh atanh; + alias atanh = core.stdc.math.atanh; /// - alias core.stdc.math.atanhf atanh; + alias atanh = core.stdc.math.atanhf; /// - alias core.stdc.math.atanhl atanh; + alias atanh = core.stdc.math.atanhl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.catanh atanh; - deprecated alias core.stdc.complex.catanhf atanh; - deprecated alias core.stdc.complex.catanhl atanh; + deprecated alias atanh = core.stdc.complex.catanh; + deprecated alias atanh = core.stdc.complex.catanhf; + deprecated alias atanh = core.stdc.complex.catanhl; /// - alias core.stdc.math.cosh cosh; + alias cosh = core.stdc.math.cosh; /// - alias core.stdc.math.coshf cosh; + alias cosh = core.stdc.math.coshf; /// - alias core.stdc.math.coshl cosh; + alias cosh = core.stdc.math.coshl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.ccosh cosh; - deprecated alias core.stdc.complex.ccoshf cosh; - deprecated alias core.stdc.complex.ccoshl cosh; + deprecated alias cosh = core.stdc.complex.ccosh; + deprecated alias cosh = core.stdc.complex.ccoshf; + deprecated alias cosh = core.stdc.complex.ccoshl; /// - alias core.stdc.math.sinh sinh; + alias sinh = core.stdc.math.sinh; /// - alias core.stdc.math.sinhf sinh; + alias sinh = core.stdc.math.sinhf; /// - alias core.stdc.math.sinhl sinh; + alias sinh = core.stdc.math.sinhl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.csinh sinh; - deprecated alias core.stdc.complex.csinhf sinh; - deprecated alias core.stdc.complex.csinhl sinh; + deprecated alias sinh = core.stdc.complex.csinh; + deprecated alias sinh = core.stdc.complex.csinhf; + deprecated alias sinh = core.stdc.complex.csinhl; /// - alias core.stdc.math.tanh tanh; + alias tanh = core.stdc.math.tanh; /// - alias core.stdc.math.tanhf tanh; + alias tanh = core.stdc.math.tanhf; /// - alias core.stdc.math.tanhl tanh; + alias tanh = core.stdc.math.tanhl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.ctanh tanh; - deprecated alias core.stdc.complex.ctanhf tanh; - deprecated alias core.stdc.complex.ctanhl tanh; + deprecated alias tanh = core.stdc.complex.ctanh; + deprecated alias tanh = core.stdc.complex.ctanhf; + deprecated alias tanh = core.stdc.complex.ctanhl; /// - alias core.stdc.math.exp exp; + alias exp = core.stdc.math.exp; /// - alias core.stdc.math.expf exp; + alias exp = core.stdc.math.expf; /// - alias core.stdc.math.expl exp; + alias exp = core.stdc.math.expl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cexp exp; - deprecated alias core.stdc.complex.cexpf exp; - deprecated alias core.stdc.complex.cexpl exp; + deprecated alias exp = core.stdc.complex.cexp; + deprecated alias exp = core.stdc.complex.cexpf; + deprecated alias exp = core.stdc.complex.cexpl; /// - alias core.stdc.math.exp2 exp2; + alias exp2 = core.stdc.math.exp2; /// - alias core.stdc.math.exp2f exp2; + alias exp2 = core.stdc.math.exp2f; /// - alias core.stdc.math.exp2l exp2; + alias exp2 = core.stdc.math.exp2l; /// - alias core.stdc.math.expm1 expm1; + alias expm1 = core.stdc.math.expm1; /// - alias core.stdc.math.expm1f expm1; + alias expm1 = core.stdc.math.expm1f; /// - alias core.stdc.math.expm1l expm1; + alias expm1 = core.stdc.math.expm1l; /// - alias core.stdc.math.frexp frexp; + alias frexp = core.stdc.math.frexp; /// - alias core.stdc.math.frexpf frexp; + alias frexp = core.stdc.math.frexpf; /// - alias core.stdc.math.frexpl frexp; + alias frexp = core.stdc.math.frexpl; /// - alias core.stdc.math.ilogb ilogb; + alias ilogb = core.stdc.math.ilogb; /// - alias core.stdc.math.ilogbf ilogb; + alias ilogb = core.stdc.math.ilogbf; /// - alias core.stdc.math.ilogbl ilogb; + alias ilogb = core.stdc.math.ilogbl; /// - alias core.stdc.math.ldexp ldexp; + alias ldexp = core.stdc.math.ldexp; /// - alias core.stdc.math.ldexpf ldexp; + alias ldexp = core.stdc.math.ldexpf; /// - alias core.stdc.math.ldexpl ldexp; + alias ldexp = core.stdc.math.ldexpl; /// - alias core.stdc.math.log log; + alias log = core.stdc.math.log; /// - alias core.stdc.math.logf log; + alias log = core.stdc.math.logf; /// - alias core.stdc.math.logl log; + alias log = core.stdc.math.logl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.clog log; - deprecated alias core.stdc.complex.clogf log; - deprecated alias core.stdc.complex.clogl log; + deprecated alias log = core.stdc.complex.clog; + deprecated alias log = core.stdc.complex.clogf; + deprecated alias log = core.stdc.complex.clogl; /// - alias core.stdc.math.log10 log10; + alias log10 = core.stdc.math.log10; /// - alias core.stdc.math.log10f log10; + alias log10 = core.stdc.math.log10f; /// - alias core.stdc.math.log10l log10; + alias log10 = core.stdc.math.log10l; /// - alias core.stdc.math.log1p log1p; + alias log1p = core.stdc.math.log1p; /// - alias core.stdc.math.log1pf log1p; + alias log1p = core.stdc.math.log1pf; /// - alias core.stdc.math.log1pl log1p; + alias log1p = core.stdc.math.log1pl; /// - alias core.stdc.math.log2 log2; + alias log2 = core.stdc.math.log2; /// - alias core.stdc.math.log2f log2; + alias log2 = core.stdc.math.log2f; /// - alias core.stdc.math.log2l log2; + alias log2 = core.stdc.math.log2l; /// - alias core.stdc.math.logb logb; + alias logb = core.stdc.math.logb; /// - alias core.stdc.math.logbf logb; + alias logb = core.stdc.math.logbf; /// - alias core.stdc.math.logbl logb; + alias logb = core.stdc.math.logbl; /// - alias core.stdc.math.modf modf; + alias modf = core.stdc.math.modf; /// - alias core.stdc.math.modff modf; + alias modf = core.stdc.math.modff; // alias core.stdc.math.modfl modf; /// - alias core.stdc.math.scalbn scalbn; + alias scalbn = core.stdc.math.scalbn; /// - alias core.stdc.math.scalbnf scalbn; + alias scalbn = core.stdc.math.scalbnf; /// - alias core.stdc.math.scalbnl scalbn; + alias scalbn = core.stdc.math.scalbnl; /// - alias core.stdc.math.scalbln scalbln; + alias scalbln = core.stdc.math.scalbln; /// - alias core.stdc.math.scalblnf scalbln; + alias scalbln = core.stdc.math.scalblnf; /// - alias core.stdc.math.scalblnl scalbln; + alias scalbln = core.stdc.math.scalblnl; /// - alias core.stdc.math.cbrt cbrt; + alias cbrt = core.stdc.math.cbrt; /// - alias core.stdc.math.cbrtf cbrt; + alias cbrt = core.stdc.math.cbrtf; /// - alias core.stdc.math.cbrtl cbrt; + alias cbrt = core.stdc.math.cbrtl; /// - alias core.stdc.math.fabs fabs; + alias fabs = core.stdc.math.fabs; /// - alias core.stdc.math.fabsf fabs; + alias fabs = core.stdc.math.fabsf; /// - alias core.stdc.math.fabsl fabs; + alias fabs = core.stdc.math.fabsl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cabs fabs; - deprecated alias core.stdc.complex.cabsf fabs; - deprecated alias core.stdc.complex.cabsl fabs; + deprecated alias fabs = core.stdc.complex.cabs; + deprecated alias fabs = core.stdc.complex.cabsf; + deprecated alias fabs = core.stdc.complex.cabsl; /// - alias core.stdc.math.hypot hypot; + alias hypot = core.stdc.math.hypot; /// - alias core.stdc.math.hypotf hypot; + alias hypot = core.stdc.math.hypotf; /// - alias core.stdc.math.hypotl hypot; + alias hypot = core.stdc.math.hypotl; /// - alias core.stdc.math.pow pow; + alias pow = core.stdc.math.pow; /// - alias core.stdc.math.powf pow; + alias pow = core.stdc.math.powf; /// - alias core.stdc.math.powl pow; + alias pow = core.stdc.math.powl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cpow pow; - deprecated alias core.stdc.complex.cpowf pow; - deprecated alias core.stdc.complex.cpowl pow; + deprecated alias pow = core.stdc.complex.cpow; + deprecated alias pow = core.stdc.complex.cpowf; + deprecated alias pow = core.stdc.complex.cpowl; /// - alias core.stdc.math.sqrt sqrt; + alias sqrt = core.stdc.math.sqrt; /// - alias core.stdc.math.sqrtf sqrt; + alias sqrt = core.stdc.math.sqrtf; /// - alias core.stdc.math.sqrtl sqrt; + alias sqrt = core.stdc.math.sqrtl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.csqrt sqrt; - deprecated alias core.stdc.complex.csqrtf sqrt; - deprecated alias core.stdc.complex.csqrtl sqrt; + deprecated alias sqrt = core.stdc.complex.csqrt; + deprecated alias sqrt = core.stdc.complex.csqrtf; + deprecated alias sqrt = core.stdc.complex.csqrtl; /// - alias core.stdc.math.erf erf; + alias erf = core.stdc.math.erf; /// - alias core.stdc.math.erff erf; + alias erf = core.stdc.math.erff; /// - alias core.stdc.math.erfl erf; + alias erf = core.stdc.math.erfl; /// - alias core.stdc.math.erfc erfc; + alias erfc = core.stdc.math.erfc; /// - alias core.stdc.math.erfcf erfc; + alias erfc = core.stdc.math.erfcf; /// - alias core.stdc.math.erfcl erfc; + alias erfc = core.stdc.math.erfcl; /// - alias core.stdc.math.lgamma lgamma; + alias lgamma = core.stdc.math.lgamma; /// - alias core.stdc.math.lgammaf lgamma; + alias lgamma = core.stdc.math.lgammaf; /// - alias core.stdc.math.lgammal lgamma; + alias lgamma = core.stdc.math.lgammal; /// - alias core.stdc.math.tgamma tgamma; + alias tgamma = core.stdc.math.tgamma; /// - alias core.stdc.math.tgammaf tgamma; + alias tgamma = core.stdc.math.tgammaf; /// - alias core.stdc.math.tgammal tgamma; + alias tgamma = core.stdc.math.tgammal; /// - alias core.stdc.math.ceil ceil; + alias ceil = core.stdc.math.ceil; /// - alias core.stdc.math.ceilf ceil; + alias ceil = core.stdc.math.ceilf; /// - alias core.stdc.math.ceill ceil; + alias ceil = core.stdc.math.ceill; /// - alias core.stdc.math.floor floor; + alias floor = core.stdc.math.floor; /// - alias core.stdc.math.floorf floor; + alias floor = core.stdc.math.floorf; /// - alias core.stdc.math.floorl floor; + alias floor = core.stdc.math.floorl; /// - alias core.stdc.math.nearbyint nearbyint; + alias nearbyint = core.stdc.math.nearbyint; /// - alias core.stdc.math.nearbyintf nearbyint; + alias nearbyint = core.stdc.math.nearbyintf; /// - alias core.stdc.math.nearbyintl nearbyint; + alias nearbyint = core.stdc.math.nearbyintl; /// - alias core.stdc.math.rint rint; + alias rint = core.stdc.math.rint; /// - alias core.stdc.math.rintf rint; + alias rint = core.stdc.math.rintf; /// - alias core.stdc.math.rintl rint; + alias rint = core.stdc.math.rintl; /// - alias core.stdc.math.lrint lrint; + alias lrint = core.stdc.math.lrint; /// - alias core.stdc.math.lrintf lrint; + alias lrint = core.stdc.math.lrintf; /// - alias core.stdc.math.lrintl lrint; + alias lrint = core.stdc.math.lrintl; /// - alias core.stdc.math.llrint llrint; + alias llrint = core.stdc.math.llrint; /// - alias core.stdc.math.llrintf llrint; + alias llrint = core.stdc.math.llrintf; /// - alias core.stdc.math.llrintl llrint; + alias llrint = core.stdc.math.llrintl; /// - alias core.stdc.math.round round; + alias round = core.stdc.math.round; /// - alias core.stdc.math.roundf round; + alias round = core.stdc.math.roundf; /// - alias core.stdc.math.roundl round; + alias round = core.stdc.math.roundl; /// - alias core.stdc.math.lround lround; + alias lround = core.stdc.math.lround; /// - alias core.stdc.math.lroundf lround; + alias lround = core.stdc.math.lroundf; /// - alias core.stdc.math.lroundl lround; + alias lround = core.stdc.math.lroundl; /// - alias core.stdc.math.llround llroundl; + alias llroundl = core.stdc.math.llround; /// - alias core.stdc.math.llroundf llroundl; + alias llroundl = core.stdc.math.llroundf; /// - alias core.stdc.math.llroundl llroundl; + alias llroundl = core.stdc.math.llroundl; /// - alias core.stdc.math.trunc trunc; + alias trunc = core.stdc.math.trunc; /// - alias core.stdc.math.truncf trunc; + alias trunc = core.stdc.math.truncf; /// - alias core.stdc.math.truncl trunc; + alias trunc = core.stdc.math.truncl; /// - alias core.stdc.math.fmod fmod; + alias fmod = core.stdc.math.fmod; /// - alias core.stdc.math.fmodf fmod; + alias fmod = core.stdc.math.fmodf; /// - alias core.stdc.math.fmodl fmod; + alias fmod = core.stdc.math.fmodl; /// - alias core.stdc.math.remainder remainder; + alias remainder = core.stdc.math.remainder; /// - alias core.stdc.math.remainderf remainder; + alias remainder = core.stdc.math.remainderf; /// - alias core.stdc.math.remainderl remainder; + alias remainder = core.stdc.math.remainderl; /// - alias core.stdc.math.remquo remquo; + alias remquo = core.stdc.math.remquo; /// - alias core.stdc.math.remquof remquo; + alias remquo = core.stdc.math.remquof; /// - alias core.stdc.math.remquol remquo; + alias remquo = core.stdc.math.remquol; /// - alias core.stdc.math.copysign copysign; + alias copysign = core.stdc.math.copysign; /// - alias core.stdc.math.copysignf copysign; + alias copysign = core.stdc.math.copysignf; /// - alias core.stdc.math.copysignl copysign; + alias copysign = core.stdc.math.copysignl; // alias core.stdc.math.nan nan; // alias core.stdc.math.nanf nan; // alias core.stdc.math.nanl nan; /// - alias core.stdc.math.nextafter nextafter; + alias nextafter = core.stdc.math.nextafter; /// - alias core.stdc.math.nextafterf nextafter; + alias nextafter = core.stdc.math.nextafterf; /// - alias core.stdc.math.nextafterl nextafter; + alias nextafter = core.stdc.math.nextafterl; /// - alias core.stdc.math.nexttoward nexttoward; + alias nexttoward = core.stdc.math.nexttoward; /// - alias core.stdc.math.nexttowardf nexttoward; + alias nexttoward = core.stdc.math.nexttowardf; /// - alias core.stdc.math.nexttowardl nexttoward; + alias nexttoward = core.stdc.math.nexttowardl; /// - alias core.stdc.math.fdim fdim; + alias fdim = core.stdc.math.fdim; /// - alias core.stdc.math.fdimf fdim; + alias fdim = core.stdc.math.fdimf; /// - alias core.stdc.math.fdiml fdim; + alias fdim = core.stdc.math.fdiml; /// - alias core.stdc.math.fmax fmax; + alias fmax = core.stdc.math.fmax; /// - alias core.stdc.math.fmaxf fmax; + alias fmax = core.stdc.math.fmaxf; /// - alias core.stdc.math.fmaxl fmax; + alias fmax = core.stdc.math.fmaxl; /// - alias core.stdc.math.fmin fmin; + alias fmin = core.stdc.math.fmin; /// - alias core.stdc.math.fmin fmin; + alias fmin = core.stdc.math.fmin; /// - alias core.stdc.math.fminl fmin; + alias fmin = core.stdc.math.fminl; /// - alias core.stdc.math.fma fma; + alias fma = core.stdc.math.fma; /// - alias core.stdc.math.fmaf fma; + alias fma = core.stdc.math.fmaf; /// - alias core.stdc.math.fmal fma; + alias fma = core.stdc.math.fmal; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.carg carg; - deprecated alias core.stdc.complex.cargf carg; - deprecated alias core.stdc.complex.cargl carg; - deprecated alias core.stdc.complex.cimag cimag; - deprecated alias core.stdc.complex.cimagf cimag; - deprecated alias core.stdc.complex.cimagl cimag; - deprecated alias core.stdc.complex.conj conj; - deprecated alias core.stdc.complex.conjf conj; - deprecated alias core.stdc.complex.conjl conj; - deprecated alias core.stdc.complex.cproj cproj; - deprecated alias core.stdc.complex.cprojf cproj; - deprecated alias core.stdc.complex.cprojl cproj; + deprecated alias carg = core.stdc.complex.carg; + deprecated alias carg = core.stdc.complex.cargf; + deprecated alias carg = core.stdc.complex.cargl; + deprecated alias cimag = core.stdc.complex.cimag; + deprecated alias cimag = core.stdc.complex.cimagf; + deprecated alias cimag = core.stdc.complex.cimagl; + deprecated alias conj = core.stdc.complex.conj; + deprecated alias conj = core.stdc.complex.conjf; + deprecated alias conj = core.stdc.complex.conjl; + deprecated alias cproj = core.stdc.complex.cproj; + deprecated alias cproj = core.stdc.complex.cprojf; + deprecated alias cproj = core.stdc.complex.cprojl; // deprecated alias core.stdc.complex.creal creal; // deprecated alias core.stdc.complex.crealf creal; @@ -526,488 +526,488 @@ version (NetBSD) else version (OpenBSD) { /// - alias core.stdc.math.acos acos; + alias acos = core.stdc.math.acos; /// - alias core.stdc.math.acosf acos; + alias acos = core.stdc.math.acosf; /// - alias core.stdc.math.acosl acos; + alias acos = core.stdc.math.acosl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cacos acos; - deprecated alias core.stdc.complex.cacosf acos; - deprecated alias core.stdc.complex.cacosl acos; + deprecated alias acos = core.stdc.complex.cacos; + deprecated alias acos = core.stdc.complex.cacosf; + deprecated alias acos = core.stdc.complex.cacosl; /// - alias core.stdc.math.asin asin; + alias asin = core.stdc.math.asin; /// - alias core.stdc.math.asinf asin; + alias asin = core.stdc.math.asinf; /// - alias core.stdc.math.asinl asin; + alias asin = core.stdc.math.asinl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.casin asin; - deprecated alias core.stdc.complex.casinf asin; - deprecated alias core.stdc.complex.casinl asin; + deprecated alias asin = core.stdc.complex.casin; + deprecated alias asin = core.stdc.complex.casinf; + deprecated alias asin = core.stdc.complex.casinl; /// - alias core.stdc.math.atan atan; + alias atan = core.stdc.math.atan; /// - alias core.stdc.math.atanf atan; + alias atan = core.stdc.math.atanf; /// - alias core.stdc.math.atanl atan; + alias atan = core.stdc.math.atanl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.catan atan; - deprecated alias core.stdc.complex.catanf atan; - deprecated alias core.stdc.complex.catanl atan; + deprecated alias atan = core.stdc.complex.catan; + deprecated alias atan = core.stdc.complex.catanf; + deprecated alias atan = core.stdc.complex.catanl; /// - alias core.stdc.math.atan2 atan2; + alias atan2 = core.stdc.math.atan2; /// - alias core.stdc.math.atan2f atan2; + alias atan2 = core.stdc.math.atan2f; /// - alias core.stdc.math.atan2l atan2; + alias atan2 = core.stdc.math.atan2l; /// - alias core.stdc.math.cos cos; + alias cos = core.stdc.math.cos; /// - alias core.stdc.math.cosf cos; + alias cos = core.stdc.math.cosf; /// - alias core.stdc.math.cosl cos; + alias cos = core.stdc.math.cosl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.ccos cos; - deprecated alias core.stdc.complex.ccosf cos; - deprecated alias core.stdc.complex.ccosl cos; + deprecated alias cos = core.stdc.complex.ccos; + deprecated alias cos = core.stdc.complex.ccosf; + deprecated alias cos = core.stdc.complex.ccosl; /// - alias core.stdc.math.sin sin; + alias sin = core.stdc.math.sin; /// - alias core.stdc.math.sinf sin; + alias sin = core.stdc.math.sinf; /// - alias core.stdc.math.sinl sin; + alias sin = core.stdc.math.sinl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.csin csin; - deprecated alias core.stdc.complex.csinf csin; - deprecated alias core.stdc.complex.csinl csin; + deprecated alias csin = core.stdc.complex.csin; + deprecated alias csin = core.stdc.complex.csinf; + deprecated alias csin = core.stdc.complex.csinl; /// - alias core.stdc.math.tan tan; + alias tan = core.stdc.math.tan; /// - alias core.stdc.math.tanf tan; + alias tan = core.stdc.math.tanf; /// - alias core.stdc.math.tanl tan; + alias tan = core.stdc.math.tanl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.ctan tan; - deprecated alias core.stdc.complex.ctanf tan; - deprecated alias core.stdc.complex.ctanl tan; + deprecated alias tan = core.stdc.complex.ctan; + deprecated alias tan = core.stdc.complex.ctanf; + deprecated alias tan = core.stdc.complex.ctanl; /// - alias core.stdc.math.acosh acosh; + alias acosh = core.stdc.math.acosh; /// - alias core.stdc.math.acoshf acosh; + alias acosh = core.stdc.math.acoshf; /// - alias core.stdc.math.acoshl acosh; + alias acosh = core.stdc.math.acoshl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cacosh acosh; - deprecated alias core.stdc.complex.cacoshf acosh; - deprecated alias core.stdc.complex.cacoshl acosh; + deprecated alias acosh = core.stdc.complex.cacosh; + deprecated alias acosh = core.stdc.complex.cacoshf; + deprecated alias acosh = core.stdc.complex.cacoshl; /// - alias core.stdc.math.asinh asinh; + alias asinh = core.stdc.math.asinh; /// - alias core.stdc.math.asinhf asinh; + alias asinh = core.stdc.math.asinhf; /// - alias core.stdc.math.asinhl asinh; + alias asinh = core.stdc.math.asinhl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.casinh asinh; - deprecated alias core.stdc.complex.casinhf asinh; - deprecated alias core.stdc.complex.casinhl asinh; + deprecated alias asinh = core.stdc.complex.casinh; + deprecated alias asinh = core.stdc.complex.casinhf; + deprecated alias asinh = core.stdc.complex.casinhl; /// - alias core.stdc.math.atanh atanh; + alias atanh = core.stdc.math.atanh; /// - alias core.stdc.math.atanhf atanh; + alias atanh = core.stdc.math.atanhf; /// - alias core.stdc.math.atanhl atanh; + alias atanh = core.stdc.math.atanhl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.catanh atanh; - deprecated alias core.stdc.complex.catanhf atanh; - deprecated alias core.stdc.complex.catanhl atanh; + deprecated alias atanh = core.stdc.complex.catanh; + deprecated alias atanh = core.stdc.complex.catanhf; + deprecated alias atanh = core.stdc.complex.catanhl; /// - alias core.stdc.math.cosh cosh; + alias cosh = core.stdc.math.cosh; /// - alias core.stdc.math.coshf cosh; + alias cosh = core.stdc.math.coshf; /// - alias core.stdc.math.coshl cosh; + alias cosh = core.stdc.math.coshl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.ccosh cosh; - deprecated alias core.stdc.complex.ccoshf cosh; - deprecated alias core.stdc.complex.ccoshl cosh; + deprecated alias cosh = core.stdc.complex.ccosh; + deprecated alias cosh = core.stdc.complex.ccoshf; + deprecated alias cosh = core.stdc.complex.ccoshl; /// - alias core.stdc.math.sinh sinh; + alias sinh = core.stdc.math.sinh; /// - alias core.stdc.math.sinhf sinh; + alias sinh = core.stdc.math.sinhf; /// - alias core.stdc.math.sinhl sinh; + alias sinh = core.stdc.math.sinhl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.csinh sinh; - deprecated alias core.stdc.complex.csinhf sinh; - deprecated alias core.stdc.complex.csinhl sinh; + deprecated alias sinh = core.stdc.complex.csinh; + deprecated alias sinh = core.stdc.complex.csinhf; + deprecated alias sinh = core.stdc.complex.csinhl; /// - alias core.stdc.math.tanh tanh; + alias tanh = core.stdc.math.tanh; /// - alias core.stdc.math.tanhf tanh; + alias tanh = core.stdc.math.tanhf; /// - alias core.stdc.math.tanhl tanh; + alias tanh = core.stdc.math.tanhl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.ctanh tanh; - deprecated alias core.stdc.complex.ctanhf tanh; - deprecated alias core.stdc.complex.ctanhl tanh; + deprecated alias tanh = core.stdc.complex.ctanh; + deprecated alias tanh = core.stdc.complex.ctanhf; + deprecated alias tanh = core.stdc.complex.ctanhl; /// - alias core.stdc.math.exp exp; + alias exp = core.stdc.math.exp; /// - alias core.stdc.math.expf exp; + alias exp = core.stdc.math.expf; /// - alias core.stdc.math.expl exp; + alias exp = core.stdc.math.expl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cexp exp; - deprecated alias core.stdc.complex.cexpf exp; - deprecated alias core.stdc.complex.cexpl exp; + deprecated alias exp = core.stdc.complex.cexp; + deprecated alias exp = core.stdc.complex.cexpf; + deprecated alias exp = core.stdc.complex.cexpl; /// - alias core.stdc.math.exp2 exp2; + alias exp2 = core.stdc.math.exp2; /// - alias core.stdc.math.exp2f exp2; + alias exp2 = core.stdc.math.exp2f; /// - alias core.stdc.math.exp2l exp2; + alias exp2 = core.stdc.math.exp2l; /// - alias core.stdc.math.expm1 expm1; + alias expm1 = core.stdc.math.expm1; /// - alias core.stdc.math.expm1f expm1; + alias expm1 = core.stdc.math.expm1f; /// - alias core.stdc.math.expm1l expm1; + alias expm1 = core.stdc.math.expm1l; /// - alias core.stdc.math.frexp frexp; + alias frexp = core.stdc.math.frexp; /// - alias core.stdc.math.frexpf frexp; + alias frexp = core.stdc.math.frexpf; /// - alias core.stdc.math.frexpl frexp; + alias frexp = core.stdc.math.frexpl; /// - alias core.stdc.math.ilogb ilogb; + alias ilogb = core.stdc.math.ilogb; /// - alias core.stdc.math.ilogbf ilogb; + alias ilogb = core.stdc.math.ilogbf; /// - alias core.stdc.math.ilogbl ilogb; + alias ilogb = core.stdc.math.ilogbl; /// - alias core.stdc.math.ldexp ldexp; + alias ldexp = core.stdc.math.ldexp; /// - alias core.stdc.math.ldexpf ldexp; + alias ldexp = core.stdc.math.ldexpf; /// - alias core.stdc.math.ldexpl ldexp; + alias ldexp = core.stdc.math.ldexpl; /// - alias core.stdc.math.log log; + alias log = core.stdc.math.log; /// - alias core.stdc.math.logf log; + alias log = core.stdc.math.logf; /// - alias core.stdc.math.logl log; + alias log = core.stdc.math.logl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.clog log; - deprecated alias core.stdc.complex.clogf log; - deprecated alias core.stdc.complex.clogl log; + deprecated alias log = core.stdc.complex.clog; + deprecated alias log = core.stdc.complex.clogf; + deprecated alias log = core.stdc.complex.clogl; /// - alias core.stdc.math.log10 log10; + alias log10 = core.stdc.math.log10; /// - alias core.stdc.math.log10f log10; + alias log10 = core.stdc.math.log10f; /// - alias core.stdc.math.log10l log10; + alias log10 = core.stdc.math.log10l; /// - alias core.stdc.math.log1p log1p; + alias log1p = core.stdc.math.log1p; /// - alias core.stdc.math.log1pf log1p; + alias log1p = core.stdc.math.log1pf; /// - alias core.stdc.math.log1pl log1p; + alias log1p = core.stdc.math.log1pl; /// - alias core.stdc.math.log2 log2; + alias log2 = core.stdc.math.log2; /// - alias core.stdc.math.log2f log2; + alias log2 = core.stdc.math.log2f; /// - alias core.stdc.math.log2l log2; + alias log2 = core.stdc.math.log2l; /// - alias core.stdc.math.logb logb; + alias logb = core.stdc.math.logb; /// - alias core.stdc.math.logbf logb; + alias logb = core.stdc.math.logbf; /// - alias core.stdc.math.logbl logb; + alias logb = core.stdc.math.logbl; /// - alias core.stdc.math.fmod fmod; + alias fmod = core.stdc.math.fmod; /// - alias core.stdc.math.fmodf fmod; + alias fmod = core.stdc.math.fmodf; /// - alias core.stdc.math.fmodl fmod; + alias fmod = core.stdc.math.fmodl; /// - alias core.stdc.math.scalbn scalbn; + alias scalbn = core.stdc.math.scalbn; /// - alias core.stdc.math.scalbnf scalbn; + alias scalbn = core.stdc.math.scalbnf; /// - alias core.stdc.math.scalbnl scalbn; + alias scalbn = core.stdc.math.scalbnl; /// - alias core.stdc.math.scalbln scalbln; + alias scalbln = core.stdc.math.scalbln; /// - alias core.stdc.math.scalblnf scalbln; + alias scalbln = core.stdc.math.scalblnf; /// - alias core.stdc.math.scalblnl scalbln; + alias scalbln = core.stdc.math.scalblnl; /// - alias core.stdc.math.cbrt cbrt; + alias cbrt = core.stdc.math.cbrt; /// - alias core.stdc.math.cbrtf cbrt; + alias cbrt = core.stdc.math.cbrtf; /// - alias core.stdc.math.cbrtl cbrt; + alias cbrt = core.stdc.math.cbrtl; /// - alias core.stdc.math.fabs fabs; + alias fabs = core.stdc.math.fabs; /// - alias core.stdc.math.fabsf fabs; + alias fabs = core.stdc.math.fabsf; /// - alias core.stdc.math.fabsl fabs; + alias fabs = core.stdc.math.fabsl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cabs fabs; - deprecated alias core.stdc.complex.cabsf fabs; - deprecated alias core.stdc.complex.cabsl fabs; + deprecated alias fabs = core.stdc.complex.cabs; + deprecated alias fabs = core.stdc.complex.cabsf; + deprecated alias fabs = core.stdc.complex.cabsl; /// - alias core.stdc.math.hypot hypot; + alias hypot = core.stdc.math.hypot; /// - alias core.stdc.math.hypotf hypot; + alias hypot = core.stdc.math.hypotf; /// - alias core.stdc.math.hypotl hypot; + alias hypot = core.stdc.math.hypotl; /// - alias core.stdc.math.pow pow; + alias pow = core.stdc.math.pow; /// - alias core.stdc.math.powf pow; + alias pow = core.stdc.math.powf; /// - alias core.stdc.math.powl pow; + alias pow = core.stdc.math.powl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cpow pow; - deprecated alias core.stdc.complex.cpowf pow; - deprecated alias core.stdc.complex.cpowl pow; + deprecated alias pow = core.stdc.complex.cpow; + deprecated alias pow = core.stdc.complex.cpowf; + deprecated alias pow = core.stdc.complex.cpowl; /// - alias core.stdc.math.sqrt sqrt; + alias sqrt = core.stdc.math.sqrt; /// - alias core.stdc.math.sqrtf sqrt; + alias sqrt = core.stdc.math.sqrtf; /// - alias core.stdc.math.sqrtl sqrt; + alias sqrt = core.stdc.math.sqrtl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.csqrt sqrt; - deprecated alias core.stdc.complex.csqrtf sqrt; - deprecated alias core.stdc.complex.csqrtl sqrt; + deprecated alias sqrt = core.stdc.complex.csqrt; + deprecated alias sqrt = core.stdc.complex.csqrtf; + deprecated alias sqrt = core.stdc.complex.csqrtl; /// - alias core.stdc.math.erf erf; + alias erf = core.stdc.math.erf; /// - alias core.stdc.math.erff erf; + alias erf = core.stdc.math.erff; /// - alias core.stdc.math.erfl erf; + alias erf = core.stdc.math.erfl; /// - alias core.stdc.math.erfc erfc; + alias erfc = core.stdc.math.erfc; /// - alias core.stdc.math.erfcf erfc; + alias erfc = core.stdc.math.erfcf; /// - alias core.stdc.math.erfcl erfc; + alias erfc = core.stdc.math.erfcl; /// - alias core.stdc.math.lgamma lgamma; + alias lgamma = core.stdc.math.lgamma; /// - alias core.stdc.math.lgammaf lgamma; + alias lgamma = core.stdc.math.lgammaf; /// - alias core.stdc.math.lgammal lgamma; + alias lgamma = core.stdc.math.lgammal; /// - alias core.stdc.math.tgamma tgamma; + alias tgamma = core.stdc.math.tgamma; /// - alias core.stdc.math.tgammaf tgamma; + alias tgamma = core.stdc.math.tgammaf; /// - alias core.stdc.math.tgammal tgamma; + alias tgamma = core.stdc.math.tgammal; /// - alias core.stdc.math.ceil ceil; + alias ceil = core.stdc.math.ceil; /// - alias core.stdc.math.ceilf ceil; + alias ceil = core.stdc.math.ceilf; /// - alias core.stdc.math.ceill ceil; + alias ceil = core.stdc.math.ceill; /// - alias core.stdc.math.floor floor; + alias floor = core.stdc.math.floor; /// - alias core.stdc.math.floorf floor; + alias floor = core.stdc.math.floorf; /// - alias core.stdc.math.floorl floor; + alias floor = core.stdc.math.floorl; /// - alias core.stdc.math.nearbyint nearbyint; + alias nearbyint = core.stdc.math.nearbyint; /// - alias core.stdc.math.nearbyintf nearbyint; + alias nearbyint = core.stdc.math.nearbyintf; /// - alias core.stdc.math.nearbyintl nearbyint; + alias nearbyint = core.stdc.math.nearbyintl; /// - alias core.stdc.math.rint rint; + alias rint = core.stdc.math.rint; /// - alias core.stdc.math.rintf rint; + alias rint = core.stdc.math.rintf; /// - alias core.stdc.math.rintl rint; + alias rint = core.stdc.math.rintl; /// - alias core.stdc.math.lrint lrint; + alias lrint = core.stdc.math.lrint; /// - alias core.stdc.math.lrintf lrint; + alias lrint = core.stdc.math.lrintf; /// - alias core.stdc.math.lrintl lrint; + alias lrint = core.stdc.math.lrintl; /// - alias core.stdc.math.llrint llrint; + alias llrint = core.stdc.math.llrint; /// - alias core.stdc.math.llrintf llrint; + alias llrint = core.stdc.math.llrintf; /// - alias core.stdc.math.llrintl llrint; + alias llrint = core.stdc.math.llrintl; /// - alias core.stdc.math.round round; + alias round = core.stdc.math.round; /// - alias core.stdc.math.roundf round; + alias round = core.stdc.math.roundf; /// - alias core.stdc.math.roundl round; + alias round = core.stdc.math.roundl; /// - alias core.stdc.math.lround lround; + alias lround = core.stdc.math.lround; /// - alias core.stdc.math.lroundf lround; + alias lround = core.stdc.math.lroundf; /// - alias core.stdc.math.lroundl lround; + alias lround = core.stdc.math.lroundl; /// - alias core.stdc.math.llround llround; + alias llround = core.stdc.math.llround; /// - alias core.stdc.math.llroundf llround; + alias llround = core.stdc.math.llroundf; /// - alias core.stdc.math.llroundl llround; + alias llround = core.stdc.math.llroundl; /// - alias core.stdc.math.trunc trunc; + alias trunc = core.stdc.math.trunc; /// - alias core.stdc.math.truncf trunc; + alias trunc = core.stdc.math.truncf; /// - alias core.stdc.math.truncl trunc; + alias trunc = core.stdc.math.truncl; /// - alias core.stdc.math.remainder remainder; + alias remainder = core.stdc.math.remainder; /// - alias core.stdc.math.remainderf remainder; + alias remainder = core.stdc.math.remainderf; /// - alias core.stdc.math.remainderl remainder; + alias remainder = core.stdc.math.remainderl; /// - alias core.stdc.math.remquo remquo; + alias remquo = core.stdc.math.remquo; /// - alias core.stdc.math.remquof remquo; + alias remquo = core.stdc.math.remquof; /// - alias core.stdc.math.remquol remquo; + alias remquo = core.stdc.math.remquol; /// - alias core.stdc.math.copysign copysign; + alias copysign = core.stdc.math.copysign; /// - alias core.stdc.math.copysignf copysign; + alias copysign = core.stdc.math.copysignf; /// - alias core.stdc.math.copysignl copysign; + alias copysign = core.stdc.math.copysignl; /// - alias core.stdc.math.nextafter nextafter; + alias nextafter = core.stdc.math.nextafter; /// - alias core.stdc.math.nextafterf nextafter; + alias nextafter = core.stdc.math.nextafterf; /// - alias core.stdc.math.nextafterl nextafter; + alias nextafter = core.stdc.math.nextafterl; /// - alias core.stdc.math.nexttoward nexttoward; + alias nexttoward = core.stdc.math.nexttoward; /// - alias core.stdc.math.nexttowardf nexttoward; + alias nexttoward = core.stdc.math.nexttowardf; /// - alias core.stdc.math.nexttowardl nexttoward; + alias nexttoward = core.stdc.math.nexttowardl; /// - alias core.stdc.math.fdim fdim; + alias fdim = core.stdc.math.fdim; /// - alias core.stdc.math.fdimf fdim; + alias fdim = core.stdc.math.fdimf; /// - alias core.stdc.math.fdiml fdim; + alias fdim = core.stdc.math.fdiml; /// - alias core.stdc.math.fmax fmax; + alias fmax = core.stdc.math.fmax; /// - alias core.stdc.math.fmaxf fmax; + alias fmax = core.stdc.math.fmaxf; /// - alias core.stdc.math.fmaxl fmax; + alias fmax = core.stdc.math.fmaxl; /// - alias core.stdc.math.fmin fmin; + alias fmin = core.stdc.math.fmin; /// - alias core.stdc.math.fmin fmin; + alias fmin = core.stdc.math.fmin; /// - alias core.stdc.math.fminl fmin; + alias fmin = core.stdc.math.fminl; /// - alias core.stdc.math.fma fma; + alias fma = core.stdc.math.fma; /// - alias core.stdc.math.fmaf fma; + alias fma = core.stdc.math.fmaf; /// - alias core.stdc.math.fmal fma; + alias fma = core.stdc.math.fmal; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.carg carg; - deprecated alias core.stdc.complex.cargf carg; - deprecated alias core.stdc.complex.cargl carg; - deprecated alias core.stdc.complex.cimag cimag; - deprecated alias core.stdc.complex.cimagf cimag; - deprecated alias core.stdc.complex.cimagl cimag; - deprecated alias core.stdc.complex.conj conj; - deprecated alias core.stdc.complex.conjf conj; - deprecated alias core.stdc.complex.conjl conj; - deprecated alias core.stdc.complex.cproj cproj; - deprecated alias core.stdc.complex.cprojf cproj; - deprecated alias core.stdc.complex.cprojl cproj; + deprecated alias carg = core.stdc.complex.carg; + deprecated alias carg = core.stdc.complex.cargf; + deprecated alias carg = core.stdc.complex.cargl; + deprecated alias cimag = core.stdc.complex.cimag; + deprecated alias cimag = core.stdc.complex.cimagf; + deprecated alias cimag = core.stdc.complex.cimagl; + deprecated alias conj = core.stdc.complex.conj; + deprecated alias conj = core.stdc.complex.conjf; + deprecated alias conj = core.stdc.complex.conjl; + deprecated alias cproj = core.stdc.complex.cproj; + deprecated alias cproj = core.stdc.complex.cprojf; + deprecated alias cproj = core.stdc.complex.cprojl; // deprecated alias core.stdc.complex.creal creal; // deprecated alias core.stdc.complex.crealf creal; @@ -1016,515 +1016,515 @@ else version (OpenBSD) else { /// - alias core.stdc.math.acos acos; + alias acos = core.stdc.math.acos; /// - alias core.stdc.math.acosf acos; + alias acos = core.stdc.math.acosf; /// - alias core.stdc.math.acosl acos; + alias acos = core.stdc.math.acosl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cacos acos; - deprecated alias core.stdc.complex.cacosf acos; - deprecated alias core.stdc.complex.cacosl acos; + deprecated alias acos = core.stdc.complex.cacos; + deprecated alias acos = core.stdc.complex.cacosf; + deprecated alias acos = core.stdc.complex.cacosl; /// - alias core.stdc.math.asin asin; + alias asin = core.stdc.math.asin; /// - alias core.stdc.math.asinf asin; + alias asin = core.stdc.math.asinf; /// - alias core.stdc.math.asinl asin; + alias asin = core.stdc.math.asinl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.casin asin; - deprecated alias core.stdc.complex.casinf asin; - deprecated alias core.stdc.complex.casinl asin; + deprecated alias asin = core.stdc.complex.casin; + deprecated alias asin = core.stdc.complex.casinf; + deprecated alias asin = core.stdc.complex.casinl; /// - alias core.stdc.math.atan atan; + alias atan = core.stdc.math.atan; /// - alias core.stdc.math.atanf atan; + alias atan = core.stdc.math.atanf; /// - alias core.stdc.math.atanl atan; + alias atan = core.stdc.math.atanl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.catan atan; - deprecated alias core.stdc.complex.catanf atan; - deprecated alias core.stdc.complex.catanl atan; + deprecated alias atan = core.stdc.complex.catan; + deprecated alias atan = core.stdc.complex.catanf; + deprecated alias atan = core.stdc.complex.catanl; /// - alias core.stdc.math.atan2 atan2; + alias atan2 = core.stdc.math.atan2; /// - alias core.stdc.math.atan2f atan2; + alias atan2 = core.stdc.math.atan2f; /// - alias core.stdc.math.atan2l atan2; + alias atan2 = core.stdc.math.atan2l; /// - alias core.stdc.math.cos cos; + alias cos = core.stdc.math.cos; /// - alias core.stdc.math.cosf cos; + alias cos = core.stdc.math.cosf; /// - alias core.stdc.math.cosl cos; + alias cos = core.stdc.math.cosl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.ccos cos; - deprecated alias core.stdc.complex.ccosf cos; - deprecated alias core.stdc.complex.ccosl cos; + deprecated alias cos = core.stdc.complex.ccos; + deprecated alias cos = core.stdc.complex.ccosf; + deprecated alias cos = core.stdc.complex.ccosl; /// - alias core.stdc.math.sin sin; + alias sin = core.stdc.math.sin; /// - alias core.stdc.math.sinf sin; + alias sin = core.stdc.math.sinf; /// - alias core.stdc.math.sinl sin; + alias sin = core.stdc.math.sinl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.csin csin; - deprecated alias core.stdc.complex.csinf csin; - deprecated alias core.stdc.complex.csinl csin; + deprecated alias csin = core.stdc.complex.csin; + deprecated alias csin = core.stdc.complex.csinf; + deprecated alias csin = core.stdc.complex.csinl; /// - alias core.stdc.math.tan tan; + alias tan = core.stdc.math.tan; /// - alias core.stdc.math.tanf tan; + alias tan = core.stdc.math.tanf; /// - alias core.stdc.math.tanl tan; + alias tan = core.stdc.math.tanl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.ctan tan; - deprecated alias core.stdc.complex.ctanf tan; - deprecated alias core.stdc.complex.ctanl tan; + deprecated alias tan = core.stdc.complex.ctan; + deprecated alias tan = core.stdc.complex.ctanf; + deprecated alias tan = core.stdc.complex.ctanl; /// - alias core.stdc.math.acosh acosh; + alias acosh = core.stdc.math.acosh; /// - alias core.stdc.math.acoshf acosh; + alias acosh = core.stdc.math.acoshf; /// - alias core.stdc.math.acoshl acosh; + alias acosh = core.stdc.math.acoshl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cacosh acosh; - deprecated alias core.stdc.complex.cacoshf acosh; - deprecated alias core.stdc.complex.cacoshl acosh; + deprecated alias acosh = core.stdc.complex.cacosh; + deprecated alias acosh = core.stdc.complex.cacoshf; + deprecated alias acosh = core.stdc.complex.cacoshl; /// - alias core.stdc.math.asinh asinh; + alias asinh = core.stdc.math.asinh; /// - alias core.stdc.math.asinhf asinh; + alias asinh = core.stdc.math.asinhf; /// - alias core.stdc.math.asinhl asinh; + alias asinh = core.stdc.math.asinhl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.casinh asinh; - deprecated alias core.stdc.complex.casinhf asinh; - deprecated alias core.stdc.complex.casinhl asinh; + deprecated alias asinh = core.stdc.complex.casinh; + deprecated alias asinh = core.stdc.complex.casinhf; + deprecated alias asinh = core.stdc.complex.casinhl; /// - alias core.stdc.math.atanh atanh; + alias atanh = core.stdc.math.atanh; /// - alias core.stdc.math.atanhf atanh; + alias atanh = core.stdc.math.atanhf; /// - alias core.stdc.math.atanhl atanh; + alias atanh = core.stdc.math.atanhl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.catanh atanh; - deprecated alias core.stdc.complex.catanhf atanh; - deprecated alias core.stdc.complex.catanhl atanh; + deprecated alias atanh = core.stdc.complex.catanh; + deprecated alias atanh = core.stdc.complex.catanhf; + deprecated alias atanh = core.stdc.complex.catanhl; /// - alias core.stdc.math.cosh cosh; + alias cosh = core.stdc.math.cosh; /// - alias core.stdc.math.coshf cosh; + alias cosh = core.stdc.math.coshf; /// - alias core.stdc.math.coshl cosh; + alias cosh = core.stdc.math.coshl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.ccosh cosh; - deprecated alias core.stdc.complex.ccoshf cosh; - deprecated alias core.stdc.complex.ccoshl cosh; + deprecated alias cosh = core.stdc.complex.ccosh; + deprecated alias cosh = core.stdc.complex.ccoshf; + deprecated alias cosh = core.stdc.complex.ccoshl; /// - alias core.stdc.math.sinh sinh; + alias sinh = core.stdc.math.sinh; /// - alias core.stdc.math.sinhf sinh; + alias sinh = core.stdc.math.sinhf; /// - alias core.stdc.math.sinhl sinh; + alias sinh = core.stdc.math.sinhl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.csinh sinh; - deprecated alias core.stdc.complex.csinhf sinh; - deprecated alias core.stdc.complex.csinhl sinh; + deprecated alias sinh = core.stdc.complex.csinh; + deprecated alias sinh = core.stdc.complex.csinhf; + deprecated alias sinh = core.stdc.complex.csinhl; /// - alias core.stdc.math.tanh tanh; + alias tanh = core.stdc.math.tanh; /// - alias core.stdc.math.tanhf tanh; + alias tanh = core.stdc.math.tanhf; /// - alias core.stdc.math.tanhl tanh; + alias tanh = core.stdc.math.tanhl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.ctanh tanh; - deprecated alias core.stdc.complex.ctanhf tanh; - deprecated alias core.stdc.complex.ctanhl tanh; + deprecated alias tanh = core.stdc.complex.ctanh; + deprecated alias tanh = core.stdc.complex.ctanhf; + deprecated alias tanh = core.stdc.complex.ctanhl; /// - alias core.stdc.math.exp exp; + alias exp = core.stdc.math.exp; /// - alias core.stdc.math.expf exp; + alias exp = core.stdc.math.expf; /// - alias core.stdc.math.expl exp; + alias exp = core.stdc.math.expl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cexp exp; - deprecated alias core.stdc.complex.cexpf exp; - deprecated alias core.stdc.complex.cexpl exp; + deprecated alias exp = core.stdc.complex.cexp; + deprecated alias exp = core.stdc.complex.cexpf; + deprecated alias exp = core.stdc.complex.cexpl; /// - alias core.stdc.math.exp2 exp2; + alias exp2 = core.stdc.math.exp2; /// - alias core.stdc.math.exp2f exp2; + alias exp2 = core.stdc.math.exp2f; /// - alias core.stdc.math.exp2l exp2; + alias exp2 = core.stdc.math.exp2l; /// - alias core.stdc.math.expm1 expm1; + alias expm1 = core.stdc.math.expm1; /// - alias core.stdc.math.expm1f expm1; + alias expm1 = core.stdc.math.expm1f; /// - alias core.stdc.math.expm1l expm1; + alias expm1 = core.stdc.math.expm1l; /// - alias core.stdc.math.frexp frexp; + alias frexp = core.stdc.math.frexp; /// - alias core.stdc.math.frexpf frexp; + alias frexp = core.stdc.math.frexpf; /// - alias core.stdc.math.frexpl frexp; + alias frexp = core.stdc.math.frexpl; /// - alias core.stdc.math.ilogb ilogb; + alias ilogb = core.stdc.math.ilogb; /// - alias core.stdc.math.ilogbf ilogb; + alias ilogb = core.stdc.math.ilogbf; /// - alias core.stdc.math.ilogbl ilogb; + alias ilogb = core.stdc.math.ilogbl; /// - alias core.stdc.math.ldexp ldexp; + alias ldexp = core.stdc.math.ldexp; /// - alias core.stdc.math.ldexpf ldexp; + alias ldexp = core.stdc.math.ldexpf; /// - alias core.stdc.math.ldexpl ldexp; + alias ldexp = core.stdc.math.ldexpl; /// - alias core.stdc.math.log log; + alias log = core.stdc.math.log; /// - alias core.stdc.math.logf log; + alias log = core.stdc.math.logf; /// - alias core.stdc.math.logl log; + alias log = core.stdc.math.logl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.clog log; - deprecated alias core.stdc.complex.clogf log; - deprecated alias core.stdc.complex.clogl log; + deprecated alias log = core.stdc.complex.clog; + deprecated alias log = core.stdc.complex.clogf; + deprecated alias log = core.stdc.complex.clogl; /// - alias core.stdc.math.log10 log10; + alias log10 = core.stdc.math.log10; /// - alias core.stdc.math.log10f log10; + alias log10 = core.stdc.math.log10f; /// - alias core.stdc.math.log10l log10; + alias log10 = core.stdc.math.log10l; /// - alias core.stdc.math.log1p log1p; + alias log1p = core.stdc.math.log1p; /// - alias core.stdc.math.log1pf log1p; + alias log1p = core.stdc.math.log1pf; /// - alias core.stdc.math.log1pl log1p; + alias log1p = core.stdc.math.log1pl; /// - alias core.stdc.math.log2 log2; + alias log2 = core.stdc.math.log2; /// - alias core.stdc.math.log2f log2; + alias log2 = core.stdc.math.log2f; /// - alias core.stdc.math.log2l log2; + alias log2 = core.stdc.math.log2l; /// - alias core.stdc.math.logb logb; + alias logb = core.stdc.math.logb; /// - alias core.stdc.math.logbf logb; + alias logb = core.stdc.math.logbf; /// - alias core.stdc.math.logbl logb; + alias logb = core.stdc.math.logbl; /// - alias core.stdc.math.modf modf; + alias modf = core.stdc.math.modf; /// - alias core.stdc.math.modff modf; + alias modf = core.stdc.math.modff; /// - alias core.stdc.math.modfl modf; + alias modf = core.stdc.math.modfl; /// - alias core.stdc.math.scalbn scalbn; + alias scalbn = core.stdc.math.scalbn; /// - alias core.stdc.math.scalbnf scalbn; + alias scalbn = core.stdc.math.scalbnf; /// - alias core.stdc.math.scalbnl scalbn; + alias scalbn = core.stdc.math.scalbnl; /// - alias core.stdc.math.scalbln scalbln; + alias scalbln = core.stdc.math.scalbln; /// - alias core.stdc.math.scalblnf scalbln; + alias scalbln = core.stdc.math.scalblnf; /// - alias core.stdc.math.scalblnl scalbln; + alias scalbln = core.stdc.math.scalblnl; /// - alias core.stdc.math.cbrt cbrt; + alias cbrt = core.stdc.math.cbrt; /// - alias core.stdc.math.cbrtf cbrt; + alias cbrt = core.stdc.math.cbrtf; /// - alias core.stdc.math.cbrtl cbrt; + alias cbrt = core.stdc.math.cbrtl; /// - alias core.stdc.math.fabs fabs; + alias fabs = core.stdc.math.fabs; version (CRuntime_Microsoft) { version (MinGW) { /// - alias core.stdc.math.fabsf fabs; + alias fabs = core.stdc.math.fabsf; /// - alias core.stdc.math.fabsl fabs; + alias fabs = core.stdc.math.fabsl; } } else { /// - alias core.stdc.math.fabsf fabs; + alias fabs = core.stdc.math.fabsf; /// - alias core.stdc.math.fabsl fabs; + alias fabs = core.stdc.math.fabsl; } // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cabs fabs; - deprecated alias core.stdc.complex.cabsf fabs; - deprecated alias core.stdc.complex.cabsl fabs; + deprecated alias fabs = core.stdc.complex.cabs; + deprecated alias fabs = core.stdc.complex.cabsf; + deprecated alias fabs = core.stdc.complex.cabsl; /// - alias core.stdc.math.hypot hypot; + alias hypot = core.stdc.math.hypot; /// - alias core.stdc.math.hypotf hypot; + alias hypot = core.stdc.math.hypotf; /// - alias core.stdc.math.hypotl hypot; + alias hypot = core.stdc.math.hypotl; /// - alias core.stdc.math.pow pow; + alias pow = core.stdc.math.pow; /// - alias core.stdc.math.powf pow; + alias pow = core.stdc.math.powf; /// - alias core.stdc.math.powl pow; + alias pow = core.stdc.math.powl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.cpow pow; - deprecated alias core.stdc.complex.cpowf pow; - deprecated alias core.stdc.complex.cpowl pow; + deprecated alias pow = core.stdc.complex.cpow; + deprecated alias pow = core.stdc.complex.cpowf; + deprecated alias pow = core.stdc.complex.cpowl; /// - alias core.stdc.math.sqrt sqrt; + alias sqrt = core.stdc.math.sqrt; /// - alias core.stdc.math.sqrtf sqrt; + alias sqrt = core.stdc.math.sqrtf; /// - alias core.stdc.math.sqrtl sqrt; + alias sqrt = core.stdc.math.sqrtl; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.csqrt sqrt; - deprecated alias core.stdc.complex.csqrtf sqrt; - deprecated alias core.stdc.complex.csqrtl sqrt; + deprecated alias sqrt = core.stdc.complex.csqrt; + deprecated alias sqrt = core.stdc.complex.csqrtf; + deprecated alias sqrt = core.stdc.complex.csqrtl; /// - alias core.stdc.math.erf erf; + alias erf = core.stdc.math.erf; /// - alias core.stdc.math.erff erf; + alias erf = core.stdc.math.erff; /// - alias core.stdc.math.erfl erf; + alias erf = core.stdc.math.erfl; /// - alias core.stdc.math.erfc erfc; + alias erfc = core.stdc.math.erfc; /// - alias core.stdc.math.erfcf erfc; + alias erfc = core.stdc.math.erfcf; /// - alias core.stdc.math.erfcl erfc; + alias erfc = core.stdc.math.erfcl; /// - alias core.stdc.math.lgamma lgamma; + alias lgamma = core.stdc.math.lgamma; /// - alias core.stdc.math.lgammaf lgamma; + alias lgamma = core.stdc.math.lgammaf; /// - alias core.stdc.math.lgammal lgamma; + alias lgamma = core.stdc.math.lgammal; /// - alias core.stdc.math.tgamma tgamma; + alias tgamma = core.stdc.math.tgamma; /// - alias core.stdc.math.tgammaf tgamma; + alias tgamma = core.stdc.math.tgammaf; /// - alias core.stdc.math.tgammal tgamma; + alias tgamma = core.stdc.math.tgammal; /// - alias core.stdc.math.ceil ceil; + alias ceil = core.stdc.math.ceil; /// - alias core.stdc.math.ceilf ceil; + alias ceil = core.stdc.math.ceilf; /// - alias core.stdc.math.ceill ceil; + alias ceil = core.stdc.math.ceill; /// - alias core.stdc.math.floor floor; + alias floor = core.stdc.math.floor; /// - alias core.stdc.math.floorf floor; + alias floor = core.stdc.math.floorf; /// - alias core.stdc.math.floorl floor; + alias floor = core.stdc.math.floorl; /// - alias core.stdc.math.nearbyint nearbyint; + alias nearbyint = core.stdc.math.nearbyint; /// - alias core.stdc.math.nearbyintf nearbyint; + alias nearbyint = core.stdc.math.nearbyintf; /// - alias core.stdc.math.nearbyintl nearbyint; + alias nearbyint = core.stdc.math.nearbyintl; /// - alias core.stdc.math.rint rint; + alias rint = core.stdc.math.rint; /// - alias core.stdc.math.rintf rint; + alias rint = core.stdc.math.rintf; /// - alias core.stdc.math.rintl rint; + alias rint = core.stdc.math.rintl; /// - alias core.stdc.math.lrint lrint; + alias lrint = core.stdc.math.lrint; /// - alias core.stdc.math.lrintf lrint; + alias lrint = core.stdc.math.lrintf; /// - alias core.stdc.math.lrintl lrint; + alias lrint = core.stdc.math.lrintl; /// - alias core.stdc.math.llrint llrint; + alias llrint = core.stdc.math.llrint; /// - alias core.stdc.math.llrintf llrint; + alias llrint = core.stdc.math.llrintf; /// - alias core.stdc.math.llrintl llrint; + alias llrint = core.stdc.math.llrintl; /// - alias core.stdc.math.round round; + alias round = core.stdc.math.round; /// - alias core.stdc.math.roundf round; + alias round = core.stdc.math.roundf; /// - alias core.stdc.math.roundl round; + alias round = core.stdc.math.roundl; /// - alias core.stdc.math.lround lround; + alias lround = core.stdc.math.lround; /// - alias core.stdc.math.lroundf lround; + alias lround = core.stdc.math.lroundf; /// - alias core.stdc.math.lroundl lround; + alias lround = core.stdc.math.lroundl; /// - alias core.stdc.math.llround llround; + alias llround = core.stdc.math.llround; /// - alias core.stdc.math.llroundf llround; + alias llround = core.stdc.math.llroundf; /// - alias core.stdc.math.llroundl llround; + alias llround = core.stdc.math.llroundl; /// - alias core.stdc.math.trunc trunc; + alias trunc = core.stdc.math.trunc; /// - alias core.stdc.math.truncf trunc; + alias trunc = core.stdc.math.truncf; /// - alias core.stdc.math.truncl trunc; + alias trunc = core.stdc.math.truncl; /// - alias core.stdc.math.fmod fmod; + alias fmod = core.stdc.math.fmod; /// - alias core.stdc.math.fmodf fmod; + alias fmod = core.stdc.math.fmodf; /// - alias core.stdc.math.fmodl fmod; + alias fmod = core.stdc.math.fmodl; /// - alias core.stdc.math.remainder remainder; + alias remainder = core.stdc.math.remainder; /// - alias core.stdc.math.remainderf remainder; + alias remainder = core.stdc.math.remainderf; /// - alias core.stdc.math.remainderl remainder; + alias remainder = core.stdc.math.remainderl; /// - alias core.stdc.math.remquo remquo; + alias remquo = core.stdc.math.remquo; /// - alias core.stdc.math.remquof remquo; + alias remquo = core.stdc.math.remquof; /// - alias core.stdc.math.remquol remquo; + alias remquo = core.stdc.math.remquol; /// - alias core.stdc.math.copysign copysign; + alias copysign = core.stdc.math.copysign; /// - alias core.stdc.math.copysignf copysign; + alias copysign = core.stdc.math.copysignf; /// - alias core.stdc.math.copysignl copysign; + alias copysign = core.stdc.math.copysignl; /// - alias core.stdc.math.nan nan; + alias nan = core.stdc.math.nan; /// - alias core.stdc.math.nanf nan; + alias nan = core.stdc.math.nanf; /// - alias core.stdc.math.nanl nan; + alias nan = core.stdc.math.nanl; /// - alias core.stdc.math.nextafter nextafter; + alias nextafter = core.stdc.math.nextafter; /// - alias core.stdc.math.nextafterf nextafter; + alias nextafter = core.stdc.math.nextafterf; /// - alias core.stdc.math.nextafterl nextafter; + alias nextafter = core.stdc.math.nextafterl; /// - alias core.stdc.math.nexttoward nexttoward; + alias nexttoward = core.stdc.math.nexttoward; /// - alias core.stdc.math.nexttowardf nexttoward; + alias nexttoward = core.stdc.math.nexttowardf; /// - alias core.stdc.math.nexttowardl nexttoward; + alias nexttoward = core.stdc.math.nexttowardl; /// - alias core.stdc.math.fdim fdim; + alias fdim = core.stdc.math.fdim; /// - alias core.stdc.math.fdimf fdim; + alias fdim = core.stdc.math.fdimf; /// - alias core.stdc.math.fdiml fdim; + alias fdim = core.stdc.math.fdiml; /// - alias core.stdc.math.fmax fmax; + alias fmax = core.stdc.math.fmax; /// - alias core.stdc.math.fmaxf fmax; + alias fmax = core.stdc.math.fmaxf; /// - alias core.stdc.math.fmaxl fmax; + alias fmax = core.stdc.math.fmaxl; /// - alias core.stdc.math.fmin fmin; + alias fmin = core.stdc.math.fmin; /// - alias core.stdc.math.fmin fmin; + alias fmin = core.stdc.math.fmin; /// - alias core.stdc.math.fminl fmin; + alias fmin = core.stdc.math.fminl; /// - alias core.stdc.math.fma fma; + alias fma = core.stdc.math.fma; /// - alias core.stdc.math.fmaf fma; + alias fma = core.stdc.math.fmaf; /// - alias core.stdc.math.fmal fma; + alias fma = core.stdc.math.fmal; // @@@DEPRECATED_2.105@@@ - deprecated alias core.stdc.complex.carg carg; - deprecated alias core.stdc.complex.cargf carg; - deprecated alias core.stdc.complex.cargl carg; - deprecated alias core.stdc.complex.cimag cimag; - deprecated alias core.stdc.complex.cimagf cimag; - deprecated alias core.stdc.complex.cimagl cimag; - deprecated alias core.stdc.complex.conj conj; - deprecated alias core.stdc.complex.conjf conj; - deprecated alias core.stdc.complex.conjl conj; - deprecated alias core.stdc.complex.cproj cproj; - deprecated alias core.stdc.complex.cprojf cproj; - deprecated alias core.stdc.complex.cprojl cproj; + deprecated alias carg = core.stdc.complex.carg; + deprecated alias carg = core.stdc.complex.cargf; + deprecated alias carg = core.stdc.complex.cargl; + deprecated alias cimag = core.stdc.complex.cimag; + deprecated alias cimag = core.stdc.complex.cimagf; + deprecated alias cimag = core.stdc.complex.cimagl; + deprecated alias conj = core.stdc.complex.conj; + deprecated alias conj = core.stdc.complex.conjf; + deprecated alias conj = core.stdc.complex.conjl; + deprecated alias cproj = core.stdc.complex.cproj; + deprecated alias cproj = core.stdc.complex.cprojf; + deprecated alias cproj = core.stdc.complex.cprojl; // deprecated alias core.stdc.complex.creal creal; // deprecated alias core.stdc.complex.crealf creal; // deprecated alias core.stdc.complex.creall creal; diff --git a/runtime/druntime/src/core/stdc/wchar_.d b/runtime/druntime/src/core/stdc/wchar_.d index cd6192b057..43c72ec190 100644 --- a/runtime/druntime/src/core/stdc/wchar_.d +++ b/runtime/druntime/src/core/stdc/wchar_.d @@ -149,11 +149,11 @@ else version (Windows) else { /// - alias int mbstate_t; + alias mbstate_t = int; } /// -alias wchar_t wint_t; +alias wint_t = wchar_t; /// enum wchar_t WEOF = 0xFFFF; diff --git a/runtime/druntime/src/core/stdc/wctype.d b/runtime/druntime/src/core/stdc/wctype.d index 88b6a01245..2b55f3decb 100644 --- a/runtime/druntime/src/core/stdc/wctype.d +++ b/runtime/druntime/src/core/stdc/wctype.d @@ -53,9 +53,9 @@ else version (CRuntime_Bionic) else { /// - alias wchar_t wctrans_t; + alias wctrans_t = wchar_t; /// - alias wchar_t wctype_t; + alias wctype_t = wchar_t; } /// diff --git a/runtime/druntime/src/core/sys/darwin/mach/kern_return.d b/runtime/druntime/src/core/sys/darwin/mach/kern_return.d index 3714e01712..5fd383bc96 100644 --- a/runtime/druntime/src/core/sys/darwin/mach/kern_return.d +++ b/runtime/druntime/src/core/sys/darwin/mach/kern_return.d @@ -25,7 +25,7 @@ else version (WatchOS) version (Darwin): extern (C): -alias int kern_return_t; +alias kern_return_t = int; enum : kern_return_t { diff --git a/runtime/druntime/src/core/sys/darwin/mach/semaphore.d b/runtime/druntime/src/core/sys/darwin/mach/semaphore.d index abaa267111..83c3e7c0f6 100644 --- a/runtime/druntime/src/core/sys/darwin/mach/semaphore.d +++ b/runtime/druntime/src/core/sys/darwin/mach/semaphore.d @@ -30,12 +30,12 @@ nothrow: public import core.sys.darwin.mach.kern_return; public import core.sys.darwin.mach.port; -alias mach_port_t task_t; -alias mach_port_t thread_t; -alias mach_port_t semaphore_t; -alias int sync_policy_t; +alias task_t = mach_port_t; +alias thread_t = mach_port_t; +alias semaphore_t = mach_port_t; +alias sync_policy_t = int; -alias int clock_res_t; +alias clock_res_t = int; struct mach_timespec_t { uint tv_sec; diff --git a/runtime/druntime/src/core/sys/darwin/mach/thread_act.d b/runtime/druntime/src/core/sys/darwin/mach/thread_act.d index d455d1b830..3a6e051981 100644 --- a/runtime/druntime/src/core/sys/darwin/mach/thread_act.d +++ b/runtime/druntime/src/core/sys/darwin/mach/thread_act.d @@ -45,10 +45,10 @@ version (PPC64) version (i386) { - alias mach_port_t thread_act_t; - alias void thread_state_t; - alias int thread_state_flavor_t; - alias natural_t mach_msg_type_number_t; + alias thread_act_t = mach_port_t; + alias thread_state_t = void; + alias thread_state_flavor_t = int; + alias mach_msg_type_number_t = natural_t; enum { @@ -136,8 +136,8 @@ version (i386) x86_THREAD_STATE_COUNT = cast(mach_msg_type_number_t)( x86_thread_state_t.sizeof / int.sizeof ), } - alias x86_THREAD_STATE MACHINE_THREAD_STATE; - alias x86_THREAD_STATE_COUNT MACHINE_THREAD_STATE_COUNT; + alias MACHINE_THREAD_STATE = x86_THREAD_STATE; + alias MACHINE_THREAD_STATE_COUNT = x86_THREAD_STATE_COUNT; mach_port_t mach_thread_self(); kern_return_t thread_suspend(thread_act_t); diff --git a/runtime/druntime/src/core/sys/darwin/sys/attr.d b/runtime/druntime/src/core/sys/darwin/sys/attr.d index cb22b380ef..30c5191df9 100644 --- a/runtime/druntime/src/core/sys/darwin/sys/attr.d +++ b/runtime/druntime/src/core/sys/darwin/sys/attr.d @@ -50,7 +50,7 @@ enum enum SEARCHFS_MAX_SEARCHPARMS = 4096; -alias uint text_encoding_t, fsobj_type_t, fsobj_tag_t, fsfile_type_t, fsvolid_t, attrgroup_t; +alias text_encoding_t = uint, fsobj_type_t = uint, fsobj_tag_t = uint, fsfile_type_t = uint, fsvolid_t = uint, attrgroup_t = uint; struct attrlist { diff --git a/runtime/druntime/src/core/sys/dragonflybsd/sys/elf32.d b/runtime/druntime/src/core/sys/dragonflybsd/sys/elf32.d index c796cd8fa7..c3c2d88b4b 100644 --- a/runtime/druntime/src/core/sys/dragonflybsd/sys/elf32.d +++ b/runtime/druntime/src/core/sys/dragonflybsd/sys/elf32.d @@ -13,10 +13,10 @@ extern (C): import core.stdc.stdint; public import core.sys.dragonflybsd.sys.elf_common; -alias uint64_t Elf32_Lword; -alias Elf32_Word Elf32_Hashelt; -alias Elf32_Word Elf32_Size; -alias Elf32_Sword Elf32_Ssize; +alias Elf32_Lword = uint64_t; +alias Elf32_Hashelt = Elf32_Word; +alias Elf32_Size = Elf32_Word; +alias Elf32_Ssize = Elf32_Sword; struct Elf32_Dyn { @@ -28,7 +28,7 @@ struct Elf32_Dyn } _d_un d_un; } -alias Elf_Note Elf32_Nhdr; +alias Elf32_Nhdr = Elf_Note; struct Elf32_Cap { diff --git a/runtime/druntime/src/core/sys/dragonflybsd/sys/elf64.d b/runtime/druntime/src/core/sys/dragonflybsd/sys/elf64.d index 89e3ca38a8..6b911dbe2a 100644 --- a/runtime/druntime/src/core/sys/dragonflybsd/sys/elf64.d +++ b/runtime/druntime/src/core/sys/dragonflybsd/sys/elf64.d @@ -13,10 +13,10 @@ extern (C): import core.stdc.stdint; public import core.sys.dragonflybsd.sys.elf_common; -alias uint64_t Elf64_Lword; -alias Elf64_Word Elf64_Hashelt; -alias Elf64_Xword Elf64_Size; -alias Elf64_Sxword Elf64_Ssize; +alias Elf64_Lword = uint64_t; +alias Elf64_Hashelt = Elf64_Word; +alias Elf64_Size = Elf64_Xword; +alias Elf64_Ssize = Elf64_Sxword; struct Elf64_Dyn { @@ -35,7 +35,7 @@ extern (D) pure auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; } } -alias Elf_Note Elf64_Nhdr; +alias Elf64_Nhdr = Elf_Note; struct Elf64_Cap { diff --git a/runtime/druntime/src/core/sys/dragonflybsd/sys/elf_common.d b/runtime/druntime/src/core/sys/dragonflybsd/sys/elf_common.d index 90e5861a6a..e0d6b24d7f 100644 --- a/runtime/druntime/src/core/sys/dragonflybsd/sys/elf_common.d +++ b/runtime/druntime/src/core/sys/dragonflybsd/sys/elf_common.d @@ -60,7 +60,7 @@ enum DT_USED = 0x7ffffffe; enum DF_1_BIND_NOW = 0x00000001; -alias VER_NDX VER_DEF_IDX; +alias VER_DEF_IDX = VER_NDX; enum VER_FLG_INFO = 0x4; @@ -74,7 +74,7 @@ extern (D) pure @safe enum VER_NEED_WEAK = 32768; enum VER_NEED_HIDDEN = VER_NDX_HIDDEN; -alias VER_NDX VER_NEED_IDX; +alias VER_NEED_IDX = VER_NDX; enum VERSYM_HIDDEN = 0x8000; enum VERSYM_VERSION = 0x7fff; diff --git a/runtime/druntime/src/core/sys/dragonflybsd/sys/link_elf.d b/runtime/druntime/src/core/sys/dragonflybsd/sys/link_elf.d index 5dad964057..7b7b350001 100644 --- a/runtime/druntime/src/core/sys/dragonflybsd/sys/link_elf.d +++ b/runtime/druntime/src/core/sys/dragonflybsd/sys/link_elf.d @@ -44,7 +44,7 @@ struct link_map void* l_ld; link_map* l_next, l_prev; } -alias link_map Link_map; +alias Link_map = link_map; enum { @@ -73,8 +73,8 @@ struct dl_phdr_info } -private alias int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb; -private alias int function(dl_phdr_info*, size_t, void *) @nogc dl_iterate_phdr_cb_ngc; +private alias dl_iterate_phdr_cb = int function(dl_phdr_info*, size_t, void *); +private alias dl_iterate_phdr_cb_ngc = int function(dl_phdr_info*, size_t, void *) @nogc; int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data); int dl_iterate_phdr(dl_iterate_phdr_cb_ngc __callback, void*__data) @nogc; diff --git a/runtime/druntime/src/core/sys/elf/package.d b/runtime/druntime/src/core/sys/elf/package.d index 60e05d9703..ccf4e6f863 100644 --- a/runtime/druntime/src/core/sys/elf/package.d +++ b/runtime/druntime/src/core/sys/elf/package.d @@ -11,30 +11,30 @@ nothrow: import core.stdc.stdint; -alias uint16_t Elf32_Half; -alias uint16_t Elf64_Half; +alias Elf32_Half = uint16_t; +alias Elf64_Half = uint16_t; -alias uint32_t Elf32_Word; -alias int32_t Elf32_Sword; -alias uint32_t Elf64_Word; -alias int32_t Elf64_Sword; +alias Elf32_Word = uint32_t; +alias Elf32_Sword = int32_t; +alias Elf64_Word = uint32_t; +alias Elf64_Sword = int32_t; -alias uint64_t Elf32_Xword; -alias int64_t Elf32_Sxword; -alias uint64_t Elf64_Xword; -alias int64_t Elf64_Sxword; +alias Elf32_Xword = uint64_t; +alias Elf32_Sxword = int64_t; +alias Elf64_Xword = uint64_t; +alias Elf64_Sxword = int64_t; -alias uint32_t Elf32_Addr; -alias uint64_t Elf64_Addr; +alias Elf32_Addr = uint32_t; +alias Elf64_Addr = uint64_t; -alias uint32_t Elf32_Off; -alias uint64_t Elf64_Off; +alias Elf32_Off = uint32_t; +alias Elf64_Off = uint64_t; -alias uint16_t Elf32_Section; -alias uint16_t Elf64_Section; +alias Elf32_Section = uint16_t; +alias Elf64_Section = uint16_t; -alias Elf32_Half Elf32_Versym; -alias Elf64_Half Elf64_Versym; +alias Elf32_Versym = Elf32_Half; +alias Elf64_Versym = Elf64_Half; enum EI_NIDENT = 16; @@ -492,9 +492,9 @@ extern (D) auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; } auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; } auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); } - alias ELF32_ST_BIND ELF64_ST_BIND; - alias ELF32_ST_TYPE ELF64_ST_TYPE; - alias ELF32_ST_INFO ELF64_ST_INFO; + alias ELF64_ST_BIND = ELF32_ST_BIND; + alias ELF64_ST_TYPE = ELF32_ST_TYPE; + alias ELF64_ST_INFO = ELF32_ST_INFO; } enum STB_LOCAL = 0; @@ -866,9 +866,9 @@ extern (D) auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; } } -alias ELF32_M_SYM ELF64_M_SYM; -alias ELF32_M_SIZE ELF64_M_SIZE; -alias ELF32_M_INFO ELF64_M_INFO; +alias ELF64_M_SYM = ELF32_M_SYM; +alias ELF64_M_SIZE = ELF32_M_SIZE; +alias ELF64_M_INFO = ELF32_M_INFO; enum EF_CPU32 = 0x00810000; enum R_68K_NONE = 0; @@ -1380,7 +1380,7 @@ enum LL_EXPORTS = (1 << 3); enum LL_DELAY_LOAD = (1 << 4); enum LL_DELTA = (1 << 5); -alias Elf32_Addr Elf32_Conflict; +alias Elf32_Conflict = Elf32_Addr; enum EF_PARISC_TRAPNIL = 0x00010000; enum EF_PARISC_EXT = 0x00020000; diff --git a/runtime/druntime/src/core/sys/freebsd/sys/elf32.d b/runtime/druntime/src/core/sys/freebsd/sys/elf32.d index 4e8ae2843f..75c293eefd 100644 --- a/runtime/druntime/src/core/sys/freebsd/sys/elf32.d +++ b/runtime/druntime/src/core/sys/freebsd/sys/elf32.d @@ -13,10 +13,10 @@ nothrow: import core.stdc.stdint; public import core.sys.freebsd.sys.elf_common; -alias uint64_t Elf32_Lword; -alias Elf32_Word Elf32_Hashelt; -alias Elf32_Word Elf32_Size; -alias Elf32_Sword Elf32_Ssize; +alias Elf32_Lword = uint64_t; +alias Elf32_Hashelt = Elf32_Word; +alias Elf32_Size = Elf32_Word; +alias Elf32_Ssize = Elf32_Sword; struct Elf32_Dyn { @@ -28,7 +28,7 @@ struct Elf32_Dyn } _d_un d_un; } -alias Elf_Note Elf32_Nhdr; +alias Elf32_Nhdr = Elf_Note; struct Elf32_Cap { diff --git a/runtime/druntime/src/core/sys/freebsd/sys/elf64.d b/runtime/druntime/src/core/sys/freebsd/sys/elf64.d index c56460c123..f1dff66ad3 100644 --- a/runtime/druntime/src/core/sys/freebsd/sys/elf64.d +++ b/runtime/druntime/src/core/sys/freebsd/sys/elf64.d @@ -13,10 +13,10 @@ nothrow: import core.stdc.stdint; public import core.sys.freebsd.sys.elf_common; -alias uint64_t Elf64_Lword; -alias Elf64_Word Elf64_Hashelt; -alias Elf64_Xword Elf64_Size; -alias Elf64_Sxword Elf64_Ssize; +alias Elf64_Lword = uint64_t; +alias Elf64_Hashelt = Elf64_Word; +alias Elf64_Size = Elf64_Xword; +alias Elf64_Ssize = Elf64_Sxword; struct Elf64_Dyn { @@ -35,7 +35,7 @@ extern (D) auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; } } -alias Elf_Note Elf64_Nhdr; +alias Elf64_Nhdr = Elf_Note; struct Elf64_Cap { diff --git a/runtime/druntime/src/core/sys/freebsd/sys/elf_common.d b/runtime/druntime/src/core/sys/freebsd/sys/elf_common.d index 05e78bf0dc..c167c80bb7 100644 --- a/runtime/druntime/src/core/sys/freebsd/sys/elf_common.d +++ b/runtime/druntime/src/core/sys/freebsd/sys/elf_common.d @@ -79,11 +79,11 @@ enum STV_EXPORTED = 4; enum STV_SINGLETON = 5; enum STV_ELIMINATE = 6; -alias VER_NDX VER_DEF_IDX; +alias VER_DEF_IDX = VER_NDX; enum VER_NEED_WEAK = 32768; enum VER_NEED_HIDDEN = VER_NDX_HIDDEN; -alias VER_NDX VER_NEED_IDX; +alias VER_NEED_IDX = VER_NDX; enum VER_NDX_GIVEN = 2; enum VER_NDX_HIDDEN = 32768; diff --git a/runtime/druntime/src/core/sys/freebsd/sys/link_elf.d b/runtime/druntime/src/core/sys/freebsd/sys/link_elf.d index d743d51a7b..f1e4c73942 100644 --- a/runtime/druntime/src/core/sys/freebsd/sys/link_elf.d +++ b/runtime/druntime/src/core/sys/freebsd/sys/link_elf.d @@ -42,7 +42,7 @@ struct link_map void* l_ld; link_map* l_next, l_prev; } -alias link_map Link_map; +alias Link_map = link_map; enum { @@ -71,8 +71,8 @@ struct dl_phdr_info } -private alias extern(C) int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb; -private alias extern(C) int function(dl_phdr_info*, size_t, void *) @nogc dl_iterate_phdr_cb_ngc; +private alias dl_iterate_phdr_cb = extern(C) int function(dl_phdr_info*, size_t, void *); +private alias dl_iterate_phdr_cb_ngc = extern(C) int function(dl_phdr_info*, size_t, void *) @nogc; extern int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data); extern int dl_iterate_phdr(dl_iterate_phdr_cb_ngc __callback, void*__data) @nogc; extern int _rtld_addr_phdr(const void*, dl_phdr_info*) @nogc; diff --git a/runtime/druntime/src/core/sys/linux/dlfcn.d b/runtime/druntime/src/core/sys/linux/dlfcn.d index 9d86d89155..7a110bbbf9 100644 --- a/runtime/druntime/src/core/sys/linux/dlfcn.d +++ b/runtime/druntime/src/core/sys/linux/dlfcn.d @@ -165,7 +165,7 @@ static if (_GNU_SOURCE) { enum RTLD_NEXT = cast(void *)-1L; enum RTLD_DEFAULT = cast(void *)0; - alias c_long Lmid_t; + alias Lmid_t = c_long; enum LM_ID_BASE = 0; enum LM_ID_NEWLM = -1; } diff --git a/runtime/druntime/src/core/sys/linux/elf.d b/runtime/druntime/src/core/sys/linux/elf.d index 0486cbee0b..18a61354c7 100644 --- a/runtime/druntime/src/core/sys/linux/elf.d +++ b/runtime/druntime/src/core/sys/linux/elf.d @@ -16,7 +16,7 @@ public import core.sys.elf; extern (D) { auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; } - alias ELF32_ST_VISIBILITY ELF64_ST_VISIBILITY; + alias ELF64_ST_VISIBILITY = ELF32_ST_VISIBILITY; } struct Elf32_Nhdr diff --git a/runtime/druntime/src/core/sys/linux/link.d b/runtime/druntime/src/core/sys/linux/link.d index ebb5771f70..2b0b1f50ca 100644 --- a/runtime/druntime/src/core/sys/linux/link.d +++ b/runtime/druntime/src/core/sys/linux/link.d @@ -33,68 +33,68 @@ import core.sys.linux.elf; // version (Android) { - alias __WORDSIZE __ELF_NATIVE_CLASS; + alias __ELF_NATIVE_CLASS = __WORDSIZE; version (D_LP64) - alias uint64_t Elf_Symndx; + alias Elf_Symndx = uint64_t; else - alias uint32_t Elf_Symndx; + alias Elf_Symndx = uint32_t; } else version (X86_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h - alias __WORDSIZE __ELF_NATIVE_CLASS; - alias uint32_t Elf_Symndx; + alias __ELF_NATIVE_CLASS = __WORDSIZE; + alias Elf_Symndx = uint32_t; } else version (HPPA_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h - alias __WORDSIZE __ELF_NATIVE_CLASS; - alias uint32_t Elf_Symndx; + alias __ELF_NATIVE_CLASS = __WORDSIZE; + alias Elf_Symndx = uint32_t; } else version (MIPS_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h - alias __WORDSIZE __ELF_NATIVE_CLASS; - alias uint32_t Elf_Symndx; + alias __ELF_NATIVE_CLASS = __WORDSIZE; + alias Elf_Symndx = uint32_t; } else version (PPC_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h - alias __WORDSIZE __ELF_NATIVE_CLASS; - alias uint32_t Elf_Symndx; + alias __ELF_NATIVE_CLASS = __WORDSIZE; + alias Elf_Symndx = uint32_t; } else version (ARM_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h - alias __WORDSIZE __ELF_NATIVE_CLASS; - alias uint32_t Elf_Symndx; + alias __ELF_NATIVE_CLASS = __WORDSIZE; + alias Elf_Symndx = uint32_t; } else version (RISCV_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h - alias __WORDSIZE __ELF_NATIVE_CLASS; - alias uint32_t Elf_Symndx; + alias __ELF_NATIVE_CLASS = __WORDSIZE; + alias Elf_Symndx = uint32_t; } else version (SPARC_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h - alias __WORDSIZE __ELF_NATIVE_CLASS; - alias uint32_t Elf_Symndx; + alias __ELF_NATIVE_CLASS = __WORDSIZE; + alias Elf_Symndx = uint32_t; } else version (IBMZ_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/s390/bits/elfclass.h - alias __WORDSIZE __ELF_NATIVE_CLASS; + alias __ELF_NATIVE_CLASS = __WORDSIZE; static if (__WORDSIZE == 64) - alias uint64_t Elf_Symndx; + alias Elf_Symndx = uint64_t; else - alias uint32_t Elf_Symndx; + alias Elf_Symndx = uint32_t; } else version (LoongArch64) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h - alias __WORDSIZE __ELF_NATIVE_CLASS; - alias uint32_t Elf_Symndx; + alias __ELF_NATIVE_CLASS = __WORDSIZE; + alias Elf_Symndx = uint32_t; } else static assert(0, "unimplemented"); @@ -102,7 +102,7 @@ else template ElfW(string type) { - mixin("alias Elf"~__ELF_NATIVE_CLASS.stringof~"_"~type~" ElfW;"); + mixin("alias ElfW = Elf"~__ELF_NATIVE_CLASS.stringof~"_"~type~";"); } enum @@ -182,8 +182,8 @@ struct dl_phdr_info void *dlpi_tls_data; } -private alias extern(C) int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb; -private alias extern(C) int function(dl_phdr_info*, size_t, void *) @nogc dl_iterate_phdr_cb_ngc; +private alias dl_iterate_phdr_cb = extern(C) int function(dl_phdr_info*, size_t, void *); +private alias dl_iterate_phdr_cb_ngc = extern(C) int function(dl_phdr_info*, size_t, void *) @nogc; extern int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data); extern int dl_iterate_phdr(dl_iterate_phdr_cb_ngc __callback, void*__data) @nogc; diff --git a/runtime/druntime/src/core/sys/linux/sched.d b/runtime/druntime/src/core/sys/linux/sched.d index 97a1478d76..155d41d312 100644 --- a/runtime/druntime/src/core/sys/linux/sched.d +++ b/runtime/druntime/src/core/sys/linux/sched.d @@ -93,7 +93,7 @@ private // helpers } /// Type for array elements in 'cpu_set_t'. -alias c_ulong cpu_mask; +alias cpu_mask = c_ulong; /// Data structure to describe CPU mask. struct cpu_set_t diff --git a/runtime/druntime/src/core/sys/linux/stdio.d b/runtime/druntime/src/core/sys/linux/stdio.d index 2d079fd71f..1d18429b03 100644 --- a/runtime/druntime/src/core/sys/linux/stdio.d +++ b/runtime/druntime/src/core/sys/linux/stdio.d @@ -16,10 +16,10 @@ import core.stdc.stddef : wchar_t; extern(C) nothrow { - alias ssize_t function(void *cookie, char *buf, size_t size) cookie_read_function_t; - alias ssize_t function(void *cookie, const(char) *buf, size_t size) cookie_write_function_t; - alias int function(void *cookie, off64_t *offset, int whence) cookie_seek_function_t; - alias int function(void *cookie) cookie_close_function_t; + alias cookie_read_function_t = ssize_t function(void *cookie, char *buf, size_t size); + alias cookie_write_function_t = ssize_t function(void *cookie, const(char) *buf, size_t size); + alias cookie_seek_function_t = int function(void *cookie, off64_t *offset, int whence); + alias cookie_close_function_t = int function(void *cookie); struct cookie_io_functions_t { diff --git a/runtime/druntime/src/core/sys/linux/sys/eventfd.d b/runtime/druntime/src/core/sys/linux/sys/eventfd.d index bb2d1371fa..42c81629e8 100644 --- a/runtime/druntime/src/core/sys/linux/sys/eventfd.d +++ b/runtime/druntime/src/core/sys/linux/sys/eventfd.d @@ -30,7 +30,7 @@ version (X86_64) version = X86_Any; import core.stdc.stdint: uint64_t; /// Type for the event counter -alias uint64_t eventfd_t; +alias eventfd_t = uint64_t; /* Return file descriptor for generic event channel. Set initial value to count. */ diff --git a/runtime/druntime/src/core/sys/netbsd/sys/elf32.d b/runtime/druntime/src/core/sys/netbsd/sys/elf32.d index 48386f6021..14046cdcef 100644 --- a/runtime/druntime/src/core/sys/netbsd/sys/elf32.d +++ b/runtime/druntime/src/core/sys/netbsd/sys/elf32.d @@ -13,10 +13,10 @@ nothrow: import core.stdc.stdint; public import core.sys.netbsd.sys.elf_common; -alias uint64_t Elf32_Lword; -alias Elf32_Word Elf32_Hashelt; -alias Elf32_Word Elf32_Size; -alias Elf32_Sword Elf32_Ssize; +alias Elf32_Lword = uint64_t; +alias Elf32_Hashelt = Elf32_Word; +alias Elf32_Size = Elf32_Word; +alias Elf32_Ssize = Elf32_Sword; struct Elf32_Dyn { @@ -28,7 +28,7 @@ struct Elf32_Dyn } _d_un d_un; } -alias Elf_Note Elf32_Nhdr; +alias Elf32_Nhdr = Elf_Note; struct Elf32_Cap { diff --git a/runtime/druntime/src/core/sys/netbsd/sys/elf64.d b/runtime/druntime/src/core/sys/netbsd/sys/elf64.d index 3eeaa90cf1..33e25327d9 100644 --- a/runtime/druntime/src/core/sys/netbsd/sys/elf64.d +++ b/runtime/druntime/src/core/sys/netbsd/sys/elf64.d @@ -13,10 +13,10 @@ nothrow: import core.stdc.stdint; public import core.sys.netbsd.sys.elf_common; -alias uint64_t Elf64_Lword; -alias Elf64_Word Elf64_Hashelt; -alias Elf64_Xword Elf64_Size; -alias Elf64_Sxword Elf64_Ssize; +alias Elf64_Lword = uint64_t; +alias Elf64_Hashelt = Elf64_Word; +alias Elf64_Size = Elf64_Xword; +alias Elf64_Ssize = Elf64_Sxword; struct Elf64_Dyn { @@ -35,7 +35,7 @@ extern (D) auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; } } -alias Elf_Note Elf64_Nhdr; +alias Elf64_Nhdr = Elf_Note; struct Elf64_Cap { diff --git a/runtime/druntime/src/core/sys/netbsd/sys/elf_common.d b/runtime/druntime/src/core/sys/netbsd/sys/elf_common.d index 6c911bdc6b..1c13f72bb6 100644 --- a/runtime/druntime/src/core/sys/netbsd/sys/elf_common.d +++ b/runtime/druntime/src/core/sys/netbsd/sys/elf_common.d @@ -82,11 +82,11 @@ enum STV_EXPORTED = 4; enum STV_SINGLETON = 5; enum STV_ELIMINATE = 6; -alias VER_NDX VER_DEF_IDX; +alias VER_DEF_IDX = VER_NDX; enum VER_NEED_WEAK = 32768; enum VER_NEED_HIDDEN = VER_NDX_HIDDEN; -alias VER_NDX VER_NEED_IDX; +alias VER_NEED_IDX = VER_NDX; enum VER_NDX_GIVEN = 2; enum VER_NDX_HIDDEN = 32768; diff --git a/runtime/druntime/src/core/sys/netbsd/sys/link_elf.d b/runtime/druntime/src/core/sys/netbsd/sys/link_elf.d index 4caec61adc..2740f789c3 100644 --- a/runtime/druntime/src/core/sys/netbsd/sys/link_elf.d +++ b/runtime/druntime/src/core/sys/netbsd/sys/link_elf.d @@ -36,7 +36,7 @@ struct link_map link_map* l_next; link_map* l_prev; } -alias link_map Link_map; +alias Link_map = link_map; enum { @@ -65,7 +65,7 @@ struct dl_phdr_info } -private alias extern(C) int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb; -private alias extern(C) int function(dl_phdr_info*, size_t, void *) @nogc dl_iterate_phdr_cb_ngc; +private alias dl_iterate_phdr_cb = extern(C) int function(dl_phdr_info*, size_t, void *); +private alias dl_iterate_phdr_cb_ngc = extern(C) int function(dl_phdr_info*, size_t, void *) @nogc; extern int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data); extern int dl_iterate_phdr(dl_iterate_phdr_cb_ngc __callback, void*__data) @nogc; diff --git a/runtime/druntime/src/core/sys/openbsd/sys/elf32.d b/runtime/druntime/src/core/sys/openbsd/sys/elf32.d index c56112186a..4f3c3336b2 100644 --- a/runtime/druntime/src/core/sys/openbsd/sys/elf32.d +++ b/runtime/druntime/src/core/sys/openbsd/sys/elf32.d @@ -14,10 +14,10 @@ nothrow: import core.stdc.stdint; public import core.sys.openbsd.sys.elf_common; -alias uint64_t Elf32_Lword; -alias Elf32_Word Elf32_Hashelt; -alias Elf32_Word Elf32_Size; -alias Elf32_Sword Elf32_Ssize; +alias Elf32_Lword = uint64_t; +alias Elf32_Hashelt = Elf32_Word; +alias Elf32_Size = Elf32_Word; +alias Elf32_Ssize = Elf32_Sword; struct Elf32_Dyn { @@ -29,7 +29,7 @@ struct Elf32_Dyn } _d_un d_un; } -alias Elf_Note Elf32_Nhdr; +alias Elf32_Nhdr = Elf_Note; struct Elf32_Cap { diff --git a/runtime/druntime/src/core/sys/openbsd/sys/elf64.d b/runtime/druntime/src/core/sys/openbsd/sys/elf64.d index 47f84d44da..c5acc72e22 100644 --- a/runtime/druntime/src/core/sys/openbsd/sys/elf64.d +++ b/runtime/druntime/src/core/sys/openbsd/sys/elf64.d @@ -14,10 +14,10 @@ nothrow: import core.stdc.stdint; public import core.sys.openbsd.sys.elf_common; -alias uint64_t Elf64_Lword; -alias Elf64_Word Elf64_Hashelt; -alias Elf64_Xword Elf64_Size; -alias Elf64_Sxword Elf64_Ssize; +alias Elf64_Lword = uint64_t; +alias Elf64_Hashelt = Elf64_Word; +alias Elf64_Size = Elf64_Xword; +alias Elf64_Ssize = Elf64_Sxword; struct Elf64_Dyn { @@ -36,7 +36,7 @@ extern (D) pure auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; } } -alias Elf_Note Elf64_Nhdr; +alias Elf64_Nhdr = Elf_Note; struct Elf64_Cap { diff --git a/runtime/druntime/src/core/sys/openbsd/sys/elf_common.d b/runtime/druntime/src/core/sys/openbsd/sys/elf_common.d index 4812e1f04d..b30d253ea0 100644 --- a/runtime/druntime/src/core/sys/openbsd/sys/elf_common.d +++ b/runtime/druntime/src/core/sys/openbsd/sys/elf_common.d @@ -61,7 +61,7 @@ enum DT_USED = 0x7ffffffe; enum DF_1_BIND_NOW = 0x00000001; -alias VER_NDX VER_DEF_IDX; +alias VER_DEF_IDX = VER_NDX; enum VER_FLG_INFO = 0x4; @@ -75,7 +75,7 @@ extern (D) pure @safe enum VER_NEED_WEAK = 32768; enum VER_NEED_HIDDEN = VER_NDX_HIDDEN; -alias VER_NDX VER_NEED_IDX; +alias VER_NEED_IDX = VER_NDX; enum VERSYM_HIDDEN = 0x8000; enum VERSYM_VERSION = 0x7fff; diff --git a/runtime/druntime/src/core/sys/openbsd/sys/link_elf.d b/runtime/druntime/src/core/sys/openbsd/sys/link_elf.d index 55fc79268e..581ff1b4c3 100644 --- a/runtime/druntime/src/core/sys/openbsd/sys/link_elf.d +++ b/runtime/druntime/src/core/sys/openbsd/sys/link_elf.d @@ -58,8 +58,8 @@ struct dl_phdr_info } -private alias int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb; -private alias int function(dl_phdr_info*, size_t, void *) @nogc dl_iterate_phdr_cb_ngc; +private alias dl_iterate_phdr_cb = int function(dl_phdr_info*, size_t, void *); +private alias dl_iterate_phdr_cb_ngc = int function(dl_phdr_info*, size_t, void *) @nogc; int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data); int dl_iterate_phdr(dl_iterate_phdr_cb_ngc __callback, void*__data) @nogc; diff --git a/runtime/druntime/src/core/sys/posix/arpa/inet.d b/runtime/druntime/src/core/sys/posix/arpa/inet.d index c602e17d32..33f31094e3 100644 --- a/runtime/druntime/src/core/sys/posix/arpa/inet.d +++ b/runtime/druntime/src/core/sys/posix/arpa/inet.d @@ -60,8 +60,8 @@ int inet_pton(int, const scope char*, void*); version (CRuntime_Glibc) { - alias uint16_t in_port_t; - alias uint32_t in_addr_t; + alias in_port_t = uint16_t; + alias in_addr_t = uint32_t; struct in_addr { @@ -83,8 +83,8 @@ version (CRuntime_Glibc) } else version (Darwin) { - alias uint16_t in_port_t; - alias uint32_t in_addr_t; + alias in_port_t = uint16_t; + alias in_addr_t = uint32_t; struct in_addr { @@ -106,8 +106,8 @@ else version (Darwin) } else version (FreeBSD) { - alias uint16_t in_port_t; - alias uint32_t in_addr_t; + alias in_port_t = uint16_t; + alias in_addr_t = uint32_t; struct in_addr { @@ -129,8 +129,8 @@ else version (FreeBSD) } else version (NetBSD) { - alias uint16_t in_port_t; - alias uint32_t in_addr_t; + alias in_port_t = uint16_t; + alias in_addr_t = uint32_t; struct in_addr { @@ -152,8 +152,8 @@ else version (NetBSD) } else version (OpenBSD) { - alias uint16_t in_port_t; - alias uint32_t in_addr_t; + alias in_port_t = uint16_t; + alias in_addr_t = uint32_t; struct in_addr { @@ -185,8 +185,8 @@ else version (OpenBSD) } else version (DragonFlyBSD) { - alias uint16_t in_port_t; - alias uint32_t in_addr_t; + alias in_port_t = uint16_t; + alias in_addr_t = uint32_t; struct in_addr { @@ -208,8 +208,8 @@ else version (DragonFlyBSD) } else version (Solaris) { - alias uint16_t in_port_t; - alias uint32_t in_addr_t; + alias in_port_t = uint16_t; + alias in_addr_t = uint32_t; struct in_addr { @@ -231,7 +231,7 @@ else version (Solaris) } else version (CRuntime_Bionic) { - alias uint32_t in_addr_t; + alias in_addr_t = uint32_t; struct in_addr { @@ -263,8 +263,8 @@ else version (CRuntime_Bionic) } else version (CRuntime_Musl) { - alias uint16_t in_port_t; - alias uint32_t in_addr_t; + alias in_port_t = uint16_t; + alias in_addr_t = uint32_t; struct in_addr { @@ -286,8 +286,8 @@ else version (CRuntime_Musl) } else version (CRuntime_UClibc) { - alias uint16_t in_port_t; - alias uint32_t in_addr_t; + alias in_port_t = uint16_t; + alias in_addr_t = uint32_t; struct in_addr { diff --git a/runtime/druntime/src/core/sys/posix/dirent.d b/runtime/druntime/src/core/sys/posix/dirent.d index 0e822f556c..18cee4c43c 100644 --- a/runtime/druntime/src/core/sys/posix/dirent.d +++ b/runtime/druntime/src/core/sys/posix/dirent.d @@ -197,7 +197,7 @@ version (CRuntime_Glibc) static if ( __USE_FILE_OFFSET64 ) { dirent* readdir64(DIR*); - alias readdir64 readdir; + alias readdir = readdir64; } else { @@ -256,7 +256,7 @@ else version (FreeBSD) DT_WHT = 14 } - alias void* DIR; + alias DIR = void*; version (GNU) { @@ -285,10 +285,10 @@ else version (NetBSD) DT_WHT = 14 } - alias void* DIR; + alias DIR = void*; dirent* __readdir30(DIR*); - alias __readdir30 readdir; + alias readdir = __readdir30; } else version (OpenBSD) { @@ -304,7 +304,7 @@ else version (OpenBSD) DT_SOCK = 12, } - alias void* DIR; + alias DIR = void*; dirent* readdir(DIR*); } @@ -324,7 +324,7 @@ else version (DragonFlyBSD) DT_DBF = 15, /* database record file */ } - alias void* DIR; + alias DIR = void*; dirent* readdir(DIR*); } @@ -348,7 +348,7 @@ else version (Solaris) static if (__USE_LARGEFILE64) { dirent* readdir64(DIR*); - alias readdir64 readdir; + alias readdir = readdir64; } else { @@ -429,7 +429,7 @@ else version (CRuntime_UClibc) static if ( __USE_FILE_OFFSET64 ) { dirent* readdir64(DIR*); - alias readdir64 readdir; + alias readdir = readdir64; } else { @@ -471,7 +471,7 @@ else version (NetBSD) { int closedir(DIR*); DIR* __opendir30(const scope char*); - alias __opendir30 opendir; + alias opendir = __opendir30; void rewinddir(DIR*); } else @@ -494,7 +494,7 @@ version (CRuntime_Glibc) static if ( __USE_LARGEFILE64 ) { int readdir64_r(DIR*, dirent*, dirent**); - alias readdir64_r readdir_r; + alias readdir_r = readdir64_r; } else { @@ -529,7 +529,7 @@ else version (DragonFlyBSD) else version (NetBSD) { int __readdir_r30(DIR*, dirent*, dirent**); - alias __readdir_r30 readdir_r; + alias readdir_r = __readdir_r30; } else version (OpenBSD) { @@ -540,7 +540,7 @@ else version (Solaris) static if (__USE_LARGEFILE64) { int readdir64_r(DIR*, dirent*, dirent**); - alias readdir64_r readdir_r; + alias readdir_r = readdir64_r; } else { @@ -560,7 +560,7 @@ else version (CRuntime_UClibc) static if ( __USE_LARGEFILE64 ) { int readdir64_r(DIR*, dirent*, dirent**); - alias readdir64_r readdir_r; + alias readdir_r = readdir64_r; } else { diff --git a/runtime/druntime/src/core/sys/posix/fcntl.d b/runtime/druntime/src/core/sys/posix/fcntl.d index 4f7a22592d..f64e234ced 100644 --- a/runtime/druntime/src/core/sys/posix/fcntl.d +++ b/runtime/druntime/src/core/sys/posix/fcntl.d @@ -886,13 +886,13 @@ version (CRuntime_Glibc) static if ( __USE_FILE_OFFSET64 ) { int creat64(const scope char*, mode_t); - alias creat64 creat; + alias creat = creat64; int open64(const scope char*, int, ...); - alias open64 open; + alias open = open64; int openat64(int, const scope char*, int, ...); - alias openat64 openat; + alias openat = openat64; } else { @@ -941,9 +941,9 @@ else version (Solaris) static if (__USE_LARGEFILE64) { - alias creat creat64; - alias open open64; - alias openat openat64; + alias creat64 = creat; + alias open64 = open; + alias openat64 = openat; } } else @@ -951,13 +951,13 @@ else version (Solaris) static if (__USE_LARGEFILE64) { int creat64(const scope char*, mode_t); - alias creat64 creat; + alias creat = creat64; int open64(const scope char*, int, ...); - alias open64 open; + alias open = open64; int openat64(int, const scope char*, int, ...); - alias openat64 openat; + alias openat = openat64; } else { @@ -984,13 +984,13 @@ else version (CRuntime_UClibc) static if ( __USE_FILE_OFFSET64 ) { int creat64(const scope char*, mode_t); - alias creat64 creat; + alias creat = creat64; int open64(const scope char*, int, ...); - alias open64 open; + alias open = open64; int openat64(int, const scope char*, int, ...); - alias openat64 openat; + alias openat = openat64; } else { diff --git a/runtime/druntime/src/core/sys/posix/iconv.d b/runtime/druntime/src/core/sys/posix/iconv.d index e588fb8210..f160b8bf03 100644 --- a/runtime/druntime/src/core/sys/posix/iconv.d +++ b/runtime/druntime/src/core/sys/posix/iconv.d @@ -36,7 +36,7 @@ nothrow: @nogc: -alias void* iconv_t; +alias iconv_t = void*; /// Allocate descriptor for code conversion from codeset FROMCODE to /// codeset TOCODE. diff --git a/runtime/druntime/src/core/sys/posix/mqueue.d b/runtime/druntime/src/core/sys/posix/mqueue.d index f8b4b15094..a272f85b31 100644 --- a/runtime/druntime/src/core/sys/posix/mqueue.d +++ b/runtime/druntime/src/core/sys/posix/mqueue.d @@ -34,7 +34,7 @@ extern (C): version (CRuntime_Glibc) { /// Message queue descriptor. - alias int mqd_t; + alias mqd_t = int; /** * Used in getting and setting the attributes of a message queue. diff --git a/runtime/druntime/src/core/sys/posix/poll.d b/runtime/druntime/src/core/sys/posix/poll.d index 5901f62b5c..4a320d158d 100644 --- a/runtime/druntime/src/core/sys/posix/poll.d +++ b/runtime/druntime/src/core/sys/posix/poll.d @@ -55,7 +55,7 @@ version (CRuntime_Glibc) short revents; } - alias c_ulong nfds_t; + alias nfds_t = c_ulong; int poll(pollfd*, nfds_t, int); } @@ -68,13 +68,13 @@ else version (Darwin) short revents; } - alias uint nfds_t; + alias nfds_t = uint; int poll(pollfd*, nfds_t, int); } else version (FreeBSD) { - alias uint nfds_t; + alias nfds_t = uint; struct pollfd { @@ -87,7 +87,7 @@ else version (FreeBSD) } else version (NetBSD) { - alias uint nfds_t; + alias nfds_t = uint; struct pollfd { @@ -100,7 +100,7 @@ else version (NetBSD) } else version (OpenBSD) { - alias uint nfds_t; + alias nfds_t = uint; struct pollfd { @@ -113,7 +113,7 @@ else version (OpenBSD) } else version (DragonFlyBSD) { - alias uint nfds_t; + alias nfds_t = uint; struct pollfd { @@ -126,7 +126,7 @@ else version (DragonFlyBSD) } else version (Solaris) { - alias c_ulong nfds_t; + alias nfds_t = c_ulong; struct pollfd { @@ -146,7 +146,7 @@ else version (CRuntime_Bionic) short revents; } - alias uint nfds_t; + alias nfds_t = uint; int poll(pollfd*, nfds_t, c_long); } @@ -159,7 +159,7 @@ else version (CRuntime_Musl) short revents; } - alias uint nfds_t; + alias nfds_t = uint; int poll(pollfd*, nfds_t, c_long); } @@ -172,7 +172,7 @@ else version (CRuntime_UClibc) short revents; } - alias c_ulong nfds_t; + alias nfds_t = c_ulong; int poll(pollfd*, nfds_t, int); } diff --git a/runtime/druntime/src/core/sys/posix/pthread.d b/runtime/druntime/src/core/sys/posix/pthread.d index 86844f9c5c..33c442df08 100644 --- a/runtime/druntime/src/core/sys/posix/pthread.d +++ b/runtime/druntime/src/core/sys/posix/pthread.d @@ -473,8 +473,8 @@ int pthread_atfork(void function(), void function(), void function()); int pthread_cancel(pthread_t); } -alias void function(void*) _pthread_cleanup_routine; -alias void function(void*) @nogc _pthread_cleanup_routine_nogc; +alias _pthread_cleanup_routine = void function(void*); +alias _pthread_cleanup_routine_nogc = void function(void*) @nogc; version (CRuntime_Glibc) { struct _pthread_cleanup_buffer diff --git a/runtime/druntime/src/core/sys/posix/pwd.d b/runtime/druntime/src/core/sys/posix/pwd.d index e2a77dec3c..d4b4a07673 100644 --- a/runtime/druntime/src/core/sys/posix/pwd.d +++ b/runtime/druntime/src/core/sys/posix/pwd.d @@ -230,9 +230,9 @@ else version (FreeBSD) else version (NetBSD) { int __getpwnam_r50(const scope char*, passwd*, char*, size_t, passwd**); - alias __getpwnam_r50 getpwnam_r; + alias getpwnam_r = __getpwnam_r50; int __getpwuid_r50(uid_t, passwd*, char*, size_t, passwd**); - alias __getpwuid_r50 getpwuid_r; + alias getpwuid_r = __getpwuid_r50; } else version (OpenBSD) { diff --git a/runtime/druntime/src/core/sys/posix/semaphore.d b/runtime/druntime/src/core/sys/posix/semaphore.d index 4f3b6e951c..dc9c14fd96 100644 --- a/runtime/druntime/src/core/sys/posix/semaphore.d +++ b/runtime/druntime/src/core/sys/posix/semaphore.d @@ -51,7 +51,7 @@ int sem_wait(sem_t*); version (CRuntime_Glibc) { - private alias int __atomic_lock_t; + private alias __atomic_lock_t = int; private struct _pthread_fastlock { @@ -70,7 +70,7 @@ version (CRuntime_Glibc) } else version (Darwin) { - alias int sem_t; + alias sem_t = int; enum SEM_FAILED = cast(sem_t*) null; } @@ -92,7 +92,7 @@ else version (FreeBSD) } else version (NetBSD) { - alias size_t sem_t; + alias sem_t = size_t; enum SEM_FAILED = cast(sem_t*) null; } diff --git a/runtime/druntime/src/core/sys/posix/setjmp.d b/runtime/druntime/src/core/sys/posix/setjmp.d index cd378ce03a..24497a27ae 100644 --- a/runtime/druntime/src/core/sys/posix/setjmp.d +++ b/runtime/druntime/src/core/sys/posix/setjmp.d @@ -49,7 +49,7 @@ version (CRuntime_Glibc) //enum JB_PC = 7; //enum JB_SIZE = 64; - alias long[8] __jmp_buf; + alias __jmp_buf = long[8]; } else version (X86) { @@ -61,11 +61,11 @@ version (CRuntime_Glibc) //enum JB_PC = 5; //enum JB_SIZE = 24; - alias int[6] __jmp_buf; + alias __jmp_buf = int[6]; } else version (SPARC) { - alias int[3] __jmp_buf; + alias __jmp_buf = int[3]; } else version (SPARC64) { @@ -73,11 +73,11 @@ version (CRuntime_Glibc) } else version (AArch64) { - alias long[22] __jmp_buf; + alias __jmp_buf = long[22]; } else version (ARM) { - alias int[64] __jmp_buf; + alias __jmp_buf = int[64]; } else version (HPPA) { @@ -95,11 +95,11 @@ version (CRuntime_Glibc) } else version (PPC) { - alias int[64 + (12*4)] __jmp_buf; + alias __jmp_buf = int[64 + (12*4)]; } else version (PPC64) { - alias long[64] __jmp_buf; + alias __jmp_buf = long[64]; } else version (MIPS32) { @@ -199,9 +199,9 @@ version (CRuntime_Glibc) sigset_t __saved_mask; } - alias __jmp_buf_tag[1] jmp_buf; + alias jmp_buf = __jmp_buf_tag[1]; - alias _setjmp setjmp; // see XOpen block + alias setjmp = _setjmp; // see XOpen block void longjmp(ref jmp_buf, int); } else version (FreeBSD) @@ -235,7 +235,7 @@ else version (FreeBSD) } else static assert(0); - alias _jmp_buf[1] jmp_buf; + alias jmp_buf = _jmp_buf[1]; int setjmp(ref jmp_buf); void longjmp(ref jmp_buf, int); @@ -255,7 +255,7 @@ else version (NetBSD) } else static assert(0); - alias _jmp_buf[_JBLEN] jmp_buf; + alias jmp_buf = _jmp_buf[_JBLEN]; int setjmp(ref jmp_buf); void longjmp(ref jmp_buf, int); @@ -313,7 +313,7 @@ else version (DragonFlyBSD) } else static assert(0); - alias _jmp_buf[1] jmp_buf; + alias jmp_buf = _jmp_buf[1]; int setjmp(ref jmp_buf); void longjmp(ref jmp_buf, int); @@ -342,7 +342,7 @@ else version (CRuntime_Bionic) static assert(false, "Architecture not supported."); } - alias c_long[_JBLEN] jmp_buf; + alias jmp_buf = c_long[_JBLEN]; int setjmp(ref jmp_buf); void longjmp(ref jmp_buf, int); @@ -351,11 +351,11 @@ else version (CRuntime_UClibc) { version (X86_64) { - alias long[8] __jmp_buf; + alias __jmp_buf = long[8]; } else version (ARM) { - align(8) alias int[64] __jmp_buf; + align(8) alias __jmp_buf = int[64]; } else version (MIPS32) { @@ -410,9 +410,9 @@ else version (CRuntime_UClibc) sigset_t __saved_mask; } - alias __jmp_buf_tag[1] jmp_buf; + alias jmp_buf = __jmp_buf_tag[1]; - alias _setjmp setjmp; + alias setjmp = _setjmp; void longjmp(ref jmp_buf, int); } @@ -428,10 +428,10 @@ void siglongjmp(sigjmp_buf, int); version (CRuntime_Glibc) { - alias jmp_buf sigjmp_buf; + alias sigjmp_buf = jmp_buf; int __sigsetjmp(sigjmp_buf, int); - alias __sigsetjmp sigsetjmp; + alias sigsetjmp = __sigsetjmp; void siglongjmp(sigjmp_buf, int); } else version (FreeBSD) @@ -466,7 +466,7 @@ else version (FreeBSD) } else static assert(0); - alias _sigjmp_buf[1] sigjmp_buf; + alias sigjmp_buf = _sigjmp_buf[1]; int sigsetjmp(ref sigjmp_buf); void siglongjmp(ref sigjmp_buf, int); @@ -484,7 +484,7 @@ else version (NetBSD) } else static assert(0); - alias _sigjmp_buf[_JBLEN + 1] sigjmp_buf; + alias sigjmp_buf = _sigjmp_buf[_JBLEN + 1]; int sigsetjmp(ref sigjmp_buf); void siglongjmp(ref sigjmp_buf, int); @@ -505,24 +505,24 @@ else version (DragonFlyBSD) } else static assert(0); - alias _sigjmp_buf[1] sigjmp_buf; + alias sigjmp_buf = _sigjmp_buf[1]; int sigsetjmp(ref sigjmp_buf); void siglongjmp(ref sigjmp_buf, int); } else version (CRuntime_Bionic) { - alias c_long[_JBLEN + 1] sigjmp_buf; + alias sigjmp_buf = c_long[_JBLEN + 1]; int sigsetjmp(ref sigjmp_buf, int); void siglongjmp(ref sigjmp_buf, int); } else version (CRuntime_UClibc) { - alias jmp_buf sigjmp_buf; + alias sigjmp_buf = jmp_buf; int __sigsetjmp(ref sigjmp_buf, int); - alias __sigsetjmp sigsetjmp; + alias sigsetjmp = __sigsetjmp; void siglongjmp(ref sigjmp_buf, int); } diff --git a/runtime/druntime/src/core/sys/posix/signal.d b/runtime/druntime/src/core/sys/posix/signal.d index bdc68687d0..aed6ca7bca 100644 --- a/runtime/druntime/src/core/sys/posix/signal.d +++ b/runtime/druntime/src/core/sys/posix/signal.d @@ -108,14 +108,14 @@ int raise(int sig); (defined in core.stdc.signal) //sig_atomic_t (defined in core.stdc.signal) -private alias void function(int) sigfn_t; -private alias void function(int, siginfo_t*, void*) sigactfn_t; +private alias sigfn_t = void function(int); +private alias sigactfn_t = void function(int, siginfo_t*, void*); // nothrow versions nothrow @nogc { - private alias void function(int) sigfn_t2; - private alias void function(int, siginfo_t*, void*) sigactfn_t2; + private alias sigfn_t2 = void function(int); + private alias sigactfn_t2 = void function(int, siginfo_t*, void*); } enum @@ -1037,7 +1037,7 @@ else version (Darwin) { enum SIG_HOLD = cast(sigfn_t2) 5; - alias uint sigset_t; + alias sigset_t = uint; enum SA_NOCLDSTOP = 8; // (CX|XSI) @@ -1492,15 +1492,15 @@ else version (NetBSD) int __sigsuspend14(const scope sigset_t*); int sigwait(const scope sigset_t*, int*); - alias __sigaction14 sigaction; - alias __sigaddset14 sigaddset; - alias __sigdelset14 sigdelset; - alias __sigemptyset14 sigemptyset; - alias __sigfillset14 sigfillset; - alias __sigismember14 sigismember; - alias __sigpending14 sigpending; - alias __sigprocmask14 sigprocmask; - alias __sigsuspend14 sigsuspend; + alias sigaction = __sigaction14; + alias sigaddset = __sigaddset14; + alias sigdelset = __sigdelset14; + alias sigemptyset = __sigemptyset14; + alias sigfillset = __sigfillset14; + alias sigismember = __sigismember14; + alias sigpending = __sigpending14; + alias sigprocmask = __sigprocmask14; + alias sigsuspend = __sigsuspend14; } else version (OpenBSD) { diff --git a/runtime/druntime/src/core/sys/posix/stdio.d b/runtime/druntime/src/core/sys/posix/stdio.d index e3de3e283c..eceef7f5d4 100644 --- a/runtime/druntime/src/core/sys/posix/stdio.d +++ b/runtime/druntime/src/core/sys/posix/stdio.d @@ -115,21 +115,21 @@ version (CRuntime_Glibc) static if ( __USE_FILE_OFFSET64 ) { int fgetpos64(FILE*, fpos_t *); - alias fgetpos64 fgetpos; + alias fgetpos = fgetpos64; FILE* fopen64(const scope char*, const scope char*); - alias fopen64 fopen; + alias fopen = fopen64; FILE* freopen64(const scope char*, const scope char*, FILE*); - alias freopen64 freopen; + alias freopen = freopen64; int fseek(FILE*, c_long, int); int fsetpos64(FILE*, const scope fpos_t*); - alias fsetpos64 fsetpos; + alias fsetpos = fsetpos64; FILE* tmpfile64(); - alias tmpfile64 tmpfile; + alias tmpfile = tmpfile64; } else { @@ -154,21 +154,21 @@ else version (CRuntime_UClibc) static if ( __USE_FILE_OFFSET64 ) { int fgetpos64(FILE*, fpos_t *); - alias fgetpos64 fgetpos; + alias fgetpos = fgetpos64; FILE* fopen64(const scope char*, const scope char*); - alias fopen64 fopen; + alias fopen = fopen64; FILE* freopen64(const scope char*, const scope char*, FILE*); - alias freopen64 freopen; + alias freopen = freopen64; int fseek(FILE*, c_long, int); int fsetpos64(FILE*, const scope fpos_t*); - alias fsetpos64 fsetpos; + alias fsetpos = fsetpos64; FILE* tmpfile64(); - alias tmpfile64 tmpfile; + alias tmpfile = tmpfile64; } else { @@ -256,7 +256,7 @@ version (CRuntime_Glibc) static if ( __USE_FILE_OFFSET64 ) { int fseeko64(FILE*, off_t, int); - alias fseeko64 fseeko; + alias fseeko = fseeko64; } else { @@ -266,7 +266,7 @@ version (CRuntime_Glibc) static if ( __USE_FILE_OFFSET64 ) { off_t ftello64(FILE*); - alias ftello64 ftello; + alias ftello = ftello64; } else { @@ -285,7 +285,7 @@ else version (CRuntime_UClibc) static if ( __USE_FILE_OFFSET64 ) { int fseeko64(FILE*, off_t, int); - alias fseeko64 fseeko; + alias fseeko = fseeko64; } else { @@ -295,7 +295,7 @@ else version (CRuntime_UClibc) static if ( __USE_FILE_OFFSET64 ) { off_t ftello64(FILE*); - alias ftello64 ftello; + alias ftello = ftello64; } else { @@ -330,7 +330,7 @@ else version (CRuntime_Bionic) static if ( __USE_FILE_OFFSET64 ) { int fseeko64(FILE*, off_t, int); - alias fseeko64 fseeko; + alias fseeko = fseeko64; } else { @@ -340,7 +340,7 @@ else version (CRuntime_Bionic) static if ( __USE_FILE_OFFSET64 ) { off_t ftello64(FILE*); - alias ftello64 ftello; + alias ftello = ftello64; } else { diff --git a/runtime/druntime/src/core/sys/posix/stdlib.d b/runtime/druntime/src/core/sys/posix/stdlib.d index ea7048ec38..8e8c16fab5 100644 --- a/runtime/druntime/src/core/sys/posix/stdlib.d +++ b/runtime/druntime/src/core/sys/posix/stdlib.d @@ -167,7 +167,7 @@ else version (NetBSD) { int setenv(const scope char*, const scope char*, int); int __unsetenv13(const scope char*); - alias __unsetenv13 unsetenv; + alias unsetenv = __unsetenv13; void* valloc(size_t); // LEGACY non-standard } else version (OpenBSD) @@ -339,7 +339,7 @@ version (CRuntime_Glibc) static if ( __USE_LARGEFILE64 ) { int mkstemp64(char*); - alias mkstemp64 mkstemp; + alias mkstemp = mkstemp64; } else { @@ -656,14 +656,14 @@ else version (Solaris) int mkstemp(char*); static if ( __USE_LARGEFILE64 ) - alias mkstemp mkstemp64; + alias mkstemp64 = mkstemp; } else { int mkstemp64(char*); static if ( __USE_LARGEFILE64 ) - alias mkstemp64 mkstemp; + alias mkstemp = mkstemp64; else int mkstemp(char*); } @@ -702,7 +702,7 @@ else version (CRuntime_UClibc) static if ( __USE_LARGEFILE64 ) { int mkstemp64(char*); - alias mkstemp64 mkstemp; + alias mkstemp = mkstemp64; } else { diff --git a/runtime/druntime/src/core/sys/posix/sys/resource.d b/runtime/druntime/src/core/sys/posix/sys/resource.d index b75c794e92..3da8411d6a 100644 --- a/runtime/druntime/src/core/sys/posix/sys/resource.d +++ b/runtime/druntime/src/core/sys/posix/sys/resource.d @@ -82,9 +82,9 @@ version (linux) } static if (__USE_FILE_OFFSET64) - alias ulong rlim_t; + alias rlim_t = ulong; else - alias c_ulong rlim_t; + alias rlim_t = c_ulong; static if (__USE_FILE_OFFSET64) enum RLIM_INFINITY = 0xffffffffffffffffUL; @@ -159,7 +159,7 @@ else version (Darwin) PRIO_USER = 2, } - alias ulong rlim_t; + alias rlim_t = ulong; enum { @@ -201,7 +201,7 @@ else version (FreeBSD) PRIO_USER = 2, } - alias long rlim_t; + alias rlim_t = long; enum { @@ -221,7 +221,7 @@ else version (FreeBSD) timeval ru_utime; timeval ru_stime; c_long ru_maxrss; - alias ru_ixrss ru_first; + alias ru_first = ru_ixrss; c_long ru_ixrss; c_long ru_idrss; c_long ru_isrss; @@ -235,7 +235,7 @@ else version (FreeBSD) c_long ru_nsignals; c_long ru_nvcsw; c_long ru_nivcsw; - alias ru_nivcsw ru_last; + alias ru_last = ru_nivcsw; } enum @@ -258,7 +258,7 @@ else version (NetBSD) PRIO_USER = 2, } - alias long rlim_t; + alias rlim_t = long; enum { @@ -278,7 +278,7 @@ else version (NetBSD) timeval ru_utime; timeval ru_stime; c_long ru_maxrss; - alias ru_ixrss ru_first; + alias ru_first = ru_ixrss; c_long ru_ixrss; c_long ru_idrss; c_long ru_isrss; @@ -292,7 +292,7 @@ else version (NetBSD) c_long ru_nsignals; c_long ru_nvcsw; c_long ru_nivcsw; - alias ru_nivcsw ru_last; + alias ru_last = ru_nivcsw; } enum @@ -315,7 +315,7 @@ else version (OpenBSD) PRIO_USER = 2, } - alias ulong rlim_t; + alias rlim_t = ulong; enum { @@ -336,7 +336,7 @@ else version (OpenBSD) timeval ru_utime; timeval ru_stime; c_long ru_maxrss; - alias ru_ixrss ru_first; + alias ru_first = ru_ixrss; c_long ru_ixrss; c_long ru_idrss; c_long ru_isrss; @@ -350,7 +350,7 @@ else version (OpenBSD) c_long ru_nsignals; c_long ru_nvcsw; c_long ru_nivcsw; - alias ru_nivcsw ru_last; + alias ru_last = ru_nivcsw; } enum @@ -374,7 +374,7 @@ else version (DragonFlyBSD) PRIO_USER = 2, } - alias long rlim_t; + alias rlim_t = long; enum { @@ -394,7 +394,7 @@ else version (DragonFlyBSD) timeval ru_utime; timeval ru_stime; c_long ru_maxrss; - alias ru_ixrss ru_first; + alias ru_first = ru_ixrss; c_long ru_ixrss; c_long ru_idrss; c_long ru_isrss; @@ -408,7 +408,7 @@ else version (DragonFlyBSD) c_long ru_nsignals; c_long ru_nvcsw; c_long ru_nivcsw; - alias ru_nivcsw ru_last; + alias ru_last = ru_nivcsw; } enum @@ -431,7 +431,7 @@ else version (Solaris) PRIO_USER = 2, } - alias c_ulong rlim_t; + alias rlim_t = c_ulong; enum : c_long { @@ -564,8 +564,8 @@ else version (CRuntime_Musl) int setpriority(int, id_t, int); int getrlimit(int, rlimit*); int setrlimit(int, const scope rlimit*); - alias getrlimit getrlimit64; - alias setrlimit setrlimit64; + alias getrlimit64 = getrlimit; + alias setrlimit64 = setrlimit; pragma(mangle, muslRedirTime64Mangle!("getrusage", "__getrusage_time64")) int getrusage(int, rusage*); } diff --git a/runtime/druntime/src/core/sys/posix/sys/select.d b/runtime/druntime/src/core/sys/posix/sys/select.d index c8a88bddc0..064dfbcc5f 100644 --- a/runtime/druntime/src/core/sys/posix/sys/select.d +++ b/runtime/druntime/src/core/sys/posix/sys/select.d @@ -54,7 +54,7 @@ version (CRuntime_Glibc) { private { - alias c_long __fd_mask; + alias __fd_mask = c_long; enum uint __NFDBITS = 8 * __fd_mask.sizeof; extern (D) auto __FDELT()( int d ) pure @@ -175,7 +175,7 @@ else version (FreeBSD) { private { - alias c_ulong __fd_mask; + alias __fd_mask = c_ulong; enum _NFDBITS = __fd_mask.sizeof * 8; } @@ -225,7 +225,7 @@ else version (NetBSD) { private { - alias c_ulong __fd_mask; + alias __fd_mask = c_ulong; enum _NFDBITS = __fd_mask.sizeof * 8; } @@ -275,7 +275,7 @@ else version (OpenBSD) { private { - alias uint __fd_mask; + alias __fd_mask = uint; enum _NFDBITS = __fd_mask.sizeof * 8; } @@ -323,7 +323,7 @@ else version (DragonFlyBSD) { private { - alias c_ulong __fd_mask; + alias __fd_mask = c_ulong; enum _NFDBITS = __fd_mask.sizeof * 8; } @@ -373,7 +373,7 @@ else version (Solaris) { private { - alias c_long fds_mask; + alias fds_mask = c_long; enum _NBBY = 8; enum FD_NFDBITS = fds_mask.sizeof * _NBBY; @@ -416,7 +416,7 @@ else version (CRuntime_Bionic) { private { - alias c_ulong __fd_mask; + alias __fd_mask = c_ulong; enum uint __NFDBITS = 8 * __fd_mask.sizeof; extern (D) auto __FDELT()( int d ) pure @@ -465,7 +465,7 @@ else version (CRuntime_Musl) { enum FD_SETSIZE = 1024; - alias ulong fd_mask; + alias fd_mask = ulong; private { @@ -514,7 +514,7 @@ else version (CRuntime_UClibc) { private { - alias c_long __fd_mask; + alias __fd_mask = c_long; enum uint __NFDBITS = 8 * __fd_mask.sizeof; extern (D) auto __FDELT()( int d ) pure diff --git a/runtime/druntime/src/core/sys/posix/sys/shm.d b/runtime/druntime/src/core/sys/posix/sys/shm.d index 7481d8cc60..927778dd2a 100644 --- a/runtime/druntime/src/core/sys/posix/sys/shm.d +++ b/runtime/druntime/src/core/sys/posix/sys/shm.d @@ -58,7 +58,7 @@ version (linux) enum SHM_RND = 0x02000; // 020000 enum SHM_REMAP = 0x4000; // 040000 - alias c_ulong shmatt_t; + alias shmatt_t = c_ulong; /* For any changes, please check /usr/include/bits/shm.h */ struct shmid_ds @@ -83,7 +83,7 @@ else version (FreeBSD) enum SHM_RDONLY = 0x01000; // 010000 enum SHM_RND = 0x02000; // 020000 - alias c_ulong shmatt_t; + alias shmatt_t = c_ulong; struct shmid_ds_old // <= FreeBSD7 { @@ -115,7 +115,7 @@ else version (NetBSD) enum SHM_RDONLY = 0x01000; // 010000 enum SHM_RND = 0x02000; // 020000 - alias c_ulong shmatt_t; + alias shmatt_t = c_ulong; struct shmid_ds { @@ -135,7 +135,7 @@ else version (OpenBSD) enum SHM_RDONLY = 0x01000; // 010000 enum SHM_RND = 0x02000; // 020000 - alias short shmatt_t; + alias shmatt_t = short; struct shmid_ds { @@ -158,7 +158,7 @@ else version (DragonFlyBSD) enum SHM_RDONLY = 0x01000; // 010000 enum SHM_RND = 0x02000; // 020000 - alias c_ulong shmatt_t; + alias shmatt_t = c_ulong; struct shmid_ds { @@ -198,7 +198,7 @@ int shmget(key_t, size_t, int); version (CRuntime_Glibc) { int __getpagesize(); - alias __getpagesize SHMLBA; + alias SHMLBA = __getpagesize; void* shmat(int, const scope void*, int); int shmctl(int, int, shmid_ds*); @@ -273,7 +273,7 @@ else version (CRuntime_Bionic) else version (CRuntime_UClibc) { int __getpagesize(); - alias __getpagesize SHMLBA; + alias SHMLBA = __getpagesize; void* shmat(int, const scope void*, int); int shmctl(int, int, shmid_ds*); diff --git a/runtime/druntime/src/core/sys/posix/sys/socket.d b/runtime/druntime/src/core/sys/posix/sys/socket.d index 5bdc22294c..35f316bd93 100644 --- a/runtime/druntime/src/core/sys/posix/sys/socket.d +++ b/runtime/druntime/src/core/sys/posix/sys/socket.d @@ -141,8 +141,8 @@ SHUT_WR version (linux) { - alias uint socklen_t; - alias ushort sa_family_t; + alias socklen_t = uint; + alias sa_family_t = ushort; struct sockaddr { @@ -622,8 +622,8 @@ version (linux) } else version (Darwin) { - alias uint socklen_t; - alias ubyte sa_family_t; + alias socklen_t = uint; + alias sa_family_t = ubyte; struct sockaddr { @@ -762,8 +762,8 @@ else version (Darwin) } else version (FreeBSD) { - alias uint socklen_t; - alias ubyte sa_family_t; + alias socklen_t = uint; + alias sa_family_t = ubyte; struct sockaddr { @@ -920,8 +920,8 @@ else version (FreeBSD) } else version (NetBSD) { - alias uint socklen_t; - alias ubyte sa_family_t; + alias socklen_t = uint; + alias sa_family_t = ubyte; struct sockaddr { @@ -1098,8 +1098,8 @@ else version (NetBSD) } else version (OpenBSD) { - alias uint socklen_t; - alias ubyte sa_family_t; + alias socklen_t = uint; + alias sa_family_t = ubyte; struct sockaddr { @@ -1270,8 +1270,8 @@ else version (OpenBSD) } else version (DragonFlyBSD) { - alias uint socklen_t; - alias ubyte sa_family_t; + alias socklen_t = uint; + alias sa_family_t = ubyte; enum { @@ -1470,8 +1470,8 @@ else version (DragonFlyBSD) } else version (Solaris) { - alias uint socklen_t; - alias ushort sa_family_t; + alias socklen_t = uint; + alias sa_family_t = ushort; struct sockaddr { @@ -1479,7 +1479,7 @@ else version (Solaris) char[14] sa_data = 0; } - alias double sockaddr_maxalign_t; + alias sockaddr_maxalign_t = double; private { diff --git a/runtime/druntime/src/core/sys/posix/sys/stat.d b/runtime/druntime/src/core/sys/posix/sys/stat.d index 7493b64486..ad59019e18 100644 --- a/runtime/druntime/src/core/sys/posix/sys/stat.d +++ b/runtime/druntime/src/core/sys/posix/sys/stat.d @@ -954,7 +954,7 @@ version (linux) c_ulong __unused4; c_ulong __unused5; } - static if (__USE_LARGEFILE64) alias stat_t stat64_t; + static if (__USE_LARGEFILE64) alias stat64_t = stat_t; static if (__WORDSIZE == 64) static assert(stat_t.sizeof == 144); @@ -1458,7 +1458,7 @@ else version (Solaris) char[_ST_FSTYPSZ] st_fstype = 0; } - static if (__USE_LARGEFILE64) alias stat_t stat64_t; + static if (__USE_LARGEFILE64) alias stat64_t = stat_t; } else { @@ -1530,9 +1530,9 @@ else version (Solaris) } static if (__USE_FILE_OFFSET64) - alias stat64_t stat_t; + alias stat_t = stat64_t; else - alias stat32_t stat_t; + alias stat_t = stat32_t; } @@ -1930,16 +1930,16 @@ version (CRuntime_Glibc) static if ( __USE_LARGEFILE64 ) { int fstat64(int, stat_t*) @trusted; - alias fstat64 fstat; + alias fstat = fstat64; int lstat64(const scope char*, stat_t*); - alias lstat64 lstat; + alias lstat = lstat64; int stat64(const scope char*, stat_t*); - alias stat64 stat; + alias stat = stat64; int fstatat64(int, const scope char*, stat_t*, int); - alias fstatat64 fstatat; + alias fstatat = fstatat64; } else @@ -1965,10 +1965,10 @@ else version (Solaris) static if (__USE_LARGEFILE64) { - alias fstat fstat64; - alias lstat lstat64; - alias stat stat64; - alias fstatat fstatat64; + alias fstat64 = fstat; + alias lstat64 = lstat; + alias stat64 = stat; + alias fstatat64 = fstatat; } } else @@ -1976,16 +1976,16 @@ else version (Solaris) static if (__USE_LARGEFILE64) { int fstat64(int, stat_t*) @trusted; - alias fstat64 fstat; + alias fstat = fstat64; int lstat64(const scope char*, stat_t*); - alias lstat64 lstat; + alias lstat = lstat64; int stat64(const scope char*, stat_t*); - alias stat64 stat; + alias stat = stat64; int fstatat64(int, const scope char*, stat_t*, int); - alias fstatat64 fstatat; + alias fstatat = fstatat64; } else { @@ -2074,9 +2074,9 @@ else version (NetBSD) int __fstat50(int, stat_t*); int __lstat50(const scope char*, stat_t*); int __stat50(const scope char*, stat_t*); - alias __fstat50 fstat; - alias __lstat50 lstat; - alias __stat50 stat; + alias fstat = __fstat50; + alias lstat = __lstat50; + alias stat = __stat50; int fchmodat(int, const scope char*, mode_t, int); int fstatat(int, const scope char*, stat_t*, int); int futimens(int, ref const(timespec)[2]); @@ -2131,9 +2131,9 @@ else version (CRuntime_Musl) pragma(mangle, muslRedirTime64Mangle!("fstatat", "__fstatat_time64")) int fstatat(int, const scope char*, stat_t*, int); - alias fstat fstat64; - alias lstat lstat64; - alias stat stat64; + alias fstat64 = fstat; + alias lstat64 = lstat; + alias stat64 = stat; int fchmodat(int, const scope char*, mode_t, int); int futimens(int, ref const(timespec)[2]); int mkdirat(int, const scope char*, mode_t); @@ -2145,16 +2145,16 @@ else version (CRuntime_UClibc) static if ( __USE_LARGEFILE64 ) { int fstat64(int, stat_t*) @trusted; - alias fstat64 fstat; + alias fstat = fstat64; int lstat64(const scope char*, stat_t*); - alias lstat64 lstat; + alias lstat = lstat64; int stat64(const scope char*, stat_t*); - alias stat64 stat; + alias stat = stat64; int fstatat64(int, const scope char*, stat_t*, int); - alias fstatat64 fstatat; + alias fstatat = fstatat64; } else { diff --git a/runtime/druntime/src/core/sys/posix/sys/statvfs.d b/runtime/druntime/src/core/sys/posix/sys/statvfs.d index ede7866bae..dec253d300 100644 --- a/runtime/druntime/src/core/sys/posix/sys/statvfs.d +++ b/runtime/druntime/src/core/sys/posix/sys/statvfs.d @@ -74,10 +74,10 @@ version (CRuntime_Glibc) { static if ( __USE_FILE_OFFSET64 ) { int statvfs64 (const char * file, statvfs_t* buf); - alias statvfs64 statvfs; + alias statvfs = statvfs64; int fstatvfs64 (int fildes, statvfs_t *buf) @trusted; - alias fstatvfs64 fstatvfs; + alias fstatvfs = fstatvfs64; } else { diff --git a/runtime/druntime/src/core/sys/posix/sys/types.d b/runtime/druntime/src/core/sys/posix/sys/types.d index 7c03b2949a..b6febde713 100644 --- a/runtime/druntime/src/core/sys/posix/sys/types.d +++ b/runtime/druntime/src/core/sys/posix/sys/types.d @@ -45,25 +45,25 @@ version (CRuntime_Glibc) version (D_X32) { // X32 kernel interface is 64-bit. - alias long slong_t; - alias ulong ulong_t; + alias slong_t = long; + alias ulong_t = ulong; } else { - alias c_long slong_t; - alias c_ulong ulong_t; + alias slong_t = c_long; + alias ulong_t = c_ulong; } } else { - alias c_long slong_t; - alias c_ulong ulong_t; + alias slong_t = c_long; + alias ulong_t = c_ulong; } } else { - alias c_long slong_t; - alias c_ulong ulong_t; + alias slong_t = c_long; + alias ulong_t = c_ulong; } // @@ -89,15 +89,15 @@ version (linux) { static if ( __USE_FILE_OFFSET64 ) { - alias long blkcnt_t; - alias ulong ino_t; - alias long off_t; + alias blkcnt_t = long; + alias ino_t = ulong; + alias off_t = long; } else { - alias slong_t blkcnt_t; - alias ulong_t ino_t; - alias slong_t off_t; + alias blkcnt_t = slong_t; + alias ino_t = ulong_t; + alias off_t = slong_t; } // musl overrides blksize_t to int on some 64-bit architectures. // Default: long (https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in?h=v1.2.3#n32) @@ -107,20 +107,20 @@ version (linux) version (CRuntime_Musl) { version (AArch64) - alias int blksize_t; + alias blksize_t = int; else version (RISCV64) - alias int blksize_t; + alias blksize_t = int; else version (LoongArch64) - alias int blksize_t; + alias blksize_t = int; else - alias slong_t blksize_t; + alias blksize_t = slong_t; } else - alias slong_t blksize_t; + alias blksize_t = slong_t; - alias ulong dev_t; - alias uint gid_t; - alias uint mode_t; + alias dev_t = ulong; + alias gid_t = uint; + alias mode_t = uint; // musl defines nlink_t as unsigned _Reg (= unsigned int on 32-bit, unsigned long on 64-bit), // with arch-specific overrides. @@ -130,32 +130,32 @@ version (linux) version (CRuntime_Musl) { version (MIPS64) - alias uint nlink_t; + alias nlink_t = uint; else version (X86_64) - alias ulong nlink_t; + alias nlink_t = ulong; else - alias uint nlink_t; + alias nlink_t = uint; } else { version (X86_64) - alias ulong nlink_t; + alias nlink_t = ulong; else version (S390) - alias size_t nlink_t; + alias nlink_t = size_t; else version (PPC64) - alias size_t nlink_t; + alias nlink_t = size_t; else version (MIPS64) - alias size_t nlink_t; + alias nlink_t = size_t; else version (HPPA64) - alias size_t nlink_t; + alias nlink_t = size_t; else - alias uint nlink_t; + alias nlink_t = uint; } - alias int pid_t; + alias pid_t = int; //size_t (defined in core.stdc.stddef) - alias c_long ssize_t; - alias uint uid_t; + alias ssize_t = c_long; + alias uid_t = uint; version (CRuntime_Musl) { @@ -180,153 +180,153 @@ version (linux) * one can recompile druntime with `CRuntime_Musl_Pre_Time64`. */ version (D_X32) - alias long time_t; + alias time_t = long; else version (CRuntime_Musl_Pre_Time64) - alias c_long time_t; + alias time_t = c_long; else - alias long time_t; + alias time_t = long; } else { - alias slong_t time_t; + alias time_t = slong_t; } } else version (Darwin) { - alias long blkcnt_t; - alias int blksize_t; - alias int dev_t; - alias uint gid_t; - alias ulong ino_t; - alias ushort mode_t; - alias ushort nlink_t; - alias long off_t; - alias int pid_t; + alias blkcnt_t = long; + alias blksize_t = int; + alias dev_t = int; + alias gid_t = uint; + alias ino_t = ulong; + alias mode_t = ushort; + alias nlink_t = ushort; + alias off_t = long; + alias pid_t = int; //size_t (defined in core.stdc.stddef) - alias c_long ssize_t; - alias c_long time_t; - alias uint uid_t; + alias ssize_t = c_long; + alias time_t = c_long; + alias uid_t = uint; } else version (FreeBSD) { import core.sys.freebsd.config; // https://github.com/freebsd/freebsd/blob/master/sys/sys/_types.h - alias long blkcnt_t; - alias uint blksize_t; + alias blkcnt_t = long; + alias blksize_t = uint; static if (__FreeBSD_version >= 1200000) { - alias ulong dev_t; - alias ulong ino_t; - alias ulong nlink_t; + alias dev_t = ulong; + alias ino_t = ulong; + alias nlink_t = ulong; } else { - alias uint dev_t; - alias uint ino_t; - alias ushort nlink_t; + alias dev_t = uint; + alias ino_t = uint; + alias nlink_t = ushort; } - alias uint gid_t; - alias ushort mode_t; - alias long off_t; - alias int pid_t; + alias gid_t = uint; + alias mode_t = ushort; + alias off_t = long; + alias pid_t = int; //size_t (defined in core.stdc.stddef) - alias c_long ssize_t; - alias c_long time_t; - alias uint uid_t; - alias uint fflags_t; // non-standard + alias ssize_t = c_long; + alias time_t = c_long; + alias uid_t = uint; + alias fflags_t = uint; // non-standard } else version (NetBSD) { - alias long blkcnt_t; - alias int blksize_t; - alias ulong dev_t; - alias uint gid_t; - alias ulong ino_t; - alias uint mode_t; - alias uint nlink_t; - alias ulong off_t; - alias int pid_t; + alias blkcnt_t = long; + alias blksize_t = int; + alias dev_t = ulong; + alias gid_t = uint; + alias ino_t = ulong; + alias mode_t = uint; + alias nlink_t = uint; + alias off_t = ulong; + alias pid_t = int; //size_t (defined in core.stdc.stddef) - alias c_long ssize_t; - alias c_long time_t; - alias uint uid_t; + alias ssize_t = c_long; + alias time_t = c_long; + alias uid_t = uint; } else version (OpenBSD) { - alias char* caddr_t; - alias long blkcnt_t; - alias int blksize_t; - alias int dev_t; - alias uint gid_t; - alias ulong ino_t; - alias uint mode_t; - alias uint nlink_t; - alias long off_t; - alias int pid_t; + alias caddr_t = char*; + alias blkcnt_t = long; + alias blksize_t = int; + alias dev_t = int; + alias gid_t = uint; + alias ino_t = ulong; + alias mode_t = uint; + alias nlink_t = uint; + alias off_t = long; + alias pid_t = int; //size_t (defined in core.stdc.stddef) - alias c_long ssize_t; - alias long time_t; - alias uint uid_t; + alias ssize_t = c_long; + alias time_t = long; + alias uid_t = uint; } else version (DragonFlyBSD) { - alias long blkcnt_t; - alias long blksize_t; - alias uint dev_t; - alias uint gid_t; - alias long ino_t; - alias ushort mode_t; - alias uint nlink_t; - alias long off_t; //__off_t (defined in /usr/include/sys/stdint.h -> core.stdc.stddef) - alias int pid_t; // size_t (defined in /usr/include/sys/stdint.h -> core.stdc.stddef) - alias c_long ssize_t; - alias long time_t; - alias uint uid_t; + alias blkcnt_t = long; + alias blksize_t = long; + alias dev_t = uint; + alias gid_t = uint; + alias ino_t = long; + alias mode_t = ushort; + alias nlink_t = uint; + alias off_t = long; //__off_t (defined in /usr/include/sys/stdint.h -> core.stdc.stddef) + alias pid_t = int; // size_t (defined in /usr/include/sys/stdint.h -> core.stdc.stddef) + alias ssize_t = c_long; + alias time_t = long; + alias uid_t = uint; } else version (Solaris) { - alias char* caddr_t; - alias c_long daddr_t; - alias short cnt_t; + alias caddr_t = char*; + alias daddr_t = c_long; + alias cnt_t = short; static if (__USE_FILE_OFFSET64) { - alias long blkcnt_t; - alias ulong ino_t; - alias long off_t; + alias blkcnt_t = long; + alias ino_t = ulong; + alias off_t = long; } else { - alias c_long blkcnt_t; - alias c_ulong ino_t; - alias c_long off_t; + alias blkcnt_t = c_long; + alias ino_t = c_ulong; + alias off_t = c_long; } version (D_LP64) { - alias blkcnt_t blkcnt64_t; - alias ino_t ino64_t; - alias off_t off64_t; + alias blkcnt64_t = blkcnt_t; + alias ino64_t = ino_t; + alias off64_t = off_t; } else { - alias long blkcnt64_t; - alias ulong ino64_t; - alias long off64_t; + alias blkcnt64_t = long; + alias ino64_t = ulong; + alias off64_t = long; } - alias uint blksize_t; - alias c_ulong dev_t; - alias uid_t gid_t; - alias uint mode_t; - alias uint nlink_t; - alias int pid_t; - alias c_long ssize_t; - alias c_long time_t; - alias uint uid_t; + alias blksize_t = uint; + alias dev_t = c_ulong; + alias gid_t = uid_t; + alias mode_t = uint; + alias nlink_t = uint; + alias pid_t = int; + alias ssize_t = c_long; + alias time_t = c_long; + alias uid_t = uint; } else { @@ -350,94 +350,94 @@ version (linux) { static if ( __USE_FILE_OFFSET64 ) { - alias ulong fsblkcnt_t; - alias ulong fsfilcnt_t; + alias fsblkcnt_t = ulong; + alias fsfilcnt_t = ulong; } else { - alias ulong_t fsblkcnt_t; - alias ulong_t fsfilcnt_t; + alias fsblkcnt_t = ulong_t; + alias fsfilcnt_t = ulong_t; } - alias slong_t clock_t; - alias uint id_t; - alias int key_t; - alias slong_t suseconds_t; - alias uint useconds_t; + alias clock_t = slong_t; + alias id_t = uint; + alias key_t = int; + alias suseconds_t = slong_t; + alias useconds_t = uint; } else version (Darwin) { - alias uint fsblkcnt_t; - alias uint fsfilcnt_t; - alias c_long clock_t; - alias uint id_t; - alias int key_t; - alias int suseconds_t; - alias uint useconds_t; + alias fsblkcnt_t = uint; + alias fsfilcnt_t = uint; + alias clock_t = c_long; + alias id_t = uint; + alias key_t = int; + alias suseconds_t = int; + alias useconds_t = uint; } else version (FreeBSD) { - alias ulong fsblkcnt_t; - alias ulong fsfilcnt_t; - alias c_long clock_t; - alias long id_t; - alias c_long key_t; - alias c_long suseconds_t; - alias uint useconds_t; + alias fsblkcnt_t = ulong; + alias fsfilcnt_t = ulong; + alias clock_t = c_long; + alias id_t = long; + alias key_t = c_long; + alias suseconds_t = c_long; + alias useconds_t = uint; } else version (NetBSD) { - alias ulong fsblkcnt_t; - alias ulong fsfilcnt_t; - alias c_long clock_t; - alias long id_t; - alias c_long key_t; - alias c_long suseconds_t; - alias uint useconds_t; + alias fsblkcnt_t = ulong; + alias fsfilcnt_t = ulong; + alias clock_t = c_long; + alias id_t = long; + alias key_t = c_long; + alias suseconds_t = c_long; + alias useconds_t = uint; } else version (OpenBSD) { - alias ulong fsblkcnt_t; - alias ulong fsfilcnt_t; - alias long clock_t; - alias uint id_t; - alias c_long key_t; - alias c_long suseconds_t; - alias uint useconds_t; + alias fsblkcnt_t = ulong; + alias fsfilcnt_t = ulong; + alias clock_t = long; + alias id_t = uint; + alias key_t = c_long; + alias suseconds_t = c_long; + alias useconds_t = uint; } else version (DragonFlyBSD) { - alias ulong fsblkcnt_t; - alias ulong fsfilcnt_t; - alias c_long clock_t; - alias long id_t; - alias c_long key_t; - alias c_long suseconds_t; - alias uint useconds_t; + alias fsblkcnt_t = ulong; + alias fsfilcnt_t = ulong; + alias clock_t = c_long; + alias id_t = long; + alias key_t = c_long; + alias suseconds_t = c_long; + alias useconds_t = uint; } else version (Solaris) { static if (__USE_FILE_OFFSET64) { - alias ulong fsblkcnt_t; - alias ulong fsfilcnt_t; + alias fsblkcnt_t = ulong; + alias fsfilcnt_t = ulong; } else { - alias c_ulong fsblkcnt_t; - alias c_ulong fsfilcnt_t; + alias fsblkcnt_t = c_ulong; + alias fsfilcnt_t = c_ulong; } - alias c_long clock_t; - alias int id_t; - alias int key_t; - alias c_long suseconds_t; - alias uint useconds_t; + alias clock_t = c_long; + alias id_t = int; + alias key_t = int; + alias suseconds_t = c_long; + alias useconds_t = uint; - alias id_t taskid_t; - alias id_t projid_t; - alias id_t poolid_t; - alias id_t zoneid_t; - alias id_t ctid_t; + alias taskid_t = id_t; + alias projid_t = id_t; + alias poolid_t = id_t; + alias zoneid_t = id_t; + alias ctid_t = id_t; } else { @@ -692,7 +692,7 @@ version (CRuntime_Glibc) c_long __align; } - private alias int __atomic_lock_t; + private alias __atomic_lock_t = int; private struct _pthread_fastlock { @@ -700,7 +700,7 @@ version (CRuntime_Glibc) __atomic_lock_t __spinlock; } - private alias void* _pthread_descr; + private alias _pthread_descr = void*; union pthread_cond_t { @@ -714,7 +714,7 @@ version (CRuntime_Glibc) int __align; } - alias uint pthread_key_t; + alias pthread_key_t = uint; union pthread_mutex_t { @@ -728,7 +728,7 @@ version (CRuntime_Glibc) int __align; } - alias int pthread_once_t; + alias pthread_once_t = int; struct pthread_rwlock_t { @@ -742,7 +742,7 @@ version (CRuntime_Glibc) c_long __align; } - alias c_ulong pthread_t; + alias pthread_t = c_ulong; } else version (CRuntime_Musl) { @@ -804,7 +804,7 @@ else version (CRuntime_Musl) uint[2] __attr; } - alias uint pthread_key_t; + alias pthread_key_t = uint; struct pthread_condattr_t { @@ -816,9 +816,9 @@ else version (CRuntime_Musl) uint __attr; } - alias int pthread_once_t; + alias pthread_once_t = int; - alias c_ulong pthread_t; + alias pthread_t = c_ulong; } else version (Darwin) { @@ -872,7 +872,7 @@ else version (Darwin) byte[__PTHREAD_CONDATTR_SIZE__] __opaque; } - alias c_ulong pthread_key_t; + alias pthread_key_t = c_ulong; struct pthread_mutex_t { @@ -911,22 +911,22 @@ else version (Darwin) byte[__PTHREAD_SIZE__] __opaque; } - alias _opaque_pthread_t* pthread_t; + alias pthread_t = _opaque_pthread_t*; } else version (FreeBSD) { - alias int lwpid_t; // non-standard - - alias void* pthread_attr_t; - alias void* pthread_cond_t; - alias void* pthread_condattr_t; - alias void* pthread_key_t; - alias void* pthread_mutex_t; - alias void* pthread_mutexattr_t; - alias void* pthread_once_t; - alias void* pthread_rwlock_t; - alias void* pthread_rwlockattr_t; - alias void* pthread_t; + alias lwpid_t = int; // non-standard + + alias pthread_attr_t = void*; + alias pthread_cond_t = void*; + alias pthread_condattr_t = void*; + alias pthread_key_t = void*; + alias pthread_mutex_t = void*; + alias pthread_mutexattr_t = void*; + alias pthread_once_t = void*; + alias pthread_rwlock_t = void*; + alias pthread_rwlockattr_t = void*; + alias pthread_t = void*; } else version (NetBSD) { @@ -993,55 +993,55 @@ else version (NetBSD) void* ptra_private; } - alias uint pthread_key_t; - alias void* pthread_t; + alias pthread_key_t = uint; + alias pthread_t = void*; } else version (OpenBSD) { - alias void* pthread_attr_t; - alias void* pthread_cond_t; - alias void* pthread_condattr_t; - alias int pthread_key_t; - alias void* pthread_mutex_t; - alias void* pthread_mutexattr_t; + alias pthread_attr_t = void*; + alias pthread_cond_t = void*; + alias pthread_condattr_t = void*; + alias pthread_key_t = int; + alias pthread_mutex_t = void*; + alias pthread_mutexattr_t = void*; private struct pthread_once { int state; pthread_mutex_t mutex; } - alias pthread_once pthread_once_t; + alias pthread_once_t = pthread_once; - alias void* pthread_rwlock_t; - alias void* pthread_rwlockattr_t; - alias void* pthread_t; + alias pthread_rwlock_t = void*; + alias pthread_rwlockattr_t = void*; + alias pthread_t = void*; } else version (DragonFlyBSD) { - alias int lwpid_t; + alias lwpid_t = int; - alias void* pthread_attr_t; - alias void* pthread_cond_t; - alias void* pthread_condattr_t; - alias void* pthread_key_t; - alias void* pthread_mutex_t; - alias void* pthread_mutexattr_t; + alias pthread_attr_t = void*; + alias pthread_cond_t = void*; + alias pthread_condattr_t = void*; + alias pthread_key_t = void*; + alias pthread_mutex_t = void*; + alias pthread_mutexattr_t = void*; private struct pthread_once { int state; pthread_mutex_t mutex; } - alias pthread_once pthread_once_t; + alias pthread_once_t = pthread_once; - alias void* pthread_rwlock_t; - alias void* pthread_rwlockattr_t; - alias void* pthread_t; + alias pthread_rwlock_t = void*; + alias pthread_rwlockattr_t = void*; + alias pthread_t = void*; } else version (Solaris) { - alias uint pthread_t; - alias int lwpid_t; // non-standard + alias pthread_t = uint; + alias lwpid_t = int; // non-standard struct pthread_attr_t { @@ -1127,7 +1127,7 @@ else version (Solaris) ulong[4] __pthread_once_pad; } - alias uint pthread_key_t; + alias pthread_key_t = uint; } else version (CRuntime_Bionic) { @@ -1150,8 +1150,8 @@ else version (CRuntime_Bionic) int[1] __private; } - alias c_long pthread_condattr_t; - alias int pthread_key_t; + alias pthread_condattr_t = c_long; + alias pthread_key_t = int; struct pthread_mutex_t { @@ -1161,8 +1161,8 @@ else version (CRuntime_Bionic) int[1] __private; } - alias c_long pthread_mutexattr_t; - alias int pthread_once_t; + alias pthread_mutexattr_t = c_long; + alias pthread_once_t = int; struct pthread_rwlock_t { @@ -1172,8 +1172,8 @@ else version (CRuntime_Bionic) int[10] __private; } - alias c_long pthread_rwlockattr_t; - alias c_long pthread_t; + alias pthread_rwlockattr_t = c_long; + alias pthread_t = c_long; } else version (CRuntime_UClibc) { @@ -1260,7 +1260,7 @@ else version (CRuntime_UClibc) c_long __align; } - alias uint pthread_key_t; + alias pthread_key_t = uint; struct __pthread_slist_t { @@ -1295,7 +1295,7 @@ else version (CRuntime_UClibc) c_long __align; } - alias int pthread_once_t; + alias pthread_once_t = int; struct pthread_rwlock_t { @@ -1333,7 +1333,7 @@ else version (CRuntime_UClibc) c_long __align; } - alias c_ulong pthread_t; + alias pthread_t = c_ulong; } else { @@ -1364,23 +1364,23 @@ version (CRuntime_Glibc) } else version (FreeBSD) { - alias void* pthread_barrier_t; - alias void* pthread_barrierattr_t; + alias pthread_barrier_t = void*; + alias pthread_barrierattr_t = void*; } else version (NetBSD) { - alias void* pthread_barrier_t; - alias void* pthread_barrierattr_t; + alias pthread_barrier_t = void*; + alias pthread_barrierattr_t = void*; } else version (OpenBSD) { - alias void* pthread_barrier_t; - alias void* pthread_barrierattr_t; + alias pthread_barrier_t = void*; + alias pthread_barrierattr_t = void*; } else version (DragonFlyBSD) { - alias void* pthread_barrier_t; - alias void* pthread_barrierattr_t; + alias pthread_barrier_t = void*; + alias pthread_barrierattr_t = void*; } else version (Darwin) { @@ -1457,11 +1457,11 @@ pthread_spinlock_t version (CRuntime_Glibc) { - alias int pthread_spinlock_t; // volatile + alias pthread_spinlock_t = int; // volatile } else version (FreeBSD) { - alias void* pthread_spinlock_t; + alias pthread_spinlock_t = void*; } else version (NetBSD) { @@ -1469,23 +1469,23 @@ else version (NetBSD) } else version (OpenBSD) { - alias void* pthread_spinlock_t; + alias pthread_spinlock_t = void*; } else version (DragonFlyBSD) { - alias void* pthread_spinlock_t; + alias pthread_spinlock_t = void*; } else version (Solaris) { - alias pthread_mutex_t pthread_spinlock_t; + alias pthread_spinlock_t = pthread_mutex_t; } else version (CRuntime_UClibc) { - alias int pthread_spinlock_t; // volatile + alias pthread_spinlock_t = int; // volatile } else version (CRuntime_Musl) { - alias int pthread_spinlock_t; + alias pthread_spinlock_t = int; } // diff --git a/runtime/druntime/src/core/sys/posix/sys/wait.d b/runtime/druntime/src/core/sys/posix/sys/wait.d index 131a9400dc..0c4e72e999 100644 --- a/runtime/druntime/src/core/sys/posix/sys/wait.d +++ b/runtime/druntime/src/core/sys/posix/sys/wait.d @@ -257,7 +257,7 @@ else version (CRuntime_Musl) extern (D) bool WIFSIGNALED()( int status ) { return (status&0xffff)-1U < 0xffU; } extern (D) bool WIFSTOPPED()( int status ) { return cast(short)(((status&0xffff)*0x10001)>>8) > 0x7f00; } extern (D) int WTERMSIG()( int status ) { return status & 0x7F; } - alias WEXITSTATUS WSTOPSIG; + alias WSTOPSIG = WEXITSTATUS; } else version (CRuntime_UClibc) { diff --git a/runtime/druntime/src/core/sys/posix/termios.d b/runtime/druntime/src/core/sys/posix/termios.d index e4a99e6865..38181a9d84 100644 --- a/runtime/druntime/src/core/sys/posix/termios.d +++ b/runtime/druntime/src/core/sys/posix/termios.d @@ -132,9 +132,9 @@ TCOON version (linux) { - alias ubyte cc_t; - alias uint speed_t; - alias uint tcflag_t; + alias cc_t = ubyte; + alias speed_t = uint; + alias tcflag_t = uint; enum NCCS = 32; @@ -230,9 +230,9 @@ version (linux) } else version (Darwin) { - alias ubyte cc_t; - alias c_ulong speed_t; - alias c_ulong tcflag_t; + alias cc_t = ubyte; + alias speed_t = c_ulong; + alias tcflag_t = c_ulong; enum NCCS = 20; @@ -327,9 +327,9 @@ else version (Darwin) } else version (FreeBSD) { - alias ubyte cc_t; - alias uint speed_t; - alias uint tcflag_t; + alias cc_t = ubyte; + alias speed_t = uint; + alias tcflag_t = uint; enum NCCS = 20; @@ -424,9 +424,9 @@ else version (FreeBSD) } else version (DragonFlyBSD) { - alias ubyte cc_t; - alias uint speed_t; - alias uint tcflag_t; + alias cc_t = ubyte; + alias speed_t = uint; + alias tcflag_t = uint; enum NCCS = 20; @@ -521,9 +521,9 @@ else version (DragonFlyBSD) } else version (NetBSD) { - alias ubyte cc_t; - alias uint speed_t; - alias uint tcflag_t; + alias cc_t = ubyte; + alias speed_t = uint; + alias tcflag_t = uint; enum NCCS = 20; @@ -618,9 +618,9 @@ else version (NetBSD) } else version (OpenBSD) { - alias uint tcflag_t; - alias ubyte cc_t; - alias uint speed_t; + alias tcflag_t = uint; + alias cc_t = ubyte; + alias speed_t = uint; enum NCCS = 20; diff --git a/runtime/druntime/src/core/sys/posix/time.d b/runtime/druntime/src/core/sys/posix/time.d index 732c18a97c..a631ddc2bc 100644 --- a/runtime/druntime/src/core/sys/posix/time.d +++ b/runtime/druntime/src/core/sys/posix/time.d @@ -257,7 +257,7 @@ else version (Solaris) c_long tv_nsec; } - alias timespec timestruc_t; + alias timestruc_t = timespec; } else { @@ -286,8 +286,8 @@ version (CRuntime_Glibc) enum CLOCK_REALTIME = 0; enum TIMER_ABSTIME = 0x01; - alias int clockid_t; - alias void* timer_t; + alias clockid_t = int; + alias timer_t = void*; int clock_getres(clockid_t, timespec*); int clock_gettime(clockid_t, timespec*); @@ -325,8 +325,8 @@ else version (FreeBSD) enum CLOCK_REALTIME = 0; enum TIMER_ABSTIME = 0x01; - alias int clockid_t; // - alias int timer_t; + alias clockid_t = int; // + alias timer_t = int; int clock_getres(clockid_t, timespec*); int clock_gettime(clockid_t, timespec*); @@ -351,8 +351,8 @@ else version (DragonFlyBSD) enum CLOCK_REALTIME = 0; enum TIMER_ABSTIME = 0x01; - alias int clockid_t; // - alias int timer_t; + alias clockid_t = int; // + alias timer_t = int; int clock_getres(clockid_t, timespec*); int clock_gettime(clockid_t, timespec*); @@ -375,8 +375,8 @@ else version (NetBSD) enum CLOCK_REALTIME = 0; enum TIMER_ABSTIME = 0x01; - alias int clockid_t; // - alias int timer_t; + alias clockid_t = int; // + alias timer_t = int; int clock_getres(clockid_t, timespec*); int clock_gettime(clockid_t, timespec*); @@ -399,8 +399,8 @@ else version (OpenBSD) enum CLOCK_REALTIME = 0; enum TIMER_ABSTIME = 0x1; - alias int clockid_t; // - alias int timer_t; + alias clockid_t = int; // + alias timer_t = int; int clock_getres(clockid_t, timespec*); int clock_gettime(clockid_t, timespec*); @@ -421,8 +421,8 @@ else version (Solaris) enum CLOCK_REALTIME = 3; // enum TIMER_ABSOLUTE = 0x1; - alias int clockid_t; - alias int timer_t; + alias clockid_t = int; + alias timer_t = int; int clock_getres(clockid_t, timespec*); int clock_gettime(clockid_t, timespec*); @@ -452,8 +452,8 @@ else version (CRuntime_Bionic) enum CLOCK_REALTIME_HR = 4; enum TIMER_ABSTIME = 0x01; - alias int clockid_t; - alias void* timer_t; // Updated since Lollipop + alias clockid_t = int; + alias timer_t = void*; // Updated since Lollipop int clock_getres(int, timespec*); int clock_gettime(int, timespec*); @@ -468,8 +468,8 @@ else version (CRuntime_Musl) { static assert(timespec.sizeof == 16); - alias int clockid_t; - alias void* timer_t; + alias clockid_t = int; + alias timer_t = void*; struct itimerspec { @@ -524,8 +524,8 @@ else version (CRuntime_UClibc) enum TIMER_ABSTIME = 0x01; - alias int clockid_t; - alias void* timer_t; + alias clockid_t = int; + alias timer_t = void*; int clock_getres(clockid_t, timespec*); int clock_gettime(clockid_t, timespec*); @@ -686,7 +686,7 @@ else version (Solaris) tm* getdate(const scope char*); char* __strptime_dontzero(const scope char*, const scope char*, tm*); - alias __strptime_dontzero strptime; + alias strptime = __strptime_dontzero; } else version (CRuntime_Bionic) { diff --git a/runtime/druntime/src/core/sys/posix/ucontext.d b/runtime/druntime/src/core/sys/posix/ucontext.d index 451401d390..3ce5c0cd6b 100644 --- a/runtime/druntime/src/core/sys/posix/ucontext.d +++ b/runtime/druntime/src/core/sys/posix/ucontext.d @@ -124,9 +124,9 @@ version (linux) enum NGREG = 23; - alias long greg_t; - alias greg_t[NGREG] gregset_t; - alias _libc_fpstate* fpregset_t; + alias greg_t = long; + alias gregset_t = greg_t[NGREG]; + alias fpregset_t = _libc_fpstate*; } struct mcontext_t @@ -196,9 +196,9 @@ version (linux) enum NGREG = 19; - alias int greg_t; - alias greg_t[NGREG] gregset_t; - alias _libc_fpstate* fpregset_t; + alias greg_t = int; + alias gregset_t = greg_t[NGREG]; + alias fpregset_t = _libc_fpstate*; } struct mcontext_t @@ -228,7 +228,7 @@ version (linux) enum NGREG = 80; enum NFPREG = 32; - alias c_ulong greg_t; + alias greg_t = c_ulong; struct gregset_t { @@ -270,8 +270,8 @@ version (linux) enum NGREG = 32; enum NFPREG = 32; - alias ulong greg_t; - alias greg_t[NGREG] gregset_t; + alias greg_t = ulong; + alias gregset_t = greg_t[NGREG]; struct fpregset_t { @@ -349,8 +349,8 @@ version (linux) enum NGREG = 32; enum NFPREG = 32; - alias ulong greg_t; - alias greg_t[NGREG] gregset_t; + alias greg_t = ulong; + alias gregset_t = greg_t[NGREG]; struct fpregset_t { @@ -400,8 +400,8 @@ version (linux) { enum NGREG = 48; - alias c_ulong greg_t; - alias greg_t[NGREG] gregset_t; + alias greg_t = c_ulong; + alias gregset_t = greg_t[NGREG]; struct fpregset_t { @@ -466,9 +466,9 @@ version (linux) enum NFPREG = 33; enum NVRREG = 34; - alias c_ulong greg_t; - alias greg_t[NGREG] gregset_t; - alias double[NFPREG] fpregset_t; + alias greg_t = c_ulong; + alias gregset_t = greg_t[NGREG]; + alias fpregset_t = double[NFPREG]; struct vscr_t { @@ -573,7 +573,7 @@ version (linux) } //alias elf_fpregset_t fpregset_t; - alias sigcontext mcontext_t; + alias mcontext_t = sigcontext; struct ucontext_t { @@ -587,7 +587,7 @@ version (linux) } else version (AArch64) { - alias int greg_t; + alias greg_t = int; struct sigcontext { ulong fault_address; @@ -600,7 +600,7 @@ version (linux) align(16) ubyte[4096] __reserved; } - alias sigcontext mcontext_t; + alias mcontext_t = sigcontext; struct ucontext_t { @@ -615,7 +615,7 @@ version (linux) { private { - alias c_ulong[32] __riscv_mc_gp_state; + alias __riscv_mc_gp_state = c_ulong[32]; struct __riscv_mc_f_ext_state { @@ -791,8 +791,8 @@ version (linux) { enum LARCH_NGREG = 32; - alias ulong greg_t; - alias greg_t[LARCH_NGREG] gregset_t; + alias greg_t = ulong; + alias gregset_t = greg_t[LARCH_NGREG]; } struct mcontext_t @@ -886,9 +886,9 @@ else version (FreeBSD) // version (X86_64) { - alias long __register_t; - alias uint __uint32_t; - alias ushort __uint16_t; + alias __register_t = long; + alias __uint32_t = uint; + alias __uint16_t = ushort; struct mcontext_t { __register_t mc_onstack; @@ -937,7 +937,7 @@ else version (FreeBSD) } else version (X86) { - alias int __register_t; + alias __register_t = int; struct mcontext_t { @@ -1010,9 +1010,9 @@ else version (FreeBSD) } else version (PPC_Any) { - alias size_t __register_t; - alias uint __uint32_t; - alias ulong __uint64_t; + alias __register_t = size_t; + alias __uint32_t = uint; + alias __uint64_t = ulong; struct mcontext_t { int mc_vers; @@ -1299,9 +1299,9 @@ else version (DragonFlyBSD) // version (X86_64) { - alias long __register_t; - alias uint __uint32_t; - alias ushort __uint16_t; + alias __register_t = long; + alias __uint32_t = uint; + alias __uint16_t = ushort; struct mcontext_t { __register_t mc_onstack; diff --git a/runtime/druntime/src/core/sys/posix/unistd.d b/runtime/druntime/src/core/sys/posix/unistd.d index 860630b422..71d501be8c 100644 --- a/runtime/druntime/src/core/sys/posix/unistd.d +++ b/runtime/druntime/src/core/sys/posix/unistd.d @@ -120,7 +120,7 @@ version (CRuntime_Glibc) static if ( __USE_FILE_OFFSET64 ) { off_t lseek64(int, off_t, int) @trusted; - alias lseek64 lseek; + alias lseek = lseek64; } else { @@ -129,7 +129,7 @@ version (CRuntime_Glibc) static if ( __USE_LARGEFILE64 ) { int ftruncate64(int, off_t) @trusted; - alias ftruncate64 ftruncate; + alias ftruncate = ftruncate64; } else { @@ -240,20 +240,20 @@ else version (Solaris) version (D_LP64) { off_t lseek(int, off_t, int) @trusted; - alias lseek lseek64; + alias lseek64 = lseek; int ftruncate(int, off_t) @trusted; - alias ftruncate ftruncate64; + alias ftruncate64 = ftruncate; } else { static if ( __USE_LARGEFILE64 ) { off64_t lseek64(int, off64_t, int) @trusted; - alias lseek64 lseek; + alias lseek = lseek64; int ftruncate64(int, off64_t) @trusted; - alias ftruncate64 ftruncate; + alias ftruncate = ftruncate64; } else { @@ -307,8 +307,8 @@ else version (CRuntime_Musl) { int ftruncate(int, off_t) @trusted; off_t lseek(int, off_t, int) @trusted; - alias ftruncate ftruncate64; - alias lseek lseek64; + alias ftruncate64 = ftruncate; + alias lseek64 = lseek; int dup3(int, int, int) @trusted; int faccessat(int, const scope char*, int, int); int fchownat(int, const scope char*, uid_t, gid_t, int); @@ -330,7 +330,7 @@ else version (CRuntime_UClibc) static if ( __USE_FILE_OFFSET64 ) { off_t lseek64(int, off_t, int) @trusted; - alias lseek64 lseek; + alias lseek = lseek64; } else { @@ -339,7 +339,7 @@ else version (CRuntime_UClibc) static if ( __USE_LARGEFILE64 ) { int ftruncate64(int, off_t) @trusted; - alias ftruncate64 ftruncate; + alias ftruncate = ftruncate64; } else { @@ -2604,16 +2604,16 @@ version (CRuntime_Glibc) static if ( __USE_FILE_OFFSET64 ) { int lockf64(int, int, off_t) @trusted; - alias lockf64 lockf; + alias lockf = lockf64; ssize_t pread64(int, void*, size_t, off_t); - alias pread64 pread; + alias pread = pread64; ssize_t pwrite64(int, const scope void*, size_t, off_t); - alias pwrite64 pwrite; + alias pwrite = pwrite64; int truncate64(const scope char*, off_t); - alias truncate64 truncate; + alias truncate = truncate64; } else { @@ -2627,7 +2627,7 @@ else version (CRuntime_Musl) { int fchdir(int) @trusted; int lockf(int, int, off_t); - alias lockf lockf64; + alias lockf64 = lockf; } else version (Darwin) { @@ -2794,32 +2794,32 @@ else version (Solaris) version (D_LP64) { int lockf(int, int, off_t); - alias lockf lockf64; + alias lockf64 = lockf; ssize_t pread(int, void*, size_t, off_t); - alias pread pread64; + alias pread64 = pread; ssize_t pwrite(int, const scope void*, size_t, off_t); - alias pwrite pwrite64; + alias pwrite64 = pwrite; int truncate(const scope char*, off_t); - alias truncate truncate64; + alias truncate64 = truncate; } else { static if ( __USE_FILE_OFFSET64 ) { int lockf64(int, int, off64_t); - alias lockf64 lockf; + alias lockf = lockf64; ssize_t pread64(int, void*, size_t, off64_t); - alias pread64 pread; + alias pread = pread64; ssize_t pwrite64(int, const scope void*, size_t, off_t); - alias pwrite64 pwrite; + alias pwrite = pwrite64; int truncate64(const scope char*, off_t); - alias truncate64 truncate; + alias truncate = truncate64; } else { @@ -2854,16 +2854,16 @@ else version (CRuntime_UClibc) static if ( __USE_FILE_OFFSET64 ) { int lockf64(int, int, off_t) @trusted; - alias lockf64 lockf; + alias lockf = lockf64; ssize_t pread64(int, void*, size_t, off_t); - alias pread64 pread; + alias pread = pread64; ssize_t pwrite64(int, const scope void*, size_t, off_t); - alias pwrite64 pwrite; + alias pwrite = pwrite64; int truncate64(const scope char*, off_t); - alias truncate64 truncate; + alias truncate = truncate64; } else { diff --git a/runtime/druntime/src/core/sys/solaris/dlfcn.d b/runtime/druntime/src/core/sys/solaris/dlfcn.d index 343f003b50..79fb21b1b1 100644 --- a/runtime/druntime/src/core/sys/solaris/dlfcn.d +++ b/runtime/druntime/src/core/sys/solaris/dlfcn.d @@ -22,7 +22,7 @@ enum RTLD_PROBE = cast(void *)-4, } -alias c_ulong Lmid_t; +alias Lmid_t = c_ulong; void* dlmopen(Lmid_t, const scope char*, int); diff --git a/runtime/druntime/src/core/sys/solaris/link.d b/runtime/druntime/src/core/sys/solaris/link.d index 1459783b4a..90eb0488ba 100644 --- a/runtime/druntime/src/core/sys/solaris/link.d +++ b/runtime/druntime/src/core/sys/solaris/link.d @@ -86,9 +86,9 @@ enum LA_ACT_DELETE = 0x02; enum LA_ACT_MAX = 3; version (D_LP64) - alias long lagreg_t; + alias lagreg_t = long; else - alias int lagreg_t; + alias lagreg_t = int; struct _la_sparc_regs { @@ -104,7 +104,7 @@ struct _la_sparc_regs version (D_LP64) { - alias _la_sparc_regs La_sparcv9_regs; + alias La_sparcv9_regs = _la_sparc_regs; struct La_amd64_regs { lagreg_t lr_rsp; @@ -119,7 +119,7 @@ version (D_LP64) } else { - alias _la_sparc_regs La_sparcv8_regs; + alias La_sparcv8_regs = _la_sparc_regs; struct La_i86_regs { lagreg_t lr_esp; @@ -174,7 +174,7 @@ struct dl_phdr_info void* dlpi_tls_data; // since Solaris 11.5 } -private alias extern(C) int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb; -private alias extern(C) int function(dl_phdr_info*, size_t, void *) @nogc dl_iterate_phdr_cb_ngc; +private alias dl_iterate_phdr_cb = extern(C) int function(dl_phdr_info*, size_t, void *); +private alias dl_iterate_phdr_cb_ngc = extern(C) int function(dl_phdr_info*, size_t, void *) @nogc; extern int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data); extern int dl_iterate_phdr(dl_iterate_phdr_cb_ngc __callback, void*__data) @nogc; diff --git a/runtime/druntime/src/core/sys/solaris/sys/elf.d b/runtime/druntime/src/core/sys/solaris/sys/elf.d index 687e7f7d51..83bcc16832 100644 --- a/runtime/druntime/src/core/sys/solaris/sys/elf.d +++ b/runtime/druntime/src/core/sys/solaris/sys/elf.d @@ -61,7 +61,7 @@ enum SHT_SUNW_versym = 0x6fffffff; extern (D) { auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x07; } - alias ELF32_ST_VISIBILITY ELF64_ST_VISIBILITY; + alias ELF64_ST_VISIBILITY = ELF32_ST_VISIBILITY; } enum STV_EXPORTED = 4; @@ -100,12 +100,12 @@ struct Elf32_Cap } } -alias Elf32_Word Elf32_Capinfo; -alias Elf32_Word Elf32_Capchain; +alias Elf32_Capinfo = Elf32_Word; +alias Elf32_Capchain = Elf32_Word; -alias ELF32_M_SYM ELF32_C_SYM; -alias ELF32_M_SIZE ELF32_C_GROUP; -alias ELF32_M_INFO ELF32_C_INFO; +alias ELF32_C_SYM = ELF32_M_SYM; +alias ELF32_C_GROUP = ELF32_M_SIZE; +alias ELF32_C_INFO = ELF32_M_INFO; struct Elf64_Cap { @@ -117,8 +117,8 @@ struct Elf64_Cap } } -alias Elf64_Xword Elf64_Capinfo; -alias Elf64_Word Elf64_Capchain; +alias Elf64_Capinfo = Elf64_Xword; +alias Elf64_Capchain = Elf64_Word; extern (D) { diff --git a/runtime/druntime/src/core/sys/solaris/sys/elftypes.d b/runtime/druntime/src/core/sys/solaris/sys/elftypes.d index fe8cfef395..98dd8ac161 100644 --- a/runtime/druntime/src/core/sys/solaris/sys/elftypes.d +++ b/runtime/druntime/src/core/sys/solaris/sys/elftypes.d @@ -18,5 +18,5 @@ public import core.sys.elf : Elf64_Sword, Elf64_Sxword, Elf64_Word, Elf64_Xword; -alias uint64_t Elf64_Lword; -alias uint64_t Elf32_Lword; +alias Elf64_Lword = uint64_t; +alias Elf32_Lword = uint64_t; diff --git a/runtime/druntime/src/core/sys/solaris/sys/link.d b/runtime/druntime/src/core/sys/solaris/sys/link.d index 9176b1794f..17b3a67629 100644 --- a/runtime/druntime/src/core/sys/solaris/sys/link.d +++ b/runtime/druntime/src/core/sys/solaris/sys/link.d @@ -75,7 +75,7 @@ enum SYMINFO_FLG_DEFERRED = 0x0200; enum SYMINFO_BT_NONE = 0xfffd; enum SYMINFO_BT_EXTERN = 0xfffc; -alias link_map Link_map; +alias Link_map = link_map; struct link_map { @@ -92,7 +92,7 @@ struct link_map version (_SYSCALL32) { -alias link_map32 Link_map32; +alias Link_map32 = link_map32; struct link_map32 { diff --git a/runtime/druntime/src/core/sys/solaris/sys/types.d b/runtime/druntime/src/core/sys/solaris/sys/types.d index 58558769b7..bb17a607c5 100644 --- a/runtime/druntime/src/core/sys/solaris/sys/types.d +++ b/runtime/druntime/src/core/sys/solaris/sys/types.d @@ -19,6 +19,6 @@ version (Solaris): nothrow: @nogc: -alias short pri_t; +alias pri_t = short; enum P_MYID = -1; diff --git a/runtime/druntime/src/core/sys/windows/accctrl.d b/runtime/druntime/src/core/sys/windows/accctrl.d index e967da6ed6..b9a9051fc3 100644 --- a/runtime/druntime/src/core/sys/windows/accctrl.d +++ b/runtime/druntime/src/core/sys/windows/accctrl.d @@ -17,7 +17,7 @@ import core.sys.windows.basetyps, core.sys.windows.w32api, core.sys.windows.winb // FIXME: check types and grouping of constants // FIXME: check Windows version support -alias LocalFree AccFree; +alias AccFree = LocalFree; enum uint ACTRL_RESERVED = 0x00000000, @@ -133,8 +133,8 @@ enum uint INHERITED_PARENT = 0x10000000, INHERITED_GRANDPARENT = 0x20000000; -alias ULONG INHERIT_FLAGS, ACCESS_RIGHTS; -alias ULONG* PINHERIT_FLAGS, PACCESS_RIGHTS; +alias INHERIT_FLAGS = ULONG, ACCESS_RIGHTS = ULONG; +alias PINHERIT_FLAGS = ULONG*, PACCESS_RIGHTS = ULONG*; enum ACCESS_MODE { NOT_USED_ACCESS, @@ -194,8 +194,8 @@ struct TRUSTEE_A { TRUSTEE_TYPE TrusteeType; LPSTR ptstrName; } -alias TRUSTEE_A TRUSTEEA; -alias TRUSTEE_A* PTRUSTEE_A, PTRUSTEEA; +alias TRUSTEEA = TRUSTEE_A; +alias PTRUSTEE_A = TRUSTEE_A*, PTRUSTEEA = TRUSTEE_A*; struct TRUSTEE_W { TRUSTEE_W* pMultipleTrustee; @@ -204,8 +204,8 @@ struct TRUSTEE_W { TRUSTEE_TYPE TrusteeType; LPWSTR ptstrName; } -alias TRUSTEE_W TRUSTEEW; -alias TRUSTEEW* PTRUSTEE_W, PTRUSTEEW; +alias TRUSTEEW = TRUSTEE_W; +alias PTRUSTEE_W = TRUSTEEW*, PTRUSTEEW = TRUSTEEW*; struct ACTRL_ACCESS_ENTRYA { TRUSTEE_A Trustee; @@ -215,7 +215,7 @@ struct ACTRL_ACCESS_ENTRYA { INHERIT_FLAGS Inheritance; LPCSTR lpInheritProperty; } -alias ACTRL_ACCESS_ENTRYA* PACTRL_ACCESS_ENTRYA; +alias PACTRL_ACCESS_ENTRYA = ACTRL_ACCESS_ENTRYA*; struct ACTRL_ACCESS_ENTRYW { TRUSTEE_W Trustee; @@ -225,47 +225,47 @@ struct ACTRL_ACCESS_ENTRYW { INHERIT_FLAGS Inheritance; LPCWSTR lpInheritProperty; } -alias ACTRL_ACCESS_ENTRYW* PACTRL_ACCESS_ENTRYW; +alias PACTRL_ACCESS_ENTRYW = ACTRL_ACCESS_ENTRYW*; struct ACTRL_ACCESS_ENTRY_LISTA { ULONG cEntries; ACTRL_ACCESS_ENTRYA* pAccessList; } -alias ACTRL_ACCESS_ENTRY_LISTA* PACTRL_ACCESS_ENTRY_LISTA; +alias PACTRL_ACCESS_ENTRY_LISTA = ACTRL_ACCESS_ENTRY_LISTA*; struct ACTRL_ACCESS_ENTRY_LISTW { ULONG cEntries; ACTRL_ACCESS_ENTRYW* pAccessList; } -alias ACTRL_ACCESS_ENTRY_LISTW* PACTRL_ACCESS_ENTRY_LISTW; +alias PACTRL_ACCESS_ENTRY_LISTW = ACTRL_ACCESS_ENTRY_LISTW*; struct ACTRL_PROPERTY_ENTRYA { LPCSTR lpProperty; PACTRL_ACCESS_ENTRY_LISTA pAccessEntryList; ULONG fListFlags; } -alias ACTRL_PROPERTY_ENTRYA* PACTRL_PROPERTY_ENTRYA; +alias PACTRL_PROPERTY_ENTRYA = ACTRL_PROPERTY_ENTRYA*; struct ACTRL_PROPERTY_ENTRYW { LPCWSTR lpProperty; PACTRL_ACCESS_ENTRY_LISTW pAccessEntryList; ULONG fListFlags; } -alias ACTRL_PROPERTY_ENTRYW* PACTRL_PROPERTY_ENTRYW; +alias PACTRL_PROPERTY_ENTRYW = ACTRL_PROPERTY_ENTRYW*; struct ACTRL_ACCESSA { ULONG cEntries; PACTRL_PROPERTY_ENTRYA pPropertyAccessList; } -alias ACTRL_ACCESSA ACTRL_AUDITA; -alias ACTRL_ACCESSA* PACTRL_ACCESSA, PACTRL_AUDITA; +alias ACTRL_AUDITA = ACTRL_ACCESSA; +alias PACTRL_ACCESSA = ACTRL_ACCESSA*, PACTRL_AUDITA = ACTRL_ACCESSA*; struct ACTRL_ACCESSW { ULONG cEntries; PACTRL_PROPERTY_ENTRYW pPropertyAccessList; } -alias ACTRL_ACCESSW ACTRL_AUDITW; -alias ACTRL_ACCESSW* PACTRL_ACCESSW, PACTRL_AUDITW; +alias ACTRL_AUDITW = ACTRL_ACCESSW; +alias PACTRL_ACCESSW = ACTRL_ACCESSW*, PACTRL_AUDITW = ACTRL_ACCESSW*; struct TRUSTEE_ACCESSA { LPSTR lpProperty; @@ -273,7 +273,7 @@ struct TRUSTEE_ACCESSA { ULONG fAccessFlags; ULONG fReturnedAccess; } -alias TRUSTEE_ACCESSA* PTRUSTEE_ACCESSA; +alias PTRUSTEE_ACCESSA = TRUSTEE_ACCESSA*; struct TRUSTEE_ACCESSW { LPWSTR lpProperty; @@ -281,7 +281,7 @@ struct TRUSTEE_ACCESSW { ULONG fAccessFlags; ULONG fReturnedAccess; } -alias TRUSTEE_ACCESSW* PTRUSTEE_ACCESSW; +alias PTRUSTEE_ACCESSW = TRUSTEE_ACCESSW*; struct ACTRL_OVERLAPPED { union { @@ -291,31 +291,31 @@ struct ACTRL_OVERLAPPED { ULONG Reserved2; HANDLE hEvent; } -alias ACTRL_OVERLAPPED* PACTRL_OVERLAPPED; +alias PACTRL_OVERLAPPED = ACTRL_OVERLAPPED*; struct ACTRL_ACCESS_INFOA { ULONG fAccessPermission; LPSTR lpAccessPermissionName; } -alias ACTRL_ACCESS_INFOA* PACTRL_ACCESS_INFOA; +alias PACTRL_ACCESS_INFOA = ACTRL_ACCESS_INFOA*; struct ACTRL_ACCESS_INFOW { ULONG fAccessPermission; LPWSTR lpAccessPermissionName; } -alias ACTRL_ACCESS_INFOW* PACTRL_ACCESS_INFOW; +alias PACTRL_ACCESS_INFOW = ACTRL_ACCESS_INFOW*; struct ACTRL_CONTROL_INFOA { LPSTR lpControlId; LPSTR lpControlName; } -alias ACTRL_CONTROL_INFOA* PACTRL_CONTROL_INFOA; +alias PACTRL_CONTROL_INFOA = ACTRL_CONTROL_INFOA*; struct ACTRL_CONTROL_INFOW { LPWSTR lpControlId; LPWSTR lpControlName; } -alias ACTRL_CONTROL_INFOW* PACTRL_CONTROL_INFOW; +alias PACTRL_CONTROL_INFOW = ACTRL_CONTROL_INFOW*; struct EXPLICIT_ACCESS_A { DWORD grfAccessPermissions; @@ -323,8 +323,8 @@ struct EXPLICIT_ACCESS_A { DWORD grfInheritance; TRUSTEE_A Trustee; } -alias EXPLICIT_ACCESS_A EXPLICIT_ACCESSA; -alias EXPLICIT_ACCESS_A* PEXPLICIT_ACCESS_A, PEXPLICIT_ACCESSA; +alias EXPLICIT_ACCESSA = EXPLICIT_ACCESS_A; +alias PEXPLICIT_ACCESS_A = EXPLICIT_ACCESS_A*, PEXPLICIT_ACCESSA = EXPLICIT_ACCESS_A*; struct EXPLICIT_ACCESS_W { DWORD grfAccessPermissions; @@ -332,8 +332,8 @@ struct EXPLICIT_ACCESS_W { DWORD grfInheritance; TRUSTEE_W Trustee; } -alias EXPLICIT_ACCESS_W EXPLICIT_ACCESSW; -alias EXPLICIT_ACCESS_W* PEXPLICIT_ACCESS_W, PEXPLICIT_ACCESSW; +alias EXPLICIT_ACCESSW = EXPLICIT_ACCESS_W; +alias PEXPLICIT_ACCESS_W = EXPLICIT_ACCESS_W*, PEXPLICIT_ACCESSW = EXPLICIT_ACCESS_W*; struct OBJECTS_AND_SID { DWORD ObjectsPresent; @@ -341,7 +341,7 @@ struct OBJECTS_AND_SID { GUID InheritedObjectTypeGuid; SID* pSid; } -alias OBJECTS_AND_SID* POBJECTS_AND_SID; +alias POBJECTS_AND_SID = OBJECTS_AND_SID*; struct OBJECTS_AND_NAME_A { DWORD ObjectsPresent; @@ -350,7 +350,7 @@ struct OBJECTS_AND_NAME_A { LPSTR InheritedObjectTypeName; LPSTR ptstrName; } -alias OBJECTS_AND_NAME_A* POBJECTS_AND_NAME_A; +alias POBJECTS_AND_NAME_A = OBJECTS_AND_NAME_A*; struct OBJECTS_AND_NAME_W { DWORD ObjectsPresent; @@ -359,64 +359,64 @@ struct OBJECTS_AND_NAME_W { LPWSTR InheritedObjectTypeName; LPWSTR ptstrName; } -alias OBJECTS_AND_NAME_W* POBJECTS_AND_NAME_W; +alias POBJECTS_AND_NAME_W = OBJECTS_AND_NAME_W*; static if (_WIN32_WINNT >= 0x501) { struct INHERITED_FROMA { LONG GenerationGap; LPSTR AncestorName; } - alias INHERITED_FROMA* PINHERITED_FROMA; + alias PINHERITED_FROMA = INHERITED_FROMA*; struct INHERITED_FROMW { LONG GenerationGap; LPWSTR AncestorName; } - alias INHERITED_FROMW* PINHERITED_FROMW; + alias PINHERITED_FROMW = INHERITED_FROMW*; } version (Unicode) { - alias TRUSTEEW TRUSTEE; - alias ACTRL_ACCESSW ACTRL_ACCESS; - alias ACTRL_ACCESS_ENTRY_LISTW ACTRL_ACCESS_ENTRY_LIST; - alias ACTRL_ACCESS_INFOW ACTRL_ACCESS_INFO; - alias ACTRL_ACCESS_ENTRYW ACTRL_ACCESS_ENTRY; - alias ACTRL_AUDITW ACTRL_AUDIT; - alias ACTRL_CONTROL_INFOW ACTRL_CONTROL_INFO; - alias EXPLICIT_ACCESSW EXPLICIT_ACCESS; - alias TRUSTEE_ACCESSW TRUSTEE_ACCESS; - alias OBJECTS_AND_NAME_W OBJECTS_AND_NAME_; + alias TRUSTEE = TRUSTEEW; + alias ACTRL_ACCESS = ACTRL_ACCESSW; + alias ACTRL_ACCESS_ENTRY_LIST = ACTRL_ACCESS_ENTRY_LISTW; + alias ACTRL_ACCESS_INFO = ACTRL_ACCESS_INFOW; + alias ACTRL_ACCESS_ENTRY = ACTRL_ACCESS_ENTRYW; + alias ACTRL_AUDIT = ACTRL_AUDITW; + alias ACTRL_CONTROL_INFO = ACTRL_CONTROL_INFOW; + alias EXPLICIT_ACCESS = EXPLICIT_ACCESSW; + alias TRUSTEE_ACCESS = TRUSTEE_ACCESSW; + alias OBJECTS_AND_NAME_ = OBJECTS_AND_NAME_W; static if (_WIN32_WINNT >= 0x501) { - alias INHERITED_FROMW INHERITED_FROM; + alias INHERITED_FROM = INHERITED_FROMW; } } else { - alias TRUSTEEA TRUSTEE; - alias ACTRL_ACCESSA ACTRL_ACCESS; - alias ACTRL_ACCESS_ENTRY_LISTA ACTRL_ACCESS_ENTRY_LIST; - alias ACTRL_ACCESS_INFOA ACTRL_ACCESS_INFO; - alias ACTRL_ACCESS_ENTRYA ACTRL_ACCESS_ENTRY; - alias ACTRL_AUDITA ACTRL_AUDIT; - alias ACTRL_CONTROL_INFOA ACTRL_CONTROL_INFO; - alias EXPLICIT_ACCESSA EXPLICIT_ACCESS; - alias TRUSTEE_ACCESSA TRUSTEE_ACCESS; - alias OBJECTS_AND_NAME_A OBJECTS_AND_NAME_; + alias TRUSTEE = TRUSTEEA; + alias ACTRL_ACCESS = ACTRL_ACCESSA; + alias ACTRL_ACCESS_ENTRY_LIST = ACTRL_ACCESS_ENTRY_LISTA; + alias ACTRL_ACCESS_INFO = ACTRL_ACCESS_INFOA; + alias ACTRL_ACCESS_ENTRY = ACTRL_ACCESS_ENTRYA; + alias ACTRL_AUDIT = ACTRL_AUDITA; + alias ACTRL_CONTROL_INFO = ACTRL_CONTROL_INFOA; + alias EXPLICIT_ACCESS = EXPLICIT_ACCESSA; + alias TRUSTEE_ACCESS = TRUSTEE_ACCESSA; + alias OBJECTS_AND_NAME_ = OBJECTS_AND_NAME_A; static if (_WIN32_WINNT >= 0x501) { - alias INHERITED_FROMA INHERITED_FROM; + alias INHERITED_FROM = INHERITED_FROMA; } } -alias TRUSTEE TRUSTEE_; -alias TRUSTEE* PTRUSTEE, PTRUSTEE_; -alias ACTRL_ACCESS* PACTRL_ACCESS; -alias ACTRL_ACCESS_ENTRY_LIST* PACTRL_ACCESS_ENTRY_LIST; -alias ACTRL_ACCESS_INFO* PACTRL_ACCESS_INFO; -alias ACTRL_ACCESS_ENTRY* PACTRL_ACCESS_ENTRY; -alias ACTRL_AUDIT* PACTRL_AUDIT; -alias ACTRL_CONTROL_INFO* PACTRL_CONTROL_INFO; -alias EXPLICIT_ACCESS EXPLICIT_ACCESS_; -alias EXPLICIT_ACCESS* PEXPLICIT_ACCESS, PEXPLICIT_ACCESS_; -alias TRUSTEE_ACCESS* PTRUSTEE_ACCESS; -alias OBJECTS_AND_NAME_* POBJECTS_AND_NAME_; +alias TRUSTEE_ = TRUSTEE; +alias PTRUSTEE = TRUSTEE*, PTRUSTEE_ = TRUSTEE*; +alias PACTRL_ACCESS = ACTRL_ACCESS*; +alias PACTRL_ACCESS_ENTRY_LIST = ACTRL_ACCESS_ENTRY_LIST*; +alias PACTRL_ACCESS_INFO = ACTRL_ACCESS_INFO*; +alias PACTRL_ACCESS_ENTRY = ACTRL_ACCESS_ENTRY*; +alias PACTRL_AUDIT = ACTRL_AUDIT*; +alias PACTRL_CONTROL_INFO = ACTRL_CONTROL_INFO*; +alias EXPLICIT_ACCESS_ = EXPLICIT_ACCESS; +alias PEXPLICIT_ACCESS = EXPLICIT_ACCESS*, PEXPLICIT_ACCESS_ = EXPLICIT_ACCESS*; +alias PTRUSTEE_ACCESS = TRUSTEE_ACCESS*; +alias POBJECTS_AND_NAME_ = OBJECTS_AND_NAME_*; static if (_WIN32_WINNT >= 0x501) { - alias INHERITED_FROM* PINHERITED_FROM; + alias PINHERITED_FROM = INHERITED_FROM*; } diff --git a/runtime/druntime/src/core/sys/windows/aclapi.d b/runtime/druntime/src/core/sys/windows/aclapi.d index 0b9f755ed6..3977aab307 100644 --- a/runtime/druntime/src/core/sys/windows/aclapi.d +++ b/runtime/druntime/src/core/sys/windows/aclapi.d @@ -93,47 +93,45 @@ extern (Windows) nothrow @nogc { } version (Unicode) { - alias BuildExplicitAccessWithNameW BuildExplicitAccessWithName; - alias BuildSecurityDescriptorW BuildSecurityDescriptor; - alias BuildTrusteeWithNameW BuildTrusteeWithName; - alias BuildTrusteeWithObjectsAndNameW BuildTrusteeWithObjectsAndName; - alias BuildTrusteeWithObjectsAndSidW BuildTrusteeWithObjectsAndSid; - alias BuildTrusteeWithSidW BuildTrusteeWithSid; - alias GetAuditedPermissionsFromAclW GetAuditedPermissionsFromAcl; - alias GetEffectiveRightsFromAclW GetEffectiveRightsFromAcl; - alias GetExplicitEntriesFromAclW GetExplicitEntriesFromAcl; - alias GetNamedSecurityInfoW GetNamedSecurityInfo; - alias GetTrusteeFormW GetTrusteeForm; - alias GetTrusteeNameW GetTrusteeName; - alias GetTrusteeTypeW GetTrusteeType; - alias LookupSecurityDescriptorPartsW LookupSecurityDescriptorParts; - alias SetEntriesInAclW SetEntriesInAcl; - alias SetNamedSecurityInfoW SetNamedSecurityInfo; - alias BuildImpersonateExplicitAccessWithNameW - BuildImpersonateExplicitAccessWithName; - alias BuildImpersonateTrusteeW BuildImpersonateTrustee; - alias GetMultipleTrusteeW GetMultipleTrustee; - alias GetMultipleTrusteeOperationW GetMultipleTrusteeOperation; + alias BuildExplicitAccessWithName = BuildExplicitAccessWithNameW; + alias BuildSecurityDescriptor = BuildSecurityDescriptorW; + alias BuildTrusteeWithName = BuildTrusteeWithNameW; + alias BuildTrusteeWithObjectsAndName = BuildTrusteeWithObjectsAndNameW; + alias BuildTrusteeWithObjectsAndSid = BuildTrusteeWithObjectsAndSidW; + alias BuildTrusteeWithSid = BuildTrusteeWithSidW; + alias GetAuditedPermissionsFromAcl = GetAuditedPermissionsFromAclW; + alias GetEffectiveRightsFromAcl = GetEffectiveRightsFromAclW; + alias GetExplicitEntriesFromAcl = GetExplicitEntriesFromAclW; + alias GetNamedSecurityInfo = GetNamedSecurityInfoW; + alias GetTrusteeForm = GetTrusteeFormW; + alias GetTrusteeName = GetTrusteeNameW; + alias GetTrusteeType = GetTrusteeTypeW; + alias LookupSecurityDescriptorParts = LookupSecurityDescriptorPartsW; + alias SetEntriesInAcl = SetEntriesInAclW; + alias SetNamedSecurityInfo = SetNamedSecurityInfoW; + alias BuildImpersonateExplicitAccessWithName = BuildImpersonateExplicitAccessWithNameW; + alias BuildImpersonateTrustee = BuildImpersonateTrusteeW; + alias GetMultipleTrustee = GetMultipleTrusteeW; + alias GetMultipleTrusteeOperation = GetMultipleTrusteeOperationW; } else { - alias BuildExplicitAccessWithNameA BuildExplicitAccessWithName; - alias BuildSecurityDescriptorA BuildSecurityDescriptor; - alias BuildTrusteeWithNameA BuildTrusteeWithName; - alias BuildTrusteeWithObjectsAndNameA BuildTrusteeWithObjectsAndName; - alias BuildTrusteeWithObjectsAndSidA BuildTrusteeWithObjectsAndSid; - alias BuildTrusteeWithSidA BuildTrusteeWithSid; - alias GetAuditedPermissionsFromAclA GetAuditedPermissionsFromAcl; - alias GetEffectiveRightsFromAclA GetEffectiveRightsFromAcl; - alias GetExplicitEntriesFromAclA GetExplicitEntriesFromAcl; - alias GetNamedSecurityInfoA GetNamedSecurityInfo; - alias GetTrusteeFormA GetTrusteeForm; - alias GetTrusteeNameA GetTrusteeName; - alias GetTrusteeTypeA GetTrusteeType; - alias LookupSecurityDescriptorPartsA LookupSecurityDescriptorParts; - alias SetEntriesInAclA SetEntriesInAcl; - alias SetNamedSecurityInfoA SetNamedSecurityInfo; - alias BuildImpersonateExplicitAccessWithNameA - BuildImpersonateExplicitAccessWithName; - alias BuildImpersonateTrusteeA BuildImpersonateTrustee; - alias GetMultipleTrusteeA GetMultipleTrustee; - alias GetMultipleTrusteeOperationA GetMultipleTrusteeOperation; + alias BuildExplicitAccessWithName = BuildExplicitAccessWithNameA; + alias BuildSecurityDescriptor = BuildSecurityDescriptorA; + alias BuildTrusteeWithName = BuildTrusteeWithNameA; + alias BuildTrusteeWithObjectsAndName = BuildTrusteeWithObjectsAndNameA; + alias BuildTrusteeWithObjectsAndSid = BuildTrusteeWithObjectsAndSidA; + alias BuildTrusteeWithSid = BuildTrusteeWithSidA; + alias GetAuditedPermissionsFromAcl = GetAuditedPermissionsFromAclA; + alias GetEffectiveRightsFromAcl = GetEffectiveRightsFromAclA; + alias GetExplicitEntriesFromAcl = GetExplicitEntriesFromAclA; + alias GetNamedSecurityInfo = GetNamedSecurityInfoA; + alias GetTrusteeForm = GetTrusteeFormA; + alias GetTrusteeName = GetTrusteeNameA; + alias GetTrusteeType = GetTrusteeTypeA; + alias LookupSecurityDescriptorParts = LookupSecurityDescriptorPartsA; + alias SetEntriesInAcl = SetEntriesInAclA; + alias SetNamedSecurityInfo = SetNamedSecurityInfoA; + alias BuildImpersonateExplicitAccessWithName = BuildImpersonateExplicitAccessWithNameA; + alias BuildImpersonateTrustee = BuildImpersonateTrusteeA; + alias GetMultipleTrustee = GetMultipleTrusteeA; + alias GetMultipleTrusteeOperation = GetMultipleTrusteeOperationA; } diff --git a/runtime/druntime/src/core/sys/windows/aclui.d b/runtime/druntime/src/core/sys/windows/aclui.d index d7db31738f..58cd8df7c7 100644 --- a/runtime/druntime/src/core/sys/windows/aclui.d +++ b/runtime/druntime/src/core/sys/windows/aclui.d @@ -30,7 +30,7 @@ struct SI_OBJECT_INFO { LPWSTR pszPageTitle; GUID guidObjectType; } -alias SI_OBJECT_INFO* PSI_OBJECT_INFO; +alias PSI_OBJECT_INFO = SI_OBJECT_INFO*; // values for SI_OBJECT_INFO.dwFlags enum DWORD @@ -66,7 +66,7 @@ const(GUID)* pguid; LPCWSTR pszName; DWORD dwFlags; } -alias SI_ACCESS* PSI_ACCESS; +alias PSI_ACCESS = SI_ACCESS*; // values for SI_ACCESS.dwFlags enum DWORD @@ -81,7 +81,7 @@ const(GUID)* pguid; ULONG dwFlags; LPCWSTR pszName; } -alias SI_INHERIT_TYPE* PSI_INHERIT_TYPE; +alias PSI_INHERIT_TYPE = SI_INHERIT_TYPE*; /* values for SI_INHERIT_TYPE.dwFlags INHERIT_ONLY_ACE, CONTAINER_INHERIT_ACE, OBJECT_INHERIT_ACE @@ -105,7 +105,7 @@ interface ISecurityInformation : IUnknown { HRESULT GetInheritTypes(PSI_INHERIT_TYPE*, ULONG*); HRESULT PropertySheetPageCallback(HWND, UINT, SI_PAGE_TYPE); } -alias ISecurityInformation LPSECURITYINFO; +alias LPSECURITYINFO = ISecurityInformation; /* Comment from MinGW * TODO: ISecurityInformation2, IEffectivePermission, ISecurityObjectTypeInfo diff --git a/runtime/druntime/src/core/sys/windows/basetsd.d b/runtime/druntime/src/core/sys/windows/basetsd.d index d06bc5744e..ab131f4e02 100644 --- a/runtime/druntime/src/core/sys/windows/basetsd.d +++ b/runtime/druntime/src/core/sys/windows/basetsd.d @@ -15,7 +15,7 @@ version (Windows): // import. alias HANDLE = void*; -alias HANDLE* PHANDLE, LPHANDLE; +alias PHANDLE = HANDLE*, LPHANDLE = HANDLE*; // helper for aligned structs // alignVal 0 means the default align. @@ -32,17 +32,17 @@ version (CoreUnittest) { } version (Win64) { - alias long __int3264; + alias __int3264 = long; enum ulong ADDRESS_TAG_BIT = 0x40000000000; - alias long INT_PTR, LONG_PTR; - alias long* PINT_PTR, PLONG_PTR; - alias ulong UINT_PTR, ULONG_PTR, HANDLE_PTR; - alias ulong* PUINT_PTR, PULONG_PTR; - alias int HALF_PTR; - alias int* PHALF_PTR; - alias uint UHALF_PTR; - alias uint* PUHALF_PTR; + alias INT_PTR = long, LONG_PTR = long; + alias PINT_PTR = long*, PLONG_PTR = long*; + alias UINT_PTR = ulong, ULONG_PTR = ulong, HANDLE_PTR = ulong; + alias PUINT_PTR = ulong*, PULONG_PTR = ulong*; + alias HALF_PTR = int; + alias PHALF_PTR = int*; + alias UHALF_PTR = uint; + alias PUHALF_PTR = uint*; uint HandleToULong()(void* h) { return(cast(uint) cast(ULONG_PTR) h); } int HandleToLong()(void* h) { return(cast(int) cast(LONG_PTR) h); } @@ -60,17 +60,17 @@ enum ulong ADDRESS_TAG_BIT = 0x40000000000; void* ULongToPtr()(uint ul) { return(cast(void*) cast(ULONG_PTR) ul); } } else { - alias int __int3264; + alias __int3264 = int; enum uint ADDRESS_TAG_BIT = 0x80000000; - alias int INT_PTR, LONG_PTR; - alias int* PINT_PTR, PLONG_PTR; - alias uint UINT_PTR, ULONG_PTR, HANDLE_PTR; - alias uint* PUINT_PTR, PULONG_PTR; - alias short HALF_PTR; - alias short* PHALF_PTR; - alias ushort UHALF_PTR; - alias ushort* PUHALF_PTR; + alias INT_PTR = int, LONG_PTR = int; + alias PINT_PTR = int*, PLONG_PTR = int*; + alias UINT_PTR = uint, ULONG_PTR = uint, HANDLE_PTR = uint; + alias PUINT_PTR = uint*, PULONG_PTR = uint*; + alias HALF_PTR = short; + alias PHALF_PTR = short*; + alias UHALF_PTR = ushort; + alias PUHALF_PTR = ushort*; uint HandleToUlong()(HANDLE h) { return cast(uint) h; } int HandleToLong()(HANDLE h) { return cast(int) h; } @@ -82,11 +82,11 @@ enum uint ADDRESS_TAG_BIT = 0x80000000; short PtrToShort(const(void)* p) { return cast(short) p; } void* IntToPtr()(int i) { return cast(void*) i; } void* UIntToPtr()(uint ui) { return cast(void*) ui; } - alias IntToPtr LongToPtr; - alias UIntToPtr ULongToPtr; + alias LongToPtr = IntToPtr; + alias ULongToPtr = UIntToPtr; } -alias UIntToPtr UintToPtr, UlongToPtr; +alias UintToPtr = UIntToPtr, UlongToPtr = UIntToPtr; enum : UINT_PTR { MAXUINT_PTR = UINT_PTR.max @@ -115,27 +115,27 @@ enum : HALF_PTR { MINHALF_PTR = HALF_PTR.min } -alias byte INT8; -alias byte* PINT8; -alias ubyte UINT8; -alias ubyte* PUINT8; - -alias short INT16; -alias short* PINT16; -alias ushort UINT16; -alias ushort* PUINT16; - -alias int LONG32, INT32; -alias int* PLONG32, PINT32; -alias uint ULONG32, DWORD32, UINT32; -alias uint* PULONG32, PDWORD32, PUINT32; - -alias ULONG_PTR SIZE_T, DWORD_PTR; -alias ULONG_PTR* PSIZE_T, PDWORD_PTR; -alias LONG_PTR SSIZE_T; -alias LONG_PTR* PSSIZE_T; - -alias long LONG64, INT64; -alias long* PLONG64, PINT64; -alias ulong ULONG64, DWORD64, UINT64; -alias ulong* PULONG64, PDWORD64, PUINT64; +alias INT8 = byte; +alias PINT8 = byte*; +alias UINT8 = ubyte; +alias PUINT8 = ubyte*; + +alias INT16 = short; +alias PINT16 = short*; +alias UINT16 = ushort; +alias PUINT16 = ushort*; + +alias LONG32 = int, INT32 = int; +alias PLONG32 = int*, PINT32 = int*; +alias ULONG32 = uint, DWORD32 = uint, UINT32 = uint; +alias PULONG32 = uint*, PDWORD32 = uint*, PUINT32 = uint*; + +alias SIZE_T = ULONG_PTR, DWORD_PTR = ULONG_PTR; +alias PSIZE_T = ULONG_PTR*, PDWORD_PTR = ULONG_PTR*; +alias SSIZE_T = LONG_PTR; +alias PSSIZE_T = LONG_PTR*; + +alias LONG64 = long, INT64 = long; +alias PLONG64 = long*, PINT64 = long*; +alias ULONG64 = ulong, DWORD64 = ulong, UINT64 = ulong; +alias PULONG64 = ulong*, PDWORD64 = ulong*, PUINT64 = ulong*; diff --git a/runtime/druntime/src/core/sys/windows/basetyps.d b/runtime/druntime/src/core/sys/windows/basetyps.d index d90d9f3425..7fd6f647c0 100644 --- a/runtime/druntime/src/core/sys/windows/basetyps.d +++ b/runtime/druntime/src/core/sys/windows/basetyps.d @@ -18,10 +18,10 @@ align(1) struct GUID { // size is 16 WORD Data3; BYTE[8] Data4; } -alias GUID UUID, /*IID, CLSID, */FMTID, uuid_t; +alias UUID = GUID, /*IID, CLSID, */FMTID = GUID, uuid_t = GUID; alias IID = const(GUID); alias CLSID = const(GUID); -alias GUID* LPGUID, LPCLSID, LPIID; -alias const(GUID)* LPCGUID, REFGUID, REFIID, REFCLSID, REFFMTID; -alias uint error_status_t, PROPID; +alias LPGUID = GUID*, LPCLSID = GUID*, LPIID = GUID*; +alias LPCGUID = const(GUID)*, REFGUID = const(GUID)*, REFIID = const(GUID)*, REFCLSID = const(GUID)*, REFFMTID = const(GUID)*; +alias error_status_t = uint, PROPID = uint; diff --git a/runtime/druntime/src/core/sys/windows/comcat.d b/runtime/druntime/src/core/sys/windows/comcat.d index 4cc35f467f..3741149883 100644 --- a/runtime/druntime/src/core/sys/windows/comcat.d +++ b/runtime/druntime/src/core/sys/windows/comcat.d @@ -14,7 +14,7 @@ import core.sys.windows.ole2; import core.sys.windows.basetyps, core.sys.windows.cguid, core.sys.windows.objbase, core.sys.windows.unknwn, core.sys.windows.windef, core.sys.windows.wtypes; -alias IEnumGUID LPENUMGUID; +alias LPENUMGUID = IEnumGUID; interface IEnumGUID : IUnknown { HRESULT Next(ULONG, GUID*, ULONG*); @@ -23,25 +23,25 @@ interface IEnumGUID : IUnknown { HRESULT Clone(LPENUMGUID*); } -alias GUID CATID; -alias REFGUID REFCATID; -alias GUID_NULL CATID_NULL; -alias IsEqualGUID IsEqualCATID; +alias CATID = GUID; +alias REFCATID = REFGUID; +alias CATID_NULL = GUID_NULL; +alias IsEqualCATID = IsEqualGUID; struct CATEGORYINFO { CATID catid; LCID lcid; OLECHAR[128] szDescription = 0; } -alias CATEGORYINFO* LPCATEGORYINFO; +alias LPCATEGORYINFO = CATEGORYINFO*; -alias IEnumGUID IEnumCATID; -alias LPENUMGUID LPENUMCATID; -alias IID_IEnumGUID IID_IEnumCATID; +alias IEnumCATID = IEnumGUID; +alias LPENUMCATID = LPENUMGUID; +alias IID_IEnumCATID = IID_IEnumGUID; -alias IEnumGUID IEnumCLSID; -alias LPENUMGUID LPENUMCLSID; -alias IID_IEnumGUID IID_IEnumCLSID; +alias IEnumCLSID = IEnumGUID; +alias LPENUMCLSID = LPENUMGUID; +alias IID_IEnumCLSID = IID_IEnumGUID; interface ICatInformation : IUnknown { HRESULT EnumCategories(LCID, LPENUMCATEGORYINFO*); @@ -52,7 +52,7 @@ interface ICatInformation : IUnknown { HRESULT EnumImplCategoriesOfClass(REFCLSID, LPENUMCATID*); HRESULT EnumReqCategoriesOfClass(REFCLSID, LPENUMCATID*); } -alias ICatInformation LPCATINFORMATION; +alias LPCATINFORMATION = ICatInformation; interface ICatRegister : IUnknown { HRESULT RegisterCategories(ULONG, CATEGORYINFO*); @@ -62,7 +62,7 @@ interface ICatRegister : IUnknown { HRESULT RegisterClassReqCategories(REFCLSID, ULONG, CATID*); HRESULT UnRegisterClassReqCategories(REFCLSID, ULONG, CATID*); } -alias ICatRegister LPCATREGISTER; +alias LPCATREGISTER = ICatRegister; interface IEnumCATEGORYINFO : IUnknown { HRESULT Next(ULONG, CATEGORYINFO*, ULONG*); @@ -70,4 +70,4 @@ interface IEnumCATEGORYINFO : IUnknown { HRESULT Reset(); HRESULT Clone(LPENUMCATEGORYINFO*); } -alias IEnumCATEGORYINFO LPENUMCATEGORYINFO; +alias LPENUMCATEGORYINFO = IEnumCATEGORYINFO; diff --git a/runtime/druntime/src/core/sys/windows/commctrl.d b/runtime/druntime/src/core/sys/windows/commctrl.d index fcece45be4..c9add615a5 100644 --- a/runtime/druntime/src/core/sys/windows/commctrl.d +++ b/runtime/druntime/src/core/sys/windows/commctrl.d @@ -947,9 +947,9 @@ static if (_WIN32_IE >= 0x400) { // IE4.0 ??? TTM_SETTITLEW // = WM_USER + 33 } static if (_WIN32_IE >= 0x500) { - alias TTM_SETTITLEW TTM_SETTITLE; + alias TTM_SETTITLE = TTM_SETTITLEW; } else { - alias TTM_SETTITLEA TTM_SETTITLE; + alias TTM_SETTITLE = TTM_SETTITLEA; } } @@ -2535,13 +2535,13 @@ static if (_WIN32_IE >= 0x400) { } version (Unicode) { - alias SB_SETTIPTEXTW SB_SETTIPTEXT; - alias SB_GETTIPTEXTW SB_GETTIPTEXT; - alias RB_GETBANDINFOW RB_GETBANDINFO; + alias SB_SETTIPTEXT = SB_SETTIPTEXTW; + alias SB_GETTIPTEXT = SB_GETTIPTEXTW; + alias RB_GETBANDINFO = RB_GETBANDINFOW; } else { - alias SB_SETTIPTEXTA SB_SETTIPTEXT; - alias SB_GETTIPTEXTA SB_GETTIPTEXT; - alias RB_GETBANDINFOA RB_GETBANDINFO; + alias SB_SETTIPTEXT = SB_SETTIPTEXTA; + alias SB_GETTIPTEXT = SB_GETTIPTEXTA; + alias RB_GETBANDINFO = RB_GETBANDINFOA; } } else { enum { @@ -2586,7 +2586,7 @@ static if (_WIN32_WINNT >= 0x501) { NMHDR hdr; DWORD dwFlags; } - alias NMBCHOTITEM* LPNMBCHOTITEM; + alias LPNMBCHOTITEM = NMBCHOTITEM*; } static if (_WIN32_WINNT >= 0x600) { @@ -2628,7 +2628,7 @@ enum HIMAGELIST BCCL_NOGLYPH = cast(HIMAGELIST)-1; UINT uSplitStyle; SIZE size; } - alias BUTTON_SPLITINFO* PBUTTON_SPLITINFO; + alias PBUTTON_SPLITINFO = BUTTON_SPLITINFO*; } enum { @@ -2745,7 +2745,7 @@ struct TBMETRICS { int cxButtonSpacing; int cyButtonSpacing; } -alias TBMETRICS* LPTBMETRICS; +alias LPTBMETRICS = TBMETRICS*; static if (_WIN32_WINNT >= 0x501) { struct TTGETTITLE { @@ -2754,7 +2754,7 @@ static if (_WIN32_WINNT >= 0x501) { UINT cch; WCHAR* pszTitle; } - alias TTGETTITLE* PTTGETTITLE; + alias PTTGETTITLE = TTGETTITLE*; } static if (_WIN32_WINNT >= 0x600) { @@ -2772,7 +2772,7 @@ static if (_WIN32_WINNT >= 0x600) { PWSTR pszName; size_t cchName; } - alias MCGRIDINFO* PMCGRIDINFO; + alias PMCGRIDINFO = MCGRIDINFO*; struct DATETIMEPICKERINFO { @@ -2785,7 +2785,7 @@ static if (_WIN32_WINNT >= 0x600) { HWND hwndUD; HWND hwndDropDown; } - alias DATETIMEPICKERINFO* LPDATETIMEPICKERINFO; + alias LPDATETIMEPICKERINFO = DATETIMEPICKERINFO*; } struct COMBOBOXEXITEMA { @@ -2799,8 +2799,8 @@ struct COMBOBOXEXITEMA { int iIndent; LPARAM lParam; } -alias COMBOBOXEXITEMA* PCOMBOBOXEXITEMA; -alias const(COMBOBOXEXITEMA)* PCCOMBOEXITEMA; +alias PCOMBOBOXEXITEMA = COMBOBOXEXITEMA*; +alias PCCOMBOEXITEMA = const(COMBOBOXEXITEMA)*; struct COMBOBOXEXITEMW { UINT mask; @@ -2813,42 +2813,42 @@ struct COMBOBOXEXITEMW { int iIndent; LPARAM lParam; } -alias COMBOBOXEXITEMW* PCOMBOBOXEXITEMW; -alias const(COMBOBOXEXITEMW)* PCCOMBOEXITEMW; +alias PCOMBOBOXEXITEMW = COMBOBOXEXITEMW*; +alias PCCOMBOEXITEMW = const(COMBOBOXEXITEMW)*; static if (_WIN32_IE >= 0x400) { struct NMCOMBOBOXEXA { NMHDR hdr; COMBOBOXEXITEMA ceItem; } - alias NMCOMBOBOXEXA* PNMCOMBOBOXEXA; + alias PNMCOMBOBOXEXA = NMCOMBOBOXEXA*; struct NMCOMBOBOXEXW { NMHDR hdr; COMBOBOXEXITEMW ceItem; } - alias NMCOMBOBOXEXW* PNMCOMBOBOXEXW; + alias PNMCOMBOBOXEXW = NMCOMBOBOXEXW*; struct NMCBEDRAGBEGINW { NMHDR hdr; int iItemid; WCHAR[CBEMAXSTRLEN] szText = 0; } - alias NMCBEDRAGBEGINW* LPNMCBEDRAGBEGINW, PNMCBEDRAGBEGINW; + alias LPNMCBEDRAGBEGINW = NMCBEDRAGBEGINW*, PNMCBEDRAGBEGINW = NMCBEDRAGBEGINW*; struct NMCBEDRAGBEGINA { NMHDR hdr; int iItemid; char[CBEMAXSTRLEN] szText = 0; } - alias NMCBEDRAGBEGINA* LPNMCBEDRAGBEGINA, PNMCBEDRAGBEGINA; + alias LPNMCBEDRAGBEGINA = NMCBEDRAGBEGINA*, PNMCBEDRAGBEGINA = NMCBEDRAGBEGINA*; struct NMIPADDRESS { NMHDR hdr; int iField; int iValue; } - alias NMIPADDRESS* LPNMIPADDRESS; + alias LPNMIPADDRESS = NMIPADDRESS*; align (1) struct NMLVKEYDOWN { @@ -2857,7 +2857,7 @@ static if (_WIN32_IE >= 0x400) { WORD wVKey; UINT flags; } - alias NMLVKEYDOWN* LPNMLVKEYDOWN; + alias LPNMLVKEYDOWN = NMLVKEYDOWN*; struct NMPGCALCSIZE { NMHDR hdr; @@ -2865,7 +2865,7 @@ static if (_WIN32_IE >= 0x400) { int iWidth; int iHeight; } - alias NMPGCALCSIZE* LPNMPGCALCSIZE; + alias LPNMPGCALCSIZE = NMPGCALCSIZE*; align (1) struct NMPGSCROLL { @@ -2878,14 +2878,14 @@ static if (_WIN32_IE >= 0x400) { int iYpos; int iScroll; } - alias NMPGSCROLL* LPNMPGSCROLL; + alias LPNMPGSCROLL = NMPGSCROLL*; struct NMSELCHANGE { NMHDR nmhdr; SYSTEMTIME stSelStart; SYSTEMTIME stSelEnd; } - alias NMSELCHANGE* LPNMSELCHANGE; + alias LPNMSELCHANGE = NMSELCHANGE*; struct NMTBHOTITEM { NMHDR hdr; @@ -2893,7 +2893,7 @@ static if (_WIN32_IE >= 0x400) { int idNew; DWORD dwFlags; } - alias NMTBHOTITEM* LPNMTBHOTITEM; + alias LPNMTBHOTITEM = NMTBHOTITEM*; struct NMTBDISPINFOA { NMHDR hdr; @@ -2904,7 +2904,7 @@ static if (_WIN32_IE >= 0x400) { LPSTR pszText; int cchText; } - alias NMTBDISPINFOA* LPNMTBDISPINFOA; + alias LPNMTBDISPINFOA = NMTBDISPINFOA*; struct NMTBDISPINFOW { NMHDR hdr; @@ -2915,7 +2915,7 @@ static if (_WIN32_IE >= 0x400) { LPWSTR pszText; int cchText; } - alias NMTBDISPINFOW* LPNMTBDISPINFOW; + alias LPNMTBDISPINFOW = NMTBDISPINFOW*; struct NMTBGETINFOTIPA { NMHDR hdr; @@ -2924,7 +2924,7 @@ static if (_WIN32_IE >= 0x400) { int iItem; LPARAM lParam; } - alias NMTBGETINFOTIPA* LPNMTBGETINFOTIPA; + alias LPNMTBGETINFOTIPA = NMTBGETINFOTIPA*; struct NMTBGETINFOTIPW { NMHDR hdr; @@ -2933,7 +2933,7 @@ static if (_WIN32_IE >= 0x400) { int iItem; LPARAM lParam; } - alias NMTBGETINFOTIPW* LPNMTBGETINFOTIPW; + alias LPNMTBGETINFOTIPW = NMTBGETINFOTIPW*; struct NMMOUSE { NMHDR hdr; @@ -2942,7 +2942,7 @@ static if (_WIN32_IE >= 0x400) { POINT pt; LPARAM dwHitInfo; } - alias NMMOUSE* LPNMMOUSE; + alias LPNMMOUSE = NMMOUSE*; } static if (_WIN32_IE >= 0x401) { @@ -2950,7 +2950,7 @@ static if (_WIN32_IE >= 0x401) { NMHDR hdr; HWND hwndToolTips; } - alias NMTOOLTIPSCREATED* LPNMTOOLTIPSCREATED; + alias LPNMTOOLTIPSCREATED = NMTOOLTIPSCREATED*; } struct NMDATETIMECHANGE { @@ -2958,7 +2958,7 @@ struct NMDATETIMECHANGE { DWORD dwFlags; SYSTEMTIME st; } -alias NMDATETIMECHANGE* LPNMDATETIMECHANGE; +alias LPNMDATETIMECHANGE = NMDATETIMECHANGE*; struct NMCBEENDEDITW { NMHDR hdr; @@ -2967,7 +2967,7 @@ struct NMCBEENDEDITW { WCHAR[CBEMAXSTRLEN] szText = 0; int iWhy; } -alias NMCBEENDEDITW* LPNMCBEENDEDITW, PNMCBEENDEDITW; +alias LPNMCBEENDEDITW = NMCBEENDEDITW*, PNMCBEENDEDITW = NMCBEENDEDITW*; struct NMCBEENDEDITA { NMHDR hdr; @@ -2976,20 +2976,20 @@ struct NMCBEENDEDITA { char[CBEMAXSTRLEN] szText = 0; int iWhy; } -alias NMCBEENDEDITA* LPNMCBEENDEDITA, PNMCBEENDEDITA; +alias LPNMCBEENDEDITA = NMCBEENDEDITA*, PNMCBEENDEDITA = NMCBEENDEDITA*; struct COLORMAP { COLORREF from; COLORREF to; } -alias COLORMAP* LPCOLORMAP; +alias LPCOLORMAP = COLORMAP*; struct DRAGLISTINFO { UINT uNotification; HWND hWnd; POINT ptCursor; } -alias DRAGLISTINFO* LPDRAGLISTINFO; +alias LPDRAGLISTINFO = DRAGLISTINFO*; struct TBBUTTON { int iBitmap; @@ -3004,8 +3004,8 @@ struct TBBUTTON { DWORD_PTR dwData; INT_PTR iString; } -alias TBBUTTON* PTBBUTTON, LPTBBUTTON; -alias const(TBBUTTON)* LPCTBBUTTON; +alias PTBBUTTON = TBBUTTON*, LPTBBUTTON = TBBUTTON*; +alias LPCTBBUTTON = const(TBBUTTON)*; static if (_WIN32_IE >= 0x400) { struct TBBUTTONINFOA { @@ -3020,7 +3020,7 @@ static if (_WIN32_IE >= 0x400) { LPSTR pszText; int cchText; } - alias TBBUTTONINFOA* LPTBBUTTONINFOA; + alias LPTBBUTTONINFOA = TBBUTTONINFOA*; struct TBBUTTONINFOW { UINT cbSize = TBBUTTONINFOW.sizeof; @@ -3034,13 +3034,13 @@ static if (_WIN32_IE >= 0x400) { LPWSTR pszText; int cchText; } - alias TBBUTTONINFOW* LPTBBUTTONINFOW; + alias LPTBBUTTONINFOW = TBBUTTONINFOW*; struct TBINSERTMARK { int iButton; DWORD dwFlags; } - alias TBINSERTMARK* LPTBINSERTMARK; + alias LPTBINSERTMARK = TBINSERTMARK*; struct LVBKIMAGEA { ULONG ulFlags; @@ -3050,7 +3050,7 @@ static if (_WIN32_IE >= 0x400) { int xOffsetPercent; int yOffsetPercent; } - alias LVBKIMAGEA* LPLVBKIMAGEA; + alias LPLVBKIMAGEA = LVBKIMAGEA*; struct LVBKIMAGEW { ULONG ulFlags; @@ -3060,7 +3060,7 @@ static if (_WIN32_IE >= 0x400) { int xOffsetPercent; int yOffsetPercent; } - alias LVBKIMAGEW* LPLVBKIMAGEW; + alias LPLVBKIMAGEW = LVBKIMAGEW*; } /*struct TBNOTIFY { @@ -3086,7 +3086,7 @@ struct IMAGEINFO { int Unused2; RECT rcImage; } -alias IMAGEINFO* LPIMAGEINFO; +alias LPIMAGEINFO = IMAGEINFO*; static if (_WIN32_IE >= 0x500) { struct HDITEMA { @@ -3161,12 +3161,12 @@ static if (_WIN32_IE >= 0x500) { LPARAM lParam; } } -alias HDITEMA* LPHDITEMA; -alias HDITEMW* LPHDITEMW; +alias LPHDITEMA = HDITEMA*; +alias LPHDITEMW = HDITEMW*; deprecated { - alias HDITEMA HD_ITEMA; - alias HDITEMW HD_ITEMW; + alias HD_ITEMA = HDITEMA; + alias HD_ITEMW = HDITEMW; //alias HDITEM HD_ITEM; fixme } @@ -3174,15 +3174,15 @@ struct HD_LAYOUT { RECT* prc; WINDOWPOS* pwpos; } -alias HD_LAYOUT* LPHDLAYOUT; -deprecated alias HD_LAYOUT HDLAYOUT; +alias LPHDLAYOUT = HD_LAYOUT*; +deprecated alias HDLAYOUT = HD_LAYOUT; struct HD_HITTESTINFO { POINT pt; UINT flags; int iItem; } -alias HD_HITTESTINFO* LPHDHITTESTINFO; +alias LPHDHITTESTINFO = HD_HITTESTINFO*; struct HD_NOTIFYA { NMHDR hdr; @@ -3207,7 +3207,7 @@ struct NMHEADERA { int iButton; HDITEMA* pitem; } -alias NMHEADERA* LPNMHEADERA; +alias LPNMHEADERA = NMHEADERA*; struct NMHEADERW { NMHDR hdr; @@ -3215,14 +3215,14 @@ struct NMHEADERW { int iButton; HDITEMW* pitem; } -alias NMHEADERW* LPNMHEADERW; +alias LPNMHEADERW = NMHEADERW*; version (Unicode) { - alias NMHEADERW NMHEADER; - alias LPNMHEADERW LPNMHEADER; + alias NMHEADER = NMHEADERW; + alias LPNMHEADER = LPNMHEADERW; } else { - alias NMHEADERA NMHEADER; - alias LPNMHEADERA LPNMHEADER; + alias NMHEADER = NMHEADERA; + alias LPNMHEADER = LPNMHEADERA; } // End FIXME @@ -3235,7 +3235,7 @@ struct NMHDDISPINFOA { int iImage; LPARAM lParam; } -alias NMHDDISPINFOA* LPNMHDDISPINFOA; +alias LPNMHDDISPINFOA = NMHDDISPINFOA*; struct NMHDDISPINFOW { NMHDR hdr; @@ -3246,7 +3246,7 @@ struct NMHDDISPINFOW { int iImage; LPARAM lParam; } -alias NMHDDISPINFOW* LPNMHDDISPINFOW; +alias LPNMHDDISPINFOW = NMHDDISPINFOW*; struct NMCUSTOMDRAW { NMHDR hdr; @@ -3257,7 +3257,7 @@ struct NMCUSTOMDRAW { UINT uItemState; LPARAM lItemlParam; } -alias NMCUSTOMDRAW* LPNMCUSTOMDRAW; +alias LPNMCUSTOMDRAW = NMCUSTOMDRAW*; static if (_WIN32_IE >= 0x400) { struct NMLVCUSTOMDRAW { @@ -3273,7 +3273,7 @@ static if (_WIN32_IE >= 0x400) { COLORREF clrTextBk; } } -alias NMLVCUSTOMDRAW* LPNMLVCUSTOMDRAW; +alias LPNMLVCUSTOMDRAW = NMLVCUSTOMDRAW*; static if (_WIN32_IE >= 0x400) { struct NMLVGETINFOTIPA { @@ -3285,7 +3285,7 @@ static if (_WIN32_IE >= 0x400) { int iSubItem; LPARAM lParam; } - alias NMLVGETINFOTIPA* LPNMLVGETINFOTIPA; + alias LPNMLVGETINFOTIPA = NMLVGETINFOTIPA*; struct NMLVGETINFOTIPW { NMHDR hdr; @@ -3296,7 +3296,7 @@ static if (_WIN32_IE >= 0x400) { int iSubItem; LPARAM lParam; } - alias NMLVGETINFOTIPW* LPNMLVGETINFOTIPW; + alias LPNMLVGETINFOTIPW = NMLVGETINFOTIPW*; } static if (_WIN32_IE >= 0x400) { @@ -3313,7 +3313,7 @@ static if (_WIN32_IE >= 0x400) { COLORREF clrTextBk; } } -alias NMTVCUSTOMDRAW* LPNMTVCUSTOMDRAW; +alias LPNMTVCUSTOMDRAW = NMTVCUSTOMDRAW*; static if (_WIN32_IE >= 0x400) { static if (_WIN32_WINNT >= 0x501) { @@ -3350,7 +3350,7 @@ static if (_WIN32_IE >= 0x400) { int nHLStringBkMode; } } - alias NMTBCUSTOMDRAW* LPNMTBCUSTOMDRAW; + alias LPNMTBCUSTOMDRAW = NMTBCUSTOMDRAW*; struct NMITEMACTIVATE { NMHDR hdr; @@ -3363,14 +3363,14 @@ static if (_WIN32_IE >= 0x400) { LPARAM lParam; UINT uKeyFlags; } - alias NMITEMACTIVATE* LPNMITEMACTIVATE; + alias LPNMITEMACTIVATE = NMITEMACTIVATE*; } struct TBADDBITMAP { HINSTANCE hInst; UINT_PTR nID; } -alias TBADDBITMAP* LPTBADDBITMAP; +alias LPTBADDBITMAP = TBADDBITMAP*; struct TBSAVEPARAMSA { HKEY hkr; @@ -3391,7 +3391,7 @@ struct TBREPLACEBITMAP { UINT_PTR nIDNew; int nButtons; } -alias TBREPLACEBITMAP* LPTBREPLACEBITMAP; +alias LPTBREPLACEBITMAP = TBREPLACEBITMAP*; static if (_WIN32_IE >= 0x500) { struct NMTOOLBARA { @@ -3428,14 +3428,14 @@ static if (_WIN32_IE >= 0x500) { LPWSTR pszText; } } -alias NMTOOLBARA* LPNMTOOLBARA; -alias NMTOOLBARW* LPNMTOOLBARW; +alias LPNMTOOLBARA = NMTOOLBARA*; +alias LPNMTOOLBARW = NMTOOLBARW*; -alias NMTOOLBARA TBNOTIFYA; -alias LPNMTOOLBARA LPTBNOTIFYA; +alias TBNOTIFYA = NMTOOLBARA; +alias LPTBNOTIFYA = LPNMTOOLBARA; -alias NMTOOLBARW TBNOTIFYW; -alias LPNMTOOLBARW LPTBNOTIFYW; +alias TBNOTIFYW = NMTOOLBARW; +alias LPTBNOTIFYW = LPNMTOOLBARW; static if (_WIN32_WINNT >= 0x501) { struct TOOLINFOA { @@ -3522,24 +3522,24 @@ enum size_t TTTOOLINFOA_V1_SIZE = TOOLINFOA.sizeof, TTTOOLINFOW_V1_SIZE = TOOLINFOW.sizeof; } -alias TOOLINFOA TTTOOLINFOA; -alias TOOLINFOW TTTOOLINFOW; -alias TTTOOLINFOA* LPTTTOOLINFOA, PTOOLINFOA, LPTOOLINFOA; -alias TTTOOLINFOW* LPTTTOOLINFOW, PTOOLINFOW, LPTOOLINFOW; +alias TTTOOLINFOA = TOOLINFOA; +alias TTTOOLINFOW = TOOLINFOW; +alias LPTTTOOLINFOA = TTTOOLINFOA*, PTOOLINFOA = TTTOOLINFOA*, LPTOOLINFOA = TTTOOLINFOA*; +alias LPTTTOOLINFOW = TTTOOLINFOW*, PTOOLINFOW = TTTOOLINFOW*, LPTOOLINFOW = TTTOOLINFOW*; struct TTHITTESTINFOA { HWND hwnd; POINT pt; TOOLINFOA ti; } -alias TTHITTESTINFOA* LPTTHITTESTINFOA, LPHITTESTINFOA; +alias LPTTHITTESTINFOA = TTHITTESTINFOA*, LPHITTESTINFOA = TTHITTESTINFOA*; struct TTHITTESTINFOW { HWND hwnd; POINT pt; TOOLINFOW ti; } -alias TTHITTESTINFOW* LPTTHITTESTINFOW, LPHITTESTINFOW; +alias LPTTHITTESTINFOW = TTHITTESTINFOW*, LPHITTESTINFOW = TTHITTESTINFOW*; static if (_WIN32_IE >= 0x300) { struct NMTTDISPINFOA { @@ -3576,29 +3576,29 @@ static if (_WIN32_IE >= 0x300) { UINT uFlags; } } -alias NMTTDISPINFOA* LPNMTTDISPINFOA; -alias NMTTDISPINFOW* LPNMTTDISPINFOW; -alias NMTTDISPINFOA TOOLTIPTEXTA; -alias LPNMTTDISPINFOA LPTOOLTIPTEXTA; -alias NMTTDISPINFOW TOOLTIPTEXTW; -alias LPNMTTDISPINFOW LPTOOLTIPTEXTW; +alias LPNMTTDISPINFOA = NMTTDISPINFOA*; +alias LPNMTTDISPINFOW = NMTTDISPINFOW*; +alias TOOLTIPTEXTA = NMTTDISPINFOA; +alias LPTOOLTIPTEXTA = LPNMTTDISPINFOA; +alias TOOLTIPTEXTW = NMTTDISPINFOW; +alias LPTOOLTIPTEXTW = LPNMTTDISPINFOW; struct UDACCEL { UINT nSec; UINT nInc; } -alias UDACCEL* LPUDACCEL; +alias LPUDACCEL = UDACCEL*; struct NMUPDOWN { NMHDR hdr; int iPos; int iDelta; } -alias NMUPDOWN* LPNMUPDOWN; +alias LPNMUPDOWN = NMUPDOWN*; deprecated { - alias NMUPDOWN NM_UPDOWN; - alias LPNMUPDOWN LPNM_UPDOWN; + alias NM_UPDOWN = NMUPDOWN; + alias LPNM_UPDOWN = LPNMUPDOWN; } static if (_WIN32_WINNT >= 0x501) { @@ -3684,10 +3684,10 @@ static if (_WIN32_WINNT >= 0x501) { LPARAM lParam; } } -alias LVITEMA* LPLVITEMA; -alias LVITEMW* LPLVITEMW; -alias LVITEMA LV_ITEMA; -alias LVITEMW LV_ITEMW; +alias LPLVITEMA = LVITEMA*; +alias LPLVITEMW = LVITEMW*; +alias LV_ITEMA = LVITEMA; +alias LV_ITEMW = LVITEMW; struct LVFINDINFOA { UINT flags; @@ -3705,10 +3705,10 @@ struct LVFINDINFOW { UINT vkDirection; } -alias LVFINDINFOA* LPFINDINFOA; -alias LVFINDINFOA LV_FINDINFOA; -alias LVFINDINFOW* LPFINDINFOW; -alias LVFINDINFOW LV_FINDINFOW; +alias LPFINDINFOA = LVFINDINFOA*; +alias LV_FINDINFOA = LVFINDINFOA; +alias LPFINDINFOW = LVFINDINFOW*; +alias LV_FINDINFOW = LVFINDINFOW; struct NMLVFINDITEMA { NMHDR hdr; @@ -3722,8 +3722,8 @@ struct NMLVFINDITEMW { LVFINDINFOW lvfi; } -alias NMLVFINDITEMA* PNMLVFINDITEMA, LPNMLVFINDITEMA; -alias NMLVFINDITEMW* PNMLVFINDITEMW, LPNMLVFINDITEMW; +alias PNMLVFINDITEMA = NMLVFINDITEMA*, LPNMLVFINDITEMA = NMLVFINDITEMA*; +alias PNMLVFINDITEMW = NMLVFINDITEMW*, LPNMLVFINDITEMW = NMLVFINDITEMW*; static if (_WIN32_IE >= 0x300) { struct LVHITTESTINFO { @@ -3739,8 +3739,8 @@ static if (_WIN32_IE >= 0x300) { int iItem; } } -alias LVHITTESTINFO* LPLVHITTESTINFO; -alias LVHITTESTINFO LV_HITTESTINFO; +alias LPLVHITTESTINFO = LVHITTESTINFO*; +alias LV_HITTESTINFO = LVHITTESTINFO; static if (_WIN32_IE >= 0x300) { struct LVCOLUMNA { @@ -3781,10 +3781,10 @@ static if (_WIN32_IE >= 0x300) { int iSubItem; } } -alias LVCOLUMNA* LPLVCOLUMNA; -alias LVCOLUMNW* LPLVCOLUMNW; -alias LVCOLUMNA LV_COLUMNA; -alias LVCOLUMNW LV_COLUMNW; +alias LPLVCOLUMNA = LVCOLUMNA*; +alias LPLVCOLUMNW = LVCOLUMNW*; +alias LV_COLUMNA = LVCOLUMNA; +alias LV_COLUMNW = LVCOLUMNW; static if (_WIN32_WINNT >= 0x501) { /* SG: The definitions in this static if block are from the MSDN docs. @@ -3818,7 +3818,7 @@ static if (_WIN32_WINNT >= 0x501) { UINT cchSubsetTitle; } } - alias LVGROUP* PLVGROUP; + alias PLVGROUP = LVGROUP*; struct LVGROUPMETRICS { UINT cbSize = LVGROUPMETRICS.sizeof; @@ -3834,7 +3834,7 @@ static if (_WIN32_WINNT >= 0x501) { COLORREF crHeader; COLORREF crFooter; } - alias LVGROUPMETRICS* PLVGROUPMETRICS; + alias PLVGROUPMETRICS = LVGROUPMETRICS*; struct LVINSERTMARK { UINT cbSize = LVINSERTMARK.sizeof; @@ -3842,8 +3842,8 @@ static if (_WIN32_WINNT >= 0x501) { int iItem; DWORD dwReserved; } - alias LVINSERTMARK* PLVINSERTMARK; - alias LVINSERTMARK* LPLVINSERTMARK; + alias PLVINSERTMARK = LVINSERTMARK*; + alias LPLVINSERTMARK = LVINSERTMARK*; struct LVTILEINFO { UINT cbSize = LVTILEINFO.sizeof; @@ -3854,7 +3854,7 @@ static if (_WIN32_WINNT >= 0x501) { int* piColFmt; } } - alias LVTILEINFO* PLVTILEINFO; + alias PLVTILEINFO = LVTILEINFO*; struct LVTILEVIEWINFO { UINT cbSize = LVTILEVIEWINFO.sizeof; @@ -3864,16 +3864,16 @@ static if (_WIN32_WINNT >= 0x501) { int cLines; RECT rcLabelMargin; } - alias LVTILEVIEWINFO* PLVTILEVIEWINFO; + alias PLVTILEVIEWINFO = LVTILEVIEWINFO*; struct LVINSERTGROUPSORTED { PFNLVGROUPCOMPARE pfnGroupCompare; LPVOID* pvData; LVGROUP lvGroup; } - alias LVINSERTGROUPSORTED* PLVINSERTGROUPSORTED; + alias PLVINSERTGROUPSORTED = LVINSERTGROUPSORTED*; - extern (Windows) alias int function(INT, INT, VOID*) PFNLVGROUPCOMPARE; + extern (Windows) alias PFNLVGROUPCOMPARE = int function(INT, INT, VOID*); struct LVSETINFOTIP { UINT cbSize = LVSETINFOTIP.sizeof; @@ -3883,14 +3883,14 @@ static if (_WIN32_WINNT >= 0x501) { int iSubItem; HBITMAP hbmp; } - alias LVSETINFOTIP* PLVSETINFOTIP; + alias PLVSETINFOTIP = LVSETINFOTIP*; struct BUTTON_IMAGELIST { HIMAGELIST himl; RECT margin; UINT uAlign; } - alias BUTTON_IMAGELIST* PBUTTON_IMAGELIST; + alias PBUTTON_IMAGELIST = BUTTON_IMAGELIST*; } static if (_WIN32_WINNT >= 0x600) { @@ -3899,7 +3899,7 @@ static if (_WIN32_WINNT >= 0x600) { int iItem; int iGroup; } - alias LVITEMINDEX* PLVITEMINDEX; + alias PLVITEMINDEX = LVITEMINDEX*; struct LVFOOTERINFO { @@ -3908,7 +3908,7 @@ static if (_WIN32_WINNT >= 0x600) { int cchTextMax; UINT cItems; } - alias LVFOOTERINFO* LPLVFOOTERINFO; + alias LPLVFOOTERINFO = LVFOOTERINFO*; struct LVFOOTERITEM { @@ -3919,15 +3919,15 @@ static if (_WIN32_WINNT >= 0x600) { UINT state; UINT stateMask; } - alias LVFOOTERITEM *LPLVFOOTERITEM; + alias LPLVFOOTERITEM = LVFOOTERITEM *; - alias UINT TVITEMPART; + alias TVITEMPART = UINT; enum { TVGIPR_BUTTON = 0x0001, } } -extern (Windows) alias int function(LPARAM, LPARAM, LPARAM) PFNLVCOMPARE; +extern (Windows) alias PFNLVCOMPARE = int function(LPARAM, LPARAM, LPARAM); struct NMLISTVIEW { NMHDR hdr; @@ -3939,26 +3939,26 @@ struct NMLISTVIEW { POINT ptAction; LPARAM lParam; } -alias NMLISTVIEW* LPNMLISTVIEW; +alias LPNMLISTVIEW = NMLISTVIEW*; deprecated { - alias NMLISTVIEW NM_LISTVIEW; - alias LPNMLISTVIEW LPNM_LISTVIEW; + alias NM_LISTVIEW = NMLISTVIEW; + alias LPNM_LISTVIEW = LPNMLISTVIEW; } struct NMLVDISPINFOA { NMHDR hdr; LV_ITEMA item; } -alias NMLVDISPINFOA* LPNMLVDISPINFOA; -alias NMLVDISPINFOA LV_DISPINFOA; +alias LPNMLVDISPINFOA = NMLVDISPINFOA*; +alias LV_DISPINFOA = NMLVDISPINFOA; struct NMLVDISPINFOW { NMHDR hdr; LV_ITEMW item; } -alias NMLVDISPINFOW* LPNMLVDISPINFOW; -alias NMLVDISPINFOW LV_DISPINFOW; +alias LPNMLVDISPINFOW = NMLVDISPINFOW*; +alias LV_DISPINFOW = NMLVDISPINFOW; align (1) struct LV_KEYDOWN { @@ -3973,8 +3973,8 @@ struct NMLVCACHEHINT { int iFrom; int iTo; } -alias NMLVCACHEHINT* LPNMLVCACHEHINT, PNM_CACHEHINT, LPNM_CACHEHINT; -alias NMLVCACHEHINT NM_CACHEHINT; +alias LPNMLVCACHEHINT = NMLVCACHEHINT*, PNM_CACHEHINT = NMLVCACHEHINT*, LPNM_CACHEHINT = NMLVCACHEHINT*; +alias NM_CACHEHINT = NMLVCACHEHINT; struct TVITEMA { UINT mask; @@ -3988,8 +3988,8 @@ struct TVITEMA { int cChildren; LPARAM lParam; } -alias TVITEMA* LPTVITEMA, LPTV_ITEMA; -alias TVITEMA TV_ITEMA; +alias LPTVITEMA = TVITEMA*, LPTV_ITEMA = TVITEMA*; +alias TV_ITEMA = TVITEMA; struct TVITEMW { UINT mask; @@ -4003,8 +4003,8 @@ struct TVITEMW { int cChildren; LPARAM lParam; } -alias TVITEMW* LPTVITEMW, LPTV_ITEMW; -alias TVITEMW TV_ITEMW; +alias LPTVITEMW = TVITEMW*, LPTV_ITEMW = TVITEMW*; +alias TV_ITEMW = TVITEMW; static if (_WIN32_IE >= 0x400) { struct TVITEMEXA { @@ -4020,7 +4020,7 @@ static if (_WIN32_IE >= 0x400) { LPARAM lParam; int iIntegral; } - alias TVITEMEXA* LPTVITEMEXA; + alias LPTVITEMEXA = TVITEMEXA*; struct TVITEMEXW { UINT mask; @@ -4035,7 +4035,7 @@ static if (_WIN32_IE >= 0x400) { LPARAM lParam; int iIntegral; } - alias TVITEMEXW* LPTVITEMEXW; + alias LPTVITEMEXW = TVITEMEXW*; } static if (_WIN32_IE >= 0x400) { @@ -4069,18 +4069,18 @@ static if (_WIN32_IE >= 0x400) { TV_ITEMW item; } } -alias TVINSERTSTRUCTA* LPTVINSERTSTRUCTA, LPTV_INSERTSTRUCTA; -alias TVINSERTSTRUCTA TV_INSERTSTRUCTA; -alias TVINSERTSTRUCTW* LPTVINSERTSTRUCTW, LPTV_INSERTSTRUCTW; -alias TVINSERTSTRUCTW TV_INSERTSTRUCTW; +alias LPTVINSERTSTRUCTA = TVINSERTSTRUCTA*, LPTV_INSERTSTRUCTA = TVINSERTSTRUCTA*; +alias TV_INSERTSTRUCTA = TVINSERTSTRUCTA; +alias LPTVINSERTSTRUCTW = TVINSERTSTRUCTW*, LPTV_INSERTSTRUCTW = TVINSERTSTRUCTW*; +alias TV_INSERTSTRUCTW = TVINSERTSTRUCTW; struct TVHITTESTINFO { POINT pt; UINT flags; HTREEITEM hItem; } -alias TVHITTESTINFO* LPTVHITTESTINFO, LPTV_HITTESTINFO; -alias TVHITTESTINFO TV_HITTESTINFO; +alias LPTVHITTESTINFO = TVHITTESTINFO*, LPTV_HITTESTINFO = TVHITTESTINFO*; +alias TV_HITTESTINFO = TVHITTESTINFO; static if (_WIN32_WINNT >= 0x600) { struct TVGETITEMPARTRECTINFO { @@ -4090,14 +4090,14 @@ static if (_WIN32_WINNT >= 0x600) { } } -extern (Windows) alias int function(LPARAM, LPARAM, LPARAM) PFNTVCOMPARE; +extern (Windows) alias PFNTVCOMPARE = int function(LPARAM, LPARAM, LPARAM); struct TVSORTCB { HTREEITEM hParent; PFNTVCOMPARE lpfnCompare; LPARAM lParam; } -alias TVSORTCB* LPTVSORTCB, LPTV_SORTCB; -alias TVSORTCB TV_SORTCB; +alias LPTVSORTCB = TVSORTCB*, LPTV_SORTCB = TVSORTCB*; +alias TV_SORTCB = TVSORTCB; struct NMTREEVIEWA { NMHDR hdr; @@ -4106,8 +4106,8 @@ struct NMTREEVIEWA { TV_ITEMA itemNew; POINT ptDrag; } -alias NMTREEVIEWA* LPNMTREEVIEWA, LPNM_TREEVIEWA; -alias NMTREEVIEWA NM_TREEVIEWA; +alias LPNMTREEVIEWA = NMTREEVIEWA*, LPNM_TREEVIEWA = NMTREEVIEWA*; +alias NM_TREEVIEWA = NMTREEVIEWA; struct NMTREEVIEWW { NMHDR hdr; @@ -4116,22 +4116,22 @@ struct NMTREEVIEWW { TV_ITEMW itemNew; POINT ptDrag; } -alias NMTREEVIEWW* LPNMTREEVIEWW, LPNM_TREEVIEWW; -alias NMTREEVIEWW NM_TREEVIEWW; +alias LPNMTREEVIEWW = NMTREEVIEWW*, LPNM_TREEVIEWW = NMTREEVIEWW*; +alias NM_TREEVIEWW = NMTREEVIEWW; struct NMTVDISPINFOA { NMHDR hdr; TVITEMA item; } -alias NMTVDISPINFOA* LPNMTVDISPINFOA; -alias NMTVDISPINFOA TV_DISPINFOA; +alias LPNMTVDISPINFOA = NMTVDISPINFOA*; +alias TV_DISPINFOA = NMTVDISPINFOA; struct NMTVDISPINFOW { NMHDR hdr; TVITEMW item; } -alias NMTVDISPINFOW* LPNMTVDISPINFOW; -alias NMTVDISPINFOW TV_DISPINFOW; +alias LPNMTVDISPINFOW = NMTVDISPINFOW*; +alias TV_DISPINFOW = NMTVDISPINFOW; static if (_WIN32_IE >= 0x400) { struct NMTVGETINFOTIPA { @@ -4141,7 +4141,7 @@ static if (_WIN32_IE >= 0x400) { HTREEITEM hItem; LPARAM lParam; } - alias NMTVGETINFOTIPA* LPNMTVGETINFOTIPA; + alias LPNMTVGETINFOTIPA = NMTVGETINFOTIPA*; struct NMTVGETINFOTIPW { NMHDR hdr; @@ -4150,7 +4150,7 @@ static if (_WIN32_IE >= 0x400) { HTREEITEM hItem; LPARAM lParam; } - alias NMTVGETINFOTIPW* LPNMTVGETINFOTIPW; + alias LPNMTVGETINFOTIPW = NMTVGETINFOTIPW*; } align (1) @@ -4220,17 +4220,17 @@ static if (_WIN32_IE >= 0x300) { LPARAM lParam; } } -alias TCITEMA* LPTCITEMA; -alias TCITEMA TC_ITEMA; -alias TCITEMW* LPTCITEMW; -alias TCITEMW TC_ITEMW; +alias LPTCITEMA = TCITEMA*; +alias TC_ITEMA = TCITEMA; +alias LPTCITEMW = TCITEMW*; +alias TC_ITEMW = TCITEMW; struct TCHITTESTINFO { POINT pt; UINT flags; } -alias TCHITTESTINFO* LPTCHITTESTINFO, LPTC_HITTESTINFO; -alias TCHITTESTINFO TC_HITTESTINFO; +alias LPTCHITTESTINFO = TCHITTESTINFO*, LPTC_HITTESTINFO = TCHITTESTINFO*; +alias TC_HITTESTINFO = TCHITTESTINFO; align (1) struct TC_KEYDOWN { @@ -4245,21 +4245,21 @@ static if (_WIN32_IE >= 0x300) { DWORD dwSize = INITCOMMONCONTROLSEX.sizeof; DWORD dwICC; } - alias INITCOMMONCONTROLSEX* LPINITCOMMONCONTROLSEX; + alias LPINITCOMMONCONTROLSEX = INITCOMMONCONTROLSEX*; } struct PBRANGE { int iLow; int iHigh; } -alias PBRANGE* PPBRANGE; +alias PPBRANGE = PBRANGE*; struct COLORSCHEME { DWORD dwSize = COLORSCHEME.sizeof; COLORREF clrBtnHighlight; COLORREF clrBtnShadow; } -alias COLORSCHEME* LPCOLORSCHEME; +alias LPCOLORSCHEME = COLORSCHEME*; struct MCHITTESTINFO { UINT cbSize = MCHITTESTINFO.sizeof; @@ -4267,10 +4267,10 @@ struct MCHITTESTINFO { UINT uHit; SYSTEMTIME st; } -alias MCHITTESTINFO* PMCHITTESTINFO; +alias PMCHITTESTINFO = MCHITTESTINFO*; -alias DWORD MONTHDAYSTATE; -alias MONTHDAYSTATE* LPMONTHDAYSTATE; +alias MONTHDAYSTATE = DWORD; +alias LPMONTHDAYSTATE = MONTHDAYSTATE*; struct NMDAYSTATE { NMHDR nmhdr; @@ -4278,14 +4278,14 @@ struct NMDAYSTATE { int cDayState; LPMONTHDAYSTATE prgDayState; } -alias NMDAYSTATE* LPNMDAYSTATE; +alias LPNMDAYSTATE = NMDAYSTATE*; struct REBARINFO { UINT cbSize = REBARINFO.sizeof; UINT fMask; HIMAGELIST himl; } -alias REBARINFO* LPREBARINFO; +alias LPREBARINFO = REBARINFO*; static if (_WIN32_IE >= 0x400) { struct REBARBANDINFOA { @@ -4378,10 +4378,10 @@ static if (_WIN32_IE >= 0x400) { REBARBANDINFOW_V3_SIZE = REBARBANDINFOW.sizeof } } -alias REBARBANDINFOA* LPREBARBANDINFOA; -alias const(REBARBANDINFOA)* LPCREBARBANDINFOA; -alias REBARBANDINFOW* LPREBARBANDINFOW; -alias const(REBARBANDINFOW)* LPCREBARBANDINFOW; +alias LPREBARBANDINFOA = REBARBANDINFOA*; +alias LPCREBARBANDINFOA = const(REBARBANDINFOA)*; +alias LPREBARBANDINFOW = REBARBANDINFOW*; +alias LPCREBARBANDINFOW = const(REBARBANDINFOW)*; static if (_WIN32_IE >= 0x300) { struct NMLVODSTATECHANGE { @@ -4391,7 +4391,7 @@ static if (_WIN32_IE >= 0x300) { UINT uNewState; UINT uOldState; } - alias NMLVODSTATECHANGE* LPNMLVODSTATECHANGE; + alias LPNMLVODSTATECHANGE = NMLVODSTATECHANGE*; static if (_WIN32_WINNT >= 0x501) { struct IMAGELISTDRAWPARAMS { @@ -4431,7 +4431,7 @@ static if (_WIN32_IE >= 0x300) { DWORD dwRop; } } - alias IMAGELISTDRAWPARAMS* LPIMAGELISTDRAWPARAMS; + alias LPIMAGELISTDRAWPARAMS = IMAGELISTDRAWPARAMS*; } static if (_WIN32_IE >= 0x400) { @@ -4442,7 +4442,7 @@ static if (_WIN32_IE >= 0x400) { RECT rcChild; RECT rcBand; } - alias NMREBARCHILDSIZE* LPNMREBARCHILDSIZE; + alias LPNMREBARCHILDSIZE = NMREBARCHILDSIZE*; struct NMREBAR { NMHDR hdr; @@ -4452,7 +4452,7 @@ static if (_WIN32_IE >= 0x400) { UINT wID; LPARAM lParam; } - alias NMREBAR* LPNMREBAR; + alias LPNMREBAR = NMREBAR*; struct NMRBAUTOSIZE { NMHDR hdr; @@ -4460,7 +4460,7 @@ static if (_WIN32_IE >= 0x400) { RECT rcTarget; RECT rcActual; } - alias NMRBAUTOSIZE* LPNMRBAUTOSIZE; + alias LPNMRBAUTOSIZE = NMRBAUTOSIZE*; static if (_WIN32_IE >= 0x500) { struct NMREBARCHEVRON { @@ -4471,7 +4471,7 @@ static if (_WIN32_IE >= 0x400) { RECT rc; LPARAM lParamNM; } - alias NMREBARCHEVRON* LPNMREBARCHEVRON; + alias LPNMREBARCHEVRON = NMREBARCHEVRON*; } struct RBHITTESTINFO { @@ -4479,440 +4479,439 @@ static if (_WIN32_IE >= 0x400) { UINT flags; int iBand; } - alias RBHITTESTINFO* LPRBHITTESTINFO; + alias LPRBHITTESTINFO = RBHITTESTINFO*; } alias HDSA = HANDLE; alias HDPA = HANDLE; version (Unicode) { - alias HDITEMW HDITEM; - alias LPHDITEMW LPHDITEM; - alias TOOLINFOW TOOLINFO; - alias TOOLINFOW* PTOOLINFO, LPTOOLINFO; - alias TTHITTESTINFOW TTHITTESTINFO; - alias TTHITTESTINFOW* LPHITTESTINFO, LPTTHITTESTINFO; - alias TOOLTIPTEXTW TOOLTIPTEXT; - alias TOOLTIPTEXTW* LPTOOLTIPTEXT; - alias NMTTDISPINFOW NMTTDISPINFO; - alias NMTTDISPINFOW* LPNMTTDISPINFO; - alias TV_ITEMW TV_ITEM; - alias TV_ITEMW* LPTV_ITEM; - alias TVITEMW TVITEM; - alias TVITEMW* LPTVITEM; + alias HDITEM = HDITEMW; + alias LPHDITEM = LPHDITEMW; + alias TOOLINFO = TOOLINFOW; + alias PTOOLINFO = TOOLINFOW*, LPTOOLINFO = TOOLINFOW*; + alias TTHITTESTINFO = TTHITTESTINFOW; + alias LPHITTESTINFO = TTHITTESTINFOW*, LPTTHITTESTINFO = TTHITTESTINFOW*; + alias TOOLTIPTEXT = TOOLTIPTEXTW; + alias LPTOOLTIPTEXT = TOOLTIPTEXTW*; + alias NMTTDISPINFO = NMTTDISPINFOW; + alias LPNMTTDISPINFO = NMTTDISPINFOW*; + alias TV_ITEM = TV_ITEMW; + alias LPTV_ITEM = TV_ITEMW*; + alias TVITEM = TVITEMW; + alias LPTVITEM = TVITEMW*; static if (_WIN32_IE >= 0x400) { - alias TVITEMEXW TVITEMEX; - alias TVITEMEXW* LPTVITEMEX; - } - - alias TV_INSERTSTRUCTW TV_INSERTSTRUCT; - alias TV_INSERTSTRUCTW* LPTV_INSERTSTRUCT; - alias TVINSERTSTRUCTW TVINSERTSTRUCT; - alias TVINSERTSTRUCTW* LPTVINSERTSTRUCT; - alias NM_TREEVIEWW NM_TREEVIEW; - alias NM_TREEVIEWW* LPNM_TREEVIEW; - alias NMTREEVIEWW NMTREEVIEW; - alias NMTREEVIEWW* LPNMTREEVIEW; - alias NMHDDISPINFOW NMHDDISPINFO; - alias NMHDDISPINFOW* LPNMHDDISPINFO; - - alias ACM_OPENW ACM_OPEN; - alias COMBOBOXEXITEMW COMBOBOXEXITEM; - alias PCOMBOBOXEXITEMW PCOMBOBOXEXITEM; + alias TVITEMEX = TVITEMEXW; + alias LPTVITEMEX = TVITEMEXW*; + } + + alias TV_INSERTSTRUCT = TV_INSERTSTRUCTW; + alias LPTV_INSERTSTRUCT = TV_INSERTSTRUCTW*; + alias TVINSERTSTRUCT = TVINSERTSTRUCTW; + alias LPTVINSERTSTRUCT = TVINSERTSTRUCTW*; + alias NM_TREEVIEW = NM_TREEVIEWW; + alias LPNM_TREEVIEW = NM_TREEVIEWW*; + alias NMTREEVIEW = NMTREEVIEWW; + alias LPNMTREEVIEW = NMTREEVIEWW*; + alias NMHDDISPINFO = NMHDDISPINFOW; + alias LPNMHDDISPINFO = NMHDDISPINFOW*; + + alias ACM_OPEN = ACM_OPENW; + alias COMBOBOXEXITEM = COMBOBOXEXITEMW; + alias PCOMBOBOXEXITEM = PCOMBOBOXEXITEMW; //alias PCCOMBOBOXEXITEMW PCCOMBOBOXEXITEM; fixme - alias CBEM_INSERTITEMW CBEM_INSERTITEM; - alias CBEM_SETITEMW CBEM_SETITEM; - alias CBEM_GETITEMW CBEM_GETITEM; - alias CBEN_ENDEDITW CBEN_ENDEDIT; - alias NMCBEENDEDITW NMCBEENDEDIT; - alias LPNMCBEENDEDITW LPNMCBEENDEDIT; - alias PNMCBEENDEDITW PNMCBEENDEDIT; + alias CBEM_INSERTITEM = CBEM_INSERTITEMW; + alias CBEM_SETITEM = CBEM_SETITEMW; + alias CBEM_GETITEM = CBEM_GETITEMW; + alias CBEN_ENDEDIT = CBEN_ENDEDITW; + alias NMCBEENDEDIT = NMCBEENDEDITW; + alias LPNMCBEENDEDIT = LPNMCBEENDEDITW; + alias PNMCBEENDEDIT = PNMCBEENDEDITW; static if (_WIN32_IE >= 0x400) { - alias NMCOMBOBOXEXW NMCOMBOBOXEX; - alias PNMCOMBOBOXEXW PNMCOMBOBOXEX; - alias CBEN_GETDISPINFOW CBEN_GETDISPINFO; - alias CBEN_DRAGBEGINW CBEN_DRAGBEGIN; - alias NMCBEDRAGBEGINW NMCBEDRAGBEGIN; - alias LPNMCBEDRAGBEGINW LPNMCBEDRAGBEGIN; - alias PNMCBEDRAGBEGINW PNMCBEDRAGBEGIN; - } - - alias SB_GETTEXTW SB_GETTEXT; - alias SB_SETTEXTW SB_SETTEXT; - alias SB_GETTEXTLENGTHW SB_GETTEXTLENGTH; - alias HDM_INSERTITEMW HDM_INSERTITEM; - alias HDM_GETITEMW HDM_GETITEM; - alias HDM_SETITEMW HDM_SETITEM; - alias HDN_ITEMCHANGINGW HDN_ITEMCHANGING; - alias HDN_ITEMCHANGEDW HDN_ITEMCHANGED; - alias HDN_ITEMCLICKW HDN_ITEMCLICK; - alias HDN_ITEMDBLCLICKW HDN_ITEMDBLCLICK; - alias HDN_DIVIDERDBLCLICKW HDN_DIVIDERDBLCLICK; - alias HDN_BEGINTRACKW HDN_BEGINTRACK; - alias HDN_ENDTRACKW HDN_ENDTRACK; - alias HDN_TRACKW HDN_TRACK; + alias NMCOMBOBOXEX = NMCOMBOBOXEXW; + alias PNMCOMBOBOXEX = PNMCOMBOBOXEXW; + alias CBEN_GETDISPINFO = CBEN_GETDISPINFOW; + alias CBEN_DRAGBEGIN = CBEN_DRAGBEGINW; + alias NMCBEDRAGBEGIN = NMCBEDRAGBEGINW; + alias LPNMCBEDRAGBEGIN = LPNMCBEDRAGBEGINW; + alias PNMCBEDRAGBEGIN = PNMCBEDRAGBEGINW; + } + + alias SB_GETTEXT = SB_GETTEXTW; + alias SB_SETTEXT = SB_SETTEXTW; + alias SB_GETTEXTLENGTH = SB_GETTEXTLENGTHW; + alias HDM_INSERTITEM = HDM_INSERTITEMW; + alias HDM_GETITEM = HDM_GETITEMW; + alias HDM_SETITEM = HDM_SETITEMW; + alias HDN_ITEMCHANGING = HDN_ITEMCHANGINGW; + alias HDN_ITEMCHANGED = HDN_ITEMCHANGEDW; + alias HDN_ITEMCLICK = HDN_ITEMCLICKW; + alias HDN_ITEMDBLCLICK = HDN_ITEMDBLCLICKW; + alias HDN_DIVIDERDBLCLICK = HDN_DIVIDERDBLCLICKW; + alias HDN_BEGINTRACK = HDN_BEGINTRACKW; + alias HDN_ENDTRACK = HDN_ENDTRACKW; + alias HDN_TRACK = HDN_TRACKW; static if (_WIN32_IE >= 0x300) { - alias HDN_GETDISPINFOW HDN_GETDISPINFO; + alias HDN_GETDISPINFO = HDN_GETDISPINFOW; } - alias HD_NOTIFYW HD_NOTIFY; - alias TBSAVEPARAMSW TBSAVEPARAMS; - alias TB_GETBUTTONTEXTW TB_GETBUTTONTEXT; - alias TB_SAVERESTOREW TB_SAVERESTORE; - alias TB_ADDSTRINGW TB_ADDSTRING; + alias HD_NOTIFY = HD_NOTIFYW; + alias TBSAVEPARAMS = TBSAVEPARAMSW; + alias TB_GETBUTTONTEXT = TB_GETBUTTONTEXTW; + alias TB_SAVERESTORE = TB_SAVERESTOREW; + alias TB_ADDSTRING = TB_ADDSTRINGW; static if (_WIN32_IE >= 0x400) { - alias TBN_GETBUTTONINFOW TBN_GETBUTTONINFO; // fixme - alias TB_GETBUTTONINFOW TB_GETBUTTONINFO; - alias TB_SETBUTTONINFOW TB_SETBUTTONINFO; - alias TB_INSERTBUTTONW TB_INSERTBUTTON; - alias TB_ADDBUTTONSW TB_ADDBUTTONS; - alias TB_MAPACCELERATORW TB_MAPACCELERATOR; - alias TB_GETSTRINGW TB_GETSTRING; - alias TBBUTTONINFOW TBBUTTONINFO; - alias LPTBBUTTONINFOW LPTBBUTTONINFO; - alias TBN_GETDISPINFOW TBN_GETDISPINFO; - alias NMTBDISPINFOW NMTBDISPINFO; - alias LPNMTBDISPINFOW LPNMTBDISPINFO; - alias NMTBGETINFOTIPW NMTBGETINFOTIP; - alias LPNMTBGETINFOTIPW LPNMTBGETINFOTIP; - } - - alias TBNOTIFYW TBNOTIFY; - alias LPTBNOTIFYW LPTBNOTIFY; - alias NMTOOLBARW NMTOOLBAR; - alias LPNMTOOLBARW LPNMTOOLBAR; - alias TTM_ADDTOOLW TTM_ADDTOOL; - alias TTM_DELTOOLW TTM_DELTOOL; - alias TTM_NEWTOOLRECTW TTM_NEWTOOLRECT; - alias TTM_GETTOOLINFOW TTM_GETTOOLINFO; - alias TTM_SETTOOLINFOW TTM_SETTOOLINFO; - alias TTM_HITTESTW TTM_HITTEST; - alias TTM_GETTEXTW TTM_GETTEXT; - alias TTM_UPDATETIPTEXTW TTM_UPDATETIPTEXT; - alias TTM_ENUMTOOLSW TTM_ENUMTOOLS; - alias TTM_GETCURRENTTOOLW TTM_GETCURRENTTOOL; - alias TTN_NEEDTEXTW TTN_NEEDTEXT; - alias TTN_GETDISPINFOW TTN_GETDISPINFO; + alias TBN_GETBUTTONINFO = TBN_GETBUTTONINFOW; // fixme + alias TB_GETBUTTONINFO = TB_GETBUTTONINFOW; + alias TB_SETBUTTONINFO = TB_SETBUTTONINFOW; + alias TB_INSERTBUTTON = TB_INSERTBUTTONW; + alias TB_ADDBUTTONS = TB_ADDBUTTONSW; + alias TB_MAPACCELERATOR = TB_MAPACCELERATORW; + alias TB_GETSTRING = TB_GETSTRINGW; + alias TBBUTTONINFO = TBBUTTONINFOW; + alias LPTBBUTTONINFO = LPTBBUTTONINFOW; + alias TBN_GETDISPINFO = TBN_GETDISPINFOW; + alias NMTBDISPINFO = NMTBDISPINFOW; + alias LPNMTBDISPINFO = LPNMTBDISPINFOW; + alias NMTBGETINFOTIP = NMTBGETINFOTIPW; + alias LPNMTBGETINFOTIP = LPNMTBGETINFOTIPW; + } + + alias TBNOTIFY = TBNOTIFYW; + alias LPTBNOTIFY = LPTBNOTIFYW; + alias NMTOOLBAR = NMTOOLBARW; + alias LPNMTOOLBAR = LPNMTOOLBARW; + alias TTM_ADDTOOL = TTM_ADDTOOLW; + alias TTM_DELTOOL = TTM_DELTOOLW; + alias TTM_NEWTOOLRECT = TTM_NEWTOOLRECTW; + alias TTM_GETTOOLINFO = TTM_GETTOOLINFOW; + alias TTM_SETTOOLINFO = TTM_SETTOOLINFOW; + alias TTM_HITTEST = TTM_HITTESTW; + alias TTM_GETTEXT = TTM_GETTEXTW; + alias TTM_UPDATETIPTEXT = TTM_UPDATETIPTEXTW; + alias TTM_ENUMTOOLS = TTM_ENUMTOOLSW; + alias TTM_GETCURRENTTOOL = TTM_GETCURRENTTOOLW; + alias TTN_NEEDTEXT = TTN_NEEDTEXTW; + alias TTN_GETDISPINFO = TTN_GETDISPINFOW; //alias SB_GETTEXTW SB_GETTEXT; //alias SB_SETTEXTW SB_SETTEXT; //alias SB_GETTEXTLENGTHW SB_GETTEXTLENGTH; - alias LV_ITEMW LV_ITEM; - alias LVITEMW LVITEM; - alias LVITEM* LPLVITEM; - alias LPSTR_TEXTCALLBACKW LPSTR_TEXTCALLBACK; + alias LV_ITEM = LV_ITEMW; + alias LVITEM = LVITEMW; + alias LPLVITEM = LVITEM*; + alias LPSTR_TEXTCALLBACK = LPSTR_TEXTCALLBACKW; static if (_WIN32_IE >= 0x400) { - alias LVBKIMAGEW LVBKIMAGE; - alias LPLVBKIMAGEW LPLVBKIMAGE; - alias LVM_SETBKIMAGEW LVM_SETBKIMAGE; - alias LVM_GETBKIMAGEW LVM_GETBKIMAGE; - } - - alias LVM_GETITEMW LVM_GETITEM; - alias LVM_SETITEMW LVM_SETITEM; - alias LVM_INSERTITEMW LVM_INSERTITEM; - alias LV_FINDINFOW LV_FINDINFO; - alias LVFINDINFOW LVFINDINFO; - alias LPFINDINFOW LPFINDINFO; - alias NMLVFINDITEMW NMLVFINDITEM; - alias PNMLVFINDITEMW PNMLVFINDITEM; - alias LPNMLVFINDITEMW LPNMLVFINDITEM; - alias LVM_FINDITEMW LVM_FINDITEM; - alias LVM_GETSTRINGWIDTHW LVM_GETSTRINGWIDTH; - alias LVM_EDITLABELW LVM_EDITLABEL; - alias LV_COLUMNW LV_COLUMN; - alias LVCOLUMNW LVCOLUMN; - alias LVCOLUMNW* LPLVCOLUMN; - alias LVM_GETCOLUMNW LVM_GETCOLUMN; - alias LVM_SETCOLUMNW LVM_SETCOLUMN; - alias LVM_INSERTCOLUMNW LVM_INSERTCOLUMN; - alias LVM_GETITEMTEXTW LVM_GETITEMTEXT; - alias LVM_SETITEMTEXTW LVM_SETITEMTEXT; - alias LVM_GETISEARCHSTRINGW LVM_GETISEARCHSTRING; - alias LVN_BEGINLABELEDITW LVN_BEGINLABELEDIT; - alias LVN_ENDLABELEDITW LVN_ENDLABELEDIT; - alias LVN_GETDISPINFOW LVN_GETDISPINFO; - alias LVN_SETDISPINFOW LVN_SETDISPINFO; + alias LVBKIMAGE = LVBKIMAGEW; + alias LPLVBKIMAGE = LPLVBKIMAGEW; + alias LVM_SETBKIMAGE = LVM_SETBKIMAGEW; + alias LVM_GETBKIMAGE = LVM_GETBKIMAGEW; + } + + alias LVM_GETITEM = LVM_GETITEMW; + alias LVM_SETITEM = LVM_SETITEMW; + alias LVM_INSERTITEM = LVM_INSERTITEMW; + alias LV_FINDINFO = LV_FINDINFOW; + alias LVFINDINFO = LVFINDINFOW; + alias LPFINDINFO = LPFINDINFOW; + alias NMLVFINDITEM = NMLVFINDITEMW; + alias PNMLVFINDITEM = PNMLVFINDITEMW; + alias LPNMLVFINDITEM = LPNMLVFINDITEMW; + alias LVM_FINDITEM = LVM_FINDITEMW; + alias LVM_GETSTRINGWIDTH = LVM_GETSTRINGWIDTHW; + alias LVM_EDITLABEL = LVM_EDITLABELW; + alias LV_COLUMN = LV_COLUMNW; + alias LVCOLUMN = LVCOLUMNW; + alias LPLVCOLUMN = LVCOLUMNW*; + alias LVM_GETCOLUMN = LVM_GETCOLUMNW; + alias LVM_SETCOLUMN = LVM_SETCOLUMNW; + alias LVM_INSERTCOLUMN = LVM_INSERTCOLUMNW; + alias LVM_GETITEMTEXT = LVM_GETITEMTEXTW; + alias LVM_SETITEMTEXT = LVM_SETITEMTEXTW; + alias LVM_GETISEARCHSTRING = LVM_GETISEARCHSTRINGW; + alias LVN_BEGINLABELEDIT = LVN_BEGINLABELEDITW; + alias LVN_ENDLABELEDIT = LVN_ENDLABELEDITW; + alias LVN_GETDISPINFO = LVN_GETDISPINFOW; + alias LVN_SETDISPINFO = LVN_SETDISPINFOW; static if (_WIN32_IE >= 0x400) { - alias LVN_GETINFOTIPW LVN_GETINFOTIP; - alias NMLVGETINFOTIPW NMLVGETINFOTIP; - alias LPNMLVGETINFOTIPW LPNMLVGETINFOTIP; - } - - alias LV_DISPINFOW LV_DISPINFO; - alias NMLVDISPINFOW NMLVDISPINFO; - alias LPNMLVDISPINFOW LPNMLVDISPINFO; - alias TVM_INSERTITEMW TVM_INSERTITEM; - alias TVM_GETITEMW TVM_GETITEM; - alias TVM_SETITEMW TVM_SETITEM; - alias TVM_EDITLABELW TVM_EDITLABEL; - alias TVM_GETISEARCHSTRINGW TVM_GETISEARCHSTRING; - alias NMTVDISPINFOW TV_DISPINFO; - alias NMTVDISPINFOW NMTVDISPINFO; - alias LPNMTVDISPINFOW LPNMTVDISPINFO; + alias LVN_GETINFOTIP = LVN_GETINFOTIPW; + alias NMLVGETINFOTIP = NMLVGETINFOTIPW; + alias LPNMLVGETINFOTIP = LPNMLVGETINFOTIPW; + } + + alias LV_DISPINFO = LV_DISPINFOW; + alias NMLVDISPINFO = NMLVDISPINFOW; + alias LPNMLVDISPINFO = LPNMLVDISPINFOW; + alias TVM_INSERTITEM = TVM_INSERTITEMW; + alias TVM_GETITEM = TVM_GETITEMW; + alias TVM_SETITEM = TVM_SETITEMW; + alias TVM_EDITLABEL = TVM_EDITLABELW; + alias TVM_GETISEARCHSTRING = TVM_GETISEARCHSTRINGW; + alias TV_DISPINFO = NMTVDISPINFOW; + alias NMTVDISPINFO = NMTVDISPINFOW; + alias LPNMTVDISPINFO = LPNMTVDISPINFOW; static if (_WIN32_IE >= 0x400) { - alias NMTVGETINFOTIPW NMTVGETINFOTIP; - alias LPNMTVGETINFOTIPW LPNMTVGETINFOTIP; - alias TVN_GETINFOTIPW TVN_GETINFOTIP; - } - - alias TVN_SELCHANGINGW TVN_SELCHANGING; - alias TVN_SELCHANGEDW TVN_SELCHANGED; - alias TVN_GETDISPINFOW TVN_GETDISPINFO; - alias TVN_SETDISPINFOW TVN_SETDISPINFO; - alias TVN_ITEMEXPANDINGW TVN_ITEMEXPANDING; - alias TVN_ITEMEXPANDEDW TVN_ITEMEXPANDED; - alias TVN_BEGINDRAGW TVN_BEGINDRAG; - alias TVN_BEGINRDRAGW TVN_BEGINRDRAG; - alias TVN_DELETEITEMW TVN_DELETEITEM; - alias TVN_BEGINLABELEDITW TVN_BEGINLABELEDIT; - alias TVN_ENDLABELEDITW TVN_ENDLABELEDIT; - alias TC_ITEMHEADERW TC_ITEMHEADER; - alias TC_ITEMW TC_ITEM; - alias TCITEMW TCITEM; - alias LPTCITEMW LPTCITEM; - alias TCM_GETITEMW TCM_GETITEM; - alias TCM_SETITEMW TCM_SETITEM; - alias TCM_INSERTITEMW TCM_INSERTITEM; - alias CreateStatusWindowW CreateStatusWindow; - alias DrawStatusTextW DrawStatusText; - alias ImageList_LoadImageW ImageList_LoadImage; - alias DTM_SETFORMATW DTM_SETFORMAT; - alias DTN_USERSTRINGW DTN_USERSTRING; - alias DTN_WMKEYDOWNW DTN_WMKEYDOWN; - alias DTN_FORMATW DTN_FORMAT; - alias DTN_FORMATQUERYW DTN_FORMATQUERY; - alias REBARBANDINFOW REBARBANDINFO; - alias REBARBANDINFO* LPREBARBANDINFO; - alias LPCREBARBANDINFOW LPCREBARBANDINFO; - alias REBARBANDINFOW_V3_SIZE REBARBANDINFO_V3_SIZE; - alias RB_INSERTBANDW RB_INSERTBAND; - alias RB_SETBANDINFOW RB_SETBANDINFO; + alias NMTVGETINFOTIP = NMTVGETINFOTIPW; + alias LPNMTVGETINFOTIP = LPNMTVGETINFOTIPW; + alias TVN_GETINFOTIP = TVN_GETINFOTIPW; + } + + alias TVN_SELCHANGING = TVN_SELCHANGINGW; + alias TVN_SELCHANGED = TVN_SELCHANGEDW; + alias TVN_GETDISPINFO = TVN_GETDISPINFOW; + alias TVN_SETDISPINFO = TVN_SETDISPINFOW; + alias TVN_ITEMEXPANDING = TVN_ITEMEXPANDINGW; + alias TVN_ITEMEXPANDED = TVN_ITEMEXPANDEDW; + alias TVN_BEGINDRAG = TVN_BEGINDRAGW; + alias TVN_BEGINRDRAG = TVN_BEGINRDRAGW; + alias TVN_DELETEITEM = TVN_DELETEITEMW; + alias TVN_BEGINLABELEDIT = TVN_BEGINLABELEDITW; + alias TVN_ENDLABELEDIT = TVN_ENDLABELEDITW; + alias TC_ITEMHEADER = TC_ITEMHEADERW; + alias TC_ITEM = TC_ITEMW; + alias TCITEM = TCITEMW; + alias LPTCITEM = LPTCITEMW; + alias TCM_GETITEM = TCM_GETITEMW; + alias TCM_SETITEM = TCM_SETITEMW; + alias TCM_INSERTITEM = TCM_INSERTITEMW; + alias CreateStatusWindow = CreateStatusWindowW; + alias DrawStatusText = DrawStatusTextW; + alias ImageList_LoadImage = ImageList_LoadImageW; + alias DTM_SETFORMAT = DTM_SETFORMATW; + alias DTN_USERSTRING = DTN_USERSTRINGW; + alias DTN_WMKEYDOWN = DTN_WMKEYDOWNW; + alias DTN_FORMAT = DTN_FORMATW; + alias DTN_FORMATQUERY = DTN_FORMATQUERYW; + alias REBARBANDINFO = REBARBANDINFOW; + alias LPREBARBANDINFO = REBARBANDINFO*; + alias LPCREBARBANDINFO = LPCREBARBANDINFOW; + alias REBARBANDINFO_V3_SIZE = REBARBANDINFOW_V3_SIZE; + alias RB_INSERTBAND = RB_INSERTBANDW; + alias RB_SETBANDINFO = RB_SETBANDINFOW; } else { - alias HDITEMA HDITEM; - alias LPHDITEMA LPHDITEM; - alias TOOLINFOA TOOLINFO; - alias TOOLINFOA* PTOOLINFO, LPTOOLINFO; - alias TTHITTESTINFOA TTHITTESTINFO; - alias TTHITTESTINFOA* LPHITTESTINFO, LPTTHITTESTINFO; - alias TOOLTIPTEXTA TOOLTIPTEXT; - alias TOOLTIPTEXTA* LPTOOLTIPTEXT; - alias NMTTDISPINFOA NMTTDISPINFO; - alias NMTTDISPINFOA* LPNMTTDISPINFO; - alias TV_ITEMA TV_ITEM; - alias TV_ITEMA* LPTV_ITEM; - alias TVITEMA TVITEM; - alias TVITEMA* LPTVITEM; + alias HDITEM = HDITEMA; + alias LPHDITEM = LPHDITEMA; + alias TOOLINFO = TOOLINFOA; + alias PTOOLINFO = TOOLINFOA*, LPTOOLINFO = TOOLINFOA*; + alias TTHITTESTINFO = TTHITTESTINFOA; + alias LPHITTESTINFO = TTHITTESTINFOA*, LPTTHITTESTINFO = TTHITTESTINFOA*; + alias TOOLTIPTEXT = TOOLTIPTEXTA; + alias LPTOOLTIPTEXT = TOOLTIPTEXTA*; + alias NMTTDISPINFO = NMTTDISPINFOA; + alias LPNMTTDISPINFO = NMTTDISPINFOA*; + alias TV_ITEM = TV_ITEMA; + alias LPTV_ITEM = TV_ITEMA*; + alias TVITEM = TVITEMA; + alias LPTVITEM = TVITEMA*; static if (_WIN32_IE >= 0x400) { - alias TVITEMEXA TVITEMEX; - alias TVITEMEXA* LPTVITEMEX; - } - - alias TV_INSERTSTRUCTA TV_INSERTSTRUCT; - alias TV_INSERTSTRUCTA* LPTV_INSERTSTRUCT; - alias TVINSERTSTRUCTA TVINSERTSTRUCT; - alias TVINSERTSTRUCTA* LPTVINSERTSTRUCT; - alias NM_TREEVIEWA NM_TREEVIEW; - alias NM_TREEVIEWA* LPNM_TREEVIEW; - alias NMTREEVIEWA NMTREEVIEW; - alias NMTREEVIEWA* LPNMTREEVIEW; - alias NMHDDISPINFOW NMHDDISPINFO; - alias NMHDDISPINFOW* LPNMHDDISPINFO; - - alias ACM_OPENA ACM_OPEN; - alias COMBOBOXEXITEMA COMBOBOXEXITEM; - alias PCOMBOBOXEXITEMA PCOMBOBOXEXITEM; + alias TVITEMEX = TVITEMEXA; + alias LPTVITEMEX = TVITEMEXA*; + } + + alias TV_INSERTSTRUCT = TV_INSERTSTRUCTA; + alias LPTV_INSERTSTRUCT = TV_INSERTSTRUCTA*; + alias TVINSERTSTRUCT = TVINSERTSTRUCTA; + alias LPTVINSERTSTRUCT = TVINSERTSTRUCTA*; + alias NM_TREEVIEW = NM_TREEVIEWA; + alias LPNM_TREEVIEW = NM_TREEVIEWA*; + alias NMTREEVIEW = NMTREEVIEWA; + alias LPNMTREEVIEW = NMTREEVIEWA*; + alias NMHDDISPINFO = NMHDDISPINFOW; + alias LPNMHDDISPINFO = NMHDDISPINFOW*; + + alias ACM_OPEN = ACM_OPENA; + alias COMBOBOXEXITEM = COMBOBOXEXITEMA; + alias PCOMBOBOXEXITEM = PCOMBOBOXEXITEMA; //alias PCCOMBOBOXEXITEMA PCCOMBOBOXEXITEM; fixme - alias CBEM_INSERTITEMA CBEM_INSERTITEM; - alias CBEM_SETITEMA CBEM_SETITEM; - alias CBEM_GETITEMA CBEM_GETITEM; - alias CBEN_ENDEDITA CBEN_ENDEDIT; - alias NMCBEENDEDITA NMCBEENDEDIT; - alias LPNMCBEENDEDITA LPNMCBEENDEDIT; - alias PNMCBEENDEDITA PNMCBEENDEDIT; + alias CBEM_INSERTITEM = CBEM_INSERTITEMA; + alias CBEM_SETITEM = CBEM_SETITEMA; + alias CBEM_GETITEM = CBEM_GETITEMA; + alias CBEN_ENDEDIT = CBEN_ENDEDITA; + alias NMCBEENDEDIT = NMCBEENDEDITA; + alias LPNMCBEENDEDIT = LPNMCBEENDEDITA; + alias PNMCBEENDEDIT = PNMCBEENDEDITA; static if (_WIN32_IE >= 0x400) { - alias TB_GETBUTTONINFOA TB_GETBUTTONINFO; - alias TB_SETBUTTONINFOA TB_SETBUTTONINFO; - alias TB_INSERTBUTTONA TB_INSERTBUTTON; - alias TB_ADDBUTTONSA TB_ADDBUTTONS; - alias TB_MAPACCELERATORA TB_MAPACCELERATOR; - alias TB_GETSTRINGA TB_GETSTRING; - alias NMCOMBOBOXEXA NMCOMBOBOXEX; - alias PNMCOMBOBOXEXA PNMCOMBOBOXEX; - alias CBEN_DRAGBEGINA CBEN_DRAGBEGIN; - alias CBEN_GETDISPINFOA CBEN_GETDISPINFO; - alias NMCBEDRAGBEGINA NMCBEDRAGBEGIN; - alias LPNMCBEDRAGBEGINA LPNMCBEDRAGBEGIN; - alias PNMCBEDRAGBEGINA PNMCBEDRAGBEGIN; - alias TBN_GETDISPINFOA TBN_GETDISPINFO; - alias NMTBDISPINFOA NMTBDISPINFO; - alias LPNMTBDISPINFOA LPNMTBDISPINFO; - alias NMTBGETINFOTIPA NMTBGETINFOTIP; - alias LPNMTBGETINFOTIPA LPNMTBGETINFOTIP; - } - - alias SB_GETTEXTA SB_GETTEXT; - alias SB_SETTEXTA SB_SETTEXT; - alias SB_GETTEXTLENGTHA SB_GETTEXTLENGTH; - alias HDM_INSERTITEMA HDM_INSERTITEM; - alias HDM_GETITEMA HDM_GETITEM; - alias HDM_SETITEMA HDM_SETITEM; - alias HDN_ITEMCHANGINGA HDN_ITEMCHANGING; - alias HDN_ITEMCHANGEDA HDN_ITEMCHANGED; - alias HDN_ITEMCLICKA HDN_ITEMCLICK; - alias HDN_ITEMDBLCLICKA HDN_ITEMDBLCLICK; - alias HDN_DIVIDERDBLCLICKA HDN_DIVIDERDBLCLICK; - alias HDN_BEGINTRACKA HDN_BEGINTRACK; - alias HDN_ENDTRACKA HDN_ENDTRACK; - alias HDN_TRACKA HDN_TRACK; + alias TB_GETBUTTONINFO = TB_GETBUTTONINFOA; + alias TB_SETBUTTONINFO = TB_SETBUTTONINFOA; + alias TB_INSERTBUTTON = TB_INSERTBUTTONA; + alias TB_ADDBUTTONS = TB_ADDBUTTONSA; + alias TB_MAPACCELERATOR = TB_MAPACCELERATORA; + alias TB_GETSTRING = TB_GETSTRINGA; + alias NMCOMBOBOXEX = NMCOMBOBOXEXA; + alias PNMCOMBOBOXEX = PNMCOMBOBOXEXA; + alias CBEN_DRAGBEGIN = CBEN_DRAGBEGINA; + alias CBEN_GETDISPINFO = CBEN_GETDISPINFOA; + alias NMCBEDRAGBEGIN = NMCBEDRAGBEGINA; + alias LPNMCBEDRAGBEGIN = LPNMCBEDRAGBEGINA; + alias PNMCBEDRAGBEGIN = PNMCBEDRAGBEGINA; + alias TBN_GETDISPINFO = TBN_GETDISPINFOA; + alias NMTBDISPINFO = NMTBDISPINFOA; + alias LPNMTBDISPINFO = LPNMTBDISPINFOA; + alias NMTBGETINFOTIP = NMTBGETINFOTIPA; + alias LPNMTBGETINFOTIP = LPNMTBGETINFOTIPA; + } + + alias SB_GETTEXT = SB_GETTEXTA; + alias SB_SETTEXT = SB_SETTEXTA; + alias SB_GETTEXTLENGTH = SB_GETTEXTLENGTHA; + alias HDM_INSERTITEM = HDM_INSERTITEMA; + alias HDM_GETITEM = HDM_GETITEMA; + alias HDM_SETITEM = HDM_SETITEMA; + alias HDN_ITEMCHANGING = HDN_ITEMCHANGINGA; + alias HDN_ITEMCHANGED = HDN_ITEMCHANGEDA; + alias HDN_ITEMCLICK = HDN_ITEMCLICKA; + alias HDN_ITEMDBLCLICK = HDN_ITEMDBLCLICKA; + alias HDN_DIVIDERDBLCLICK = HDN_DIVIDERDBLCLICKA; + alias HDN_BEGINTRACK = HDN_BEGINTRACKA; + alias HDN_ENDTRACK = HDN_ENDTRACKA; + alias HDN_TRACK = HDN_TRACKA; static if (_WIN32_IE >= 0x300) { - alias HDN_GETDISPINFOA HDN_GETDISPINFO; + alias HDN_GETDISPINFO = HDN_GETDISPINFOA; } - alias HD_NOTIFYA HD_NOTIFY; - alias TBSAVEPARAMSA TBSAVEPARAMS; - alias TB_GETBUTTONTEXTA TB_GETBUTTONTEXT; - alias TB_SAVERESTOREA TB_SAVERESTORE; - alias TB_ADDSTRINGA TB_ADDSTRING; - alias TBN_GETBUTTONINFOA TBN_GETBUTTONINFO; + alias HD_NOTIFY = HD_NOTIFYA; + alias TBSAVEPARAMS = TBSAVEPARAMSA; + alias TB_GETBUTTONTEXT = TB_GETBUTTONTEXTA; + alias TB_SAVERESTORE = TB_SAVERESTOREA; + alias TB_ADDSTRING = TB_ADDSTRINGA; + alias TBN_GETBUTTONINFO = TBN_GETBUTTONINFOA; static if (_WIN32_IE >= 0x400) { - alias TBBUTTONINFOA TBBUTTONINFO; - alias LPTBBUTTONINFOA LPTBBUTTONINFO; - } - - alias TBNOTIFYA TBNOTIFY; - alias LPTBNOTIFYA LPTBNOTIFY; - alias NMTOOLBARA NMTOOLBAR; - alias LPNMTOOLBARA LPNMTOOLBAR; - alias TTM_ADDTOOLA TTM_ADDTOOL; - alias TTM_DELTOOLA TTM_DELTOOL; - alias TTM_NEWTOOLRECTA TTM_NEWTOOLRECT; - alias TTM_GETTOOLINFOA TTM_GETTOOLINFO; - alias TTM_SETTOOLINFOA TTM_SETTOOLINFO; - alias TTM_HITTESTA TTM_HITTEST; - alias TTM_GETTEXTA TTM_GETTEXT; - alias TTM_UPDATETIPTEXTA TTM_UPDATETIPTEXT; - alias TTM_ENUMTOOLSA TTM_ENUMTOOLS; - alias TTM_GETCURRENTTOOLA TTM_GETCURRENTTOOL; - alias TTN_NEEDTEXTA TTN_NEEDTEXT; - alias TTN_GETDISPINFOA TTN_GETDISPINFO; - alias LV_ITEMA LV_ITEM; - alias LVITEMA LVITEM; - alias LVITEM* LPLVITEM; - alias LPSTR_TEXTCALLBACKA LPSTR_TEXTCALLBACK; + alias TBBUTTONINFO = TBBUTTONINFOA; + alias LPTBBUTTONINFO = LPTBBUTTONINFOA; + } + + alias TBNOTIFY = TBNOTIFYA; + alias LPTBNOTIFY = LPTBNOTIFYA; + alias NMTOOLBAR = NMTOOLBARA; + alias LPNMTOOLBAR = LPNMTOOLBARA; + alias TTM_ADDTOOL = TTM_ADDTOOLA; + alias TTM_DELTOOL = TTM_DELTOOLA; + alias TTM_NEWTOOLRECT = TTM_NEWTOOLRECTA; + alias TTM_GETTOOLINFO = TTM_GETTOOLINFOA; + alias TTM_SETTOOLINFO = TTM_SETTOOLINFOA; + alias TTM_HITTEST = TTM_HITTESTA; + alias TTM_GETTEXT = TTM_GETTEXTA; + alias TTM_UPDATETIPTEXT = TTM_UPDATETIPTEXTA; + alias TTM_ENUMTOOLS = TTM_ENUMTOOLSA; + alias TTM_GETCURRENTTOOL = TTM_GETCURRENTTOOLA; + alias TTN_NEEDTEXT = TTN_NEEDTEXTA; + alias TTN_GETDISPINFO = TTN_GETDISPINFOA; + alias LV_ITEM = LV_ITEMA; + alias LVITEM = LVITEMA; + alias LPLVITEM = LVITEM*; + alias LPSTR_TEXTCALLBACK = LPSTR_TEXTCALLBACKA; static if (_WIN32_IE >= 0x400) { - alias LVBKIMAGEA LVBKIMAGE; - alias LPLVBKIMAGEA LPLVBKIMAGE; - alias LVM_SETBKIMAGEA LVM_SETBKIMAGE; - alias LVM_GETBKIMAGEA LVM_GETBKIMAGE; - } - - alias LVM_GETITEMA LVM_GETITEM; - alias LVM_SETITEMA LVM_SETITEM; - alias LVM_INSERTITEMA LVM_INSERTITEM; - alias LV_FINDINFOA LV_FINDINFO; - alias LVFINDINFOA LVFINDINFO; - alias LPFINDINFOA LPFINDINFO; - alias NMLVFINDITEMA NMLVFINDITEM; - alias PNMLVFINDITEMA PNMLVFINDITEM; - alias LPNMLVFINDITEMA LPNMLVFINDITEM; - alias LVM_FINDITEMA LVM_FINDITEM; - alias LVM_GETSTRINGWIDTHA LVM_GETSTRINGWIDTH; - alias LVM_EDITLABELA LVM_EDITLABEL; - alias LV_COLUMNA LV_COLUMN; - alias LVCOLUMNA LVCOLUMN; - alias LVCOLUMNA* LPLVCOLUMN; - alias LVM_GETCOLUMNA LVM_GETCOLUMN; - alias LVM_SETCOLUMNA LVM_SETCOLUMN; - alias LVM_INSERTCOLUMNA LVM_INSERTCOLUMN; - alias LVM_GETITEMTEXTA LVM_GETITEMTEXT; - alias LVM_SETITEMTEXTA LVM_SETITEMTEXT; - alias LVM_GETISEARCHSTRINGA LVM_GETISEARCHSTRING; - alias LVN_BEGINLABELEDITA LVN_BEGINLABELEDIT; - alias LVN_ENDLABELEDITA LVN_ENDLABELEDIT; - alias LVN_GETDISPINFOA LVN_GETDISPINFO; - alias LVN_SETDISPINFOA LVN_SETDISPINFO; + alias LVBKIMAGE = LVBKIMAGEA; + alias LPLVBKIMAGE = LPLVBKIMAGEA; + alias LVM_SETBKIMAGE = LVM_SETBKIMAGEA; + alias LVM_GETBKIMAGE = LVM_GETBKIMAGEA; + } + + alias LVM_GETITEM = LVM_GETITEMA; + alias LVM_SETITEM = LVM_SETITEMA; + alias LVM_INSERTITEM = LVM_INSERTITEMA; + alias LV_FINDINFO = LV_FINDINFOA; + alias LVFINDINFO = LVFINDINFOA; + alias LPFINDINFO = LPFINDINFOA; + alias NMLVFINDITEM = NMLVFINDITEMA; + alias PNMLVFINDITEM = PNMLVFINDITEMA; + alias LPNMLVFINDITEM = LPNMLVFINDITEMA; + alias LVM_FINDITEM = LVM_FINDITEMA; + alias LVM_GETSTRINGWIDTH = LVM_GETSTRINGWIDTHA; + alias LVM_EDITLABEL = LVM_EDITLABELA; + alias LV_COLUMN = LV_COLUMNA; + alias LVCOLUMN = LVCOLUMNA; + alias LPLVCOLUMN = LVCOLUMNA*; + alias LVM_GETCOLUMN = LVM_GETCOLUMNA; + alias LVM_SETCOLUMN = LVM_SETCOLUMNA; + alias LVM_INSERTCOLUMN = LVM_INSERTCOLUMNA; + alias LVM_GETITEMTEXT = LVM_GETITEMTEXTA; + alias LVM_SETITEMTEXT = LVM_SETITEMTEXTA; + alias LVM_GETISEARCHSTRING = LVM_GETISEARCHSTRINGA; + alias LVN_BEGINLABELEDIT = LVN_BEGINLABELEDITA; + alias LVN_ENDLABELEDIT = LVN_ENDLABELEDITA; + alias LVN_GETDISPINFO = LVN_GETDISPINFOA; + alias LVN_SETDISPINFO = LVN_SETDISPINFOA; static if (_WIN32_IE >= 0x400) { - alias LVN_GETINFOTIPA LVN_GETINFOTIP; - alias NMLVGETINFOTIPA NMLVGETINFOTIP; - alias LPNMLVGETINFOTIPA LPNMLVGETINFOTIP; - } - - alias LV_DISPINFOA LV_DISPINFO; - alias NMLVDISPINFOA NMLVDISPINFO; - alias LPNMLVDISPINFOA LPNMLVDISPINFO; - alias TVM_INSERTITEMA TVM_INSERTITEM; - alias TVM_GETITEMA TVM_GETITEM; - alias TVM_SETITEMA TVM_SETITEM; - alias TVM_EDITLABELA TVM_EDITLABEL; - alias TVM_GETISEARCHSTRINGA TVM_GETISEARCHSTRING; - alias NMTVDISPINFOA TV_DISPINFO; - alias NMTVDISPINFOA NMTVDISPINFO; - alias LPNMTVDISPINFOA LPNMTVDISPINFO; + alias LVN_GETINFOTIP = LVN_GETINFOTIPA; + alias NMLVGETINFOTIP = NMLVGETINFOTIPA; + alias LPNMLVGETINFOTIP = LPNMLVGETINFOTIPA; + } + + alias LV_DISPINFO = LV_DISPINFOA; + alias NMLVDISPINFO = NMLVDISPINFOA; + alias LPNMLVDISPINFO = LPNMLVDISPINFOA; + alias TVM_INSERTITEM = TVM_INSERTITEMA; + alias TVM_GETITEM = TVM_GETITEMA; + alias TVM_SETITEM = TVM_SETITEMA; + alias TVM_EDITLABEL = TVM_EDITLABELA; + alias TVM_GETISEARCHSTRING = TVM_GETISEARCHSTRINGA; + alias TV_DISPINFO = NMTVDISPINFOA; + alias NMTVDISPINFO = NMTVDISPINFOA; + alias LPNMTVDISPINFO = LPNMTVDISPINFOA; static if (_WIN32_IE >= 0x400) { - alias NMTVGETINFOTIPA NMTVGETINFOTIP; - alias LPNMTVGETINFOTIPA LPNMTVGETINFOTIP; - alias TVN_GETINFOTIPA TVN_GETINFOTIP; - } - - alias TVN_SELCHANGINGA TVN_SELCHANGING; - alias TVN_SELCHANGEDA TVN_SELCHANGED; - alias TVN_GETDISPINFOA TVN_GETDISPINFO; - alias TVN_SETDISPINFOA TVN_SETDISPINFO; - alias TVN_ITEMEXPANDINGA TVN_ITEMEXPANDING; - alias TVN_ITEMEXPANDEDA TVN_ITEMEXPANDED; - alias TVN_BEGINDRAGA TVN_BEGINDRAG; - alias TVN_BEGINRDRAGA TVN_BEGINRDRAG; - alias TVN_DELETEITEMA TVN_DELETEITEM; - alias TVN_BEGINLABELEDITA TVN_BEGINLABELEDIT; - alias TVN_ENDLABELEDITA TVN_ENDLABELEDIT; - alias TC_ITEMHEADERA TC_ITEMHEADER; - alias TC_ITEMA TC_ITEM; - alias TCITEMA TCITEM; - alias LPTCITEMA LPTCITEM; - alias TCM_GETITEMA TCM_GETITEM; - alias TCM_SETITEMA TCM_SETITEM; - alias TCM_INSERTITEMA TCM_INSERTITEM; - alias CreateStatusWindowA CreateStatusWindow; - alias DrawStatusTextA DrawStatusText; - alias ImageList_LoadImageA ImageList_LoadImage; - alias DTM_SETFORMATA DTM_SETFORMAT; - alias DTN_USERSTRINGA DTN_USERSTRING; - alias DTN_WMKEYDOWNA DTN_WMKEYDOWN; - alias DTN_FORMATA DTN_FORMAT; - alias DTN_FORMATQUERYA DTN_FORMATQUERY; - alias REBARBANDINFOA REBARBANDINFO; - alias REBARBANDINFOA* LPREBARBANDINFO; - alias LPCREBARBANDINFOA LPCREBARBANDINFO; - alias REBARBANDINFOA_V3_SIZE REBARBANDINFO_V3_SIZE; - alias RB_INSERTBANDA RB_INSERTBAND; - alias RB_SETBANDINFOA RB_SETBANDINFO; + alias NMTVGETINFOTIP = NMTVGETINFOTIPA; + alias LPNMTVGETINFOTIP = LPNMTVGETINFOTIPA; + alias TVN_GETINFOTIP = TVN_GETINFOTIPA; + } + + alias TVN_SELCHANGING = TVN_SELCHANGINGA; + alias TVN_SELCHANGED = TVN_SELCHANGEDA; + alias TVN_GETDISPINFO = TVN_GETDISPINFOA; + alias TVN_SETDISPINFO = TVN_SETDISPINFOA; + alias TVN_ITEMEXPANDING = TVN_ITEMEXPANDINGA; + alias TVN_ITEMEXPANDED = TVN_ITEMEXPANDEDA; + alias TVN_BEGINDRAG = TVN_BEGINDRAGA; + alias TVN_BEGINRDRAG = TVN_BEGINRDRAGA; + alias TVN_DELETEITEM = TVN_DELETEITEMA; + alias TVN_BEGINLABELEDIT = TVN_BEGINLABELEDITA; + alias TVN_ENDLABELEDIT = TVN_ENDLABELEDITA; + alias TC_ITEMHEADER = TC_ITEMHEADERA; + alias TC_ITEM = TC_ITEMA; + alias TCITEM = TCITEMA; + alias LPTCITEM = LPTCITEMA; + alias TCM_GETITEM = TCM_GETITEMA; + alias TCM_SETITEM = TCM_SETITEMA; + alias TCM_INSERTITEM = TCM_INSERTITEMA; + alias CreateStatusWindow = CreateStatusWindowA; + alias DrawStatusText = DrawStatusTextA; + alias ImageList_LoadImage = ImageList_LoadImageA; + alias DTM_SETFORMAT = DTM_SETFORMATA; + alias DTN_USERSTRING = DTN_USERSTRINGA; + alias DTN_WMKEYDOWN = DTN_WMKEYDOWNA; + alias DTN_FORMAT = DTN_FORMATA; + alias DTN_FORMATQUERY = DTN_FORMATQUERYA; + alias REBARBANDINFO = REBARBANDINFOA; + alias LPREBARBANDINFO = REBARBANDINFOA*; + alias LPCREBARBANDINFO = LPCREBARBANDINFOA; + alias REBARBANDINFO_V3_SIZE = REBARBANDINFOA_V3_SIZE; + alias RB_INSERTBAND = RB_INSERTBANDA; + alias RB_SETBANDINFO = RB_SETBANDINFOA; } extern (Windows) { -alias INT function(PVOID, PVOID) PFNDPAENUMCALLBACK; -alias INT function(PVOID, PVOID) PFNDSAENUMCALLBACK; -alias INT function(PVOID, PVOID, LPARAM) PFNDPACOMPARE; +alias PFNDPAENUMCALLBACK = INT function(PVOID, PVOID); +alias PFNDSAENUMCALLBACK = INT function(PVOID, PVOID); +alias PFNDPACOMPARE = INT function(PVOID, PVOID, LPARAM); } static if (_WIN32_WINNT >= 0x501) { extern (Windows) - alias LRESULT function(HWND, UINT, WPARAM, LPARAM, UINT_PTR, DWORD_PTR) - SUBCLASSPROC; + alias SUBCLASSPROC = LRESULT function(HWND, UINT, WPARAM, LPARAM, UINT_PTR, DWORD_PTR); struct LITEM { UINT mask; @@ -4922,19 +4921,19 @@ static if (_WIN32_WINNT >= 0x501) { WCHAR[MAX_LINKID_TEXT] szID = 0; WCHAR[L_MAX_URL_LENGTH] szUrl = 0; } - alias LITEM* PLITEM; + alias PLITEM = LITEM*; struct LHITTESTINFO { POINT pt; LITEM item; } - alias LHITTESTINFO* PLHITTESTINFO; + alias PLHITTESTINFO = LHITTESTINFO*; struct NMLINK { NMHDR hdr; LITEM item; } - alias NMLINK* PNMLINK; + alias PNMLINK = NMLINK*; } uint INDEXTOOVERLAYMASK()(uint i) { return i << 8; } @@ -5171,13 +5170,13 @@ extern (Windows) nothrow @nogc { version (Win64) { BOOL FlatSB_GetScrollPropPtr(HWND, INT, PINT_PTR); } else { - alias FlatSB_GetScrollProp FlatSB_GetScrollPropPtr; + alias FlatSB_GetScrollPropPtr = FlatSB_GetScrollProp; } INT FlatSB_SetScrollPos(HWND, INT, INT, BOOL); INT FlatSB_SetScrollInfo(HWND, INT, LPSCROLLINFO, BOOL); INT FlatSB_SetScrollRange(HWND, INT, INT, INT, BOOL); BOOL FlatSB_SetScrollProp(HWND, UINT, INT_PTR, BOOL); - alias FlatSB_SetScrollProp FlatSB_SetScrollPropPtr; + alias FlatSB_SetScrollPropPtr = FlatSB_SetScrollProp; BOOL InitializeFlatSB(HWND); HRESULT UninitializeFlatSB(HWND); } @@ -6287,7 +6286,7 @@ static if (_WIN32_WINNT >= 0x501) { LPCWSTR pszText; INT ttiIcon; } - alias EDITBALLOONTIP* PEDITBALLOONTIP; + alias PEDITBALLOONTIP = EDITBALLOONTIP*; enum EM_SETCUEBANNER = ECM_FIRST + 1; enum EM_GETCUEBANNER = ECM_FIRST + 2; diff --git a/runtime/druntime/src/core/sys/windows/commdlg.d b/runtime/druntime/src/core/sys/windows/commdlg.d index 9be9a9f1f2..a74b599c5d 100644 --- a/runtime/druntime/src/core/sys/windows/commdlg.d +++ b/runtime/druntime/src/core/sys/windows/commdlg.d @@ -297,9 +297,7 @@ alias CommDlg_OpenSave_GetFolderPath // Callbacks. extern(Windows) { -alias UINT_PTR function (HWND, UINT, WPARAM, LPARAM) nothrow - LPCCHOOKPROC, LPCFHOOKPROC, LPFRHOOKPROC, LPOFNHOOKPROC, - LPPAGEPAINTHOOK, LPPAGESETUPHOOK, LPSETUPHOOKPROC, LPPRINTHOOKPROC; +alias LPCCHOOKPROC = UINT_PTR function (HWND, UINT, WPARAM, LPARAM) nothrow, LPCFHOOKPROC = UINT_PTR function (HWND, UINT, WPARAM, LPARAM) nothrow, LPFRHOOKPROC = UINT_PTR function (HWND, UINT, WPARAM, LPARAM) nothrow, LPOFNHOOKPROC = UINT_PTR function (HWND, UINT, WPARAM, LPARAM) nothrow, LPPAGEPAINTHOOK = UINT_PTR function (HWND, UINT, WPARAM, LPARAM) nothrow, LPPAGESETUPHOOK = UINT_PTR function (HWND, UINT, WPARAM, LPARAM) nothrow, LPSETUPHOOKPROC = UINT_PTR function (HWND, UINT, WPARAM, LPARAM) nothrow, LPPRINTHOOKPROC = UINT_PTR function (HWND, UINT, WPARAM, LPARAM) nothrow; } //align (1): // 1 in Win32, default in Win64 @@ -315,7 +313,7 @@ struct CHOOSECOLORA { LPCCHOOKPROC lpfnHook; LPCSTR lpTemplateName; } -alias CHOOSECOLORA* LPCHOOSECOLORA; +alias LPCHOOSECOLORA = CHOOSECOLORA*; struct CHOOSECOLORW { DWORD lStructSize = CHOOSECOLORW.sizeof; @@ -328,7 +326,7 @@ struct CHOOSECOLORW { LPCCHOOKPROC lpfnHook; LPCWSTR lpTemplateName; } -alias CHOOSECOLORW* LPCHOOSECOLORW; +alias LPCHOOSECOLORW = CHOOSECOLORW*; struct CHOOSEFONTA { DWORD lStructSize = CHOOSEFONTA.sizeof; @@ -348,7 +346,7 @@ struct CHOOSEFONTA { INT nSizeMin; INT nSizeMax; } -alias CHOOSEFONTA* LPCHOOSEFONTA; +alias LPCHOOSEFONTA = CHOOSEFONTA*; struct CHOOSEFONTW { DWORD lStructSize = CHOOSEFONTW.sizeof; @@ -368,7 +366,7 @@ struct CHOOSEFONTW { INT nSizeMin; INT nSizeMax; } -alias CHOOSEFONTW* LPCHOOSEFONTW; +alias LPCHOOSEFONTW = CHOOSEFONTW*; struct DEVNAMES { WORD wDriverOffset; @@ -376,7 +374,7 @@ struct DEVNAMES { WORD wOutputOffset; WORD wDefault; } -alias DEVNAMES* LPDEVNAMES; +alias LPDEVNAMES = DEVNAMES*; struct FINDREPLACEA { DWORD lStructSize = FINDREPLACEA.sizeof; @@ -391,7 +389,7 @@ struct FINDREPLACEA { LPFRHOOKPROC lpfnHook; LPCSTR lpTemplateName; } -alias FINDREPLACEA* LPFINDREPLACEA; +alias LPFINDREPLACEA = FINDREPLACEA*; struct FINDREPLACEW { DWORD lStructSize = FINDREPLACEW.sizeof; @@ -406,7 +404,7 @@ struct FINDREPLACEW { LPFRHOOKPROC lpfnHook; LPCWSTR lpTemplateName; } -alias FINDREPLACEW* LPFINDREPLACEW; +alias LPFINDREPLACEW = FINDREPLACEW*; struct OPENFILENAMEA { DWORD lStructSize = OPENFILENAMEA.sizeof; @@ -436,7 +434,7 @@ struct OPENFILENAMEA { DWORD FlagsEx; //} } -alias OPENFILENAMEA* LPOPENFILENAMEA; +alias LPOPENFILENAMEA = OPENFILENAMEA*; struct OPENFILENAMEW { DWORD lStructSize = OPENFILENAMEW.sizeof; @@ -466,7 +464,7 @@ struct OPENFILENAMEW { DWORD FlagsEx; //} } -alias OPENFILENAMEW* LPOPENFILENAMEW; +alias LPOPENFILENAMEW = OPENFILENAMEW*; enum size_t OPENFILENAME_SIZE_VERSION_400 = 76; @@ -475,14 +473,14 @@ struct OFNOTIFYA { LPOPENFILENAMEA lpOFN; LPSTR pszFile; } -alias OFNOTIFYA* LPOFNOTIFYA; +alias LPOFNOTIFYA = OFNOTIFYA*; struct OFNOTIFYW { NMHDR hdr; LPOPENFILENAMEW lpOFN; LPWSTR pszFile; } -alias OFNOTIFYW* LPOFNOTIFYW; +alias LPOFNOTIFYW = OFNOTIFYW*; struct PAGESETUPDLGA { DWORD lStructSize = PAGESETUPDLGA.sizeof; @@ -500,7 +498,7 @@ struct PAGESETUPDLGA { LPCSTR lpPageSetupTemplateName; HGLOBAL hPageSetupTemplate; } -alias PAGESETUPDLGA* LPPAGESETUPDLGA; +alias LPPAGESETUPDLGA = PAGESETUPDLGA*; struct PAGESETUPDLGW { DWORD lStructSize = PAGESETUPDLGW.sizeof; @@ -518,7 +516,7 @@ struct PAGESETUPDLGW { LPCWSTR lpPageSetupTemplateName; HGLOBAL hPageSetupTemplate; } -alias PAGESETUPDLGW* LPPAGESETUPDLGW; +alias LPPAGESETUPDLGW = PAGESETUPDLGW*; align (1) struct PRINTDLGA { align(1): @@ -546,7 +544,7 @@ align(1): HANDLE hPrintTemplate; HANDLE hSetupTemplate; } -alias PRINTDLGA* LPPRINTDLGA; +alias LPPRINTDLGA = PRINTDLGA*; align (1) struct PRINTDLGW { align(1): @@ -574,7 +572,7 @@ align(1): HANDLE hPrintTemplate; HANDLE hSetupTemplate; } -alias PRINTDLGW* LPPRINTDLGW; +alias LPPRINTDLGW = PRINTDLGW*; //static if (_WIN32_WINNT >= 0x500) { import core.sys.windows.unknwn; // for LPUNKNOWN @@ -584,7 +582,7 @@ alias PRINTDLGW* LPPRINTDLGW; DWORD nFromPage; DWORD nToPage; } - alias PRINTPAGERANGE* LPPRINTPAGERANGE; + alias LPPRINTPAGERANGE = PRINTPAGERANGE*; struct PRINTDLGEXA { DWORD lStructSize = PRINTDLGEXA.sizeof; @@ -609,7 +607,7 @@ alias PRINTDLGW* LPPRINTDLGW; DWORD nStartPage; DWORD dwResultAction; } - alias PRINTDLGEXA* LPPRINTDLGEXA; + alias LPPRINTDLGEXA = PRINTDLGEXA*; struct PRINTDLGEXW { DWORD lStructSize = PRINTDLGEXW.sizeof; @@ -634,7 +632,7 @@ alias PRINTDLGW* LPPRINTDLGW; DWORD nStartPage; DWORD dwResultAction; } - alias PRINTDLGEXW* LPPRINTDLGEXW; + alias LPPRINTDLGEXW = PRINTDLGEXW*; //} // _WIN32_WINNT >= 0x500 @@ -666,63 +664,63 @@ extern (Windows) nothrow @nogc { } version (Unicode) { - alias CHOOSECOLORW CHOOSECOLOR; - alias CHOOSEFONTW CHOOSEFONT; - alias FINDREPLACEW FINDREPLACE; - alias OPENFILENAMEW OPENFILENAME; - alias OFNOTIFYW OFNOTIFY; - alias PAGESETUPDLGW PAGESETUPDLG; - alias PRINTDLGW PRINTDLG; - - alias ChooseColorW ChooseColor; - alias ChooseFontW ChooseFont; - alias FindTextW FindText; - alias GetFileTitleW GetFileTitle; - alias GetOpenFileNameW GetOpenFileName; - alias GetSaveFileNameW GetSaveFileName; - alias PageSetupDlgW PageSetupDlg; - alias PrintDlgW PrintDlg; - alias ReplaceTextW ReplaceText; + alias CHOOSECOLOR = CHOOSECOLORW; + alias CHOOSEFONT = CHOOSEFONTW; + alias FINDREPLACE = FINDREPLACEW; + alias OPENFILENAME = OPENFILENAMEW; + alias OFNOTIFY = OFNOTIFYW; + alias PAGESETUPDLG = PAGESETUPDLGW; + alias PRINTDLG = PRINTDLGW; + + alias ChooseColor = ChooseColorW; + alias ChooseFont = ChooseFontW; + alias FindText = FindTextW; + alias GetFileTitle = GetFileTitleW; + alias GetOpenFileName = GetOpenFileNameW; + alias GetSaveFileName = GetSaveFileNameW; + alias PageSetupDlg = PageSetupDlgW; + alias PrintDlg = PrintDlgW; + alias ReplaceText = ReplaceTextW; //static if (_WIN32_WINNT >= 0x500) { - alias PRINTDLGEXW PRINTDLGEX; - alias PrintDlgExW PrintDlgEx; + alias PRINTDLGEX = PRINTDLGEXW; + alias PrintDlgEx = PrintDlgExW; //} } else { // UNICODE - alias CHOOSECOLORA CHOOSECOLOR; - alias CHOOSEFONTA CHOOSEFONT; - alias FINDREPLACEA FINDREPLACE; - alias OPENFILENAMEA OPENFILENAME; - alias OFNOTIFYA OFNOTIFY; - alias PAGESETUPDLGA PAGESETUPDLG; - alias PRINTDLGA PRINTDLG; - - alias ChooseColorA ChooseColor; - alias ChooseFontA ChooseFont; - alias FindTextA FindText; - alias GetFileTitleA GetFileTitle; - alias GetOpenFileNameA GetOpenFileName; - alias GetSaveFileNameA GetSaveFileName; - alias PageSetupDlgA PageSetupDlg; - alias PrintDlgA PrintDlg; - alias ReplaceTextA ReplaceText; + alias CHOOSECOLOR = CHOOSECOLORA; + alias CHOOSEFONT = CHOOSEFONTA; + alias FINDREPLACE = FINDREPLACEA; + alias OPENFILENAME = OPENFILENAMEA; + alias OFNOTIFY = OFNOTIFYA; + alias PAGESETUPDLG = PAGESETUPDLGA; + alias PRINTDLG = PRINTDLGA; + + alias ChooseColor = ChooseColorA; + alias ChooseFont = ChooseFontA; + alias FindText = FindTextA; + alias GetFileTitle = GetFileTitleA; + alias GetOpenFileName = GetOpenFileNameA; + alias GetSaveFileName = GetSaveFileNameA; + alias PageSetupDlg = PageSetupDlgA; + alias PrintDlg = PrintDlgA; + alias ReplaceText = ReplaceTextA; //static if (_WIN32_WINNT >= 0x500) { - alias PRINTDLGEXA PRINTDLGEX; - alias PrintDlgExA PrintDlgEx; + alias PRINTDLGEX = PRINTDLGEXA; + alias PrintDlgEx = PrintDlgExA; //} } // UNICODE -alias CHOOSECOLOR* LPCHOOSECOLOR; -alias CHOOSEFONT* LPCHOOSEFONT; -alias FINDREPLACE* LPFINDREPLACE; -alias OPENFILENAME* LPOPENFILENAME; -alias OFNOTIFY* LPOFNOTIFY; -alias PAGESETUPDLG* LPPAGESETUPDLG; -alias PRINTDLG* LPPRINTDLG; +alias LPCHOOSECOLOR = CHOOSECOLOR*; +alias LPCHOOSEFONT = CHOOSEFONT*; +alias LPFINDREPLACE = FINDREPLACE*; +alias LPOPENFILENAME = OPENFILENAME*; +alias LPOFNOTIFY = OFNOTIFY*; +alias LPPAGESETUPDLG = PAGESETUPDLG*; +alias LPPRINTDLG = PRINTDLG*; //static if (_WIN32_WINNT >= 0x500) { - alias PRINTDLGEX* LPPRINTDLGEX; + alias LPPRINTDLGEX = PRINTDLGEX*; //} diff --git a/runtime/druntime/src/core/sys/windows/cpl.d b/runtime/druntime/src/core/sys/windows/cpl.d index df98703520..6ad65f2a63 100644 --- a/runtime/druntime/src/core/sys/windows/cpl.d +++ b/runtime/druntime/src/core/sys/windows/cpl.d @@ -34,7 +34,7 @@ enum : uint { CPL_SETUP = 200 } -extern (Windows) alias LONG function(HWND, UINT, LONG, LONG) APPLET_PROC; +extern (Windows) alias APPLET_PROC = LONG function(HWND, UINT, LONG, LONG); align(1) struct CPLINFO { @@ -44,7 +44,7 @@ align(1): int idInfo; LONG_PTR lData; } -alias CPLINFO* LPCPLINFO; +alias LPCPLINFO = CPLINFO*; align(1) struct NEWCPLINFOA { @@ -58,7 +58,7 @@ align(1): CHAR[64] szInfo = 0; CHAR[128] szHelpFile = 0; } -alias NEWCPLINFOA* LPNEWCPLINFOA; +alias LPNEWCPLINFOA = NEWCPLINFOA*; align(1) struct NEWCPLINFOW { @@ -72,14 +72,14 @@ align(1): WCHAR[64] szInfo = 0; WCHAR[128] szHelpFile = 0; } -alias NEWCPLINFOW* LPNEWCPLINFOW; +alias LPNEWCPLINFOW = NEWCPLINFOW*; version (Unicode) { - alias CPL_STARTWPARMSW CPL_STARTWPARMS; - alias NEWCPLINFOW NEWCPLINFO; + alias CPL_STARTWPARMS = CPL_STARTWPARMSW; + alias NEWCPLINFO = NEWCPLINFOW; } else { - alias CPL_STARTWPARMSA CPL_STARTWPARMS; - alias NEWCPLINFOA NEWCPLINFO; + alias CPL_STARTWPARMS = CPL_STARTWPARMSA; + alias NEWCPLINFO = NEWCPLINFOA; } -alias NEWCPLINFO* LPNEWCPLINFO; +alias LPNEWCPLINFO = NEWCPLINFO*; diff --git a/runtime/druntime/src/core/sys/windows/custcntl.d b/runtime/druntime/src/core/sys/windows/custcntl.d index ddac960738..d7a641fc72 100644 --- a/runtime/druntime/src/core/sys/windows/custcntl.d +++ b/runtime/druntime/src/core/sys/windows/custcntl.d @@ -29,7 +29,7 @@ struct CCSTYLEA { LANGID lgid; WORD wReserved1; } -alias CCSTYLEA* LPCCSTYLEA; +alias LPCCSTYLEA = CCSTYLEA*; struct CCSTYLEW { DWORD flStyle; @@ -38,21 +38,21 @@ struct CCSTYLEW { LANGID lgid; WORD wReserved1; } -alias CCSTYLEW* LPCCSTYLEW; +alias LPCCSTYLEW = CCSTYLEW*; struct CCSTYLEFLAGA { DWORD flStyle; DWORD flStyleMask; LPSTR pszStyle; } -alias CCSTYLEFLAGA* LPCCSTYLEFLAGA; +alias LPCCSTYLEFLAGA = CCSTYLEFLAGA*; struct CCSTYLEFLAGW { DWORD flStyle; DWORD flStyleMask; LPWSTR pszStyle; } -alias CCSTYLEFLAGW* LPCCSTYLEFLAGW; +alias LPCCSTYLEFLAGW = CCSTYLEFLAGW*; struct CCINFOA { CHAR[CCHCCCLASS] szClass = 0; @@ -71,7 +71,7 @@ struct CCINFOA { DWORD dwReserved1; DWORD dwReserved2; } -alias CCINFOA* LPCCINFOA; +alias LPCCINFOA = CCINFOA*; struct CCINFOW { WCHAR[CCHCCCLASS] szClass = 0; @@ -90,36 +90,36 @@ struct CCINFOW { DWORD dwReserved1; DWORD dwReserved2; } -alias CCINFOW* LPCCINFOW; +alias LPCCINFOW = CCINFOW*; extern (Windows) { - alias BOOL function(HWND, LPCCSTYLEA) LPFNCCSTYLEA; - alias BOOL function(HWND, LPCCSTYLEW) LPFNCCSTYLEW; - alias INT function(DWORD, DWORD, HFONT, LPSTR) LPFNCCSIZETOTEXTA; - alias INT function(DWORD, DWORD, HFONT, LPWSTR) LPFNCCSIZETOTEXTW; - alias UINT function(LPCCINFOA) LPFNCCINFOA; - alias UINT function(LPCCINFOW) LPFNCCINFOW; + alias LPFNCCSTYLEA = BOOL function(HWND, LPCCSTYLEA); + alias LPFNCCSTYLEW = BOOL function(HWND, LPCCSTYLEW); + alias LPFNCCSIZETOTEXTA = INT function(DWORD, DWORD, HFONT, LPSTR); + alias LPFNCCSIZETOTEXTW = INT function(DWORD, DWORD, HFONT, LPWSTR); + alias LPFNCCINFOA = UINT function(LPCCINFOA); + alias LPFNCCINFOW = UINT function(LPCCINFOW); nothrow @nogc: UINT CustomControlInfoA(LPCCINFOA acci); UINT CustomControlInfoW(LPCCINFOW acci); } version (Unicode) { - alias CCSTYLEW CCSTYLE; - alias CCSTYLEFLAGW CCSTYLEFLAG; - alias CCINFOW CCINFO; - alias LPFNCCSTYLEW LPFNCCSTYLE; - alias LPFNCCSIZETOTEXTW LPFNCCSIZETOTEXT; - alias LPFNCCINFOW LPFNCCINFO; + alias CCSTYLE = CCSTYLEW; + alias CCSTYLEFLAG = CCSTYLEFLAGW; + alias CCINFO = CCINFOW; + alias LPFNCCSTYLE = LPFNCCSTYLEW; + alias LPFNCCSIZETOTEXT = LPFNCCSIZETOTEXTW; + alias LPFNCCINFO = LPFNCCINFOW; } else { - alias CCSTYLEA CCSTYLE; - alias CCSTYLEFLAGA CCSTYLEFLAG; - alias CCINFOA CCINFO; - alias LPFNCCSTYLEA LPFNCCSTYLE; - alias LPFNCCSIZETOTEXTA LPFNCCSIZETOTEXT; - alias LPFNCCINFOA LPFNCCINFO; + alias CCSTYLE = CCSTYLEA; + alias CCSTYLEFLAG = CCSTYLEFLAGA; + alias CCINFO = CCINFOA; + alias LPFNCCSTYLE = LPFNCCSTYLEA; + alias LPFNCCSIZETOTEXT = LPFNCCSIZETOTEXTA; + alias LPFNCCINFO = LPFNCCINFOA; } -alias CCSTYLE* LPCCSTYLE; -alias CCSTYLEFLAG* LPCCSTYLEFLAG; -alias CCINFO* LPCCINFO; +alias LPCCSTYLE = CCSTYLE*; +alias LPCCSTYLEFLAG = CCSTYLEFLAG*; +alias LPCCINFO = CCINFO*; diff --git a/runtime/druntime/src/core/sys/windows/dbghelp.d b/runtime/druntime/src/core/sys/windows/dbghelp.d index fb6fb66867..45b2041161 100644 --- a/runtime/druntime/src/core/sys/windows/dbghelp.d +++ b/runtime/druntime/src/core/sys/windows/dbghelp.d @@ -19,31 +19,31 @@ public import core.sys.windows.dbghelp_types; extern(Windows) { - alias BOOL function(HANDLE hProcess, DWORD64 lpBaseAddress, PVOID lpBuffer, DWORD nSize, LPDWORD lpNumberOfBytesRead) ReadProcessMemoryProc64; - alias PVOID function(HANDLE hProcess, DWORD64 AddrBase) FunctionTableAccessProc64; - alias DWORD64 function(HANDLE hProcess, DWORD64 Address) GetModuleBaseProc64; - alias DWORD64 function(HANDLE hProcess, HANDLE hThread, ADDRESS64 *lpaddr) TranslateAddressProc64; + alias ReadProcessMemoryProc64 = BOOL function(HANDLE hProcess, DWORD64 lpBaseAddress, PVOID lpBuffer, DWORD nSize, LPDWORD lpNumberOfBytesRead); + alias FunctionTableAccessProc64 = PVOID function(HANDLE hProcess, DWORD64 AddrBase); + alias GetModuleBaseProc64 = DWORD64 function(HANDLE hProcess, DWORD64 Address); + alias TranslateAddressProc64 = DWORD64 function(HANDLE hProcess, HANDLE hThread, ADDRESS64 *lpaddr); - alias BOOL function(HANDLE hProcess, PCSTR UserSearchPath, bool fInvadeProcess) SymInitializeFunc; - alias BOOL function(HANDLE hProcess) SymCleanupFunc; - alias DWORD function(DWORD SymOptions) SymSetOptionsFunc; - alias DWORD function() SymGetOptionsFunc; - alias PVOID function(HANDLE hProcess, DWORD64 AddrBase) SymFunctionTableAccess64Func; - alias BOOL function(DWORD MachineType, HANDLE hProcess, HANDLE hThread, STACKFRAME64 *StackFrame, PVOID ContextRecord, + alias SymInitializeFunc = BOOL function(HANDLE hProcess, PCSTR UserSearchPath, bool fInvadeProcess); + alias SymCleanupFunc = BOOL function(HANDLE hProcess); + alias SymSetOptionsFunc = DWORD function(DWORD SymOptions); + alias SymGetOptionsFunc = DWORD function(); + alias SymFunctionTableAccess64Func = PVOID function(HANDLE hProcess, DWORD64 AddrBase); + alias StackWalk64Func = BOOL function(DWORD MachineType, HANDLE hProcess, HANDLE hThread, STACKFRAME64 *StackFrame, PVOID ContextRecord, ReadProcessMemoryProc64 ReadMemoryRoutine, FunctionTableAccessProc64 FunctoinTableAccess, - GetModuleBaseProc64 GetModuleBaseRoutine, TranslateAddressProc64 TranslateAddress) @nogc StackWalk64Func; - alias BOOL function(HANDLE hProcess, DWORD64 dwAddr, PDWORD pdwDisplacement, IMAGEHLP_LINEA64 *line) SymGetLineFromAddr64Func; - alias DWORD64 function(HANDLE hProcess, DWORD64 dwAddr) SymGetModuleBase64Func; - alias BOOL function(HANDLE hProcess, DWORD64 dwAddr, IMAGEHLP_MODULEA64 *ModuleInfo) SymGetModuleInfo64Func; - alias BOOL function(HANDLE hProcess, DWORD64 Address, DWORD64 *Displacement, IMAGEHLP_SYMBOLA64 *Symbol) SymGetSymFromAddr64Func; - alias DWORD function(PCSTR DecoratedName, PSTR UnDecoratedName, DWORD UndecoratedLength, DWORD Flags) UnDecorateSymbolNameFunc; - alias DWORD64 function(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll) SymLoadModule64Func; - alias BOOL function(HANDLE hProcess, PSTR SearchPath, DWORD SearchPathLength) SymGetSearchPathFunc; - alias BOOL function(HANDLE hProcess, PCSTR SearchPath) SymSetSearchPathFunc; - alias BOOL function(HANDLE hProcess, DWORD64 Address) SymUnloadModule64Func; - alias BOOL function(HANDLE hProcess, ULONG ActionCode, ulong CallbackContext, ulong UserContext) PSYMBOL_REGISTERED_CALLBACK64; - alias BOOL function(HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ulong UserContext) SymRegisterCallback64Func; - alias API_VERSION* function() ImagehlpApiVersionFunc; + GetModuleBaseProc64 GetModuleBaseRoutine, TranslateAddressProc64 TranslateAddress) @nogc; + alias SymGetLineFromAddr64Func = BOOL function(HANDLE hProcess, DWORD64 dwAddr, PDWORD pdwDisplacement, IMAGEHLP_LINEA64 *line); + alias SymGetModuleBase64Func = DWORD64 function(HANDLE hProcess, DWORD64 dwAddr); + alias SymGetModuleInfo64Func = BOOL function(HANDLE hProcess, DWORD64 dwAddr, IMAGEHLP_MODULEA64 *ModuleInfo); + alias SymGetSymFromAddr64Func = BOOL function(HANDLE hProcess, DWORD64 Address, DWORD64 *Displacement, IMAGEHLP_SYMBOLA64 *Symbol); + alias UnDecorateSymbolNameFunc = DWORD function(PCSTR DecoratedName, PSTR UnDecoratedName, DWORD UndecoratedLength, DWORD Flags); + alias SymLoadModule64Func = DWORD64 function(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll); + alias SymGetSearchPathFunc = BOOL function(HANDLE hProcess, PSTR SearchPath, DWORD SearchPathLength); + alias SymSetSearchPathFunc = BOOL function(HANDLE hProcess, PCSTR SearchPath); + alias SymUnloadModule64Func = BOOL function(HANDLE hProcess, DWORD64 Address); + alias PSYMBOL_REGISTERED_CALLBACK64 = BOOL function(HANDLE hProcess, ULONG ActionCode, ulong CallbackContext, ulong UserContext); + alias SymRegisterCallback64Func = BOOL function(HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ulong UserContext); + alias ImagehlpApiVersionFunc = API_VERSION* function(); } struct DbgHelp diff --git a/runtime/druntime/src/core/sys/windows/dbghelp_types.d b/runtime/druntime/src/core/sys/windows/dbghelp_types.d index f75f98bc88..f31271037c 100644 --- a/runtime/druntime/src/core/sys/windows/dbghelp_types.d +++ b/runtime/druntime/src/core/sys/windows/dbghelp_types.d @@ -222,13 +222,13 @@ struct API_VERSION version (Unicode) { - alias IMAGEHLP_LINEW64 IMAGEHLP_LINE64; - alias IMAGEHLP_MODULEW64 IMAGEHLP_MODULE64; - alias IMAGEHLP_SYMBOLW64 IMAGEHLP_SYMBOL64; + alias IMAGEHLP_LINE64 = IMAGEHLP_LINEW64; + alias IMAGEHLP_MODULE64 = IMAGEHLP_MODULEW64; + alias IMAGEHLP_SYMBOL64 = IMAGEHLP_SYMBOLW64; } else { - alias IMAGEHLP_LINEA64 IMAGEHLP_LINE64; - alias IMAGEHLP_MODULEA64 IMAGEHLP_MODULE64; - alias IMAGEHLP_SYMBOLA64 IMAGEHLP_SYMBOL64; + alias IMAGEHLP_LINE64 = IMAGEHLP_LINEA64; + alias IMAGEHLP_MODULE64 = IMAGEHLP_MODULEA64; + alias IMAGEHLP_SYMBOL64 = IMAGEHLP_SYMBOLA64; } diff --git a/runtime/druntime/src/core/sys/windows/dbt.d b/runtime/druntime/src/core/sys/windows/dbt.d index 41f1c32a41..c865fe2558 100644 --- a/runtime/druntime/src/core/sys/windows/dbt.d +++ b/runtime/druntime/src/core/sys/windows/dbt.d @@ -97,7 +97,7 @@ struct DEV_BROADCAST_HDR { DWORD dbch_devicetype; DWORD dbch_reserved; } -alias DEV_BROADCAST_HDR* PDEV_BROADCAST_HDR; +alias PDEV_BROADCAST_HDR = DEV_BROADCAST_HDR*; struct DEV_BROADCAST_OEM { DWORD dbco_size = DEV_BROADCAST_OEM.sizeof; @@ -106,7 +106,7 @@ struct DEV_BROADCAST_OEM { DWORD dbco_identifier; DWORD dbco_suppfunc; } -alias DEV_BROADCAST_OEM* PDEV_BROADCAST_OEM; +alias PDEV_BROADCAST_OEM = DEV_BROADCAST_OEM*; struct DEV_BROADCAST_PORT_A { DWORD dbcp_size = DEV_BROADCAST_PORT_A.sizeof; @@ -115,7 +115,7 @@ struct DEV_BROADCAST_PORT_A { char _dbcp_name = 0; char* dbcp_name() return { return &_dbcp_name; } } -alias DEV_BROADCAST_PORT_A* PDEV_BROADCAST_PORT_A; +alias PDEV_BROADCAST_PORT_A = DEV_BROADCAST_PORT_A*; struct DEV_BROADCAST_PORT_W { DWORD dbcp_size = DEV_BROADCAST_PORT_W.sizeof; @@ -124,7 +124,7 @@ struct DEV_BROADCAST_PORT_W { WCHAR _dbcp_name = 0; WCHAR* dbcp_name() return { return &_dbcp_name; } } -alias DEV_BROADCAST_PORT_W* PDEV_BROADCAST_PORT_W; +alias PDEV_BROADCAST_PORT_W = DEV_BROADCAST_PORT_W*; struct DEV_BROADCAST_USERDEFINED { DEV_BROADCAST_HDR dbud_dbh; @@ -139,14 +139,14 @@ struct DEV_BROADCAST_VOLUME { DWORD dbcv_unitmask; WORD dbcv_flags; } -alias DEV_BROADCAST_VOLUME* PDEV_BROADCAST_VOLUME; +alias PDEV_BROADCAST_VOLUME = DEV_BROADCAST_VOLUME*; version (Unicode) { - alias DEV_BROADCAST_PORT_W DEV_BROADCAST_PORT; + alias DEV_BROADCAST_PORT = DEV_BROADCAST_PORT_W; } else { - alias DEV_BROADCAST_PORT_A DEV_BROADCAST_PORT; + alias DEV_BROADCAST_PORT = DEV_BROADCAST_PORT_A; } -alias DEV_BROADCAST_PORT* PDEV_BROADCAST_PORT; +alias PDEV_BROADCAST_PORT = DEV_BROADCAST_PORT*; //static if (_WIN32_WINNT >= 0x500) { struct DEV_BROADCAST_DEVICEINTERFACE_A { @@ -157,7 +157,7 @@ alias DEV_BROADCAST_PORT* PDEV_BROADCAST_PORT; char _dbcc_name; char* dbcc_name() return { return &_dbcc_name; } } - alias DEV_BROADCAST_DEVICEINTERFACE_A* PDEV_BROADCAST_DEVICEINTERFACE_A; + alias PDEV_BROADCAST_DEVICEINTERFACE_A = DEV_BROADCAST_DEVICEINTERFACE_A*; struct DEV_BROADCAST_DEVICEINTERFACE_W { DWORD dbcc_size = DEV_BROADCAST_DEVICEINTERFACE_W.sizeof; @@ -167,14 +167,14 @@ alias DEV_BROADCAST_PORT* PDEV_BROADCAST_PORT; WCHAR _dbcc_name = 0; WCHAR* dbcc_name() return { return &_dbcc_name; } } - alias DEV_BROADCAST_DEVICEINTERFACE_W* PDEV_BROADCAST_DEVICEINTERFACE_W; + alias PDEV_BROADCAST_DEVICEINTERFACE_W = DEV_BROADCAST_DEVICEINTERFACE_W*; version (Unicode) { - alias DEV_BROADCAST_DEVICEINTERFACE_W DEV_BROADCAST_DEVICEINTERFACE; + alias DEV_BROADCAST_DEVICEINTERFACE = DEV_BROADCAST_DEVICEINTERFACE_W; } else { - alias DEV_BROADCAST_DEVICEINTERFACE_A DEV_BROADCAST_DEVICEINTERFACE; + alias DEV_BROADCAST_DEVICEINTERFACE = DEV_BROADCAST_DEVICEINTERFACE_A; } - alias DEV_BROADCAST_DEVICEINTERFACE* PDEV_BROADCAST_DEVICEINTERFACE; + alias PDEV_BROADCAST_DEVICEINTERFACE = DEV_BROADCAST_DEVICEINTERFACE*; struct DEV_BROADCAST_HANDLE { DWORD dbch_size = DEV_BROADCAST_HANDLE.sizeof; @@ -187,5 +187,5 @@ alias DEV_BROADCAST_PORT* PDEV_BROADCAST_PORT; BYTE _dbch_data; BYTE* dbch_data() return { return &_dbch_data; } } - alias DEV_BROADCAST_HANDLE* PDEV_BROADCAST_HANDLE; + alias PDEV_BROADCAST_HANDLE = DEV_BROADCAST_HANDLE*; //} diff --git a/runtime/druntime/src/core/sys/windows/ddeml.d b/runtime/druntime/src/core/sys/windows/ddeml.d index 0ff1a3f4f1..8dafb0ed90 100644 --- a/runtime/druntime/src/core/sys/windows/ddeml.d +++ b/runtime/druntime/src/core/sys/windows/ddeml.d @@ -206,14 +206,14 @@ enum : int { MH_CLEANUP = 4 } -extern (Windows) alias HDDEDATA - function(UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, ULONG_PTR, ULONG_PTR) PFNCALLBACK; +extern (Windows) alias PFNCALLBACK = HDDEDATA + function(UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, ULONG_PTR, ULONG_PTR); struct HSZPAIR { HSZ hszSvc; HSZ hszTopic; } -alias HSZPAIR* PHSZPAIR; +alias PHSZPAIR = HSZPAIR*; struct CONVCONTEXT { UINT cb = CONVCONTEXT.sizeof; @@ -224,7 +224,7 @@ struct CONVCONTEXT { DWORD dwSecurity; SECURITY_QUALITY_OF_SERVICE qos; } -alias CONVCONTEXT* PCONVCONTEXT; +alias PCONVCONTEXT = CONVCONTEXT*; struct CONVINFO { DWORD cb = CONVINFO.sizeof; @@ -244,7 +244,7 @@ struct CONVINFO { HWND hwnd; HWND hwndPartner; } -alias CONVINFO* PCONVINFO; +alias PCONVINFO = CONVINFO*; struct DDEML_MSG_HOOK_DATA { UINT_PTR uiLo; @@ -263,7 +263,7 @@ struct MONHSZSTRUCT { TCHAR* str() return { return _str.ptr; } } -alias MONHSZSTRUCT* PMONHSZSTRUCT; +alias PMONHSZSTRUCT = MONHSZSTRUCT*; struct MONLINKSTRUCT { UINT cb = MONLINKSTRUCT.sizeof; @@ -279,7 +279,7 @@ struct MONLINKSTRUCT { HCONV hConvServer; HCONV hConvClient; } -alias MONLINKSTRUCT* PMONLINKSTRUCT; +alias PMONLINKSTRUCT = MONLINKSTRUCT*; struct MONCONVSTRUCT { UINT cb = MONCONVSTRUCT.sizeof; @@ -291,7 +291,7 @@ struct MONCONVSTRUCT { HCONV hConvClient; HCONV hConvServer; } -alias MONCONVSTRUCT* PMONCONVSTRUCT; +alias PMONCONVSTRUCT = MONCONVSTRUCT*; struct MONCBSTRUCT { UINT cb = MONCBSTRUCT.sizeof; @@ -310,7 +310,7 @@ struct MONCBSTRUCT { DWORD cbData; DWORD[8] Data; } -alias MONCBSTRUCT* PMONCBSTRUCT; +alias PMONCBSTRUCT = MONCBSTRUCT*; struct MONERRSTRUCT { UINT cb = MONERRSTRUCT.sizeof; @@ -318,7 +318,7 @@ struct MONERRSTRUCT { DWORD dwTime; HANDLE hTask; } -alias MONERRSTRUCT* PMONERRSTRUCT; +alias PMONERRSTRUCT = MONERRSTRUCT*; struct MONMSGSTRUCT { UINT cb = MONMSGSTRUCT.sizeof; @@ -330,7 +330,7 @@ struct MONMSGSTRUCT { LPARAM lParam; DDEML_MSG_HOOK_DATA dmhd; } -alias MONMSGSTRUCT* PMONMSGSTRUCT; +alias PMONMSGSTRUCT = MONMSGSTRUCT*; extern (Windows) nothrow @nogc { BOOL DdeAbandonTransaction(DWORD, HCONV, DWORD); @@ -379,11 +379,11 @@ const TCHAR[] SZDDE_ITEM_ITEMLIST = "TopicItemList"; version (Unicode) { - alias DdeCreateStringHandleW DdeCreateStringHandle; - alias DdeInitializeW DdeInitialize; - alias DdeQueryStringW DdeQueryString; + alias DdeCreateStringHandle = DdeCreateStringHandleW; + alias DdeInitialize = DdeInitializeW; + alias DdeQueryString = DdeQueryStringW; } else { - alias DdeCreateStringHandleA DdeCreateStringHandle; - alias DdeInitializeA DdeInitialize; - alias DdeQueryStringA DdeQueryString; + alias DdeCreateStringHandle = DdeCreateStringHandleA; + alias DdeInitialize = DdeInitializeA; + alias DdeQueryString = DdeQueryStringA; } diff --git a/runtime/druntime/src/core/sys/windows/dhcpcsdk.d b/runtime/druntime/src/core/sys/windows/dhcpcsdk.d index 6171469c8c..9cb8019335 100644 --- a/runtime/druntime/src/core/sys/windows/dhcpcsdk.d +++ b/runtime/druntime/src/core/sys/windows/dhcpcsdk.d @@ -28,7 +28,7 @@ struct DHCPCAPI_CLASSID { LPBYTE Data; ULONG nBytesData; } -alias DHCPCAPI_CLASSID* PDHCPCAPI_CLASSID, LPDHCPCAPI_CLASSID; +alias PDHCPCAPI_CLASSID = DHCPCAPI_CLASSID*, LPDHCPCAPI_CLASSID = DHCPCAPI_CLASSID*; struct DHCPAPI_PARAMS { ULONG Flags; @@ -37,13 +37,13 @@ struct DHCPAPI_PARAMS { LPBYTE Data; DWORD nBytesData; } -alias DHCPAPI_PARAMS* PDHCPAPI_PARAMS, LPDHCPAPI_PARAMS; +alias PDHCPAPI_PARAMS = DHCPAPI_PARAMS*, LPDHCPAPI_PARAMS = DHCPAPI_PARAMS*; struct DHCPCAPI_PARAMS_ARRAY { ULONG nParams; LPDHCPAPI_PARAMS Params; } -alias DHCPCAPI_PARAMS_ARRAY* PDHCPCAPI_PARAMS_ARRAY, LPDHCPCAPI_PARAMS_ARRAY; +alias PDHCPCAPI_PARAMS_ARRAY = DHCPCAPI_PARAMS_ARRAY*, LPDHCPCAPI_PARAMS_ARRAY = DHCPCAPI_PARAMS_ARRAY*; extern (Windows) nothrow @nogc { void DhcpCApiCleanup(); diff --git a/runtime/druntime/src/core/sys/windows/dll.d b/runtime/druntime/src/core/sys/windows/dll.d index 06f01f3f6d..5668b44b8d 100644 --- a/runtime/druntime/src/core/sys/windows/dll.d +++ b/runtime/druntime/src/core/sys/windows/dll.d @@ -34,9 +34,9 @@ extern (C) extern __gshared byte _tls_start; extern __gshared byte _tls_end; extern __gshared void* __xl_a; - alias _tls_start _tlsstart; - alias _tls_end _tlsend; - alias __xl_a _tls_callbacks_a; + alias _tlsstart = _tls_start; + alias _tlsend = _tls_end; + alias _tls_callbacks_a = __xl_a; } extern __gshared int _tls_index; } @@ -221,7 +221,7 @@ version (Win32) } } // Win32 - alias bool BOOLEAN; + alias BOOLEAN = bool; struct UNICODE_STRING { diff --git a/runtime/druntime/src/core/sys/windows/docobj.d b/runtime/druntime/src/core/sys/windows/docobj.d index 4abbea3124..f4f247fd09 100644 --- a/runtime/druntime/src/core/sys/windows/docobj.d +++ b/runtime/druntime/src/core/sys/windows/docobj.d @@ -81,8 +81,8 @@ struct OLECMD { DWORD cmdf; } -alias IOleInPlaceSite LPOLEINPLACESITE; -alias IEnumOleDocumentViews LPENUMOLEDOCUMENTVIEWS; +alias LPOLEINPLACESITE = IOleInPlaceSite; +alias LPENUMOLEDOCUMENTVIEWS = IEnumOleDocumentViews; extern (C) extern const IID IID_IContinueCallback, diff --git a/runtime/druntime/src/core/sys/windows/errorrep.d b/runtime/druntime/src/core/sys/windows/errorrep.d index 840ea61f3c..f50c0e5ccb 100644 --- a/runtime/druntime/src/core/sys/windows/errorrep.d +++ b/runtime/druntime/src/core/sys/windows/errorrep.d @@ -36,7 +36,7 @@ extern (Windows) nothrow @nogc { } version (Unicode) { - alias AddERExcludedApplicationW AddERExcludedApplication; + alias AddERExcludedApplication = AddERExcludedApplicationW; } else { - alias AddERExcludedApplicationA AddERExcludedApplication; + alias AddERExcludedApplication = AddERExcludedApplicationA; } diff --git a/runtime/druntime/src/core/sys/windows/httpext.d b/runtime/druntime/src/core/sys/windows/httpext.d index b7f6aedcbd..1994ebde5c 100644 --- a/runtime/druntime/src/core/sys/windows/httpext.d +++ b/runtime/druntime/src/core/sys/windows/httpext.d @@ -53,7 +53,7 @@ struct HSE_VERSION_INFO { DWORD dwExtensionVersion; CHAR[HSE_MAX_EXT_DLL_NAME_LEN] lpszExtensionDesc = 0; } -alias HSE_VERSION_INFO* LPHSE_VERSION_INFO; +alias LPHSE_VERSION_INFO = HSE_VERSION_INFO*; struct EXTENSION_CONTROL_BLOCK { DWORD cbSize = EXTENSION_CONTROL_BLOCK.sizeof; @@ -76,13 +76,13 @@ struct EXTENSION_CONTROL_BLOCK { BOOL function(HCONN, DWORD, LPVOID, LPDWORD, LPDWORD) ServerSupportFunction; } } -alias EXTENSION_CONTROL_BLOCK* LPEXTENSION_CONTROL_BLOCK; +alias LPEXTENSION_CONTROL_BLOCK = EXTENSION_CONTROL_BLOCK*; extern (Windows) { - alias BOOL function(HSE_VERSION_INFO*) PFN_GETEXTENSIONVERSION; - alias DWORD function(EXTENSION_CONTROL_BLOCK*) PFN_HTTPEXTENSIONPROC; - alias BOOL function(DWORD) PFN_TERMINATEEXTENSION; - alias VOID function(EXTENSION_CONTROL_BLOCK*, PVOID, DWORD, DWORD) PFN_HSE_IO_COMPLETION; + alias PFN_GETEXTENSIONVERSION = BOOL function(HSE_VERSION_INFO*); + alias PFN_HTTPEXTENSIONPROC = DWORD function(EXTENSION_CONTROL_BLOCK*); + alias PFN_TERMINATEEXTENSION = BOOL function(DWORD); + alias PFN_HSE_IO_COMPLETION = VOID function(EXTENSION_CONTROL_BLOCK*, PVOID, DWORD, DWORD); } struct HSE_TF_INFO { @@ -98,7 +98,7 @@ struct HSE_TF_INFO { DWORD TailLength; DWORD dwFlags; } -alias HSE_TF_INFO* LPHSE_TF_INFO; +alias LPHSE_TF_INFO = HSE_TF_INFO*; struct HSE_SEND_HEADER_EX_INFO { LPCSTR pszStatus; @@ -107,7 +107,7 @@ struct HSE_SEND_HEADER_EX_INFO { DWORD cchHeader; BOOL fKeepConn; } -alias HSE_SEND_HEADER_EX_INFO* LPHSE_SEND_HEADER_EX_INF; +alias LPHSE_SEND_HEADER_EX_INF = HSE_SEND_HEADER_EX_INFO*; extern (Windows) nothrow @nogc { BOOL GetExtensionVersion(HSE_VERSION_INFO*); diff --git a/runtime/druntime/src/core/sys/windows/imagehlp.d b/runtime/druntime/src/core/sys/windows/imagehlp.d index c6d28e68fd..0c900a6947 100644 --- a/runtime/druntime/src/core/sys/windows/imagehlp.d +++ b/runtime/druntime/src/core/sys/windows/imagehlp.d @@ -122,7 +122,7 @@ struct LOADED_IMAGE { LIST_ENTRY Links; ULONG SizeOfImage; } -alias LOADED_IMAGE* PLOADED_IMAGE; +alias PLOADED_IMAGE = LOADED_IMAGE*; struct IMAGE_DEBUG_INFORMATION { LIST_ENTRY List; @@ -156,7 +156,7 @@ struct IMAGE_DEBUG_INFORMATION { DWORD NumberOfDebugDirectories; DWORD[3] Reserved; } -alias IMAGE_DEBUG_INFORMATION* PIMAGE_DEBUG_INFORMATION; +alias PIMAGE_DEBUG_INFORMATION = IMAGE_DEBUG_INFORMATION*; enum ADDRESS_MODE { AddrMode1616, @@ -170,7 +170,7 @@ struct ADDRESS { WORD Segment; ADDRESS_MODE Mode; } -alias ADDRESS* LPADDRESS; +alias LPADDRESS = ADDRESS*; struct KDHELP { DWORD Thread; @@ -186,7 +186,7 @@ struct KDHELP { DWORD StackLimit; DWORD[5] Reserved; } -alias KDHELP* PKDHELP; +alias PKDHELP = KDHELP*; struct STACKFRAME { ADDRESS AddrPC; @@ -201,7 +201,7 @@ struct STACKFRAME { KDHELP KdHelp; ADDRESS AddrBStore; } -alias STACKFRAME* LPSTACKFRAME; +alias LPSTACKFRAME = STACKFRAME*; /* struct API_VERSION { @@ -212,7 +212,7 @@ struct API_VERSION { } */ public import core.sys.windows.dbghelp_types : API_VERSION; -alias API_VERSION* LPAPI_VERSION; +alias LPAPI_VERSION = API_VERSION*; enum SYM_TYPE { SymNone, @@ -232,7 +232,7 @@ struct IMAGEHLP_SYMBOL { DWORD MaxNameLength; CHAR[1] Name = 0; } -alias IMAGEHLP_SYMBOL* PIMAGEHLP_SYMBOL; +alias PIMAGEHLP_SYMBOL = IMAGEHLP_SYMBOL*; struct IMAGEHLP_MODULE { DWORD SizeOfStruct; @@ -246,7 +246,7 @@ struct IMAGEHLP_MODULE { CHAR[256] ImageName = 0; CHAR[256] LoadedImageName = 0; } -alias IMAGEHLP_MODULE* PIMAGEHLP_MODULE; +alias PIMAGEHLP_MODULE = IMAGEHLP_MODULE*; struct IMAGEHLP_LINE { DWORD SizeOfStruct; @@ -255,7 +255,7 @@ struct IMAGEHLP_LINE { PCHAR FileName; DWORD Address; } -alias IMAGEHLP_LINE* PIMAGEHLP_LINE; +alias PIMAGEHLP_LINE = IMAGEHLP_LINE*; struct IMAGEHLP_DEFERRED_SYMBOL_LOAD { DWORD SizeOfStruct; @@ -265,7 +265,7 @@ struct IMAGEHLP_DEFERRED_SYMBOL_LOAD { CHAR[MAX_PATH] FileName = 0; BOOLEAN Reparse; } -alias IMAGEHLP_DEFERRED_SYMBOL_LOAD* PIMAGEHLP_DEFERRED_SYMBOL_LOAD; +alias PIMAGEHLP_DEFERRED_SYMBOL_LOAD = IMAGEHLP_DEFERRED_SYMBOL_LOAD*; struct IMAGEHLP_DUPLICATE_SYMBOL { DWORD SizeOfStruct; @@ -273,27 +273,21 @@ struct IMAGEHLP_DUPLICATE_SYMBOL { PIMAGEHLP_SYMBOL Symbol; ULONG SelectedSymbol; } -alias IMAGEHLP_DUPLICATE_SYMBOL* PIMAGEHLP_DUPLICATE_SYMBOL; +alias PIMAGEHLP_DUPLICATE_SYMBOL = IMAGEHLP_DUPLICATE_SYMBOL*; alias DIGEST_HANDLE = HANDLE; extern (Windows) { - alias BOOL function(IMAGEHLP_STATUS_REASON, LPSTR, LPSTR, ULONG_PTR, ULONG_PTR) - PIMAGEHLP_STATUS_ROUTINE; - alias BOOL function(HANDLE , LPCVOID, LPVOID, DWORD, LPDWORD) - PREAD_PROCESS_MEMORY_ROUTINE; - alias LPVOID function(HANDLE, DWORD) PFUNCTION_TABLE_ACCESS_ROUTINE; - alias DWORD function(HANDLE, DWORD) PGET_MODULE_BASE_ROUTINE; - alias DWORD function(HANDLE, HANDLE, LPADDRESS) - PTRANSLATE_ADDRESS_ROUTINE; - alias BOOL function(LPSTR, ULONG, PVOID) PSYM_ENUMMODULES_CALLBACK; - alias BOOL function(LPSTR, ULONG, ULONG, PVOID) PSYM_ENUMSYMBOLS_CALLBACK; - alias BOOL function(LPSTR, ULONG, ULONG, PVOID) - PENUMLOADED_MODULES_CALLBACK; - alias BOOL function(HANDLE, ULONG, PVOID, PVOID) - PSYMBOL_REGISTERED_CALLBACK; - alias BOOL function(DIGEST_HANDLE refdata, PBYTE pData, DWORD dwLength) - DIGEST_FUNCTION; + alias PIMAGEHLP_STATUS_ROUTINE = BOOL function(IMAGEHLP_STATUS_REASON, LPSTR, LPSTR, ULONG_PTR, ULONG_PTR); + alias PREAD_PROCESS_MEMORY_ROUTINE = BOOL function(HANDLE , LPCVOID, LPVOID, DWORD, LPDWORD); + alias PFUNCTION_TABLE_ACCESS_ROUTINE = LPVOID function(HANDLE, DWORD); + alias PGET_MODULE_BASE_ROUTINE = DWORD function(HANDLE, DWORD); + alias PTRANSLATE_ADDRESS_ROUTINE = DWORD function(HANDLE, HANDLE, LPADDRESS); + alias PSYM_ENUMMODULES_CALLBACK = BOOL function(LPSTR, ULONG, PVOID); + alias PSYM_ENUMSYMBOLS_CALLBACK = BOOL function(LPSTR, ULONG, ULONG, PVOID); + alias PENUMLOADED_MODULES_CALLBACK = BOOL function(LPSTR, ULONG, ULONG, PVOID); + alias PSYMBOL_REGISTERED_CALLBACK = BOOL function(HANDLE, ULONG, PVOID, PVOID); + alias DIGEST_FUNCTION = BOOL function(DIGEST_HANDLE refdata, PBYTE pData, DWORD dwLength); nothrow @nogc: PIMAGE_NT_HEADERS CheckSumMappedFile(LPVOID, DWORD, LPDWORD, LPDWORD); @@ -374,7 +368,7 @@ nothrow @nogc: } version (Unicode) { - alias MapFileAndCheckSumW MapFileAndCheckSum; + alias MapFileAndCheckSum = MapFileAndCheckSumW; } else { - alias MapFileAndCheckSumA MapFileAndCheckSum; + alias MapFileAndCheckSum = MapFileAndCheckSumA; } diff --git a/runtime/druntime/src/core/sys/windows/imm.d b/runtime/druntime/src/core/sys/windows/imm.d index 4ad678c9b4..5cdea4286c 100644 --- a/runtime/druntime/src/core/sys/windows/imm.d +++ b/runtime/druntime/src/core/sys/windows/imm.d @@ -276,16 +276,16 @@ enum IMFS_DEFAULT=MFS_DEFAULT; enum STYLE_DESCRIPTION_SIZE=32; -alias DWORD HIMC; -alias DWORD HIMCC; -alias HKL* LPHKL; +alias HIMC = DWORD; +alias HIMCC = DWORD; +alias LPHKL = HKL*; struct COMPOSITIONFORM{ DWORD dwStyle; POINT ptCurrentPos; RECT rcArea; } -alias COMPOSITIONFORM* PCOMPOSITIONFORM, LPCOMPOSITIONFORM; +alias PCOMPOSITIONFORM = COMPOSITIONFORM*, LPCOMPOSITIONFORM = COMPOSITIONFORM*; struct CANDIDATEFORM{ DWORD dwIndex; @@ -293,7 +293,7 @@ struct CANDIDATEFORM{ POINT ptCurrentPos; RECT rcArea; } -alias CANDIDATEFORM* PCANDIDATEFORM, LPCANDIDATEFORM; +alias PCANDIDATEFORM = CANDIDATEFORM*, LPCANDIDATEFORM = CANDIDATEFORM*; struct CANDIDATELIST{ DWORD dwSize; @@ -304,31 +304,31 @@ struct CANDIDATELIST{ DWORD dwPageSize; DWORD[1] dwOffset; } -alias CANDIDATELIST* PCANDIDATELIST, LPCANDIDATELIST; +alias PCANDIDATELIST = CANDIDATELIST*, LPCANDIDATELIST = CANDIDATELIST*; struct REGISTERWORDA{ LPSTR lpReading; LPSTR lpWord; } -alias REGISTERWORDA* PREGISTERWORDA, LPREGISTERWORDA; +alias PREGISTERWORDA = REGISTERWORDA*, LPREGISTERWORDA = REGISTERWORDA*; struct REGISTERWORDW{ LPWSTR lpReading; LPWSTR lpWord; } -alias REGISTERWORDW* PREGISTERWORDW, LPREGISTERWORDW; +alias PREGISTERWORDW = REGISTERWORDW*, LPREGISTERWORDW = REGISTERWORDW*; struct STYLEBUFA{ DWORD dwStyle; CHAR[STYLE_DESCRIPTION_SIZE] szDescription = 0; } -alias STYLEBUFA* PSTYLEBUFA, LPSTYLEBUFA; +alias PSTYLEBUFA = STYLEBUFA*, LPSTYLEBUFA = STYLEBUFA*; struct STYLEBUFW{ DWORD dwStyle; WCHAR[STYLE_DESCRIPTION_SIZE] szDescription = 0; } -alias STYLEBUFW* PSTYLEBUFW, LPSTYLEBUFW; +alias PSTYLEBUFW = STYLEBUFW*, LPSTYLEBUFW = STYLEBUFW*; struct IMEMENUITEMINFOA{ UINT cbSize = this.sizeof; @@ -341,7 +341,7 @@ struct IMEMENUITEMINFOA{ CHAR[IMEMENUITEM_STRING_SIZE] szString = 0; HBITMAP hbmpItem; } -alias IMEMENUITEMINFOA* PIMEMENUITEMINFOA, LPIMEMENUITEMINFOA; +alias PIMEMENUITEMINFOA = IMEMENUITEMINFOA*, LPIMEMENUITEMINFOA = IMEMENUITEMINFOA*; struct IMEMENUITEMINFOW{ UINT cbSize = this.sizeof; @@ -354,28 +354,28 @@ struct IMEMENUITEMINFOW{ WCHAR[IMEMENUITEM_STRING_SIZE] szString = 0; HBITMAP hbmpItem; } -alias IMEMENUITEMINFOW* PIMEMENUITEMINFOW, LPIMEMENUITEMINFOW; +alias PIMEMENUITEMINFOW = IMEMENUITEMINFOW*, LPIMEMENUITEMINFOW = IMEMENUITEMINFOW*; extern (Windows) { -alias int function (LPCSTR, DWORD, LPCSTR, LPVOID) REGISTERWORDENUMPROCA; -alias int function (LPCWSTR, DWORD, LPCWSTR, LPVOID) REGISTERWORDENUMPROCW; +alias REGISTERWORDENUMPROCA = int function (LPCSTR, DWORD, LPCSTR, LPVOID); +alias REGISTERWORDENUMPROCW = int function (LPCWSTR, DWORD, LPCWSTR, LPVOID); } version (Unicode) { - alias REGISTERWORDENUMPROCW REGISTERWORDENUMPROC; - alias REGISTERWORDW REGISTERWORD; - alias IMEMENUITEMINFOW IMEMENUITEMINFO; - alias STYLEBUFW STYLEBUF; + alias REGISTERWORDENUMPROC = REGISTERWORDENUMPROCW; + alias REGISTERWORD = REGISTERWORDW; + alias IMEMENUITEMINFO = IMEMENUITEMINFOW; + alias STYLEBUF = STYLEBUFW; } else { - alias REGISTERWORDENUMPROCA REGISTERWORDENUMPROC; - alias REGISTERWORDA REGISTERWORD; - alias IMEMENUITEMINFOA IMEMENUITEMINFO; - alias STYLEBUFA STYLEBUF; + alias REGISTERWORDENUMPROC = REGISTERWORDENUMPROCA; + alias REGISTERWORD = REGISTERWORDA; + alias IMEMENUITEMINFO = IMEMENUITEMINFOA; + alias STYLEBUF = STYLEBUFA; } -alias STYLEBUF* PSTYLEBUF, LPSTYLEBUF; -alias REGISTERWORD* PREGISTERWORD, LPREGISTERWORD; -alias IMEMENUITEMINFO* PIMEMENUITEMINFO, LPIMEMENUITEMINFO; +alias PSTYLEBUF = STYLEBUF*, LPSTYLEBUF = STYLEBUF*; +alias PREGISTERWORD = REGISTERWORD*, LPREGISTERWORD = REGISTERWORD*; +alias PIMEMENUITEMINFO = IMEMENUITEMINFO*, LPIMEMENUITEMINFO = IMEMENUITEMINFO*; extern (Windows): @@ -444,43 +444,43 @@ DWORD ImmGetImeMenuItemsA(HIMC, DWORD, DWORD, LPIMEMENUITEMINFOA, LPIMEMENUITEMI DWORD ImmGetImeMenuItemsW(HIMC, DWORD, DWORD, LPIMEMENUITEMINFOW, LPIMEMENUITEMINFOW, DWORD); version (Unicode) { - alias ImmEnumRegisterWordW ImmEnumRegisterWord; - alias ImmGetRegisterWordStyleW ImmGetRegisterWordStyle; - alias ImmUnregisterWordW ImmUnregisterWord; - alias ImmRegisterWordW ImmRegisterWord; - alias ImmInstallIMEW ImmInstallIME; - alias ImmIsUIMessageW ImmIsUIMessage; - alias ImmGetConversionListW ImmGetConversionList; - alias ImmEscapeW ImmEscape; - alias ImmConfigureIMEW ImmConfigureIME; - alias ImmSetCompositionFontW ImmSetCompositionFont; - alias ImmGetCompositionFontW ImmGetCompositionFont; - alias ImmGetGuideLineW ImmGetGuideLine; - alias ImmGetCandidateListW ImmGetCandidateList; - alias ImmGetCandidateListCountW ImmGetCandidateListCount; - alias ImmSetCompositionStringW ImmSetCompositionString; - alias ImmGetCompositionStringW ImmGetCompositionString; - alias ImmGetDescriptionW ImmGetDescription; - alias ImmGetIMEFileNameW ImmGetIMEFileName; - alias ImmGetImeMenuItemsW ImmGetImeMenuItems; + alias ImmEnumRegisterWord = ImmEnumRegisterWordW; + alias ImmGetRegisterWordStyle = ImmGetRegisterWordStyleW; + alias ImmUnregisterWord = ImmUnregisterWordW; + alias ImmRegisterWord = ImmRegisterWordW; + alias ImmInstallIME = ImmInstallIMEW; + alias ImmIsUIMessage = ImmIsUIMessageW; + alias ImmGetConversionList = ImmGetConversionListW; + alias ImmEscape = ImmEscapeW; + alias ImmConfigureIME = ImmConfigureIMEW; + alias ImmSetCompositionFont = ImmSetCompositionFontW; + alias ImmGetCompositionFont = ImmGetCompositionFontW; + alias ImmGetGuideLine = ImmGetGuideLineW; + alias ImmGetCandidateList = ImmGetCandidateListW; + alias ImmGetCandidateListCount = ImmGetCandidateListCountW; + alias ImmSetCompositionString = ImmSetCompositionStringW; + alias ImmGetCompositionString = ImmGetCompositionStringW; + alias ImmGetDescription = ImmGetDescriptionW; + alias ImmGetIMEFileName = ImmGetIMEFileNameW; + alias ImmGetImeMenuItems = ImmGetImeMenuItemsW; } else { - alias ImmEnumRegisterWordA ImmEnumRegisterWord; - alias ImmGetRegisterWordStyleA ImmGetRegisterWordStyle; - alias ImmUnregisterWordA ImmUnregisterWord; - alias ImmRegisterWordA ImmRegisterWord; - alias ImmInstallIMEA ImmInstallIME; - alias ImmIsUIMessageA ImmIsUIMessage; - alias ImmGetConversionListA ImmGetConversionList; - alias ImmEscapeA ImmEscape; - alias ImmConfigureIMEA ImmConfigureIME; - alias ImmSetCompositionFontA ImmSetCompositionFont; - alias ImmGetCompositionFontA ImmGetCompositionFont; - alias ImmGetGuideLineA ImmGetGuideLine; - alias ImmGetCandidateListA ImmGetCandidateList; - alias ImmGetCandidateListCountA ImmGetCandidateListCount; - alias ImmSetCompositionStringA ImmSetCompositionString; - alias ImmGetCompositionStringA ImmGetCompositionString; - alias ImmGetDescriptionA ImmGetDescription; - alias ImmGetIMEFileNameA ImmGetIMEFileName; - alias ImmGetImeMenuItemsW ImmGetImeMenuItems; + alias ImmEnumRegisterWord = ImmEnumRegisterWordA; + alias ImmGetRegisterWordStyle = ImmGetRegisterWordStyleA; + alias ImmUnregisterWord = ImmUnregisterWordA; + alias ImmRegisterWord = ImmRegisterWordA; + alias ImmInstallIME = ImmInstallIMEA; + alias ImmIsUIMessage = ImmIsUIMessageA; + alias ImmGetConversionList = ImmGetConversionListA; + alias ImmEscape = ImmEscapeA; + alias ImmConfigureIME = ImmConfigureIMEA; + alias ImmSetCompositionFont = ImmSetCompositionFontA; + alias ImmGetCompositionFont = ImmGetCompositionFontA; + alias ImmGetGuideLine = ImmGetGuideLineA; + alias ImmGetCandidateList = ImmGetCandidateListA; + alias ImmGetCandidateListCount = ImmGetCandidateListCountA; + alias ImmSetCompositionString = ImmSetCompositionStringA; + alias ImmGetCompositionString = ImmGetCompositionStringA; + alias ImmGetDescription = ImmGetDescriptionA; + alias ImmGetIMEFileName = ImmGetIMEFileNameA; + alias ImmGetImeMenuItems = ImmGetImeMenuItemsW; } diff --git a/runtime/druntime/src/core/sys/windows/intshcut.d b/runtime/druntime/src/core/sys/windows/intshcut.d index cc4bf62354..d5630ea7d9 100644 --- a/runtime/druntime/src/core/sys/windows/intshcut.d +++ b/runtime/druntime/src/core/sys/windows/intshcut.d @@ -58,8 +58,8 @@ struct URLINVOKECOMMANDINFO { HWND hwndParent; PCSTR pcszVerb; } -alias URLINVOKECOMMANDINFO CURLINVOKECOMMANDINFO; -alias URLINVOKECOMMANDINFO* PURLINVOKECOMMANDINFO, PCURLINVOKECOMMANDINFO; +alias CURLINVOKECOMMANDINFO = URLINVOKECOMMANDINFO; +alias PURLINVOKECOMMANDINFO = URLINVOKECOMMANDINFO*, PCURLINVOKECOMMANDINFO = URLINVOKECOMMANDINFO*; interface IUniformResourceLocator : IUnknown { HRESULT SetURL(PCSTR, DWORD); @@ -67,8 +67,7 @@ interface IUniformResourceLocator : IUnknown { HRESULT InvokeCommand(PURLINVOKECOMMANDINFO); } //alias typeof(*(IUniformResourceLocator.init)) CIUniformResourceLocator; // value-type of interface not representable in D -alias IUniformResourceLocator PIUniformResourceLocator, - PCIUniformResourceLocator; +alias PIUniformResourceLocator = IUniformResourceLocator, PCIUniformResourceLocator = IUniformResourceLocator; extern (Windows) nothrow @nogc { BOOL InetIsOffline(DWORD); @@ -81,11 +80,11 @@ extern (Windows) nothrow @nogc { } version (Unicode) { - alias TranslateURLW TranslateURL; - alias MIMEAssociationDialogW MIMEAssociationDialog; - alias URLAssociationDialogW URLAssociationDialog; + alias TranslateURL = TranslateURLW; + alias MIMEAssociationDialog = MIMEAssociationDialogW; + alias URLAssociationDialog = URLAssociationDialogW; } else { - alias TranslateURLA TranslateURL; - alias MIMEAssociationDialogA MIMEAssociationDialog; - alias URLAssociationDialogA URLAssociationDialog; + alias TranslateURL = TranslateURLA; + alias MIMEAssociationDialog = MIMEAssociationDialogA; + alias URLAssociationDialog = URLAssociationDialogA; } diff --git a/runtime/druntime/src/core/sys/windows/ipexport.d b/runtime/druntime/src/core/sys/windows/ipexport.d index b0a4a0151a..f08e6e9223 100644 --- a/runtime/druntime/src/core/sys/windows/ipexport.d +++ b/runtime/druntime/src/core/sys/windows/ipexport.d @@ -63,7 +63,7 @@ enum : ubyte { enum ubyte MAX_OPT_SIZE = 40; -alias uint IPAddr, IPMask, IP_STATUS; +alias IPAddr = uint, IPMask = uint, IP_STATUS = uint; struct IP_OPTION_INFORMATION { ubyte Ttl; @@ -72,7 +72,7 @@ struct IP_OPTION_INFORMATION { ubyte OptionsSize; ubyte* OptionsData; } -alias IP_OPTION_INFORMATION* PIP_OPTION_INFORMATION; +alias PIP_OPTION_INFORMATION = IP_OPTION_INFORMATION*; struct ICMP_ECHO_REPLY { IPAddr Address; @@ -83,13 +83,13 @@ struct ICMP_ECHO_REPLY { void* Data; IP_OPTION_INFORMATION Options; } -alias ICMP_ECHO_REPLY* PICMP_ECHO_REPLY; +alias PICMP_ECHO_REPLY = ICMP_ECHO_REPLY*; struct IP_ADAPTER_INDEX_MAP { ULONG Index; WCHAR[MAX_ADAPTER_NAME] Name = 0; } -alias IP_ADAPTER_INDEX_MAP* PIP_ADAPTER_INDEX_MAP; +alias PIP_ADAPTER_INDEX_MAP = IP_ADAPTER_INDEX_MAP*; struct IP_INTERFACE_INFO { LONG NumAdapters; @@ -97,7 +97,7 @@ struct IP_INTERFACE_INFO { IP_ADAPTER_INDEX_MAP* Adapter() return { return _Adapter.ptr; } } -alias IP_INTERFACE_INFO* PIP_INTERFACE_INFO; +alias PIP_INTERFACE_INFO = IP_INTERFACE_INFO*; struct IP_UNIDIRECTIONAL_ADAPTER_ADDRESS { ULONG NumAdapters; @@ -105,4 +105,4 @@ struct IP_UNIDIRECTIONAL_ADAPTER_ADDRESS { IPAddr* Address() return { return _Address.ptr; } } -alias IP_UNIDIRECTIONAL_ADAPTER_ADDRESS* PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS; +alias PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS = IP_UNIDIRECTIONAL_ADAPTER_ADDRESS*; diff --git a/runtime/druntime/src/core/sys/windows/iprtrmib.d b/runtime/druntime/src/core/sys/windows/iprtrmib.d index 05c31b3dd0..58f8f34207 100644 --- a/runtime/druntime/src/core/sys/windows/iprtrmib.d +++ b/runtime/druntime/src/core/sys/windows/iprtrmib.d @@ -63,7 +63,7 @@ struct MIB_IPADDRROW { ushort unused1; ushort unused2; } -alias MIB_IPADDRROW* PMIB_IPADDRROW; +alias PMIB_IPADDRROW = MIB_IPADDRROW*; struct MIB_IPADDRTABLE { DWORD dwNumEntries; @@ -71,7 +71,7 @@ struct MIB_IPADDRTABLE { MIB_IPADDRROW* table() return { return _table.ptr; } } -alias MIB_IPADDRTABLE* PMIB_IPADDRTABLE; +alias PMIB_IPADDRTABLE = MIB_IPADDRTABLE*; struct MIB_IPFORWARDROW { DWORD dwForwardDest; @@ -89,7 +89,7 @@ struct MIB_IPFORWARDROW { DWORD dwForwardMetric4; DWORD dwForwardMetric5; } -alias MIB_IPFORWARDROW* PMIB_IPFORWARDROW; +alias PMIB_IPFORWARDROW = MIB_IPFORWARDROW*; struct MIB_IPFORWARDTABLE { DWORD dwNumEntries; @@ -97,7 +97,7 @@ struct MIB_IPFORWARDTABLE { MIB_IPFORWARDROW* table() return { return _table.ptr; } } -alias MIB_IPFORWARDTABLE* PMIB_IPFORWARDTABLE; +alias PMIB_IPFORWARDTABLE = MIB_IPFORWARDTABLE*; struct MIB_IPNETROW { DWORD dwIndex; @@ -106,7 +106,7 @@ struct MIB_IPNETROW { DWORD dwAddr; DWORD dwType; } -alias MIB_IPNETROW* PMIB_IPNETROW; +alias PMIB_IPNETROW = MIB_IPNETROW*; struct MIB_IPNETTABLE { DWORD dwNumEntries; @@ -114,7 +114,7 @@ struct MIB_IPNETTABLE { MIB_IPNETROW* table() return { return _table.ptr; } } -alias MIB_IPNETTABLE* PMIB_IPNETTABLE; +alias PMIB_IPNETTABLE = MIB_IPNETTABLE*; struct MIBICMPSTATS { DWORD dwMsgs; @@ -131,18 +131,18 @@ struct MIBICMPSTATS { DWORD dwAddrMasks; DWORD dwAddrMaskReps; } -alias MIBICMPSTATS* PMIBICMPSTATS; +alias PMIBICMPSTATS = MIBICMPSTATS*; struct MIBICMPINFO { MIBICMPSTATS icmpInStats; MIBICMPSTATS icmpOutStats; } -alias MIBICMPINFO* PMIBICMPINFO; +alias PMIBICMPINFO = MIBICMPINFO*; struct MIB_ICMP { MIBICMPINFO stats; } -alias MIB_ICMP* PMIB_ICMP; +alias PMIB_ICMP = MIB_ICMP*; struct MIB_IFROW { WCHAR[MAX_INTERFACE_NAME_LEN] wszName = 0; @@ -170,7 +170,7 @@ struct MIB_IFROW { DWORD dwDescrLen; BYTE[MAXLEN_IFDESCR] bDescr; } -alias MIB_IFROW* PMIB_IFROW; +alias PMIB_IFROW = MIB_IFROW*; struct MIB_IFTABLE { DWORD dwNumEntries; @@ -178,7 +178,7 @@ struct MIB_IFTABLE { MIB_IFROW* table() return { return _table.ptr; } } -alias MIB_IFTABLE* PMIB_IFTABLE; +alias PMIB_IFTABLE = MIB_IFTABLE*; struct MIB_IPSTATS { DWORD dwForwarding; @@ -205,7 +205,7 @@ struct MIB_IPSTATS { DWORD dwNumAddr; DWORD dwNumRoutes; } -alias MIB_IPSTATS* PMIB_IPSTATS; +alias PMIB_IPSTATS = MIB_IPSTATS*; struct MIB_TCPSTATS { DWORD dwRtoAlgorithm; @@ -224,7 +224,7 @@ struct MIB_TCPSTATS { DWORD dwOutRsts; DWORD dwNumConns; } -alias MIB_TCPSTATS* PMIB_TCPSTATS; +alias PMIB_TCPSTATS = MIB_TCPSTATS*; struct MIB_TCPROW { DWORD dwState; @@ -233,7 +233,7 @@ struct MIB_TCPROW { DWORD dwRemoteAddr; DWORD dwRemotePort; } -alias MIB_TCPROW* PMIB_TCPROW; +alias PMIB_TCPROW = MIB_TCPROW*; struct MIB_TCPTABLE { DWORD dwNumEntries; @@ -241,7 +241,7 @@ struct MIB_TCPTABLE { MIB_TCPROW* table() return { return _table.ptr; } } -alias MIB_TCPTABLE* PMIB_TCPTABLE; +alias PMIB_TCPTABLE = MIB_TCPTABLE*; struct MIB_UDPSTATS { DWORD dwInDatagrams; @@ -250,13 +250,13 @@ struct MIB_UDPSTATS { DWORD dwOutDatagrams; DWORD dwNumAddrs; } -alias MIB_UDPSTATS* PMIB_UDPSTATS; +alias PMIB_UDPSTATS = MIB_UDPSTATS*; struct MIB_UDPROW { DWORD dwLocalAddr; DWORD dwLocalPort; } -alias MIB_UDPROW* PMIB_UDPROW; +alias PMIB_UDPROW = MIB_UDPROW*; struct MIB_UDPTABLE { DWORD dwNumEntries; @@ -264,4 +264,4 @@ struct MIB_UDPTABLE { MIB_UDPROW* table() return { return _table.ptr; } } -alias MIB_UDPTABLE* PMIB_UDPTABLE; +alias PMIB_UDPTABLE = MIB_UDPTABLE*; diff --git a/runtime/druntime/src/core/sys/windows/iptypes.d b/runtime/druntime/src/core/sys/windows/iptypes.d index baaf6ae765..ecf1e272f3 100644 --- a/runtime/druntime/src/core/sys/windows/iptypes.d +++ b/runtime/druntime/src/core/sys/windows/iptypes.d @@ -41,8 +41,8 @@ enum : UINT { struct IP_ADDRESS_STRING { char[16] String = 0; } -alias IP_ADDRESS_STRING IP_MASK_STRING; -alias IP_ADDRESS_STRING* PIP_ADDRESS_STRING, PIP_MASK_STRING; +alias IP_MASK_STRING = IP_ADDRESS_STRING; +alias PIP_ADDRESS_STRING = IP_ADDRESS_STRING*, PIP_MASK_STRING = IP_ADDRESS_STRING*; struct IP_ADDR_STRING { IP_ADDR_STRING* Next; @@ -50,7 +50,7 @@ struct IP_ADDR_STRING { IP_MASK_STRING IpMask; DWORD Context; } -alias IP_ADDR_STRING* PIP_ADDR_STRING; +alias PIP_ADDR_STRING = IP_ADDR_STRING*; struct IP_ADAPTER_INFO { IP_ADAPTER_INFO* Next; @@ -72,7 +72,7 @@ struct IP_ADAPTER_INFO { time_t LeaseObtained; time_t LeaseExpires; } -alias IP_ADAPTER_INFO* PIP_ADAPTER_INFO; +alias PIP_ADAPTER_INFO = IP_ADAPTER_INFO*; struct IP_PER_ADAPTER_INFO { UINT AutoconfigEnabled; @@ -80,7 +80,7 @@ struct IP_PER_ADAPTER_INFO { PIP_ADDR_STRING CurrentDnsServer; IP_ADDR_STRING DnsServerList; } -alias IP_PER_ADAPTER_INFO* PIP_PER_ADAPTER_INFO; +alias PIP_PER_ADAPTER_INFO = IP_PER_ADAPTER_INFO*; struct FIXED_INFO { char[MAX_HOSTNAME_LEN+4] HostName = 0; @@ -93,4 +93,4 @@ struct FIXED_INFO { UINT EnableProxy; UINT EnableDns; } -alias FIXED_INFO* PFIXED_INFO; +alias PFIXED_INFO = FIXED_INFO*; diff --git a/runtime/druntime/src/core/sys/windows/lmaccess.d b/runtime/druntime/src/core/sys/windows/lmaccess.d index cf6f9d4c4d..02c5095eac 100644 --- a/runtime/druntime/src/core/sys/windows/lmaccess.d +++ b/runtime/druntime/src/core/sys/windows/lmaccess.d @@ -234,7 +234,7 @@ enum NETLOGON_REDO_NEEDED=8; struct USER_INFO_0 { LPWSTR usri0_name; } -alias USER_INFO_0* PUSER_INFO_0, LPUSER_INFO_0; +alias PUSER_INFO_0 = USER_INFO_0*, LPUSER_INFO_0 = USER_INFO_0*; struct USER_INFO_1{ LPWSTR usri1_name; @@ -246,7 +246,7 @@ struct USER_INFO_1{ DWORD usri1_flags; LPWSTR usri1_script_path; } -alias USER_INFO_1* PUSER_INFO_1, LPUSER_INFO_1; +alias PUSER_INFO_1 = USER_INFO_1*, LPUSER_INFO_1 = USER_INFO_1*; struct USER_INFO_2{ LPWSTR usri2_name; @@ -274,7 +274,7 @@ struct USER_INFO_2{ DWORD usri2_country_code; DWORD usri2_code_page; } -alias USER_INFO_2* PUSER_INFO_2, LPUSER_INFO_2; +alias PUSER_INFO_2 = USER_INFO_2*, LPUSER_INFO_2 = USER_INFO_2*; struct USER_INFO_3{ LPWSTR usri3_name; @@ -307,7 +307,7 @@ struct USER_INFO_3{ LPWSTR usri3_home_dir_drive; DWORD usri3_password_expired; } -alias USER_INFO_3* PUSER_INFO_3, LPUSER_INFO_3; +alias PUSER_INFO_3 = USER_INFO_3*, LPUSER_INFO_3 = USER_INFO_3*; struct USER_INFO_10{ LPWSTR usri10_name; @@ -315,7 +315,7 @@ struct USER_INFO_10{ LPWSTR usri10_usr_comment; LPWSTR usri10_full_name; } -alias USER_INFO_10* PUSER_INFO_10, LPUSER_INFO_10; +alias PUSER_INFO_10 = USER_INFO_10*, LPUSER_INFO_10 = USER_INFO_10*; struct USER_INFO_11{ LPWSTR usri11_name; @@ -339,7 +339,7 @@ struct USER_INFO_11{ PBYTE usri11_logon_hours; DWORD usri11_code_page; } -alias USER_INFO_11* PUSER_INFO_11, LPUSER_INFO_11; +alias PUSER_INFO_11 = USER_INFO_11*, LPUSER_INFO_11 = USER_INFO_11*; struct USER_INFO_20 { LPWSTR usri20_name; @@ -348,12 +348,12 @@ struct USER_INFO_20 { DWORD usri20_flags; DWORD usri20_user_id; } -alias USER_INFO_20* PUSER_INFO_20, LPUSER_INFO_20; +alias PUSER_INFO_20 = USER_INFO_20*, LPUSER_INFO_20 = USER_INFO_20*; struct USER_INFO_21 { BYTE[ENCRYPTED_PWLEN] usri21_password; } -alias USER_INFO_21* PUSER_INFO_21, LPUSER_INFO_21; +alias PUSER_INFO_21 = USER_INFO_21*, LPUSER_INFO_21 = USER_INFO_21*; struct USER_INFO_22{ LPWSTR usri22_name; @@ -381,108 +381,108 @@ struct USER_INFO_22{ DWORD usri22_country_code; DWORD usri22_code_page; } -alias USER_INFO_22* PUSER_INFO_22, LPUSER_INFO_22; +alias PUSER_INFO_22 = USER_INFO_22*, LPUSER_INFO_22 = USER_INFO_22*; struct USER_INFO_1003{ LPWSTR usri1003_password; } -alias USER_INFO_1003* PUSER_INFO_1003, LPUSER_INFO_1003; +alias PUSER_INFO_1003 = USER_INFO_1003*, LPUSER_INFO_1003 = USER_INFO_1003*; struct USER_INFO_1005{ DWORD usri1005_priv; } -alias USER_INFO_1005* PUSER_INFO_1005, LPUSER_INFO_1005; +alias PUSER_INFO_1005 = USER_INFO_1005*, LPUSER_INFO_1005 = USER_INFO_1005*; struct USER_INFO_1006{ LPWSTR usri1006_home_dir; } -alias USER_INFO_1006* PUSER_INFO_1006, LPUSER_INFO_1006; +alias PUSER_INFO_1006 = USER_INFO_1006*, LPUSER_INFO_1006 = USER_INFO_1006*; struct USER_INFO_1007{ LPWSTR usri1007_comment; } -alias USER_INFO_1007* PUSER_INFO_1007, LPUSER_INFO_1007; +alias PUSER_INFO_1007 = USER_INFO_1007*, LPUSER_INFO_1007 = USER_INFO_1007*; struct USER_INFO_1008{ DWORD usri1008_flags; } -alias USER_INFO_1008* PUSER_INFO_1008, LPUSER_INFO_1008; +alias PUSER_INFO_1008 = USER_INFO_1008*, LPUSER_INFO_1008 = USER_INFO_1008*; struct USER_INFO_1009{ LPWSTR usri1009_script_path; } -alias USER_INFO_1009* PUSER_INFO_1009, LPUSER_INFO_1009; +alias PUSER_INFO_1009 = USER_INFO_1009*, LPUSER_INFO_1009 = USER_INFO_1009*; struct USER_INFO_1010{ DWORD usri1010_auth_flags; } -alias USER_INFO_1010* PUSER_INFO_1010, LPUSER_INFO_1010; +alias PUSER_INFO_1010 = USER_INFO_1010*, LPUSER_INFO_1010 = USER_INFO_1010*; struct USER_INFO_1011{ LPWSTR usri1011_full_name; } -alias USER_INFO_1011* PUSER_INFO_1011, LPUSER_INFO_1011; +alias PUSER_INFO_1011 = USER_INFO_1011*, LPUSER_INFO_1011 = USER_INFO_1011*; struct USER_INFO_1012{ LPWSTR usri1012_usr_comment; } -alias USER_INFO_1012* PUSER_INFO_1012, LPUSER_INFO_1012; +alias PUSER_INFO_1012 = USER_INFO_1012*, LPUSER_INFO_1012 = USER_INFO_1012*; struct USER_INFO_1013{ LPWSTR usri1013_parms; } -alias USER_INFO_1013* PUSER_INFO_1013, LPUSER_INFO_1013; +alias PUSER_INFO_1013 = USER_INFO_1013*, LPUSER_INFO_1013 = USER_INFO_1013*; struct USER_INFO_1014{ LPWSTR usri1014_workstations; } -alias USER_INFO_1014* PUSER_INFO_1014, LPUSER_INFO_1014; +alias PUSER_INFO_1014 = USER_INFO_1014*, LPUSER_INFO_1014 = USER_INFO_1014*; struct USER_INFO_1017{ DWORD usri1017_acct_expires; } -alias USER_INFO_1017* PUSER_INFO_1017, LPUSER_INFO_1017; +alias PUSER_INFO_1017 = USER_INFO_1017*, LPUSER_INFO_1017 = USER_INFO_1017*; struct USER_INFO_1018{ DWORD usri1018_max_storage; } -alias USER_INFO_1018* PUSER_INFO_1018, LPUSER_INFO_1018; +alias PUSER_INFO_1018 = USER_INFO_1018*, LPUSER_INFO_1018 = USER_INFO_1018*; struct USER_INFO_1020{ DWORD usri1020_units_per_week; PBYTE usri1020_logon_hours; } -alias USER_INFO_1020* PUSER_INFO_1020, LPUSER_INFO_1020; +alias PUSER_INFO_1020 = USER_INFO_1020*, LPUSER_INFO_1020 = USER_INFO_1020*; struct USER_INFO_1023{ LPWSTR usri1023_logon_server; } -alias USER_INFO_1023* PUSER_INFO_1023, LPUSER_INFO_1023; +alias PUSER_INFO_1023 = USER_INFO_1023*, LPUSER_INFO_1023 = USER_INFO_1023*; struct USER_INFO_1024{ DWORD usri1024_country_code; } -alias USER_INFO_1024* PUSER_INFO_1024, LPUSER_INFO_1024; +alias PUSER_INFO_1024 = USER_INFO_1024*, LPUSER_INFO_1024 = USER_INFO_1024*; struct USER_INFO_1025{ DWORD usri1025_code_page; } -alias USER_INFO_1025* PUSER_INFO_1025, LPUSER_INFO_1025; +alias PUSER_INFO_1025 = USER_INFO_1025*, LPUSER_INFO_1025 = USER_INFO_1025*; struct USER_INFO_1051{ DWORD usri1051_primary_group_id; } -alias USER_INFO_1051* PUSER_INFO_1051, LPUSER_INFO_1051; +alias PUSER_INFO_1051 = USER_INFO_1051*, LPUSER_INFO_1051 = USER_INFO_1051*; struct USER_INFO_1052{ LPWSTR usri1052_profile; } -alias USER_INFO_1052* PUSER_INFO_1052, LPUSER_INFO_1052; +alias PUSER_INFO_1052 = USER_INFO_1052*, LPUSER_INFO_1052 = USER_INFO_1052*; struct USER_INFO_1053{ LPWSTR usri1053_home_dir_drive; } -alias USER_INFO_1053* PUSER_INFO_1053, LPUSER_INFO_1053; +alias PUSER_INFO_1053 = USER_INFO_1053*, LPUSER_INFO_1053 = USER_INFO_1053*; struct USER_MODALS_INFO_0{ DWORD usrmod0_min_passwd_len; @@ -491,72 +491,72 @@ struct USER_MODALS_INFO_0{ DWORD usrmod0_force_logoff; DWORD usrmod0_password_hist_len; } -alias USER_MODALS_INFO_0* PUSER_MODALS_INFO_0, LPUSER_MODALS_INFO_0; +alias PUSER_MODALS_INFO_0 = USER_MODALS_INFO_0*, LPUSER_MODALS_INFO_0 = USER_MODALS_INFO_0*; struct USER_MODALS_INFO_1{ DWORD usrmod1_role; LPWSTR usrmod1_primary; } -alias USER_MODALS_INFO_1* PUSER_MODALS_INFO_1, LPUSER_MODALS_INFO_1; +alias PUSER_MODALS_INFO_1 = USER_MODALS_INFO_1*, LPUSER_MODALS_INFO_1 = USER_MODALS_INFO_1*; struct USER_MODALS_INFO_2{ LPWSTR usrmod2_domain_name; PSID usrmod2_domain_id; } -alias USER_MODALS_INFO_2* PUSER_MODALS_INFO_2, LPUSER_MODALS_INFO_2; +alias PUSER_MODALS_INFO_2 = USER_MODALS_INFO_2*, LPUSER_MODALS_INFO_2 = USER_MODALS_INFO_2*; struct USER_MODALS_INFO_3{ DWORD usrmod3_lockout_duration; DWORD usrmod3_lockout_observation_window; DWORD usrmod3_lockout_threshold; } -alias USER_MODALS_INFO_3* PUSER_MODALS_INFO_3, LPUSER_MODALS_INFO_3; +alias PUSER_MODALS_INFO_3 = USER_MODALS_INFO_3*, LPUSER_MODALS_INFO_3 = USER_MODALS_INFO_3*; struct USER_MODALS_INFO_1001{ DWORD usrmod1001_min_passwd_len; } -alias USER_MODALS_INFO_1001* PUSER_MODALS_INFO_1001, LPUSER_MODALS_INFO_1001; +alias PUSER_MODALS_INFO_1001 = USER_MODALS_INFO_1001*, LPUSER_MODALS_INFO_1001 = USER_MODALS_INFO_1001*; struct USER_MODALS_INFO_1002{ DWORD usrmod1002_max_passwd_age; } -alias USER_MODALS_INFO_1002* PUSER_MODALS_INFO_1002, LPUSER_MODALS_INFO_1002; +alias PUSER_MODALS_INFO_1002 = USER_MODALS_INFO_1002*, LPUSER_MODALS_INFO_1002 = USER_MODALS_INFO_1002*; struct USER_MODALS_INFO_1003{ DWORD usrmod1003_min_passwd_age; } -alias USER_MODALS_INFO_1003* PUSER_MODALS_INFO_1003, LPUSER_MODALS_INFO_1003; +alias PUSER_MODALS_INFO_1003 = USER_MODALS_INFO_1003*, LPUSER_MODALS_INFO_1003 = USER_MODALS_INFO_1003*; struct USER_MODALS_INFO_1004{ DWORD usrmod1004_force_logoff; } -alias USER_MODALS_INFO_1004* PUSER_MODALS_INFO_1004, LPUSER_MODALS_INFO_1004; +alias PUSER_MODALS_INFO_1004 = USER_MODALS_INFO_1004*, LPUSER_MODALS_INFO_1004 = USER_MODALS_INFO_1004*; struct USER_MODALS_INFO_1005{ DWORD usrmod1005_password_hist_len; } -alias USER_MODALS_INFO_1005* PUSER_MODALS_INFO_1005, LPUSER_MODALS_INFO_1005; +alias PUSER_MODALS_INFO_1005 = USER_MODALS_INFO_1005*, LPUSER_MODALS_INFO_1005 = USER_MODALS_INFO_1005*; struct USER_MODALS_INFO_1006{ DWORD usrmod1006_role; } -alias USER_MODALS_INFO_1006* PUSER_MODALS_INFO_1006, LPUSER_MODALS_INFO_1006; +alias PUSER_MODALS_INFO_1006 = USER_MODALS_INFO_1006*, LPUSER_MODALS_INFO_1006 = USER_MODALS_INFO_1006*; struct USER_MODALS_INFO_1007{ LPWSTR usrmod1007_primary; } -alias USER_MODALS_INFO_1007* PUSER_MODALS_INFO_1007, LPUSER_MODALS_INFO_1007; +alias PUSER_MODALS_INFO_1007 = USER_MODALS_INFO_1007*, LPUSER_MODALS_INFO_1007 = USER_MODALS_INFO_1007*; struct GROUP_INFO_0{ LPWSTR grpi0_name; } -alias GROUP_INFO_0* PGROUP_INFO_0, LPGROUP_INFO_0; +alias PGROUP_INFO_0 = GROUP_INFO_0*, LPGROUP_INFO_0 = GROUP_INFO_0*; struct GROUP_INFO_1{ LPWSTR grpi1_name; LPWSTR grpi1_comment; } -alias GROUP_INFO_1* PGROUP_INFO_1, LPGROUP_INFO_1; +alias PGROUP_INFO_1 = GROUP_INFO_1*, LPGROUP_INFO_1 = GROUP_INFO_1*; struct GROUP_INFO_2{ LPWSTR grpi2_name; @@ -564,73 +564,73 @@ struct GROUP_INFO_2{ DWORD grpi2_group_id; DWORD grpi2_attributes; } -alias GROUP_INFO_2* PGROUP_INFO_2; +alias PGROUP_INFO_2 = GROUP_INFO_2*; struct GROUP_INFO_1002{ LPWSTR grpi1002_comment; } -alias GROUP_INFO_1002* PGROUP_INFO_1002, LPGROUP_INFO_1002; +alias PGROUP_INFO_1002 = GROUP_INFO_1002*, LPGROUP_INFO_1002 = GROUP_INFO_1002*; struct GROUP_INFO_1005{ DWORD grpi1005_attributes; } -alias GROUP_INFO_1005* PGROUP_INFO_1005, LPGROUP_INFO_1005; +alias PGROUP_INFO_1005 = GROUP_INFO_1005*, LPGROUP_INFO_1005 = GROUP_INFO_1005*; struct GROUP_USERS_INFO_0{ LPWSTR grui0_name; } -alias GROUP_USERS_INFO_0* PGROUP_USERS_INFO_0, LPGROUP_USERS_INFO_0; +alias PGROUP_USERS_INFO_0 = GROUP_USERS_INFO_0*, LPGROUP_USERS_INFO_0 = GROUP_USERS_INFO_0*; struct GROUP_USERS_INFO_1{ LPWSTR grui1_name; DWORD grui1_attributes; } -alias GROUP_USERS_INFO_1* PGROUP_USERS_INFO_1, LPGROUP_USERS_INFO_1; +alias PGROUP_USERS_INFO_1 = GROUP_USERS_INFO_1*, LPGROUP_USERS_INFO_1 = GROUP_USERS_INFO_1*; struct LOCALGROUP_INFO_0{ LPWSTR lgrpi0_name; } -alias LOCALGROUP_INFO_0* PLOCALGROUP_INFO_0, LPLOCALGROUP_INFO_0; +alias PLOCALGROUP_INFO_0 = LOCALGROUP_INFO_0*, LPLOCALGROUP_INFO_0 = LOCALGROUP_INFO_0*; struct LOCALGROUP_INFO_1{ LPWSTR lgrpi1_name; LPWSTR lgrpi1_comment; } -alias LOCALGROUP_INFO_1* PLOCALGROUP_INFO_1, LPLOCALGROUP_INFO_1; +alias PLOCALGROUP_INFO_1 = LOCALGROUP_INFO_1*, LPLOCALGROUP_INFO_1 = LOCALGROUP_INFO_1*; struct LOCALGROUP_INFO_1002{ LPWSTR lgrpi1002_comment; } -alias LOCALGROUP_INFO_1002* PLOCALGROUP_INFO_1002, LPLOCALGROUP_INFO_1002; +alias PLOCALGROUP_INFO_1002 = LOCALGROUP_INFO_1002*, LPLOCALGROUP_INFO_1002 = LOCALGROUP_INFO_1002*; struct LOCALGROUP_MEMBERS_INFO_0{ PSID lgrmi0_sid; } -alias LOCALGROUP_MEMBERS_INFO_0* PLOCALGROUP_MEMBERS_INFO_0, LPLOCALGROUP_MEMBERS_INFO_0; +alias PLOCALGROUP_MEMBERS_INFO_0 = LOCALGROUP_MEMBERS_INFO_0*, LPLOCALGROUP_MEMBERS_INFO_0 = LOCALGROUP_MEMBERS_INFO_0*; struct LOCALGROUP_MEMBERS_INFO_1{ PSID lgrmi1_sid; SID_NAME_USE lgrmi1_sidusage; LPWSTR lgrmi1_name; } -alias LOCALGROUP_MEMBERS_INFO_1* PLOCALGROUP_MEMBERS_INFO_1, LPLOCALGROUP_MEMBERS_INFO_1; +alias PLOCALGROUP_MEMBERS_INFO_1 = LOCALGROUP_MEMBERS_INFO_1*, LPLOCALGROUP_MEMBERS_INFO_1 = LOCALGROUP_MEMBERS_INFO_1*; struct LOCALGROUP_MEMBERS_INFO_2{ PSID lgrmi2_sid; SID_NAME_USE lgrmi2_sidusage; LPWSTR lgrmi2_domainandname; } -alias LOCALGROUP_MEMBERS_INFO_2* PLOCALGROUP_MEMBERS_INFO_2, LPLOCALGROUP_MEMBERS_INFO_2; +alias PLOCALGROUP_MEMBERS_INFO_2 = LOCALGROUP_MEMBERS_INFO_2*, LPLOCALGROUP_MEMBERS_INFO_2 = LOCALGROUP_MEMBERS_INFO_2*; struct LOCALGROUP_MEMBERS_INFO_3{ LPWSTR lgrmi3_domainandname; } -alias LOCALGROUP_MEMBERS_INFO_3* PLOCALGROUP_MEMBERS_INFO_3, LPLOCALGROUP_MEMBERS_INFO_3; +alias PLOCALGROUP_MEMBERS_INFO_3 = LOCALGROUP_MEMBERS_INFO_3*, LPLOCALGROUP_MEMBERS_INFO_3 = LOCALGROUP_MEMBERS_INFO_3*; struct LOCALGROUP_USERS_INFO_0{ LPWSTR lgrui0_name; } -alias LOCALGROUP_USERS_INFO_0* PLOCALGROUP_USERS_INFO_0, LPLOCALGROUP_USERS_INFO_0; +alias PLOCALGROUP_USERS_INFO_0 = LOCALGROUP_USERS_INFO_0*, LPLOCALGROUP_USERS_INFO_0 = LOCALGROUP_USERS_INFO_0*; struct NET_DISPLAY_USER{ LPWSTR usri1_name; @@ -640,7 +640,7 @@ struct NET_DISPLAY_USER{ DWORD usri1_user_id; DWORD usri1_next_index; } -alias NET_DISPLAY_USER* PNET_DISPLAY_USER; +alias PNET_DISPLAY_USER = NET_DISPLAY_USER*; struct NET_DISPLAY_MACHINE{ LPWSTR usri2_name; @@ -649,7 +649,7 @@ struct NET_DISPLAY_MACHINE{ DWORD usri2_user_id; DWORD usri2_next_index; } -alias NET_DISPLAY_MACHINE* PNET_DISPLAY_MACHINE; +alias PNET_DISPLAY_MACHINE = NET_DISPLAY_MACHINE*; struct NET_DISPLAY_GROUP{ LPWSTR grpi3_name; @@ -658,36 +658,36 @@ struct NET_DISPLAY_GROUP{ DWORD grpi3_attributes; DWORD grpi3_next_index; } -alias NET_DISPLAY_GROUP* PNET_DISPLAY_GROUP; +alias PNET_DISPLAY_GROUP = NET_DISPLAY_GROUP*; struct ACCESS_INFO_0{ LPTSTR acc0_resource_name; } -alias ACCESS_INFO_0* PACCESS_INFO_0, LPACCESS_INFO_0; +alias PACCESS_INFO_0 = ACCESS_INFO_0*, LPACCESS_INFO_0 = ACCESS_INFO_0*; struct ACCESS_INFO_1{ LPTSTR acc1_resource_name; DWORD acc1_attr; DWORD acc1_count; } -alias ACCESS_INFO_1* PACCESS_INFO_1, LPACCESS_INFO_1; +alias PACCESS_INFO_1 = ACCESS_INFO_1*, LPACCESS_INFO_1 = ACCESS_INFO_1*; struct ACCESS_INFO_1002{ DWORD acc1002_attr; } -alias ACCESS_INFO_1002* PACCESS_INFO_1002, LPACCESS_INFO_1002; +alias PACCESS_INFO_1002 = ACCESS_INFO_1002*, LPACCESS_INFO_1002 = ACCESS_INFO_1002*; struct ACCESS_LIST{ LPTSTR acl_ugname; DWORD acl_access; } -alias ACCESS_LIST* PACCESS_LIST, LPACCESS_LIST; +alias PACCESS_LIST = ACCESS_LIST*, LPACCESS_LIST = ACCESS_LIST*; struct NETLOGON_INFO_1{ DWORD netlog1_flags; NET_API_STATUS netlog1_pdc_connection_status; } -alias NETLOGON_INFO_1* PNETLOGON_INFO_1; +alias PNETLOGON_INFO_1 = NETLOGON_INFO_1*; struct NETLOGON_INFO_2{ DWORD netlog2_flags; @@ -695,7 +695,7 @@ struct NETLOGON_INFO_2{ LPWSTR netlog2_trusted_dc_name; NET_API_STATUS netlog2_tc_connection_status; } -alias NETLOGON_INFO_2* PNETLOGON_INFO_2; +alias PNETLOGON_INFO_2 = NETLOGON_INFO_2*; struct NETLOGON_INFO_3{ DWORD netlog3_flags; @@ -706,7 +706,7 @@ struct NETLOGON_INFO_3{ DWORD netlog3_reserved4; DWORD netlog3_reserved5; } -alias NETLOGON_INFO_3* PNETLOGON_INFO_3; +alias PNETLOGON_INFO_3 = NETLOGON_INFO_3*; extern (Windows) nothrow @nogc { deprecated { diff --git a/runtime/druntime/src/core/sys/windows/lmalert.d b/runtime/druntime/src/core/sys/windows/lmalert.d index acb96cfbc9..a2aa4de2c1 100644 --- a/runtime/druntime/src/core/sys/windows/lmalert.d +++ b/runtime/druntime/src/core/sys/windows/lmalert.d @@ -42,20 +42,20 @@ struct ADMIN_OTHER_INFO{ DWORD alrtad_errcode; DWORD alrtad_numstrings; } -alias ADMIN_OTHER_INFO* PADMIN_OTHER_INFO, LPADMIN_OTHER_INFO; +alias PADMIN_OTHER_INFO = ADMIN_OTHER_INFO*, LPADMIN_OTHER_INFO = ADMIN_OTHER_INFO*; struct STD_ALERT{ DWORD alrt_timestamp; TCHAR[EVLEN+1] alrt_eventname = 0; TCHAR[SNLEN+1] alrt_servicename = 0; } -alias STD_ALERT* PSTD_ALERT, LPSTD_ALERT; +alias PSTD_ALERT = STD_ALERT*, LPSTD_ALERT = STD_ALERT*; struct ERRLOG_OTHER_INFO{ DWORD alrter_errcode; DWORD alrter_offset; } -alias ERRLOG_OTHER_INFO* PERRLOG_OTHER_INFO, LPERRLOG_OTHER_INFO; +alias PERRLOG_OTHER_INFO = ERRLOG_OTHER_INFO*, LPERRLOG_OTHER_INFO = ERRLOG_OTHER_INFO*; struct PRINT_OTHER_INFO{ DWORD alrtpr_jobid; @@ -63,13 +63,13 @@ struct PRINT_OTHER_INFO{ DWORD alrtpr_submitted; DWORD alrtpr_size; } -alias PRINT_OTHER_INFO* PPRINT_OTHER_INFO, LPPRINT_OTHER_INFO; +alias PPRINT_OTHER_INFO = PRINT_OTHER_INFO*, LPPRINT_OTHER_INFO = PRINT_OTHER_INFO*; struct USER_OTHER_INFO{ DWORD alrtus_errcode; DWORD alrtus_numstrings; } -alias USER_OTHER_INFO* PUSER_OTHER_INFO, LPUSER_OTHER_INFO; +alias PUSER_OTHER_INFO = USER_OTHER_INFO*, LPUSER_OTHER_INFO = USER_OTHER_INFO*; extern (Windows) nothrow @nogc { NET_API_STATUS NetAlertRaise(LPCWSTR,PVOID,DWORD); diff --git a/runtime/druntime/src/core/sys/windows/lmat.d b/runtime/druntime/src/core/sys/windows/lmat.d index ee1249e915..7c593efaba 100644 --- a/runtime/druntime/src/core/sys/windows/lmat.d +++ b/runtime/druntime/src/core/sys/windows/lmat.d @@ -30,7 +30,7 @@ struct AT_ENUM { UCHAR Flags; LPWSTR Command; } -alias AT_ENUM* PAT_ENUM, LPAT_ENUM; +alias PAT_ENUM = AT_ENUM*, LPAT_ENUM = AT_ENUM*; struct AT_INFO { DWORD_PTR JobTime; @@ -39,7 +39,7 @@ struct AT_INFO { UCHAR Flags; LPWSTR Command; } -alias AT_INFO* PAT_INFO, LPAT_INFO; +alias PAT_INFO = AT_INFO*, LPAT_INFO = AT_INFO*; extern (Windows) { NET_API_STATUS NetScheduleJobAdd(LPWSTR, PBYTE, LPDWORD); diff --git a/runtime/druntime/src/core/sys/windows/lmaudit.d b/runtime/druntime/src/core/sys/windows/lmaudit.d index 8db56f1763..88f1588dc6 100644 --- a/runtime/druntime/src/core/sys/windows/lmaudit.d +++ b/runtime/druntime/src/core/sys/windows/lmaudit.d @@ -97,7 +97,7 @@ struct AUDIT_ENTRY{ DWORD ae_data_offset; DWORD ae_data_size; } -alias AUDIT_ENTRY* PAUDIT_ENTRY, LPAUDIT_ENTRY; +alias PAUDIT_ENTRY = AUDIT_ENTRY*, LPAUDIT_ENTRY = AUDIT_ENTRY*; struct HLOG{ DWORD time; @@ -105,32 +105,32 @@ struct HLOG{ DWORD offset; DWORD rec_offset; } -alias HLOG* PHLOG, LPHLOG; +alias PHLOG = HLOG*, LPHLOG = HLOG*; struct AE_SRVSTATUS{ DWORD ae_sv_status; } -alias AE_SRVSTATUS* PAE_SRVSTATUS, LPAE_SRVSTATUS; +alias PAE_SRVSTATUS = AE_SRVSTATUS*, LPAE_SRVSTATUS = AE_SRVSTATUS*; struct AE_SESSLOGON{ DWORD ae_so_compname; DWORD ae_so_username; DWORD ae_so_privilege; } -alias AE_SESSLOGON* PAE_SESSLOGON, LPAE_SESSLOGON; +alias PAE_SESSLOGON = AE_SESSLOGON*, LPAE_SESSLOGON = AE_SESSLOGON*; struct AE_SESSLOGOFF{ DWORD ae_sf_compname; DWORD ae_sf_username; DWORD ae_sf_reason; } -alias AE_SESSLOGOFF* PAE_SESSLOGOFF, LPAE_SESSLOGOFF; +alias PAE_SESSLOGOFF = AE_SESSLOGOFF*, LPAE_SESSLOGOFF = AE_SESSLOGOFF*; struct AE_SESSPWERR{ DWORD ae_sp_compname; DWORD ae_sp_username; } -alias AE_SESSPWERR* PAE_SESSPWERR, LPAE_SESSPWERR; +alias PAE_SESSPWERR = AE_SESSPWERR*, LPAE_SESSPWERR = AE_SESSPWERR*; struct AE_CONNSTART{ DWORD ae_ct_compname; @@ -138,7 +138,7 @@ struct AE_CONNSTART{ DWORD ae_ct_netname; DWORD ae_ct_connid; } -alias AE_CONNSTART* PAE_CONNSTART, LPAE_CONNSTART; +alias PAE_CONNSTART = AE_CONNSTART*, LPAE_CONNSTART = AE_CONNSTART*; struct AE_CONNSTOP{ DWORD ae_cp_compname; @@ -147,7 +147,7 @@ struct AE_CONNSTOP{ DWORD ae_cp_connid; DWORD ae_cp_reason; } -alias AE_CONNSTOP* PAE_CONNSTOP, LPAE_CONNSTOP; +alias PAE_CONNSTOP = AE_CONNSTOP*, LPAE_CONNSTOP = AE_CONNSTOP*; struct AE_CONNREJ{ DWORD ae_cr_compname; @@ -155,7 +155,7 @@ struct AE_CONNREJ{ DWORD ae_cr_netname; DWORD ae_cr_reason; } -alias AE_CONNREJ* PAE_CONNREJ, LPAE_CONNREJ; +alias PAE_CONNREJ = AE_CONNREJ*, LPAE_CONNREJ = AE_CONNREJ*; struct AE_RESACCESS{ DWORD ae_ra_compname; @@ -166,7 +166,7 @@ struct AE_RESACCESS{ DWORD ae_ra_restype; DWORD ae_ra_fileid; } -alias AE_RESACCESS* PAE_RESACCESS, LPAE_RESACCESS; +alias PAE_RESACCESS = AE_RESACCESS*, LPAE_RESACCESS = AE_RESACCESS*; struct AE_RESACCESSREJ{ DWORD ae_rr_compname; @@ -174,7 +174,7 @@ struct AE_RESACCESSREJ{ DWORD ae_rr_resname; DWORD ae_rr_operation; } -alias AE_RESACCESSREJ* PAE_RESACCESSREJ, LPAE_RESACCESSREJ; +alias PAE_RESACCESSREJ = AE_RESACCESSREJ*, LPAE_RESACCESSREJ = AE_RESACCESSREJ*; struct AE_CLOSEFILE{ DWORD ae_cf_compname; @@ -184,7 +184,7 @@ struct AE_CLOSEFILE{ DWORD ae_cf_duration; DWORD ae_cf_reason; } -alias AE_CLOSEFILE* PAE_CLOSEFILE, LPAE_CLOSEFILE; +alias PAE_CLOSEFILE = AE_CLOSEFILE*, LPAE_CLOSEFILE = AE_CLOSEFILE*; struct AE_SERVICESTAT{ DWORD ae_ss_compname; @@ -195,7 +195,7 @@ struct AE_SERVICESTAT{ DWORD ae_ss_text; DWORD ae_ss_returnval; } -alias AE_SERVICESTAT* PAE_SERVICESTAT, LPAE_SERVICESTAT; +alias PAE_SERVICESTAT = AE_SERVICESTAT*, LPAE_SERVICESTAT = AE_SERVICESTAT*; struct AE_ACLMOD{ DWORD ae_am_compname; @@ -204,7 +204,7 @@ struct AE_ACLMOD{ DWORD ae_am_action; DWORD ae_am_datalen; } -alias AE_ACLMOD* PAE_ACLMOD, LPAE_ACLMOD; +alias PAE_ACLMOD = AE_ACLMOD*, LPAE_ACLMOD = AE_ACLMOD*; struct AE_UASMOD{ DWORD ae_um_compname; @@ -214,7 +214,7 @@ struct AE_UASMOD{ DWORD ae_um_action; DWORD ae_um_datalen; } -alias AE_UASMOD* PAE_UASMOD, LPAE_UASMOD; +alias PAE_UASMOD = AE_UASMOD*, LPAE_UASMOD = AE_UASMOD*; struct AE_NETLOGON{ DWORD ae_no_compname; @@ -222,7 +222,7 @@ struct AE_NETLOGON{ DWORD ae_no_privilege; DWORD ae_no_authflags; } -alias AE_NETLOGON* PAE_NETLOGON, LPAE_NETLOGON; +alias PAE_NETLOGON = AE_NETLOGON*, LPAE_NETLOGON = AE_NETLOGON*; struct AE_NETLOGOFF{ DWORD ae_nf_compname; @@ -230,7 +230,7 @@ struct AE_NETLOGOFF{ DWORD ae_nf_reserved1; DWORD ae_nf_reserved2; } -alias AE_NETLOGOFF* PAE_NETLOGOFF, LPAE_NETLOGOFF; +alias PAE_NETLOGOFF = AE_NETLOGOFF*, LPAE_NETLOGOFF = AE_NETLOGOFF*; struct AE_ACCLIM{ DWORD ae_al_compname; @@ -238,7 +238,7 @@ struct AE_ACCLIM{ DWORD ae_al_resname; DWORD ae_al_limit; } -alias AE_ACCLIM* PAE_ACCLIM, LPAE_ACCLIM; +alias PAE_ACCLIM = AE_ACCLIM*, LPAE_ACCLIM = AE_ACCLIM*; struct AE_LOCKOUT{ DWORD ae_lk_compname; @@ -246,7 +246,7 @@ struct AE_LOCKOUT{ DWORD ae_lk_action; DWORD ae_lk_bad_pw_count; } -alias AE_LOCKOUT* PAE_LOCKOUT, LPAE_LOCKOUT; +alias PAE_LOCKOUT = AE_LOCKOUT*, LPAE_LOCKOUT = AE_LOCKOUT*; struct AE_GENERIC{ DWORD ae_ge_msgfile; @@ -262,7 +262,7 @@ struct AE_GENERIC{ DWORD ae_ge_param8; DWORD ae_ge_param9; } -alias AE_GENERIC* PAE_GENERIC, LPAE_GENERIC; +alias PAE_GENERIC = AE_GENERIC*, LPAE_GENERIC = AE_GENERIC*; extern (Windows) { deprecated { diff --git a/runtime/druntime/src/core/sys/windows/lmbrowsr.d b/runtime/druntime/src/core/sys/windows/lmbrowsr.d index 16cc661139..3d96b36155 100644 --- a/runtime/druntime/src/core/sys/windows/lmbrowsr.d +++ b/runtime/druntime/src/core/sys/windows/lmbrowsr.d @@ -35,7 +35,7 @@ struct BROWSER_STATISTICS { ULONG NumberOfDuplicateMasterAnnouncements; LARGE_INTEGER NumberOfIllegalDatagrams; } -alias BROWSER_STATISTICS* PBROWSER_STATISTICS, LPBROWSER_STATISTICS; +alias PBROWSER_STATISTICS = BROWSER_STATISTICS*, LPBROWSER_STATISTICS = BROWSER_STATISTICS*; struct BROWSER_STATISTICS_100 { LARGE_INTEGER StartTime; @@ -46,7 +46,7 @@ struct BROWSER_STATISTICS_100 { ULONG NumberOfGetBrowserServerListRequests; LARGE_INTEGER NumberOfIllegalDatagrams; } -alias BROWSER_STATISTICS_100* PBROWSER_STATISTICS_100; +alias PBROWSER_STATISTICS_100 = BROWSER_STATISTICS_100*; struct BROWSER_STATISTICS_101 { LARGE_INTEGER StartTime; @@ -66,7 +66,7 @@ struct BROWSER_STATISTICS_101 { ULONG NumberOfFailedMailslotOpens; ULONG NumberOfDuplicateMasterAnnouncements; } -alias BROWSER_STATISTICS_101* PBROWSER_STATISTICS_101; +alias PBROWSER_STATISTICS_101 = BROWSER_STATISTICS_101*; extern (Windows) { NET_API_STATUS I_BrowserServerEnum(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, diff --git a/runtime/druntime/src/core/sys/windows/lmchdev.d b/runtime/druntime/src/core/sys/windows/lmchdev.d index 55460e16bd..db496aae60 100644 --- a/runtime/druntime/src/core/sys/windows/lmchdev.d +++ b/runtime/druntime/src/core/sys/windows/lmchdev.d @@ -36,7 +36,7 @@ enum CHARDEVQ_MIN_PRIORITY = 9; struct CHARDEV_INFO_0 { LPWSTR ch0_dev; } -alias CHARDEV_INFO_0* PCHARDEV_INFO_0, LPCHARDEV_INFO_0; +alias PCHARDEV_INFO_0 = CHARDEV_INFO_0*, LPCHARDEV_INFO_0 = CHARDEV_INFO_0*; struct CHARDEV_INFO_1{ LPWSTR ch1_dev; @@ -44,12 +44,12 @@ struct CHARDEV_INFO_1{ LPWSTR ch1_username; DWORD ch1_time; } -alias CHARDEV_INFO_1* PCHARDEV_INFO_1, LPCHARDEV_INFO_1; +alias PCHARDEV_INFO_1 = CHARDEV_INFO_1*, LPCHARDEV_INFO_1 = CHARDEV_INFO_1*; struct CHARDEVQ_INFO_0 { LPWSTR cq0_dev; } -alias CHARDEVQ_INFO_0* PCHARDEVQ_INFO_0, LPCHARDEVQ_INFO_0; +alias PCHARDEVQ_INFO_0 = CHARDEVQ_INFO_0*, LPCHARDEVQ_INFO_0 = CHARDEVQ_INFO_0*; struct CHARDEVQ_INFO_1{ LPWSTR cq1_dev; @@ -58,23 +58,23 @@ struct CHARDEVQ_INFO_1{ DWORD cq1_numusers; DWORD cq1_numahead; } -alias CHARDEVQ_INFO_1* PCHARDEVQ_INFO_1, LPCHARDEVQ_INFO_1; +alias PCHARDEVQ_INFO_1 = CHARDEVQ_INFO_1*, LPCHARDEVQ_INFO_1 = CHARDEVQ_INFO_1*; struct CHARDEVQ_INFO_1002 { DWORD cq1002_priority; } -alias CHARDEVQ_INFO_1002* PCHARDEVQ_INFO_1002, LPCHARDEVQ_INFO_1002; +alias PCHARDEVQ_INFO_1002 = CHARDEVQ_INFO_1002*, LPCHARDEVQ_INFO_1002 = CHARDEVQ_INFO_1002*; struct CHARDEVQ_INFO_1003 { LPWSTR cq1003_devs; } -alias CHARDEVQ_INFO_1003* PCHARDEVQ_INFO_1003, LPCHARDEVQ_INFO_1003; +alias PCHARDEVQ_INFO_1003 = CHARDEVQ_INFO_1003*, LPCHARDEVQ_INFO_1003 = CHARDEVQ_INFO_1003*; struct HANDLE_INFO_1{ DWORD hdli1_chartime; DWORD hdli1_charcount; } -alias HANDLE_INFO_1* PHANDLE_INFO_1, LPHANDLE_INFO_1; +alias PHANDLE_INFO_1 = HANDLE_INFO_1*, LPHANDLE_INFO_1 = HANDLE_INFO_1*; extern (Windows) { NET_API_STATUS NetCharDevEnum(LPCWSTR, DWORD, PBYTE*, DWORD, PDWORD, PDWORD, PDWORD); diff --git a/runtime/druntime/src/core/sys/windows/lmconfig.d b/runtime/druntime/src/core/sys/windows/lmconfig.d index 6652a52144..10172c6036 100644 --- a/runtime/druntime/src/core/sys/windows/lmconfig.d +++ b/runtime/druntime/src/core/sys/windows/lmconfig.d @@ -19,7 +19,7 @@ deprecated { LPWSTR cfgi0_data; } - alias CONFIG_INFO_0* PCONFIG_INFO_0, LPCONFIG_INFO_0; + alias PCONFIG_INFO_0 = CONFIG_INFO_0*, LPCONFIG_INFO_0 = CONFIG_INFO_0*; extern (Windows) { NET_API_STATUS NetConfigGet(LPCWSTR, LPCWSTR, LPCWSTR, PBYTE*); diff --git a/runtime/druntime/src/core/sys/windows/lmcons.d b/runtime/druntime/src/core/sys/windows/lmcons.d index 838748a138..a16294c7b4 100644 --- a/runtime/druntime/src/core/sys/windows/lmcons.d +++ b/runtime/druntime/src/core/sys/windows/lmcons.d @@ -19,7 +19,7 @@ const TCHAR[] OS2MSG_FILENAME = "BASE", HELP_MSG_FILENAME = "NETH"; -alias DWORD NET_API_STATUS, API_RET_TYPE; +alias NET_API_STATUS = DWORD, API_RET_TYPE = DWORD; enum MIN_LANMAN_MESSAGE_ID = NERR_BASE; enum MAX_LANMAN_MESSAGE_ID = 5799; @@ -80,9 +80,9 @@ enum PLATFORM_ID_VMS = 700; // this is a new typedef in W2K, but it should be harmless for earlier Windows versions. version (Unicode) { - alias LPWSTR LMSTR; - alias LPCWSTR LMCSTR; + alias LMSTR = LPWSTR; + alias LMCSTR = LPCWSTR; } else { - alias LPSTR LMSTR; - alias LPCSTR LMCSTR; + alias LMSTR = LPSTR; + alias LMCSTR = LPCSTR; } diff --git a/runtime/druntime/src/core/sys/windows/lmerrlog.d b/runtime/druntime/src/core/sys/windows/lmerrlog.d index effe73a9ae..159e010c04 100644 --- a/runtime/druntime/src/core/sys/windows/lmerrlog.d +++ b/runtime/druntime/src/core/sys/windows/lmerrlog.d @@ -209,7 +209,7 @@ struct ERROR_LOG { DWORD el_data_size; DWORD el_nstrings; } -alias ERROR_LOG* PERROR_LOG, LPERROR_LOG; +alias PERROR_LOG = ERROR_LOG*, LPERROR_LOG = ERROR_LOG*; extern (Windows) { deprecated { diff --git a/runtime/druntime/src/core/sys/windows/lmmsg.d b/runtime/druntime/src/core/sys/windows/lmmsg.d index eab8788274..40ad5f7ec1 100644 --- a/runtime/druntime/src/core/sys/windows/lmmsg.d +++ b/runtime/druntime/src/core/sys/windows/lmmsg.d @@ -23,14 +23,14 @@ enum MSGNAME_FORWARDED_FROM = 16; struct MSG_INFO_0 { LPWSTR msgi0_name; } -alias MSG_INFO_0* PMSG_INFO_0, LPMSG_INFO_0; +alias PMSG_INFO_0 = MSG_INFO_0*, LPMSG_INFO_0 = MSG_INFO_0*; struct MSG_INFO_1 { LPWSTR msgi1_name; DWORD msgi1_forward_flag; LPWSTR msgi1_forward; } -alias MSG_INFO_1* PMSG_INFO_1, LPMSG_INFO_1; +alias PMSG_INFO_1 = MSG_INFO_1*, LPMSG_INFO_1 = MSG_INFO_1*; extern (Windows) nothrow @nogc { NET_API_STATUS NetMessageBufferSend(LPCWSTR, LPCWSTR, LPCWSTR, PBYTE, diff --git a/runtime/druntime/src/core/sys/windows/lmremutl.d b/runtime/druntime/src/core/sys/windows/lmremutl.d index 196be667fe..565feea377 100644 --- a/runtime/druntime/src/core/sys/windows/lmremutl.d +++ b/runtime/druntime/src/core/sys/windows/lmremutl.d @@ -32,9 +32,9 @@ enum USE_SPECIFIC_TRANSPORT = 0x80000000; //[No] typedef WCHAR DESC_CHAR; //[No] #endif // FIXME (D): Is this OK? -alias TCHAR DESC_CHAR; +alias DESC_CHAR = TCHAR; -alias DESC_CHAR* LPDESC; +alias LPDESC = DESC_CHAR*; struct TIME_OF_DAY_INFO { DWORD tod_elapsedt; @@ -50,7 +50,7 @@ struct TIME_OF_DAY_INFO { DWORD tod_year; DWORD tod_weekday; } -alias TIME_OF_DAY_INFO* PTIME_OF_DAY_INFO, LPTIME_OF_DAY_INFO; +alias PTIME_OF_DAY_INFO = TIME_OF_DAY_INFO*, LPTIME_OF_DAY_INFO = TIME_OF_DAY_INFO*; extern (Windows) nothrow @nogc { NET_API_STATUS NetRemoteTOD(LPCWSTR, PBYTE*); diff --git a/runtime/druntime/src/core/sys/windows/lmrepl.d b/runtime/druntime/src/core/sys/windows/lmrepl.d index 1563a5e290..1cf9ed838b 100644 --- a/runtime/druntime/src/core/sys/windows/lmrepl.d +++ b/runtime/druntime/src/core/sys/windows/lmrepl.d @@ -47,39 +47,39 @@ struct REPL_INFO_0 { DWORD rp0_guardtime; DWORD rp0_random; } -alias REPL_INFO_0* PREPL_INFO_0, LPREPL_INFO_0; +alias PREPL_INFO_0 = REPL_INFO_0*, LPREPL_INFO_0 = REPL_INFO_0*; struct REPL_INFO_1000 { DWORD rp1000_interval; } -alias REPL_INFO_1000* PREPL_INFO_1000, LPREPL_INFO_1000; +alias PREPL_INFO_1000 = REPL_INFO_1000*, LPREPL_INFO_1000 = REPL_INFO_1000*; struct REPL_INFO_1001 { DWORD rp1001_pulse; } -alias REPL_INFO_1001* PREPL_INFO_1001, LPREPL_INFO_1001; +alias PREPL_INFO_1001 = REPL_INFO_1001*, LPREPL_INFO_1001 = REPL_INFO_1001*; struct REPL_INFO_1002 { DWORD rp1002_guardtime; } -alias REPL_INFO_1002* PREPL_INFO_1002, LPREPL_INFO_1002; +alias PREPL_INFO_1002 = REPL_INFO_1002*, LPREPL_INFO_1002 = REPL_INFO_1002*; struct REPL_INFO_1003 { DWORD rp1003_random; } -alias REPL_INFO_1003* PREPL_INFO_1003, LPREPL_INFO_1003; +alias PREPL_INFO_1003 = REPL_INFO_1003*, LPREPL_INFO_1003 = REPL_INFO_1003*; struct REPL_EDIR_INFO_0 { LPWSTR rped0_dirname; } -alias REPL_EDIR_INFO_0* PREPL_EDIR_INFO_0, LPREPL_EDIR_INFO_0; +alias PREPL_EDIR_INFO_0 = REPL_EDIR_INFO_0*, LPREPL_EDIR_INFO_0 = REPL_EDIR_INFO_0*; struct REPL_EDIR_INFO_1 { LPWSTR rped1_dirname; DWORD rped1_integrity; DWORD rped1_extent; } -alias REPL_EDIR_INFO_1* PREPL_EDIR_INFO_1, LPREPL_EDIR_INFO_1; +alias PREPL_EDIR_INFO_1 = REPL_EDIR_INFO_1*, LPREPL_EDIR_INFO_1 = REPL_EDIR_INFO_1*; struct REPL_EDIR_INFO_2 { LPWSTR rped2_dirname; @@ -88,22 +88,22 @@ struct REPL_EDIR_INFO_2 { DWORD rped2_lockcount; DWORD rped2_locktime; } -alias REPL_EDIR_INFO_2* PREPL_EDIR_INFO_2, LPREPL_EDIR_INFO_2; +alias PREPL_EDIR_INFO_2 = REPL_EDIR_INFO_2*, LPREPL_EDIR_INFO_2 = REPL_EDIR_INFO_2*; struct REPL_EDIR_INFO_1000 { DWORD rped1000_integrity; } -alias REPL_EDIR_INFO_1000* PREPL_EDIR_INFO_1000, LPREPL_EDIR_INFO_1000; +alias PREPL_EDIR_INFO_1000 = REPL_EDIR_INFO_1000*, LPREPL_EDIR_INFO_1000 = REPL_EDIR_INFO_1000*; struct REPL_EDIR_INFO_1001 { DWORD rped1001_extent; } -alias REPL_EDIR_INFO_1001* PREPL_EDIR_INFO_1001, LPREPL_EDIR_INFO_1001; +alias PREPL_EDIR_INFO_1001 = REPL_EDIR_INFO_1001*, LPREPL_EDIR_INFO_1001 = REPL_EDIR_INFO_1001*; struct REPL_IDIR_INFO_0 { LPWSTR rpid0_dirname; } -alias REPL_IDIR_INFO_0* PREPL_IDIR_INFO_0, LPREPL_IDIR_INFO_0; +alias PREPL_IDIR_INFO_0 = REPL_IDIR_INFO_0*, LPREPL_IDIR_INFO_0 = REPL_IDIR_INFO_0*; struct REPL_IDIR_INFO_1 { LPWSTR rpid1_dirname; @@ -113,7 +113,7 @@ struct REPL_IDIR_INFO_1 { DWORD rpid1_lockcount; DWORD rpid1_locktime; } -alias REPL_IDIR_INFO_1* PREPL_IDIR_INFO_1, LPREPL_IDIR_INFO_1; +alias PREPL_IDIR_INFO_1 = REPL_IDIR_INFO_1*, LPREPL_IDIR_INFO_1 = REPL_IDIR_INFO_1*; extern (Windows) { NET_API_STATUS NetReplGetInfo(LPCWSTR,DWORD,PBYTE*); diff --git a/runtime/druntime/src/core/sys/windows/lmserver.d b/runtime/druntime/src/core/sys/windows/lmserver.d index 5a550bca80..8e5ad0845d 100644 --- a/runtime/druntime/src/core/sys/windows/lmserver.d +++ b/runtime/druntime/src/core/sys/windows/lmserver.d @@ -16,7 +16,7 @@ struct SERVER_INFO_100 { DWORD sv100_platform_id; LPWSTR sv100_name; } -alias SERVER_INFO_100* PSERVER_INFO_100, LPSERVER_INFO_100; +alias PSERVER_INFO_100 = SERVER_INFO_100*, LPSERVER_INFO_100 = SERVER_INFO_100*; struct SERVER_INFO_101 { DWORD sv101_platform_id; @@ -26,7 +26,7 @@ struct SERVER_INFO_101 { DWORD sv101_type; LPWSTR sv101_comment; } -alias SERVER_INFO_101* PSERVER_INFO_101, LPSERVER_INFO_101; +alias PSERVER_INFO_101 = SERVER_INFO_101*, LPSERVER_INFO_101 = SERVER_INFO_101*; struct SERVER_INFO_102 { DWORD sv102_platform_id; @@ -43,7 +43,7 @@ struct SERVER_INFO_102 { DWORD sv102_licenses; LPWSTR sv102_userpath; } -alias SERVER_INFO_102* PSERVER_INFO_102, LPSERVER_INFO_102; +alias PSERVER_INFO_102 = SERVER_INFO_102*, LPSERVER_INFO_102 = SERVER_INFO_102*; struct SERVER_INFO_402 { DWORD sv402_ulist_mtime; @@ -78,7 +78,7 @@ struct SERVER_INFO_402 { DWORD sv402_maxauditsz; LPWSTR sv402_srvheuristics; } -alias SERVER_INFO_402* PSERVER_INFO_402, LPSERVER_INFO_402; +alias PSERVER_INFO_402 = SERVER_INFO_402*, LPSERVER_INFO_402 = SERVER_INFO_402*; struct SERVER_INFO_403 { DWORD sv403_ulist_mtime; @@ -116,7 +116,7 @@ struct SERVER_INFO_403 { DWORD sv403_autoprofile; LPWSTR sv403_autopath; } -alias SERVER_INFO_403* PSERVER_INFO_403, LPSERVER_INFO_403; +alias PSERVER_INFO_403 = SERVER_INFO_403*, LPSERVER_INFO_403 = SERVER_INFO_403*; struct SERVER_INFO_502 { DWORD sv502_sessopens; @@ -138,7 +138,7 @@ struct SERVER_INFO_502 { BOOL sv502_acceptdownlevelapis; BOOL sv502_lmannounce; } -alias SERVER_INFO_502* PSERVER_INFO_502, LPSERVER_INFO_502; +alias PSERVER_INFO_502 = SERVER_INFO_502*, LPSERVER_INFO_502 = SERVER_INFO_502*; struct SERVER_INFO_503 { DWORD sv503_sessopens; @@ -184,7 +184,7 @@ struct SERVER_INFO_503 { DWORD sv503_minfreeconnections; DWORD sv503_maxfreeconnections; } -alias SERVER_INFO_503* PSERVER_INFO_503, LPSERVER_INFO_503; +alias PSERVER_INFO_503 = SERVER_INFO_503*, LPSERVER_INFO_503 = SERVER_INFO_503*; struct SERVER_INFO_599 { DWORD sv599_sessopens; @@ -244,7 +244,7 @@ struct SERVER_INFO_599 { DWORD sv599_scavqosinfoupdatetime; DWORD sv599_maxworkitemidletime; } -alias SERVER_INFO_599* PSERVER_INFO_599, LPSERVER_INFO_599; +alias PSERVER_INFO_599 = SERVER_INFO_599*, LPSERVER_INFO_599 = SERVER_INFO_599*; struct SERVER_INFO_598 { DWORD sv598_maxrawworkitems; @@ -274,401 +274,401 @@ struct SERVER_INFO_598 { DWORD sv598_maxpagedpoolchunksize; BOOL sv598_sendsfrompreferredprocessor; } -alias SERVER_INFO_598* PSERVER_INFO_598, LPSERVER_INFO_598; +alias PSERVER_INFO_598 = SERVER_INFO_598*, LPSERVER_INFO_598 = SERVER_INFO_598*; struct SERVER_INFO_1005 { LPWSTR sv1005_comment; } -alias SERVER_INFO_1005* PSERVER_INFO_1005, LPSERVER_INFO_1005; +alias PSERVER_INFO_1005 = SERVER_INFO_1005*, LPSERVER_INFO_1005 = SERVER_INFO_1005*; struct SERVER_INFO_1107 { DWORD sv1107_users; } -alias SERVER_INFO_1107* PSERVER_INFO_1107, LPSERVER_INFO_1107; +alias PSERVER_INFO_1107 = SERVER_INFO_1107*, LPSERVER_INFO_1107 = SERVER_INFO_1107*; struct SERVER_INFO_1010 { LONG sv1010_disc; } -alias SERVER_INFO_1010* PSERVER_INFO_1010, LPSERVER_INFO_1010; +alias PSERVER_INFO_1010 = SERVER_INFO_1010*, LPSERVER_INFO_1010 = SERVER_INFO_1010*; struct SERVER_INFO_1016 { BOOL sv1016_hidden; } -alias SERVER_INFO_1016* PSERVER_INFO_1016, LPSERVER_INFO_1016; +alias PSERVER_INFO_1016 = SERVER_INFO_1016*, LPSERVER_INFO_1016 = SERVER_INFO_1016*; struct SERVER_INFO_1017 { DWORD sv1017_announce; } -alias SERVER_INFO_1017* PSERVER_INFO_1017, LPSERVER_INFO_1017; +alias PSERVER_INFO_1017 = SERVER_INFO_1017*, LPSERVER_INFO_1017 = SERVER_INFO_1017*; struct SERVER_INFO_1018 { DWORD sv1018_anndelta; } -alias SERVER_INFO_1018* PSERVER_INFO_1018, LPSERVER_INFO_1018; +alias PSERVER_INFO_1018 = SERVER_INFO_1018*, LPSERVER_INFO_1018 = SERVER_INFO_1018*; struct SERVER_INFO_1501 { DWORD sv1501_sessopens; } -alias SERVER_INFO_1501* PSERVER_INFO_1501, LPSERVER_INFO_1501; +alias PSERVER_INFO_1501 = SERVER_INFO_1501*, LPSERVER_INFO_1501 = SERVER_INFO_1501*; struct SERVER_INFO_1502 { DWORD sv1502_sessvcs; } -alias SERVER_INFO_1502* PSERVER_INFO_1502, LPSERVER_INFO_1502; +alias PSERVER_INFO_1502 = SERVER_INFO_1502*, LPSERVER_INFO_1502 = SERVER_INFO_1502*; struct SERVER_INFO_1503 { DWORD sv1503_opensearch; } -alias SERVER_INFO_1503* PSERVER_INFO_1503, LPSERVER_INFO_1503; +alias PSERVER_INFO_1503 = SERVER_INFO_1503*, LPSERVER_INFO_1503 = SERVER_INFO_1503*; struct SERVER_INFO_1506 { DWORD sv1506_maxworkitems; } -alias SERVER_INFO_1506* PSERVER_INFO_1506, LPSERVER_INFO_1506; +alias PSERVER_INFO_1506 = SERVER_INFO_1506*, LPSERVER_INFO_1506 = SERVER_INFO_1506*; struct SERVER_INFO_1509 { DWORD sv1509_maxrawbuflen; } -alias SERVER_INFO_1509* PSERVER_INFO_1509, LPSERVER_INFO_1509; +alias PSERVER_INFO_1509 = SERVER_INFO_1509*, LPSERVER_INFO_1509 = SERVER_INFO_1509*; struct SERVER_INFO_1510 { DWORD sv1510_sessusers; } -alias SERVER_INFO_1510* PSERVER_INFO_1510, LPSERVER_INFO_1510; +alias PSERVER_INFO_1510 = SERVER_INFO_1510*, LPSERVER_INFO_1510 = SERVER_INFO_1510*; struct SERVER_INFO_1511 { DWORD sv1511_sessconns; -} alias SERVER_INFO_1511* PSERVER_INFO_1511, LPSERVER_INFO_1511; +} alias PSERVER_INFO_1511 = SERVER_INFO_1511*, LPSERVER_INFO_1511 = SERVER_INFO_1511*; struct SERVER_INFO_1512 { DWORD sv1512_maxnonpagedmemoryusage; } -alias SERVER_INFO_1512* PSERVER_INFO_1512, LPSERVER_INFO_1512; +alias PSERVER_INFO_1512 = SERVER_INFO_1512*, LPSERVER_INFO_1512 = SERVER_INFO_1512*; struct SERVER_INFO_1513 { DWORD sv1513_maxpagedmemoryusage; } -alias SERVER_INFO_1513* PSERVER_INFO_1513, LPSERVER_INFO_1513; +alias PSERVER_INFO_1513 = SERVER_INFO_1513*, LPSERVER_INFO_1513 = SERVER_INFO_1513*; struct SERVER_INFO_1514 { BOOL sv1514_enablesoftcompat; } -alias SERVER_INFO_1514* PSERVER_INFO_1514, LPSERVER_INFO_1514; +alias PSERVER_INFO_1514 = SERVER_INFO_1514*, LPSERVER_INFO_1514 = SERVER_INFO_1514*; struct SERVER_INFO_1515 { BOOL sv1515_enableforcedlogoff; } -alias SERVER_INFO_1515* PSERVER_INFO_1515, LPSERVER_INFO_1515; +alias PSERVER_INFO_1515 = SERVER_INFO_1515*, LPSERVER_INFO_1515 = SERVER_INFO_1515*; struct SERVER_INFO_1516 { BOOL sv1516_timesource; } -alias SERVER_INFO_1516* PSERVER_INFO_1516, LPSERVER_INFO_1516; +alias PSERVER_INFO_1516 = SERVER_INFO_1516*, LPSERVER_INFO_1516 = SERVER_INFO_1516*; struct SERVER_INFO_1518 { BOOL sv1518_lmannounce; } -alias SERVER_INFO_1518* PSERVER_INFO_1518, LPSERVER_INFO_1518; +alias PSERVER_INFO_1518 = SERVER_INFO_1518*, LPSERVER_INFO_1518 = SERVER_INFO_1518*; struct SERVER_INFO_1520 { DWORD sv1520_maxcopyreadlen; } -alias SERVER_INFO_1520* PSERVER_INFO_1520, LPSERVER_INFO_1520; +alias PSERVER_INFO_1520 = SERVER_INFO_1520*, LPSERVER_INFO_1520 = SERVER_INFO_1520*; struct SERVER_INFO_1521 { DWORD sv1521_maxcopywritelen; } -alias SERVER_INFO_1521* PSERVER_INFO_1521, LPSERVER_INFO_1521; +alias PSERVER_INFO_1521 = SERVER_INFO_1521*, LPSERVER_INFO_1521 = SERVER_INFO_1521*; struct SERVER_INFO_1522 { DWORD sv1522_minkeepsearch; } -alias SERVER_INFO_1522* PSERVER_INFO_1522, LPSERVER_INFO_1522; +alias PSERVER_INFO_1522 = SERVER_INFO_1522*, LPSERVER_INFO_1522 = SERVER_INFO_1522*; struct SERVER_INFO_1523 { DWORD sv1523_maxkeepsearch; } -alias SERVER_INFO_1523* PSERVER_INFO_1523, LPSERVER_INFO_1523; +alias PSERVER_INFO_1523 = SERVER_INFO_1523*, LPSERVER_INFO_1523 = SERVER_INFO_1523*; struct SERVER_INFO_1524 { DWORD sv1524_minkeepcomplsearch; } -alias SERVER_INFO_1524* PSERVER_INFO_1524, LPSERVER_INFO_1524; +alias PSERVER_INFO_1524 = SERVER_INFO_1524*, LPSERVER_INFO_1524 = SERVER_INFO_1524*; struct SERVER_INFO_1525 { DWORD sv1525_maxkeepcomplsearch; } -alias SERVER_INFO_1525* PSERVER_INFO_1525, LPSERVER_INFO_1525; +alias PSERVER_INFO_1525 = SERVER_INFO_1525*, LPSERVER_INFO_1525 = SERVER_INFO_1525*; struct SERVER_INFO_1528 { DWORD sv1528_scavtimeout; } -alias SERVER_INFO_1528* PSERVER_INFO_1528, LPSERVER_INFO_1528; +alias PSERVER_INFO_1528 = SERVER_INFO_1528*, LPSERVER_INFO_1528 = SERVER_INFO_1528*; struct SERVER_INFO_1529 { DWORD sv1529_minrcvqueue; } -alias SERVER_INFO_1529* PSERVER_INFO_1529, LPSERVER_INFO_1529; +alias PSERVER_INFO_1529 = SERVER_INFO_1529*, LPSERVER_INFO_1529 = SERVER_INFO_1529*; struct SERVER_INFO_1530 { DWORD sv1530_minfreeworkitems; } -alias SERVER_INFO_1530* PSERVER_INFO_1530, LPSERVER_INFO_1530; +alias PSERVER_INFO_1530 = SERVER_INFO_1530*, LPSERVER_INFO_1530 = SERVER_INFO_1530*; struct SERVER_INFO_1533 { DWORD sv1533_maxmpxct; } -alias SERVER_INFO_1533* PSERVER_INFO_1533, LPSERVER_INFO_1533; +alias PSERVER_INFO_1533 = SERVER_INFO_1533*, LPSERVER_INFO_1533 = SERVER_INFO_1533*; struct SERVER_INFO_1534 { DWORD sv1534_oplockbreakwait; } -alias SERVER_INFO_1534* PSERVER_INFO_1534, LPSERVER_INFO_1534; +alias PSERVER_INFO_1534 = SERVER_INFO_1534*, LPSERVER_INFO_1534 = SERVER_INFO_1534*; struct SERVER_INFO_1535 { DWORD sv1535_oplockbreakresponsewait; } -alias SERVER_INFO_1535* PSERVER_INFO_1535, LPSERVER_INFO_1535; +alias PSERVER_INFO_1535 = SERVER_INFO_1535*, LPSERVER_INFO_1535 = SERVER_INFO_1535*; struct SERVER_INFO_1536 { BOOL sv1536_enableoplocks; } -alias SERVER_INFO_1536* PSERVER_INFO_1536, LPSERVER_INFO_1536; +alias PSERVER_INFO_1536 = SERVER_INFO_1536*, LPSERVER_INFO_1536 = SERVER_INFO_1536*; struct SERVER_INFO_1537 { BOOL sv1537_enableoplockforceclose; } -alias SERVER_INFO_1537* PSERVER_INFO_1537, LPSERVER_INFO_1537; +alias PSERVER_INFO_1537 = SERVER_INFO_1537*, LPSERVER_INFO_1537 = SERVER_INFO_1537*; struct SERVER_INFO_1538 { BOOL sv1538_enablefcbopens; } -alias SERVER_INFO_1538* PSERVER_INFO_1538, LPSERVER_INFO_1538; +alias PSERVER_INFO_1538 = SERVER_INFO_1538*, LPSERVER_INFO_1538 = SERVER_INFO_1538*; struct SERVER_INFO_1539 { BOOL sv1539_enableraw; } -alias SERVER_INFO_1539* PSERVER_INFO_1539, LPSERVER_INFO_1539; +alias PSERVER_INFO_1539 = SERVER_INFO_1539*, LPSERVER_INFO_1539 = SERVER_INFO_1539*; struct SERVER_INFO_1540 { BOOL sv1540_enablesharednetdrives; } -alias SERVER_INFO_1540* PSERVER_INFO_1540, LPSERVER_INFO_1540; +alias PSERVER_INFO_1540 = SERVER_INFO_1540*, LPSERVER_INFO_1540 = SERVER_INFO_1540*; struct SERVER_INFO_1541 { BOOL sv1541_minfreeconnections; } -alias SERVER_INFO_1541* PSERVER_INFO_1541, LPSERVER_INFO_1541; +alias PSERVER_INFO_1541 = SERVER_INFO_1541*, LPSERVER_INFO_1541 = SERVER_INFO_1541*; struct SERVER_INFO_1542 { BOOL sv1542_maxfreeconnections; } -alias SERVER_INFO_1542* PSERVER_INFO_1542, LPSERVER_INFO_1542; +alias PSERVER_INFO_1542 = SERVER_INFO_1542*, LPSERVER_INFO_1542 = SERVER_INFO_1542*; struct SERVER_INFO_1543 { DWORD sv1543_initsesstable; } -alias SERVER_INFO_1543* PSERVER_INFO_1543, LPSERVER_INFO_1543; +alias PSERVER_INFO_1543 = SERVER_INFO_1543*, LPSERVER_INFO_1543 = SERVER_INFO_1543*; struct SERVER_INFO_1544 { DWORD sv1544_initconntable; } -alias SERVER_INFO_1544* PSERVER_INFO_1544, LPSERVER_INFO_1544; +alias PSERVER_INFO_1544 = SERVER_INFO_1544*, LPSERVER_INFO_1544 = SERVER_INFO_1544*; struct SERVER_INFO_1545 { DWORD sv1545_initfiletable; } -alias SERVER_INFO_1545* PSERVER_INFO_1545, LPSERVER_INFO_1545; +alias PSERVER_INFO_1545 = SERVER_INFO_1545*, LPSERVER_INFO_1545 = SERVER_INFO_1545*; struct SERVER_INFO_1546 { DWORD sv1546_initsearchtable; } -alias SERVER_INFO_1546* PSERVER_INFO_1546, LPSERVER_INFO_1546; +alias PSERVER_INFO_1546 = SERVER_INFO_1546*, LPSERVER_INFO_1546 = SERVER_INFO_1546*; struct SERVER_INFO_1547 { DWORD sv1547_alertschedule; } -alias SERVER_INFO_1547* PSERVER_INFO_1547, LPSERVER_INFO_1547; +alias PSERVER_INFO_1547 = SERVER_INFO_1547*, LPSERVER_INFO_1547 = SERVER_INFO_1547*; struct SERVER_INFO_1548 { DWORD sv1548_errorthreshold; } -alias SERVER_INFO_1548* PSERVER_INFO_1548, LPSERVER_INFO_1548; +alias PSERVER_INFO_1548 = SERVER_INFO_1548*, LPSERVER_INFO_1548 = SERVER_INFO_1548*; struct SERVER_INFO_1549 { DWORD sv1549_networkerrorthreshold; } -alias SERVER_INFO_1549* PSERVER_INFO_1549, LPSERVER_INFO_1549; +alias PSERVER_INFO_1549 = SERVER_INFO_1549*, LPSERVER_INFO_1549 = SERVER_INFO_1549*; struct SERVER_INFO_1550 { DWORD sv1550_diskspacethreshold; } -alias SERVER_INFO_1550* PSERVER_INFO_1550, LPSERVER_INFO_1550; +alias PSERVER_INFO_1550 = SERVER_INFO_1550*, LPSERVER_INFO_1550 = SERVER_INFO_1550*; struct SERVER_INFO_1552 { DWORD sv1552_maxlinkdelay; } -alias SERVER_INFO_1552* PSERVER_INFO_1552, LPSERVER_INFO_1552; +alias PSERVER_INFO_1552 = SERVER_INFO_1552*, LPSERVER_INFO_1552 = SERVER_INFO_1552*; struct SERVER_INFO_1553 { DWORD sv1553_minlinkthroughput; } -alias SERVER_INFO_1553* PSERVER_INFO_1553, LPSERVER_INFO_1553; +alias PSERVER_INFO_1553 = SERVER_INFO_1553*, LPSERVER_INFO_1553 = SERVER_INFO_1553*; struct SERVER_INFO_1554 { DWORD sv1554_linkinfovalidtime; } -alias SERVER_INFO_1554* PSERVER_INFO_1554, LPSERVER_INFO_1554; +alias PSERVER_INFO_1554 = SERVER_INFO_1554*, LPSERVER_INFO_1554 = SERVER_INFO_1554*; struct SERVER_INFO_1555 { DWORD sv1555_scavqosinfoupdatetime; } -alias SERVER_INFO_1555* PSERVER_INFO_1555, LPSERVER_INFO_1555; +alias PSERVER_INFO_1555 = SERVER_INFO_1555*, LPSERVER_INFO_1555 = SERVER_INFO_1555*; struct SERVER_INFO_1556 { DWORD sv1556_maxworkitemidletime; } -alias SERVER_INFO_1556* PSERVER_INFO_1556, LPSERVER_INFO_1556; +alias PSERVER_INFO_1556 = SERVER_INFO_1556*, LPSERVER_INFO_1556 = SERVER_INFO_1556*; struct SERVER_INFO_1557 { DWORD sv1557_maxrawworkitems; } -alias SERVER_INFO_1557* PSERVER_INFO_1557, LPSERVER_INFO_1557; +alias PSERVER_INFO_1557 = SERVER_INFO_1557*, LPSERVER_INFO_1557 = SERVER_INFO_1557*; struct SERVER_INFO_1560 { DWORD sv1560_producttype; } -alias SERVER_INFO_1560* PSERVER_INFO_1560, LPSERVER_INFO_1560; +alias PSERVER_INFO_1560 = SERVER_INFO_1560*, LPSERVER_INFO_1560 = SERVER_INFO_1560*; struct SERVER_INFO_1561 { DWORD sv1561_serversize; } -alias SERVER_INFO_1561* PSERVER_INFO_1561, LPSERVER_INFO_1561; +alias PSERVER_INFO_1561 = SERVER_INFO_1561*, LPSERVER_INFO_1561 = SERVER_INFO_1561*; struct SERVER_INFO_1562 { DWORD sv1562_connectionlessautodisc; } -alias SERVER_INFO_1562* PSERVER_INFO_1562, LPSERVER_INFO_1562; +alias PSERVER_INFO_1562 = SERVER_INFO_1562*, LPSERVER_INFO_1562 = SERVER_INFO_1562*; struct SERVER_INFO_1563 { DWORD sv1563_sharingviolationretries; } -alias SERVER_INFO_1563* PSERVER_INFO_1563, LPSERVER_INFO_1563; +alias PSERVER_INFO_1563 = SERVER_INFO_1563*, LPSERVER_INFO_1563 = SERVER_INFO_1563*; struct SERVER_INFO_1564 { DWORD sv1564_sharingviolationdelay; } -alias SERVER_INFO_1564* PSERVER_INFO_1564, LPSERVER_INFO_1564; +alias PSERVER_INFO_1564 = SERVER_INFO_1564*, LPSERVER_INFO_1564 = SERVER_INFO_1564*; struct SERVER_INFO_1565 { DWORD sv1565_maxglobalopensearch; } -alias SERVER_INFO_1565* PSERVER_INFO_1565, LPSERVER_INFO_1565; +alias PSERVER_INFO_1565 = SERVER_INFO_1565*, LPSERVER_INFO_1565 = SERVER_INFO_1565*; struct SERVER_INFO_1566 { BOOL sv1566_removeduplicatesearches; } -alias SERVER_INFO_1566* PSERVER_INFO_1566, LPSERVER_INFO_1566; +alias PSERVER_INFO_1566 = SERVER_INFO_1566*, LPSERVER_INFO_1566 = SERVER_INFO_1566*; struct SERVER_INFO_1567 { DWORD sv1567_lockviolationretries; } -alias SERVER_INFO_1567* PSERVER_INFO_1567, LPSERVER_INFO_1567; +alias PSERVER_INFO_1567 = SERVER_INFO_1567*, LPSERVER_INFO_1567 = SERVER_INFO_1567*; struct SERVER_INFO_1568 { DWORD sv1568_lockviolationoffset; } -alias SERVER_INFO_1568* PSERVER_INFO_1568, LPSERVER_INFO_1568; +alias PSERVER_INFO_1568 = SERVER_INFO_1568*, LPSERVER_INFO_1568 = SERVER_INFO_1568*; struct SERVER_INFO_1569 { DWORD sv1569_lockviolationdelay; } -alias SERVER_INFO_1569* PSERVER_INFO_1569, LPSERVER_INFO_1569; +alias PSERVER_INFO_1569 = SERVER_INFO_1569*, LPSERVER_INFO_1569 = SERVER_INFO_1569*; struct SERVER_INFO_1570 { DWORD sv1570_mdlreadswitchover; } -alias SERVER_INFO_1570* PSERVER_INFO_1570, LPSERVER_INFO_1570; +alias PSERVER_INFO_1570 = SERVER_INFO_1570*, LPSERVER_INFO_1570 = SERVER_INFO_1570*; struct SERVER_INFO_1571 { DWORD sv1571_cachedopenlimit; } -alias SERVER_INFO_1571* PSERVER_INFO_1571, LPSERVER_INFO_1571; +alias PSERVER_INFO_1571 = SERVER_INFO_1571*, LPSERVER_INFO_1571 = SERVER_INFO_1571*; struct SERVER_INFO_1572 { DWORD sv1572_criticalthreads; } -alias SERVER_INFO_1572* PSERVER_INFO_1572, LPSERVER_INFO_1572; +alias PSERVER_INFO_1572 = SERVER_INFO_1572*, LPSERVER_INFO_1572 = SERVER_INFO_1572*; struct SERVER_INFO_1573 { DWORD sv1573_restrictnullsessaccess; } -alias SERVER_INFO_1573* PSERVER_INFO_1573, LPSERVER_INFO_1573; +alias PSERVER_INFO_1573 = SERVER_INFO_1573*, LPSERVER_INFO_1573 = SERVER_INFO_1573*; struct SERVER_INFO_1574 { DWORD sv1574_enablewfw311directipx; } -alias SERVER_INFO_1574* PSERVER_INFO_1574, LPSERVER_INFO_1574; +alias PSERVER_INFO_1574 = SERVER_INFO_1574*, LPSERVER_INFO_1574 = SERVER_INFO_1574*; struct SERVER_INFO_1575 { DWORD sv1575_otherqueueaffinity; } -alias SERVER_INFO_1575* PSERVER_INFO_1575, LPSERVER_INFO_1575; +alias PSERVER_INFO_1575 = SERVER_INFO_1575*, LPSERVER_INFO_1575 = SERVER_INFO_1575*; struct SERVER_INFO_1576 { DWORD sv1576_queuesamplesecs; } -alias SERVER_INFO_1576* PSERVER_INFO_1576, LPSERVER_INFO_1576; +alias PSERVER_INFO_1576 = SERVER_INFO_1576*, LPSERVER_INFO_1576 = SERVER_INFO_1576*; struct SERVER_INFO_1577 { DWORD sv1577_balancecount; } -alias SERVER_INFO_1577* PSERVER_INFO_1577, LPSERVER_INFO_1577; +alias PSERVER_INFO_1577 = SERVER_INFO_1577*, LPSERVER_INFO_1577 = SERVER_INFO_1577*; struct SERVER_INFO_1578 { DWORD sv1578_preferredaffinity; } -alias SERVER_INFO_1578* PSERVER_INFO_1578, LPSERVER_INFO_1578; +alias PSERVER_INFO_1578 = SERVER_INFO_1578*, LPSERVER_INFO_1578 = SERVER_INFO_1578*; struct SERVER_INFO_1579 { DWORD sv1579_maxfreerfcbs; } -alias SERVER_INFO_1579* PSERVER_INFO_1579, LPSERVER_INFO_1579; +alias PSERVER_INFO_1579 = SERVER_INFO_1579*, LPSERVER_INFO_1579 = SERVER_INFO_1579*; struct SERVER_INFO_1580 { DWORD sv1580_maxfreemfcbs; } -alias SERVER_INFO_1580* PSERVER_INFO_1580, LPSERVER_INFO_1580; +alias PSERVER_INFO_1580 = SERVER_INFO_1580*, LPSERVER_INFO_1580 = SERVER_INFO_1580*; struct SERVER_INFO_1581 { DWORD sv1581_maxfreemlcbs; } -alias SERVER_INFO_1581* PSERVER_INFO_1581, LPSERVER_INFO_1581; +alias PSERVER_INFO_1581 = SERVER_INFO_1581*, LPSERVER_INFO_1581 = SERVER_INFO_1581*; struct SERVER_INFO_1582 { DWORD sv1582_maxfreepagedpoolchunks; } -alias SERVER_INFO_1582* PSERVER_INFO_1582, LPSERVER_INFO_1582; +alias PSERVER_INFO_1582 = SERVER_INFO_1582*, LPSERVER_INFO_1582 = SERVER_INFO_1582*; struct SERVER_INFO_1583 { DWORD sv1583_minpagedpoolchunksize; } -alias SERVER_INFO_1583* PSERVER_INFO_1583, LPSERVER_INFO_1583; +alias PSERVER_INFO_1583 = SERVER_INFO_1583*, LPSERVER_INFO_1583 = SERVER_INFO_1583*; struct SERVER_INFO_1584 { DWORD sv1584_maxpagedpoolchunksize; } -alias SERVER_INFO_1584* PSERVER_INFO_1584, LPSERVER_INFO_1584; +alias PSERVER_INFO_1584 = SERVER_INFO_1584*, LPSERVER_INFO_1584 = SERVER_INFO_1584*; struct SERVER_INFO_1585 { BOOL sv1585_sendsfrompreferredprocessor; } -alias SERVER_INFO_1585* PSERVER_INFO_1585, LPSERVER_INFO_1585; +alias PSERVER_INFO_1585 = SERVER_INFO_1585*, LPSERVER_INFO_1585 = SERVER_INFO_1585*; struct SERVER_INFO_1586 { BOOL sv1586_maxthreadsperqueue; } -alias SERVER_INFO_1586* PSERVER_INFO_1586, LPSERVER_INFO_1586; +alias PSERVER_INFO_1586 = SERVER_INFO_1586*, LPSERVER_INFO_1586 = SERVER_INFO_1586*; struct SERVER_TRANSPORT_INFO_0 { DWORD svti0_numberofvcs; @@ -677,8 +677,7 @@ struct SERVER_TRANSPORT_INFO_0 { DWORD svti0_transportaddresslength; LPWSTR svti0_networkaddress; } -alias SERVER_TRANSPORT_INFO_0* PSERVER_TRANSPORT_INFO_0, - LPSERVER_TRANSPORT_INFO_0; +alias PSERVER_TRANSPORT_INFO_0 = SERVER_TRANSPORT_INFO_0*, LPSERVER_TRANSPORT_INFO_0 = SERVER_TRANSPORT_INFO_0*; extern (Windows): NET_API_STATUS NetServerEnum(LPCWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,DWORD,LPCWSTR,PDWORD); diff --git a/runtime/druntime/src/core/sys/windows/lmshare.d b/runtime/druntime/src/core/sys/windows/lmshare.d index bd8eecb46d..0b34069c4c 100644 --- a/runtime/druntime/src/core/sys/windows/lmshare.d +++ b/runtime/druntime/src/core/sys/windows/lmshare.d @@ -51,7 +51,7 @@ enum PERM_FILE_CREATE = 4; struct FILE_INFO_2 { DWORD fi2_id; } -alias FILE_INFO_2* PFILE_INFO_2, LPFILE_INFO_2; +alias PFILE_INFO_2 = FILE_INFO_2*, LPFILE_INFO_2 = FILE_INFO_2*; struct FILE_INFO_3 { DWORD fi3_id; @@ -60,19 +60,19 @@ struct FILE_INFO_3 { LPTSTR fi3_pathname; LPTSTR fi3_username; } -alias FILE_INFO_3* PFILE_INFO_3, LPFILE_INFO_3; +alias PFILE_INFO_3 = FILE_INFO_3*, LPFILE_INFO_3 = FILE_INFO_3*; struct SHARE_INFO_0 { LPTSTR shi0_netname; } -alias SHARE_INFO_0* PSHARE_INFO_0, LPSHARE_INFO_0; +alias PSHARE_INFO_0 = SHARE_INFO_0*, LPSHARE_INFO_0 = SHARE_INFO_0*; struct SHARE_INFO_1 { LPTSTR shi1_netname; DWORD shi1_type; LPTSTR shi1_remark; } -alias SHARE_INFO_1* PSHARE_INFO_1, LPSHARE_INFO_1; +alias PSHARE_INFO_1 = SHARE_INFO_1*, LPSHARE_INFO_1 = SHARE_INFO_1*; struct SHARE_INFO_2 { LPTSTR shi2_netname; @@ -84,7 +84,7 @@ struct SHARE_INFO_2 { LPTSTR shi2_path; LPTSTR shi2_passwd; } -alias SHARE_INFO_2* PSHARE_INFO_2, LPSHARE_INFO_2; +alias PSHARE_INFO_2 = SHARE_INFO_2*, LPSHARE_INFO_2 = SHARE_INFO_2*; struct SHARE_INFO_502 { LPTSTR shi502_netname; @@ -98,28 +98,28 @@ struct SHARE_INFO_502 { DWORD shi502_reserved; PSECURITY_DESCRIPTOR shi502_security_descriptor; } -alias SHARE_INFO_502* PSHARE_INFO_502, LPSHARE_INFO_502; +alias PSHARE_INFO_502 = SHARE_INFO_502*, LPSHARE_INFO_502 = SHARE_INFO_502*; struct SHARE_INFO_1004 { LPTSTR shi1004_remark; } -alias SHARE_INFO_1004* PSHARE_INFO_1004, LPSHARE_INFO_1004; +alias PSHARE_INFO_1004 = SHARE_INFO_1004*, LPSHARE_INFO_1004 = SHARE_INFO_1004*; struct SHARE_INFO_1006 { DWORD shi1006_max_uses; } -alias SHARE_INFO_1006* PSHARE_INFO_1006, LPSHARE_INFO_1006; +alias PSHARE_INFO_1006 = SHARE_INFO_1006*, LPSHARE_INFO_1006 = SHARE_INFO_1006*; struct SHARE_INFO_1501 { DWORD shi1501_reserved; PSECURITY_DESCRIPTOR shi1501_security_descriptor; } -alias SHARE_INFO_1501* PSHARE_INFO_1501, LPSHARE_INFO_1501; +alias PSHARE_INFO_1501 = SHARE_INFO_1501*, LPSHARE_INFO_1501 = SHARE_INFO_1501*; struct SESSION_INFO_0 { LPWSTR sesi0_cname; } -alias SESSION_INFO_0* PSESSION_INFO_0, LPSESSION_INFO_0; +alias PSESSION_INFO_0 = SESSION_INFO_0*, LPSESSION_INFO_0 = SESSION_INFO_0*; struct SESSION_INFO_1 { LPTSTR sesi1_cname; @@ -129,7 +129,7 @@ struct SESSION_INFO_1 { DWORD sesi1_idle_time; DWORD sesi1_user_flags; } -alias SESSION_INFO_1* PSESSION_INFO_1, LPSESSION_INFO_1; +alias PSESSION_INFO_1 = SESSION_INFO_1*, LPSESSION_INFO_1 = SESSION_INFO_1*; struct SESSION_INFO_2 { LPTSTR sesi2_cname; @@ -140,7 +140,7 @@ struct SESSION_INFO_2 { DWORD sesi2_user_flags; LPWSTR sesi2_cltype_name; } -alias SESSION_INFO_2* PSESSION_INFO_2, LPSESSION_INFO_2; +alias PSESSION_INFO_2 = SESSION_INFO_2*, LPSESSION_INFO_2 = SESSION_INFO_2*; struct SESSION_INFO_10 { LPWSTR sesi10_cname; @@ -148,7 +148,7 @@ struct SESSION_INFO_10 { DWORD sesi10_time; DWORD sesi10_idle_time; } -alias SESSION_INFO_10* PSESSION_INFO_10, LPSESSION_INFO_10; +alias PSESSION_INFO_10 = SESSION_INFO_10*, LPSESSION_INFO_10 = SESSION_INFO_10*; struct SESSION_INFO_502 { LPWSTR sesi502_cname; @@ -160,12 +160,12 @@ struct SESSION_INFO_502 { LPWSTR sesi502_cltype_name; LPWSTR sesi502_transport; } -alias SESSION_INFO_502* PSESSION_INFO_502, LPSESSION_INFO_502; +alias PSESSION_INFO_502 = SESSION_INFO_502*, LPSESSION_INFO_502 = SESSION_INFO_502*; struct CONNECTION_INFO_0 { DWORD coni0_id; } -alias CONNECTION_INFO_0* PCONNECTION_INFO_0, LPCONNECTION_INFO_0; +alias PCONNECTION_INFO_0 = CONNECTION_INFO_0*, LPCONNECTION_INFO_0 = CONNECTION_INFO_0*; struct CONNECTION_INFO_1 { DWORD coni1_id; @@ -176,7 +176,7 @@ struct CONNECTION_INFO_1 { LPWSTR coni1_username; LPWSTR coni1_netname; } -alias CONNECTION_INFO_1* PCONNECTION_INFO_1, LPCONNECTION_INFO_1; +alias PCONNECTION_INFO_1 = CONNECTION_INFO_1*, LPCONNECTION_INFO_1 = CONNECTION_INFO_1*; extern (Windows) { NET_API_STATUS NetShareAdd(LPWSTR,DWORD,PBYTE,PDWORD); diff --git a/runtime/druntime/src/core/sys/windows/lmstats.d b/runtime/druntime/src/core/sys/windows/lmstats.d index e83808b12a..4e80c64dbc 100644 --- a/runtime/druntime/src/core/sys/windows/lmstats.d +++ b/runtime/druntime/src/core/sys/windows/lmstats.d @@ -36,7 +36,7 @@ struct STAT_SERVER_0{ DWORD sts0_reqbufneed; DWORD sts0_bigbufneed; } -alias STAT_SERVER_0* PSTAT_SERVER_0, LPSTAT_SERVER_0; +alias PSTAT_SERVER_0 = STAT_SERVER_0*, LPSTAT_SERVER_0 = STAT_SERVER_0*; // #ifdef LM20_WORKSTATION_STATISTICS // typedef struct _STAT_WORKSTATION_0 { @@ -115,7 +115,7 @@ struct STAT_WORKSTATION_0{ DWORD FailedUseCount; DWORD CurrentCommands; } -alias STAT_WORKSTATION_0* PSTAT_WORKSTATION_0, LPSTAT_WORKSTATION_0; +alias PSTAT_WORKSTATION_0 = STAT_WORKSTATION_0*, LPSTAT_WORKSTATION_0 = STAT_WORKSTATION_0*; extern (Windows): NET_API_STATUS NetStatisticsGet(LPWSTR,LPWSTR,DWORD,DWORD,PBYTE*); diff --git a/runtime/druntime/src/core/sys/windows/lmsvc.d b/runtime/druntime/src/core/sys/windows/lmsvc.d index ddea61c7d0..52e30b05a1 100644 --- a/runtime/druntime/src/core/sys/windows/lmsvc.d +++ b/runtime/druntime/src/core/sys/windows/lmsvc.d @@ -117,7 +117,7 @@ enum SERVICE_UIC_M_DATABASE_ERROR = SERVICE2_BASE+2; struct SERVICE_INFO_0 { LPWSTR svci0_name; } -alias SERVICE_INFO_0* PSERVICE_INFO_0, LPSERVICE_INFO_0; +alias PSERVICE_INFO_0 = SERVICE_INFO_0*, LPSERVICE_INFO_0 = SERVICE_INFO_0*; struct SERVICE_INFO_1 { LPWSTR svci1_name; @@ -125,7 +125,7 @@ struct SERVICE_INFO_1 { DWORD svci1_code; DWORD svci1_pid; } -alias SERVICE_INFO_1* PSERVICE_INFO_1, LPSERVICE_INFO_1; +alias PSERVICE_INFO_1 = SERVICE_INFO_1*, LPSERVICE_INFO_1 = SERVICE_INFO_1*; struct SERVICE_INFO_2 { LPWSTR svci2_name; @@ -136,7 +136,7 @@ struct SERVICE_INFO_2 { DWORD svci2_specific_error; LPWSTR svci2_display_name; } -alias SERVICE_INFO_2* PSERVICE_INFO_2, LPSERVICE_INFO_2; +alias PSERVICE_INFO_2 = SERVICE_INFO_2*, LPSERVICE_INFO_2 = SERVICE_INFO_2*; extern (Windows) { deprecated { diff --git a/runtime/druntime/src/core/sys/windows/lmuse.d b/runtime/druntime/src/core/sys/windows/lmuse.d index a48d72e005..10b659337b 100644 --- a/runtime/druntime/src/core/sys/windows/lmuse.d +++ b/runtime/druntime/src/core/sys/windows/lmuse.d @@ -45,7 +45,7 @@ struct USE_INFO_0 { LPWSTR ui0_local; LPWSTR ui0_remote; } -alias USE_INFO_0* PUSE_INFO_0, LPUSE_INFO_0; +alias PUSE_INFO_0 = USE_INFO_0*, LPUSE_INFO_0 = USE_INFO_0*; struct USE_INFO_1 { LPWSTR ui1_local; @@ -56,7 +56,7 @@ struct USE_INFO_1 { DWORD ui1_refcount; DWORD ui1_usecount; } -alias USE_INFO_1* PUSE_INFO_1, LPUSE_INFO_1; +alias PUSE_INFO_1 = USE_INFO_1*, LPUSE_INFO_1 = USE_INFO_1*; struct USE_INFO_2 { LPWSTR ui2_local; @@ -69,7 +69,7 @@ struct USE_INFO_2 { LPWSTR ui2_username; LPWSTR ui2_domainname; } -alias USE_INFO_2* PUSE_INFO_2, LPUSE_INFO_2; +alias PUSE_INFO_2 = USE_INFO_2*, LPUSE_INFO_2 = USE_INFO_2*; extern (Windows) { NET_API_STATUS NetUseAdd(LPWSTR, DWORD, PBYTE, PDWORD); diff --git a/runtime/druntime/src/core/sys/windows/lmwksta.d b/runtime/druntime/src/core/sys/windows/lmwksta.d index 29ddca76d8..86e394e057 100644 --- a/runtime/druntime/src/core/sys/windows/lmwksta.d +++ b/runtime/druntime/src/core/sys/windows/lmwksta.d @@ -80,7 +80,7 @@ struct WKSTA_INFO_100{ DWORD wki100_ver_major; DWORD wki100_ver_minor; } -alias WKSTA_INFO_100* PWKSTA_INFO_100, LPWKSTA_INFO_100; +alias PWKSTA_INFO_100 = WKSTA_INFO_100*, LPWKSTA_INFO_100 = WKSTA_INFO_100*; struct WKSTA_INFO_101{ DWORD wki101_platform_id; @@ -90,7 +90,7 @@ struct WKSTA_INFO_101{ DWORD wki101_ver_minor; LPWSTR wki101_lanroot; } -alias WKSTA_INFO_101* PWKSTA_INFO_101, LPWKSTA_INFO_101; +alias PWKSTA_INFO_101 = WKSTA_INFO_101*, LPWKSTA_INFO_101 = WKSTA_INFO_101*; struct WKSTA_INFO_102{ DWORD wki102_platform_id; @@ -101,7 +101,7 @@ struct WKSTA_INFO_102{ LPWSTR wki102_lanroot; DWORD wki102_logged_on_users; } -alias WKSTA_INFO_102* PWKSTA_INFO_102, LPWKSTA_INFO_102; +alias PWKSTA_INFO_102 = WKSTA_INFO_102*, LPWKSTA_INFO_102 = WKSTA_INFO_102*; struct WKSTA_INFO_302{ DWORD wki302_char_wait; @@ -125,7 +125,7 @@ struct WKSTA_INFO_302{ DWORD wki302_mailslots; DWORD wki302_num_dgram_buf; } -alias WKSTA_INFO_302* PWKSTA_INFO_302, LPWKSTA_INFO_302; +alias PWKSTA_INFO_302 = WKSTA_INFO_302*, LPWKSTA_INFO_302 = WKSTA_INFO_302*; struct WKSTA_INFO_402{ DWORD wki402_char_wait; @@ -150,7 +150,7 @@ struct WKSTA_INFO_402{ DWORD wki402_num_dgram_buf; DWORD wki402_max_threads; } -alias WKSTA_INFO_402* PWKSTA_INFO_402, LPWKSTA_INFO_402; +alias PWKSTA_INFO_402 = WKSTA_INFO_402*, LPWKSTA_INFO_402 = WKSTA_INFO_402*; struct WKSTA_INFO_502{ DWORD wki502_char_wait; @@ -189,172 +189,172 @@ struct WKSTA_INFO_502{ BOOL wki502_force_core_create_mode; BOOL wki502_use_512_byte_max_transfer; } -alias WKSTA_INFO_502* PWKSTA_INFO_502, LPWKSTA_INFO_502; +alias PWKSTA_INFO_502 = WKSTA_INFO_502*, LPWKSTA_INFO_502 = WKSTA_INFO_502*; struct WKSTA_INFO_1010 { DWORD wki1010_char_wait; } -alias WKSTA_INFO_1010* PWKSTA_INFO_1010, LPWKSTA_INFO_1010; +alias PWKSTA_INFO_1010 = WKSTA_INFO_1010*, LPWKSTA_INFO_1010 = WKSTA_INFO_1010*; struct WKSTA_INFO_1011 { DWORD wki1011_collection_time; } -alias WKSTA_INFO_1011* PWKSTA_INFO_1011, LPWKSTA_INFO_1011; +alias PWKSTA_INFO_1011 = WKSTA_INFO_1011*, LPWKSTA_INFO_1011 = WKSTA_INFO_1011*; struct WKSTA_INFO_1012 { DWORD wki1012_maximum_collection_count; } -alias WKSTA_INFO_1012* PWKSTA_INFO_1012, LPWKSTA_INFO_1012; +alias PWKSTA_INFO_1012 = WKSTA_INFO_1012*, LPWKSTA_INFO_1012 = WKSTA_INFO_1012*; struct WKSTA_INFO_1027 { DWORD wki1027_errlog_sz; } -alias WKSTA_INFO_1027* PWKSTA_INFO_1027, LPWKSTA_INFO_1027; +alias PWKSTA_INFO_1027 = WKSTA_INFO_1027*, LPWKSTA_INFO_1027 = WKSTA_INFO_1027*; struct WKSTA_INFO_1028 { DWORD wki1028_print_buf_time; } -alias WKSTA_INFO_1028* PWKSTA_INFO_1028, LPWKSTA_INFO_1028; +alias PWKSTA_INFO_1028 = WKSTA_INFO_1028*, LPWKSTA_INFO_1028 = WKSTA_INFO_1028*; struct WKSTA_INFO_1032 { DWORD wki1032_wrk_heuristics; } -alias WKSTA_INFO_1032* PWKSTA_INFO_1032, LPWKSTA_INFO_1032; +alias PWKSTA_INFO_1032 = WKSTA_INFO_1032*, LPWKSTA_INFO_1032 = WKSTA_INFO_1032*; struct WKSTA_INFO_1013 { DWORD wki1013_keep_conn; } -alias WKSTA_INFO_1013* PWKSTA_INFO_1013, LPWKSTA_INFO_1013; +alias PWKSTA_INFO_1013 = WKSTA_INFO_1013*, LPWKSTA_INFO_1013 = WKSTA_INFO_1013*; struct WKSTA_INFO_1018 { DWORD wki1018_sess_timeout; } -alias WKSTA_INFO_1018* PWKSTA_INFO_1018, LPWKSTA_INFO_1018; +alias PWKSTA_INFO_1018 = WKSTA_INFO_1018*, LPWKSTA_INFO_1018 = WKSTA_INFO_1018*; struct WKSTA_INFO_1023 { DWORD wki1023_siz_char_buf; } -alias WKSTA_INFO_1023* PWKSTA_INFO_1023, LPWKSTA_INFO_1023; +alias PWKSTA_INFO_1023 = WKSTA_INFO_1023*, LPWKSTA_INFO_1023 = WKSTA_INFO_1023*; struct WKSTA_INFO_1033 { DWORD wki1033_max_threads; } -alias WKSTA_INFO_1033* PWKSTA_INFO_1033, LPWKSTA_INFO_1033; +alias PWKSTA_INFO_1033 = WKSTA_INFO_1033*, LPWKSTA_INFO_1033 = WKSTA_INFO_1033*; struct WKSTA_INFO_1041 { DWORD wki1041_lock_quota; } -alias WKSTA_INFO_1041* PWKSTA_INFO_1041, LPWKSTA_INFO_1041; +alias PWKSTA_INFO_1041 = WKSTA_INFO_1041*, LPWKSTA_INFO_1041 = WKSTA_INFO_1041*; struct WKSTA_INFO_1042 { DWORD wki1042_lock_increment; } -alias WKSTA_INFO_1042* PWKSTA_INFO_1042, LPWKSTA_INFO_1042; +alias PWKSTA_INFO_1042 = WKSTA_INFO_1042*, LPWKSTA_INFO_1042 = WKSTA_INFO_1042*; struct WKSTA_INFO_1043 { DWORD wki1043_lock_maximum; } -alias WKSTA_INFO_1043* PWKSTA_INFO_1043, LPWKSTA_INFO_1043; +alias PWKSTA_INFO_1043 = WKSTA_INFO_1043*, LPWKSTA_INFO_1043 = WKSTA_INFO_1043*; struct WKSTA_INFO_1044 { DWORD wki1044_pipe_increment; } -alias WKSTA_INFO_1044* PWKSTA_INFO_1044, LPWKSTA_INFO_1044; +alias PWKSTA_INFO_1044 = WKSTA_INFO_1044*, LPWKSTA_INFO_1044 = WKSTA_INFO_1044*; struct WKSTA_INFO_1045 { DWORD wki1045_pipe_maximum; } -alias WKSTA_INFO_1045* PWKSTA_INFO_1045, LPWKSTA_INFO_1045; +alias PWKSTA_INFO_1045 = WKSTA_INFO_1045*, LPWKSTA_INFO_1045 = WKSTA_INFO_1045*; struct WKSTA_INFO_1046 { DWORD wki1046_dormant_file_limit; } -alias WKSTA_INFO_1046* PWKSTA_INFO_1046, LPWKSTA_INFO_1046; +alias PWKSTA_INFO_1046 = WKSTA_INFO_1046*, LPWKSTA_INFO_1046 = WKSTA_INFO_1046*; struct WKSTA_INFO_1047 { DWORD wki1047_cache_file_timeout; } -alias WKSTA_INFO_1047* PWKSTA_INFO_1047, LPWKSTA_INFO_1047; +alias PWKSTA_INFO_1047 = WKSTA_INFO_1047*, LPWKSTA_INFO_1047 = WKSTA_INFO_1047*; struct WKSTA_INFO_1048 { BOOL wki1048_use_opportunistic_locking; } -alias WKSTA_INFO_1048* PWKSTA_INFO_1048, LPWKSTA_INFO_1048; +alias PWKSTA_INFO_1048 = WKSTA_INFO_1048*, LPWKSTA_INFO_1048 = WKSTA_INFO_1048*; struct WKSTA_INFO_1049 { BOOL wki1049_use_unlock_behind; } -alias WKSTA_INFO_1049* PWKSTA_INFO_1049, LPWKSTA_INFO_1049; +alias PWKSTA_INFO_1049 = WKSTA_INFO_1049*, LPWKSTA_INFO_1049 = WKSTA_INFO_1049*; struct WKSTA_INFO_1050 { BOOL wki1050_use_close_behind; } -alias WKSTA_INFO_1050* PWKSTA_INFO_1050, LPWKSTA_INFO_1050; +alias PWKSTA_INFO_1050 = WKSTA_INFO_1050*, LPWKSTA_INFO_1050 = WKSTA_INFO_1050*; struct WKSTA_INFO_1051 { BOOL wki1051_buf_named_pipes; } -alias WKSTA_INFO_1051* PWKSTA_INFO_1051, LPWKSTA_INFO_1051; +alias PWKSTA_INFO_1051 = WKSTA_INFO_1051*, LPWKSTA_INFO_1051 = WKSTA_INFO_1051*; struct WKSTA_INFO_1052 { BOOL wki1052_use_lock_read_unlock; } -alias WKSTA_INFO_1052* PWKSTA_INFO_1052, LPWKSTA_INFO_1052; +alias PWKSTA_INFO_1052 = WKSTA_INFO_1052*, LPWKSTA_INFO_1052 = WKSTA_INFO_1052*; struct WKSTA_INFO_1053 { BOOL wki1053_utilize_nt_caching; } -alias WKSTA_INFO_1053* PWKSTA_INFO_1053, LPWKSTA_INFO_1053; +alias PWKSTA_INFO_1053 = WKSTA_INFO_1053*, LPWKSTA_INFO_1053 = WKSTA_INFO_1053*; struct WKSTA_INFO_1054 { BOOL wki1054_use_raw_read; } -alias WKSTA_INFO_1054* PWKSTA_INFO_1054, LPWKSTA_INFO_1054; +alias PWKSTA_INFO_1054 = WKSTA_INFO_1054*, LPWKSTA_INFO_1054 = WKSTA_INFO_1054*; struct WKSTA_INFO_1055 { BOOL wki1055_use_raw_write; } -alias WKSTA_INFO_1055* PWKSTA_INFO_1055, LPWKSTA_INFO_1055; +alias PWKSTA_INFO_1055 = WKSTA_INFO_1055*, LPWKSTA_INFO_1055 = WKSTA_INFO_1055*; struct WKSTA_INFO_1056 { BOOL wki1056_use_write_raw_data; } -alias WKSTA_INFO_1056* PWKSTA_INFO_1056, LPWKSTA_INFO_1056; +alias PWKSTA_INFO_1056 = WKSTA_INFO_1056*, LPWKSTA_INFO_1056 = WKSTA_INFO_1056*; struct WKSTA_INFO_1057 { BOOL wki1057_use_encryption; } -alias WKSTA_INFO_1057* PWKSTA_INFO_1057, LPWKSTA_INFO_1057; +alias PWKSTA_INFO_1057 = WKSTA_INFO_1057*, LPWKSTA_INFO_1057 = WKSTA_INFO_1057*; struct WKSTA_INFO_1058 { BOOL wki1058_buf_files_deny_write; } -alias WKSTA_INFO_1058* PWKSTA_INFO_1058, LPWKSTA_INFO_1058; +alias PWKSTA_INFO_1058 = WKSTA_INFO_1058*, LPWKSTA_INFO_1058 = WKSTA_INFO_1058*; struct WKSTA_INFO_1059 { BOOL wki1059_buf_read_only_files; } -alias WKSTA_INFO_1059* PWKSTA_INFO_1059, LPWKSTA_INFO_1059; +alias PWKSTA_INFO_1059 = WKSTA_INFO_1059*, LPWKSTA_INFO_1059 = WKSTA_INFO_1059*; struct WKSTA_INFO_1060 { BOOL wki1060_force_core_create_mode; } -alias WKSTA_INFO_1060* PWKSTA_INFO_1060, LPWKSTA_INFO_1060; +alias PWKSTA_INFO_1060 = WKSTA_INFO_1060*, LPWKSTA_INFO_1060 = WKSTA_INFO_1060*; struct WKSTA_INFO_1061 { BOOL wki1061_use_512_byte_max_transfer; } -alias WKSTA_INFO_1061* PWKSTA_INFO_1061, LPWKSTA_INFO_1061; +alias PWKSTA_INFO_1061 = WKSTA_INFO_1061*, LPWKSTA_INFO_1061 = WKSTA_INFO_1061*; struct WKSTA_INFO_1062 { DWORD wki1062_read_ahead_throughput; } -alias WKSTA_INFO_1062* PWKSTA_INFO_1062, LPWKSTA_INFO_1062; +alias PWKSTA_INFO_1062 = WKSTA_INFO_1062*, LPWKSTA_INFO_1062 = WKSTA_INFO_1062*; struct WKSTA_USER_INFO_0 { LPWSTR wkui0_username; } -alias WKSTA_USER_INFO_0* PWKSTA_USER_INFO_0, LPWKSTA_USER_INFO_0; +alias PWKSTA_USER_INFO_0 = WKSTA_USER_INFO_0*, LPWKSTA_USER_INFO_0 = WKSTA_USER_INFO_0*; struct WKSTA_USER_INFO_1{ LPWSTR wkui1_username; @@ -362,12 +362,12 @@ struct WKSTA_USER_INFO_1{ LPWSTR wkui1_oth_domains; LPWSTR wkui1_logon_server; } -alias WKSTA_USER_INFO_1* PWKSTA_USER_INFO_1, LPWKSTA_USER_INFO_1; +alias PWKSTA_USER_INFO_1 = WKSTA_USER_INFO_1*, LPWKSTA_USER_INFO_1 = WKSTA_USER_INFO_1*; struct WKSTA_USER_INFO_1101 { LPWSTR wkui1101_oth_domains; } -alias WKSTA_USER_INFO_1101* PWKSTA_USER_INFO_1101, LPWKSTA_USER_INFO_1101; +alias PWKSTA_USER_INFO_1101 = WKSTA_USER_INFO_1101*, LPWKSTA_USER_INFO_1101 = WKSTA_USER_INFO_1101*; struct WKSTA_TRANSPORT_INFO_0{ DWORD wkti0_quality_of_service; @@ -376,7 +376,7 @@ struct WKSTA_TRANSPORT_INFO_0{ LPWSTR wkti0_transport_address; BOOL wkti0_wan_ish; } -alias WKSTA_TRANSPORT_INFO_0* PWKSTA_TRANSPORT_INFO_0, LPWKSTA_TRANSPORT_INFO_0; +alias PWKSTA_TRANSPORT_INFO_0 = WKSTA_TRANSPORT_INFO_0*, LPWKSTA_TRANSPORT_INFO_0 = WKSTA_TRANSPORT_INFO_0*; extern (Windows) { NET_API_STATUS NetWkstaGetInfo(LPWSTR,DWORD,PBYTE*); diff --git a/runtime/druntime/src/core/sys/windows/lzexpand.d b/runtime/druntime/src/core/sys/windows/lzexpand.d index 6c3bd0084f..2a76eecd38 100644 --- a/runtime/druntime/src/core/sys/windows/lzexpand.d +++ b/runtime/druntime/src/core/sys/windows/lzexpand.d @@ -42,9 +42,9 @@ INT LZRead(INT, LPSTR, INT); LONG LZSeek(INT, LONG, INT); version (Unicode) { - alias GetExpandedNameW GetExpandedName; - alias LZOpenFileW LZOpenFile; + alias GetExpandedName = GetExpandedNameW; + alias LZOpenFile = LZOpenFileW; } else { - alias GetExpandedNameA GetExpandedName; - alias LZOpenFileA LZOpenFile; + alias GetExpandedName = GetExpandedNameA; + alias LZOpenFile = LZOpenFileA; } diff --git a/runtime/druntime/src/core/sys/windows/mapi.d b/runtime/druntime/src/core/sys/windows/mapi.d index 8f8eea1e12..74e20f3bc7 100644 --- a/runtime/druntime/src/core/sys/windows/mapi.d +++ b/runtime/druntime/src/core/sys/windows/mapi.d @@ -74,10 +74,10 @@ enum MAPI_UNREAD = 0x0001; enum MAPI_RECEIPT_REQUESTED = 0x0002; enum MAPI_SENT = 0x0004; -alias uint FLAGS; -alias uint* LPULONG; -alias ULONG_PTR LHANDLE; -alias ULONG_PTR* LPLHANDLE; +alias FLAGS = uint; +alias LPULONG = uint*; +alias LHANDLE = ULONG_PTR; +alias LPLHANDLE = ULONG_PTR*; struct MapiRecipDesc { ULONG ulReserved; @@ -87,7 +87,7 @@ struct MapiRecipDesc { ULONG ulEIDSize; LPVOID lpEntryID; } -alias MapiRecipDesc* lpMapiRecipDesc; +alias lpMapiRecipDesc = MapiRecipDesc*; struct MapiFileDesc { ULONG ulReserved; @@ -97,7 +97,7 @@ struct MapiFileDesc { LPSTR lpszFileName; LPVOID lpFileType; } -alias MapiFileDesc* lpMapiFileDesc; +alias lpMapiFileDesc = MapiFileDesc*; struct MapiFileTagExt { ULONG ulReserved; @@ -106,7 +106,7 @@ struct MapiFileTagExt { ULONG cbEncoding; LPBYTE lpEncoding; } -alias MapiFileTagExt* lpMapiFileTagExt; +alias lpMapiFileTagExt = MapiFileTagExt*; struct MapiMessage { ULONG ulReserved; @@ -122,7 +122,7 @@ struct MapiMessage { ULONG nFileCount; lpMapiFileDesc lpFiles; } -alias MapiMessage* lpMapiMessage; +alias lpMapiMessage = MapiMessage*; extern (Windows) { ULONG MAPILogon(ULONG_PTR, LPSTR, LPSTR, FLAGS, ULONG, LPLHANDLE); @@ -145,26 +145,18 @@ extern (Windows) { ULONG MAPI_NSCP_SynchronizeClient(LHANDLE, ULONG); // Handles for use with GetProcAddress - alias ULONG function(ULONG_PTR, LPSTR, LPSTR, FLAGS, ULONG, LPLHANDLE) - LPMAPILOGON; - alias ULONG function(LHANDLE, ULONG_PTR, lpMapiMessage, FLAGS, ULONG) - LPMAPISENDMAIL; - alias ULONG function(ULONG_PTR, LPSTR, LPSTR, LPSTR, ULONG) - LPMAPISENDDOCUMENTS; - alias ULONG function(LHANDLE, ULONG_PTR, LPSTR, FLAGS, ULONG, lpMapiMessage*) - LPMAPIREADMAIL; - alias ULONG function(LHANDLE, ULONG_PTR, LPSTR, LPSTR, FLAGS, ULONG, LPSTR) - LPMAPIFINDNEXT; - alias ULONG function(LHANDLE, ULONG_PTR, LPSTR, FLAGS, ULONG, - lpMapiRecipDesc*) LPMAPIRESOLVENAME; - alias ULONG function(LHANDLE, ULONG_PTR, LPSTR, ULONG, LPSTR, ULONG, - lpMapiRecipDesc, FLAGS, ULONG, LPULONG, lpMapiRecipDesc*) LPMAPIADDRESS; - alias ULONG function(LPVOID lpv) LPMAPIFREEBUFFER; - alias ULONG function(LHANDLE, ULONG_PTR, lpMapiRecipDesc, FLAGS, ULONG) - LPMAPIDETAILS; - alias ULONG function(LHANDLE, ULONG_PTR, lpMapiMessage, FLAGS, ULONG, LPSTR) - LPMAPISAVEMAIL; - alias ULONG function(LHANDLE, ULONG_PTR, LPSTR, FLAGS, ULONG) - LPMAPIDELETEMAIL; - alias ULONG function(LHANDLE, ULONG_PTR, FLAGS, ULONG) LPMAPILOGOFF; + alias LPMAPILOGON = ULONG function(ULONG_PTR, LPSTR, LPSTR, FLAGS, ULONG, LPLHANDLE); + alias LPMAPISENDMAIL = ULONG function(LHANDLE, ULONG_PTR, lpMapiMessage, FLAGS, ULONG); + alias LPMAPISENDDOCUMENTS = ULONG function(ULONG_PTR, LPSTR, LPSTR, LPSTR, ULONG); + alias LPMAPIREADMAIL = ULONG function(LHANDLE, ULONG_PTR, LPSTR, FLAGS, ULONG, lpMapiMessage*); + alias LPMAPIFINDNEXT = ULONG function(LHANDLE, ULONG_PTR, LPSTR, LPSTR, FLAGS, ULONG, LPSTR); + alias LPMAPIRESOLVENAME = ULONG function(LHANDLE, ULONG_PTR, LPSTR, FLAGS, ULONG, + lpMapiRecipDesc*); + alias LPMAPIADDRESS = ULONG function(LHANDLE, ULONG_PTR, LPSTR, ULONG, LPSTR, ULONG, + lpMapiRecipDesc, FLAGS, ULONG, LPULONG, lpMapiRecipDesc*); + alias LPMAPIFREEBUFFER = ULONG function(LPVOID lpv); + alias LPMAPIDETAILS = ULONG function(LHANDLE, ULONG_PTR, lpMapiRecipDesc, FLAGS, ULONG); + alias LPMAPISAVEMAIL = ULONG function(LHANDLE, ULONG_PTR, lpMapiMessage, FLAGS, ULONG, LPSTR); + alias LPMAPIDELETEMAIL = ULONG function(LHANDLE, ULONG_PTR, LPSTR, FLAGS, ULONG); + alias LPMAPILOGOFF = ULONG function(LHANDLE, ULONG_PTR, FLAGS, ULONG); } diff --git a/runtime/druntime/src/core/sys/windows/mcx.d b/runtime/druntime/src/core/sys/windows/mcx.d index 5c6ac24a31..864c3f27da 100644 --- a/runtime/druntime/src/core/sys/windows/mcx.d +++ b/runtime/druntime/src/core/sys/windows/mcx.d @@ -78,7 +78,7 @@ struct MODEMDEVCAPS { BYTE* abVariablePortion() return { return &_abVariablePortion; } } -alias MODEMDEVCAPS* PMODEMDEVCAPS, LPMODEMDEVCAPS; +alias PMODEMDEVCAPS = MODEMDEVCAPS*, LPMODEMDEVCAPS = MODEMDEVCAPS*; struct MODEMSETTINGS { DWORD dwActualSize; @@ -96,4 +96,4 @@ struct MODEMSETTINGS { BYTE* abVariablePortion() return { return &_abVariablePortion; } } -alias MODEMSETTINGS* PMODEMSETTINGS, LPMODEMSETTINGS; +alias PMODEMSETTINGS = MODEMSETTINGS*, LPMODEMSETTINGS = MODEMSETTINGS*; diff --git a/runtime/druntime/src/core/sys/windows/mgmtapi.d b/runtime/druntime/src/core/sys/windows/mgmtapi.d index 336d24e750..11b2aa6617 100644 --- a/runtime/druntime/src/core/sys/windows/mgmtapi.d +++ b/runtime/druntime/src/core/sys/windows/mgmtapi.d @@ -27,7 +27,7 @@ enum { enum MGMCTL_SETAGENTPORT = 1; -alias PVOID LPSNMP_MGR_SESSION; +alias LPSNMP_MGR_SESSION = PVOID; extern (Windows) nothrow @nogc { BOOL SnmpMgrClose(LPSNMP_MGR_SESSION); diff --git a/runtime/druntime/src/core/sys/windows/mmsystem.d b/runtime/druntime/src/core/sys/windows/mmsystem.d index 2ce75aa788..6957a44496 100644 --- a/runtime/druntime/src/core/sys/windows/mmsystem.d +++ b/runtime/druntime/src/core/sys/windows/mmsystem.d @@ -1018,11 +1018,11 @@ enum C1_TRANSPARENT=1; //const SEEK_END=2; public import core.stdc.stdio : SEEK_SET, SEEK_CUR, SEEK_END; -alias DWORD MCIERROR; -alias UINT MCIDEVICEID; -extern(Windows) alias UINT function (MCIDEVICEID, DWORD) YIELDPROC; -alias UINT MMVERSION; -alias UINT MMRESULT; +alias MCIERROR = DWORD; +alias MCIDEVICEID = UINT; +extern(Windows) alias YIELDPROC = UINT function (MCIDEVICEID, DWORD); +alias MMVERSION = UINT; +alias MMRESULT = UINT; struct MMTIME { UINT wType; @@ -1047,9 +1047,9 @@ struct MMTIME { _midi midi; } } -alias MMTIME* PMMTIME, LPMMTIME; +alias PMMTIME = MMTIME*, LPMMTIME = MMTIME*; -alias HANDLE HDRVR; +alias HDRVR = HANDLE; struct DRVCONFIGINFO { align(1): @@ -1057,7 +1057,7 @@ align(1): LPCWSTR lpszDCISectionName; LPCWSTR lpszDCIAliasName; } -alias DRVCONFIGINFO * PDRVCONFIGINFO, LPDRVCONFIGINFO; +alias PDRVCONFIGINFO = DRVCONFIGINFO *, LPDRVCONFIGINFO = DRVCONFIGINFO *; struct DRVCONFIGINFOEX { align(1): @@ -1066,7 +1066,7 @@ align(1): LPCWSTR lpszDCIAliasName; DWORD dnDevNode; } -alias DRVCONFIGINFOEX* PDRVCONFIGINFOEX, LPDRVCONFIGINFOEX; +alias PDRVCONFIGINFOEX = DRVCONFIGINFOEX*, LPDRVCONFIGINFOEX = DRVCONFIGINFOEX*; extern(Windows): @@ -1083,12 +1083,12 @@ alias MIDICALLBACK* LPMIDICALLBACK; +/ -alias HANDLE HWAVE; -alias HANDLE HWAVEIN; -alias HANDLE HWAVEOUT; +alias HWAVE = HANDLE; +alias HWAVEIN = HANDLE; +alias HWAVEOUT = HANDLE; -alias HWAVEIN* LPHWAVEIN; -alias HWAVEOUT* LPHWAVEOUT; +alias LPHWAVEIN = HWAVEIN*; +alias LPHWAVEOUT = HWAVEOUT*; struct WAVEHDR { LPSTR lpData; @@ -1100,7 +1100,7 @@ struct WAVEHDR { WAVEHDR *lpNext; DWORD_PTR reserved; } -alias WAVEHDR* PWAVEHDR, LPWAVEHDR; +alias PWAVEHDR = WAVEHDR*, LPWAVEHDR = WAVEHDR*; struct WAVEOUTCAPSA { WORD wMid; @@ -1112,7 +1112,7 @@ struct WAVEOUTCAPSA { WORD wReserved1; DWORD dwSupport; } -alias WAVEOUTCAPSA* PWAVEOUTCAPSA, LPWAVEOUTCAPSA; +alias PWAVEOUTCAPSA = WAVEOUTCAPSA*, LPWAVEOUTCAPSA = WAVEOUTCAPSA*; struct WAVEOUTCAPSW { WORD wMid; @@ -1124,7 +1124,7 @@ struct WAVEOUTCAPSW { WORD wReserved1; DWORD dwSupport; } -alias WAVEOUTCAPSW* PWAVEOUTCAPSW, LPWAVEOUTCAPSW; +alias PWAVEOUTCAPSW = WAVEOUTCAPSW*, LPWAVEOUTCAPSW = WAVEOUTCAPSW*; struct WAVEINCAPSA { WORD wMid; @@ -1135,7 +1135,7 @@ struct WAVEINCAPSA { WORD wChannels; WORD wReserved1; } -alias WAVEINCAPSA* PWAVEINCAPSA, LPWAVEINCAPSA; +alias PWAVEINCAPSA = WAVEINCAPSA*, LPWAVEINCAPSA = WAVEINCAPSA*; struct WAVEINCAPSW { WORD wMid; @@ -1146,7 +1146,7 @@ struct WAVEINCAPSW { WORD wChannels; WORD wReserved1; } -alias WAVEINCAPSW* PWAVEINCAPSW, LPWAVEINCAPSW; +alias PWAVEINCAPSW = WAVEINCAPSW*, LPWAVEINCAPSW = WAVEINCAPSW*; struct WAVEFORMAT { WORD wFormatTag; @@ -1155,13 +1155,13 @@ struct WAVEFORMAT { DWORD nAvgBytesPerSec; WORD nBlockAlign; } -alias WAVEFORMAT* PWAVEFORMAT, LPWAVEFORMAT; +alias PWAVEFORMAT = WAVEFORMAT*, LPWAVEFORMAT = WAVEFORMAT*; struct PCMWAVEFORMAT { WAVEFORMAT wf; WORD wBitsPerSample; } -alias PCMWAVEFORMAT* PPCMWAVEFORMAT, LPPCMWAVEFORMAT; +alias PPCMWAVEFORMAT = PCMWAVEFORMAT*, LPPCMWAVEFORMAT = PCMWAVEFORMAT*; struct WAVEFORMATEX { WORD wFormatTag; @@ -1172,23 +1172,23 @@ struct WAVEFORMATEX { WORD wBitsPerSample; WORD cbSize; } -alias WAVEFORMATEX* PWAVEFORMATEX, LPWAVEFORMATEX; -alias const(WAVEFORMATEX)* LPCWAVEFORMATEX; +alias PWAVEFORMATEX = WAVEFORMATEX*, LPWAVEFORMATEX = WAVEFORMATEX*; +alias LPCWAVEFORMATEX = const(WAVEFORMATEX)*; -alias HANDLE HMIDI; -alias HANDLE HMIDIIN; -alias HANDLE HMIDIOUT; -alias HANDLE HMIDISTRM; +alias HMIDI = HANDLE; +alias HMIDIIN = HANDLE; +alias HMIDIOUT = HANDLE; +alias HMIDISTRM = HANDLE; -alias HMIDI* LPHMIDI; -alias HMIDIIN* LPHMIDIIN; -alias HMIDIOUT* LPHMIDIOUT; -alias HMIDISTRM* LPHMIDISTRM; +alias LPHMIDI = HMIDI*; +alias LPHMIDIIN = HMIDIIN*; +alias LPHMIDIOUT = HMIDIOUT*; +alias LPHMIDISTRM = HMIDISTRM*; -alias WORD[MIDIPATCHSIZE] PATCHARRAY; -alias WORD* LPPATCHARRAY; -alias WORD[MIDIPATCHSIZE] KEYARRAY; -alias WORD* LPKEYARRAY; +alias PATCHARRAY = WORD[MIDIPATCHSIZE]; +alias LPPATCHARRAY = WORD*; +alias KEYARRAY = WORD[MIDIPATCHSIZE]; +alias LPKEYARRAY = WORD*; struct MIDIOUTCAPSA { WORD wMid; @@ -1201,7 +1201,7 @@ struct MIDIOUTCAPSA { WORD wChannelMask; DWORD dwSupport; } -alias MIDIOUTCAPSA* PMIDIOUTCAPSA, LPMIDIOUTCAPSA; +alias PMIDIOUTCAPSA = MIDIOUTCAPSA*, LPMIDIOUTCAPSA = MIDIOUTCAPSA*; struct MIDIOUTCAPSW { WORD wMid; @@ -1214,7 +1214,7 @@ struct MIDIOUTCAPSW { WORD wChannelMask; DWORD dwSupport; } -alias MIDIOUTCAPSW* PMIDIOUTCAPSW, LPMIDIOUTCAPSW; +alias PMIDIOUTCAPSW = MIDIOUTCAPSW*, LPMIDIOUTCAPSW = MIDIOUTCAPSW*; struct MIDIINCAPSA { WORD wMid; @@ -1223,7 +1223,7 @@ struct MIDIINCAPSA { CHAR[MAXPNAMELEN] szPname = 0; DWORD dwSupport; } -alias MIDIINCAPSA* PMIDIINCAPSA, LPMIDIINCAPSA; +alias PMIDIINCAPSA = MIDIINCAPSA*, LPMIDIINCAPSA = MIDIINCAPSA*; struct MIDIINCAPSW { WORD wMid; @@ -1232,7 +1232,7 @@ struct MIDIINCAPSW { WCHAR[MAXPNAMELEN] szPname = 0; DWORD dwSupport; } -alias MIDIINCAPSW* PMIDIINCAPSW, LPMIDIINCAPSW; +alias PMIDIINCAPSW = MIDIINCAPSW*, LPMIDIINCAPSW = MIDIINCAPSW*; struct MIDIHDR { align(1): @@ -1246,7 +1246,7 @@ align(1): DWORD dwOffset; DWORD_PTR[8] dwReserved; } -alias MIDIHDR* PMIDIHDR, LPMIDIHDR; +alias PMIDIHDR = MIDIHDR*, LPMIDIHDR = MIDIHDR*; struct MIDIEVENT { DWORD dwDeltaTime; @@ -1265,13 +1265,13 @@ struct MIDIPROPTIMEDIV { DWORD cbStruct; DWORD dwTimeDiv; } -alias MIDIPROPTIMEDIV* LPMIDIPROPTIMEDIV; +alias LPMIDIPROPTIMEDIV = MIDIPROPTIMEDIV*; struct MIDIPROPTEMPO { DWORD cbStruct; DWORD dwTempo; } -alias MIDIPROPTEMPO* LPMIDIPROPTEMPO; +alias LPMIDIPROPTEMPO = MIDIPROPTEMPO*; struct AUXCAPSA { WORD wMid; @@ -1282,7 +1282,7 @@ struct AUXCAPSA { WORD wReserved1; DWORD dwSupport; } -alias AUXCAPSA* PAUXCAPSA, LPAUXCAPSA; +alias PAUXCAPSA = AUXCAPSA*, LPAUXCAPSA = AUXCAPSA*; struct AUXCAPSW { WORD wMid; @@ -1293,13 +1293,13 @@ struct AUXCAPSW { WORD wReserved1; DWORD dwSupport; } -alias AUXCAPSW* PAUXCAPSW, LPAUXCAPSW; +alias PAUXCAPSW = AUXCAPSW*, LPAUXCAPSW = AUXCAPSW*; -alias HANDLE HMIXEROBJ; -alias HMIXEROBJ* LPHMIXEROBJ; +alias HMIXEROBJ = HANDLE; +alias LPHMIXEROBJ = HMIXEROBJ*; -alias HANDLE HMIXER; -alias HMIXER* LPHMIXER; +alias HMIXER = HANDLE; +alias LPHMIXER = HMIXER*; struct MIXERCAPSA { WORD wMid; @@ -1309,7 +1309,7 @@ struct MIXERCAPSA { DWORD fdwSupport; DWORD cDestinations; } -alias MIXERCAPSA* PMIXERCAPSA, LPMIXERCAPSA; +alias PMIXERCAPSA = MIXERCAPSA*, LPMIXERCAPSA = MIXERCAPSA*; struct MIXERCAPSW { WORD wMid; @@ -1319,7 +1319,7 @@ struct MIXERCAPSW { DWORD fdwSupport; DWORD cDestinations; } -alias MIXERCAPSW* PMIXERCAPSW, LPMIXERCAPSW; +alias PMIXERCAPSW = MIXERCAPSW*, LPMIXERCAPSW = MIXERCAPSW*; struct MIXERLINEA { align(1): @@ -1345,7 +1345,7 @@ align(1): } _Target Target; } -alias MIXERLINEA* PMIXERLINEA, LPMIXERLINEA; +alias PMIXERLINEA = MIXERLINEA*, LPMIXERLINEA = MIXERLINEA*; struct MIXERLINEW { align(1): @@ -1371,7 +1371,7 @@ align(1): } _Target Target; } -alias MIXERLINEW* PMIXERLINEW, LPMIXERLINEW; +alias PMIXERLINEW = MIXERLINEW*, LPMIXERLINEW = MIXERLINEW*; struct MIXERCONTROLA { DWORD cbStruct; @@ -1400,7 +1400,7 @@ struct MIXERCONTROLA { } _Metrics Metrics; } -alias MIXERCONTROLA* PMIXERCONTROLA, LPMIXERCONTROLA; +alias PMIXERCONTROLA = MIXERCONTROLA*, LPMIXERCONTROLA = MIXERCONTROLA*; struct MIXERCONTROLW { DWORD cbStruct; @@ -1430,7 +1430,7 @@ struct MIXERCONTROLW { _Metrics Metrics; } -alias MIXERCONTROLW* PMIXERCONTROLW, LPMIXERCONTROLW; +alias PMIXERCONTROLW = MIXERCONTROLW*, LPMIXERCONTROLW = MIXERCONTROLW*; struct MIXERLINECONTROLSA { align(1): @@ -1444,7 +1444,7 @@ align(1): DWORD cbmxctrl; LPMIXERCONTROLA pamxctrl; } -alias MIXERLINECONTROLSA* PMIXERLINECONTROLSA, LPMIXERLINECONTROLSA; +alias PMIXERLINECONTROLSA = MIXERLINECONTROLSA*, LPMIXERLINECONTROLSA = MIXERLINECONTROLSA*; struct MIXERLINECONTROLSW { align(1): @@ -1458,7 +1458,7 @@ align(1): DWORD cbmxctrl; LPMIXERCONTROLW pamxctrl; } -alias MIXERLINECONTROLSW* PMIXERLINECONTROLSW, LPMIXERLINECONTROLSW; +alias PMIXERLINECONTROLSW = MIXERLINECONTROLSW*, LPMIXERLINECONTROLSW = MIXERLINECONTROLSW*; struct MIXERCONTROLDETAILS { align(1): @@ -1472,44 +1472,44 @@ align(1): DWORD cbDetails; PVOID paDetails; } -alias MIXERCONTROLDETAILS* PMIXERCONTROLDETAILS, LPMIXERCONTROLDETAILS; +alias PMIXERCONTROLDETAILS = MIXERCONTROLDETAILS*, LPMIXERCONTROLDETAILS = MIXERCONTROLDETAILS*; struct MIXERCONTROLDETAILS_LISTTEXTA { DWORD dwParam1; DWORD dwParam2; CHAR[MIXER_LONG_NAME_CHARS] szName = 0; } -alias MIXERCONTROLDETAILS_LISTTEXTA* PMIXERCONTROLDETAILS_LISTTEXTA, LPMIXERCONTROLDETAILS_LISTTEXTA; +alias PMIXERCONTROLDETAILS_LISTTEXTA = MIXERCONTROLDETAILS_LISTTEXTA*, LPMIXERCONTROLDETAILS_LISTTEXTA = MIXERCONTROLDETAILS_LISTTEXTA*; struct MIXERCONTROLDETAILS_LISTTEXTW { DWORD dwParam1; DWORD dwParam2; WCHAR[MIXER_LONG_NAME_CHARS] szName = 0; } -alias MIXERCONTROLDETAILS_LISTTEXTW* PMIXERCONTROLDETAILS_LISTTEXTW, LPMIXERCONTROLDETAILS_LISTTEXTW; +alias PMIXERCONTROLDETAILS_LISTTEXTW = MIXERCONTROLDETAILS_LISTTEXTW*, LPMIXERCONTROLDETAILS_LISTTEXTW = MIXERCONTROLDETAILS_LISTTEXTW*; struct MIXERCONTROLDETAILS_BOOLEAN { LONG fValue; } -alias MIXERCONTROLDETAILS_BOOLEAN* PMIXERCONTROLDETAILS_BOOLEAN, LPMIXERCONTROLDETAILS_BOOLEAN; +alias PMIXERCONTROLDETAILS_BOOLEAN = MIXERCONTROLDETAILS_BOOLEAN*, LPMIXERCONTROLDETAILS_BOOLEAN = MIXERCONTROLDETAILS_BOOLEAN*; struct MIXERCONTROLDETAILS_SIGNED { LONG lValue; } -alias MIXERCONTROLDETAILS_SIGNED* PMIXERCONTROLDETAILS_SIGNED, LPMIXERCONTROLDETAILS_SIGNED; +alias PMIXERCONTROLDETAILS_SIGNED = MIXERCONTROLDETAILS_SIGNED*, LPMIXERCONTROLDETAILS_SIGNED = MIXERCONTROLDETAILS_SIGNED*; struct MIXERCONTROLDETAILS_UNSIGNED { DWORD dwValue; } -alias MIXERCONTROLDETAILS_UNSIGNED* PMIXERCONTROLDETAILS_UNSIGNED, LPMIXERCONTROLDETAILS_UNSIGNED; +alias PMIXERCONTROLDETAILS_UNSIGNED = MIXERCONTROLDETAILS_UNSIGNED*, LPMIXERCONTROLDETAILS_UNSIGNED = MIXERCONTROLDETAILS_UNSIGNED*; -alias void function (UINT, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR) LPTIMECALLBACK; +alias LPTIMECALLBACK = void function (UINT, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR); struct TIMECAPS { UINT wPeriodMin; UINT wPeriodMax; } -alias TIMECAPS* PTIMECAPS, LPTIMECAPS; +alias PTIMECAPS = TIMECAPS*, LPTIMECAPS = TIMECAPS*; struct JOYCAPSA { WORD wMid; @@ -1537,7 +1537,7 @@ struct JOYCAPSA { CHAR[MAXPNAMELEN] szRegKey = 0; CHAR[MAX_JOYSTICKOEMVXDNAME] szOEMVxD = 0; } -alias JOYCAPSA* PJOYCAPSA, LPJOYCAPSA; +alias PJOYCAPSA = JOYCAPSA*, LPJOYCAPSA = JOYCAPSA*; struct JOYCAPSW { WORD wMid; @@ -1565,7 +1565,7 @@ struct JOYCAPSW { WCHAR[MAXPNAMELEN] szRegKey = 0; WCHAR[MAX_JOYSTICKOEMVXDNAME] szOEMVxD = 0; } -alias JOYCAPSW* PJOYCAPSW, LPJOYCAPSW; +alias PJOYCAPSW = JOYCAPSW*, LPJOYCAPSW = JOYCAPSW*; struct JOYINFO { UINT wXpos; @@ -1573,7 +1573,7 @@ struct JOYINFO { UINT wZpos; UINT wButtons; } -alias JOYINFO* PJOYINFO, LPJOYINFO; +alias PJOYINFO = JOYINFO*, LPJOYINFO = JOYINFO*; struct JOYINFOEX { DWORD dwSize; @@ -1590,14 +1590,14 @@ struct JOYINFOEX { DWORD dwReserved1; DWORD dwReserved2; } -alias JOYINFOEX* PJOYINFOEX, LPJOYINFOEX; +alias PJOYINFOEX = JOYINFOEX*, LPJOYINFOEX = JOYINFOEX*; -alias DWORD FOURCC; -alias char* HPSTR; +alias FOURCC = DWORD; +alias HPSTR = char*; -alias HANDLE HMMIO; +alias HMMIO = HANDLE; -alias LRESULT function (LPSTR, UINT, LPARAM, LPARAM) LPMMIOPROC; +alias LPMMIOPROC = LRESULT function (LPSTR, UINT, LPARAM, LPARAM); struct MMIOINFO { align(1): @@ -1618,8 +1618,8 @@ align(1): DWORD dwReserved2; HMMIO hmmio; } -alias MMIOINFO* PMMIOINFO, LPMMIOINFO; -alias const(MMIOINFO)* LPCMMIOINFO; +alias PMMIOINFO = MMIOINFO*, LPMMIOINFO = MMIOINFO*; +alias LPCMMIOINFO = const(MMIOINFO)*; struct MMCKINFO { FOURCC ckid; @@ -1628,13 +1628,13 @@ struct MMCKINFO { DWORD dwDataOffset; DWORD dwFlags; } -alias MMCKINFO* PMMCKINFO, LPMMCKINFO; -alias const(MMCKINFO)* LPCMMCKINFO; +alias PMMCKINFO = MMCKINFO*, LPMMCKINFO = MMCKINFO*; +alias LPCMMCKINFO = const(MMCKINFO)*; struct MCI_GENERIC_PARMS { DWORD_PTR dwCallback; } -alias MCI_GENERIC_PARMS* PMCI_GENERIC_PARMS, LPMCI_GENERIC_PARMS; +alias PMCI_GENERIC_PARMS = MCI_GENERIC_PARMS*, LPMCI_GENERIC_PARMS = MCI_GENERIC_PARMS*; struct MCI_OPEN_PARMSA { align(1): @@ -1644,7 +1644,7 @@ align(1): LPCSTR lpstrElementName; LPCSTR lpstrAlias; } -alias MCI_OPEN_PARMSA* PMCI_OPEN_PARMSA, LPMCI_OPEN_PARMSA; +alias PMCI_OPEN_PARMSA = MCI_OPEN_PARMSA*, LPMCI_OPEN_PARMSA = MCI_OPEN_PARMSA*; struct MCI_OPEN_PARMSW { align(1): @@ -1654,20 +1654,20 @@ align(1): LPCWSTR lpstrElementName; LPCWSTR lpstrAlias; } -alias MCI_OPEN_PARMSW* PMCI_OPEN_PARMSW, LPMCI_OPEN_PARMSW; +alias PMCI_OPEN_PARMSW = MCI_OPEN_PARMSW*, LPMCI_OPEN_PARMSW = MCI_OPEN_PARMSW*; struct MCI_PLAY_PARMS { DWORD_PTR dwCallback; DWORD dwFrom; DWORD dwTo; } -alias MCI_PLAY_PARMS* PMCI_PLAY_PARMS, LPMCI_PLAY_PARMS; +alias PMCI_PLAY_PARMS = MCI_PLAY_PARMS*, LPMCI_PLAY_PARMS = MCI_PLAY_PARMS*; struct MCI_SEEK_PARMS { DWORD_PTR dwCallback; DWORD dwTo; } -alias MCI_SEEK_PARMS* PMCI_SEEK_PARMS, LPMCI_SEEK_PARMS; +alias PMCI_SEEK_PARMS = MCI_SEEK_PARMS*, LPMCI_SEEK_PARMS = MCI_SEEK_PARMS*; struct MCI_STATUS_PARMS { DWORD_PTR dwCallback; @@ -1675,28 +1675,28 @@ struct MCI_STATUS_PARMS { DWORD dwItem; DWORD dwTrack; } -alias MCI_STATUS_PARMS* PMCI_STATUS_PARMS, LPMCI_STATUS_PARMS; +alias PMCI_STATUS_PARMS = MCI_STATUS_PARMS*, LPMCI_STATUS_PARMS = MCI_STATUS_PARMS*; struct MCI_INFO_PARMSA { DWORD_PTR dwCallback; LPSTR lpstrReturn; DWORD dwRetSize; } -alias MCI_INFO_PARMSA* LPMCI_INFO_PARMSA; +alias LPMCI_INFO_PARMSA = MCI_INFO_PARMSA*; struct MCI_INFO_PARMSW { DWORD_PTR dwCallback; LPWSTR lpstrReturn; DWORD dwRetSize; } -alias MCI_INFO_PARMSW* LPMCI_INFO_PARMSW; +alias LPMCI_INFO_PARMSW = MCI_INFO_PARMSW*; struct MCI_GETDEVCAPS_PARMS { DWORD_PTR dwCallback; DWORD dwReturn; DWORD dwItem; } -alias MCI_GETDEVCAPS_PARMS* PMCI_GETDEVCAPS_PARMS, LPMCI_GETDEVCAPS_PARMS; +alias PMCI_GETDEVCAPS_PARMS = MCI_GETDEVCAPS_PARMS*, LPMCI_GETDEVCAPS_PARMS = MCI_GETDEVCAPS_PARMS*; struct MCI_SYSINFO_PARMSA { DWORD_PTR dwCallback; @@ -1705,7 +1705,7 @@ struct MCI_SYSINFO_PARMSA { DWORD dwNumber; UINT wDeviceType; } -alias MCI_SYSINFO_PARMSA* PMCI_SYSINFO_PARMSA, LPMCI_SYSINFO_PARMSA; +alias PMCI_SYSINFO_PARMSA = MCI_SYSINFO_PARMSA*, LPMCI_SYSINFO_PARMSA = MCI_SYSINFO_PARMSA*; struct MCI_SYSINFO_PARMSW { DWORD_PTR dwCallback; @@ -1714,14 +1714,14 @@ struct MCI_SYSINFO_PARMSW { DWORD dwNumber; UINT wDeviceType; } -alias MCI_SYSINFO_PARMSW* PMCI_SYSINFO_PARMSW, LPMCI_SYSINFO_PARMSW; +alias PMCI_SYSINFO_PARMSW = MCI_SYSINFO_PARMSW*, LPMCI_SYSINFO_PARMSW = MCI_SYSINFO_PARMSW*; struct MCI_SET_PARMS { DWORD_PTR dwCallback; DWORD dwTimeFormat; DWORD dwAudio; } -alias MCI_SET_PARMS* PMCI_SET_PARMS, LPMCI_SET_PARMS; +alias PMCI_SET_PARMS = MCI_SET_PARMS*, LPMCI_SET_PARMS = MCI_SET_PARMS*; struct MCI_BREAK_PARMS { align(1): @@ -1729,38 +1729,38 @@ align(1): int nVirtKey; HWND hwndBreak; } -alias MCI_BREAK_PARMS* PMCI_BREAK_PARMS, LPMCI_BREAK_PARMS; +alias PMCI_BREAK_PARMS = MCI_BREAK_PARMS*, LPMCI_BREAK_PARMS = MCI_BREAK_PARMS*; struct MCI_SAVE_PARMSA { DWORD_PTR dwCallback; LPCSTR lpfilename; } -alias MCI_SAVE_PARMSA* PMCI_SAVE_PARMSA, LPMCI_SAVE_PARMSA; +alias PMCI_SAVE_PARMSA = MCI_SAVE_PARMSA*, LPMCI_SAVE_PARMSA = MCI_SAVE_PARMSA*; struct MCI_SAVE_PARMSW { DWORD_PTR dwCallback; LPCWSTR lpfilename; } -alias MCI_SAVE_PARMSW* PMCI_SAVE_PARMSW, LPMCI_SAVE_PARMSW; +alias PMCI_SAVE_PARMSW = MCI_SAVE_PARMSW*, LPMCI_SAVE_PARMSW = MCI_SAVE_PARMSW*; struct MCI_LOAD_PARMSA { DWORD_PTR dwCallback; LPCSTR lpfilename; } -alias MCI_LOAD_PARMSA* PMCI_LOAD_PARMSA, LPMCI_LOAD_PARMSA; +alias PMCI_LOAD_PARMSA = MCI_LOAD_PARMSA*, LPMCI_LOAD_PARMSA = MCI_LOAD_PARMSA*; struct MCI_LOAD_PARMSW { DWORD_PTR dwCallback; LPCWSTR lpfilename; } -alias MCI_LOAD_PARMSW* PMCI_LOAD_PARMSW, LPMCI_LOAD_PARMSW; +alias PMCI_LOAD_PARMSW = MCI_LOAD_PARMSW*, LPMCI_LOAD_PARMSW = MCI_LOAD_PARMSW*; struct MCI_RECORD_PARMS { DWORD_PTR dwCallback; DWORD dwFrom; DWORD dwTo; } -alias MCI_RECORD_PARMS* LPMCI_RECORD_PARMS; +alias LPMCI_RECORD_PARMS = MCI_RECORD_PARMS*; struct MCI_VD_PLAY_PARMS { DWORD_PTR dwCallback; @@ -1768,25 +1768,25 @@ struct MCI_VD_PLAY_PARMS { DWORD dwTo; DWORD dwSpeed; } -alias MCI_VD_PLAY_PARMS* PMCI_VD_PLAY_PARMS, LPMCI_VD_PLAY_PARMS; +alias PMCI_VD_PLAY_PARMS = MCI_VD_PLAY_PARMS*, LPMCI_VD_PLAY_PARMS = MCI_VD_PLAY_PARMS*; struct MCI_VD_STEP_PARMS { DWORD_PTR dwCallback; DWORD dwFrames; } -alias MCI_VD_STEP_PARMS* PMCI_VD_STEP_PARMS, LPMCI_VD_STEP_PARMS; +alias PMCI_VD_STEP_PARMS = MCI_VD_STEP_PARMS*, LPMCI_VD_STEP_PARMS = MCI_VD_STEP_PARMS*; struct MCI_VD_ESCAPE_PARMSA { DWORD_PTR dwCallback; LPCSTR lpstrCommand; } -alias MCI_VD_ESCAPE_PARMSA* PMCI_VD_ESCAPE_PARMSA, LPMCI_VD_ESCAPE_PARMSA; +alias PMCI_VD_ESCAPE_PARMSA = MCI_VD_ESCAPE_PARMSA*, LPMCI_VD_ESCAPE_PARMSA = MCI_VD_ESCAPE_PARMSA*; struct MCI_VD_ESCAPE_PARMSW { DWORD_PTR dwCallback; LPCWSTR lpstrCommand; } -alias MCI_VD_ESCAPE_PARMSW* PMCI_VD_ESCAPE_PARMSW, LPMCI_VD_ESCAPE_PARMSW; +alias PMCI_VD_ESCAPE_PARMSW = MCI_VD_ESCAPE_PARMSW*, LPMCI_VD_ESCAPE_PARMSW = MCI_VD_ESCAPE_PARMSW*; struct MCI_WAVE_OPEN_PARMSA { align(1): @@ -1797,7 +1797,7 @@ align(1): LPCSTR lpstrAlias; DWORD dwBufferSeconds; } -alias MCI_WAVE_OPEN_PARMSA* PMCI_WAVE_OPEN_PARMSA, LPMCI_WAVE_OPEN_PARMSA; +alias PMCI_WAVE_OPEN_PARMSA = MCI_WAVE_OPEN_PARMSA*, LPMCI_WAVE_OPEN_PARMSA = MCI_WAVE_OPEN_PARMSA*; struct MCI_WAVE_OPEN_PARMSW { align(1): @@ -1808,14 +1808,14 @@ align(1): LPCWSTR lpstrAlias; DWORD dwBufferSeconds; } -alias MCI_WAVE_OPEN_PARMSW* PMCI_WAVE_OPEN_PARMSW, LPMCI_WAVE_OPEN_PARMSW; +alias PMCI_WAVE_OPEN_PARMSW = MCI_WAVE_OPEN_PARMSW*, LPMCI_WAVE_OPEN_PARMSW = MCI_WAVE_OPEN_PARMSW*; struct MCI_WAVE_DELETE_PARMS { DWORD_PTR dwCallback; DWORD dwFrom; DWORD dwTo; } -alias MCI_WAVE_DELETE_PARMS* PMCI_WAVE_DELETE_PARMS, LPMCI_WAVE_DELETE_PARMS; +alias PMCI_WAVE_DELETE_PARMS = MCI_WAVE_DELETE_PARMS*, LPMCI_WAVE_DELETE_PARMS = MCI_WAVE_DELETE_PARMS*; struct MCI_WAVE_SET_PARMS { DWORD_PTR dwCallback; @@ -1834,7 +1834,7 @@ struct MCI_WAVE_SET_PARMS { WORD wBitsPerSample; WORD wReserved5; } -alias MCI_WAVE_SET_PARMS* PMCI_WAVE_SET_PARMS, LPMCI_WAVE_SET_PARMS; +alias PMCI_WAVE_SET_PARMS = MCI_WAVE_SET_PARMS*, LPMCI_WAVE_SET_PARMS = MCI_WAVE_SET_PARMS*; extern (Windows) nothrow @nogc: LRESULT CloseDriver(HDRVR, LONG, LONG); @@ -2013,7 +2013,7 @@ struct MCI_SEQ_SET_PARMS { DWORD dwMaster; DWORD dwOffset; } -alias MCI_SEQ_SET_PARMS* PMCI_SEQ_SET_PARMS, LPMCI_SEQ_SET_PARMS; +alias PMCI_SEQ_SET_PARMS = MCI_SEQ_SET_PARMS*, LPMCI_SEQ_SET_PARMS = MCI_SEQ_SET_PARMS*; struct MCI_ANIM_OPEN_PARMSA { align(1): @@ -2025,7 +2025,7 @@ align(1): DWORD dwStyle; HWND hWndParent; } -alias MCI_ANIM_OPEN_PARMSA* PMCI_ANIM_OPEN_PARMSA, LPMCI_ANIM_OPEN_PARMSA; +alias PMCI_ANIM_OPEN_PARMSA = MCI_ANIM_OPEN_PARMSA*, LPMCI_ANIM_OPEN_PARMSA = MCI_ANIM_OPEN_PARMSA*; struct MCI_ANIM_OPEN_PARMSW { align(1): @@ -2037,7 +2037,7 @@ align(1): DWORD dwStyle; HWND hWndParent; } -alias MCI_ANIM_OPEN_PARMSW* PMCI_ANIM_OPEN_PARMSW, LPMCI_ANIM_OPEN_PARMSW; +alias PMCI_ANIM_OPEN_PARMSW = MCI_ANIM_OPEN_PARMSW*, LPMCI_ANIM_OPEN_PARMSW = MCI_ANIM_OPEN_PARMSW*; struct MCI_ANIM_PLAY_PARMS { DWORD_PTR dwCallback; @@ -2045,13 +2045,13 @@ struct MCI_ANIM_PLAY_PARMS { DWORD dwTo; DWORD dwSpeed; } -alias MCI_ANIM_PLAY_PARMS* PMCI_ANIM_PLAY_PARMS, LPMCI_ANIM_PLAY_PARMS; +alias PMCI_ANIM_PLAY_PARMS = MCI_ANIM_PLAY_PARMS*, LPMCI_ANIM_PLAY_PARMS = MCI_ANIM_PLAY_PARMS*; struct MCI_ANIM_STEP_PARMS { DWORD_PTR dwCallback; DWORD dwFrames; } -alias MCI_ANIM_STEP_PARMS* PMCI_ANIM_STEP_PARMS, LPMCI_ANIM_STEP_PARMS; +alias PMCI_ANIM_STEP_PARMS = MCI_ANIM_STEP_PARMS*, LPMCI_ANIM_STEP_PARMS = MCI_ANIM_STEP_PARMS*; struct MCI_ANIM_WINDOW_PARMSA { align(1): @@ -2060,7 +2060,7 @@ align(1): UINT nCmdShow; LPCSTR lpstrText; } -alias MCI_ANIM_WINDOW_PARMSA* PMCI_ANIM_WINDOW_PARMSA, LPMCI_ANIM_WINDOW_PARMSA; +alias PMCI_ANIM_WINDOW_PARMSA = MCI_ANIM_WINDOW_PARMSA*, LPMCI_ANIM_WINDOW_PARMSA = MCI_ANIM_WINDOW_PARMSA*; struct MCI_ANIM_WINDOW_PARMSW { align(1): @@ -2069,7 +2069,7 @@ align(1): UINT nCmdShow; LPCWSTR lpstrText; } -alias MCI_ANIM_WINDOW_PARMSW* PMCI_ANIM_WINDOW_PARMSW, LPMCI_ANIM_WINDOW_PARMSW; +alias PMCI_ANIM_WINDOW_PARMSW = MCI_ANIM_WINDOW_PARMSW*, LPMCI_ANIM_WINDOW_PARMSW = MCI_ANIM_WINDOW_PARMSW*; struct MCI_ANIM_RECT_PARMS { DWORD_PTR dwCallback; @@ -2080,14 +2080,14 @@ struct MCI_ANIM_RECT_PARMS { RECT rc; //#endif } -alias MCI_ANIM_RECT_PARMS* PMCI_ANIM_RECT_PARMS, LPMCI_ANIM_RECT_PARMS; +alias PMCI_ANIM_RECT_PARMS = MCI_ANIM_RECT_PARMS*, LPMCI_ANIM_RECT_PARMS = MCI_ANIM_RECT_PARMS*; struct MCI_ANIM_UPDATE_PARMS { DWORD_PTR dwCallback; RECT rc; HDC hDC; } -alias MCI_ANIM_UPDATE_PARMS* PMCI_ANIM_UPDATE_PARMS, LPMCI_ANIM_UPDATE_PARMS; +alias PMCI_ANIM_UPDATE_PARMS = MCI_ANIM_UPDATE_PARMS*, LPMCI_ANIM_UPDATE_PARMS = MCI_ANIM_UPDATE_PARMS*; struct MCI_OVLY_OPEN_PARMSA { align(1): @@ -2099,7 +2099,7 @@ align(1): DWORD dwStyle; HWND hWndParent; } -alias MCI_OVLY_OPEN_PARMSA* PMCI_OVLY_OPEN_PARMSA, LPMCI_OVLY_OPEN_PARMSA; +alias PMCI_OVLY_OPEN_PARMSA = MCI_OVLY_OPEN_PARMSA*, LPMCI_OVLY_OPEN_PARMSA = MCI_OVLY_OPEN_PARMSA*; struct MCI_OVLY_OPEN_PARMSW { align(1): @@ -2111,7 +2111,7 @@ align(1): DWORD dwStyle; HWND hWndParent; } -alias MCI_OVLY_OPEN_PARMSW* PMCI_OVLY_OPEN_PARMSW, LPMCI_OVLY_OPEN_PARMSW; +alias PMCI_OVLY_OPEN_PARMSW = MCI_OVLY_OPEN_PARMSW*, LPMCI_OVLY_OPEN_PARMSW = MCI_OVLY_OPEN_PARMSW*; struct MCI_OVLY_WINDOW_PARMSA { align(1): @@ -2120,7 +2120,7 @@ align(1): UINT nCmdShow; LPCSTR lpstrText; } -alias MCI_OVLY_WINDOW_PARMSA* PMCI_OVLY_WINDOW_PARMSA, LPMCI_OVLY_WINDOW_PARMSA; +alias PMCI_OVLY_WINDOW_PARMSA = MCI_OVLY_WINDOW_PARMSA*, LPMCI_OVLY_WINDOW_PARMSA = MCI_OVLY_WINDOW_PARMSA*; struct MCI_OVLY_WINDOW_PARMSW { align(1): @@ -2129,7 +2129,7 @@ align(1): UINT nCmdShow; LPCWSTR lpstrText; } -alias MCI_OVLY_WINDOW_PARMSW* PMCI_OVLY_WINDOW_PARMSW, LPMCI_OVLY_WINDOW_PARMSW; +alias PMCI_OVLY_WINDOW_PARMSW = MCI_OVLY_WINDOW_PARMSW*, LPMCI_OVLY_WINDOW_PARMSW = MCI_OVLY_WINDOW_PARMSW*; struct MCI_OVLY_RECT_PARMS { DWORD_PTR dwCallback; @@ -2140,159 +2140,159 @@ struct MCI_OVLY_RECT_PARMS { RECT rc; //#endif } -alias MCI_OVLY_RECT_PARMS* PMCI_OVLY_RECT_PARMS, LPMCI_OVLY_RECT_PARMS; +alias PMCI_OVLY_RECT_PARMS = MCI_OVLY_RECT_PARMS*, LPMCI_OVLY_RECT_PARMS = MCI_OVLY_RECT_PARMS*; struct MCI_OVLY_SAVE_PARMSA { DWORD_PTR dwCallback; LPCSTR lpfilename; RECT rc; } -alias MCI_OVLY_SAVE_PARMSA* PMCI_OVLY_SAVE_PARMSA, LPMCI_OVLY_SAVE_PARMSA; +alias PMCI_OVLY_SAVE_PARMSA = MCI_OVLY_SAVE_PARMSA*, LPMCI_OVLY_SAVE_PARMSA = MCI_OVLY_SAVE_PARMSA*; struct MCI_OVLY_SAVE_PARMSW { DWORD_PTR dwCallback; LPCWSTR lpfilename; RECT rc; } -alias MCI_OVLY_SAVE_PARMSW* PMCI_OVLY_SAVE_PARMSW, LPMCI_OVLY_SAVE_PARMSW; +alias PMCI_OVLY_SAVE_PARMSW = MCI_OVLY_SAVE_PARMSW*, LPMCI_OVLY_SAVE_PARMSW = MCI_OVLY_SAVE_PARMSW*; struct MCI_OVLY_LOAD_PARMSA { DWORD_PTR dwCallback; LPCSTR lpfilename; RECT rc; } -alias MCI_OVLY_LOAD_PARMSA* PMCI_OVLY_LOAD_PARMSA, LPMCI_OVLY_LOAD_PARMSA; +alias PMCI_OVLY_LOAD_PARMSA = MCI_OVLY_LOAD_PARMSA*, LPMCI_OVLY_LOAD_PARMSA = MCI_OVLY_LOAD_PARMSA*; struct MCI_OVLY_LOAD_PARMSW { DWORD_PTR dwCallback; LPCWSTR lpfilename; RECT rc; } -alias MCI_OVLY_LOAD_PARMSW* PMCI_OVLY_LOAD_PARMSW, LPMCI_OVLY_LOAD_PARMSW; +alias PMCI_OVLY_LOAD_PARMSW = MCI_OVLY_LOAD_PARMSW*, LPMCI_OVLY_LOAD_PARMSW = MCI_OVLY_LOAD_PARMSW*; version (Unicode) { - alias WAVEOUTCAPSW WAVEOUTCAPS; - alias WAVEINCAPSW WAVEINCAPS; - alias MIDIOUTCAPSW MIDIOUTCAPS; - alias MIDIINCAPSW MIDIINCAPS; - alias AUXCAPSW AUXCAPS; - alias MIXERCAPSW MIXERCAPS; - alias MIXERLINEW MIXERLINE; - alias MIXERCONTROLA MIXERCONTROL; - alias MIXERLINECONTROLSW MIXERLINECONTROLS; - alias MIXERCONTROLDETAILS_LISTTEXTW MIXERCONTROLDETAILS_LISTTEXT; - alias JOYCAPSW JOYCAPS; - alias MCI_OPEN_PARMSW MCI_OPEN_PARMS; - alias MCI_INFO_PARMSW MCI_INFO_PARMS; - alias MCI_SYSINFO_PARMSW MCI_SYSINFO_PARMS; - alias MCI_SAVE_PARMSW MCI_SAVE_PARMS; - alias MCI_LOAD_PARMSW MCI_LOAD_PARMS; - alias MCI_VD_ESCAPE_PARMSW MCI_VD_ESCAPE_PARMS; - alias MCI_WAVE_OPEN_PARMSW MCI_WAVE_OPEN_PARMS; - alias MCI_ANIM_OPEN_PARMSW MCI_ANIM_OPEN_PARMS; - alias MCI_ANIM_WINDOW_PARMSW MCI_ANIM_WINDOW_PARMS; - alias MCI_OVLY_OPEN_PARMSW MCI_OVLY_OPEN_PARMS; - alias MCI_OVLY_WINDOW_PARMSW MCI_OVLY_WINDOW_PARMS; - alias MCI_OVLY_SAVE_PARMSW MCI_OVLY_SAVE_PARMS; - - alias sndPlaySoundW sndPlaySound; - alias PlaySoundW PlaySound; - alias waveOutGetDevCapsW waveOutGetDevCaps; - alias waveOutGetErrorTextW waveOutGetErrorText; - alias waveInGetDevCapsW waveInGetDevCaps; - alias waveInGetErrorTextW waveInGetErrorText; - alias midiOutGetDevCapsW midiOutGetDevCaps; - alias midiOutGetErrorTextW midiOutGetErrorText; - alias midiInGetDevCapsW midiInGetDevCaps; - alias midiInGetErrorTextW midiInGetErrorText; - alias auxGetDevCapsW auxGetDevCaps; - alias mixerGetDevCapsW mixerGetDevCaps; - alias mixerGetLineInfoW mixerGetLineInfo; - alias mixerGetLineControlsW mixerGetLineControls; - alias mixerGetControlDetailsW mixerGetControlDetails; - alias joyGetDevCapsW joyGetDevCaps; - alias mmioInstallIOProcW mmioInstallIOProc; - alias mmioStringToFOURCCW mmioStringToFOURCC; - alias mmioOpenW mmioOpen; - alias mmioRenameW mmioRename; - alias mciSendCommandW mciSendCommand; - alias mciSendStringW mciSendString; - alias mciGetDeviceIDW mciGetDeviceID; - alias mciGetDeviceIDFromElementIDW mciGetDeviceIDFromElementID; - alias mciGetErrorStringW mciGetErrorString; + alias WAVEOUTCAPS = WAVEOUTCAPSW; + alias WAVEINCAPS = WAVEINCAPSW; + alias MIDIOUTCAPS = MIDIOUTCAPSW; + alias MIDIINCAPS = MIDIINCAPSW; + alias AUXCAPS = AUXCAPSW; + alias MIXERCAPS = MIXERCAPSW; + alias MIXERLINE = MIXERLINEW; + alias MIXERCONTROL = MIXERCONTROLA; + alias MIXERLINECONTROLS = MIXERLINECONTROLSW; + alias MIXERCONTROLDETAILS_LISTTEXT = MIXERCONTROLDETAILS_LISTTEXTW; + alias JOYCAPS = JOYCAPSW; + alias MCI_OPEN_PARMS = MCI_OPEN_PARMSW; + alias MCI_INFO_PARMS = MCI_INFO_PARMSW; + alias MCI_SYSINFO_PARMS = MCI_SYSINFO_PARMSW; + alias MCI_SAVE_PARMS = MCI_SAVE_PARMSW; + alias MCI_LOAD_PARMS = MCI_LOAD_PARMSW; + alias MCI_VD_ESCAPE_PARMS = MCI_VD_ESCAPE_PARMSW; + alias MCI_WAVE_OPEN_PARMS = MCI_WAVE_OPEN_PARMSW; + alias MCI_ANIM_OPEN_PARMS = MCI_ANIM_OPEN_PARMSW; + alias MCI_ANIM_WINDOW_PARMS = MCI_ANIM_WINDOW_PARMSW; + alias MCI_OVLY_OPEN_PARMS = MCI_OVLY_OPEN_PARMSW; + alias MCI_OVLY_WINDOW_PARMS = MCI_OVLY_WINDOW_PARMSW; + alias MCI_OVLY_SAVE_PARMS = MCI_OVLY_SAVE_PARMSW; + + alias sndPlaySound = sndPlaySoundW; + alias PlaySound = PlaySoundW; + alias waveOutGetDevCaps = waveOutGetDevCapsW; + alias waveOutGetErrorText = waveOutGetErrorTextW; + alias waveInGetDevCaps = waveInGetDevCapsW; + alias waveInGetErrorText = waveInGetErrorTextW; + alias midiOutGetDevCaps = midiOutGetDevCapsW; + alias midiOutGetErrorText = midiOutGetErrorTextW; + alias midiInGetDevCaps = midiInGetDevCapsW; + alias midiInGetErrorText = midiInGetErrorTextW; + alias auxGetDevCaps = auxGetDevCapsW; + alias mixerGetDevCaps = mixerGetDevCapsW; + alias mixerGetLineInfo = mixerGetLineInfoW; + alias mixerGetLineControls = mixerGetLineControlsW; + alias mixerGetControlDetails = mixerGetControlDetailsW; + alias joyGetDevCaps = joyGetDevCapsW; + alias mmioInstallIOProc = mmioInstallIOProcW; + alias mmioStringToFOURCC = mmioStringToFOURCCW; + alias mmioOpen = mmioOpenW; + alias mmioRename = mmioRenameW; + alias mciSendCommand = mciSendCommandW; + alias mciSendString = mciSendStringW; + alias mciGetDeviceID = mciGetDeviceIDW; + alias mciGetDeviceIDFromElementID = mciGetDeviceIDFromElementIDW; + alias mciGetErrorString = mciGetErrorStringW; } else { - alias WAVEOUTCAPSA WAVEOUTCAPS; - alias WAVEINCAPSA WAVEINCAPS; - alias MIDIOUTCAPSA MIDIOUTCAPS; - alias MIDIINCAPSA MIDIINCAPS; - alias AUXCAPSA AUXCAPS; - alias MIXERCAPSA MIXERCAPS; - alias MIXERLINEA MIXERLINE; - alias MIXERCONTROLA MIXERCONTROL; - alias MIXERLINECONTROLSA MIXERLINECONTROLS; - alias MIXERCONTROLDETAILS_LISTTEXTA MIXERCONTROLDETAILS_LISTTEXT; - alias JOYCAPSA JOYCAPS; - alias MCI_OPEN_PARMSA MCI_OPEN_PARMS; - alias MCI_INFO_PARMSA MCI_INFO_PARMS; - alias MCI_SYSINFO_PARMSA MCI_SYSINFO_PARMS; - alias MCI_SAVE_PARMSA MCI_SAVE_PARMS; - alias MCI_LOAD_PARMSA MCI_LOAD_PARMS; - alias MCI_VD_ESCAPE_PARMSA MCI_VD_ESCAPE_PARMS; - alias MCI_WAVE_OPEN_PARMSA MCI_WAVE_OPEN_PARMS; - alias MCI_ANIM_OPEN_PARMSA MCI_ANIM_OPEN_PARMS; - alias MCI_ANIM_WINDOW_PARMSA MCI_ANIM_WINDOW_PARMS; - alias MCI_OVLY_OPEN_PARMSA MCI_OVLY_OPEN_PARMS; - alias MCI_OVLY_WINDOW_PARMSA MCI_OVLY_WINDOW_PARMS; - alias MCI_OVLY_SAVE_PARMSA MCI_OVLY_SAVE_PARMS; - - alias sndPlaySoundA sndPlaySound; - alias PlaySoundA PlaySound; - alias waveOutGetDevCapsA waveOutGetDevCaps; - alias waveOutGetErrorTextA waveOutGetErrorText; - alias waveInGetDevCapsA waveInGetDevCaps; - alias waveInGetErrorTextA waveInGetErrorText; - alias midiOutGetDevCapsA midiOutGetDevCaps; - alias midiOutGetErrorTextA midiOutGetErrorText; - alias midiInGetDevCapsA midiInGetDevCaps; - alias midiInGetErrorTextA midiInGetErrorText; - alias auxGetDevCapsA auxGetDevCaps; - alias mixerGetDevCapsA mixerGetDevCaps; - alias mixerGetLineInfoA mixerGetLineInfo; - alias mixerGetLineControlsA mixerGetLineControls; - alias mixerGetControlDetailsA mixerGetControlDetails; - alias joyGetDevCapsA joyGetDevCaps; - alias mmioInstallIOProcA mmioInstallIOProc; - alias mmioStringToFOURCCA mmioStringToFOURCC; - alias mmioOpenA mmioOpen; - alias mmioRenameA mmioRename; - alias mciSendCommandA mciSendCommand; - alias mciSendStringA mciSendString; - alias mciGetDeviceIDA mciGetDeviceID; - alias mciGetDeviceIDFromElementIDA mciGetDeviceIDFromElementID; - alias mciGetErrorStringA mciGetErrorString; -} - -alias WAVEOUTCAPS* PWAVEOUTCAPS, LPWAVEOUTCAPS; -alias WAVEINCAPS* PWAVEINCAPS, LPWAVEINCAPS; -alias MIDIOUTCAPS* PMIDIOUTCAPS, LPMIDIOUTCAPS; -alias MIDIINCAPS* PMIDIINCAPS, LPMIDIINCAPS; -alias AUXCAPS* PAUXCAPS, LPAUXCAPS; -alias MIXERCAPS* PMIXERCAPS, LPMIXERCAPS; -alias MIXERLINE* PMIXERLINE, LPMIXERLINE; -alias MIXERCONTROL* PMIXERCONTROL, LPMIXERCONTROL; -alias MIXERLINECONTROLS* PMIXERLINECONTROLS, LPMIXERLINECONTROLS; -alias MIXERCONTROLDETAILS_LISTTEXT* PMIXERCONTROLDETAILS_LISTTEXT, LPMIXERCONTROLDETAILS_LISTTEXT; -alias JOYCAPS* PJOYCAPS, LPJOYCAPS; -alias MCI_OPEN_PARMS* PMCI_OPEN_PARMS, LPMCI_OPEN_PARMS; -alias MCI_INFO_PARMS* LPMCI_INFO_PARMS; -alias MCI_SYSINFO_PARMS* PMCI_SYSINFO_PARMS, LPMCI_SYSINFO_PARMS; -alias MCI_SAVE_PARMS* PMCI_SAVE_PARMS, LPMCI_SAVE_PARMS; -alias MCI_LOAD_PARMS* PMCI_LOAD_PARMS, LPMCI_LOAD_PARMS; -alias MCI_VD_ESCAPE_PARMS* PMCI_VD_ESCAPE_PARMS, LPMCI_VD_ESCAPE_PARMS; -alias MCI_WAVE_OPEN_PARMS* PMCI_WAVE_OPEN_PARMS, LPMCI_WAVE_OPEN_PARMS; -alias MCI_ANIM_OPEN_PARMS* PMCI_ANIM_OPEN_PARMS, LPMCI_ANIM_OPEN_PARMS; -alias MCI_ANIM_WINDOW_PARMS* PMCI_ANIM_WINDOW_PARMS, LPMCI_ANIM_WINDOW_PARMS; -alias MCI_OVLY_OPEN_PARMS* PMCI_OVLY_OPEN_PARMS, LPMCI_OVLY_OPEN_PARMS; -alias MCI_OVLY_WINDOW_PARMS* PMCI_OVLY_WINDOW_PARMS, LPMCI_OVLY_WINDOW_PARMS; -alias MCI_OVLY_SAVE_PARMS* PMCI_OVLY_SAVE_PARMS, LPMCI_OVLY_SAVE_PARMS; + alias WAVEOUTCAPS = WAVEOUTCAPSA; + alias WAVEINCAPS = WAVEINCAPSA; + alias MIDIOUTCAPS = MIDIOUTCAPSA; + alias MIDIINCAPS = MIDIINCAPSA; + alias AUXCAPS = AUXCAPSA; + alias MIXERCAPS = MIXERCAPSA; + alias MIXERLINE = MIXERLINEA; + alias MIXERCONTROL = MIXERCONTROLA; + alias MIXERLINECONTROLS = MIXERLINECONTROLSA; + alias MIXERCONTROLDETAILS_LISTTEXT = MIXERCONTROLDETAILS_LISTTEXTA; + alias JOYCAPS = JOYCAPSA; + alias MCI_OPEN_PARMS = MCI_OPEN_PARMSA; + alias MCI_INFO_PARMS = MCI_INFO_PARMSA; + alias MCI_SYSINFO_PARMS = MCI_SYSINFO_PARMSA; + alias MCI_SAVE_PARMS = MCI_SAVE_PARMSA; + alias MCI_LOAD_PARMS = MCI_LOAD_PARMSA; + alias MCI_VD_ESCAPE_PARMS = MCI_VD_ESCAPE_PARMSA; + alias MCI_WAVE_OPEN_PARMS = MCI_WAVE_OPEN_PARMSA; + alias MCI_ANIM_OPEN_PARMS = MCI_ANIM_OPEN_PARMSA; + alias MCI_ANIM_WINDOW_PARMS = MCI_ANIM_WINDOW_PARMSA; + alias MCI_OVLY_OPEN_PARMS = MCI_OVLY_OPEN_PARMSA; + alias MCI_OVLY_WINDOW_PARMS = MCI_OVLY_WINDOW_PARMSA; + alias MCI_OVLY_SAVE_PARMS = MCI_OVLY_SAVE_PARMSA; + + alias sndPlaySound = sndPlaySoundA; + alias PlaySound = PlaySoundA; + alias waveOutGetDevCaps = waveOutGetDevCapsA; + alias waveOutGetErrorText = waveOutGetErrorTextA; + alias waveInGetDevCaps = waveInGetDevCapsA; + alias waveInGetErrorText = waveInGetErrorTextA; + alias midiOutGetDevCaps = midiOutGetDevCapsA; + alias midiOutGetErrorText = midiOutGetErrorTextA; + alias midiInGetDevCaps = midiInGetDevCapsA; + alias midiInGetErrorText = midiInGetErrorTextA; + alias auxGetDevCaps = auxGetDevCapsA; + alias mixerGetDevCaps = mixerGetDevCapsA; + alias mixerGetLineInfo = mixerGetLineInfoA; + alias mixerGetLineControls = mixerGetLineControlsA; + alias mixerGetControlDetails = mixerGetControlDetailsA; + alias joyGetDevCaps = joyGetDevCapsA; + alias mmioInstallIOProc = mmioInstallIOProcA; + alias mmioStringToFOURCC = mmioStringToFOURCCA; + alias mmioOpen = mmioOpenA; + alias mmioRename = mmioRenameA; + alias mciSendCommand = mciSendCommandA; + alias mciSendString = mciSendStringA; + alias mciGetDeviceID = mciGetDeviceIDA; + alias mciGetDeviceIDFromElementID = mciGetDeviceIDFromElementIDA; + alias mciGetErrorString = mciGetErrorStringA; +} + +alias PWAVEOUTCAPS = WAVEOUTCAPS*, LPWAVEOUTCAPS = WAVEOUTCAPS*; +alias PWAVEINCAPS = WAVEINCAPS*, LPWAVEINCAPS = WAVEINCAPS*; +alias PMIDIOUTCAPS = MIDIOUTCAPS*, LPMIDIOUTCAPS = MIDIOUTCAPS*; +alias PMIDIINCAPS = MIDIINCAPS*, LPMIDIINCAPS = MIDIINCAPS*; +alias PAUXCAPS = AUXCAPS*, LPAUXCAPS = AUXCAPS*; +alias PMIXERCAPS = MIXERCAPS*, LPMIXERCAPS = MIXERCAPS*; +alias PMIXERLINE = MIXERLINE*, LPMIXERLINE = MIXERLINE*; +alias PMIXERCONTROL = MIXERCONTROL*, LPMIXERCONTROL = MIXERCONTROL*; +alias PMIXERLINECONTROLS = MIXERLINECONTROLS*, LPMIXERLINECONTROLS = MIXERLINECONTROLS*; +alias PMIXERCONTROLDETAILS_LISTTEXT = MIXERCONTROLDETAILS_LISTTEXT*, LPMIXERCONTROLDETAILS_LISTTEXT = MIXERCONTROLDETAILS_LISTTEXT*; +alias PJOYCAPS = JOYCAPS*, LPJOYCAPS = JOYCAPS*; +alias PMCI_OPEN_PARMS = MCI_OPEN_PARMS*, LPMCI_OPEN_PARMS = MCI_OPEN_PARMS*; +alias LPMCI_INFO_PARMS = MCI_INFO_PARMS*; +alias PMCI_SYSINFO_PARMS = MCI_SYSINFO_PARMS*, LPMCI_SYSINFO_PARMS = MCI_SYSINFO_PARMS*; +alias PMCI_SAVE_PARMS = MCI_SAVE_PARMS*, LPMCI_SAVE_PARMS = MCI_SAVE_PARMS*; +alias PMCI_LOAD_PARMS = MCI_LOAD_PARMS*, LPMCI_LOAD_PARMS = MCI_LOAD_PARMS*; +alias PMCI_VD_ESCAPE_PARMS = MCI_VD_ESCAPE_PARMS*, LPMCI_VD_ESCAPE_PARMS = MCI_VD_ESCAPE_PARMS*; +alias PMCI_WAVE_OPEN_PARMS = MCI_WAVE_OPEN_PARMS*, LPMCI_WAVE_OPEN_PARMS = MCI_WAVE_OPEN_PARMS*; +alias PMCI_ANIM_OPEN_PARMS = MCI_ANIM_OPEN_PARMS*, LPMCI_ANIM_OPEN_PARMS = MCI_ANIM_OPEN_PARMS*; +alias PMCI_ANIM_WINDOW_PARMS = MCI_ANIM_WINDOW_PARMS*, LPMCI_ANIM_WINDOW_PARMS = MCI_ANIM_WINDOW_PARMS*; +alias PMCI_OVLY_OPEN_PARMS = MCI_OVLY_OPEN_PARMS*, LPMCI_OVLY_OPEN_PARMS = MCI_OVLY_OPEN_PARMS*; +alias PMCI_OVLY_WINDOW_PARMS = MCI_OVLY_WINDOW_PARMS*, LPMCI_OVLY_WINDOW_PARMS = MCI_OVLY_WINDOW_PARMS*; +alias PMCI_OVLY_SAVE_PARMS = MCI_OVLY_SAVE_PARMS*, LPMCI_OVLY_SAVE_PARMS = MCI_OVLY_SAVE_PARMS*; diff --git a/runtime/druntime/src/core/sys/windows/msacm.d b/runtime/druntime/src/core/sys/windows/msacm.d index df4d6c4fc9..18936b7d4b 100644 --- a/runtime/druntime/src/core/sys/windows/msacm.d +++ b/runtime/druntime/src/core/sys/windows/msacm.d @@ -16,7 +16,7 @@ import core.sys.windows.basetsd, core.sys.windows.mmsystem, core.sys.windows.win alias HACMDRIVERID = HANDLE; alias HACMDRIVER = HANDLE; -alias HACMDRIVER* LPHACMDRIVER; +alias LPHACMDRIVER = HACMDRIVER*; enum size_t ACMDRIVERDETAILS_SHORTNAME_CHARS = 32, @@ -40,7 +40,7 @@ struct ACMFORMATDETAILSA { DWORD cbwfx; char[ACMFORMATDETAILS_FORMAT_CHARS] szFormat = 0; } -alias ACMFORMATDETAILSA* LPACMFORMATDETAILSA; +alias LPACMFORMATDETAILSA = ACMFORMATDETAILSA*; struct ACMFORMATDETAILSW { DWORD cbStruct = ACMFORMATDETAILSW.sizeof; @@ -51,7 +51,7 @@ struct ACMFORMATDETAILSW { DWORD cbwfx; WCHAR[ACMFORMATDETAILS_FORMAT_CHARS] szFormat = 0; } -alias ACMFORMATDETAILSW* LPACMFORMATDETAILSW; +alias LPACMFORMATDETAILSW = ACMFORMATDETAILSW*; struct ACMFORMATTAGDETAILSA { DWORD cbStruct = ACMFORMATTAGDETAILSA.sizeof; @@ -62,7 +62,7 @@ struct ACMFORMATTAGDETAILSA { DWORD cStandardFormats; char[ACMFORMATTAGDETAILS_FORMATTAG_CHARS] szFormatTag = 0; } -alias ACMFORMATTAGDETAILSA* LPACMFORMATTAGDETAILSA; +alias LPACMFORMATTAGDETAILSA = ACMFORMATTAGDETAILSA*; struct ACMFORMATTAGDETAILSW { DWORD cbStruct = ACMFORMATTAGDETAILSW.sizeof; @@ -73,7 +73,7 @@ struct ACMFORMATTAGDETAILSW { DWORD cStandardFormats; WCHAR[ACMFORMATTAGDETAILS_FORMATTAG_CHARS] szFormatTag = 0; } -alias ACMFORMATTAGDETAILSW* LPACMFORMATTAGDETAILSW; +alias LPACMFORMATTAGDETAILSW = ACMFORMATTAGDETAILSW*; struct ACMDRIVERDETAILSA { align(1): @@ -94,7 +94,7 @@ align(1): char[ACMDRIVERDETAILS_LICENSING_CHARS] szLicensing = 0; char[ACMDRIVERDETAILS_FEATURES_CHARS] szFeatures = 0; } -alias ACMDRIVERDETAILSA* LPACMDRIVERDETAILSA; +alias LPACMDRIVERDETAILSA = ACMDRIVERDETAILSA*; struct ACMDRIVERDETAILSW { align(1): @@ -115,19 +115,19 @@ align(1): WCHAR[ACMDRIVERDETAILS_LICENSING_CHARS] szLicensing = 0; WCHAR[ACMDRIVERDETAILS_FEATURES_CHARS] szFeatures = 0; } -alias ACMDRIVERDETAILSW* LPACMDRIVERDETAILSW; +alias LPACMDRIVERDETAILSW = ACMDRIVERDETAILSW*; extern (Windows) { - alias BOOL function(HACMDRIVERID hadid, LPACMFORMATDETAILSA pafd, - DWORD_PTR dwInstance, DWORD fdwSupport) ACMFORMATENUMCBA; - alias BOOL function(HACMDRIVERID hadid, LPACMFORMATDETAILSW pafd, - DWORD_PTR dwInstance, DWORD fdwSupport) ACMFORMATENUMCBW; - alias BOOL function(HACMDRIVERID hadid, LPACMFORMATTAGDETAILSA paftd, - DWORD_PTR dwInstance, DWORD fdwSupport) ACMFORMATTAGENUMCBA; - alias BOOL function(HACMDRIVERID hadid, LPACMFORMATTAGDETAILSW paftd, - DWORD_PTR dwInstance, DWORD fdwSupport) ACMFORMATTAGENUMCBW; - alias BOOL function(HACMDRIVERID hadid, DWORD_PTR dwInstance, - DWORD fdwSupport) ACMDRIVERENUMCB; + alias ACMFORMATENUMCBA = BOOL function(HACMDRIVERID hadid, LPACMFORMATDETAILSA pafd, + DWORD_PTR dwInstance, DWORD fdwSupport); + alias ACMFORMATENUMCBW = BOOL function(HACMDRIVERID hadid, LPACMFORMATDETAILSW pafd, + DWORD_PTR dwInstance, DWORD fdwSupport); + alias ACMFORMATTAGENUMCBA = BOOL function(HACMDRIVERID hadid, LPACMFORMATTAGDETAILSA paftd, + DWORD_PTR dwInstance, DWORD fdwSupport); + alias ACMFORMATTAGENUMCBW = BOOL function(HACMDRIVERID hadid, LPACMFORMATTAGDETAILSW paftd, + DWORD_PTR dwInstance, DWORD fdwSupport); + alias ACMDRIVERENUMCB = BOOL function(HACMDRIVERID hadid, DWORD_PTR dwInstance, + DWORD fdwSupport); MMRESULT acmDriverOpen(LPHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen); @@ -149,25 +149,25 @@ extern (Windows) { } version (Unicode) { - alias ACMFORMATDETAILSW ACMFORMATDETAILS; - alias ACMFORMATTAGDETAILSW ACMFORMATTAGDETAILS; - alias ACMDRIVERDETAILSW ACMDRIVERDETAILS; - alias ACMFORMATENUMCBW ACMFORMATENUMCB; - alias ACMFORMATTAGENUMCBW ACMFORMATTAGENUMCB; - alias acmFormatEnumW acmFormatEnum; - alias acmDriverDetailsW acmDriverDetails; - alias acmFormatTagEnumW acmFormatTagEnum; + alias ACMFORMATDETAILS = ACMFORMATDETAILSW; + alias ACMFORMATTAGDETAILS = ACMFORMATTAGDETAILSW; + alias ACMDRIVERDETAILS = ACMDRIVERDETAILSW; + alias ACMFORMATENUMCB = ACMFORMATENUMCBW; + alias ACMFORMATTAGENUMCB = ACMFORMATTAGENUMCBW; + alias acmFormatEnum = acmFormatEnumW; + alias acmDriverDetails = acmDriverDetailsW; + alias acmFormatTagEnum = acmFormatTagEnumW; } else { - alias ACMFORMATDETAILSA ACMFORMATDETAILS; - alias ACMFORMATTAGDETAILSA ACMFORMATTAGDETAILS; - alias ACMDRIVERDETAILSA ACMDRIVERDETAILS; - alias ACMFORMATENUMCBA ACMFORMATENUMCB; - alias ACMFORMATTAGENUMCBA ACMFORMATTAGENUMCB; - alias acmFormatEnumA acmFormatEnum; - alias acmDriverDetailsA acmDriverDetails; - alias acmFormatTagEnumA acmFormatTagEnum; + alias ACMFORMATDETAILS = ACMFORMATDETAILSA; + alias ACMFORMATTAGDETAILS = ACMFORMATTAGDETAILSA; + alias ACMDRIVERDETAILS = ACMDRIVERDETAILSA; + alias ACMFORMATENUMCB = ACMFORMATENUMCBA; + alias ACMFORMATTAGENUMCB = ACMFORMATTAGENUMCBA; + alias acmFormatEnum = acmFormatEnumA; + alias acmDriverDetails = acmDriverDetailsA; + alias acmFormatTagEnum = acmFormatTagEnumA; } -alias ACMFORMATDETAILS* LPACMFORMATDETAILS; -alias ACMFORMATTAGDETAILS* LPACMFORMATTAGDETAILS; -alias ACMDRIVERDETAILS* LPACMDRIVERDETAILS; +alias LPACMFORMATDETAILS = ACMFORMATDETAILS*; +alias LPACMFORMATTAGDETAILS = ACMFORMATTAGDETAILS*; +alias LPACMDRIVERDETAILS = ACMDRIVERDETAILS*; diff --git a/runtime/druntime/src/core/sys/windows/mshtml.d b/runtime/druntime/src/core/sys/windows/mshtml.d index d20c4bbb30..033e459ca8 100644 --- a/runtime/druntime/src/core/sys/windows/mshtml.d +++ b/runtime/druntime/src/core/sys/windows/mshtml.d @@ -14,34 +14,34 @@ import core.sys.windows.basetyps, core.sys.windows.oaidl, core.sys.windows.unknw // These are used in this file, but not defined in MinGW. interface IHTMLStyleSheet {} -alias IHTMLStyle LPHTMLSTYLE; -alias IHTMLStyleSheet LPHTMLSTYLESHEET; +alias LPHTMLSTYLE = IHTMLStyle; +alias LPHTMLSTYLESHEET = IHTMLStyleSheet; interface IHTMLLocation {} -alias IHTMLLocation LPHTMLLOCATION; +alias LPHTMLLOCATION = IHTMLLocation; interface IHTMLFramesCollection {} -alias IHTMLFramesCollection LPHTMLFRAMESCOLLECTION; +alias LPHTMLFRAMESCOLLECTION = IHTMLFramesCollection; interface IHTMLStyleSheetsCollection {} -alias IHTMLStyleSheetsCollection LPHTMLSTYLESHEETSCOLLECTION; +alias LPHTMLSTYLESHEETSCOLLECTION = IHTMLStyleSheetsCollection; interface IHTMLStyle {} interface IHTMLFiltersCollection {} -alias IHTMLFiltersCollection LPHTMLFILTERSCOLLECTION; +alias LPHTMLFILTERSCOLLECTION = IHTMLFiltersCollection; interface IOmHistory : IDispatch { HRESULT get_length(short* p); HRESULT back(VARIANT*); HRESULT forward(VARIANT*); HRESULT go(VARIANT*); } -alias IOmHistory LPOMHISTORY; +alias LPOMHISTORY = IOmHistory; interface IOmNavigator {} -alias IOmNavigator LPOMNAVIGATOR; +alias LPOMNAVIGATOR = IOmNavigator; interface IHTMLImageElementFactory {} -alias IHTMLImageElementFactory LPHTMLIMAGEELEMENTFACTORY; +alias LPHTMLIMAGEELEMENTFACTORY = IHTMLImageElementFactory; interface IHTMLEventObj {} -alias IHTMLEventObj LPHTMLEVENTOBJ; +alias LPHTMLEVENTOBJ = IHTMLEventObj; interface IHTMLScreen {} -alias IHTMLScreen LPHTMLSCREEN; +alias LPHTMLSCREEN = IHTMLScreen; interface IHTMLOptionElementFactory {} -alias IHTMLOptionElementFactory LPHTMLOPTIONELEMENTFACTORY; +alias LPHTMLOPTIONELEMENTFACTORY = IHTMLOptionElementFactory; interface IHTMLLinkElement : IDispatch { HRESULT put_href(BSTR); @@ -65,7 +65,7 @@ interface IHTMLLinkElement : IDispatch { HRESULT put_media(BSTR); HRESULT get_media(BSTR*); } -alias IHTMLLinkElement LPHTMLLINKELEMENT; +alias LPHTMLLINKELEMENT = IHTMLLinkElement; interface IHTMLImgElement : IDispatch { HRESULT put_isMap(VARIANT_BOOL); @@ -117,7 +117,7 @@ interface IHTMLImgElement : IDispatch { HRESULT put_start(BSTR); HRESULT get_start(BSTR*); } -alias IHTMLImgElement LPHTMLIMGELEMENT; +alias LPHTMLIMGELEMENT = IHTMLImgElement; interface IHTMLElementCollection : IDispatch { HRESULT toString(BSTR*); @@ -127,7 +127,7 @@ interface IHTMLElementCollection : IDispatch { HRESULT item(VARIANT,VARIANT,IDispatch* pDisp); HRESULT tags(VARIANT,IDispatch* pdisp); } -alias IHTMLElementCollection LPHTMLELEMENTCOLLECTION; +alias LPHTMLELEMENTCOLLECTION = IHTMLElementCollection; interface IHTMLDocument : IDispatch { HRESULT get_Script(IDispatch*); @@ -250,7 +250,7 @@ interface IHTMLSelectionObject : IDispatch { HRESULT clear(); HRESULT get_type(BSTR*); } -alias IHTMLSelectionObject LPHTMLSELECTIONOBJECT; +alias LPHTMLSELECTIONOBJECT = IHTMLSelectionObject; interface IHTMLTxtRange : IDispatch { HRESULT get_htmlText(BSTR*); @@ -374,7 +374,7 @@ interface IHTMLElement : IDispatch { HRESULT get_children(IDispatch*); HRESULT get_all(IDispatch*); } -alias IHTMLElement LPHTMLELEMENT; +alias LPHTMLELEMENT = IHTMLElement; interface IHTMLFramesCollection2 : IDispatch { HRESULT item(VARIANT*,VARIANT*); @@ -451,7 +451,7 @@ interface IHTMLWindow2 : IHTMLFramesCollection2 { HRESULT resizeBy(LONG,LONG); HRESULT get_external(IDispatch*); } -alias IHTMLWindow2 LPHTMLWINDOW2; +alias LPHTMLWINDOW2 = IHTMLWindow2; interface IHTMLFrameBase : IDispatch { HRESULT put_src(BSTR); diff --git a/runtime/druntime/src/core/sys/windows/mswsock.d b/runtime/druntime/src/core/sys/windows/mswsock.d index d8beee421a..0cefbf4064 100644 --- a/runtime/druntime/src/core/sys/windows/mswsock.d +++ b/runtime/druntime/src/core/sys/windows/mswsock.d @@ -82,7 +82,7 @@ struct TRANSMIT_FILE_BUFFERS { PVOID Tail; DWORD TailLength; } -alias TRANSMIT_FILE_BUFFERS* PTRANSMIT_FILE_BUFFERS, LPTRANSMIT_FILE_BUFFERS; +alias PTRANSMIT_FILE_BUFFERS = TRANSMIT_FILE_BUFFERS*, LPTRANSMIT_FILE_BUFFERS = TRANSMIT_FILE_BUFFERS*; extern(Windows) { /* Win95+, WinNT3.51+ @@ -99,10 +99,10 @@ extern(Windows) { /* WinNT3.51+ ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/acceptex_2.htm */ - alias BOOL function(SOCKET, SOCKET, PVOID, DWORD, DWORD, DWORD, LPDWORD, LPOVERLAPPED) LPFN_ACCEPTEX; + alias LPFN_ACCEPTEX = BOOL function(SOCKET, SOCKET, PVOID, DWORD, DWORD, DWORD, LPDWORD, LPOVERLAPPED); const GUID WSAID_ACCEPTEX = {0xb5367df1,0xcbac,0x11cf,[0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92]}; - alias BOOL function(SOCKET, SOCKADDR*, int, PVOID, DWORD, LPDWORD, LPOVERLAPPED) LPFN_CONNECTEX; + alias LPFN_CONNECTEX = BOOL function(SOCKET, SOCKADDR*, int, PVOID, DWORD, LPDWORD, LPOVERLAPPED); const GUID WSAID_CONNECTEX = {0x25a207b9,0xddf3,0x4660,[0x8e,0xe9,0x76,0xe5,0x8c,0x74,0x06,0x3e]}; } @@ -136,7 +136,7 @@ static if (_WIN32_WINNT >= 0x501) { CHAR* buf; } - alias WSABUF* LPWSABUF; + alias LPWSABUF = WSABUF*; /* WinXP+, Server2003+: * ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/wsamsg_2.htm @@ -150,7 +150,7 @@ static if (_WIN32_WINNT >= 0x501) { DWORD dwFlags; } - alias WSAMSG* PWSAMSG, LPWSAMSG; + alias PWSAMSG = WSAMSG*, LPWSAMSG = WSAMSG*; /* According to MSDN docs, the WSAMSG.Control buffer starts with a cmsghdr header of the following form. See also RFC 2292. */ diff --git a/runtime/druntime/src/core/sys/windows/nb30.d b/runtime/druntime/src/core/sys/windows/nb30.d index cfa57d609e..746bf0cfe2 100644 --- a/runtime/druntime/src/core/sys/windows/nb30.d +++ b/runtime/druntime/src/core/sys/windows/nb30.d @@ -125,7 +125,7 @@ struct ACTION_HEADER { USHORT action_code; USHORT reserved; } -alias ACTION_HEADER* PACTION_HEADER; +alias PACTION_HEADER = ACTION_HEADER*; struct ADAPTER_STATUS { UCHAR[6] adapter_address; @@ -156,7 +156,7 @@ struct ADAPTER_STATUS { WORD max_sess_pkt_size; WORD name_count; } -alias ADAPTER_STATUS* PADAPTER_STATUS; +alias PADAPTER_STATUS = ADAPTER_STATUS*; struct FIND_NAME_BUFFER { /* From Win32 API docs @@ -175,27 +175,27 @@ struct FIND_NAME_BUFFER { UCHAR[6] source_addr; UCHAR[18] routing_info; } -alias FIND_NAME_BUFFER* PFIND_NAME_BUFFER; +alias PFIND_NAME_BUFFER = FIND_NAME_BUFFER*; struct FIND_NAME_HEADER { WORD node_count; UCHAR reserved; UCHAR unique_group; } -alias FIND_NAME_HEADER* PFIND_NAME_HEADER; +alias PFIND_NAME_HEADER = FIND_NAME_HEADER*; struct LANA_ENUM { UCHAR length; UCHAR[MAX_LANA+1] lana; } -alias LANA_ENUM* PLANA_ENUM; +alias PLANA_ENUM = LANA_ENUM*; struct NAME_BUFFER { UCHAR[NCBNAMSZ] name; UCHAR name_num; UCHAR name_flags; } -alias NAME_BUFFER* PNAME_BUFFER; +alias PNAME_BUFFER = NAME_BUFFER*; struct NCB { UCHAR ncb_command; @@ -217,7 +217,7 @@ struct NCB { UCHAR[10] ncb_reserve; HANDLE ncb_event; } -alias NCB* PNCB; +alias PNCB = NCB*; struct SESSION_BUFFER { UCHAR lsn; @@ -227,7 +227,7 @@ struct SESSION_BUFFER { UCHAR rcvs_outstanding; UCHAR sends_outstanding; } -alias SESSION_BUFFER* PSESSION_BUFFER; +alias PSESSION_BUFFER = SESSION_BUFFER*; struct SESSION_HEADER { UCHAR sess_name; @@ -235,6 +235,6 @@ struct SESSION_HEADER { UCHAR rcv_dg_outstanding; UCHAR rcv_any_outstanding; } -alias SESSION_HEADER* PSESSION_HEADER; +alias PSESSION_HEADER = SESSION_HEADER*; extern (Windows) UCHAR Netbios(PNCB); diff --git a/runtime/druntime/src/core/sys/windows/nddeapi.d b/runtime/druntime/src/core/sys/windows/nddeapi.d index 3efca620e1..80d8fc7b9c 100644 --- a/runtime/druntime/src/core/sys/windows/nddeapi.d +++ b/runtime/druntime/src/core/sys/windows/nddeapi.d @@ -134,31 +134,31 @@ extern (Windows) { } version (Unicode) { - alias NDdeShareAddW NDdeShareAdd; - alias NDdeShareDelW NDdeShareDel; - alias NDdeSetShareSecurityW NDdeSetShareSecurity; - alias NDdeGetShareSecurityW NDdeGetShareSecurity; - alias NDdeShareEnumW NDdeShareEnum; - alias NDdeShareGetInfoW NDdeShareGetInfo; - alias NDdeShareSetInfoW NDdeShareSetInfo; - alias NDdeGetErrorStringW NDdeGetErrorString; - alias NDdeIsValidShareNameW NDdeIsValidShareName; - alias NDdeIsValidAppTopicListW NDdeIsValidAppTopicList; - alias NDdeSetTrustedShareW NDdeSetTrustedShare; - alias NDdeGetTrustedShareW NDdeGetTrustedShare; - alias NDdeTrustedShareEnumW NDdeTrustedShareEnum; + alias NDdeShareAdd = NDdeShareAddW; + alias NDdeShareDel = NDdeShareDelW; + alias NDdeSetShareSecurity = NDdeSetShareSecurityW; + alias NDdeGetShareSecurity = NDdeGetShareSecurityW; + alias NDdeShareEnum = NDdeShareEnumW; + alias NDdeShareGetInfo = NDdeShareGetInfoW; + alias NDdeShareSetInfo = NDdeShareSetInfoW; + alias NDdeGetErrorString = NDdeGetErrorStringW; + alias NDdeIsValidShareName = NDdeIsValidShareNameW; + alias NDdeIsValidAppTopicList = NDdeIsValidAppTopicListW; + alias NDdeSetTrustedShare = NDdeSetTrustedShareW; + alias NDdeGetTrustedShare = NDdeGetTrustedShareW; + alias NDdeTrustedShareEnum = NDdeTrustedShareEnumW; } else { - alias NDdeShareAddA NDdeShareAdd; - alias NDdeShareDelA NDdeShareDel; - alias NDdeSetShareSecurityA NDdeSetShareSecurity; - alias NDdeGetShareSecurityA NDdeGetShareSecurity; - alias NDdeShareEnumA NDdeShareEnum; - alias NDdeShareGetInfoA NDdeShareGetInfo; - alias NDdeShareSetInfoA NDdeShareSetInfo; - alias NDdeGetErrorStringA NDdeGetErrorString; - alias NDdeIsValidShareNameA NDdeIsValidShareName; - alias NDdeIsValidAppTopicListA NDdeIsValidAppTopicList; - alias NDdeSetTrustedShareA NDdeSetTrustedShare; - alias NDdeGetTrustedShareA NDdeGetTrustedShare; - alias NDdeTrustedShareEnumA NDdeTrustedShareEnum; + alias NDdeShareAdd = NDdeShareAddA; + alias NDdeShareDel = NDdeShareDelA; + alias NDdeSetShareSecurity = NDdeSetShareSecurityA; + alias NDdeGetShareSecurity = NDdeGetShareSecurityA; + alias NDdeShareEnum = NDdeShareEnumA; + alias NDdeShareGetInfo = NDdeShareGetInfoA; + alias NDdeShareSetInfo = NDdeShareSetInfoA; + alias NDdeGetErrorString = NDdeGetErrorStringA; + alias NDdeIsValidShareName = NDdeIsValidShareNameA; + alias NDdeIsValidAppTopicList = NDdeIsValidAppTopicListA; + alias NDdeSetTrustedShare = NDdeSetTrustedShareA; + alias NDdeGetTrustedShare = NDdeGetTrustedShareA; + alias NDdeTrustedShareEnum = NDdeTrustedShareEnumA; } diff --git a/runtime/druntime/src/core/sys/windows/nspapi.d b/runtime/druntime/src/core/sys/windows/nspapi.d index bac6526849..6253753381 100644 --- a/runtime/druntime/src/core/sys/windows/nspapi.d +++ b/runtime/druntime/src/core/sys/windows/nspapi.d @@ -55,7 +55,7 @@ struct SOCKET_ADDRESS { LPSOCKADDR lpSockaddr; INT iSockaddrLength; } -alias SOCKET_ADDRESS* PSOCKET_ADDRESS, LPSOCKET_ADDRESS; +alias PSOCKET_ADDRESS = SOCKET_ADDRESS*, LPSOCKET_ADDRESS = SOCKET_ADDRESS*; struct CSADDR_INFO { SOCKET_ADDRESS LocalAddr; @@ -63,13 +63,13 @@ struct CSADDR_INFO { INT iSocketType; INT iProtocol; } -alias CSADDR_INFO* PCSADDR_INFO, LPCSADDR_INFO; +alias PCSADDR_INFO = CSADDR_INFO*, LPCSADDR_INFO = CSADDR_INFO*; struct BLOB { ULONG cbSize; BYTE* pBlobData; } -alias BLOB* PBLOB, LPBLOB; +alias PBLOB = BLOB*, LPBLOB = BLOB*; struct SERVICE_ADDRESS { DWORD dwAddressType; @@ -86,7 +86,7 @@ struct SERVICE_ADDRESSES { SERVICE_ADDRESS* Addresses() return { return &_Addresses; } } -alias SERVICE_ADDRESSES* PSERVICE_ADDRESSES, LPSERVICE_ADDRESSES; +alias PSERVICE_ADDRESSES = SERVICE_ADDRESSES*, LPSERVICE_ADDRESSES = SERVICE_ADDRESSES*; struct SERVICE_INFOA { LPGUID lpServiceType; @@ -100,7 +100,7 @@ struct SERVICE_INFOA { LPSERVICE_ADDRESSES lpServiceAddress; BLOB ServiceSpecificInfo; } -alias SERVICE_INFOA* LPSERVICE_INFOA; +alias LPSERVICE_INFOA = SERVICE_INFOA*; struct SERVICE_INFOW { LPGUID lpServiceType; @@ -114,9 +114,9 @@ struct SERVICE_INFOW { LPSERVICE_ADDRESSES lpServiceAddress; BLOB ServiceSpecificInfo; } -alias SERVICE_INFOW* LPSERVICE_INFOW; +alias LPSERVICE_INFOW = SERVICE_INFOW*; -alias void* LPSERVICE_ASYNC_INFO; +alias LPSERVICE_ASYNC_INFO = void*; extern (Windows) { INT SetServiceA(DWORD, DWORD, DWORD, LPSERVICE_INFOA, @@ -130,14 +130,14 @@ extern (Windows) { } version (Unicode) { - alias SERVICE_INFOW SERVICE_INFO; - alias SetServiceW SetService; - alias GetAddressByNameW GetAddressByName; + alias SERVICE_INFO = SERVICE_INFOW; + alias SetService = SetServiceW; + alias GetAddressByName = GetAddressByNameW; } else { - alias SERVICE_INFOA SERVICE_INFO; - alias SetServiceA SetService; - alias GetAddressByNameA GetAddressByName; + alias SERVICE_INFO = SERVICE_INFOA; + alias SetService = SetServiceA; + alias GetAddressByName = GetAddressByNameA; } -alias SERVICE_INFO _SERVICE_INFO; -alias SERVICE_INFO* LPSERVICE_INFO; +alias _SERVICE_INFO = SERVICE_INFO; +alias LPSERVICE_INFO = SERVICE_INFO*; diff --git a/runtime/druntime/src/core/sys/windows/ntdef.d b/runtime/druntime/src/core/sys/windows/ntdef.d index e45d0effcd..e5da02295a 100644 --- a/runtime/druntime/src/core/sys/windows/ntdef.d +++ b/runtime/druntime/src/core/sys/windows/ntdef.d @@ -44,27 +44,27 @@ pragma(inline, true) @safe pure nothrow @nogc { * type aliases are defined in ntdef.h, ntsecapi.h and subauth.h, each of * which checks that none of the others is already included. */ -alias int NTSTATUS; -alias int* PNTSTATUS; +alias NTSTATUS = int; +alias PNTSTATUS = int*; struct UNICODE_STRING { USHORT Length; USHORT MaximumLength; PWSTR Buffer; } -alias UNICODE_STRING* PUNICODE_STRING; -alias const(UNICODE_STRING)* PCUNICODE_STRING; +alias PUNICODE_STRING = UNICODE_STRING*; +alias PCUNICODE_STRING = const(UNICODE_STRING)*; struct STRING { USHORT Length; USHORT MaximumLength; PCHAR Buffer; } -alias STRING ANSI_STRING, OEM_STRING; -alias STRING* PSTRING, PANSI_STRING, POEM_STRING; +alias ANSI_STRING = STRING, OEM_STRING = STRING; +alias PSTRING = STRING*, PANSI_STRING = STRING*, POEM_STRING = STRING*; -alias LARGE_INTEGER PHYSICAL_ADDRESS; -alias LARGE_INTEGER* PPHYSICAL_ADDRESS; +alias PHYSICAL_ADDRESS = LARGE_INTEGER; +alias PPHYSICAL_ADDRESS = LARGE_INTEGER*; enum SECTION_INHERIT { ViewShare = 1, @@ -82,4 +82,4 @@ struct OBJECT_ATTRIBUTES { PVOID SecurityDescriptor; PVOID SecurityQualityOfService; } -alias OBJECT_ATTRIBUTES* POBJECT_ATTRIBUTES; +alias POBJECT_ATTRIBUTES = OBJECT_ATTRIBUTES*; diff --git a/runtime/druntime/src/core/sys/windows/ntsecapi.d b/runtime/druntime/src/core/sys/windows/ntsecapi.d index 7088cb1020..8dd430a968 100644 --- a/runtime/druntime/src/core/sys/windows/ntsecapi.d +++ b/runtime/druntime/src/core/sys/windows/ntsecapi.d @@ -182,10 +182,10 @@ enum { TRUST_TYPE_DCE } -alias UNICODE_STRING LSA_UNICODE_STRING; -alias UNICODE_STRING* PLSA_UNICODE_STRING; -alias STRING LSA_STRING; -alias STRING* PLSA_STRING; +alias LSA_UNICODE_STRING = UNICODE_STRING; +alias PLSA_UNICODE_STRING = UNICODE_STRING*; +alias LSA_STRING = STRING; +alias PLSA_STRING = STRING*; enum MSV1_0_LOGON_SUBMIT_TYPE { MsV1_0InteractiveLogon = 2, @@ -194,14 +194,14 @@ enum MSV1_0_LOGON_SUBMIT_TYPE { MsV1_0SubAuthLogon, MsV1_0WorkstationUnlockLogon = 7 } -alias MSV1_0_LOGON_SUBMIT_TYPE* PMSV1_0_LOGON_SUBMIT_TYPE; +alias PMSV1_0_LOGON_SUBMIT_TYPE = MSV1_0_LOGON_SUBMIT_TYPE*; enum MSV1_0_PROFILE_BUFFER_TYPE { MsV1_0InteractiveProfile = 2, MsV1_0Lm20LogonProfile, MsV1_0SmartCardProfile } -alias MSV1_0_PROFILE_BUFFER_TYPE* PMSV1_0_PROFILE_BUFFER_TYPE; +alias PMSV1_0_PROFILE_BUFFER_TYPE = MSV1_0_PROFILE_BUFFER_TYPE*; enum MSV1_0_AVID { @@ -226,19 +226,19 @@ enum MSV1_0_PROTOCOL_MESSAGE_TYPE { MsV1_0DeriveCredential, MsV1_0CacheLookup } -alias MSV1_0_PROTOCOL_MESSAGE_TYPE* PMSV1_0_PROTOCOL_MESSAGE_TYPE; +alias PMSV1_0_PROTOCOL_MESSAGE_TYPE = MSV1_0_PROTOCOL_MESSAGE_TYPE*; enum POLICY_LSA_SERVER_ROLE { PolicyServerRoleBackup = 2, PolicyServerRolePrimary } -alias POLICY_LSA_SERVER_ROLE* PPOLICY_LSA_SERVER_ROLE; +alias PPOLICY_LSA_SERVER_ROLE = POLICY_LSA_SERVER_ROLE*; enum POLICY_SERVER_ENABLE_STATE { PolicyServerEnabled = 2, PolicyServerDisabled } -alias POLICY_SERVER_ENABLE_STATE* PPOLICY_SERVER_ENABLE_STATE; +alias PPOLICY_SERVER_ENABLE_STATE = POLICY_SERVER_ENABLE_STATE*; enum POLICY_INFORMATION_CLASS { PolicyAuditLogInformation = 1, @@ -255,7 +255,7 @@ enum POLICY_INFORMATION_CLASS { PolicyDnsDomainInformation, PolicyEfsInformation } -alias POLICY_INFORMATION_CLASS* PPOLICY_INFORMATION_CLASS; +alias PPOLICY_INFORMATION_CLASS = POLICY_INFORMATION_CLASS*; enum POLICY_AUDIT_EVENT_TYPE { AuditCategorySystem, @@ -268,7 +268,7 @@ enum POLICY_AUDIT_EVENT_TYPE { AuditCategoryDirectoryServiceAccess, AuditCategoryAccountLogon } -alias POLICY_AUDIT_EVENT_TYPE* PPOLICY_AUDIT_EVENT_TYPE; +alias PPOLICY_AUDIT_EVENT_TYPE = POLICY_AUDIT_EVENT_TYPE*; enum POLICY_LOCAL_INFORMATION_CLASS { PolicyLocalAuditEventsInformation = 1, @@ -285,7 +285,7 @@ enum POLICY_LOCAL_INFORMATION_CLASS { PolicyLocalQualityOfServiceInformation, PolicyLocalPolicyLocationInformation } -alias POLICY_LOCAL_INFORMATION_CLASS* PPOLICY_LOCAL_INFORMATION_CLASS; +alias PPOLICY_LOCAL_INFORMATION_CLASS = POLICY_LOCAL_INFORMATION_CLASS*; enum POLICY_DOMAIN_INFORMATION_CLASS { PolicyDomainIPSecReferenceInformation = 1, @@ -296,7 +296,7 @@ enum POLICY_DOMAIN_INFORMATION_CLASS { PolicyDomainLockoutInformation, PolicyDomainKerberosTicketInformation } -alias POLICY_DOMAIN_INFORMATION_CLASS* PPOLICY_DOMAIN_INFORMATION_CLASS; +alias PPOLICY_DOMAIN_INFORMATION_CLASS = POLICY_DOMAIN_INFORMATION_CLASS*; enum SECURITY_LOGON_TYPE { Interactive = 2, @@ -306,7 +306,7 @@ enum SECURITY_LOGON_TYPE { Proxy, Unlock } -alias SECURITY_LOGON_TYPE* PSECURITY_LOGON_TYPE; +alias PSECURITY_LOGON_TYPE = SECURITY_LOGON_TYPE*; enum TRUSTED_INFORMATION_CLASS { TrustedDomainNameInformation = 1, @@ -318,7 +318,7 @@ enum TRUSTED_INFORMATION_CLASS { TrustedDomainAuthInformation, TrustedDomainFullInformation } -alias TRUSTED_INFORMATION_CLASS* PTRUSTED_INFORMATION_CLASS; +alias PTRUSTED_INFORMATION_CLASS = TRUSTED_INFORMATION_CLASS*; struct DOMAIN_PASSWORD_INFORMATION { USHORT MinPasswordLength; @@ -327,47 +327,47 @@ struct DOMAIN_PASSWORD_INFORMATION { LARGE_INTEGER MaxPasswordAge; LARGE_INTEGER MinPasswordAge; } -alias DOMAIN_PASSWORD_INFORMATION* PDOMAIN_PASSWORD_INFORMATION; +alias PDOMAIN_PASSWORD_INFORMATION = DOMAIN_PASSWORD_INFORMATION*; struct LSA_ENUMERATION_INFORMATION { PSID Sid; } -alias LSA_ENUMERATION_INFORMATION* PLSA_ENUMERATION_INFORMATION; +alias PLSA_ENUMERATION_INFORMATION = LSA_ENUMERATION_INFORMATION*; -alias OBJECT_ATTRIBUTES LSA_OBJECT_ATTRIBUTES; -alias OBJECT_ATTRIBUTES* PLSA_OBJECT_ATTRIBUTES; +alias LSA_OBJECT_ATTRIBUTES = OBJECT_ATTRIBUTES; +alias PLSA_OBJECT_ATTRIBUTES = OBJECT_ATTRIBUTES*; struct LSA_TRUST_INFORMATION { LSA_UNICODE_STRING Name; PSID Sid; } -alias LSA_TRUST_INFORMATION TRUSTED_DOMAIN_INFORMATION_BASIC; -alias LSA_TRUST_INFORMATION* PLSA_TRUST_INFORMATION; +alias TRUSTED_DOMAIN_INFORMATION_BASIC = LSA_TRUST_INFORMATION; +alias PLSA_TRUST_INFORMATION = LSA_TRUST_INFORMATION*; /* in MinGW (further down the code): * typedef PLSA_TRUST_INFORMATION *PTRUSTED_DOMAIN_INFORMATION_BASIC; * but it doesn't look right.... */ -alias LSA_TRUST_INFORMATION** PTRUSTED_DOMAIN_INFORMATION_BASIC; +alias PTRUSTED_DOMAIN_INFORMATION_BASIC = LSA_TRUST_INFORMATION**; struct LSA_REFERENCED_DOMAIN_LIST { ULONG Entries; PLSA_TRUST_INFORMATION Domains; } -alias LSA_REFERENCED_DOMAIN_LIST* PLSA_REFERENCED_DOMAIN_LIST; +alias PLSA_REFERENCED_DOMAIN_LIST = LSA_REFERENCED_DOMAIN_LIST*; struct LSA_TRANSLATED_SID { SID_NAME_USE Use; ULONG RelativeId; LONG DomainIndex; } -alias LSA_TRANSLATED_SID* PLSA_TRANSLATED_SID; +alias PLSA_TRANSLATED_SID = LSA_TRANSLATED_SID*; struct LSA_TRANSLATED_NAME { SID_NAME_USE Use; LSA_UNICODE_STRING Name; LONG DomainIndex; } -alias LSA_TRANSLATED_NAME* PLSA_TRANSLATED_NAME; +alias PLSA_TRANSLATED_NAME = LSA_TRANSLATED_NAME*; struct MSV1_0_INTERACTIVE_LOGON { MSV1_0_LOGON_SUBMIT_TYPE MessageType; @@ -375,7 +375,7 @@ struct MSV1_0_INTERACTIVE_LOGON { UNICODE_STRING UserName; UNICODE_STRING Password; } -alias MSV1_0_INTERACTIVE_LOGON* PMSV1_0_INTERACTIVE_LOGON; +alias PMSV1_0_INTERACTIVE_LOGON = MSV1_0_INTERACTIVE_LOGON*; struct MSV1_0_INTERACTIVE_PROFILE { MSV1_0_PROFILE_BUFFER_TYPE MessageType; @@ -395,7 +395,7 @@ struct MSV1_0_INTERACTIVE_PROFILE { UNICODE_STRING LogonServer; ULONG UserFlags; } -alias MSV1_0_INTERACTIVE_PROFILE* PMSV1_0_INTERACTIVE_PROFILE; +alias PMSV1_0_INTERACTIVE_PROFILE = MSV1_0_INTERACTIVE_PROFILE*; struct MSV1_0_LM20_LOGON { MSV1_0_LOGON_SUBMIT_TYPE MessageType; @@ -407,7 +407,7 @@ struct MSV1_0_LM20_LOGON { STRING CaseInsensitiveChallengeResponse; ULONG ParameterControl; } -alias MSV1_0_LM20_LOGON* PMSV1_0_LM20_LOGON; +alias PMSV1_0_LM20_LOGON = MSV1_0_LM20_LOGON*; //static if (_WIN32_WINNT >= 0x500) { struct MSV1_0_SUBAUTH_LOGON { @@ -421,7 +421,7 @@ alias MSV1_0_LM20_LOGON* PMSV1_0_LM20_LOGON; ULONG ParameterControl; ULONG SubAuthPackageId; } - alias MSV1_0_SUBAUTH_LOGON* PMSV1_0_SUBAUTH_LOGON; + alias PMSV1_0_SUBAUTH_LOGON = MSV1_0_SUBAUTH_LOGON*; //} struct MSV1_0_LM20_LOGON_PROFILE { @@ -435,7 +435,7 @@ struct MSV1_0_LM20_LOGON_PROFILE { UNICODE_STRING LogonServer; UNICODE_STRING UserParameters; } -alias MSV1_0_LM20_LOGON_PROFILE* PMSV1_0_LM20_LOGON_PROFILE; +alias PMSV1_0_LM20_LOGON_PROFILE = MSV1_0_LM20_LOGON_PROFILE*; struct MSV1_0_SUPPLEMENTAL_CREDENTIAL { ULONG Version; @@ -443,7 +443,7 @@ struct MSV1_0_SUPPLEMENTAL_CREDENTIAL { UCHAR[MSV1_0_OWF_PASSWORD_LENGTH] LmPassword; UCHAR[MSV1_0_OWF_PASSWORD_LENGTH] NtPassword; } -alias MSV1_0_SUPPLEMENTAL_CREDENTIAL* PMSV1_0_SUPPLEMENTAL_CREDENTIAL; +alias PMSV1_0_SUPPLEMENTAL_CREDENTIAL = MSV1_0_SUPPLEMENTAL_CREDENTIAL*; struct MSV1_0_NTLM3_RESPONSE { UCHAR[MSV1_0_NTLM3_RESPONSE_LENGTH] Response; @@ -457,13 +457,13 @@ struct MSV1_0_NTLM3_RESPONSE { UCHAR _Buffer; UCHAR* Buffer() return { return &_Buffer; } } -alias MSV1_0_NTLM3_RESPONSE* PMSV1_0_NTLM3_RESPONSE; +alias PMSV1_0_NTLM3_RESPONSE = MSV1_0_NTLM3_RESPONSE*; struct MSV1_0_AV_PAIR { USHORT AvId; USHORT AvLen; } -alias MSV1_0_AV_PAIR* PMSV1_0_AV_PAIR; +alias PMSV1_0_AV_PAIR = MSV1_0_AV_PAIR*; struct MSV1_0_CHANGEPASSWORD_REQUEST { MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType; @@ -473,14 +473,14 @@ struct MSV1_0_CHANGEPASSWORD_REQUEST { UNICODE_STRING NewPassword; BOOLEAN Impersonating; } -alias MSV1_0_CHANGEPASSWORD_REQUEST* PMSV1_0_CHANGEPASSWORD_REQUEST; +alias PMSV1_0_CHANGEPASSWORD_REQUEST = MSV1_0_CHANGEPASSWORD_REQUEST*; struct MSV1_0_CHANGEPASSWORD_RESPONSE { MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType; BOOLEAN PasswordInfoValid; DOMAIN_PASSWORD_INFORMATION DomainPasswordInfo; } -alias MSV1_0_CHANGEPASSWORD_RESPONSE* PMSV1_0_CHANGEPASSWORD_RESPONSE; +alias PMSV1_0_CHANGEPASSWORD_RESPONSE = MSV1_0_CHANGEPASSWORD_RESPONSE*; struct MSV1_0_SUBAUTH_REQUEST { MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType; @@ -488,14 +488,14 @@ struct MSV1_0_SUBAUTH_REQUEST { ULONG SubAuthInfoLength; PUCHAR SubAuthSubmitBuffer; } -alias MSV1_0_SUBAUTH_REQUEST* PMSV1_0_SUBAUTH_REQUEST; +alias PMSV1_0_SUBAUTH_REQUEST = MSV1_0_SUBAUTH_REQUEST*; struct MSV1_0_SUBAUTH_RESPONSE { MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType; ULONG SubAuthInfoLength; PUCHAR SubAuthReturnBuffer; } -alias MSV1_0_SUBAUTH_RESPONSE* PMSV1_0_SUBAUTH_RESPONSE; +alias PMSV1_0_SUBAUTH_RESPONSE = MSV1_0_SUBAUTH_RESPONSE*; enum MSV1_0_DERIVECRED_TYPE_SHA1 = 0; @@ -507,7 +507,7 @@ struct MSV1_0_DERIVECRED_REQUEST { UCHAR _DeriveCredSubmitBuffer; UCHAR* DeriveCredSubmitBuffer() return { return &_DeriveCredSubmitBuffer; } } -alias MSV1_0_DERIVECRED_REQUEST* PMSV1_0_DERIVECRED_REQUEST; +alias PMSV1_0_DERIVECRED_REQUEST = MSV1_0_DERIVECRED_REQUEST*; struct MSV1_0_DERIVECRED_RESPONSE { MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType; @@ -515,18 +515,16 @@ struct MSV1_0_DERIVECRED_RESPONSE { UCHAR _DeriveCredReturnBuffer; UCHAR* DeriveCredReturnBuffer() return { return &_DeriveCredReturnBuffer; } } -alias MSV1_0_DERIVECRED_RESPONSE* PMSV1_0_DERIVECRED_RESPONSE; +alias PMSV1_0_DERIVECRED_RESPONSE = MSV1_0_DERIVECRED_RESPONSE*; -alias uint LSA_ENUMERATION_HANDLE, LSA_OPERATIONAL_MODE, - POLICY_AUDIT_EVENT_OPTIONS; -alias uint* PLSA_ENUMERATION_HANDLE, PLSA_OPERATIONAL_MODE, - PPOLICY_AUDIT_EVENT_OPTIONS; +alias LSA_ENUMERATION_HANDLE = uint, LSA_OPERATIONAL_MODE = uint, POLICY_AUDIT_EVENT_OPTIONS = uint; +alias PLSA_ENUMERATION_HANDLE = uint*, PLSA_OPERATIONAL_MODE = uint*, PPOLICY_AUDIT_EVENT_OPTIONS = uint*; struct POLICY_PRIVILEGE_DEFINITION { LSA_UNICODE_STRING Name; LUID LocalValue; } -alias POLICY_PRIVILEGE_DEFINITION* PPOLICY_PRIVILEGE_DEFINITION; +alias PPOLICY_PRIVILEGE_DEFINITION = POLICY_PRIVILEGE_DEFINITION*; struct POLICY_AUDIT_LOG_INFO { ULONG AuditLogPercentFull; @@ -536,26 +534,26 @@ struct POLICY_AUDIT_LOG_INFO { LARGE_INTEGER TimeToShutdown; ULONG NextAuditRecordId; } -alias POLICY_AUDIT_LOG_INFO* PPOLICY_AUDIT_LOG_INFO; +alias PPOLICY_AUDIT_LOG_INFO = POLICY_AUDIT_LOG_INFO*; struct POLICY_AUDIT_EVENTS_INFO { BOOLEAN AuditingMode; PPOLICY_AUDIT_EVENT_OPTIONS EventAuditingOptions; ULONG MaximumAuditEventCount; } -alias POLICY_AUDIT_EVENTS_INFO* PPOLICY_AUDIT_EVENTS_INFO; +alias PPOLICY_AUDIT_EVENTS_INFO = POLICY_AUDIT_EVENTS_INFO*; struct POLICY_ACCOUNT_DOMAIN_INFO { LSA_UNICODE_STRING DomainName; PSID DomainSid; } -alias POLICY_ACCOUNT_DOMAIN_INFO* PPOLICY_ACCOUNT_DOMAIN_INFO; +alias PPOLICY_ACCOUNT_DOMAIN_INFO = POLICY_ACCOUNT_DOMAIN_INFO*; struct POLICY_PRIMARY_DOMAIN_INFO { LSA_UNICODE_STRING Name; PSID Sid; } -alias POLICY_PRIMARY_DOMAIN_INFO* PPOLICY_PRIMARY_DOMAIN_INFO; +alias PPOLICY_PRIMARY_DOMAIN_INFO = POLICY_PRIMARY_DOMAIN_INFO*; struct POLICY_DNS_DOMAIN_INFO { LSA_UNICODE_STRING Name; @@ -564,88 +562,85 @@ struct POLICY_DNS_DOMAIN_INFO { GUID DomainGuid; PSID Sid; } -alias POLICY_DNS_DOMAIN_INFO* PPOLICY_DNS_DOMAIN_INFO; +alias PPOLICY_DNS_DOMAIN_INFO = POLICY_DNS_DOMAIN_INFO*; struct POLICY_PD_ACCOUNT_INFO { LSA_UNICODE_STRING Name; } -alias POLICY_PD_ACCOUNT_INFO* PPOLICY_PD_ACCOUNT_INFO; +alias PPOLICY_PD_ACCOUNT_INFO = POLICY_PD_ACCOUNT_INFO*; struct POLICY_LSA_SERVER_ROLE_INFO { POLICY_LSA_SERVER_ROLE LsaServerRole; } -alias POLICY_LSA_SERVER_ROLE_INFO* PPOLICY_LSA_SERVER_ROLE_INFO; +alias PPOLICY_LSA_SERVER_ROLE_INFO = POLICY_LSA_SERVER_ROLE_INFO*; struct POLICY_REPLICA_SOURCE_INFO { LSA_UNICODE_STRING ReplicaSource; LSA_UNICODE_STRING ReplicaAccountName; } -alias POLICY_REPLICA_SOURCE_INFO* PPOLICY_REPLICA_SOURCE_INFO; +alias PPOLICY_REPLICA_SOURCE_INFO = POLICY_REPLICA_SOURCE_INFO*; struct POLICY_DEFAULT_QUOTA_INFO { QUOTA_LIMITS QuotaLimits; } -alias POLICY_DEFAULT_QUOTA_INFO* PPOLICY_DEFAULT_QUOTA_INFO; +alias PPOLICY_DEFAULT_QUOTA_INFO = POLICY_DEFAULT_QUOTA_INFO*; struct POLICY_MODIFICATION_INFO { LARGE_INTEGER ModifiedId; LARGE_INTEGER DatabaseCreationTime; } -alias POLICY_MODIFICATION_INFO* PPOLICY_MODIFICATION_INFO; +alias PPOLICY_MODIFICATION_INFO = POLICY_MODIFICATION_INFO*; struct POLICY_AUDIT_FULL_SET_INFO { BOOLEAN ShutDownOnFull; } -alias POLICY_AUDIT_FULL_SET_INFO* PPOLICY_AUDIT_FULL_SET_INFO; +alias PPOLICY_AUDIT_FULL_SET_INFO = POLICY_AUDIT_FULL_SET_INFO*; struct POLICY_AUDIT_FULL_QUERY_INFO { BOOLEAN ShutDownOnFull; BOOLEAN LogIsFull; } -alias POLICY_AUDIT_FULL_QUERY_INFO* PPOLICY_AUDIT_FULL_QUERY_INFO; +alias PPOLICY_AUDIT_FULL_QUERY_INFO = POLICY_AUDIT_FULL_QUERY_INFO*; struct POLICY_EFS_INFO { ULONG InfoLength; PUCHAR EfsBlob; } -alias POLICY_EFS_INFO* PPOLICY_EFS_INFO; +alias PPOLICY_EFS_INFO = POLICY_EFS_INFO*; struct POLICY_LOCAL_IPSEC_REFERENCE_INFO { LSA_UNICODE_STRING ObjectPath; } -alias POLICY_LOCAL_IPSEC_REFERENCE_INFO* PPOLICY_LOCAL_IPSEC_REFERENCE_INFO; +alias PPOLICY_LOCAL_IPSEC_REFERENCE_INFO = POLICY_LOCAL_IPSEC_REFERENCE_INFO*; struct POLICY_LOCAL_MACHINE_PASSWORD_INFO { LARGE_INTEGER PasswordChangeInterval; } -alias POLICY_LOCAL_MACHINE_PASSWORD_INFO* PPOLICY_LOCAL_MACHINE_PASSWORD_INFO; +alias PPOLICY_LOCAL_MACHINE_PASSWORD_INFO = POLICY_LOCAL_MACHINE_PASSWORD_INFO*; struct POLICY_LOCAL_POLICY_LOCATION_INFO { ULONG PolicyLocation; } -alias POLICY_LOCAL_POLICY_LOCATION_INFO* PPOLICY_LOCAL_POLICY_LOCATION_INFO; +alias PPOLICY_LOCAL_POLICY_LOCATION_INFO = POLICY_LOCAL_POLICY_LOCATION_INFO*; struct POLICY_LOCAL_QUALITY_OF_SERVICE_INFO{ ULONG QualityOfService; } -alias POLICY_LOCAL_QUALITY_OF_SERVICE_INFO - POLICY_DOMAIN_QUALITY_OF_SERVICE_INFO; -alias POLICY_LOCAL_QUALITY_OF_SERVICE_INFO* - PPOLICY_LOCAL_QUALITY_OF_SERVICE_INFO, - PPOLICY_DOMAIN_QUALITY_OF_SERVICE_INFO; +alias POLICY_DOMAIN_QUALITY_OF_SERVICE_INFO = POLICY_LOCAL_QUALITY_OF_SERVICE_INFO; +alias PPOLICY_LOCAL_QUALITY_OF_SERVICE_INFO = POLICY_LOCAL_QUALITY_OF_SERVICE_INFO*, PPOLICY_DOMAIN_QUALITY_OF_SERVICE_INFO = POLICY_LOCAL_QUALITY_OF_SERVICE_INFO*; struct POLICY_DOMAIN_PUBLIC_KEY_INFO { ULONG InfoLength; PUCHAR PublicKeyInfo; } -alias POLICY_DOMAIN_PUBLIC_KEY_INFO* PPOLICY_DOMAIN_PUBLIC_KEY_INFO; +alias PPOLICY_DOMAIN_PUBLIC_KEY_INFO = POLICY_DOMAIN_PUBLIC_KEY_INFO*; struct POLICY_DOMAIN_LOCKOUT_INFO { LARGE_INTEGER LockoutDuration; LARGE_INTEGER LockoutObservationWindow; USHORT LockoutThreshold; } -alias POLICY_DOMAIN_LOCKOUT_INFO* PPOLICY_DOMAIN_LOCKOUT_INFO; +alias PPOLICY_DOMAIN_LOCKOUT_INFO = POLICY_DOMAIN_LOCKOUT_INFO*; struct POLICY_DOMAIN_PASSWORD_INFO { USHORT MinPasswordLength; @@ -654,7 +649,7 @@ struct POLICY_DOMAIN_PASSWORD_INFO { LARGE_INTEGER MaxPasswordAge; LARGE_INTEGER MinPasswordAge; } -alias POLICY_DOMAIN_PASSWORD_INFO* PPOLICY_DOMAIN_PASSWORD_INFO; +alias PPOLICY_DOMAIN_PASSWORD_INFO = POLICY_DOMAIN_PASSWORD_INFO*; struct POLICY_DOMAIN_KERBEROS_TICKET_INFO { ULONG AuthenticationOptions; @@ -664,32 +659,32 @@ struct POLICY_DOMAIN_KERBEROS_TICKET_INFO { LARGE_INTEGER ProxyLifetime; LARGE_INTEGER ForceLogoff; } -alias POLICY_DOMAIN_KERBEROS_TICKET_INFO* PPOLICY_DOMAIN_KERBEROS_TICKET_INFO; +alias PPOLICY_DOMAIN_KERBEROS_TICKET_INFO = POLICY_DOMAIN_KERBEROS_TICKET_INFO*; alias LSA_HANDLE = HANDLE; -alias LSA_HANDLE* PLSA_HANDLE; +alias PLSA_HANDLE = LSA_HANDLE*; struct TRUSTED_DOMAIN_NAME_INFO { LSA_UNICODE_STRING Name; } -alias TRUSTED_DOMAIN_NAME_INFO* PTRUSTED_DOMAIN_NAME_INFO; +alias PTRUSTED_DOMAIN_NAME_INFO = TRUSTED_DOMAIN_NAME_INFO*; struct TRUSTED_CONTROLLERS_INFO { ULONG Entries; PLSA_UNICODE_STRING Names; } -alias TRUSTED_CONTROLLERS_INFO* PTRUSTED_CONTROLLERS_INFO; +alias PTRUSTED_CONTROLLERS_INFO = TRUSTED_CONTROLLERS_INFO*; struct TRUSTED_POSIX_OFFSET_INFO { ULONG Offset; } -alias TRUSTED_POSIX_OFFSET_INFO* PTRUSTED_POSIX_OFFSET_INFO; +alias PTRUSTED_POSIX_OFFSET_INFO = TRUSTED_POSIX_OFFSET_INFO*; struct TRUSTED_PASSWORD_INFO { LSA_UNICODE_STRING Password; LSA_UNICODE_STRING OldPassword; } -alias TRUSTED_PASSWORD_INFO* PTRUSTED_PASSWORD_INFO; +alias PTRUSTED_PASSWORD_INFO = TRUSTED_PASSWORD_INFO*; struct TRUSTED_DOMAIN_INFORMATION_EX { LSA_UNICODE_STRING Name; @@ -699,7 +694,7 @@ struct TRUSTED_DOMAIN_INFORMATION_EX { ULONG TrustType; ULONG TrustAttributes; } -alias TRUSTED_DOMAIN_INFORMATION_EX* PTRUSTED_DOMAIN_INFORMATION_EX; +alias PTRUSTED_DOMAIN_INFORMATION_EX = TRUSTED_DOMAIN_INFORMATION_EX*; struct LSA_AUTH_INFORMATION { LARGE_INTEGER LastUpdateTime; @@ -707,7 +702,7 @@ struct LSA_AUTH_INFORMATION { ULONG AuthInfoLength; PUCHAR AuthInfo; } -alias LSA_AUTH_INFORMATION* PLSA_AUTH_INFORMATION; +alias PLSA_AUTH_INFORMATION = LSA_AUTH_INFORMATION*; struct TRUSTED_DOMAIN_AUTH_INFORMATION { ULONG IncomingAuthInfos; @@ -717,14 +712,14 @@ struct TRUSTED_DOMAIN_AUTH_INFORMATION { PLSA_AUTH_INFORMATION OutgoingAuthenticationInformation; PLSA_AUTH_INFORMATION OutgoingPreviousAuthenticationInformation; } -alias TRUSTED_DOMAIN_AUTH_INFORMATION* PTRUSTED_DOMAIN_AUTH_INFORMATION; +alias PTRUSTED_DOMAIN_AUTH_INFORMATION = TRUSTED_DOMAIN_AUTH_INFORMATION*; struct TRUSTED_DOMAIN_FULL_INFORMATION { TRUSTED_DOMAIN_INFORMATION_EX Information; TRUSTED_POSIX_OFFSET_INFO PosixOffset; TRUSTED_DOMAIN_AUTH_INFORMATION AuthInformation; } -alias TRUSTED_DOMAIN_FULL_INFORMATION* PTRUSTED_DOMAIN_FULL_INFORMATION; +alias PTRUSTED_DOMAIN_FULL_INFORMATION = TRUSTED_DOMAIN_FULL_INFORMATION*; extern (Windows) nothrow @nogc { NTSTATUS LsaAddAccountRights(LSA_HANDLE, PSID, PLSA_UNICODE_STRING, @@ -789,8 +784,7 @@ extern (Windows) nothrow @nogc { PLSA_UNICODE_STRING); } -alias NTSTATUS function(PUNICODE_STRING, ULONG, PUNICODE_STRING) - PSAM_PASSWORD_NOTIFICATION_ROUTINE; -alias BOOLEAN function() PSAM_INIT_NOTIFICATION_ROUTINE; -alias BOOLEAN function(PUNICODE_STRING, PUNICODE_STRING, - PUNICODE_STRING, BOOLEAN) PSAM_PASSWORD_FILTER_ROUTINE; +alias PSAM_PASSWORD_NOTIFICATION_ROUTINE = NTSTATUS function(PUNICODE_STRING, ULONG, PUNICODE_STRING); +alias PSAM_INIT_NOTIFICATION_ROUTINE = BOOLEAN function(); +alias PSAM_PASSWORD_FILTER_ROUTINE = BOOLEAN function(PUNICODE_STRING, PUNICODE_STRING, + PUNICODE_STRING, BOOLEAN); diff --git a/runtime/druntime/src/core/sys/windows/ntsecpkg.d b/runtime/druntime/src/core/sys/windows/ntsecpkg.d index 56803b043c..02110716fd 100644 --- a/runtime/druntime/src/core/sys/windows/ntsecpkg.d +++ b/runtime/druntime/src/core/sys/windows/ntsecpkg.d @@ -70,7 +70,7 @@ enum LSA_TOKEN_INFORMATION_TYPE { LsaTokenInformationNull, LsaTokenInformationV1 } -alias LSA_TOKEN_INFORMATION_TYPE* PLSA_TOKEN_INFORMATION_TYPE; +alias PLSA_TOKEN_INFORMATION_TYPE = LSA_TOKEN_INFORMATION_TYPE*; enum SECPKG_EXTENDED_INFORMATION_CLASS { SecpkgGssInfo = 1, @@ -102,18 +102,18 @@ struct SECPKG_PRIMARY_CRED { UNICODE_STRING Spare3; UNICODE_STRING Spare4; } -alias SECPKG_PRIMARY_CRED* PSECPKG_PRIMARY_CRED; +alias PSECPKG_PRIMARY_CRED = SECPKG_PRIMARY_CRED*; struct SECPKG_SUPPLEMENTAL_CRED { UNICODE_STRING PackageName; ULONG CredentialSize; PUCHAR Credentials; } -alias SECPKG_SUPPLEMENTAL_CRED* PSECPKG_SUPPLEMENTAL_CRED; +alias PSECPKG_SUPPLEMENTAL_CRED = SECPKG_SUPPLEMENTAL_CRED*; struct SECPKG_SUPPLEMENTAL_CRED_ARRAY { ULONG CredentialCount; SECPKG_SUPPLEMENTAL_CRED[1] Credentials; } -alias SECPKG_SUPPLEMENTAL_CRED_ARRAY* PSECPKG_SUPPLEMENTAL_CRED_ARRAY; +alias PSECPKG_SUPPLEMENTAL_CRED_ARRAY = SECPKG_SUPPLEMENTAL_CRED_ARRAY*; struct SECPKG_PARAMETERS { ULONG Version; ULONG MachineState; @@ -123,8 +123,8 @@ struct SECPKG_PARAMETERS { UNICODE_STRING DnsDomainName; GUID DomainGuid; } -alias SECPKG_PARAMETERS* PSECPKG_PARAMETERS,PSECPKG_EVENT_DOMAIN_CHANGE; -alias SECPKG_PARAMETERS SECPKG_EVENT_DOMAIN_CHANGE; +alias PSECPKG_PARAMETERS = SECPKG_PARAMETERS*, PSECPKG_EVENT_DOMAIN_CHANGE = SECPKG_PARAMETERS*; +alias SECPKG_EVENT_DOMAIN_CHANGE = SECPKG_PARAMETERS; struct SECPKG_CLIENT_INFO { LUID LogonId; ULONG ProcessID; @@ -133,36 +133,36 @@ struct SECPKG_CLIENT_INFO { BOOLEAN Impersonating; BOOLEAN Restricted; } -alias SECPKG_CLIENT_INFO* PSECPKG_CLIENT_INFO; +alias PSECPKG_CLIENT_INFO = SECPKG_CLIENT_INFO*; struct SECURITY_USER_DATA { SECURITY_STRING UserName; SECURITY_STRING LogonDomainName; SECURITY_STRING LogonServer; PSID pSid; } -alias SECURITY_USER_DATA* PSECURITY_USER_DATA,PSecurityUserData; -alias SECURITY_USER_DATA SecurityUserData; +alias PSECURITY_USER_DATA = SECURITY_USER_DATA*, PSecurityUserData = SECURITY_USER_DATA*; +alias SecurityUserData = SECURITY_USER_DATA; struct SECPKG_GSS_INFO { ULONG EncodedIdLength; UCHAR[4] EncodedId; } -alias SECPKG_GSS_INFO* PSECPKG_GSS_INFO; +alias PSECPKG_GSS_INFO = SECPKG_GSS_INFO*; struct SECPKG_CONTEXT_THUNKS { ULONG InfoLevelCount; ULONG[1] Levels; } -alias SECPKG_CONTEXT_THUNKS* PSECPKG_CONTEXT_THUNKS; +alias PSECPKG_CONTEXT_THUNKS = SECPKG_CONTEXT_THUNKS*; struct SECPKG_MUTUAL_AUTH_LEVEL { ULONG MutualAuthLevel; } -alias SECPKG_MUTUAL_AUTH_LEVEL* PSECPKG_MUTUAL_AUTH_LEVEL; +alias PSECPKG_MUTUAL_AUTH_LEVEL = SECPKG_MUTUAL_AUTH_LEVEL*; struct SECPKG_CALL_INFO { ULONG ProcessId; ULONG ThreadId; ULONG Attributes; ULONG CallCount; } -alias SECPKG_CALL_INFO* PSECPKG_CALL_INFO; +alias PSECPKG_CALL_INFO = SECPKG_CALL_INFO*; struct SECPKG_EXTENDED_INFORMATION { SECPKG_EXTENDED_INFORMATION_CLASS Class; union _Info{ @@ -172,86 +172,86 @@ struct SECPKG_EXTENDED_INFORMATION { } _Info Info; } -alias SECPKG_EXTENDED_INFORMATION* PSECPKG_EXTENDED_INFORMATION; +alias PSECPKG_EXTENDED_INFORMATION = SECPKG_EXTENDED_INFORMATION*; /* callbacks implemented by SSP/AP dlls and called by the LSA */ -alias void function(ULONG_PTR, ULONG_PTR, PSecBuffer, - PSecBuffer) PLSA_CALLBACK_FUNCTION; +alias PLSA_CALLBACK_FUNCTION = void function(ULONG_PTR, ULONG_PTR, PSecBuffer, + PSecBuffer); /* misc typedefs used in the below prototypes */ -alias PVOID* PLSA_CLIENT_REQUEST; -alias ULONG_PTR LSA_SEC_HANDLE; -alias LSA_SEC_HANDLE* PLSA_SEC_HANDLE; -alias LPTHREAD_START_ROUTINE SEC_THREAD_START; -alias PSECURITY_ATTRIBUTES SEC_ATTRS; +alias PLSA_CLIENT_REQUEST = PVOID*; +alias LSA_SEC_HANDLE = ULONG_PTR; +alias PLSA_SEC_HANDLE = LSA_SEC_HANDLE*; +alias SEC_THREAD_START = LPTHREAD_START_ROUTINE; +alias SEC_ATTRS = PSECURITY_ATTRIBUTES; /* functions used by SSP/AP obtainable by dispatch tables */ -alias NTSTATUS function(ULONG, PLSA_CALLBACK_FUNCTION) PLSA_REGISTER_CALLBACK; -alias NTSTATUS function(PLUID) PLSA_CREATE_LOGON_SESSION; -alias NTSTATUS function(PLUID) PLSA_DELETE_LOGON_SESSION; -alias NTSTATUS function(PLUID, ULONG, PLSA_STRING, - PLSA_STRING) PLSA_ADD_CREDENTIAL; -alias NTSTATUS function(PLUID, ULONG, PULONG, BOOLEAN, - PLSA_STRING, PULONG, PLSA_STRING) PLSA_GET_CREDENTIALS; -alias NTSTATUS function(PLUID, ULONG, PLSA_STRING) PLSA_DELETE_CREDENTIAL; -alias PVOID function(ULONG) PLSA_ALLOCATE_LSA_HEAP; -alias void function(PVOID) PLSA_FREE_LSA_HEAP; -alias NTSTATUS function(PLSA_CLIENT_REQUEST, - ULONG, PVOID*) PLSA_ALLOCATE_CLIENT_BUFFER; -alias NTSTATUS function(PLSA_CLIENT_REQUEST, PVOID) PLSA_FREE_CLIENT_BUFFER; -alias NTSTATUS function(PLSA_CLIENT_REQUEST, ULONG, - PVOID, PVOID) PLSA_COPY_TO_CLIENT_BUFFER; -alias NTSTATUS function(PLSA_CLIENT_REQUEST, - ULONG, PVOID, PVOID) PLSA_COPY_FROM_CLIENT_BUFFER; -alias NTSTATUS function() PLSA_IMPERSONATE_CLIENT; -alias NTSTATUS function() PLSA_UNLOAD_PACKAGE; -alias NTSTATUS function(HANDLE, PHANDLE) PLSA_DUPLICATE_HANDLE; -alias NTSTATUS function(PLUID, ULONG, - PVOID, BOOLEAN) PLSA_SAVE_SUPPLEMENTAL_CREDENTIALS; -alias HANDLE function(SEC_ATTRS, ULONG, SEC_THREAD_START, - PVOID, ULONG, PULONG) PLSA_CREATE_THREAD; -alias NTSTATUS function(PSECPKG_CLIENT_INFO) PLSA_GET_CLIENT_INFO; -alias HANDLE function(SEC_THREAD_START, PVOID, - ULONG, ULONG, ULONG, ULONG, HANDLE) PLSA_REGISTER_NOTIFICATION; -alias NTSTATUS function(HANDLE) PLSA_CANCEL_NOTIFICATION; -alias NTSTATUS function(PSecBuffer, PSecBuffer) PLSA_MAP_BUFFER; -alias NTSTATUS function(PLUID, PTOKEN_SOURCE, +alias PLSA_REGISTER_CALLBACK = NTSTATUS function(ULONG, PLSA_CALLBACK_FUNCTION); +alias PLSA_CREATE_LOGON_SESSION = NTSTATUS function(PLUID); +alias PLSA_DELETE_LOGON_SESSION = NTSTATUS function(PLUID); +alias PLSA_ADD_CREDENTIAL = NTSTATUS function(PLUID, ULONG, PLSA_STRING, + PLSA_STRING); +alias PLSA_GET_CREDENTIALS = NTSTATUS function(PLUID, ULONG, PULONG, BOOLEAN, + PLSA_STRING, PULONG, PLSA_STRING); +alias PLSA_DELETE_CREDENTIAL = NTSTATUS function(PLUID, ULONG, PLSA_STRING); +alias PLSA_ALLOCATE_LSA_HEAP = PVOID function(ULONG); +alias PLSA_FREE_LSA_HEAP = void function(PVOID); +alias PLSA_ALLOCATE_CLIENT_BUFFER = NTSTATUS function(PLSA_CLIENT_REQUEST, + ULONG, PVOID*); +alias PLSA_FREE_CLIENT_BUFFER = NTSTATUS function(PLSA_CLIENT_REQUEST, PVOID); +alias PLSA_COPY_TO_CLIENT_BUFFER = NTSTATUS function(PLSA_CLIENT_REQUEST, ULONG, + PVOID, PVOID); +alias PLSA_COPY_FROM_CLIENT_BUFFER = NTSTATUS function(PLSA_CLIENT_REQUEST, + ULONG, PVOID, PVOID); +alias PLSA_IMPERSONATE_CLIENT = NTSTATUS function(); +alias PLSA_UNLOAD_PACKAGE = NTSTATUS function(); +alias PLSA_DUPLICATE_HANDLE = NTSTATUS function(HANDLE, PHANDLE); +alias PLSA_SAVE_SUPPLEMENTAL_CREDENTIALS = NTSTATUS function(PLUID, ULONG, + PVOID, BOOLEAN); +alias PLSA_CREATE_THREAD = HANDLE function(SEC_ATTRS, ULONG, SEC_THREAD_START, + PVOID, ULONG, PULONG); +alias PLSA_GET_CLIENT_INFO = NTSTATUS function(PSECPKG_CLIENT_INFO); +alias PLSA_REGISTER_NOTIFICATION = HANDLE function(SEC_THREAD_START, PVOID, + ULONG, ULONG, ULONG, ULONG, HANDLE); +alias PLSA_CANCEL_NOTIFICATION = NTSTATUS function(HANDLE); +alias PLSA_MAP_BUFFER = NTSTATUS function(PSecBuffer, PSecBuffer); +alias PLSA_CREATE_TOKEN = NTSTATUS function(PLUID, PTOKEN_SOURCE, SECURITY_LOGON_TYPE, SECURITY_IMPERSONATION_LEVEL, LSA_TOKEN_INFORMATION_TYPE, PVOID, PTOKEN_GROUPS, PUNICODE_STRING, PUNICODE_STRING, PUNICODE_STRING, - PUNICODE_STRING, PHANDLE, PNTSTATUS) PLSA_CREATE_TOKEN; -alias void function(NTSTATUS, NTSTATUS, PUNICODE_STRING, + PUNICODE_STRING, PHANDLE, PNTSTATUS); +alias PLSA_AUDIT_LOGON = void function(NTSTATUS, NTSTATUS, PUNICODE_STRING, PUNICODE_STRING, PUNICODE_STRING, PSID, SECURITY_LOGON_TYPE, - PTOKEN_SOURCE, PLUID) PLSA_AUDIT_LOGON; -alias NTSTATUS function(PUNICODE_STRING, PVOID, ULONG, - PVOID*, PULONG, PNTSTATUS) PLSA_CALL_PACKAGE; -alias BOOLEAN function(PSECPKG_CALL_INFO) PLSA_GET_CALL_INFO; -alias NTSTATUS function(PUNICODE_STRING, PVOID, PVOID, - ULONG, PVOID*, PULONG, PNTSTATUS) PLSA_CALL_PACKAGEEX; -alias PVOID function(ULONG, ULONG) PLSA_CREATE_SHARED_MEMORY; -alias PVOID function(PVOID, ULONG) PLSA_ALLOCATE_SHARED_MEMORY; -alias void function(PVOID, PVOID) PLSA_FREE_SHARED_MEMORY; -alias BOOLEAN function(PVOID) PLSA_DELETE_SHARED_MEMORY; -alias NTSTATUS function(PSECURITY_STRING, SECPKG_NAME_TYPE, - PSECURITY_STRING, BOOLEAN, ULONG, PVOID*) PLSA_OPEN_SAM_USER; -alias NTSTATUS function(PVOID, PVOID *, PULONG, - PVOID *, PULONG) PLSA_GET_USER_CREDENTIALS; -alias NTSTATUS function(PVOID, PUCHAR *, PULONG) PLSA_GET_USER_AUTH_DATA; -alias NTSTATUS function(PVOID) PLSA_CLOSE_SAM_USER; -alias NTSTATUS function(PVOID, ULONG, + PTOKEN_SOURCE, PLUID); +alias PLSA_CALL_PACKAGE = NTSTATUS function(PUNICODE_STRING, PVOID, ULONG, + PVOID*, PULONG, PNTSTATUS); +alias PLSA_GET_CALL_INFO = BOOLEAN function(PSECPKG_CALL_INFO); +alias PLSA_CALL_PACKAGEEX = NTSTATUS function(PUNICODE_STRING, PVOID, PVOID, + ULONG, PVOID*, PULONG, PNTSTATUS); +alias PLSA_CREATE_SHARED_MEMORY = PVOID function(ULONG, ULONG); +alias PLSA_ALLOCATE_SHARED_MEMORY = PVOID function(PVOID, ULONG); +alias PLSA_FREE_SHARED_MEMORY = void function(PVOID, PVOID); +alias PLSA_DELETE_SHARED_MEMORY = BOOLEAN function(PVOID); +alias PLSA_OPEN_SAM_USER = NTSTATUS function(PSECURITY_STRING, SECPKG_NAME_TYPE, + PSECURITY_STRING, BOOLEAN, ULONG, PVOID*); +alias PLSA_GET_USER_CREDENTIALS = NTSTATUS function(PVOID, PVOID *, PULONG, + PVOID *, PULONG); +alias PLSA_GET_USER_AUTH_DATA = NTSTATUS function(PVOID, PUCHAR *, PULONG); +alias PLSA_CLOSE_SAM_USER = NTSTATUS function(PVOID); +alias PLSA_CONVERT_AUTH_DATA_TO_TOKEN = NTSTATUS function(PVOID, ULONG, SECURITY_IMPERSONATION_LEVEL, PTOKEN_SOURCE, SECURITY_LOGON_TYPE, - PUNICODE_STRING, PHANDLE, PLUID, PUNICODE_STRING, PNTSTATUS) PLSA_CONVERT_AUTH_DATA_TO_TOKEN; -alias NTSTATUS function(PCHAR, ULONG_PTR, ULONG_PTR, - PSecBuffer, PSecBuffer) PLSA_CLIENT_CALLBACK; -alias NTSTATUS function(PSECPKG_PRIMARY_CRED, PSECPKG_SUPPLEMENTAL_CRED_ARRAY) PLSA_UPDATE_PRIMARY_CREDENTIALS; -alias NTSTATUS function(PSECURITY_STRING, - SECPKG_NAME_TYPE, PSECURITY_STRING, PUCHAR *, PULONG, PUNICODE_STRING) PLSA_GET_AUTH_DATA_FOR_USER; -alias NTSTATUS function(ULONG, BOOLEAN, + PUNICODE_STRING, PHANDLE, PLUID, PUNICODE_STRING, PNTSTATUS); +alias PLSA_CLIENT_CALLBACK = NTSTATUS function(PCHAR, ULONG_PTR, ULONG_PTR, + PSecBuffer, PSecBuffer); +alias PLSA_UPDATE_PRIMARY_CREDENTIALS = NTSTATUS function(PSECPKG_PRIMARY_CRED, PSECPKG_SUPPLEMENTAL_CRED_ARRAY); +alias PLSA_GET_AUTH_DATA_FOR_USER = NTSTATUS function(PSECURITY_STRING, + SECPKG_NAME_TYPE, PSECURITY_STRING, PUCHAR *, PULONG, PUNICODE_STRING); +alias PLSA_CRACK_SINGLE_NAME = NTSTATUS function(ULONG, BOOLEAN, PUNICODE_STRING, PUNICODE_STRING, ULONG, PUNICODE_STRING, PUNICODE_STRING, - PULONG) PLSA_CRACK_SINGLE_NAME; -alias NTSTATUS function(ULONG, BOOLEAN, - PUNICODE_STRING, PUNICODE_STRING, PUNICODE_STRING, NTSTATUS) PLSA_AUDIT_ACCOUNT_LOGON; -alias NTSTATUS function(PUNICODE_STRING, PVOID, - PVOID, ULONG, PVOID*, PULONG, PNTSTATUS) PLSA_CALL_PACKAGE_PASSTHROUGH; + PULONG); +alias PLSA_AUDIT_ACCOUNT_LOGON = NTSTATUS function(ULONG, BOOLEAN, + PUNICODE_STRING, PUNICODE_STRING, PUNICODE_STRING, NTSTATUS); +alias PLSA_CALL_PACKAGE_PASSTHROUGH = NTSTATUS function(PUNICODE_STRING, PVOID, + PVOID, ULONG, PVOID*, PULONG, PNTSTATUS); /* Dispatch tables of functions used by SSP/AP */ struct SECPKG_DLL_FUNCTIONS { @@ -259,7 +259,7 @@ struct SECPKG_DLL_FUNCTIONS { PLSA_FREE_LSA_HEAP FreeHeap; PLSA_REGISTER_CALLBACK RegisterCallback; } -alias SECPKG_DLL_FUNCTIONS* PSECPKG_DLL_FUNCTIONS; +alias PSECPKG_DLL_FUNCTIONS = SECPKG_DLL_FUNCTIONS*; struct LSA_DISPATCH_TABLE { PLSA_CREATE_LOGON_SESSION CreateLogonSession; PLSA_DELETE_LOGON_SESSION DeleteLogonSession; @@ -273,7 +273,7 @@ struct LSA_DISPATCH_TABLE { PLSA_COPY_TO_CLIENT_BUFFER CopyToClientBuffer; PLSA_COPY_FROM_CLIENT_BUFFER CopyFromClientBuffer; } -alias LSA_DISPATCH_TABLE* PLSA_DISPATCH_TABLE; +alias PLSA_DISPATCH_TABLE = LSA_DISPATCH_TABLE*; struct LSA_SECPKG_FUNCTION_TABLE { PLSA_CREATE_LOGON_SESSION CreateLogonSession; PLSA_DELETE_LOGON_SESSION DeleteLogonSession; @@ -317,76 +317,76 @@ struct LSA_SECPKG_FUNCTION_TABLE { PLSA_AUDIT_ACCOUNT_LOGON AuditAccountLogon; PLSA_CALL_PACKAGE_PASSTHROUGH CallPackagePassthrough; } -alias LSA_SECPKG_FUNCTION_TABLE* PLSA_SECPKG_FUNCTION_TABLE; +alias PLSA_SECPKG_FUNCTION_TABLE = LSA_SECPKG_FUNCTION_TABLE*; /* functions implemented by SSP/AP obtainable by dispatch tables */ -alias NTSTATUS function(ULONG, PLSA_DISPATCH_TABLE, - PLSA_STRING, PLSA_STRING, PLSA_STRING *) PLSA_AP_INITIALIZE_PACKAGE; -alias NTSTATUS function(LPWSTR, LPWSTR, LPWSTR, LPWSTR, - DWORD, DWORD, PHANDLE) PLSA_AP_LOGON_USER; -alias NTSTATUS function(PUNICODE_STRING, PVOID, ULONG, - PVOID *, PULONG, PNTSTATUS) PLSA_AP_CALL_PACKAGE; -alias void function(PLUID) PLSA_AP_LOGON_TERMINATED; -alias NTSTATUS function(PLSA_CLIENT_REQUEST, - PVOID, PVOID, ULONG, PVOID *, PULONG, PNTSTATUS) PLSA_AP_CALL_PACKAGE_UNTRUSTED; -alias NTSTATUS function(PUNICODE_STRING, - PVOID, PVOID, ULONG, PVOID *, PULONG, PNTSTATUS) PLSA_AP_CALL_PACKAGE_PASSTHROUGH; -alias NTSTATUS function(PLSA_CLIENT_REQUEST, +alias PLSA_AP_INITIALIZE_PACKAGE = NTSTATUS function(ULONG, PLSA_DISPATCH_TABLE, + PLSA_STRING, PLSA_STRING, PLSA_STRING *); +alias PLSA_AP_LOGON_USER = NTSTATUS function(LPWSTR, LPWSTR, LPWSTR, LPWSTR, + DWORD, DWORD, PHANDLE); +alias PLSA_AP_CALL_PACKAGE = NTSTATUS function(PUNICODE_STRING, PVOID, ULONG, + PVOID *, PULONG, PNTSTATUS); +alias PLSA_AP_LOGON_TERMINATED = void function(PLUID); +alias PLSA_AP_CALL_PACKAGE_UNTRUSTED = NTSTATUS function(PLSA_CLIENT_REQUEST, + PVOID, PVOID, ULONG, PVOID *, PULONG, PNTSTATUS); +alias PLSA_AP_CALL_PACKAGE_PASSTHROUGH = NTSTATUS function(PUNICODE_STRING, + PVOID, PVOID, ULONG, PVOID *, PULONG, PNTSTATUS); +alias PLSA_AP_LOGON_USER_EX = NTSTATUS function(PLSA_CLIENT_REQUEST, SECURITY_LOGON_TYPE, PVOID, PVOID, ULONG, PVOID *, PULONG, PLUID, PNTSTATUS, PLSA_TOKEN_INFORMATION_TYPE, PVOID *, PUNICODE_STRING *, PUNICODE_STRING *, - PUNICODE_STRING *) PLSA_AP_LOGON_USER_EX; -alias NTSTATUS function(PLSA_CLIENT_REQUEST, + PUNICODE_STRING *); +alias PLSA_AP_LOGON_USER_EX2 = NTSTATUS function(PLSA_CLIENT_REQUEST, SECURITY_LOGON_TYPE, PVOID, PVOID, ULONG, PVOID *, PULONG, PLUID, PNTSTATUS, PLSA_TOKEN_INFORMATION_TYPE, PVOID *, PUNICODE_STRING *, PUNICODE_STRING *, - PUNICODE_STRING *, PSECPKG_PRIMARY_CRED, PSECPKG_SUPPLEMENTAL_CRED_ARRAY *) PLSA_AP_LOGON_USER_EX2; -alias NTSTATUS function(ULONG_PTR, PSECPKG_PARAMETERS, - PLSA_SECPKG_FUNCTION_TABLE) SpInitializeFn; -alias NTSTATUS function() SpShutDownFn; -alias NTSTATUS function(PSecPkgInfoW) SpGetInfoFn; -alias NTSTATUS function(SECURITY_LOGON_TYPE, - PUNICODE_STRING, PSECPKG_PRIMARY_CRED, PSECPKG_SUPPLEMENTAL_CRED) SpAcceptCredentialsFn; -alias NTSTATUS function(PUNICODE_STRING, ULONG, - PLUID, PVOID, PVOID, PVOID, PLSA_SEC_HANDLE, PTimeStamp) SpAcquireCredentialsHandleFn; -alias NTSTATUS function(LSA_SEC_HANDLE, ULONG, PVOID) SpQueryCredentialsAttributesFn; -alias NTSTATUS function(LSA_SEC_HANDLE) SpFreeCredentialsHandleFn; -alias NTSTATUS function(LSA_SEC_HANDLE, PSecBuffer) SpSaveCredentialsFn; -alias NTSTATUS function(LSA_SEC_HANDLE, PSecBuffer) SpGetCredentialsFn; -alias NTSTATUS function(LSA_SEC_HANDLE, PSecBuffer) SpDeleteCredentialsFn; -alias NTSTATUS function(LSA_SEC_HANDLE, LSA_SEC_HANDLE, + PUNICODE_STRING *, PSECPKG_PRIMARY_CRED, PSECPKG_SUPPLEMENTAL_CRED_ARRAY *); +alias SpInitializeFn = NTSTATUS function(ULONG_PTR, PSECPKG_PARAMETERS, + PLSA_SECPKG_FUNCTION_TABLE); +alias SpShutDownFn = NTSTATUS function(); +alias SpGetInfoFn = NTSTATUS function(PSecPkgInfoW); +alias SpAcceptCredentialsFn = NTSTATUS function(SECURITY_LOGON_TYPE, + PUNICODE_STRING, PSECPKG_PRIMARY_CRED, PSECPKG_SUPPLEMENTAL_CRED); +alias SpAcquireCredentialsHandleFn = NTSTATUS function(PUNICODE_STRING, ULONG, + PLUID, PVOID, PVOID, PVOID, PLSA_SEC_HANDLE, PTimeStamp); +alias SpQueryCredentialsAttributesFn = NTSTATUS function(LSA_SEC_HANDLE, ULONG, PVOID); +alias SpFreeCredentialsHandleFn = NTSTATUS function(LSA_SEC_HANDLE); +alias SpSaveCredentialsFn = NTSTATUS function(LSA_SEC_HANDLE, PSecBuffer); +alias SpGetCredentialsFn = NTSTATUS function(LSA_SEC_HANDLE, PSecBuffer); +alias SpDeleteCredentialsFn = NTSTATUS function(LSA_SEC_HANDLE, PSecBuffer); +alias SpInitLsaModeContextFn = NTSTATUS function(LSA_SEC_HANDLE, LSA_SEC_HANDLE, PUNICODE_STRING, ULONG, ULONG, PSecBufferDesc, PLSA_SEC_HANDLE, PSecBufferDesc, - PULONG, PTimeStamp, PBOOLEAN, PSecBuffer) SpInitLsaModeContextFn; -alias NTSTATUS function(LSA_SEC_HANDLE, + PULONG, PTimeStamp, PBOOLEAN, PSecBuffer); +alias SpAcceptLsaModeContextFn = NTSTATUS function(LSA_SEC_HANDLE, LSA_SEC_HANDLE, PSecBufferDesc, ULONG, ULONG, PLSA_SEC_HANDLE, PSecBufferDesc, - PULONG, PTimeStamp, PBOOLEAN, PSecBuffer) SpAcceptLsaModeContextFn; -alias NTSTATUS function(LSA_SEC_HANDLE) SpDeleteContextFn; -alias NTSTATUS function(LSA_SEC_HANDLE, PSecBufferDesc) SpApplyControlTokenFn; -alias NTSTATUS function(PLUID, ULONG, PSecurityUserData *) SpGetUserInfoFn; -alias NTSTATUS function(SECPKG_EXTENDED_INFORMATION_CLASS, PSECPKG_EXTENDED_INFORMATION *) SpGetExtendedInformationFn; -alias NTSTATUS function(LSA_SEC_HANDLE, ULONG, PVOID) SpQueryContextAttributesFn; -alias NTSTATUS function(LSA_SEC_HANDLE, PUNICODE_STRING, - PUNICODE_STRING, ULONG, PVOID, PVOID, PVOID, PTimeStamp) SpAddCredentialsFn; -alias NTSTATUS function( - SECPKG_EXTENDED_INFORMATION_CLASS, PSECPKG_EXTENDED_INFORMATION) SpSetExtendedInformationFn; -alias NTSTATUS function(ULONG, PSECPKG_DLL_FUNCTIONS, - PVOID *) SpInstanceInitFn; -alias NTSTATUS function(LSA_SEC_HANDLE, PSecBuffer) SpInitUserModeContextFn; -alias NTSTATUS function(LSA_SEC_HANDLE, ULONG, - PSecBufferDesc, ULONG) SpMakeSignatureFn; -alias NTSTATUS function(LSA_SEC_HANDLE, PSecBufferDesc, - ULONG, PULONG) SpVerifySignatureFn; -alias NTSTATUS function(LSA_SEC_HANDLE, ULONG, PSecBufferDesc, - ULONG) SpSealMessageFn; -alias NTSTATUS function(LSA_SEC_HANDLE, PSecBufferDesc, - ULONG, PULONG) SpUnsealMessageFn; -alias NTSTATUS function(LSA_SEC_HANDLE, PHANDLE) SpGetContextTokenFn; -alias NTSTATUS function(LSA_SEC_HANDLE, PSecBufferDesc) SpCompleteAuthTokenFn; -alias NTSTATUS function(PSecBuffer, PSecBuffer) SpFormatCredentialsFn; -alias NTSTATUS function(ULONG, PUCHAR, PULONG, - PVOID *) SpMarshallSupplementalCredsFn; -alias NTSTATUS function(LSA_SEC_HANDLE, ULONG, - PSecBuffer, PHANDLE) SpExportSecurityContextFn; -alias NTSTATUS function(PSecBuffer, HANDLE, - PLSA_SEC_HANDLE) SpImportSecurityContextFn; + PULONG, PTimeStamp, PBOOLEAN, PSecBuffer); +alias SpDeleteContextFn = NTSTATUS function(LSA_SEC_HANDLE); +alias SpApplyControlTokenFn = NTSTATUS function(LSA_SEC_HANDLE, PSecBufferDesc); +alias SpGetUserInfoFn = NTSTATUS function(PLUID, ULONG, PSecurityUserData *); +alias SpGetExtendedInformationFn = NTSTATUS function(SECPKG_EXTENDED_INFORMATION_CLASS, PSECPKG_EXTENDED_INFORMATION *); +alias SpQueryContextAttributesFn = NTSTATUS function(LSA_SEC_HANDLE, ULONG, PVOID); +alias SpAddCredentialsFn = NTSTATUS function(LSA_SEC_HANDLE, PUNICODE_STRING, + PUNICODE_STRING, ULONG, PVOID, PVOID, PVOID, PTimeStamp); +alias SpSetExtendedInformationFn = NTSTATUS function( + SECPKG_EXTENDED_INFORMATION_CLASS, PSECPKG_EXTENDED_INFORMATION); +alias SpInstanceInitFn = NTSTATUS function(ULONG, PSECPKG_DLL_FUNCTIONS, + PVOID *); +alias SpInitUserModeContextFn = NTSTATUS function(LSA_SEC_HANDLE, PSecBuffer); +alias SpMakeSignatureFn = NTSTATUS function(LSA_SEC_HANDLE, ULONG, + PSecBufferDesc, ULONG); +alias SpVerifySignatureFn = NTSTATUS function(LSA_SEC_HANDLE, PSecBufferDesc, + ULONG, PULONG); +alias SpSealMessageFn = NTSTATUS function(LSA_SEC_HANDLE, ULONG, PSecBufferDesc, + ULONG); +alias SpUnsealMessageFn = NTSTATUS function(LSA_SEC_HANDLE, PSecBufferDesc, + ULONG, PULONG); +alias SpGetContextTokenFn = NTSTATUS function(LSA_SEC_HANDLE, PHANDLE); +alias SpCompleteAuthTokenFn = NTSTATUS function(LSA_SEC_HANDLE, PSecBufferDesc); +alias SpFormatCredentialsFn = NTSTATUS function(PSecBuffer, PSecBuffer); +alias SpMarshallSupplementalCredsFn = NTSTATUS function(ULONG, PUCHAR, PULONG, + PVOID *); +alias SpExportSecurityContextFn = NTSTATUS function(LSA_SEC_HANDLE, ULONG, + PSecBuffer, PHANDLE); +alias SpImportSecurityContextFn = NTSTATUS function(PSecBuffer, HANDLE, + PLSA_SEC_HANDLE); /* Dispatch tables of functions implemented by SSP/AP */ struct SECPKG_FUNCTION_TABLE { @@ -418,7 +418,7 @@ struct SECPKG_FUNCTION_TABLE { SpAddCredentialsFn *AddCredentials; SpSetExtendedInformationFn *SetExtendedInformation; } -alias SECPKG_FUNCTION_TABLE* PSECPKG_FUNCTION_TABLE; +alias PSECPKG_FUNCTION_TABLE = SECPKG_FUNCTION_TABLE*; struct SECPKG_USER_FUNCTION_TABLE { SpInstanceInitFn *InstanceInit; @@ -436,10 +436,10 @@ struct SECPKG_USER_FUNCTION_TABLE { SpExportSecurityContextFn *ExportContext; SpImportSecurityContextFn *ImportContext; } -alias SECPKG_USER_FUNCTION_TABLE* PSECPKG_USER_FUNCTION_TABLE; +alias PSECPKG_USER_FUNCTION_TABLE = SECPKG_USER_FUNCTION_TABLE*; /* Entry points to SSP/AP */ -alias NTSTATUS function(ULONG, PULONG, - PSECPKG_FUNCTION_TABLE *, PULONG) SpLsaModeInitializeFn; -alias NTSTATUS function(ULONG, PULONG, - PSECPKG_USER_FUNCTION_TABLE *, PULONG) SpUserModeInitializeFn; +alias SpLsaModeInitializeFn = NTSTATUS function(ULONG, PULONG, + PSECPKG_FUNCTION_TABLE *, PULONG); +alias SpUserModeInitializeFn = NTSTATUS function(ULONG, PULONG, + PSECPKG_USER_FUNCTION_TABLE *, PULONG); diff --git a/runtime/druntime/src/core/sys/windows/oaidl.d b/runtime/druntime/src/core/sys/windows/oaidl.d index cd11061d0b..49e36f4698 100644 --- a/runtime/druntime/src/core/sys/windows/oaidl.d +++ b/runtime/druntime/src/core/sys/windows/oaidl.d @@ -77,15 +77,15 @@ struct TLIBATTR { WORD wMinorVerNum; WORD wLibFlags; } -alias TLIBATTR* LPTLIBATTR; +alias LPTLIBATTR = TLIBATTR*; -alias CY CURRENCY; +alias CURRENCY = CY; struct SAFEARRAYBOUND { ULONG cElements; LONG lLbound; } -alias SAFEARRAYBOUND* LPSAFEARRAYBOUND; +alias LPSAFEARRAYBOUND = SAFEARRAYBOUND*; struct SAFEARR_BSTR { ULONG Size; @@ -125,7 +125,7 @@ struct _wireBRECORD { LPRECORDINFO* pRecInfo; byte* pRecord; } -alias _wireBRECORD* wireBRECORD; +alias wireBRECORD = _wireBRECORD*; struct SAFEARR_BRECORD { ULONG Size; @@ -163,9 +163,9 @@ struct _wireSAFEARRAY { SAFEARRAYUNION uArrayStructs; SAFEARRAYBOUND[1] rgsabound; } -alias _wireSAFEARRAY* wireSAFEARRAY; +alias wireSAFEARRAY = _wireSAFEARRAY*; -alias wireSAFEARRAY* wirePSAFEARRAY; +alias wirePSAFEARRAY = wireSAFEARRAY*; struct SAFEARRAY { USHORT cDims; @@ -175,7 +175,7 @@ struct SAFEARRAY { PVOID pvData; SAFEARRAYBOUND[1] rgsabound; } -alias SAFEARRAY* LPSAFEARRAY; +alias LPSAFEARRAY = SAFEARRAY*; struct VARIANT { union { @@ -238,10 +238,10 @@ struct VARIANT { DECIMAL decVal; } } -alias VARIANT* LPVARIANT; +alias LPVARIANT = VARIANT*; -alias VARIANT VARIANTARG; -alias VARIANT* LPVARIANTARG; +alias VARIANTARG = VARIANT; +alias LPVARIANTARG = VARIANT*; struct _wireVARIANT { DWORD clSize; @@ -297,11 +297,11 @@ struct _wireVARIANT { UINT* puintVal; } } -alias _wireVARIANT* wireVARIANT; +alias wireVARIANT = _wireVARIANT*; -alias LONG DISPID; -alias DISPID MEMBERID; -alias DWORD HREFTYPE; +alias DISPID = LONG; +alias MEMBERID = DISPID; +alias HREFTYPE = DWORD; enum TYPEKIND { TKIND_ENUM, TKIND_RECORD, TKIND_MODULE, TKIND_INTERFACE, TKIND_DISPATCH, @@ -327,19 +327,19 @@ struct PARAMDESCEX { ULONG cBytes; VARIANTARG varDefaultValue; } -alias PARAMDESCEX* LPPARAMDESCEX; +alias LPPARAMDESCEX = PARAMDESCEX*; struct PARAMDESC { LPPARAMDESCEX pparamdescex; USHORT wParamFlags; } -alias PARAMDESC* LPPARAMDESC; +alias LPPARAMDESC = PARAMDESC*; struct IDLDESC { ULONG_PTR dwReserved; USHORT wIDLFlags; } -alias IDLDESC* LPIDLDESC; +alias LPIDLDESC = IDLDESC*; struct ELEMDESC { TYPEDESC tdesc; @@ -348,7 +348,7 @@ struct ELEMDESC { PARAMDESC paramdesc; } } -alias ELEMDESC* LPELEMDESC; +alias LPELEMDESC = ELEMDESC*; struct TYPEATTR { GUID guid; @@ -370,7 +370,7 @@ struct TYPEATTR { TYPEDESC tdescAlias; IDLDESC idldescType; } -alias TYPEATTR* LPTYPEATTR; +alias LPTYPEATTR = TYPEATTR*; struct DISPPARAMS { VARIANTARG* rgvarg; @@ -392,7 +392,7 @@ struct EXCEPINFO { } SCODE scode; } -alias EXCEPINFO* LPEXCEPINFO; +alias LPEXCEPINFO = EXCEPINFO*; enum CALLCONV { CC_FASTCALL, @@ -437,7 +437,7 @@ struct FUNCDESC { ELEMDESC elemdescFunc; WORD wFuncFlags; } -alias FUNCDESC* LPFUNCDESC; +alias LPFUNCDESC = FUNCDESC*; enum VARKIND { VAR_PERINSTANCE, VAR_STATIC, VAR_CONST, VAR_DISPATCH @@ -454,7 +454,7 @@ struct VARDESC { WORD wVarFlags; VARKIND varkind; } -alias VARDESC* LPVARDESC; +alias LPVARDESC = VARDESC*; enum TYPEFLAGS { TYPEFLAG_FAPPOBJECT = 1, @@ -515,13 +515,13 @@ struct CUSTDATAITEM { GUID guid; VARIANTARG varValue; } -alias CUSTDATAITEM* LPCUSTDATAITEM; +alias LPCUSTDATAITEM = CUSTDATAITEM*; struct CUSTDATA { DWORD cCustData; LPCUSTDATAITEM prgCustData; } -alias CUSTDATA* LPCUSTDATA; +alias LPCUSTDATA = CUSTDATA*; enum DESCKIND { DESCKIND_NONE = 0, @@ -537,7 +537,7 @@ union BINDPTR { LPVARDESC lpvardesc; LPTYPECOMP lptcomp; } -alias BINDPTR* LPBINDPTR; +alias LPBINDPTR = BINDPTR*; interface IDispatch : IUnknown { HRESULT GetTypeInfoCount(UINT*); @@ -545,7 +545,7 @@ interface IDispatch : IUnknown { HRESULT GetIDsOfNames(REFIID, LPOLESTR*, UINT, LCID, DISPID*); HRESULT Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*); } -alias IDispatch LPDISPATCH; +alias LPDISPATCH = IDispatch; interface IEnumVARIANT : IUnknown { HRESULT Next(ULONG, VARIANT*, ULONG*); @@ -553,13 +553,13 @@ interface IEnumVARIANT : IUnknown { HRESULT Reset(); HRESULT Clone(IEnumVARIANT*); } -alias IEnumVARIANT LPENUMVARIANT; +alias LPENUMVARIANT = IEnumVARIANT; interface ITypeComp : IUnknown { HRESULT Bind(LPOLESTR, ULONG, WORD, LPTYPEINFO*, DESCKIND*, LPBINDPTR); HRESULT BindType(LPOLESTR, ULONG, LPTYPEINFO*, LPTYPECOMP*); } -alias ITypeComp LPTYPECOMP; +alias LPTYPECOMP = ITypeComp; interface ITypeInfo : IUnknown { HRESULT GetTypeAttr(LPTYPEATTR*); @@ -583,7 +583,7 @@ interface ITypeInfo : IUnknown { void ReleaseFuncDesc(LPFUNCDESC); void ReleaseVarDesc(LPVARDESC); } -alias ITypeInfo LPTYPEINFO; +alias LPTYPEINFO = ITypeInfo; interface ITypeInfo2 : ITypeInfo { HRESULT GetTypeKind(TYPEKIND*); @@ -602,7 +602,7 @@ interface ITypeInfo2 : ITypeInfo { HRESULT GetAllVarCustData(UINT, CUSTDATA*); HRESULT GetAllImplTypeCustData(UINT, CUSTDATA*); } -alias ITypeInfo2 LPTYPEINFO2; +alias LPTYPEINFO2 = ITypeInfo2; interface ITypeLib : IUnknown { UINT GetTypeInfoCount(); @@ -616,7 +616,7 @@ interface ITypeLib : IUnknown { HRESULT FindName(LPOLESTR, ULONG, ITypeInfo*, MEMBERID*, USHORT*); void ReleaseTLibAttr(TLIBATTR*); } -alias ITypeLib LPTYPELIB; +alias LPTYPELIB = ITypeLib; interface ITypeLib2 : ITypeLib { HRESULT GetCustData(REFGUID, VARIANT*); @@ -624,7 +624,7 @@ interface ITypeLib2 : ITypeLib { HRESULT GetDocumentation2(INT, LCID, BSTR*, DWORD*, BSTR*); HRESULT GetAllCustData(CUSTDATA*); } -alias ITypeLib2 LPTYPELIB2; +alias LPTYPELIB2 = ITypeLib2; interface IErrorInfo : IUnknown { HRESULT GetGUID(GUID*); @@ -633,7 +633,7 @@ interface IErrorInfo : IUnknown { HRESULT GetHelpFile(BSTR*); HRESULT GetHelpContext(DWORD*); } -alias IErrorInfo LPERRORINFO; +alias LPERRORINFO = IErrorInfo; interface ICreateErrorInfo : IUnknown { HRESULT SetGUID(REFGUID); @@ -642,12 +642,12 @@ interface ICreateErrorInfo : IUnknown { HRESULT SetHelpFile(LPOLESTR); HRESULT SetHelpContext(DWORD); } -alias ICreateErrorInfo LPCREATEERRORINFO; +alias LPCREATEERRORINFO = ICreateErrorInfo; interface ISupportErrorInfo : IUnknown { HRESULT InterfaceSupportsErrorInfo(REFIID); } -alias ISupportErrorInfo LPSUPPORTERRORINFO; +alias LPSUPPORTERRORINFO = ISupportErrorInfo; interface IRecordInfo : IUnknown { HRESULT RecordInit(PVOID); @@ -667,7 +667,7 @@ interface IRecordInfo : IUnknown { HRESULT RecordCreateCopy(PVOID, PVOID*); HRESULT RecordDestroy (PVOID); } -alias IRecordInfo LPRECORDINFO; +alias LPRECORDINFO = IRecordInfo; interface ITypeMarshal : IUnknown { HRESULT Size(PVOID, DWORD, PVOID, ULONG*); diff --git a/runtime/druntime/src/core/sys/windows/objbase.d b/runtime/druntime/src/core/sys/windows/objbase.d index 350c2b8839..5d63fa168c 100644 --- a/runtime/druntime/src/core/sys/windows/objbase.d +++ b/runtime/druntime/src/core/sys/windows/objbase.d @@ -87,8 +87,8 @@ extern (Windows) BOOL IsEqualGUID( REFGUID rguid2 ); -alias IsEqualGUID IsEqualIID; -alias IsEqualGUID IsEqualCLSID; +alias IsEqualIID = IsEqualGUID; +alias IsEqualCLSID = IsEqualGUID; enum COINIT { COINIT_APARTMENTTHREADED = 2, @@ -103,8 +103,8 @@ enum STDMSHLFLAGS { } extern(Windows) { - alias HRESULT function(REFCLSID, REFIID, PVOID*) LPFNGETCLASSOBJECT; - alias HRESULT function() LPFNCANUNLOADNOW; + alias LPFNGETCLASSOBJECT = HRESULT function(REFCLSID, REFIID, PVOID*); + alias LPFNCANUNLOADNOW = HRESULT function(); DWORD CoBuildVersion(); HRESULT CoInitialize(PVOID); diff --git a/runtime/druntime/src/core/sys/windows/objfwd.d b/runtime/druntime/src/core/sys/windows/objfwd.d index 076e02e608..1571775e4e 100644 --- a/runtime/druntime/src/core/sys/windows/objfwd.d +++ b/runtime/druntime/src/core/sys/windows/objfwd.d @@ -59,45 +59,45 @@ extern(Windows) { interface IRpcStubBuffer; } +/ -alias IMoniker LPMONIKER; -alias IStream LPSTREAM; -alias IMarshal LPMARSHAL; -alias IMalloc LPMALLOC; -alias IMallocSpy LPMALLOCSPY; -alias IMessageFilter LPMESSAGEFILTER; -alias IPersist LPPERSIST; -alias IPersistStream LPPERSISTSTREAM; -alias IRunningObjectTable LPRUNNINGOBJECTTABLE; -alias IBindCtx LPBINDCTX, LPBC; -alias IAdviseSink LPADVISESINK; -alias IAdviseSink2 LPADVISESINK2; -alias IDataObject LPDATAOBJECT; -alias IDataAdviseHolder LPDATAADVISEHOLDER; -alias IEnumMoniker LPENUMMONIKER; -alias IEnumFORMATETC LPENUMFORMATETC; -alias IEnumSTATDATA LPENUMSTATDATA; -alias IEnumSTATSTG LPENUMSTATSTG; -alias IEnumSTATPROPSTG LPENUMSTATPROPSTG; -alias IEnumString LPENUMSTRING; -alias IEnumUnknown LPENUMUNKNOWN; -alias IStorage LPSTORAGE; -alias IPersistStorage LPPERSISTSTORAGE; -alias ILockBytes LPLOCKBYTES; -alias IStdMarshalInfo LPSTDMARSHALINFO; -alias IExternalConnection LPEXTERNALCONNECTION; -alias IRunnableObject LPRUNNABLEOBJECT; -alias IROTData LPROTDATA; -alias IPersistFile LPPERSISTFILE; -alias IRootStorage LPROOTSTORAGE; -alias IRpcChannelBuffer LPRPCCHANNELBUFFER; -alias IRpcProxyBuffer LPRPCPROXYBUFFER; -alias IRpcStubBuffer LPRPCSTUBBUFFER; -alias IPropertyStorage LPPROPERTYSTORAGE; -alias IEnumSTATPROPSETSTG LPENUMSTATPROPSETSTG; -alias IPropertySetStorage LPPROPERTYSETSTORAGE; -alias IClientSecurity LPCLIENTSECURITY; -alias IServerSecurity LPSERVERSECURITY; -alias IClassActivator LPCLASSACTIVATOR; -alias IFillLockBytes LPFILLLOCKBYTES; -alias IProgressNotify LPPROGRESSNOTIFY; -alias ILayoutStorage LPLAYOUTSTORAGE; +alias LPMONIKER = IMoniker; +alias LPSTREAM = IStream; +alias LPMARSHAL = IMarshal; +alias LPMALLOC = IMalloc; +alias LPMALLOCSPY = IMallocSpy; +alias LPMESSAGEFILTER = IMessageFilter; +alias LPPERSIST = IPersist; +alias LPPERSISTSTREAM = IPersistStream; +alias LPRUNNINGOBJECTTABLE = IRunningObjectTable; +alias LPBINDCTX = IBindCtx, LPBC = IBindCtx; +alias LPADVISESINK = IAdviseSink; +alias LPADVISESINK2 = IAdviseSink2; +alias LPDATAOBJECT = IDataObject; +alias LPDATAADVISEHOLDER = IDataAdviseHolder; +alias LPENUMMONIKER = IEnumMoniker; +alias LPENUMFORMATETC = IEnumFORMATETC; +alias LPENUMSTATDATA = IEnumSTATDATA; +alias LPENUMSTATSTG = IEnumSTATSTG; +alias LPENUMSTATPROPSTG = IEnumSTATPROPSTG; +alias LPENUMSTRING = IEnumString; +alias LPENUMUNKNOWN = IEnumUnknown; +alias LPSTORAGE = IStorage; +alias LPPERSISTSTORAGE = IPersistStorage; +alias LPLOCKBYTES = ILockBytes; +alias LPSTDMARSHALINFO = IStdMarshalInfo; +alias LPEXTERNALCONNECTION = IExternalConnection; +alias LPRUNNABLEOBJECT = IRunnableObject; +alias LPROTDATA = IROTData; +alias LPPERSISTFILE = IPersistFile; +alias LPROOTSTORAGE = IRootStorage; +alias LPRPCCHANNELBUFFER = IRpcChannelBuffer; +alias LPRPCPROXYBUFFER = IRpcProxyBuffer; +alias LPRPCSTUBBUFFER = IRpcStubBuffer; +alias LPPROPERTYSTORAGE = IPropertyStorage; +alias LPENUMSTATPROPSETSTG = IEnumSTATPROPSETSTG; +alias LPPROPERTYSETSTORAGE = IPropertySetStorage; +alias LPCLIENTSECURITY = IClientSecurity; +alias LPSERVERSECURITY = IServerSecurity; +alias LPCLASSACTIVATOR = IClassActivator; +alias LPFILLLOCKBYTES = IFillLockBytes; +alias LPPROGRESSNOTIFY = IProgressNotify; +alias LPLAYOUTSTORAGE = ILayoutStorage; diff --git a/runtime/druntime/src/core/sys/windows/objidl.d b/runtime/druntime/src/core/sys/windows/objidl.d index aa51840a51..ab656c20ce 100644 --- a/runtime/druntime/src/core/sys/windows/objidl.d +++ b/runtime/druntime/src/core/sys/windows/objidl.d @@ -54,7 +54,7 @@ struct INTERFACEINFO { IID iid; WORD wMethod; } -alias INTERFACEINFO* LPINTERFACEINFO; +alias LPINTERFACEINFO = INTERFACEINFO*; enum CALLTYPE { CALLTYPE_TOPLEVEL = 1, @@ -75,14 +75,14 @@ enum PENDINGMSG { PENDINGMSG_WAITDEFPROCESS } -alias OLECHAR** SNB; +alias SNB = OLECHAR**; enum DATADIR { DATADIR_GET = 1, DATADIR_SET } -alias WORD CLIPFORMAT; -alias CLIPFORMAT* LPCLIPFORMAT; +alias CLIPFORMAT = WORD; +alias LPCLIPFORMAT = CLIPFORMAT*; struct DVTARGETDEVICE { DWORD tdSize; @@ -100,7 +100,7 @@ struct FORMATETC { LONG lindex; DWORD tymed; } -alias FORMATETC* LPFORMATETC; +alias LPFORMATETC = FORMATETC*; struct RemSTGMEDIUM { DWORD tymed; @@ -177,7 +177,7 @@ struct BIND_OPTS { DWORD grfMode; DWORD dwTickCountDeadline; } -alias BIND_OPTS* LPBIND_OPTS; +alias LPBIND_OPTS = BIND_OPTS*; struct BIND_OPTS2 { DWORD cbStruct; @@ -189,7 +189,7 @@ struct BIND_OPTS2 { LCID locale; COSERVERINFO* pServerInfo; } -alias BIND_OPTS2* LPBIND_OPTS2; +alias LPBIND_OPTS2 = BIND_OPTS2*; enum BIND_FLAGS { BIND_MAYBOTHERUSER = 1, @@ -209,7 +209,7 @@ struct STGMEDIUM { } LPUNKNOWN pUnkForRelease; } -alias STGMEDIUM* LPSTGMEDIUM; +alias LPSTGMEDIUM = STGMEDIUM*; enum LOCKTYPE { LOCK_WRITE = 1, @@ -217,7 +217,7 @@ enum LOCKTYPE { LOCK_ONLYONCE = 4 } -alias uint RPCOLEDATAREP; +alias RPCOLEDATAREP = uint; struct RPCOLEMESSAGE { PVOID reserved1; @@ -228,7 +228,7 @@ struct RPCOLEMESSAGE { PVOID[5] reserved2; ULONG rpcFlags; } -alias RPCOLEMESSAGE* PRPCOLEMESSAGE; +alias PRPCOLEMESSAGE = RPCOLEMESSAGE*; enum MKSYS { MKSYS_NONE, @@ -378,7 +378,7 @@ struct CACLSID { ULONG cElems; CLSID* pElems; } -alias PROPVARIANT* LPPROPVARIANT; +alias LPPROPVARIANT = PROPVARIANT*; struct CAPROPVARIANT { ULONG cElems; @@ -791,7 +791,7 @@ interface IPSFactoryBuffer : IUnknown { HRESULT CreateProxy(LPUNKNOWN, REFIID, LPRPCPROXYBUFFER*, PVOID*); HRESULT CreateStub(REFIID, LPUNKNOWN, LPRPCSTUBBUFFER*); } -alias IPSFactoryBuffer LPPSFACTORYBUFFER; +alias LPPSFACTORYBUFFER = IPSFactoryBuffer; interface ILockBytes : IUnknown { HRESULT ReadAt(ULARGE_INTEGER, PVOID, ULONG, ULONG*); diff --git a/runtime/druntime/src/core/sys/windows/ocidl.d b/runtime/druntime/src/core/sys/windows/ocidl.d index 9bacbf0f34..b1cc0dea9e 100644 --- a/runtime/druntime/src/core/sys/windows/ocidl.d +++ b/runtime/druntime/src/core/sys/windows/ocidl.d @@ -41,18 +41,18 @@ interface IBindHost : IUnknown //[Yes] #ifndef OLE2ANSI -alias TEXTMETRICW TEXTMETRICOLE; +alias TEXTMETRICOLE = TEXTMETRICW; //} else { //alias TEXTMETRIC TEXTMETRICOLE; //} -alias TEXTMETRICOLE* LPTEXTMETRICOLE; +alias LPTEXTMETRICOLE = TEXTMETRICOLE*; -alias DWORD OLE_COLOR; -alias UINT OLE_HANDLE; -alias int OLE_XPOS_HIMETRIC; -alias int OLE_YPOS_HIMETRIC; -alias int OLE_XSIZE_HIMETRIC; -alias int OLE_YSIZE_HIMETRIC; +alias OLE_COLOR = DWORD; +alias OLE_HANDLE = UINT; +alias OLE_XPOS_HIMETRIC = int; +alias OLE_YPOS_HIMETRIC = int; +alias OLE_XSIZE_HIMETRIC = int; +alias OLE_YSIZE_HIMETRIC = int; enum READYSTATE { READYSTATE_UNINITIALIZED = 0, @@ -124,7 +124,7 @@ struct POINTF { float x; float y; } -alias POINTF* LPPOINTF; +alias LPPOINTF = POINTF*; struct CONTROLINFO { ULONG cb; @@ -132,38 +132,38 @@ struct CONTROLINFO { USHORT cAccel; DWORD dwFlags; } -alias CONTROLINFO* LPCONTROLINFO; +alias LPCONTROLINFO = CONTROLINFO*; struct CONNECTDATA { LPUNKNOWN pUnk; DWORD dwCookie; } -alias CONNECTDATA* LPCONNECTDATA; +alias LPCONNECTDATA = CONNECTDATA*; struct LICINFO { int cbLicInfo; BOOL fRuntimeKeyAvail; BOOL fLicVerified; } -alias LICINFO* LPLICINFO; +alias LPLICINFO = LICINFO*; struct CAUUID { ULONG cElems; GUID* pElems; } -alias CAUUID* LPCAUUID; +alias LPCAUUID = CAUUID*; struct CALPOLESTR { ULONG cElems; LPOLESTR* pElems; } -alias CALPOLESTR* LPCALPOLESTR; +alias LPCALPOLESTR = CALPOLESTR*; struct CADWORD { ULONG cElems; DWORD* pElems; } -alias CADWORD* LPCADWORD; +alias LPCADWORD = CADWORD*; struct PROPPAGEINFO { ULONG cb; @@ -173,7 +173,7 @@ struct PROPPAGEINFO { LPOLESTR pszHelpFile; DWORD dwHelpContext; } -alias PROPPAGEINFO* LPPROPPAGEINFO; +alias LPPROPPAGEINFO = PROPPAGEINFO*; interface IOleControl : IUnknown { HRESULT GetControlInfo(LPCONTROLINFO); @@ -200,13 +200,13 @@ interface ISimpleFrameSite : IUnknown { interface IErrorLog : IUnknown { HRESULT AddError(LPCOLESTR, LPEXCEPINFO); } -alias IErrorLog LPERRORLOG; +alias LPERRORLOG = IErrorLog; interface IPropertyBag : IUnknown { HRESULT Read(LPCOLESTR, LPVARIANT, LPERRORLOG); HRESULT Write(LPCOLESTR, LPVARIANT); } -alias IPropertyBag LPPROPERTYBAG; +alias LPPROPERTYBAG = IPropertyBag; interface IPropertyBag2 : IUnknown { HRESULT Read(ULONG, PROPBAG2*, LPERRORLOG, VARIANT*, HRESULT*); @@ -215,7 +215,7 @@ interface IPropertyBag2 : IUnknown { HRESULT GetPropertyInfo(ULONG, ULONG, PROPBAG2*, ULONG*); HRESULT LoadObject(LPCOLESTR, DWORD, IUnknown, LPERRORLOG); } -alias IPropertyBag2 LPPROPERTYBAG2; +alias LPPROPERTYBAG2 = IPropertyBag2; interface IPersistPropertyBag : IPersist { HRESULT InitNew(); @@ -270,7 +270,7 @@ interface IEnumConnectionPoints : IUnknown { HRESULT Reset(); HRESULT Clone(LPENUMCONNECTIONPOINTS*); } -alias IEnumConnectionPoints LPENUMCONNECTIONPOINTS; +alias LPENUMCONNECTIONPOINTS = IEnumConnectionPoints; interface IConnectionPoint : IUnknown { HRESULT GetConnectionInterface(IID*); @@ -279,7 +279,7 @@ interface IConnectionPoint : IUnknown { HRESULT Unadvise(DWORD); HRESULT EnumConnections(LPENUMCONNECTIONS*); } -alias IConnectionPoint LPCONNECTIONPOINT; +alias LPCONNECTIONPOINT = IConnectionPoint; interface IEnumConnections : IUnknown { HRESULT Next(ULONG, LPCONNECTDATA, PULONG); @@ -287,7 +287,7 @@ interface IEnumConnections : IUnknown { HRESULT Reset(); HRESULT Clone(LPENUMCONNECTIONS*); } -alias IEnumConnections LPENUMCONNECTIONS; +alias LPENUMCONNECTIONS = IEnumConnections; interface IClassFactory2 : IClassFactory { HRESULT GetLicInfo(LPLICINFO); @@ -312,7 +312,7 @@ interface IPropertyPageSite : IUnknown { HRESULT GetPageContainer(LPUNKNOWN*); HRESULT TranslateAccelerator(LPMSG); } -alias IPropertyPageSite LPPROPERTYPAGESITE; +alias LPPROPERTYPAGESITE = IPropertyPageSite; interface IPropertyPage : IUnknown { HRESULT SetPageSite(LPPROPERTYPAGESITE); @@ -359,11 +359,11 @@ interface IFont : IUnknown { HRESULT ReleaseHfont(HFONT); HRESULT SetHdc(HDC); } -alias IFont LPFONT; +alias LPFONT = IFont; interface IFontDisp : IDispatch { } -alias IFontDisp LPFONTDISP; +alias LPFONTDISP = IFontDisp; interface IPicture : IUnknown { HRESULT get_Handle(OLE_HANDLE*); @@ -463,7 +463,7 @@ interface IOleUndoManager : IUnknown { HRESULT GetLastRedoDescription(BSTR*); HRESULT Enable(BOOL); } -alias IOleUndoManager LPOLEUNDOMANAGER; +alias LPOLEUNDOMANAGER = IOleUndoManager; interface IQuickActivate : IUnknown { HRESULT QuickActivate(QACONTAINER*, QACONTROL*); diff --git a/runtime/druntime/src/core/sys/windows/odbcinst.d b/runtime/druntime/src/core/sys/windows/odbcinst.d index ebacb5889f..6120aaf5f1 100644 --- a/runtime/druntime/src/core/sys/windows/odbcinst.d +++ b/runtime/druntime/src/core/sys/windows/odbcinst.d @@ -142,27 +142,27 @@ static if (ODBCVER >= 0x0300) { } version (Unicode) { - alias SQLConfigDataSourceW SQLConfigDataSource; - alias SQLConfigDriverW SQLConfigDriver; - alias SQLCreateDataSourceW SQLCreateDataSource; - alias SQLGetAvailableDriversW SQLGetAvailableDrivers; - alias SQLGetInstalledDriversW SQLGetInstalledDrivers; - alias SQLGetPrivateProfileStringW SQLGetPrivateProfileString; - alias SQLGetTranslatorW SQLGetTranslator; - alias SQLInstallDriverW SQLInstallDriver; - alias SQLInstallDriverExW SQLInstallDriverEx; - alias SQLInstallDriverManagerW SQLInstallDriverManager; - alias SQLInstallerErrorW SQLInstallerError; - alias SQLInstallODBCW SQLInstallODBC; - deprecated alias SQLInstallTranslatorW SQLInstallTranslator; - alias SQLInstallTranslatorExW SQLInstallTranslatorEx; - alias SQLPostInstallerErrorW SQLPostInstallerError; - alias SQLReadFileDSNW SQLReadFileDSN; - alias SQLRemoveDriverW SQLRemoveDriver; - alias SQLRemoveDSNFromIniW SQLRemoveDSNFromIni; - alias SQLRemoveTranslatorW SQLRemoveTranslator; - alias SQLValidDSNW SQLValidDSN; - alias SQLWriteDSNToIniW SQLWriteDSNToIni; - alias SQLWriteFileDSNW SQLWriteFileDSN; - alias SQLWritePrivateProfileStringW SQLWritePrivateProfileString; + alias SQLConfigDataSource = SQLConfigDataSourceW; + alias SQLConfigDriver = SQLConfigDriverW; + alias SQLCreateDataSource = SQLCreateDataSourceW; + alias SQLGetAvailableDrivers = SQLGetAvailableDriversW; + alias SQLGetInstalledDrivers = SQLGetInstalledDriversW; + alias SQLGetPrivateProfileString = SQLGetPrivateProfileStringW; + alias SQLGetTranslator = SQLGetTranslatorW; + alias SQLInstallDriver = SQLInstallDriverW; + alias SQLInstallDriverEx = SQLInstallDriverExW; + alias SQLInstallDriverManager = SQLInstallDriverManagerW; + alias SQLInstallerError = SQLInstallerErrorW; + alias SQLInstallODBC = SQLInstallODBCW; + deprecated alias SQLInstallTranslator = SQLInstallTranslatorW; + alias SQLInstallTranslatorEx = SQLInstallTranslatorExW; + alias SQLPostInstallerError = SQLPostInstallerErrorW; + alias SQLReadFileDSN = SQLReadFileDSNW; + alias SQLRemoveDriver = SQLRemoveDriverW; + alias SQLRemoveDSNFromIni = SQLRemoveDSNFromIniW; + alias SQLRemoveTranslator = SQLRemoveTranslatorW; + alias SQLValidDSN = SQLValidDSNW; + alias SQLWriteDSNToIni = SQLWriteDSNToIniW; + alias SQLWriteFileDSN = SQLWriteFileDSNW; + alias SQLWritePrivateProfileString = SQLWritePrivateProfileStringW; } diff --git a/runtime/druntime/src/core/sys/windows/ole.d b/runtime/druntime/src/core/sys/windows/ole.d index 7c51d7a1be..c5eb17d9f0 100644 --- a/runtime/druntime/src/core/sys/windows/ole.d +++ b/runtime/druntime/src/core/sys/windows/ole.d @@ -13,7 +13,7 @@ pragma(lib, "ole32"); import core.sys.windows.windef, core.sys.windows.wingdi, core.sys.windows.uuid; -alias LPCSTR OLE_LPCSTR; +alias OLE_LPCSTR = LPCSTR; /+#define LRESULT LONG #define HGLOBAL HANDLE+/ @@ -40,7 +40,7 @@ struct OLETARGETDEVICE { BYTE _otdData; BYTE* otdData() return { return &_otdData; } } -alias OLETARGETDEVICE* LPOLETARGETDEVICE; +alias LPOLETARGETDEVICE = OLETARGETDEVICE*; enum OLESTATUS { OLE_OK, @@ -144,7 +144,7 @@ enum OLEOPT_RENDER { olerender_format } -alias WORD OLECLIPFORMAT; +alias OLECLIPFORMAT = WORD; enum OLEOPT_UPDATE { oleupdate_always, @@ -156,7 +156,7 @@ enum OLEOPT_UPDATE { } alias HOBJECT = HANDLE; -alias LONG_PTR LHSERVER, LHCLIENTDOC, LHSERVERDOC; +alias LHSERVER = LONG_PTR, LHCLIENTDOC = LONG_PTR, LHSERVERDOC = LONG_PTR; struct OLEOBJECTVTBL { extern (Windows) { @@ -207,36 +207,36 @@ struct OLEOBJECTVTBL { //#endif } } -alias OLEOBJECTVTBL* LPOLEOBJECTVTBL; +alias LPOLEOBJECTVTBL = OLEOBJECTVTBL*; //#ifndef OLE_INTERNAL struct OLEOBJECT { LPOLEOBJECTVTBL lpvtbl; } -alias OLEOBJECT* LPOLEOBJECT; +alias LPOLEOBJECT = OLEOBJECT*; //#endif struct OLECLIENTVTBL { extern (Windows) int function(LPOLECLIENT, OLE_NOTIFICATION, LPOLEOBJECT) CallBack; } -alias OLECLIENTVTBL* LPOLECLIENTVTBL; +alias LPOLECLIENTVTBL = OLECLIENTVTBL*; struct OLECLIENT { LPOLECLIENTVTBL lpvtbl; } -alias OLECLIENT* LPOLECLIENT; +alias LPOLECLIENT = OLECLIENT*; struct OLESTREAMVTBL { extern (Windows): DWORD function(LPOLESTREAM, void*, DWORD) Get; DWORD function(LPOLESTREAM, void*, DWORD) Put; } -alias OLESTREAMVTBL* LPOLESTREAMVTBL; +alias LPOLESTREAMVTBL = OLESTREAMVTBL*; struct OLESTREAM { LPOLESTREAMVTBL lpstbl; } -alias OLESTREAM* LPOLESTREAM; +alias LPOLESTREAM = OLESTREAM*; enum OLE_SERVER_USE { OLE_SERVER_MULTI, @@ -257,12 +257,12 @@ struct OLESERVERVTBL { OLESTATUS function(LPOLESERVER) Release; OLESTATUS function(LPOLESERVER, HGLOBAL) Execute; } -alias OLESERVERVTBL* LPOLESERVERVTBL; +alias LPOLESERVERVTBL = OLESERVERVTBL*; struct OLESERVER { LPOLESERVERVTBL lpvtbl; } -alias OLESERVER* LPOLESERVER; +alias LPOLESERVER = OLESERVER*; struct OLESERVERDOCVTBL { extern (Windows): @@ -276,12 +276,12 @@ extern (Windows): OLESTATUS function(LPOLESERVERDOC, LOGPALETTE*) SetColorScheme; OLESTATUS function(LPOLESERVERDOC, HGLOBAL) Execute; } -alias OLESERVERDOCVTBL* LPOLESERVERDOCVTBL; +alias LPOLESERVERDOCVTBL = OLESERVERDOCVTBL*; struct OLESERVERDOC { LPOLESERVERDOCVTBL lpvtbl; } -alias OLESERVERDOC* LPOLESERVERDOC; +alias LPOLESERVERDOC = OLESERVERDOC*; extern (Windows) nothrow @nogc { OLESTATUS OleDelete(LPOLEOBJECT); diff --git a/runtime/druntime/src/core/sys/windows/ole2.d b/runtime/druntime/src/core/sys/windows/ole2.d index fcbbc8a3d2..71ec1f9382 100644 --- a/runtime/druntime/src/core/sys/windows/ole2.d +++ b/runtime/druntime/src/core/sys/windows/ole2.d @@ -38,7 +38,7 @@ align(8): struct OLESTREAM { LPOLESTREAMVTBL lpstbl; } -alias OLESTREAM* LPOLESTREAM; +alias LPOLESTREAM = OLESTREAM*; extern (Windows) { struct OLESTREAMVTBL { @@ -46,7 +46,7 @@ extern (Windows) { DWORD function (LPOLESTREAM, const(void)*, DWORD) Put; } } -alias OLESTREAMVTBL* LPOLESTREAMVTBL; +alias LPOLESTREAMVTBL = OLESTREAMVTBL*; extern (Windows) nothrow @nogc { HRESULT CreateDataAdviseHolder(LPDATAADVISEHOLDER*); diff --git a/runtime/druntime/src/core/sys/windows/oleacc.d b/runtime/druntime/src/core/sys/windows/oleacc.d index 8a97a93e34..1e2bbfe95f 100644 --- a/runtime/druntime/src/core/sys/windows/oleacc.d +++ b/runtime/druntime/src/core/sys/windows/oleacc.d @@ -184,7 +184,7 @@ interface IAccessible : IDispatch { HRESULT put_accValue(VARIANT, BSTR); } -alias IAccessible LPACCESSIBLE; +alias LPACCESSIBLE = IAccessible; extern (Windows) nothrow @nogc { HRESULT AccessibleChildren(IAccessible, LONG, LONG, VARIANT*, LONG*); @@ -206,11 +206,11 @@ extern (Windows) nothrow @nogc { } version (Unicode) { - alias CreateStdAccessibleProxyW CreateStdAccessibleProxy; - alias GetRoleTextW GetRoleText; - alias GetStateTextW GetStateText; + alias CreateStdAccessibleProxy = CreateStdAccessibleProxyW; + alias GetRoleText = GetRoleTextW; + alias GetStateText = GetStateTextW; } else { - alias CreateStdAccessibleProxyA CreateStdAccessibleProxy; - alias GetRoleTextA GetRoleText; - alias GetStateTextA GetStateText; + alias CreateStdAccessibleProxy = CreateStdAccessibleProxyA; + alias GetRoleText = GetRoleTextA; + alias GetStateText = GetStateTextA; } diff --git a/runtime/druntime/src/core/sys/windows/oleauto.d b/runtime/druntime/src/core/sys/windows/oleauto.d index cc7b937a03..53b24fafd3 100644 --- a/runtime/druntime/src/core/sys/windows/oleauto.d +++ b/runtime/druntime/src/core/sys/windows/oleauto.d @@ -175,7 +175,7 @@ struct PARAMDATA{ OLECHAR* szName; VARTYPE vt; } -alias PARAMDATA* LPPARAMDATA; +alias LPPARAMDATA = PARAMDATA*; struct METHODDATA{ OLECHAR* szName; @@ -187,13 +187,13 @@ struct METHODDATA{ WORD wFlags; VARTYPE vtReturn; } -alias METHODDATA* LPMETHODDATA; +alias LPMETHODDATA = METHODDATA*; struct INTERFACEDATA{ METHODDATA* pmethdata; UINT cMembers; } -alias INTERFACEDATA* LPINTERFACEDATA; +alias LPINTERFACEDATA = INTERFACEDATA*; struct UDATE { SYSTEMTIME st; @@ -220,10 +220,10 @@ deprecated { // not actually deprecated, but they aren't converted yet. interface ICreateTypeLib {} interface ICreateTypeLib2 {} - alias ICreateTypeInfo LPCREATETYPEINFO; - alias ICreateTypeInfo2 LPCREATETYPEINFO2; - alias ICreateTypeLib LPCREATETYPELIB; - alias ICreateTypeLib2 LPCREATETYPELIB2; + alias LPCREATETYPEINFO = ICreateTypeInfo; + alias LPCREATETYPEINFO2 = ICreateTypeInfo2; + alias LPCREATETYPELIB = ICreateTypeLib; + alias LPCREATETYPELIB2 = ICreateTypeLib2; } extern (Windows) nothrow @nogc { diff --git a/runtime/druntime/src/core/sys/windows/olectl.d b/runtime/druntime/src/core/sys/windows/olectl.d index df8266b142..9aae47d37a 100644 --- a/runtime/druntime/src/core/sys/windows/olectl.d +++ b/runtime/druntime/src/core/sys/windows/olectl.d @@ -291,35 +291,35 @@ enum { DISPID_PICT_RENDER // = 6 } -alias IOleControl LPOLECONTROL; -alias IOleControlSite LPOLECONTROLSITE; -alias ISimpleFrameSite LPSIMPLEFRAMESITE; -alias IPersistPropertyBag LPPERSISTPROPERTYBAG; -alias IPersistStreamInit LPPERSISTSTREAMINIT; -alias IPersistMemory LPPERSISTMEMORY; -alias IPropertyNotifySink LPPROPERTYNOTIFYSINK; -alias IProvideClassInfo LPPROVIDECLASSINFO; -alias IProvideClassInfo2 LPPROVIDECLASSINFO2; -alias IConnectionPointContainer LPCONNECTIONPOINTCONTAINER; -alias IClassFactory2 LPCLASSFACTORY2; -alias ISpecifyPropertyPages LPSPECIFYPROPERTYPAGES; -alias IPerPropertyBrowsing LPPERPROPERTYBROWSING; -alias IPropertyPage LPPROPERTYPAGE; -alias IPropertyPage2 LPPROPERTYPAGE2; - -alias IPicture LPPICTURE; -alias IPictureDisp LPPICTUREDISP; -alias int OLE_XPOS_PIXELS; -alias int OLE_YPOS_PIXELS; -alias int OLE_XSIZE_PIXELS; -alias int OLE_YSIZE_PIXELS; -alias float OLE_XPOS_CONTAINER; -alias float OLE_YPOS_CONTAINER; -alias float OLE_XSIZE_CONTAINER; - -alias VARIANT_BOOL OLE_OPTEXCLUSIVE; -alias VARIANT_BOOL OLE_CANCELBOOL; -alias VARIANT_BOOL OLE_ENABLEDEFAULTBOOL; +alias LPOLECONTROL = IOleControl; +alias LPOLECONTROLSITE = IOleControlSite; +alias LPSIMPLEFRAMESITE = ISimpleFrameSite; +alias LPPERSISTPROPERTYBAG = IPersistPropertyBag; +alias LPPERSISTSTREAMINIT = IPersistStreamInit; +alias LPPERSISTMEMORY = IPersistMemory; +alias LPPROPERTYNOTIFYSINK = IPropertyNotifySink; +alias LPPROVIDECLASSINFO = IProvideClassInfo; +alias LPPROVIDECLASSINFO2 = IProvideClassInfo2; +alias LPCONNECTIONPOINTCONTAINER = IConnectionPointContainer; +alias LPCLASSFACTORY2 = IClassFactory2; +alias LPSPECIFYPROPERTYPAGES = ISpecifyPropertyPages; +alias LPPERPROPERTYBROWSING = IPerPropertyBrowsing; +alias LPPROPERTYPAGE = IPropertyPage; +alias LPPROPERTYPAGE2 = IPropertyPage2; + +alias LPPICTURE = IPicture; +alias LPPICTUREDISP = IPictureDisp; +alias OLE_XPOS_PIXELS = int; +alias OLE_YPOS_PIXELS = int; +alias OLE_XSIZE_PIXELS = int; +alias OLE_YSIZE_PIXELS = int; +alias OLE_XPOS_CONTAINER = float; +alias OLE_YPOS_CONTAINER = float; +alias OLE_XSIZE_CONTAINER = float; + +alias OLE_OPTEXCLUSIVE = VARIANT_BOOL; +alias OLE_CANCELBOOL = VARIANT_BOOL; +alias OLE_ENABLEDEFAULTBOOL = VARIANT_BOOL; align(8): @@ -342,7 +342,7 @@ struct OCPFIPARAMS { LCID lcid; DISPID dispidInitialProperty; } -alias OCPFIPARAMS* LPOCPFIPARAMS; +alias LPOCPFIPARAMS = OCPFIPARAMS*; struct FONTDESC { UINT cbSizeofstruct; @@ -354,7 +354,7 @@ struct FONTDESC { BOOL fUnderline; BOOL fStrikethrough; } -alias FONTDESC* LPFONTDESC; +alias LPFONTDESC = FONTDESC*; struct PICTDESC { @@ -382,7 +382,7 @@ struct PICTDESC _emf emf; } } -alias PICTDESC* LPPICTDESC; +alias LPPICTDESC = PICTDESC*; extern(Windows) { HRESULT DllRegisterServer(); diff --git a/runtime/druntime/src/core/sys/windows/oledlg.d b/runtime/druntime/src/core/sys/windows/oledlg.d index 26e0a79160..486291c1ef 100644 --- a/runtime/druntime/src/core/sys/windows/oledlg.d +++ b/runtime/druntime/src/core/sys/windows/oledlg.d @@ -332,7 +332,7 @@ enum VPF_DISABLESCALE=4; align(8): extern (Windows) { - alias UINT function(HWND, UINT, WPARAM, LPARAM) LPFNOLEUIHOOK; + alias LPFNOLEUIHOOK = UINT function(HWND, UINT, WPARAM, LPARAM); } struct OLEUIINSERTOBJECTW { @@ -359,7 +359,7 @@ struct OLEUIINSERTOBJECTW { SCODE sc; HGLOBAL hMetaPict; } -alias OLEUIINSERTOBJECTW* POLEUIINSERTOBJECTW, LPOLEUIINSERTOBJECTW; +alias POLEUIINSERTOBJECTW = OLEUIINSERTOBJECTW*, LPOLEUIINSERTOBJECTW = OLEUIINSERTOBJECTW*; struct OLEUIINSERTOBJECTA { DWORD cbStruct; @@ -385,7 +385,7 @@ struct OLEUIINSERTOBJECTA { SCODE sc; HGLOBAL hMetaPict; } -alias OLEUIINSERTOBJECTA* POLEUIINSERTOBJECTA, LPOLEUIINSERTOBJECTA; +alias POLEUIINSERTOBJECTA = OLEUIINSERTOBJECTA*, LPOLEUIINSERTOBJECTA = OLEUIINSERTOBJECTA*; extern (Windows) nothrow @nogc { UINT OleUIInsertObjectW(LPOLEUIINSERTOBJECTW); @@ -414,7 +414,7 @@ struct OLEUIPASTEENTRYW { DWORD dwFlags; DWORD dwScratchSpace; } -alias OLEUIPASTEENTRYW* POLEUIPASTEENTRYW, LPOLEUIPASTEENTRYW; +alias POLEUIPASTEENTRYW = OLEUIPASTEENTRYW*, LPOLEUIPASTEENTRYW = OLEUIPASTEENTRYW*; struct OLEUIPASTEENTRYA { FORMATETC fmtetc; @@ -423,7 +423,7 @@ struct OLEUIPASTEENTRYA { DWORD dwFlags; DWORD dwScratchSpace; } -alias OLEUIPASTEENTRYA* POLEUIPASTEENTRYA, LPOLEUIPASTEENTRYA; +alias POLEUIPASTEENTRYA = OLEUIPASTEENTRYA*, LPOLEUIPASTEENTRYA = OLEUIPASTEENTRYA*; struct OLEUIPASTESPECIALW { DWORD cbStruct; @@ -447,7 +447,7 @@ struct OLEUIPASTESPECIALW { HGLOBAL hMetaPict; SIZEL sizel; } -alias OLEUIPASTESPECIALW* POLEUIPASTESPECIALW, LPOLEUIPASTESPECIALW; +alias POLEUIPASTESPECIALW = OLEUIPASTESPECIALW*, LPOLEUIPASTESPECIALW = OLEUIPASTESPECIALW*; struct OLEUIPASTESPECIALA { DWORD cbStruct; @@ -471,7 +471,7 @@ struct OLEUIPASTESPECIALA { HGLOBAL hMetaPict; SIZEL sizel; } -alias OLEUIPASTESPECIALA* POLEUIPASTESPECIALA, LPOLEUIPASTESPECIALA; +alias POLEUIPASTESPECIALA = OLEUIPASTESPECIALA*, LPOLEUIPASTESPECIALA = OLEUIPASTESPECIALA*; interface IOleUILinkContainerW : IUnknown { @@ -487,7 +487,7 @@ interface IOleUILinkContainerW : IUnknown HRESULT UpdateLink(DWORD, BOOL, BOOL); HRESULT CancelLink(DWORD); } -alias IOleUILinkContainerW LPOLEUILINKCONTAINERW; +alias LPOLEUILINKCONTAINERW = IOleUILinkContainerW; interface IOleUILinkContainerA : IUnknown { @@ -503,7 +503,7 @@ interface IOleUILinkContainerA : IUnknown HRESULT UpdateLink(DWORD, BOOL, BOOL); HRESULT CancelLink(DWORD); } -alias IOleUILinkContainerA LPOLEUILINKCONTAINERA; +alias LPOLEUILINKCONTAINERA = IOleUILinkContainerA; struct OLEUIEDITLINKSW { DWORD cbStruct; @@ -517,7 +517,7 @@ struct OLEUIEDITLINKSW { HRSRC hResource; LPOLEUILINKCONTAINERW lpOleUILinkContainer; } -alias OLEUIEDITLINKSW* POLEUIEDITLINKSW, LPOLEUIEDITLINKSW; +alias POLEUIEDITLINKSW = OLEUIEDITLINKSW*, LPOLEUIEDITLINKSW = OLEUIEDITLINKSW*; struct OLEUIEDITLINKSA { DWORD cbStruct; @@ -531,7 +531,7 @@ struct OLEUIEDITLINKSA { HRSRC hResource; LPOLEUILINKCONTAINERA lpOleUILinkContainer; } -alias OLEUIEDITLINKSA* POLEUIEDITLINKSA, LPOLEUIEDITLINKSA; +alias POLEUIEDITLINKSA = OLEUIEDITLINKSA*, LPOLEUIEDITLINKSA = OLEUIEDITLINKSA*; struct OLEUICHANGEICONW { DWORD cbStruct; @@ -548,7 +548,7 @@ struct OLEUICHANGEICONW { WCHAR[MAX_PATH] szIconExe = 0; int cchIconExe; } -alias OLEUICHANGEICONW* POLEUICHANGEICONW, LPOLEUICHANGEICONW; +alias POLEUICHANGEICONW = OLEUICHANGEICONW*, LPOLEUICHANGEICONW = OLEUICHANGEICONW*; struct OLEUICHANGEICONA { DWORD cbStruct; @@ -565,7 +565,7 @@ struct OLEUICHANGEICONA { CHAR[MAX_PATH] szIconExe = 0; int cchIconExe; } -alias OLEUICHANGEICONA* POLEUICHANGEICONA, LPOLEUICHANGEICONA; +alias POLEUICHANGEICONA = OLEUICHANGEICONA*, LPOLEUICHANGEICONA = OLEUICHANGEICONA*; struct OLEUICONVERTW { DWORD cbStruct; @@ -591,7 +591,7 @@ struct OLEUICONVERTW { UINT cClsidExclude; LPCLSID lpClsidExclude; } -alias OLEUICONVERTW* POLEUICONVERTW, LPOLEUICONVERTW; +alias POLEUICONVERTW = OLEUICONVERTW*, LPOLEUICONVERTW = OLEUICONVERTW*; struct OLEUICONVERTA { DWORD cbStruct; @@ -617,7 +617,7 @@ struct OLEUICONVERTA { UINT cClsidExclude; LPCLSID lpClsidExclude; } -alias OLEUICONVERTA* POLEUICONVERTA, LPOLEUICONVERTA; +alias POLEUICONVERTA = OLEUICONVERTA*, LPOLEUICONVERTA = OLEUICONVERTA*; struct OLEUIBUSYW { DWORD cbStruct; @@ -632,7 +632,7 @@ struct OLEUIBUSYW { HTASK hTask; HWND *lphWndDialog; } -alias OLEUIBUSYW* POLEUIBUSYW, LPOLEUIBUSYW; +alias POLEUIBUSYW = OLEUIBUSYW*, LPOLEUIBUSYW = OLEUIBUSYW*; struct OLEUIBUSYA { DWORD cbStruct; @@ -647,7 +647,7 @@ struct OLEUIBUSYA { HTASK hTask; HWND *lphWndDialog; } -alias OLEUIBUSYA* POLEUIBUSYA, LPOLEUIBUSYA; +alias POLEUIBUSYA = OLEUIBUSYA*, LPOLEUIBUSYA = OLEUIBUSYA*; struct OLEUICHANGESOURCEW { DWORD cbStruct; @@ -668,7 +668,7 @@ struct OLEUICHANGESOURCEW { LPWSTR lpszFrom; LPWSTR lpszTo; } -alias OLEUICHANGESOURCEW* POLEUICHANGESOURCEW, LPOLEUICHANGESOURCEW; +alias POLEUICHANGESOURCEW = OLEUICHANGESOURCEW*, LPOLEUICHANGESOURCEW = OLEUICHANGESOURCEW*; struct OLEUICHANGESOURCEA { DWORD cbStruct; @@ -689,7 +689,7 @@ struct OLEUICHANGESOURCEA { LPSTR lpszFrom; LPSTR lpszTo; } -alias OLEUICHANGESOURCEA* POLEUICHANGESOURCEA, LPOLEUICHANGESOURCEA; +alias POLEUICHANGESOURCEA = OLEUICHANGESOURCEA*, LPOLEUICHANGESOURCEA = OLEUICHANGESOURCEA*; interface IOleUIObjInfoW : IUnknown { @@ -702,7 +702,7 @@ interface IOleUIObjInfoW : IUnknown HRESULT GetViewInfo(DWORD, HGLOBAL*, PDWORD, int*); HRESULT SetViewInfo(DWORD, HGLOBAL, DWORD, int, BOOL); } -alias IOleUIObjInfoW LPOLEUIOBJINFOW; +alias LPOLEUIOBJINFOW = IOleUIObjInfoW; interface IOleUIObjInfoA : IUnknown { @@ -715,7 +715,7 @@ interface IOleUIObjInfoA : IUnknown HRESULT GetViewInfo(DWORD, HGLOBAL*, PDWORD, int*); HRESULT SetViewInfo(DWORD, HGLOBAL, DWORD, int, BOOL); } -alias IOleUIObjInfoA LPOLEUIOBJINFOA; +alias LPOLEUIOBJINFOA = IOleUIObjInfoA; interface IOleUILinkInfoW : IOleUILinkContainerW { @@ -732,7 +732,7 @@ interface IOleUILinkInfoW : IOleUILinkContainerW HRESULT CancelLink(DWORD); HRESULT GetLastUpdate(DWORD, FILETIME*); } -alias IOleUILinkInfoW LPOLEUILINKINFOW; +alias LPOLEUILINKINFOW = IOleUILinkInfoW; interface IOleUILinkInfoA : IOleUILinkContainerA { @@ -749,7 +749,7 @@ interface IOleUILinkInfoA : IOleUILinkContainerA HRESULT CancelLink(DWORD); HRESULT GetLastUpdate(DWORD, FILETIME*); } -alias IOleUILinkInfoA LPOLEUILINKINFOA; +alias LPOLEUILINKINFOA = IOleUILinkInfoA; struct OLEUIGNRLPROPSW { DWORD cbStruct; @@ -760,7 +760,7 @@ struct OLEUIGNRLPROPSW { DWORD[3] dwReserved2; OLEUIOBJECTPROPSW* lpOP; } -alias OLEUIGNRLPROPSW* POLEUIGNRLPROPSW, LPOLEUIGNRLPROPSW; +alias POLEUIGNRLPROPSW = OLEUIGNRLPROPSW*, LPOLEUIGNRLPROPSW = OLEUIGNRLPROPSW*; struct OLEUIGNRLPROPSA { DWORD cbStruct; @@ -771,7 +771,7 @@ struct OLEUIGNRLPROPSA { DWORD[3] dwReserved2; OLEUIOBJECTPROPSA* lpOP; } -alias OLEUIGNRLPROPSA* POLEUIGNRLPROPSA, LPOLEUIGNRLPROPSA; +alias POLEUIGNRLPROPSA = OLEUIGNRLPROPSA*, LPOLEUIGNRLPROPSA = OLEUIGNRLPROPSA*; struct OLEUIVIEWPROPSW { DWORD cbStruct; @@ -784,7 +784,7 @@ struct OLEUIVIEWPROPSW { int nScaleMin; int nScaleMax; } -alias OLEUIVIEWPROPSW* POLEUIVIEWPROPSW, LPOLEUIVIEWPROPSW; +alias POLEUIVIEWPROPSW = OLEUIVIEWPROPSW*, LPOLEUIVIEWPROPSW = OLEUIVIEWPROPSW*; struct OLEUIVIEWPROPSA { DWORD cbStruct; @@ -797,7 +797,7 @@ struct OLEUIVIEWPROPSA { int nScaleMin; int nScaleMax; } -alias OLEUIVIEWPROPSA* POLEUIVIEWPROPSA, LPOLEUIVIEWPROPSA; +alias POLEUIVIEWPROPSA = OLEUIVIEWPROPSA*, LPOLEUIVIEWPROPSA = OLEUIVIEWPROPSA*; struct OLEUILINKPROPSW { DWORD cbStruct; @@ -808,7 +808,7 @@ struct OLEUILINKPROPSW { DWORD[3] dwReserved2; OLEUIOBJECTPROPSW *lpOP; } -alias OLEUILINKPROPSW* POLEUILINKPROPSW, LPOLEUILINKPROPSW; +alias POLEUILINKPROPSW = OLEUILINKPROPSW*, LPOLEUILINKPROPSW = OLEUILINKPROPSW*; struct OLEUILINKPROPSA { DWORD cbStruct; @@ -819,7 +819,7 @@ struct OLEUILINKPROPSA { DWORD[3] dwReserved2; OLEUIOBJECTPROPSA* lpOP; } -alias OLEUILINKPROPSA* POLEUILINKPROPSA, LPOLEUILINKPROPSA; +alias POLEUILINKPROPSA = OLEUILINKPROPSA*, LPOLEUILINKPROPSA = OLEUILINKPROPSA*; struct OLEUIOBJECTPROPSW { DWORD cbStruct; @@ -833,7 +833,7 @@ struct OLEUIOBJECTPROPSW { LPOLEUIVIEWPROPSW lpVP; LPOLEUILINKPROPSW lpLP; } -alias OLEUIOBJECTPROPSW* POLEUIOBJECTPROPSW, LPOLEUIOBJECTPROPSW; +alias POLEUIOBJECTPROPSW = OLEUIOBJECTPROPSW*, LPOLEUIOBJECTPROPSW = OLEUIOBJECTPROPSW*; struct OLEUIOBJECTPROPSA { DWORD cbStruct; @@ -847,7 +847,7 @@ struct OLEUIOBJECTPROPSA { LPOLEUIVIEWPROPSA lpVP; LPOLEUILINKPROPSA lpLP; } -alias OLEUIOBJECTPROPSA* POLEUIOBJECTPROPSA, LPOLEUIOBJECTPROPSA; +alias POLEUIOBJECTPROPSA = OLEUIOBJECTPROPSA*, LPOLEUIOBJECTPROPSA = OLEUIOBJECTPROPSA*; extern (Windows) nothrow @nogc { BOOL OleUIAddVerbMenuW(LPOLEOBJECT, LPCWSTR, HMENU, UINT, UINT, UINT, BOOL, UINT, HMENU*); @@ -877,117 +877,117 @@ extern (C) { } version (Unicode) { - alias IDD_SERVERNOTREGW IDD_SERVERNOTREG; - alias IDD_LINKTYPECHANGEDW IDD_LINKTYPECHANGED; - alias OleUIUpdateLinksW OleUIUpdateLinks; - alias OleUIAddVerbMenuW OleUIAddVerbMenu; - alias OLEUIOBJECTPROPSW OLEUIOBJECTPROPS; - alias POLEUIOBJECTPROPSW POLEUIOBJECTPROPS; - alias LPOLEUIOBJECTPROPSW LPOLEUIOBJECTPROPS; - alias OleUIObjectPropertiesW OleUIObjectProperties; - alias OLEUIINSERTOBJECTW OLEUIINSERTOBJECT; - alias POLEUIINSERTOBJECTW POLEUIINSERTOBJECT; - alias LPOLEUIINSERTOBJECTW LPOLEUIINSERTOBJECT; - alias OleUIInsertObjectW OleUIInsertObject; - alias OleUIPromptUserW OleUIPromptUser; - alias OLEUIPASTEENTRYW OLEUIPASTEENTRY; - alias POLEUIPASTEENTRYW POLEUIPASTEENTRY; - alias LPOLEUIPASTEENTRYW LPOLEUIPASTEENTRY; - alias OLEUIPASTESPECIALW OLEUIPASTESPECIAL; - alias POLEUIPASTESPECIALW POLEUIPASTESPECIAL; - alias LPOLEUIPASTESPECIALW LPOLEUIPASTESPECIAL; - alias OleUIPasteSpecialW OleUIPasteSpecial; - alias IOleUILinkContainerW IOleUILinkContainer; - alias LPOLEUILINKCONTAINERW LPOLEUILINKCONTAINER; - alias OLEUIEDITLINKSW OLEUIEDITLINKS; - alias POLEUIEDITLINKSW POLEUIEDITLINKS; - alias LPOLEUIEDITLINKSW LPOLEUIEDITLINKS; - alias OleUIEditLinksW OleUIEditLinks; - alias OLEUICHANGEICONW OLEUICHANGEICON; - alias POLEUICHANGEICONW POLEUICHANGEICON; - alias LPOLEUICHANGEICONW LPOLEUICHANGEICON; - alias OleUIChangeIconW OleUIChangeIcon; - alias OLEUICONVERTW OLEUICONVERT; - alias POLEUICONVERTW POLEUICONVERT; - alias LPOLEUICONVERTW LPOLEUICONVERT; - alias OleUIConvertW OleUIConvert; - alias OLEUIBUSYW OLEUIBUSY; - alias POLEUIBUSYW POLEUIBUSY; - alias LPOLEUIBUSYW LPOLEUIBUSY; - alias OleUIBusyW OleUIBusy; - alias OLEUICHANGESOURCEW OLEUICHANGESOURCE; - alias POLEUICHANGESOURCEW POLEUICHANGESOURCE; - alias LPOLEUICHANGESOURCEW LPOLEUICHANGESOURCE; - alias OleUIChangeSourceW OleUIChangeSource; - alias IOleUIObjInfoW IOleUIObjInfo; - alias LPOLEUIOBJINFOW LPOLEUIOBJINFO; - alias IOleUILinkInfoW IOleUILinkInfo; + alias IDD_SERVERNOTREG = IDD_SERVERNOTREGW; + alias IDD_LINKTYPECHANGED = IDD_LINKTYPECHANGEDW; + alias OleUIUpdateLinks = OleUIUpdateLinksW; + alias OleUIAddVerbMenu = OleUIAddVerbMenuW; + alias OLEUIOBJECTPROPS = OLEUIOBJECTPROPSW; + alias POLEUIOBJECTPROPS = POLEUIOBJECTPROPSW; + alias LPOLEUIOBJECTPROPS = LPOLEUIOBJECTPROPSW; + alias OleUIObjectProperties = OleUIObjectPropertiesW; + alias OLEUIINSERTOBJECT = OLEUIINSERTOBJECTW; + alias POLEUIINSERTOBJECT = POLEUIINSERTOBJECTW; + alias LPOLEUIINSERTOBJECT = LPOLEUIINSERTOBJECTW; + alias OleUIInsertObject = OleUIInsertObjectW; + alias OleUIPromptUser = OleUIPromptUserW; + alias OLEUIPASTEENTRY = OLEUIPASTEENTRYW; + alias POLEUIPASTEENTRY = POLEUIPASTEENTRYW; + alias LPOLEUIPASTEENTRY = LPOLEUIPASTEENTRYW; + alias OLEUIPASTESPECIAL = OLEUIPASTESPECIALW; + alias POLEUIPASTESPECIAL = POLEUIPASTESPECIALW; + alias LPOLEUIPASTESPECIAL = LPOLEUIPASTESPECIALW; + alias OleUIPasteSpecial = OleUIPasteSpecialW; + alias IOleUILinkContainer = IOleUILinkContainerW; + alias LPOLEUILINKCONTAINER = LPOLEUILINKCONTAINERW; + alias OLEUIEDITLINKS = OLEUIEDITLINKSW; + alias POLEUIEDITLINKS = POLEUIEDITLINKSW; + alias LPOLEUIEDITLINKS = LPOLEUIEDITLINKSW; + alias OleUIEditLinks = OleUIEditLinksW; + alias OLEUICHANGEICON = OLEUICHANGEICONW; + alias POLEUICHANGEICON = POLEUICHANGEICONW; + alias LPOLEUICHANGEICON = LPOLEUICHANGEICONW; + alias OleUIChangeIcon = OleUIChangeIconW; + alias OLEUICONVERT = OLEUICONVERTW; + alias POLEUICONVERT = POLEUICONVERTW; + alias LPOLEUICONVERT = LPOLEUICONVERTW; + alias OleUIConvert = OleUIConvertW; + alias OLEUIBUSY = OLEUIBUSYW; + alias POLEUIBUSY = POLEUIBUSYW; + alias LPOLEUIBUSY = LPOLEUIBUSYW; + alias OleUIBusy = OleUIBusyW; + alias OLEUICHANGESOURCE = OLEUICHANGESOURCEW; + alias POLEUICHANGESOURCE = POLEUICHANGESOURCEW; + alias LPOLEUICHANGESOURCE = LPOLEUICHANGESOURCEW; + alias OleUIChangeSource = OleUIChangeSourceW; + alias IOleUIObjInfo = IOleUIObjInfoW; + alias LPOLEUIOBJINFO = LPOLEUIOBJINFOW; + alias IOleUILinkInfo = IOleUILinkInfoW; //alias IOleUILinkInfoWVtbl IOleUILinkInfoVtbl; - alias LPOLEUILINKINFOW LPOLEUILINKINFO; - alias OLEUIGNRLPROPSW OLEUIGNRLPROPS; - alias POLEUIGNRLPROPSW POLEUIGNRLPROPS; - alias LPOLEUIGNRLPROPSW LPOLEUIGNRLPROPS; - alias OLEUIVIEWPROPSW OLEUIVIEWPROPS; - alias POLEUIVIEWPROPSW POLEUIVIEWPROPS; - alias LPOLEUIVIEWPROPSW LPOLEUIVIEWPROPS; - alias OLEUILINKPROPSW OLEUILINKPROPS; - alias POLEUILINKPROPSW POLEUILINKPROPS; - alias LPOLEUILINKPROPSW LPOLEUILINKPROPS; + alias LPOLEUILINKINFO = LPOLEUILINKINFOW; + alias OLEUIGNRLPROPS = OLEUIGNRLPROPSW; + alias POLEUIGNRLPROPS = POLEUIGNRLPROPSW; + alias LPOLEUIGNRLPROPS = LPOLEUIGNRLPROPSW; + alias OLEUIVIEWPROPS = OLEUIVIEWPROPSW; + alias POLEUIVIEWPROPS = POLEUIVIEWPROPSW; + alias LPOLEUIVIEWPROPS = LPOLEUIVIEWPROPSW; + alias OLEUILINKPROPS = OLEUILINKPROPSW; + alias POLEUILINKPROPS = POLEUILINKPROPSW; + alias LPOLEUILINKPROPS = LPOLEUILINKPROPSW; } else { - alias IDD_SERVERNOTREGA IDD_SERVERNOTREG; - alias IDD_LINKTYPECHANGEDA IDD_LINKTYPECHANGED; - alias OleUIUpdateLinksA OleUIUpdateLinks; - alias OleUIAddVerbMenuA OleUIAddVerbMenu; - alias OLEUIOBJECTPROPSA OLEUIOBJECTPROPS; - alias POLEUIOBJECTPROPSA POLEUIOBJECTPROPS; - alias LPOLEUIOBJECTPROPSA LPOLEUIOBJECTPROPS; - alias OleUIObjectPropertiesA OleUIObjectProperties; - alias OLEUIINSERTOBJECTA OLEUIINSERTOBJECT; - alias POLEUIINSERTOBJECTA POLEUIINSERTOBJECT; - alias LPOLEUIINSERTOBJECTA LPOLEUIINSERTOBJECT; - alias OleUIInsertObjectA OleUIInsertObject; - alias OleUIPromptUserA OleUIPromptUser; - alias OLEUIPASTEENTRYA OLEUIPASTEENTRY; - alias POLEUIPASTEENTRYA POLEUIPASTEENTRY; - alias LPOLEUIPASTEENTRYA LPOLEUIPASTEENTRY; - alias OLEUIPASTESPECIALA OLEUIPASTESPECIAL; - alias POLEUIPASTESPECIALA POLEUIPASTESPECIAL; - alias LPOLEUIPASTESPECIALA LPOLEUIPASTESPECIAL; - alias OleUIPasteSpecialA OleUIPasteSpecial; - alias IOleUILinkContainerA IOleUILinkContainer; - alias LPOLEUILINKCONTAINERA LPOLEUILINKCONTAINER; - alias OLEUIEDITLINKSA OLEUIEDITLINKS; - alias POLEUIEDITLINKSA POLEUIEDITLINKS; - alias LPOLEUIEDITLINKSA LPOLEUIEDITLINKS; - alias OleUIEditLinksA OleUIEditLinks; - alias OLEUICHANGEICONA OLEUICHANGEICON; - alias POLEUICHANGEICONA POLEUICHANGEICON; - alias LPOLEUICHANGEICONA LPOLEUICHANGEICON; - alias OleUIChangeIconA OleUIChangeIcon; - alias OLEUICONVERTA OLEUICONVERT; - alias POLEUICONVERTA POLEUICONVERT; - alias LPOLEUICONVERTA LPOLEUICONVERT; - alias OleUIConvertA OleUIConvert; - alias OLEUIBUSYA OLEUIBUSY; - alias POLEUIBUSYA POLEUIBUSY; - alias LPOLEUIBUSYA LPOLEUIBUSY; - alias OleUIBusyA OleUIBusy; - alias OLEUICHANGESOURCEA OLEUICHANGESOURCE; - alias POLEUICHANGESOURCEA POLEUICHANGESOURCE; - alias LPOLEUICHANGESOURCEA LPOLEUICHANGESOURCE; - alias OleUIChangeSourceA OleUIChangeSource; - alias IOleUIObjInfoA IOleUIObjInfo; - alias LPOLEUIOBJINFOA LPOLEUIOBJINFO; - alias IOleUILinkInfoA IOleUILinkInfo; + alias IDD_SERVERNOTREG = IDD_SERVERNOTREGA; + alias IDD_LINKTYPECHANGED = IDD_LINKTYPECHANGEDA; + alias OleUIUpdateLinks = OleUIUpdateLinksA; + alias OleUIAddVerbMenu = OleUIAddVerbMenuA; + alias OLEUIOBJECTPROPS = OLEUIOBJECTPROPSA; + alias POLEUIOBJECTPROPS = POLEUIOBJECTPROPSA; + alias LPOLEUIOBJECTPROPS = LPOLEUIOBJECTPROPSA; + alias OleUIObjectProperties = OleUIObjectPropertiesA; + alias OLEUIINSERTOBJECT = OLEUIINSERTOBJECTA; + alias POLEUIINSERTOBJECT = POLEUIINSERTOBJECTA; + alias LPOLEUIINSERTOBJECT = LPOLEUIINSERTOBJECTA; + alias OleUIInsertObject = OleUIInsertObjectA; + alias OleUIPromptUser = OleUIPromptUserA; + alias OLEUIPASTEENTRY = OLEUIPASTEENTRYA; + alias POLEUIPASTEENTRY = POLEUIPASTEENTRYA; + alias LPOLEUIPASTEENTRY = LPOLEUIPASTEENTRYA; + alias OLEUIPASTESPECIAL = OLEUIPASTESPECIALA; + alias POLEUIPASTESPECIAL = POLEUIPASTESPECIALA; + alias LPOLEUIPASTESPECIAL = LPOLEUIPASTESPECIALA; + alias OleUIPasteSpecial = OleUIPasteSpecialA; + alias IOleUILinkContainer = IOleUILinkContainerA; + alias LPOLEUILINKCONTAINER = LPOLEUILINKCONTAINERA; + alias OLEUIEDITLINKS = OLEUIEDITLINKSA; + alias POLEUIEDITLINKS = POLEUIEDITLINKSA; + alias LPOLEUIEDITLINKS = LPOLEUIEDITLINKSA; + alias OleUIEditLinks = OleUIEditLinksA; + alias OLEUICHANGEICON = OLEUICHANGEICONA; + alias POLEUICHANGEICON = POLEUICHANGEICONA; + alias LPOLEUICHANGEICON = LPOLEUICHANGEICONA; + alias OleUIChangeIcon = OleUIChangeIconA; + alias OLEUICONVERT = OLEUICONVERTA; + alias POLEUICONVERT = POLEUICONVERTA; + alias LPOLEUICONVERT = LPOLEUICONVERTA; + alias OleUIConvert = OleUIConvertA; + alias OLEUIBUSY = OLEUIBUSYA; + alias POLEUIBUSY = POLEUIBUSYA; + alias LPOLEUIBUSY = LPOLEUIBUSYA; + alias OleUIBusy = OleUIBusyA; + alias OLEUICHANGESOURCE = OLEUICHANGESOURCEA; + alias POLEUICHANGESOURCE = POLEUICHANGESOURCEA; + alias LPOLEUICHANGESOURCE = LPOLEUICHANGESOURCEA; + alias OleUIChangeSource = OleUIChangeSourceA; + alias IOleUIObjInfo = IOleUIObjInfoA; + alias LPOLEUIOBJINFO = LPOLEUIOBJINFOA; + alias IOleUILinkInfo = IOleUILinkInfoA; //alias IOleUILinkInfoAVtbl IOleUILinkInfoVtbl; - alias LPOLEUILINKINFOA LPOLEUILINKINFO; - alias OLEUIGNRLPROPSA OLEUIGNRLPROPS; - alias POLEUIGNRLPROPSA POLEUIGNRLPROPS; - alias LPOLEUIGNRLPROPSA LPOLEUIGNRLPROPS; - alias OLEUIVIEWPROPSA OLEUIVIEWPROPS; - alias POLEUIVIEWPROPSA POLEUIVIEWPROPS; - alias LPOLEUIVIEWPROPSA LPOLEUIVIEWPROPS; - alias OLEUILINKPROPSA OLEUILINKPROPS; - alias POLEUILINKPROPSA POLEUILINKPROPS; - alias LPOLEUILINKPROPSA LPOLEUILINKPROPS; + alias LPOLEUILINKINFO = LPOLEUILINKINFOA; + alias OLEUIGNRLPROPS = OLEUIGNRLPROPSA; + alias POLEUIGNRLPROPS = POLEUIGNRLPROPSA; + alias LPOLEUIGNRLPROPS = LPOLEUIGNRLPROPSA; + alias OLEUIVIEWPROPS = OLEUIVIEWPROPSA; + alias POLEUIVIEWPROPS = POLEUIVIEWPROPSA; + alias LPOLEUIVIEWPROPS = LPOLEUIVIEWPROPSA; + alias OLEUILINKPROPS = OLEUILINKPROPSA; + alias POLEUILINKPROPS = POLEUILINKPROPSA; + alias LPOLEUILINKPROPS = LPOLEUILINKPROPSA; } diff --git a/runtime/druntime/src/core/sys/windows/oleidl.d b/runtime/druntime/src/core/sys/windows/oleidl.d index 17e1d647b3..fdd320b2ac 100644 --- a/runtime/druntime/src/core/sys/windows/oleidl.d +++ b/runtime/druntime/src/core/sys/windows/oleidl.d @@ -56,9 +56,9 @@ enum DROPEFFECT { struct OLEMENUGROUPWIDTHS { LONG[6] width; } -alias OLEMENUGROUPWIDTHS* LPOLEMENUGROUPWIDTHS; +alias LPOLEMENUGROUPWIDTHS = OLEMENUGROUPWIDTHS*; -alias HGLOBAL HOLEMENU; +alias HOLEMENU = HGLOBAL; enum OLECLOSE { OLECLOSE_SAVEIFDIRTY, @@ -72,11 +72,11 @@ struct OLEVERB { DWORD fuFlags; DWORD grfAttribs; } -alias OLEVERB* LPOLEVERB; +alias LPOLEVERB = OLEVERB*; -alias RECT BORDERWIDTHS; -alias LPRECT LPBORDERWIDTHS; -alias LPCRECT LPCBORDERWIDTHS; +alias BORDERWIDTHS = RECT; +alias LPBORDERWIDTHS = LPRECT; +alias LPCBORDERWIDTHS = LPCRECT; struct OLEINPLACEFRAMEINFO { UINT cb; @@ -85,7 +85,7 @@ struct OLEINPLACEFRAMEINFO { HACCEL haccel; UINT cAccelEntries; } -alias OLEINPLACEFRAMEINFO* LPOLEINPLACEFRAMEINFO; +alias LPOLEINPLACEFRAMEINFO = OLEINPLACEFRAMEINFO*; interface IEnumOLEVERB : IUnknown { @@ -95,19 +95,19 @@ interface IEnumOLEVERB : IUnknown HRESULT Clone(IEnumOLEVERB*); } //alias IEnumOLEVERB IEnumOleVerb; -alias IEnumOLEVERB LPENUMOLEVERB; +alias LPENUMOLEVERB = IEnumOLEVERB; interface IParseDisplayName : IUnknown { HRESULT ParseDisplayName(IBindCtx,LPOLESTR,ULONG*,IMoniker*); } -alias IParseDisplayName LPPARSEDISPLAYNAME; +alias LPPARSEDISPLAYNAME = IParseDisplayName; interface IOleContainer : IParseDisplayName { HRESULT EnumObjects(DWORD,IEnumUnknown*); HRESULT LockContainer(BOOL); } -alias IOleContainer LPOLECONTAINER; +alias LPOLECONTAINER = IOleContainer; interface IOleItemContainer : IOleContainer { HRESULT GetObject(LPOLESTR,DWORD,IBindCtx,REFIID,void**); @@ -124,7 +124,7 @@ interface IOleClientSite : IUnknown { HRESULT OnShowWindow(BOOL); HRESULT RequestNewObjectLayout(); } -alias IOleClientSite LPOLECLIENTSITE; +alias LPOLECLIENTSITE = IOleClientSite; interface IOleObject : IUnknown { HRESULT SetClientSite(LPOLECLIENTSITE); @@ -149,13 +149,13 @@ interface IOleObject : IUnknown { HRESULT GetMiscStatus(DWORD,PDWORD); HRESULT SetColorScheme(LPLOGPALETTE); } -alias IOleObject LPOLEOBJECT; +alias LPOLEOBJECT = IOleObject; interface IOleWindow : IUnknown { HRESULT GetWindow(HWND*); HRESULT ContextSensitiveHelp(BOOL); } -alias IOleWindow LPOLEWINDOW; +alias LPOLEWINDOW = IOleWindow; interface IOleInPlaceUIWindow : IOleWindow { HRESULT GetBorder(LPRECT); @@ -163,7 +163,7 @@ interface IOleInPlaceUIWindow : IOleWindow { HRESULT SetBorderSpace(LPCBORDERWIDTHS); HRESULT SetActiveObject(LPOLEINPLACEACTIVEOBJECT,LPCOLESTR); } -alias IOleInPlaceUIWindow LPOLEINPLACEUIWINDOW; +alias LPOLEINPLACEUIWINDOW = IOleInPlaceUIWindow; interface IOleInPlaceObject : IOleWindow { HRESULT InPlaceDeactivate(); @@ -180,7 +180,7 @@ interface IOleInPlaceActiveObject : IOleWindow { HRESULT ResizeBorder(LPCRECT,LPOLEINPLACEUIWINDOW,BOOL); HRESULT EnableModeless(BOOL); } -alias IOleInPlaceActiveObject LPOLEINPLACEACTIVEOBJECT; +alias LPOLEINPLACEACTIVEOBJECT = IOleInPlaceActiveObject; interface IOleInPlaceFrame : IOleInPlaceUIWindow { HRESULT InsertMenus(HMENU,LPOLEMENUGROUPWIDTHS); @@ -190,7 +190,7 @@ interface IOleInPlaceFrame : IOleInPlaceUIWindow { HRESULT EnableModeless(BOOL); HRESULT TranslateAccelerator(LPMSG,WORD); } -alias IOleInPlaceFrame LPOLEINPLACEFRAME; +alias LPOLEINPLACEFRAME = IOleInPlaceFrame; interface IOleInPlaceSite : IOleWindow { HRESULT CanInPlaceActivate(); @@ -213,13 +213,13 @@ interface IOleAdviseHolder : IUnknown { HRESULT SendOnSave(); HRESULT SendOnClose(); } -alias IOleAdviseHolder LPOLEADVISEHOLDER; +alias LPOLEADVISEHOLDER = IOleAdviseHolder; interface IDropSource : IUnknown { HRESULT QueryContinueDrag(BOOL,DWORD); HRESULT GiveFeedback(DWORD); } -alias IDropSource LPDROPSOURCE; +alias LPDROPSOURCE = IDropSource; interface IDropTarget : IUnknown { HRESULT DragEnter(LPDATAOBJECT,DWORD,POINTL,PDWORD); @@ -227,10 +227,10 @@ interface IDropTarget : IUnknown { HRESULT DragLeave(); HRESULT Drop(LPDATAOBJECT,DWORD,POINTL,PDWORD); } -alias IDropTarget LPDROPTARGET; +alias LPDROPTARGET = IDropTarget; extern (Windows) { - alias BOOL function(ULONG_PTR) __IView_pfncont; + alias __IView_pfncont = BOOL function(ULONG_PTR); } interface IViewObject : IUnknown { @@ -241,12 +241,12 @@ interface IViewObject : IUnknown { HRESULT SetAdvise(DWORD,DWORD,IAdviseSink); HRESULT GetAdvise(PDWORD,PDWORD,IAdviseSink*); } -alias IViewObject LPVIEWOBJECT; +alias LPVIEWOBJECT = IViewObject; interface IViewObject2 : IViewObject { HRESULT GetExtent(DWORD,LONG,DVTARGETDEVICE*,LPSIZEL); } -alias IViewObject2 LPVIEWOBJECT2; +alias LPVIEWOBJECT2 = IViewObject2; interface IOleCache : IUnknown { HRESULT Cache(FORMATETC*,DWORD,DWORD*); @@ -255,16 +255,16 @@ interface IOleCache : IUnknown { HRESULT InitCache(LPDATAOBJECT); HRESULT SetData(FORMATETC*,STGMEDIUM*,BOOL); } -alias IOleCache LPOLECACHE; +alias LPOLECACHE = IOleCache; interface IOleCache2 : IOleCache { HRESULT UpdateCache(LPDATAOBJECT,DWORD,LPVOID); HRESULT DiscardCache(DWORD); } -alias IOleCache2 LPOLECACHE2; +alias LPOLECACHE2 = IOleCache2; interface IOleCacheControl : IUnknown { HRESULT OnRun(LPDATAOBJECT); HRESULT OnStop(); } -alias IOleCacheControl LPOLECACHECONTROL; +alias LPOLECACHECONTROL = IOleCacheControl; diff --git a/runtime/druntime/src/core/sys/windows/powrprof.d b/runtime/druntime/src/core/sys/windows/powrprof.d index be4d0aa2d2..5bc4131092 100644 --- a/runtime/druntime/src/core/sys/windows/powrprof.d +++ b/runtime/druntime/src/core/sys/windows/powrprof.d @@ -31,7 +31,7 @@ struct GLOBAL_MACHINE_POWER_POLICY { SYSTEM_POWER_STATE LidOpenWakeDc; ULONG BroadcastCapacityResolution; } -alias GLOBAL_MACHINE_POWER_POLICY* PGLOBAL_MACHINE_POWER_POLICY; +alias PGLOBAL_MACHINE_POWER_POLICY = GLOBAL_MACHINE_POWER_POLICY*; struct GLOBAL_USER_POWER_POLICY { ULONG Revision; @@ -44,13 +44,13 @@ struct GLOBAL_USER_POWER_POLICY { SYSTEM_POWER_LEVEL[NUM_DISCHARGE_POLICIES] DischargePolicy; ULONG GlobalFlags; } -alias GLOBAL_USER_POWER_POLICY* PGLOBAL_USER_POWER_POLICY; +alias PGLOBAL_USER_POWER_POLICY = GLOBAL_USER_POWER_POLICY*; struct GLOBAL_POWER_POLICY { GLOBAL_USER_POWER_POLICY user; GLOBAL_MACHINE_POWER_POLICY mach; } -alias GLOBAL_POWER_POLICY* PGLOBAL_POWER_POLICY; +alias PGLOBAL_POWER_POLICY = GLOBAL_POWER_POLICY*; struct MACHINE_POWER_POLICY { ULONG Revision; @@ -68,14 +68,14 @@ struct MACHINE_POWER_POLICY { POWER_ACTION_POLICY OverThrottledAc; POWER_ACTION_POLICY OverThrottledDc; } -alias MACHINE_POWER_POLICY* PMACHINE_POWER_POLICY; +alias PMACHINE_POWER_POLICY = MACHINE_POWER_POLICY*; struct MACHINE_PROCESSOR_POWER_POLICY { ULONG Revision; PROCESSOR_POWER_POLICY ProcessorPolicyAc; PROCESSOR_POWER_POLICY ProcessorPolicyDc; } -alias MACHINE_PROCESSOR_POWER_POLICY* PMACHINE_PROCESSOR_POWER_POLICY; +alias PMACHINE_PROCESSOR_POWER_POLICY = MACHINE_PROCESSOR_POWER_POLICY*; struct USER_POWER_POLICY { ULONG Revision; @@ -101,19 +101,18 @@ struct USER_POWER_POLICY { UCHAR ForcedThrottleAc; UCHAR ForcedThrottleDc; } -alias USER_POWER_POLICY* PUSER_POWER_POLICY; +alias PUSER_POWER_POLICY = USER_POWER_POLICY*; struct POWER_POLICY { USER_POWER_POLICY user; MACHINE_POWER_POLICY mach; } -alias POWER_POLICY* PPOWER_POLICY; +alias PPOWER_POLICY = POWER_POLICY*; extern (Windows) { - alias BOOLEAN function(UINT, DWORD, LPTSTR, DWORD, LPTSTR, PPOWER_POLICY, - LPARAM) PWRSCHEMESENUMPROC; - alias BOOLEAN function(POWER_ACTION, SYSTEM_POWER_STATE, ULONG, BOOLEAN) - PFNNTINITIATEPWRACTION; + alias PWRSCHEMESENUMPROC = BOOLEAN function(UINT, DWORD, LPTSTR, DWORD, LPTSTR, PPOWER_POLICY, + LPARAM); + alias PFNNTINITIATEPWRACTION = BOOLEAN function(POWER_ACTION, SYSTEM_POWER_STATE, ULONG, BOOLEAN); NTSTATUS CallNtPowerInformation(POWER_INFORMATION_LEVEL, PVOID, ULONG, PVOID, ULONG); diff --git a/runtime/druntime/src/core/sys/windows/prsht.d b/runtime/druntime/src/core/sys/windows/prsht.d index 570d1689b3..b3a7a2fd2f 100644 --- a/runtime/druntime/src/core/sys/windows/prsht.d +++ b/runtime/druntime/src/core/sys/windows/prsht.d @@ -190,9 +190,9 @@ enum { } extern (Windows) { - alias UINT function(HWND, UINT, LPPROPSHEETPAGEA) LPFNPSPCALLBACKA; - alias UINT function(HWND, UINT, LPPROPSHEETPAGEW) LPFNPSPCALLBACKW; - alias int function(HWND, UINT, LPARAM) PFNPROPSHEETCALLBACK; + alias LPFNPSPCALLBACKA = UINT function(HWND, UINT, LPPROPSHEETPAGEA); + alias LPFNPSPCALLBACKW = UINT function(HWND, UINT, LPPROPSHEETPAGEW); + alias PFNPROPSHEETCALLBACK = int function(HWND, UINT, LPARAM); } align(4): @@ -219,8 +219,8 @@ struct PROPSHEETPAGEA { LPCSTR pszHeaderSubTitle; } } -alias PROPSHEETPAGEA* LPPROPSHEETPAGEA; -alias const(PROPSHEETPAGEA)* LPCPROPSHEETPAGEA; +alias LPPROPSHEETPAGEA = PROPSHEETPAGEA*; +alias LPCPROPSHEETPAGEA = const(PROPSHEETPAGEA)*; struct PROPSHEETPAGEW { DWORD dwSize = PROPSHEETPAGEW.sizeof; @@ -244,8 +244,8 @@ struct PROPSHEETPAGEW { LPCWSTR pszHeaderSubTitle; } } -alias PROPSHEETPAGEW* LPPROPSHEETPAGEW; -alias const(PROPSHEETPAGEW)* LPCPROPSHEETPAGEW; +alias LPPROPSHEETPAGEW = PROPSHEETPAGEW*; +alias LPCPROPSHEETPAGEW = const(PROPSHEETPAGEW)*; alias HPROPSHEETPAGE = HANDLE; @@ -281,8 +281,8 @@ struct PROPSHEETHEADERA { } } } -alias PROPSHEETHEADERA* LPPROPSHEETHEADERA; -alias const(PROPSHEETHEADERA)* LPCPROPSHEETHEADERA; +alias LPPROPSHEETHEADERA = PROPSHEETHEADERA*; +alias LPCPROPSHEETHEADERA = const(PROPSHEETHEADERA)*; struct PROPSHEETHEADERW { DWORD dwSize = PROPSHEETHEADERW.sizeof; @@ -316,20 +316,19 @@ struct PROPSHEETHEADERW { } } } -alias PROPSHEETHEADERW* LPPROPSHEETHEADERW; -alias const(PROPSHEETHEADERW)* LPCPROPSHEETHEADERW; +alias LPPROPSHEETHEADERW = PROPSHEETHEADERW*; +alias LPCPROPSHEETHEADERW = const(PROPSHEETHEADERW)*; extern (Windows) { - alias BOOL function(HPROPSHEETPAGE, LPARAM) LPFNADDPROPSHEETPAGE; - alias BOOL function(LPVOID, LPFNADDPROPSHEETPAGE, LPARAM) - LPFNADDPROPSHEETPAGES; + alias LPFNADDPROPSHEETPAGE = BOOL function(HPROPSHEETPAGE, LPARAM); + alias LPFNADDPROPSHEETPAGES = BOOL function(LPVOID, LPFNADDPROPSHEETPAGE, LPARAM); } struct PSHNOTIFY { NMHDR hdr; LPARAM lParam; } -alias PSHNOTIFY* LPPSHNOTIFY; +alias LPPSHNOTIFY = PSHNOTIFY*; extern (Windows) nothrow @nogc { HPROPSHEETPAGE CreatePropertySheetPageA(LPCPROPSHEETPAGEA); @@ -340,29 +339,29 @@ extern (Windows) nothrow @nogc { } version (Unicode) { - alias LPFNPSPCALLBACKW LPFNPSPCALLBACK; - alias PROPSHEETPAGEW PROPSHEETPAGE; - alias LPPROPSHEETPAGEW LPPROPSHEETPAGE; - alias LPCPROPSHEETPAGEW LPCPROPSHEETPAGE; - alias PROPSHEETHEADERW PROPSHEETHEADER; - alias LPPROPSHEETHEADERW LPPROPSHEETHEADER; - alias LPCPROPSHEETHEADERW LPCPROPSHEETHEADER; - alias PSM_SETTITLEW PSM_SETTITLE; - alias PSM_SETFINISHTEXTW PSM_SETFINISHTEXT; - alias CreatePropertySheetPageW CreatePropertySheetPage; - alias PropertySheetW PropertySheet; + alias LPFNPSPCALLBACK = LPFNPSPCALLBACKW; + alias PROPSHEETPAGE = PROPSHEETPAGEW; + alias LPPROPSHEETPAGE = LPPROPSHEETPAGEW; + alias LPCPROPSHEETPAGE = LPCPROPSHEETPAGEW; + alias PROPSHEETHEADER = PROPSHEETHEADERW; + alias LPPROPSHEETHEADER = LPPROPSHEETHEADERW; + alias LPCPROPSHEETHEADER = LPCPROPSHEETHEADERW; + alias PSM_SETTITLE = PSM_SETTITLEW; + alias PSM_SETFINISHTEXT = PSM_SETFINISHTEXTW; + alias CreatePropertySheetPage = CreatePropertySheetPageW; + alias PropertySheet = PropertySheetW; } else { - alias LPFNPSPCALLBACKA LPFNPSPCALLBACK; - alias PROPSHEETPAGEA PROPSHEETPAGE; - alias LPPROPSHEETPAGEA LPPROPSHEETPAGE; - alias LPCPROPSHEETPAGEA LPCPROPSHEETPAGE; - alias PROPSHEETHEADERA PROPSHEETHEADER; - alias LPPROPSHEETHEADERA LPPROPSHEETHEADER; - alias LPCPROPSHEETHEADERA LPCPROPSHEETHEADER; - alias PSM_SETTITLEA PSM_SETTITLE; - alias PSM_SETFINISHTEXTA PSM_SETFINISHTEXT; - alias CreatePropertySheetPageA CreatePropertySheetPage; - alias PropertySheetA PropertySheet; + alias LPFNPSPCALLBACK = LPFNPSPCALLBACKA; + alias PROPSHEETPAGE = PROPSHEETPAGEA; + alias LPPROPSHEETPAGE = LPPROPSHEETPAGEA; + alias LPCPROPSHEETPAGE = LPCPROPSHEETPAGEA; + alias PROPSHEETHEADER = PROPSHEETHEADERA; + alias LPPROPSHEETHEADER = LPPROPSHEETHEADERA; + alias LPCPROPSHEETHEADER = LPCPROPSHEETHEADERA; + alias PSM_SETTITLE = PSM_SETTITLEA; + alias PSM_SETFINISHTEXT = PSM_SETFINISHTEXTA; + alias CreatePropertySheetPage = CreatePropertySheetPageA; + alias PropertySheet = PropertySheetA; } BOOL PropSheet_SetCurSel(HWND hPropSheetDlg, HPROPSHEETPAGE hpage, diff --git a/runtime/druntime/src/core/sys/windows/psapi.d b/runtime/druntime/src/core/sys/windows/psapi.d index 42fc5fdd6b..75f4f5c777 100644 --- a/runtime/druntime/src/core/sys/windows/psapi.d +++ b/runtime/druntime/src/core/sys/windows/psapi.d @@ -25,20 +25,20 @@ struct MODULEINFO { DWORD SizeOfImage; LPVOID EntryPoint; } -alias MODULEINFO* LPMODULEINFO; +alias LPMODULEINFO = MODULEINFO*; struct PSAPI_WS_WATCH_INFORMATION { LPVOID FaultingPc; LPVOID FaultingVa; } -alias PSAPI_WS_WATCH_INFORMATION* PPSAPI_WS_WATCH_INFORMATION; +alias PPSAPI_WS_WATCH_INFORMATION = PSAPI_WS_WATCH_INFORMATION*; struct PSAPI_WS_WATCH_INFORMATION_EX { PSAPI_WS_WATCH_INFORMATION BasicInfo; ULONG_PTR FaultingThreadId; ULONG_PTR Flags; } -alias PSAPI_WS_WATCH_INFORMATION_EX* PPSAPI_WS_WATCH_INFORMATION_EX; +alias PPSAPI_WS_WATCH_INFORMATION_EX = PSAPI_WS_WATCH_INFORMATION_EX*; struct PROCESS_MEMORY_COUNTERS { DWORD cb; @@ -52,7 +52,7 @@ struct PROCESS_MEMORY_COUNTERS { SIZE_T PagefileUsage; SIZE_T PeakPagefileUsage; } -alias PROCESS_MEMORY_COUNTERS* PPROCESS_MEMORY_COUNTERS; +alias PPROCESS_MEMORY_COUNTERS = PROCESS_MEMORY_COUNTERS*; struct PERFORMANCE_INFORMATION { DWORD cb; @@ -70,7 +70,7 @@ struct PERFORMANCE_INFORMATION { DWORD ProcessCount; DWORD ThreadCount; } -alias PERFORMANCE_INFORMATION* PPERFORMANCE_INFORMATION; +alias PPERFORMANCE_INFORMATION = PERFORMANCE_INFORMATION*; struct ENUM_PAGE_FILE_INFORMATION { DWORD cb; @@ -79,14 +79,12 @@ struct ENUM_PAGE_FILE_INFORMATION { SIZE_T TotalInUse; SIZE_T PeakUsage; } -alias ENUM_PAGE_FILE_INFORMATION* PENUM_PAGE_FILE_INFORMATION; +alias PENUM_PAGE_FILE_INFORMATION = ENUM_PAGE_FILE_INFORMATION*; /* application-defined callback function used with the EnumPageFiles() * http://windowssdk.msdn.microsoft.com/library/ms682627.aspx */ -alias BOOL function(LPVOID, PENUM_PAGE_FILE_INFORMATION, LPCWSTR) - PENUM_PAGE_FILE_CALLBACKW; -alias BOOL function(LPVOID, PENUM_PAGE_FILE_INFORMATION, LPCSTR) - PENUM_PAGE_FILE_CALLBACKA; +alias PENUM_PAGE_FILE_CALLBACKW = BOOL function(LPVOID, PENUM_PAGE_FILE_INFORMATION, LPCWSTR); +alias PENUM_PAGE_FILE_CALLBACKA = BOOL function(LPVOID, PENUM_PAGE_FILE_INFORMATION, LPCSTR); // Grouped by application, not in alphabetical order. @@ -140,21 +138,21 @@ extern (Windows) nothrow @nogc { } version (Unicode) { - alias PENUM_PAGE_FILE_CALLBACKW PENUM_PAGE_FILE_CALLBACK; - alias GetModuleBaseNameW GetModuleBaseName; - alias GetModuleFileNameExW GetModuleFileNameEx; - alias GetMappedFileNameW GetMappedFileName; - alias GetDeviceDriverBaseNameW GetDeviceDriverBaseName; - alias GetDeviceDriverFileNameW GetDeviceDriverFileName; - alias EnumPageFilesW EnumPageFiles; - alias GetProcessImageFileNameW GetProcessImageFileName; + alias PENUM_PAGE_FILE_CALLBACK = PENUM_PAGE_FILE_CALLBACKW; + alias GetModuleBaseName = GetModuleBaseNameW; + alias GetModuleFileNameEx = GetModuleFileNameExW; + alias GetMappedFileName = GetMappedFileNameW; + alias GetDeviceDriverBaseName = GetDeviceDriverBaseNameW; + alias GetDeviceDriverFileName = GetDeviceDriverFileNameW; + alias EnumPageFiles = EnumPageFilesW; + alias GetProcessImageFileName = GetProcessImageFileNameW; } else { - alias PENUM_PAGE_FILE_CALLBACKA PENUM_PAGE_FILE_CALLBACK; - alias GetModuleBaseNameA GetModuleBaseName; - alias GetModuleFileNameExA GetModuleFileNameEx; - alias GetMappedFileNameA GetMappedFileName; - alias GetDeviceDriverBaseNameA GetDeviceDriverBaseName; - alias GetDeviceDriverFileNameA GetDeviceDriverFileName; - alias EnumPageFilesA EnumPageFiles; - alias GetProcessImageFileNameA GetProcessImageFileName; + alias PENUM_PAGE_FILE_CALLBACK = PENUM_PAGE_FILE_CALLBACKA; + alias GetModuleBaseName = GetModuleBaseNameA; + alias GetModuleFileNameEx = GetModuleFileNameExA; + alias GetMappedFileName = GetMappedFileNameA; + alias GetDeviceDriverBaseName = GetDeviceDriverBaseNameA; + alias GetDeviceDriverFileName = GetDeviceDriverFileNameA; + alias EnumPageFiles = EnumPageFilesA; + alias GetProcessImageFileName = GetProcessImageFileNameA; } diff --git a/runtime/druntime/src/core/sys/windows/rapi.d b/runtime/druntime/src/core/sys/windows/rapi.d index 2fc640468b..86112313bb 100644 --- a/runtime/druntime/src/core/sys/windows/rapi.d +++ b/runtime/druntime/src/core/sys/windows/rapi.d @@ -30,7 +30,7 @@ interface IRAPIStream HRESULT GetRapiStat(RAPISTREAMFLAG, DWORD*); } -alias HRESULT function(DWORD, BYTE, DWORD, BYTE, IRAPIStream) RAPIEXT; +alias RAPIEXT = HRESULT function(DWORD, BYTE, DWORD, BYTE, IRAPIStream); struct RAPIINIT { diff --git a/runtime/druntime/src/core/sys/windows/ras.d b/runtime/druntime/src/core/sys/windows/ras.d index 4561799a87..8dc770a126 100644 --- a/runtime/druntime/src/core/sys/windows/ras.d +++ b/runtime/druntime/src/core/sys/windows/ras.d @@ -208,7 +208,7 @@ enum RASCONNSTATE { RASCS_Connected = RASCS_DONE, RASCS_Disconnected } -alias RASCONNSTATE* LPRASCONNSTATE; +alias LPRASCONNSTATE = RASCONNSTATE*; enum RASPROJECTION { RASP_Amb = 0x10000, @@ -221,10 +221,10 @@ enum RASPROJECTION { RASP_PppLcp = 0xC021, RASP_Slip = 0x20000 } -alias RASPROJECTION* LPRASPROJECTION; +alias LPRASPROJECTION = RASPROJECTION*; -alias HANDLE HRASCONN; -alias HRASCONN* LPHRASCONN; +alias HRASCONN = HANDLE; +alias LPHRASCONN = HRASCONN*; struct RASCONNW { align(4): @@ -247,7 +247,7 @@ align(4): LUID luid; } } -alias RASCONNW* LPRASCONNW; +alias LPRASCONNW = RASCONNW*; struct RASCONNA { align(4): @@ -270,7 +270,7 @@ align(4): LUID luid; } } -alias RASCONNA* LPRASCONNA; +alias LPRASCONNA = RASCONNA*; struct RASCONNSTATUSW { DWORD dwSize; @@ -282,7 +282,7 @@ struct RASCONNSTATUSW { WCHAR[RAS_MaxPhoneNumber + 1] szPhoneNumber = 0; } } -alias RASCONNSTATUSW* LPRASCONNSTATUSW; +alias LPRASCONNSTATUSW = RASCONNSTATUSW*; struct RASCONNSTATUSA { DWORD dwSize; @@ -294,7 +294,7 @@ struct RASCONNSTATUSA { CHAR[RAS_MaxPhoneNumber + 1] szPhoneNumber = 0; } } -alias RASCONNSTATUSA* LPRASCONNSTATUSA; +alias LPRASCONNSTATUSA = RASCONNSTATUSA*; struct RASDIALPARAMSW { align(4): @@ -312,7 +312,7 @@ align { ULONG_PTR dwCallbackId; } } -alias RASDIALPARAMSW* LPRASDIALPARAMSW; +alias LPRASDIALPARAMSW = RASDIALPARAMSW*; struct RASDIALPARAMSA{ align(4): @@ -330,7 +330,7 @@ align { ULONG_PTR dwCallbackId; } } -alias RASDIALPARAMSA* LPRASDIALPARAMSA; +alias LPRASDIALPARAMSA = RASDIALPARAMSA*; //static if (_WIN32_WINNT >= 0x500) { struct RASEAPINFO { @@ -351,7 +351,7 @@ align(4): RASEAPINFO RasEapInfo; //} } -alias RASDIALEXTENSIONS* LPRASDIALEXTENSIONS; +alias LPRASDIALEXTENSIONS = RASDIALEXTENSIONS*; struct RASENTRYNAMEW { DWORD dwSize; @@ -361,7 +361,7 @@ struct RASENTRYNAMEW { WCHAR[MAX_PATH + 1] szPhonebookPath = 0; //} } -alias RASENTRYNAMEW* LPRASENTRYNAMEW; +alias LPRASENTRYNAMEW = RASENTRYNAMEW*; struct RASENTRYNAMEA{ DWORD dwSize; @@ -371,7 +371,7 @@ struct RASENTRYNAMEA{ CHAR[MAX_PATH + 1] szPhonebookPath = 0; //} } -alias RASENTRYNAMEA* LPRASENTRYNAMEA; +alias LPRASENTRYNAMEA = RASENTRYNAMEA*; struct RASAMBW{ DWORD dwSize; @@ -379,7 +379,7 @@ struct RASAMBW{ WCHAR[NETBIOS_NAME_LEN + 1] szNetBiosError = 0; BYTE bLana; } -alias RASAMBW* LPRASAMBW; +alias LPRASAMBW = RASAMBW*; struct RASAMBA{ DWORD dwSize; @@ -387,7 +387,7 @@ struct RASAMBA{ CHAR[NETBIOS_NAME_LEN + 1] szNetBiosError = 0; BYTE bLana; } -alias RASAMBA* LPRASAMBA; +alias LPRASAMBA = RASAMBA*; struct RASPPPNBFW{ DWORD dwSize; @@ -397,7 +397,7 @@ struct RASPPPNBFW{ WCHAR[NETBIOS_NAME_LEN + 1] szWorkstationName = 0; BYTE bLana; } -alias RASPPPNBFW* LPRASPPPNBFW; +alias LPRASPPPNBFW = RASPPPNBFW*; struct RASPPPNBFA{ DWORD dwSize; @@ -407,21 +407,21 @@ struct RASPPPNBFA{ CHAR[NETBIOS_NAME_LEN + 1] szWorkstationName = 0; BYTE bLana; } -alias RASPPPNBFA* LPRASPPPNBFA; +alias LPRASPPPNBFA = RASPPPNBFA*; struct RASPPPIPXW { DWORD dwSize; DWORD dwError; WCHAR[RAS_MaxIpxAddress + 1] szIpxAddress = 0; } -alias RASPPPIPXW* LPRASPPPIPXW; +alias LPRASPPPIPXW = RASPPPIPXW*; struct RASPPPIPXA { DWORD dwSize; DWORD dwError; CHAR[RAS_MaxIpxAddress + 1] szIpxAddress = 0; } -alias RASPPPIPXA* LPRASPPPIPXA; +alias LPRASPPPIPXA = RASPPPIPXA*; struct RASPPPIPW{ DWORD dwSize; @@ -435,7 +435,7 @@ struct RASPPPIPW{ DWORD dwServerOptions; //} } -alias RASPPPIPW* LPRASPPPIPW; +alias LPRASPPPIPW = RASPPPIPW*; struct RASPPPIPA{ DWORD dwSize; @@ -449,7 +449,7 @@ struct RASPPPIPA{ DWORD dwServerOptions; //} } -alias RASPPPIPA* LPRASPPPIPA; +alias LPRASPPPIPA = RASPPPIPA*; struct RASPPPLCPW{ DWORD dwSize; @@ -470,7 +470,7 @@ struct RASPPPLCPW{ DWORD dwServerOptions; //} } -alias RASPPPLCPW* LPRASPPPLCPW; +alias LPRASPPPLCPW = RASPPPLCPW*; struct RASPPPLCPA{ DWORD dwSize; @@ -491,35 +491,35 @@ struct RASPPPLCPA{ DWORD dwServerOptions; //} } -alias RASPPPLCPA* LPRASPPPLCPA; +alias LPRASPPPLCPA = RASPPPLCPA*; struct RASSLIPW{ DWORD dwSize; DWORD dwError; WCHAR[RAS_MaxIpAddress + 1] szIpAddress = 0; } -alias RASSLIPW* LPRASSLIPW; +alias LPRASSLIPW = RASSLIPW*; struct RASSLIPA{ DWORD dwSize; DWORD dwError; CHAR[RAS_MaxIpAddress + 1] szIpAddress = 0; } -alias RASSLIPA* LPRASSLIPA; +alias LPRASSLIPA = RASSLIPA*; struct RASDEVINFOW{ DWORD dwSize; WCHAR[RAS_MaxDeviceType + 1] szDeviceType = 0; WCHAR[RAS_MaxDeviceName + 1] szDeviceName = 0; } -alias RASDEVINFOW* LPRASDEVINFOW; +alias LPRASDEVINFOW = RASDEVINFOW*; struct RASDEVINFOA{ DWORD dwSize; CHAR[RAS_MaxDeviceType + 1] szDeviceType = 0; CHAR[RAS_MaxDeviceName + 1] szDeviceName = 0; } -alias RASDEVINFOA* LPRASDEVINFOA; +alias LPRASDEVINFOA = RASDEVINFOA*; struct RASCTRYINFO { DWORD dwSize; @@ -528,10 +528,10 @@ struct RASCTRYINFO { DWORD dwCountryCode; DWORD dwCountryNameOffset; } -alias RASCTRYINFO* LPRASCTRYINFO; -alias RASCTRYINFO RASCTRYINFOW, RASCTRYINFOA; -alias RASCTRYINFOW* LPRASCTRYINFOW; -alias RASCTRYINFOA* LPRASCTRYINFOA; +alias LPRASCTRYINFO = RASCTRYINFO*; +alias RASCTRYINFOW = RASCTRYINFO, RASCTRYINFOA = RASCTRYINFO; +alias LPRASCTRYINFOW = RASCTRYINFOW*; +alias LPRASCTRYINFOA = RASCTRYINFOA*; struct RASIPADDR { BYTE a; @@ -586,7 +586,7 @@ struct RASENTRYW { DWORD dwVpnStrategy; //} } -alias RASENTRYW* LPRASENTRYW; +alias LPRASENTRYW = RASENTRYW*; struct RASENTRYA { DWORD dwSize; @@ -634,7 +634,7 @@ struct RASENTRYA { DWORD dwVpnStrategy; //} } -alias RASENTRYA* LPRASENTRYA; +alias LPRASENTRYA = RASENTRYA*; //static if (_WIN32_WINNT >= 0x401) { @@ -646,7 +646,7 @@ alias RASENTRYA* LPRASENTRYA; LONG xDlg; LONG yDlg; } - alias RASADPARAMS* LPRASADPARAMS; + alias LPRASADPARAMS = RASADPARAMS*; struct RASSUBENTRYW{ DWORD dwSize; @@ -656,7 +656,7 @@ alias RASENTRYA* LPRASENTRYA; WCHAR[RAS_MaxPhoneNumber + 1] szLocalPhoneNumber = 0; DWORD dwAlternateOffset; } - alias RASSUBENTRYW* LPRASSUBENTRYW; + alias LPRASSUBENTRYW = RASSUBENTRYW*; struct RASSUBENTRYA{ DWORD dwSize; @@ -666,7 +666,7 @@ alias RASENTRYA* LPRASENTRYA; CHAR[RAS_MaxPhoneNumber + 1] szLocalPhoneNumber = 0; DWORD dwAlternateOffset; } - alias RASSUBENTRYA* LPRASSUBENTRYA; + alias LPRASSUBENTRYA = RASSUBENTRYA*; struct RASCREDENTIALSW{ DWORD dwSize; @@ -675,7 +675,7 @@ alias RASENTRYA* LPRASENTRYA; WCHAR[PWLEN + 1] szPassword = 0; WCHAR[DNLEN + 1] szDomain = 0; } - alias RASCREDENTIALSW* LPRASCREDENTIALSW; + alias LPRASCREDENTIALSW = RASCREDENTIALSW*; struct RASCREDENTIALSA{ DWORD dwSize; @@ -684,7 +684,7 @@ alias RASENTRYA* LPRASENTRYA; CHAR[PWLEN + 1] szPassword = 0; CHAR[DNLEN + 1] szDomain = 0; } - alias RASCREDENTIALSA* LPRASCREDENTIALSA; + alias LPRASCREDENTIALSA = RASCREDENTIALSA*; struct RASAUTODIALENTRYW{ DWORD dwSize; @@ -692,7 +692,7 @@ alias RASENTRYA* LPRASENTRYA; DWORD dwDialingLocation; WCHAR[RAS_MaxEntryName + 1] szEntry = 0; } - alias RASAUTODIALENTRYW* LPRASAUTODIALENTRYW; + alias LPRASAUTODIALENTRYW = RASAUTODIALENTRYW*; struct RASAUTODIALENTRYA{ DWORD dwSize; @@ -700,7 +700,7 @@ alias RASENTRYA* LPRASENTRYA; DWORD dwDialingLocation; CHAR[RAS_MaxEntryName + 1] szEntry = 0; } - alias RASAUTODIALENTRYA* LPRASAUTODIALENTRYA; + alias LPRASAUTODIALENTRYA = RASAUTODIALENTRYA*; //} //static if (_WIN32_WINNT >= 0x500) { @@ -712,21 +712,21 @@ alias RASENTRYA* LPRASENTRYA; DWORD dwServerCompressionAlgorithm; DWORD dwServerOptions; } - alias RASPPPCCP* LPRASPPPCCP; + alias LPRASPPPCCP = RASPPPCCP*; struct RASEAPUSERIDENTITYW{ WCHAR[UNLEN + 1] szUserName = 0; DWORD dwSizeofEapInfo; BYTE[1] pbEapInfo; } - alias RASEAPUSERIDENTITYW* LPRASEAPUSERIDENTITYW; + alias LPRASEAPUSERIDENTITYW = RASEAPUSERIDENTITYW*; struct RASEAPUSERIDENTITYA{ CHAR[UNLEN + 1] szUserName = 0; DWORD dwSizeofEapInfo; BYTE[1] pbEapInfo; } - alias RASEAPUSERIDENTITYA* LPRASEAPUSERIDENTITYA; + alias LPRASEAPUSERIDENTITYA = RASEAPUSERIDENTITYA*; struct RAS_STATS{ DWORD dwSize; @@ -745,93 +745,93 @@ alias RASENTRYA* LPRASENTRYA; DWORD dwBps; DWORD dwConnectDuration; } - alias RAS_STATS* PRAS_STATS; + alias PRAS_STATS = RAS_STATS*; //} /* UNICODE typedefs for structures*/ version (Unicode) { - alias RASCONNW RASCONN; - alias RASENTRYW RASENTRY; - alias RASCONNSTATUSW RASCONNSTATUS; - alias RASDIALPARAMSW RASDIALPARAMS; - alias RASAMBW RASAMB; - alias RASPPPNBFW RASPPPNBF; - alias RASPPPIPXW RASPPPIPX; - alias RASPPPIPW RASPPPIP; - alias RASPPPLCPW RASPPPLCP; - alias RASSLIPW RASSLIP; - alias RASDEVINFOW RASDEVINFO; - alias RASENTRYNAMEW RASENTRYNAME; + alias RASCONN = RASCONNW; + alias RASENTRY = RASENTRYW; + alias RASCONNSTATUS = RASCONNSTATUSW; + alias RASDIALPARAMS = RASDIALPARAMSW; + alias RASAMB = RASAMBW; + alias RASPPPNBF = RASPPPNBFW; + alias RASPPPIPX = RASPPPIPXW; + alias RASPPPIP = RASPPPIPW; + alias RASPPPLCP = RASPPPLCPW; + alias RASSLIP = RASSLIPW; + alias RASDEVINFO = RASDEVINFOW; + alias RASENTRYNAME = RASENTRYNAMEW; //static if (_WIN32_WINNT >= 0x401) { - alias RASSUBENTRYW RASSUBENTRY; - alias RASCREDENTIALSW RASCREDENTIALS; - alias RASAUTODIALENTRYW RASAUTODIALENTRY; + alias RASSUBENTRY = RASSUBENTRYW; + alias RASCREDENTIALS = RASCREDENTIALSW; + alias RASAUTODIALENTRY = RASAUTODIALENTRYW; //} //static if (_WIN32_WINNT >= 0x500) { - alias RASEAPUSERIDENTITYW RASEAPUSERIDENTITY; + alias RASEAPUSERIDENTITY = RASEAPUSERIDENTITYW; //} } else { // ! defined UNICODE - alias RASCONNA RASCONN; - alias RASENTRYA RASENTRY; - alias RASCONNSTATUSA RASCONNSTATUS; - alias RASDIALPARAMSA RASDIALPARAMS; - alias RASAMBA RASAMB; - alias RASPPPNBFA RASPPPNBF; - alias RASPPPIPXA RASPPPIPX; - alias RASPPPIPA RASPPPIP; - alias RASPPPLCPA RASPPPLCP; - alias RASSLIPA RASSLIP; - alias RASDEVINFOA RASDEVINFO; - alias RASENTRYNAMEA RASENTRYNAME; + alias RASCONN = RASCONNA; + alias RASENTRY = RASENTRYA; + alias RASCONNSTATUS = RASCONNSTATUSA; + alias RASDIALPARAMS = RASDIALPARAMSA; + alias RASAMB = RASAMBA; + alias RASPPPNBF = RASPPPNBFA; + alias RASPPPIPX = RASPPPIPXA; + alias RASPPPIP = RASPPPIPA; + alias RASPPPLCP = RASPPPLCPA; + alias RASSLIP = RASSLIPA; + alias RASDEVINFO = RASDEVINFOA; + alias RASENTRYNAME = RASENTRYNAMEA; //static if (_WIN32_WINNT >= 0x401) { - alias RASSUBENTRYA RASSUBENTRY; - alias RASCREDENTIALSA RASCREDENTIALS; - alias RASAUTODIALENTRYA RASAUTODIALENTRY; + alias RASSUBENTRY = RASSUBENTRYA; + alias RASCREDENTIALS = RASCREDENTIALSA; + alias RASAUTODIALENTRY = RASAUTODIALENTRYA; //} //static if (_WIN32_WINNT >= 0x500) { - alias RASEAPUSERIDENTITYA RASEAPUSERIDENTITY; + alias RASEAPUSERIDENTITY = RASEAPUSERIDENTITYA; //} }// ! UNICODE -alias RASCONN* LPRASCONN; -alias RASENTRY* LPRASENTRY; -alias RASCONNSTATUS* LPRASCONNSTATUS; -alias RASDIALPARAMS* LPRASDIALPARAMS; -alias RASAMB* LPRASAM; -alias RASPPPNBF* LPRASPPPNBF; -alias RASPPPIPX* LPRASPPPIPX; -alias RASPPPIP* LPRASPPPIP; -alias RASPPPLCP* LPRASPPPLCP; -alias RASSLIP* LPRASSLIP; -alias RASDEVINFO* LPRASDEVINFO; -alias RASENTRYNAME* LPRASENTRYNAME; +alias LPRASCONN = RASCONN*; +alias LPRASENTRY = RASENTRY*; +alias LPRASCONNSTATUS = RASCONNSTATUS*; +alias LPRASDIALPARAMS = RASDIALPARAMS*; +alias LPRASAM = RASAMB*; +alias LPRASPPPNBF = RASPPPNBF*; +alias LPRASPPPIPX = RASPPPIPX*; +alias LPRASPPPIP = RASPPPIP*; +alias LPRASPPPLCP = RASPPPLCP*; +alias LPRASSLIP = RASSLIP*; +alias LPRASDEVINFO = RASDEVINFO*; +alias LPRASENTRYNAME = RASENTRYNAME*; //static if (_WIN32_WINNT >= 0x401) { - alias RASSUBENTRY* LPRASSUBENTRY; - alias RASCREDENTIALS* LPRASCREDENTIALS; - alias RASAUTODIALENTRY* LPRASAUTODIALENTRY; + alias LPRASSUBENTRY = RASSUBENTRY*; + alias LPRASCREDENTIALS = RASCREDENTIALS*; + alias LPRASAUTODIALENTRY = RASAUTODIALENTRY*; //} //static if (_WIN32_WINNT >= 0x500) { - alias RASEAPUSERIDENTITY* LPRASEAPUSERIDENTITY; + alias LPRASEAPUSERIDENTITY = RASEAPUSERIDENTITY*; //} /* Callback prototypes */ extern (Windows) { /* WINAPI */ deprecated { - alias BOOL function (HWND, LPSTR, DWORD, LPDWORD) ORASADFUNC; + alias ORASADFUNC = BOOL function (HWND, LPSTR, DWORD, LPDWORD); } - alias void function (UINT, RASCONNSTATE, DWORD) RASDIALFUNC; - alias void function(HRASCONN, UINT, RASCONNSTATE, DWORD, DWORD) RASDIALFUNC1; - alias DWORD function (ULONG_PTR, DWORD, HRASCONN, UINT, - RASCONNSTATE, DWORD, DWORD) RASDIALFUNC2; + alias RASDIALFUNC = void function (UINT, RASCONNSTATE, DWORD); + alias RASDIALFUNC1 = void function(HRASCONN, UINT, RASCONNSTATE, DWORD, DWORD); + alias RASDIALFUNC2 = DWORD function (ULONG_PTR, DWORD, HRASCONN, UINT, + RASCONNSTATE, DWORD, DWORD); /* External functions */ DWORD RasDialA(LPRASDIALEXTENSIONS, LPCSTR, LPRASDIALPARAMSA, DWORD, LPVOID, LPHRASCONN); @@ -872,8 +872,8 @@ extern (Windows) { /* WINAPI */ DWORD RasValidateEntryNameW(LPCWSTR, LPCWSTR); //static if (_WIN32_WINNT >= 0x401) { - alias BOOL function(LPSTR, LPSTR, LPRASADPARAMS, LPDWORD) RASADFUNCA; - alias BOOL function(LPWSTR, LPWSTR, LPRASADPARAMS, LPDWORD) RASADFUNCW; + alias RASADFUNCA = BOOL function(LPSTR, LPSTR, LPRASADPARAMS, LPDWORD); + alias RASADFUNCW = BOOL function(LPWSTR, LPWSTR, LPRASADPARAMS, LPDWORD); DWORD RasGetSubEntryHandleA(HRASCONN, DWORD, LPHRASCONN); DWORD RasGetSubEntryHandleW(HRASCONN, DWORD, LPHRASCONN); @@ -904,10 +904,10 @@ extern (Windows) { /* WINAPI */ //} static if (_WIN32_WINNT >= 0x500) { - alias DWORD function(HRASCONN) RasCustomHangUpFn; - alias DWORD function(LPCTSTR, LPCTSTR, DWORD) RasCustomDeleteEntryNotifyFn; - alias DWORD function(HINSTANCE, LPRASDIALEXTENSIONS, LPCTSTR, LPRASDIALPARAMS, DWORD, LPVOID, - LPHRASCONN, DWORD) RasCustomDialFn; + alias RasCustomHangUpFn = DWORD function(HRASCONN); + alias RasCustomDeleteEntryNotifyFn = DWORD function(LPCTSTR, LPCTSTR, DWORD); + alias RasCustomDialFn = DWORD function(HINSTANCE, LPRASDIALEXTENSIONS, LPCTSTR, LPRASDIALPARAMS, DWORD, LPVOID, + LPHRASCONN, DWORD); DWORD RasInvokeEapUI(HRASCONN, DWORD, LPRASDIALEXTENSIONS, HWND); DWORD RasGetLinkStatistics(HRASCONN, DWORD, RAS_STATS*); @@ -932,94 +932,94 @@ static if (_WIN32_WINNT >= 0x500) { /* UNICODE defines for functions */ version (Unicode) { - alias RasDialW RasDial; - alias RasEnumConnectionsW RasEnumConnections; - alias RasEnumEntriesW RasEnumEntries; - alias RasGetConnectStatusW RasGetConnectStatus; - alias RasGetErrorStringW RasGetErrorString; - alias RasHangUpW RasHangUp; - alias RasGetProjectionInfoW RasGetProjectionInfo; - alias RasCreatePhonebookEntryW RasCreatePhonebookEntry; - alias RasEditPhonebookEntryW RasEditPhonebookEntry; - alias RasSetEntryDialParamsW RasSetEntryDialParams; - alias RasGetEntryDialParamsW RasGetEntryDialParams; - alias RasEnumDevicesW RasEnumDevices; - alias RasGetCountryInfoW RasGetCountryInfo; - alias RasGetEntryPropertiesW RasGetEntryProperties; - alias RasSetEntryPropertiesW RasSetEntryProperties; - alias RasRenameEntryW RasRenameEntry; - alias RasDeleteEntryW RasDeleteEntry; - alias RasValidateEntryNameW RasValidateEntryName; + alias RasDial = RasDialW; + alias RasEnumConnections = RasEnumConnectionsW; + alias RasEnumEntries = RasEnumEntriesW; + alias RasGetConnectStatus = RasGetConnectStatusW; + alias RasGetErrorString = RasGetErrorStringW; + alias RasHangUp = RasHangUpW; + alias RasGetProjectionInfo = RasGetProjectionInfoW; + alias RasCreatePhonebookEntry = RasCreatePhonebookEntryW; + alias RasEditPhonebookEntry = RasEditPhonebookEntryW; + alias RasSetEntryDialParams = RasSetEntryDialParamsW; + alias RasGetEntryDialParams = RasGetEntryDialParamsW; + alias RasEnumDevices = RasEnumDevicesW; + alias RasGetCountryInfo = RasGetCountryInfoW; + alias RasGetEntryProperties = RasGetEntryPropertiesW; + alias RasSetEntryProperties = RasSetEntryPropertiesW; + alias RasRenameEntry = RasRenameEntryW; + alias RasDeleteEntry = RasDeleteEntryW; + alias RasValidateEntryName = RasValidateEntryNameW; //static if (_WIN32_WINNT >= 0x401) { - alias RASADFUNCW RASADFUNC; - alias RasGetSubEntryHandleW RasGetSubEntryHandle; - alias RasConnectionNotificationW RasConnectionNotification; - alias RasGetSubEntryPropertiesW RasGetSubEntryProperties; - alias RasSetSubEntryPropertiesW RasSetSubEntryProperties; - alias RasGetCredentialsW RasGetCredentials; - alias RasSetCredentialsW RasSetCredentials; - alias RasGetAutodialAddressW RasGetAutodialAddress; - alias RasSetAutodialAddressW RasSetAutodialAddress; - alias RasEnumAutodialAddressesW RasEnumAutodialAddresses; - alias RasGetAutodialEnableW RasGetAutodialEnable; - alias RasSetAutodialEnableW RasSetAutodialEnable; - alias RasGetAutodialParamW RasGetAutodialParam; - alias RasSetAutodialParamW RasSetAutodialParam; + alias RASADFUNC = RASADFUNCW; + alias RasGetSubEntryHandle = RasGetSubEntryHandleW; + alias RasConnectionNotification = RasConnectionNotificationW; + alias RasGetSubEntryProperties = RasGetSubEntryPropertiesW; + alias RasSetSubEntryProperties = RasSetSubEntryPropertiesW; + alias RasGetCredentials = RasGetCredentialsW; + alias RasSetCredentials = RasSetCredentialsW; + alias RasGetAutodialAddress = RasGetAutodialAddressW; + alias RasSetAutodialAddress = RasSetAutodialAddressW; + alias RasEnumAutodialAddresses = RasEnumAutodialAddressesW; + alias RasGetAutodialEnable = RasGetAutodialEnableW; + alias RasSetAutodialEnable = RasSetAutodialEnableW; + alias RasGetAutodialParam = RasGetAutodialParamW; + alias RasSetAutodialParam = RasSetAutodialParamW; //} //static if (_WIN32_WINNT >= 0x500) { - alias RasGetEapUserDataW RasGetEapUserData; - alias RasSetEapUserDataW RasSetEapUserData; - alias RasGetCustomAuthDataW RasGetCustomAuthData; - alias RasSetCustomAuthDataW RasSetCustomAuthData; - alias RasGetEapUserIdentityW RasGetEapUserIdentity; - alias RasFreeEapUserIdentityW RasFreeEapUserIdentity; + alias RasGetEapUserData = RasGetEapUserDataW; + alias RasSetEapUserData = RasSetEapUserDataW; + alias RasGetCustomAuthData = RasGetCustomAuthDataW; + alias RasSetCustomAuthData = RasSetCustomAuthDataW; + alias RasGetEapUserIdentity = RasGetEapUserIdentityW; + alias RasFreeEapUserIdentity = RasFreeEapUserIdentityW; //} } else { // !Unicode - alias RasDialA RasDial; - alias RasEnumConnectionsA RasEnumConnections; - alias RasEnumEntriesA RasEnumEntries; - alias RasGetConnectStatusA RasGetConnectStatus; - alias RasGetErrorStringA RasGetErrorString; - alias RasHangUpA RasHangUp; - alias RasGetProjectionInfoA RasGetProjectionInfo; - alias RasCreatePhonebookEntryA RasCreatePhonebookEntry; - alias RasEditPhonebookEntryA RasEditPhonebookEntry; - alias RasSetEntryDialParamsA RasSetEntryDialParams; - alias RasGetEntryDialParamsA RasGetEntryDialParams; - alias RasEnumDevicesA RasEnumDevices; - alias RasGetCountryInfoA RasGetCountryInfo; - alias RasGetEntryPropertiesA RasGetEntryProperties; - alias RasSetEntryPropertiesA RasSetEntryProperties; - alias RasRenameEntryA RasRenameEntry; - alias RasDeleteEntryA RasDeleteEntry; - alias RasValidateEntryNameA RasValidateEntryName; + alias RasDial = RasDialA; + alias RasEnumConnections = RasEnumConnectionsA; + alias RasEnumEntries = RasEnumEntriesA; + alias RasGetConnectStatus = RasGetConnectStatusA; + alias RasGetErrorString = RasGetErrorStringA; + alias RasHangUp = RasHangUpA; + alias RasGetProjectionInfo = RasGetProjectionInfoA; + alias RasCreatePhonebookEntry = RasCreatePhonebookEntryA; + alias RasEditPhonebookEntry = RasEditPhonebookEntryA; + alias RasSetEntryDialParams = RasSetEntryDialParamsA; + alias RasGetEntryDialParams = RasGetEntryDialParamsA; + alias RasEnumDevices = RasEnumDevicesA; + alias RasGetCountryInfo = RasGetCountryInfoA; + alias RasGetEntryProperties = RasGetEntryPropertiesA; + alias RasSetEntryProperties = RasSetEntryPropertiesA; + alias RasRenameEntry = RasRenameEntryA; + alias RasDeleteEntry = RasDeleteEntryA; + alias RasValidateEntryName = RasValidateEntryNameA; //static if (_WIN32_WINNT >= 0x401) { - alias RASADFUNCA RASADFUNC; - alias RasGetSubEntryHandleA RasGetSubEntryHandle; - alias RasConnectionNotificationA RasConnectionNotification; - alias RasGetSubEntryPropertiesA RasGetSubEntryProperties; - alias RasSetSubEntryPropertiesA RasSetSubEntryProperties; - alias RasGetCredentialsA RasGetCredentials; - alias RasSetCredentialsA RasSetCredentials; - alias RasGetAutodialAddressA RasGetAutodialAddress; - alias RasSetAutodialAddressA RasSetAutodialAddress; - alias RasEnumAutodialAddressesA RasEnumAutodialAddresses; - alias RasGetAutodialEnableA RasGetAutodialEnable; - alias RasSetAutodialEnableA RasSetAutodialEnable; - alias RasGetAutodialParamA RasGetAutodialParam; - alias RasSetAutodialParamA RasSetAutodialParam; + alias RASADFUNC = RASADFUNCA; + alias RasGetSubEntryHandle = RasGetSubEntryHandleA; + alias RasConnectionNotification = RasConnectionNotificationA; + alias RasGetSubEntryProperties = RasGetSubEntryPropertiesA; + alias RasSetSubEntryProperties = RasSetSubEntryPropertiesA; + alias RasGetCredentials = RasGetCredentialsA; + alias RasSetCredentials = RasSetCredentialsA; + alias RasGetAutodialAddress = RasGetAutodialAddressA; + alias RasSetAutodialAddress = RasSetAutodialAddressA; + alias RasEnumAutodialAddresses = RasEnumAutodialAddressesA; + alias RasGetAutodialEnable = RasGetAutodialEnableA; + alias RasSetAutodialEnable = RasSetAutodialEnableA; + alias RasGetAutodialParam = RasGetAutodialParamA; + alias RasSetAutodialParam = RasSetAutodialParamA; //} //static if (_WIN32_WINNT >= 0x500) { - alias RasGetEapUserDataA RasGetEapUserData; - alias RasSetEapUserDataA RasSetEapUserData; - alias RasGetCustomAuthDataA RasGetCustomAuthData; - alias RasSetCustomAuthDataA RasSetCustomAuthData; - alias RasGetEapUserIdentityA RasGetEapUserIdentity; - alias RasFreeEapUserIdentityA RasFreeEapUserIdentity; + alias RasGetEapUserData = RasGetEapUserDataA; + alias RasSetEapUserData = RasSetEapUserDataA; + alias RasGetCustomAuthData = RasGetCustomAuthDataA; + alias RasSetCustomAuthData = RasSetCustomAuthDataA; + alias RasGetEapUserIdentity = RasGetEapUserIdentityA; + alias RasFreeEapUserIdentity = RasFreeEapUserIdentityA; //} } //#endif // !Unicode diff --git a/runtime/druntime/src/core/sys/windows/rasdlg.d b/runtime/druntime/src/core/sys/windows/rasdlg.d index a980d270f8..50fd63b676 100644 --- a/runtime/druntime/src/core/sys/windows/rasdlg.d +++ b/runtime/druntime/src/core/sys/windows/rasdlg.d @@ -49,7 +49,7 @@ align(4): ULONG_PTR reserved; ULONG_PTR reserved2; } -alias RASENTRYDLGA* LPRASENTRYDLGA; +alias LPRASENTRYDLGA = RASENTRYDLGA*; struct RASENTRYDLGW { align(4): @@ -63,7 +63,7 @@ align(4): ULONG_PTR reserved; ULONG_PTR reserved2; } -alias RASENTRYDLGW* LPRASENTRYDLGW; +alias LPRASENTRYDLGW = RASENTRYDLGW*; struct RASDIALDLG { align(4): @@ -77,12 +77,12 @@ align(4): ULONG_PTR reserved; ULONG_PTR reserved2; } -alias RASDIALDLG* LPRASDIALDLG; +alias LPRASDIALDLG = RASDIALDLG*; // Application-defined callback functions extern (Windows) { - alias VOID function(ULONG_PTR, DWORD, LPWSTR, LPVOID) RASPBDLGFUNCW; - alias VOID function(ULONG_PTR, DWORD, LPSTR, LPVOID) RASPBDLGFUNCA; + alias RASPBDLGFUNCW = VOID function(ULONG_PTR, DWORD, LPWSTR, LPVOID); + alias RASPBDLGFUNCA = VOID function(ULONG_PTR, DWORD, LPSTR, LPVOID); } struct RASPBDLGA { @@ -98,7 +98,7 @@ align(4): ULONG_PTR reserved; ULONG_PTR reserved2; } -alias RASPBDLGA* LPRASPBDLGA; +alias LPRASPBDLGA = RASPBDLGA*; struct RASPBDLGW { align(4): @@ -113,7 +113,7 @@ align(4): ULONG_PTR reserved; ULONG_PTR reserved2; } -alias RASPBDLGW* LPRASPBDLGW; +alias LPRASPBDLGW = RASPBDLGW*; struct RASNOUSERA { @@ -124,7 +124,7 @@ struct RASNOUSERA CHAR[PWLEN + 1] szPassword = 0; CHAR[DNLEN + 1] szDomain = 0; } -alias RASNOUSERA* LPRASNOUSERA; +alias LPRASNOUSERA = RASNOUSERA*; struct RASNOUSERW { DWORD dwSize = RASNOUSERW.sizeof; @@ -134,7 +134,7 @@ struct RASNOUSERW { WCHAR[PWLEN + 1] szPassword = 0; WCHAR[DNLEN + 1] szDomain = 0; } -alias RASNOUSERW* LPRASNOUSERW; +alias LPRASNOUSERW = RASNOUSERW*; extern (Windows) { BOOL RasDialDlgA(LPSTR, LPSTR, LPSTR, LPRASDIALDLG); @@ -146,21 +146,21 @@ extern (Windows) { } version (Unicode) { - alias RASENTRYDLGW RASENTRYDLG; - alias RASPBDLGW RASPBDLG; - alias RASNOUSERW RASNOUSER; - alias RasDialDlgW RasDialDlg; - alias RasEntryDlgW RasEntryDlg; - alias RasPhonebookDlgW RasPhonebookDlg; + alias RASENTRYDLG = RASENTRYDLGW; + alias RASPBDLG = RASPBDLGW; + alias RASNOUSER = RASNOUSERW; + alias RasDialDlg = RasDialDlgW; + alias RasEntryDlg = RasEntryDlgW; + alias RasPhonebookDlg = RasPhonebookDlgW; } else { - alias RASENTRYDLGA RASENTRYDLG; - alias RASPBDLGA RASPBDLG; - alias RASNOUSERA RASNOUSER; - alias RasDialDlgA RasDialDlg; - alias RasEntryDlgA RasEntryDlg; - alias RasPhonebookDlgA RasPhonebookDlg; + alias RASENTRYDLG = RASENTRYDLGA; + alias RASPBDLG = RASPBDLGA; + alias RASNOUSER = RASNOUSERA; + alias RasDialDlg = RasDialDlgA; + alias RasEntryDlg = RasEntryDlgA; + alias RasPhonebookDlg = RasPhonebookDlgA; } -alias RASENTRYDLG* LPRASENTRYDLG; -alias RASPBDLG* LPRASPBDLG; -alias RASNOUSER* LPRASNOUSER; +alias LPRASENTRYDLG = RASENTRYDLG*; +alias LPRASPBDLG = RASPBDLG*; +alias LPRASNOUSER = RASNOUSER*; diff --git a/runtime/druntime/src/core/sys/windows/rassapi.d b/runtime/druntime/src/core/sys/windows/rassapi.d index 5244ca4115..27d3f465c0 100644 --- a/runtime/druntime/src/core/sys/windows/rassapi.d +++ b/runtime/druntime/src/core/sys/windows/rassapi.d @@ -73,7 +73,7 @@ enum { RASADMIN_CURRENT = 40 } -alias ULONG IPADDR; +alias IPADDR = ULONG; enum RAS_PARAMS_FORMAT { ParamNumber = 0, @@ -100,7 +100,7 @@ struct RAS_USER_0 { BYTE bfPrivilege; WCHAR[RASSAPI_MAX_PHONENUMBER_SIZE + 1] szPhoneNumber = 0; } -alias RAS_USER_0* PRAS_USER_0; +alias PRAS_USER_0 = RAS_USER_0*; struct RAS_PORT_0 { WCHAR[RASSAPI_MAX_PORT_NAME] wszPortName = 0; @@ -115,7 +115,7 @@ struct RAS_PORT_0 { WCHAR[DNLEN + 1] wszLogonDomain = 0; BOOL fAdvancedServer; } -alias RAS_PORT_0* PRAS_PORT_0; +alias PRAS_PORT_0 = RAS_PORT_0*; struct RAS_PPP_NBFCP_RESULT { DWORD dwError; @@ -156,7 +156,7 @@ struct RAS_PORT_1 { DWORD SizeMediaParms; RAS_PPP_PROJECTION_RESULT ProjResult; } -alias RAS_PORT_1* PRAS_PORT_1; +alias PRAS_PORT_1 = RAS_PORT_1*; struct RAS_PORT_STATISTICS { DWORD dwBytesXmited; @@ -188,14 +188,14 @@ struct RAS_PORT_STATISTICS { DWORD dwPortBytesXmitedCompressed; DWORD dwPortBytesRcvedCompressed; } -alias RAS_PORT_STATISTICS* PRAS_PORT_STATISTICS; +alias PRAS_PORT_STATISTICS = RAS_PORT_STATISTICS*; struct RAS_SERVER_0 { WORD TotalPorts; WORD PortsInUse; DWORD RasVersion; } -alias RAS_SERVER_0* PRAS_SERVER_0; +alias PRAS_SERVER_0 = RAS_SERVER_0*; extern (Windows) { DWORD RasAdminServerGetInfo(const(WCHAR)*, PRAS_SERVER_0); diff --git a/runtime/druntime/src/core/sys/windows/regstr.d b/runtime/druntime/src/core/sys/windows/regstr.d index f8851fa720..9327c46913 100644 --- a/runtime/druntime/src/core/sys/windows/regstr.d +++ b/runtime/druntime/src/core/sys/windows/regstr.d @@ -813,4 +813,4 @@ struct DSKTLSYSTEMTIME { WORD wMilliseconds; WORD wResult; } -alias DSKTLSYSTEMTIME* PDSKTLSYSTEMTIME, LPDSKTLSYSTEMTIME; +alias PDSKTLSYSTEMTIME = DSKTLSYSTEMTIME*, LPDSKTLSYSTEMTIME = DSKTLSYSTEMTIME*; diff --git a/runtime/druntime/src/core/sys/windows/richedit.d b/runtime/druntime/src/core/sys/windows/richedit.d index 0f56fef097..c128d79fd4 100644 --- a/runtime/druntime/src/core/sys/windows/richedit.d +++ b/runtime/druntime/src/core/sys/windows/richedit.d @@ -287,7 +287,7 @@ enum SCF_WORD = 2; enum SCF_ALL = 4; enum SCF_USEUIRULES = 8; -alias DWORD TEXTMODE; +alias TEXTMODE = DWORD; enum TM_PLAINTEXT=1; enum TM_RICHTEXT=2; enum TM_SINGLELEVELUNDO=4; @@ -301,7 +301,7 @@ enum GT_USECRLF=1; enum yHeightCharPtsMost=1638; enum lDefaultTab=720; -alias DWORD UNDONAMEID; +alias UNDONAMEID = DWORD; enum UID_UNKNOWN = 0; enum UID_TYPING = 1; enum UID_DELETE = 2; @@ -388,7 +388,7 @@ struct COMPCOLOR { } extern (Windows) { - alias DWORD function(DWORD_PTR,PBYTE,LONG,LONG*) EDITSTREAMCALLBACK; + alias EDITSTREAMCALLBACK = DWORD function(DWORD_PTR,PBYTE,LONG,LONG*); } struct EDITSTREAM { @@ -438,7 +438,7 @@ align(4): LPARAM lParam; CHARRANGE chrg; } -alias ENPROTECTED* LPENPROTECTED; +alias LPENPROTECTED = ENPROTECTED*; struct ENSAVECLIPBOARD { align(4): @@ -568,7 +568,7 @@ align(4): } extern (Windows) { -alias LONG function(char*,LONG,BYTE,INT) EDITWORDBREAKPROCEX; +alias EDITWORDBREAKPROCEX = LONG function(char*,LONG,BYTE,INT); } /* Defines for EM_SETTYPOGRAPHYOPTIONS */ @@ -590,15 +590,15 @@ align(4): } version (Unicode) { - alias CHARFORMATW CHARFORMAT; - alias CHARFORMAT2W CHARFORMAT2; - alias FINDTEXTW FINDTEXT; - alias FINDTEXTEXW FINDTEXTEX; - alias TEXTRANGEW TEXTRANGE; + alias CHARFORMAT = CHARFORMATW; + alias CHARFORMAT2 = CHARFORMAT2W; + alias FINDTEXT = FINDTEXTW; + alias FINDTEXTEX = FINDTEXTEXW; + alias TEXTRANGE = TEXTRANGEW; } else { - alias CHARFORMATA CHARFORMAT; - alias CHARFORMAT2A CHARFORMAT2; - alias FINDTEXTA FINDTEXT; - alias FINDTEXTEXA FINDTEXTEX; - alias TEXTRANGEA TEXTRANGE; + alias CHARFORMAT = CHARFORMATA; + alias CHARFORMAT2 = CHARFORMAT2A; + alias FINDTEXT = FINDTEXTA; + alias FINDTEXTEX = FINDTEXTEXA; + alias TEXTRANGE = TEXTRANGEA; } diff --git a/runtime/druntime/src/core/sys/windows/richole.d b/runtime/druntime/src/core/sys/windows/richole.d index 01518189df..e44ee4348d 100644 --- a/runtime/druntime/src/core/sys/windows/richole.d +++ b/runtime/druntime/src/core/sys/windows/richole.d @@ -84,7 +84,7 @@ interface IRichEditOle : IUnknown { HRESULT GetClipboardData(CHARRANGE*, DWORD, LPDATAOBJECT*); HRESULT ImportDataObject(LPDATAOBJECT, CLIPFORMAT, HGLOBAL); } -alias IRichEditOle LPRICHEDITOLE; +alias LPRICHEDITOLE = IRichEditOle; interface IRichEditOleCallback : IUnknown { HRESULT GetNewStorage(LPSTORAGE*); @@ -98,4 +98,4 @@ interface IRichEditOleCallback : IUnknown { HRESULT GetDragDropEffect(BOOL, DWORD, PDWORD); HRESULT GetContextMenu(WORD, LPOLEOBJECT, CHARRANGE*, HMENU*); } -alias IRichEditOleCallback LPRICHEDITOLECALLBACK; +alias LPRICHEDITOLECALLBACK = IRichEditOleCallback; diff --git a/runtime/druntime/src/core/sys/windows/rpc.d b/runtime/druntime/src/core/sys/windows/rpc.d index 3b7e28d213..77d6064667 100644 --- a/runtime/druntime/src/core/sys/windows/rpc.d +++ b/runtime/druntime/src/core/sys/windows/rpc.d @@ -23,8 +23,8 @@ public import core.sys.windows.rpcnsi; public import core.sys.windows.rpcnterr; public import core.sys.windows.winerror; -alias MIDL_user_allocate midl_user_allocate; -alias MIDL_user_free midl_user_free; +alias midl_user_allocate = MIDL_user_allocate; +alias midl_user_free = MIDL_user_free; extern (Windows) nothrow @nogc { int I_RpcMapWin32Status(RPC_STATUS); diff --git a/runtime/druntime/src/core/sys/windows/rpcdce.d b/runtime/druntime/src/core/sys/windows/rpcdce.d index 951480b955..83a5a828c1 100644 --- a/runtime/druntime/src/core/sys/windows/rpcdce.d +++ b/runtime/druntime/src/core/sys/windows/rpcdce.d @@ -20,9 +20,9 @@ import core.sys.windows.basetyps, core.sys.windows.w32api, core.sys.windows.wind // FIXME: clean up Windows version support -alias UUID uuid_t; -alias UUID_VECTOR uuid_vector_t; -alias void RPC_MGR_EPV; +alias uuid_t = UUID; +alias uuid_vector_t = UUID_VECTOR; +alias RPC_MGR_EPV = void; // for RpcMgmtSetComTimeout() enum : uint { @@ -114,16 +114,16 @@ enum RPC_C_AUTHZ_NAME=1; enum RPC_C_AUTHZ_DCE=2; enum RPC_C_AUTHZ_DEFAULT=0xFFFFFFFF; -alias I_RPC_HANDLE RPC_BINDING_HANDLE; -alias RPC_BINDING_HANDLE handle_t; +alias RPC_BINDING_HANDLE = I_RPC_HANDLE; +alias handle_t = RPC_BINDING_HANDLE; struct RPC_BINDING_VECTOR { uint Count; RPC_BINDING_HANDLE[1] BindingH; } -alias RPC_BINDING_HANDLE rpc_binding_handle_t; -alias RPC_BINDING_VECTOR rpc_binding_vector_t; +alias rpc_binding_handle_t = RPC_BINDING_HANDLE; +alias rpc_binding_vector_t = RPC_BINDING_VECTOR; struct UUID_VECTOR { @@ -131,7 +131,7 @@ struct UUID_VECTOR { UUID*[1] Uuid; } -alias void* RPC_IF_HANDLE; +alias RPC_IF_HANDLE = void*; struct RPC_IF_ID { UUID Uuid; @@ -144,11 +144,11 @@ struct RPC_POLICY { uint EndpointFlags; uint NICFlags; } -alias RPC_POLICY* PRPC_POLICY; +alias PRPC_POLICY = RPC_POLICY*; extern (Windows) { - alias void function(UUID*, UUID*, RPC_STATUS*) RPC_OBJECT_INQ_FN; - alias RPC_STATUS function(RPC_IF_HANDLE, void*) RPC_IF_CALLBACK_FN; + alias RPC_OBJECT_INQ_FN = void function(UUID*, UUID*, RPC_STATUS*); + alias RPC_IF_CALLBACK_FN = RPC_STATUS function(RPC_IF_HANDLE, void*); } struct RPC_STATS_VECTOR { @@ -169,7 +169,7 @@ struct RPC_SECURITY_QOS { uint IdentityTracking; uint ImpersonationType; } -alias RPC_SECURITY_QOS* PRPC_SECURITY_QOS; +alias PRPC_SECURITY_QOS = RPC_SECURITY_QOS*; struct SEC_WINNT_AUTH_IDENTITY_W { ushort* User; @@ -180,7 +180,7 @@ struct SEC_WINNT_AUTH_IDENTITY_W { uint PasswordLength; uint Flags; } -alias SEC_WINNT_AUTH_IDENTITY_W* PSEC_WINNT_AUTH_IDENTITY_W; +alias PSEC_WINNT_AUTH_IDENTITY_W = SEC_WINNT_AUTH_IDENTITY_W*; struct SEC_WINNT_AUTH_IDENTITY_A { ubyte* User; @@ -191,7 +191,7 @@ struct SEC_WINNT_AUTH_IDENTITY_A { uint PasswordLength; uint Flags; } -alias SEC_WINNT_AUTH_IDENTITY_A* PSEC_WINNT_AUTH_IDENTITY_A; +alias PSEC_WINNT_AUTH_IDENTITY_A = SEC_WINNT_AUTH_IDENTITY_A*; struct RPC_CLIENT_INFORMATION1 { ubyte* UserName; @@ -199,10 +199,10 @@ struct RPC_CLIENT_INFORMATION1 { ushort Privilege; uint AuthFlags; } -alias RPC_CLIENT_INFORMATION1* PRPC_CLIENT_INFORMATION1; -alias I_RPC_HANDLE* RPC_EP_INQ_HANDLE; +alias PRPC_CLIENT_INFORMATION1 = RPC_CLIENT_INFORMATION1*; +alias RPC_EP_INQ_HANDLE = I_RPC_HANDLE*; extern (Windows) { - alias int function(RPC_BINDING_HANDLE, uint, RPC_STATUS*) RPC_MGMT_AUTHORIZATION_FN; + alias RPC_MGMT_AUTHORIZATION_FN = int function(RPC_BINDING_HANDLE, uint, RPC_STATUS*); } struct RPC_PROTSEQ_VECTORA { @@ -260,7 +260,7 @@ extern (Windows) { RPC_STATUS RpcBindingSetAuthInfoExW(RPC_BINDING_HANDLE, wchar*, uint, uint, RPC_AUTH_IDENTITY_HANDLE, uint, RPC_SECURITY_QOS*); RPC_STATUS RpcBindingInqAuthInfoExA(RPC_BINDING_HANDLE, char**, uint*, uint*, RPC_AUTH_IDENTITY_HANDLE*, uint*, uint, RPC_SECURITY_QOS*); RPC_STATUS RpcBindingInqAuthInfoExW(RPC_BINDING_HANDLE, wchar**, uint*, uint*, RPC_AUTH_IDENTITY_HANDLE*, uint*, uint, RPC_SECURITY_QOS*); - alias void function(void*, wchar*, uint, void**, RPC_STATUS*) RPC_AUTH_KEY_RETRIEVAL_FN; + alias RPC_AUTH_KEY_RETRIEVAL_FN = void function(void*, wchar*, uint, void**, RPC_STATUS*); RPC_STATUS RpcServerRegisterAuthInfoA(char*, uint, RPC_AUTH_KEY_RETRIEVAL_FN, void*); RPC_STATUS RpcServerRegisterAuthInfoW(wchar*, uint, RPC_AUTH_KEY_RETRIEVAL_FN, void*); RPC_STATUS UuidToStringA(UUID*, char**); @@ -282,71 +282,71 @@ extern (Windows) { } version (Unicode) { - alias RPC_PROTSEQ_VECTORW RPC_PROTSEQ_VECTOR; - alias SEC_WINNT_AUTH_IDENTITY_W SEC_WINNT_AUTH_IDENTITY; - alias PSEC_WINNT_AUTH_IDENTITY_W PSEC_WINNT_AUTH_IDENTITY; - alias RpcMgmtEpEltInqNextW RpcMgmtEpEltInqNext; - alias RpcBindingFromStringBindingW RpcBindingFromStringBinding; - alias RpcBindingToStringBindingW RpcBindingToStringBinding; - alias RpcStringBindingComposeW RpcStringBindingCompose; - alias RpcStringBindingParseW RpcStringBindingParse; - alias RpcStringFreeW RpcStringFree; - alias RpcNetworkIsProtseqValidW RpcNetworkIsProtseqValid; - alias RpcNetworkInqProtseqsW RpcNetworkInqProtseqs; - alias RpcProtseqVectorFreeW RpcProtseqVectorFree; - alias RpcServerUseProtseqW RpcServerUseProtseq; - alias RpcServerUseProtseqExW RpcServerUseProtseqEx; - alias RpcServerUseProtseqEpW RpcServerUseProtseqEp; - alias RpcServerUseProtseqEpExW RpcServerUseProtseqEpEx; - alias RpcServerUseProtseqIfW RpcServerUseProtseqIf; - alias RpcServerUseProtseqIfExW RpcServerUseProtseqIfEx; - alias RpcMgmtInqServerPrincNameW RpcMgmtInqServerPrincName; - alias RpcServerInqDefaultPrincNameW RpcServerInqDefaultPrincName; - alias RpcNsBindingInqEntryNameW RpcNsBindingInqEntryName; - alias RpcBindingInqAuthClientW RpcBindingInqAuthClient; - alias RpcBindingInqAuthInfoW RpcBindingInqAuthInfo; - alias RpcBindingSetAuthInfoW RpcBindingSetAuthInfo; - alias RpcServerRegisterAuthInfoW RpcServerRegisterAuthInfo; - alias RpcBindingInqAuthInfoExW RpcBindingInqAuthInfoEx; - alias RpcBindingSetAuthInfoExW RpcBindingSetAuthInfoEx; - alias UuidFromStringW UuidFromString; - alias UuidToStringW UuidToString; - alias RpcEpRegisterNoReplaceW RpcEpRegisterNoReplace; - alias RpcEpRegisterW RpcEpRegister; - alias DceErrorInqTextW DceErrorInqText; + alias RPC_PROTSEQ_VECTOR = RPC_PROTSEQ_VECTORW; + alias SEC_WINNT_AUTH_IDENTITY = SEC_WINNT_AUTH_IDENTITY_W; + alias PSEC_WINNT_AUTH_IDENTITY = PSEC_WINNT_AUTH_IDENTITY_W; + alias RpcMgmtEpEltInqNext = RpcMgmtEpEltInqNextW; + alias RpcBindingFromStringBinding = RpcBindingFromStringBindingW; + alias RpcBindingToStringBinding = RpcBindingToStringBindingW; + alias RpcStringBindingCompose = RpcStringBindingComposeW; + alias RpcStringBindingParse = RpcStringBindingParseW; + alias RpcStringFree = RpcStringFreeW; + alias RpcNetworkIsProtseqValid = RpcNetworkIsProtseqValidW; + alias RpcNetworkInqProtseqs = RpcNetworkInqProtseqsW; + alias RpcProtseqVectorFree = RpcProtseqVectorFreeW; + alias RpcServerUseProtseq = RpcServerUseProtseqW; + alias RpcServerUseProtseqEx = RpcServerUseProtseqExW; + alias RpcServerUseProtseqEp = RpcServerUseProtseqEpW; + alias RpcServerUseProtseqEpEx = RpcServerUseProtseqEpExW; + alias RpcServerUseProtseqIf = RpcServerUseProtseqIfW; + alias RpcServerUseProtseqIfEx = RpcServerUseProtseqIfExW; + alias RpcMgmtInqServerPrincName = RpcMgmtInqServerPrincNameW; + alias RpcServerInqDefaultPrincName = RpcServerInqDefaultPrincNameW; + alias RpcNsBindingInqEntryName = RpcNsBindingInqEntryNameW; + alias RpcBindingInqAuthClient = RpcBindingInqAuthClientW; + alias RpcBindingInqAuthInfo = RpcBindingInqAuthInfoW; + alias RpcBindingSetAuthInfo = RpcBindingSetAuthInfoW; + alias RpcServerRegisterAuthInfo = RpcServerRegisterAuthInfoW; + alias RpcBindingInqAuthInfoEx = RpcBindingInqAuthInfoExW; + alias RpcBindingSetAuthInfoEx = RpcBindingSetAuthInfoExW; + alias UuidFromString = UuidFromStringW; + alias UuidToString = UuidToStringW; + alias RpcEpRegisterNoReplace = RpcEpRegisterNoReplaceW; + alias RpcEpRegister = RpcEpRegisterW; + alias DceErrorInqText = DceErrorInqTextW; } else { // Ansi - alias RPC_PROTSEQ_VECTORA RPC_PROTSEQ_VECTOR; - alias SEC_WINNT_AUTH_IDENTITY_A SEC_WINNT_AUTH_IDENTITY; - alias PSEC_WINNT_AUTH_IDENTITY_A PSEC_WINNT_AUTH_IDENTITY; - alias RpcMgmtEpEltInqNextA RpcMgmtEpEltInqNext; - alias RpcBindingFromStringBindingA RpcBindingFromStringBinding; - alias RpcBindingToStringBindingA RpcBindingToStringBinding; - alias RpcStringBindingComposeA RpcStringBindingCompose; - alias RpcStringBindingParseA RpcStringBindingParse; - alias RpcStringFreeA RpcStringFree; - alias RpcNetworkIsProtseqValidA RpcNetworkIsProtseqValid; - alias RpcNetworkInqProtseqsA RpcNetworkInqProtseqs; - alias RpcProtseqVectorFreeA RpcProtseqVectorFree; - alias RpcServerUseProtseqA RpcServerUseProtseq; - alias RpcServerUseProtseqExA RpcServerUseProtseqEx; - alias RpcServerUseProtseqEpA RpcServerUseProtseqEp; - alias RpcServerUseProtseqEpExA RpcServerUseProtseqEpEx; - alias RpcServerUseProtseqIfA RpcServerUseProtseqIf; - alias RpcServerUseProtseqIfExA RpcServerUseProtseqIfEx; - alias RpcMgmtInqServerPrincNameA RpcMgmtInqServerPrincName; - alias RpcServerInqDefaultPrincNameA RpcServerInqDefaultPrincName; - alias RpcNsBindingInqEntryNameA RpcNsBindingInqEntryName; - alias RpcBindingInqAuthClientA RpcBindingInqAuthClient; - alias RpcBindingInqAuthInfoA RpcBindingInqAuthInfo; - alias RpcBindingSetAuthInfoA RpcBindingSetAuthInfo; - alias RpcServerRegisterAuthInfoA RpcServerRegisterAuthInfo; - alias RpcBindingInqAuthInfoExA RpcBindingInqAuthInfoEx; - alias RpcBindingSetAuthInfoExA RpcBindingSetAuthInfoEx; - alias UuidFromStringA UuidFromString; - alias UuidToStringA UuidToString; - alias RpcEpRegisterNoReplaceA RpcEpRegisterNoReplace; - alias RpcEpRegisterA RpcEpRegister; - alias DceErrorInqTextA DceErrorInqText; + alias RPC_PROTSEQ_VECTOR = RPC_PROTSEQ_VECTORA; + alias SEC_WINNT_AUTH_IDENTITY = SEC_WINNT_AUTH_IDENTITY_A; + alias PSEC_WINNT_AUTH_IDENTITY = PSEC_WINNT_AUTH_IDENTITY_A; + alias RpcMgmtEpEltInqNext = RpcMgmtEpEltInqNextA; + alias RpcBindingFromStringBinding = RpcBindingFromStringBindingA; + alias RpcBindingToStringBinding = RpcBindingToStringBindingA; + alias RpcStringBindingCompose = RpcStringBindingComposeA; + alias RpcStringBindingParse = RpcStringBindingParseA; + alias RpcStringFree = RpcStringFreeA; + alias RpcNetworkIsProtseqValid = RpcNetworkIsProtseqValidA; + alias RpcNetworkInqProtseqs = RpcNetworkInqProtseqsA; + alias RpcProtseqVectorFree = RpcProtseqVectorFreeA; + alias RpcServerUseProtseq = RpcServerUseProtseqA; + alias RpcServerUseProtseqEx = RpcServerUseProtseqExA; + alias RpcServerUseProtseqEp = RpcServerUseProtseqEpA; + alias RpcServerUseProtseqEpEx = RpcServerUseProtseqEpExA; + alias RpcServerUseProtseqIf = RpcServerUseProtseqIfA; + alias RpcServerUseProtseqIfEx = RpcServerUseProtseqIfExA; + alias RpcMgmtInqServerPrincName = RpcMgmtInqServerPrincNameA; + alias RpcServerInqDefaultPrincName = RpcServerInqDefaultPrincNameA; + alias RpcNsBindingInqEntryName = RpcNsBindingInqEntryNameA; + alias RpcBindingInqAuthClient = RpcBindingInqAuthClientA; + alias RpcBindingInqAuthInfo = RpcBindingInqAuthInfoA; + alias RpcBindingSetAuthInfo = RpcBindingSetAuthInfoA; + alias RpcServerRegisterAuthInfo = RpcServerRegisterAuthInfoA; + alias RpcBindingInqAuthInfoEx = RpcBindingInqAuthInfoExA; + alias RpcBindingSetAuthInfoEx = RpcBindingSetAuthInfoExA; + alias UuidFromString = UuidFromStringA; + alias UuidToString = UuidToStringA; + alias RpcEpRegisterNoReplace = RpcEpRegisterNoReplaceA; + alias RpcEpRegister = RpcEpRegisterA; + alias DceErrorInqText = DceErrorInqTextA; } //#endif // UNICODE extern (Windows) { diff --git a/runtime/druntime/src/core/sys/windows/rpcdce2.d b/runtime/druntime/src/core/sys/windows/rpcdce2.d index 08348c0623..85b4cb146a 100644 --- a/runtime/druntime/src/core/sys/windows/rpcdce2.d +++ b/runtime/druntime/src/core/sys/windows/rpcdce2.d @@ -69,11 +69,11 @@ extern (Windows) { } version (Unicode) { - alias RpcMgmtEpEltInqNextW RpcMgmtEpEltInqNext; - alias DceErrorInqTextW DceErrorInqText; + alias RpcMgmtEpEltInqNext = RpcMgmtEpEltInqNextW; + alias DceErrorInqText = DceErrorInqTextW; } else { - alias RpcMgmtEpEltInqNextA RpcMgmtEpEltInqNext; - alias DceErrorInqTextA DceErrorInqText; + alias RpcMgmtEpEltInqNext = RpcMgmtEpEltInqNextA; + alias DceErrorInqText = DceErrorInqTextA; } /+ #else /* RPC_UNICODE_SUPPORTED */ diff --git a/runtime/druntime/src/core/sys/windows/rpcdcep.d b/runtime/druntime/src/core/sys/windows/rpcdcep.d index 421c2752b1..d123feb1ef 100644 --- a/runtime/druntime/src/core/sys/windows/rpcdcep.d +++ b/runtime/druntime/src/core/sys/windows/rpcdcep.d @@ -16,7 +16,7 @@ import core.sys.windows.w32api; import core.sys.windows.windef; alias I_RPC_HANDLE = HANDLE; -alias long RPC_STATUS; +alias RPC_STATUS = long; enum RPC_NCA_FLAGS_DEFAULT=0; enum RPC_NCA_FLAGS_IDEMPOTENT=1; @@ -39,7 +39,7 @@ struct RPC_SYNTAX_IDENTIFIER { GUID SyntaxGUID; RPC_VERSION SyntaxVersion; } -alias RPC_SYNTAX_IDENTIFIER* PRPC_SYNTAX_IDENTIFIER; +alias PRPC_SYNTAX_IDENTIFIER = RPC_SYNTAX_IDENTIFIER*; struct RPC_MESSAGE { HANDLE Handle; @@ -54,10 +54,10 @@ struct RPC_MESSAGE { void* ImportContext; uint RpcFlags; } -alias RPC_MESSAGE* PRPC_MESSAGE; +alias PRPC_MESSAGE = RPC_MESSAGE*; extern (Windows) { -alias void function (PRPC_MESSAGE Message) RPC_DISPATCH_FUNCTION; +alias RPC_DISPATCH_FUNCTION = void function (PRPC_MESSAGE Message); } struct RPC_DISPATCH_TABLE { @@ -65,13 +65,13 @@ struct RPC_DISPATCH_TABLE { RPC_DISPATCH_FUNCTION* DispatchTable; LONG_PTR Reserved; } -alias RPC_DISPATCH_TABLE* PRPC_DISPATCH_TABLE; +alias PRPC_DISPATCH_TABLE = RPC_DISPATCH_TABLE*; struct RPC_PROTSEQ_ENDPOINT { ubyte* RpcProtocolSequence; ubyte* Endpoint; } -alias RPC_PROTSEQ_ENDPOINT* PRPC_PROTSEQ_ENDPOINT; +alias PRPC_PROTSEQ_ENDPOINT = RPC_PROTSEQ_ENDPOINT*; struct RPC_SERVER_INTERFACE { uint Length; @@ -83,7 +83,7 @@ struct RPC_SERVER_INTERFACE { void* DefaultManagerEpv; const(void)* InterpreterInfo; } -alias RPC_SERVER_INTERFACE* PRPC_SERVER_INTERFACE; +alias PRPC_SERVER_INTERFACE = RPC_SERVER_INTERFACE*; struct RPC_CLIENT_INTERFACE { uint Length; @@ -95,19 +95,19 @@ struct RPC_CLIENT_INTERFACE { ULONG_PTR Reserved; const(void)* InterpreterInfo; } -alias RPC_CLIENT_INTERFACE* PRPC_CLIENT_INTERFACE; +alias PRPC_CLIENT_INTERFACE = RPC_CLIENT_INTERFACE*; -alias void* I_RPC_MUTEX; +alias I_RPC_MUTEX = void*; struct RPC_TRANSFER_SYNTAX { GUID Uuid; ushort VersMajor; ushort VersMinor; } -alias RPC_STATUS function(void*, void*, void*) RPC_BLOCKING_FN; +alias RPC_BLOCKING_FN = RPC_STATUS function(void*, void*, void*); extern (Windows) { - alias void function(void*) PRPC_RUNDOWN; + alias PRPC_RUNDOWN = void function(void*); int I_RpcGetBuffer(RPC_MESSAGE*); int I_RpcSendReceive(RPC_MESSAGE*); @@ -147,7 +147,7 @@ extern (Windows) { } version (Unicode) { - alias I_RpcServerUnregisterEndpointW I_RpcServerUnregisterEndpoint; + alias I_RpcServerUnregisterEndpoint = I_RpcServerUnregisterEndpointW; } else { - alias I_RpcServerUnregisterEndpointA I_RpcServerUnregisterEndpoint; + alias I_RpcServerUnregisterEndpoint = I_RpcServerUnregisterEndpointA; } diff --git a/runtime/druntime/src/core/sys/windows/rpcndr.d b/runtime/druntime/src/core/sys/windows/rpcndr.d index f5744ecdb0..ee9417fbba 100644 --- a/runtime/druntime/src/core/sys/windows/rpcndr.d +++ b/runtime/druntime/src/core/sys/windows/rpcndr.d @@ -37,12 +37,12 @@ enum uint NDR_CHAR_REP_MASK = 0xF, NDR_LOCAL_DATA_REPRESENTATION = 0x10, NDR_LOCAL_ENDIAN = NDR_LITTLE_ENDIAN; -alias MIDL_user_allocate midl_user_allocate; -alias MIDL_user_free midl_user_free; +alias midl_user_allocate = MIDL_user_allocate; +alias midl_user_free = MIDL_user_free; -alias long hyper; -alias ulong MIDL_uhyper; -alias char small; +alias hyper = long; +alias MIDL_uhyper = ulong; +alias small = char; enum cbNDRContext=20; //MACRO #define NDRSContextValue(hContext) (&(hContext)->userContext) @@ -97,27 +97,27 @@ enum cbNDRContext=20; //MACRO #define NdrFcShort(s) (unsigned char)(s & 0xff), (unsigned char)(s >> 8) //MACRO #define NdrFcLong(s) (unsigned char)(s & 0xff), (unsigned char)((s & 0x0000ff00) >> 8), (unsigned char)((s & 0x00ff0000) >> 16), (unsigned char)(s >> 24) -alias void * NDR_CCONTEXT; +alias NDR_CCONTEXT = void *; struct tagNDR_SCONTEXT { void*[2] pad; void *userContext; } -alias tagNDR_SCONTEXT * NDR_SCONTEXT; +alias NDR_SCONTEXT = tagNDR_SCONTEXT *; struct SCONTEXT_QUEUE { uint NumberOfObjects; NDR_SCONTEXT *ArrayOfObjects; } -alias SCONTEXT_QUEUE * PSCONTEXT_QUEUE; +alias PSCONTEXT_QUEUE = SCONTEXT_QUEUE *; struct _MIDL_STUB_MESSAGE; struct _MIDL_STUB_DESC; struct _FULL_PTR_XLAT_TABLES; -alias ubyte *RPC_BUFPTR; -alias uint RPC_LENGTH; +alias RPC_BUFPTR = ubyte *; +alias RPC_LENGTH = uint; -alias const(char)* PFORMAT_STRING; +alias PFORMAT_STRING = const(char)*; struct ARRAY_INFO { int Dimension; @@ -127,7 +127,7 @@ struct ARRAY_INFO { uint *OffsetArray; uint *ActualCountArray; } -alias ARRAY_INFO * PARRAY_INFO; +alias PARRAY_INFO = ARRAY_INFO *; RPC_BINDING_HANDLE NDRCContextBinding(NDR_CCONTEXT); void NDRCContextMarshall(NDR_CCONTEXT,void*); @@ -212,16 +212,16 @@ const(_MIDL_STUB_DESC)* StubDesc; uint dwStubPhase; INT_PTR[5] w2kReserved; } -alias MIDL_STUB_MESSAGE * PMIDL_STUB_MESSAGE; +alias PMIDL_STUB_MESSAGE = MIDL_STUB_MESSAGE *; extern (Windows) { - alias void* function (void*) GENERIC_BINDING_ROUTINE; - alias void function (void*,ubyte*) GENERIC_UNBIND_ROUTINE; - alias uint function (uint *,uint,void *) USER_MARSHAL_SIZING_ROUTINE; - alias ubyte * function (uint *,ubyte *,void *) USER_MARSHAL_MARSHALLING_ROUTINE; - alias ubyte * function (uint *,ubyte *,void *) USER_MARSHAL_UNMARSHALLING_ROUTINE; - alias void function (uint *,void *) USER_MARSHAL_FREEING_ROUTINE; - alias void function () NDR_NOTIFY_ROUTINE; + alias GENERIC_BINDING_ROUTINE = void* function (void*); + alias GENERIC_UNBIND_ROUTINE = void function (void*,ubyte*); + alias USER_MARSHAL_SIZING_ROUTINE = uint function (uint *,uint,void *); + alias USER_MARSHAL_MARSHALLING_ROUTINE = ubyte * function (uint *,ubyte *,void *); + alias USER_MARSHAL_UNMARSHALLING_ROUTINE = ubyte * function (uint *,ubyte *,void *); + alias USER_MARSHAL_FREEING_ROUTINE = void function (uint *,void *); + alias NDR_NOTIFY_ROUTINE = void function (); } align: @@ -229,7 +229,7 @@ struct GENERIC_BINDING_ROUTINE_PAIR { GENERIC_BINDING_ROUTINE pfnBind; GENERIC_UNBIND_ROUTINE pfnUnbind; } -alias GENERIC_BINDING_ROUTINE_PAIR * PGENERIC_BINDING_ROUTINE_PAIR; +alias PGENERIC_BINDING_ROUTINE_PAIR = GENERIC_BINDING_ROUTINE_PAIR *; struct GENERIC_BINDING_INFO { void *pObj; @@ -237,7 +237,7 @@ struct GENERIC_BINDING_INFO { GENERIC_BINDING_ROUTINE pfnBind; GENERIC_UNBIND_ROUTINE pfnUnbind; } -alias GENERIC_BINDING_INFO * PGENERIC_BINDING_INFO; +alias PGENERIC_BINDING_INFO = GENERIC_BINDING_INFO *; struct XMIT_ROUTINE_QUINTUPLE { @@ -246,7 +246,7 @@ struct XMIT_ROUTINE_QUINTUPLE { XMIT_HELPER_ROUTINE pfnFreeXmit; XMIT_HELPER_ROUTINE pfnFreeInst; } -alias XMIT_ROUTINE_QUINTUPLE * PXMIT_ROUTINE_QUINTUPLE; +alias PXMIT_ROUTINE_QUINTUPLE = XMIT_ROUTINE_QUINTUPLE *; struct MALLOC_FREE_STRUCT { void* function (uint) pfnAllocate; @@ -310,9 +310,9 @@ const(NDR_CS_ROUTINES)* CsRoutineTables; void *Reserved4; ULONG_PTR Reserved5; } -alias const(MIDL_STUB_DESC)* PMIDL_STUB_DESC; +alias PMIDL_STUB_DESC = const(MIDL_STUB_DESC)*; -alias void * PMIDL_XMIT_TYPE; +alias PMIDL_XMIT_TYPE = void *; struct MIDL_FORMAT_STRING { short Pad; @@ -326,14 +326,14 @@ const(SERVER_ROUTINE)* DispatchTable; const(ushort)* FmtStringOffset; const(STUB_THUNK)* ThunkTable; } -alias MIDL_SERVER_INFO * PMIDL_SERVER_INFO; +alias PMIDL_SERVER_INFO = MIDL_SERVER_INFO *; struct MIDL_STUBLESS_PROXY_INFO { PMIDL_STUB_DESC pStubDesc; PFORMAT_STRING ProcFormatString; const(ushort)* FormatStringOffset; } -alias MIDL_STUBLESS_PROXY_INFO *PMIDL_STUBLESS_PROXY_INFO; +alias PMIDL_STUBLESS_PROXY_INFO = MIDL_STUBLESS_PROXY_INFO *; union CLIENT_CALL_RETURN { void *Pointer; @@ -350,7 +350,7 @@ struct FULL_PTR_TO_REFID_ELEMENT { uint RefId; ubyte State; } -alias FULL_PTR_TO_REFID_ELEMENT * PFULL_PTR_TO_REFID_ELEMENT; +alias PFULL_PTR_TO_REFID_ELEMENT = FULL_PTR_TO_REFID_ELEMENT *; struct FULL_PTR_XLAT_TABLES { struct _RefIdToPointer { @@ -369,7 +369,7 @@ struct FULL_PTR_XLAT_TABLES { uint NextRefId; XLAT_SIDE XlatSide; } -alias FULL_PTR_XLAT_TABLES * PFULL_PTR_XLAT_TABLES; +alias PFULL_PTR_XLAT_TABLES = FULL_PTR_XLAT_TABLES *; enum STUB_PHASE { @@ -387,25 +387,25 @@ enum PROXY_PHASE { PROXY_UNMARSHAL } -alias void * RPC_SS_THREAD_HANDLE; +alias RPC_SS_THREAD_HANDLE = void *; extern (Windows) { -alias void function (void*) NDR_RUNDOWN; -alias void function (_MIDL_STUB_MESSAGE*) EXPR_EVAL; -alias void function(PMIDL_STUB_MESSAGE) XMIT_HELPER_ROUTINE; -alias void function (RPC_BINDING_HANDLE,uint,uint,IDL_CS_CONVERT*,uint*,error_status_t*) CS_TYPE_NET_SIZE_ROUTINE; -alias void function (RPC_BINDING_HANDLE,uint,uint,IDL_CS_CONVERT*,uint*,error_status_t*) CS_TYPE_LOCAL_SIZE_ROUTINE; -alias void function (RPC_BINDING_HANDLE,uint,void*,uint,byte*,uint*,error_status_t*) CS_TYPE_TO_NETCS_ROUTINE; -alias void function (RPC_BINDING_HANDLE,uint,byte*,uint,uint,void*,uint*,error_status_t*) CS_TYPE_FROM_NETCS_ROUTINE; -alias void function (RPC_BINDING_HANDLE,int,uint*,uint*,uint*,error_status_t*) CS_TAG_GETTING_ROUTINE; +alias NDR_RUNDOWN = void function (void*); +alias EXPR_EVAL = void function (_MIDL_STUB_MESSAGE*); +alias XMIT_HELPER_ROUTINE = void function(PMIDL_STUB_MESSAGE); +alias CS_TYPE_NET_SIZE_ROUTINE = void function (RPC_BINDING_HANDLE,uint,uint,IDL_CS_CONVERT*,uint*,error_status_t*); +alias CS_TYPE_LOCAL_SIZE_ROUTINE = void function (RPC_BINDING_HANDLE,uint,uint,IDL_CS_CONVERT*,uint*,error_status_t*); +alias CS_TYPE_TO_NETCS_ROUTINE = void function (RPC_BINDING_HANDLE,uint,void*,uint,byte*,uint*,error_status_t*); +alias CS_TYPE_FROM_NETCS_ROUTINE = void function (RPC_BINDING_HANDLE,uint,byte*,uint,uint,void*,uint*,error_status_t*); +alias CS_TAG_GETTING_ROUTINE = void function (RPC_BINDING_HANDLE,int,uint*,uint*,uint*,error_status_t*); //alias void* RPC_CLIENT_ALLOC(uint); //alias void RPC_CLIENT_FREE(void*); -alias void* function(uint) PRPC_CLIENT_ALLOC; -alias void function(void*) PRPC_CLIENT_FREE; +alias PRPC_CLIENT_ALLOC = void* function(uint); +alias PRPC_CLIENT_FREE = void function(void*); - alias void function (PMIDL_STUB_MESSAGE) STUB_THUNK; - alias int function() SERVER_ROUTINE; + alias STUB_THUNK = void function (PMIDL_STUB_MESSAGE); + alias SERVER_ROUTINE = int function(); } void NdrSimpleTypeMarshall(PMIDL_STUB_MESSAGE,ubyte*,ubyte); diff --git a/runtime/druntime/src/core/sys/windows/rpcnsi.d b/runtime/druntime/src/core/sys/windows/rpcnsi.d index 60c7b0972a..ee2d2093e2 100644 --- a/runtime/druntime/src/core/sys/windows/rpcnsi.d +++ b/runtime/druntime/src/core/sys/windows/rpcnsi.d @@ -107,45 +107,45 @@ version (Unicode) { } version (Unicode) { - alias RpcNsBindingLookupBeginW RpcNsBindingLookupBegin; - alias RpcNsBindingImportBeginW RpcNsBindingImportBegin; - alias RpcNsBindingExportW RpcNsBindingExport; - alias RpcNsBindingUnexportW RpcNsBindingUnexport; - alias RpcNsGroupDeleteW RpcNsGroupDelete; - alias RpcNsGroupMbrAddW RpcNsGroupMbrAdd; - alias RpcNsGroupMbrRemoveW RpcNsGroupMbrRemove; - alias RpcNsGroupMbrInqBeginW RpcNsGroupMbrInqBegin; - alias RpcNsGroupMbrInqNextW RpcNsGroupMbrInqNext; - alias RpcNsEntryExpandNameW RpcNsEntryExpandName; - alias RpcNsEntryObjectInqBeginW RpcNsEntryObjectInqBegin; - alias RpcNsMgmtBindingUnexportW RpcNsMgmtBindingUnexport; - alias RpcNsMgmtEntryCreateW RpcNsMgmtEntryCreate; - alias RpcNsMgmtEntryDeleteW RpcNsMgmtEntryDelete; - alias RpcNsMgmtEntryInqIfIdsW RpcNsMgmtEntryInqIfIds; - alias RpcNsProfileDeleteW RpcNsProfileDelete; - alias RpcNsProfileEltAddW RpcNsProfileEltAdd; - alias RpcNsProfileEltRemoveW RpcNsProfileEltRemove; - alias RpcNsProfileEltInqBeginW RpcNsProfileEltInqBegin; - alias RpcNsProfileEltInqNextW RpcNsProfileEltInqNext; + alias RpcNsBindingLookupBegin = RpcNsBindingLookupBeginW; + alias RpcNsBindingImportBegin = RpcNsBindingImportBeginW; + alias RpcNsBindingExport = RpcNsBindingExportW; + alias RpcNsBindingUnexport = RpcNsBindingUnexportW; + alias RpcNsGroupDelete = RpcNsGroupDeleteW; + alias RpcNsGroupMbrAdd = RpcNsGroupMbrAddW; + alias RpcNsGroupMbrRemove = RpcNsGroupMbrRemoveW; + alias RpcNsGroupMbrInqBegin = RpcNsGroupMbrInqBeginW; + alias RpcNsGroupMbrInqNext = RpcNsGroupMbrInqNextW; + alias RpcNsEntryExpandName = RpcNsEntryExpandNameW; + alias RpcNsEntryObjectInqBegin = RpcNsEntryObjectInqBeginW; + alias RpcNsMgmtBindingUnexport = RpcNsMgmtBindingUnexportW; + alias RpcNsMgmtEntryCreate = RpcNsMgmtEntryCreateW; + alias RpcNsMgmtEntryDelete = RpcNsMgmtEntryDeleteW; + alias RpcNsMgmtEntryInqIfIds = RpcNsMgmtEntryInqIfIdsW; + alias RpcNsProfileDelete = RpcNsProfileDeleteW; + alias RpcNsProfileEltAdd = RpcNsProfileEltAddW; + alias RpcNsProfileEltRemove = RpcNsProfileEltRemoveW; + alias RpcNsProfileEltInqBegin = RpcNsProfileEltInqBeginW; + alias RpcNsProfileEltInqNext = RpcNsProfileEltInqNextW; } else { - alias RpcNsBindingLookupBeginA RpcNsBindingLookupBegin; - alias RpcNsBindingImportBeginA RpcNsBindingImportBegin; - alias RpcNsBindingExportA RpcNsBindingExport; - alias RpcNsBindingUnexportA RpcNsBindingUnexport; - alias RpcNsGroupDeleteA RpcNsGroupDelete; - alias RpcNsGroupMbrAddA RpcNsGroupMbrAdd; - alias RpcNsGroupMbrRemoveA RpcNsGroupMbrRemove; - alias RpcNsGroupMbrInqBeginA RpcNsGroupMbrInqBegin; - alias RpcNsGroupMbrInqNextA RpcNsGroupMbrInqNext; - alias RpcNsEntryExpandNameA RpcNsEntryExpandName; - alias RpcNsEntryObjectInqBeginA RpcNsEntryObjectInqBegin; - alias RpcNsMgmtBindingUnexportA RpcNsMgmtBindingUnexport; - alias RpcNsMgmtEntryCreateA RpcNsMgmtEntryCreate; - alias RpcNsMgmtEntryDeleteA RpcNsMgmtEntryDelete; - alias RpcNsMgmtEntryInqIfIdsA RpcNsMgmtEntryInqIfIds; - alias RpcNsProfileDeleteA RpcNsProfileDelete; - alias RpcNsProfileEltAddA RpcNsProfileEltAdd; - alias RpcNsProfileEltRemoveA RpcNsProfileEltRemove; - alias RpcNsProfileEltInqBeginA RpcNsProfileEltInqBegin; - alias RpcNsProfileEltInqNextA RpcNsProfileEltInqNext; + alias RpcNsBindingLookupBegin = RpcNsBindingLookupBeginA; + alias RpcNsBindingImportBegin = RpcNsBindingImportBeginA; + alias RpcNsBindingExport = RpcNsBindingExportA; + alias RpcNsBindingUnexport = RpcNsBindingUnexportA; + alias RpcNsGroupDelete = RpcNsGroupDeleteA; + alias RpcNsGroupMbrAdd = RpcNsGroupMbrAddA; + alias RpcNsGroupMbrRemove = RpcNsGroupMbrRemoveA; + alias RpcNsGroupMbrInqBegin = RpcNsGroupMbrInqBeginA; + alias RpcNsGroupMbrInqNext = RpcNsGroupMbrInqNextA; + alias RpcNsEntryExpandName = RpcNsEntryExpandNameA; + alias RpcNsEntryObjectInqBegin = RpcNsEntryObjectInqBeginA; + alias RpcNsMgmtBindingUnexport = RpcNsMgmtBindingUnexportA; + alias RpcNsMgmtEntryCreate = RpcNsMgmtEntryCreateA; + alias RpcNsMgmtEntryDelete = RpcNsMgmtEntryDeleteA; + alias RpcNsMgmtEntryInqIfIds = RpcNsMgmtEntryInqIfIdsA; + alias RpcNsProfileDelete = RpcNsProfileDeleteA; + alias RpcNsProfileEltAdd = RpcNsProfileEltAddA; + alias RpcNsProfileEltRemove = RpcNsProfileEltRemoveA; + alias RpcNsProfileEltInqBegin = RpcNsProfileEltInqBeginA; + alias RpcNsProfileEltInqNext = RpcNsProfileEltInqNextA; } diff --git a/runtime/druntime/src/core/sys/windows/rpcnsip.d b/runtime/druntime/src/core/sys/windows/rpcnsip.d index ccf026f495..f951e11ad9 100644 --- a/runtime/druntime/src/core/sys/windows/rpcnsip.d +++ b/runtime/druntime/src/core/sys/windows/rpcnsip.d @@ -16,7 +16,7 @@ struct RPC_IMPORT_CONTEXT_P { RPC_BINDING_HANDLE ProposedHandle; RPC_BINDING_VECTOR* Bindings; } -alias RPC_IMPORT_CONTEXT_P* PRPC_IMPORT_CONTEXT_P; +alias PRPC_IMPORT_CONTEXT_P = RPC_IMPORT_CONTEXT_P*; extern(Windows) { RPC_STATUS I_RpcNsGetBuffer(PRPC_MESSAGE); diff --git a/runtime/druntime/src/core/sys/windows/schannel.d b/runtime/druntime/src/core/sys/windows/schannel.d index 6ffab30f17..4456a3f4b7 100644 --- a/runtime/druntime/src/core/sys/windows/schannel.d +++ b/runtime/druntime/src/core/sys/windows/schannel.d @@ -69,30 +69,30 @@ struct SCHANNEL_CRED { DWORD dwFlags; DWORD reserved; } -alias SCHANNEL_CRED* PSCHANNEL_CRED; +alias PSCHANNEL_CRED = SCHANNEL_CRED*; struct SecPkgCred_SupportedAlgs { DWORD cSupportedAlgs; ALG_ID* palgSupportedAlgs; } -alias SecPkgCred_SupportedAlgs* PSecPkgCred_SupportedAlgs; +alias PSecPkgCred_SupportedAlgs = SecPkgCred_SupportedAlgs*; struct SecPkgCred_CypherStrengths { DWORD dwMinimumCypherStrength; DWORD dwMaximumCypherStrength; } -alias SecPkgCred_CypherStrengths* PSecPkgCred_CypherStrengths; +alias PSecPkgCred_CypherStrengths = SecPkgCred_CypherStrengths*; struct SecPkgCred_SupportedProtocols { DWORD grbitProtocol; } -alias SecPkgCred_SupportedProtocols* PSecPkgCred_SupportedProtocols; +alias PSecPkgCred_SupportedProtocols = SecPkgCred_SupportedProtocols*; struct SecPkgContext_IssuerListInfoEx { PCERT_NAME_BLOB aIssuers; DWORD cIssuers; } -alias SecPkgContext_IssuerListInfoEx* PSecPkgContext_IssuerListInfoEx; +alias PSecPkgContext_IssuerListInfoEx = SecPkgContext_IssuerListInfoEx*; struct SecPkgContext_ConnectionInfo { DWORD dwProtocol; @@ -103,4 +103,4 @@ struct SecPkgContext_ConnectionInfo { ALG_ID aiExch; DWORD dwExchStrength; } -alias SecPkgContext_ConnectionInfo* PSecPkgContext_ConnectionInfo; +alias PSecPkgContext_ConnectionInfo = SecPkgContext_ConnectionInfo*; diff --git a/runtime/druntime/src/core/sys/windows/secext.d b/runtime/druntime/src/core/sys/windows/secext.d index ab615365aa..79b7bececc 100644 --- a/runtime/druntime/src/core/sys/windows/secext.d +++ b/runtime/druntime/src/core/sys/windows/secext.d @@ -30,7 +30,7 @@ enum EXTENDED_NAME_FORMAT { NameServicePrincipal, // = 10 NameDnsDomain = 12 } -alias EXTENDED_NAME_FORMAT* PEXTENDED_NAME_FORMAT; +alias PEXTENDED_NAME_FORMAT = EXTENDED_NAME_FORMAT*; extern (Windows) { BOOLEAN GetComputerObjectNameA(EXTENDED_NAME_FORMAT, LPSTR, PULONG); @@ -44,11 +44,11 @@ extern (Windows) { } version (Unicode) { - alias GetComputerObjectNameW GetComputerObjectName; - alias GetUserNameExW GetUserNameEx; - alias TranslateNameW TranslateName; + alias GetComputerObjectName = GetComputerObjectNameW; + alias GetUserNameEx = GetUserNameExW; + alias TranslateName = TranslateNameW; } else { - alias GetComputerObjectNameA GetComputerObjectName; - alias GetUserNameExA GetUserNameEx; - alias TranslateNameA TranslateName; + alias GetComputerObjectName = GetComputerObjectNameA; + alias GetUserNameEx = GetUserNameExA; + alias TranslateName = TranslateNameA; } diff --git a/runtime/druntime/src/core/sys/windows/setupapi.d b/runtime/druntime/src/core/sys/windows/setupapi.d index da50386478..2c226eb83e 100644 --- a/runtime/druntime/src/core/sys/windows/setupapi.d +++ b/runtime/druntime/src/core/sys/windows/setupapi.d @@ -163,7 +163,7 @@ enum : DWORD { DICS_FLAG_CONFIGGENERAL = 4 } -alias UINT DI_FUNCTION; +alias DI_FUNCTION = UINT; enum : DI_FUNCTION { DIF_SELECTDEVICE = 1, @@ -566,7 +566,7 @@ enum : DWORD { INFINFO_INF_PATH_LIST_SEARCH // = 5 } -alias DWORD LogSeverity; +alias LogSeverity = DWORD; enum : LogSeverity { LogSevInformation, LogSevWarning, @@ -856,11 +856,11 @@ enum : DWORD { SRCLIST_NOSTRIPPLATFORM = 0x00000400 } -alias PVOID HINF; -alias PVOID HDSKSPC; +alias HINF = PVOID; +alias HDSKSPC = PVOID; alias HDEVINFO = HANDLE; -alias PVOID HSPFILEQ; -alias PVOID HSPFILELOG; +alias HSPFILEQ = PVOID; +alias HSPFILELOG = PVOID; enum SetupFileLogInfo { SetupFileLogSourceFilename, @@ -882,7 +882,7 @@ struct INFCONTEXT { UINT Section; UINT Line; } -alias INFCONTEXT* PINFCONTEXT; +alias PINFCONTEXT = INFCONTEXT*; mixin AlignedStr!(_alignVal, "SP_INF_INFORMATION", q{ DWORD InfStyle; @@ -890,7 +890,7 @@ mixin AlignedStr!(_alignVal, "SP_INF_INFORMATION", q{ BYTE[1] _VersionData; BYTE* VersionData() return { return _VersionData.ptr; } }); -alias SP_INF_INFORMATION* PSP_INF_INFORMATION; +alias PSP_INF_INFORMATION = SP_INF_INFORMATION*; struct SP_ALTPLATFORM_INFO { DWORD cbSize = SP_ALTPLATFORM_INFO.sizeof; @@ -900,21 +900,21 @@ struct SP_ALTPLATFORM_INFO { WORD ProcessorArchitecture; WORD Reserved; } -alias SP_ALTPLATFORM_INFO* PSP_ALTPLATFORM_INFO; +alias PSP_ALTPLATFORM_INFO = SP_ALTPLATFORM_INFO*; struct SP_ORIGINAL_FILE_INFO_A { DWORD cbSize = SP_ORIGINAL_FILE_INFO_A.sizeof; CHAR[MAX_PATH] OriginalInfName = 0; CHAR[MAX_PATH] OriginalCatalogName = 0; } -alias SP_ORIGINAL_FILE_INFO_A* PSP_ORIGINAL_FILE_INFO_A; +alias PSP_ORIGINAL_FILE_INFO_A = SP_ORIGINAL_FILE_INFO_A*; struct SP_ORIGINAL_FILE_INFO_W { DWORD cbSize = SP_ORIGINAL_FILE_INFO_W.sizeof; WCHAR[MAX_PATH] OriginalInfName = 0; WCHAR[MAX_PATH] OriginalCatalogName = 0; } -alias SP_ORIGINAL_FILE_INFO_W* PSP_ORIGINAL_FILE_INFO_W; +alias PSP_ORIGINAL_FILE_INFO_W = SP_ORIGINAL_FILE_INFO_W*; struct FILEPATHS_A { PCSTR Target; @@ -922,7 +922,7 @@ struct FILEPATHS_A { UINT Win32Error; DWORD Flags; } -alias FILEPATHS_A* PFILEPATHS_A; +alias PFILEPATHS_A = FILEPATHS_A*; struct FILEPATHS_W { PCWSTR Target; @@ -930,7 +930,7 @@ struct FILEPATHS_W { UINT Win32Error; DWORD Flags; } -alias FILEPATHS_W* PFILEPATHS_W; +alias PFILEPATHS_W = FILEPATHS_W*; struct SOURCE_MEDIA_A { PCSTR Reserved; @@ -940,7 +940,7 @@ struct SOURCE_MEDIA_A { PCSTR SourceFile; DWORD Flags; } -alias SOURCE_MEDIA_A* PSOURCE_MEDIA_A; +alias PSOURCE_MEDIA_A = SOURCE_MEDIA_A*; struct SOURCE_MEDIA_W { PCWSTR Reserved; @@ -950,7 +950,7 @@ struct SOURCE_MEDIA_W { PCWSTR SourceFile; DWORD Flags; } -alias SOURCE_MEDIA_W* PSOURCE_MEDIA_W; +alias PSOURCE_MEDIA_W = SOURCE_MEDIA_W*; struct CABINET_INFO_A { PCSTR CabinetPath; @@ -959,7 +959,7 @@ struct CABINET_INFO_A { USHORT SetId; USHORT CabinetNumber; } -alias CABINET_INFO_A* PCABINET_INFO_A; +alias PCABINET_INFO_A = CABINET_INFO_A*; struct CABINET_INFO_W { PCWSTR CabinetPath; @@ -968,7 +968,7 @@ struct CABINET_INFO_W { USHORT SetId; USHORT CabinetNumber; } -alias CABINET_INFO_W* PCABINET_INFO_W; +alias PCABINET_INFO_W = CABINET_INFO_W*; mixin AlignedStr!(_alignVal, "FILE_IN_CABINET_INFO_A", q{ PCSTR NameInCabinet; @@ -979,7 +979,7 @@ mixin AlignedStr!(_alignVal, "FILE_IN_CABINET_INFO_A", q{ WORD DosAttribs; CHAR[MAX_PATH] FullTargetName = 0; }); -alias FILE_IN_CABINET_INFO_A* PFILE_IN_CABINET_INFO_A; +alias PFILE_IN_CABINET_INFO_A = FILE_IN_CABINET_INFO_A*; mixin AlignedStr!(_alignVal, "FILE_IN_CABINET_INFO_W", q{ PCWSTR NameInCabinet; @@ -990,7 +990,7 @@ mixin AlignedStr!(_alignVal, "FILE_IN_CABINET_INFO_W", q{ WORD DosAttribs; WCHAR[MAX_PATH] FullTargetName = 0; }); -alias FILE_IN_CABINET_INFO_W* PFILE_IN_CABINET_INFO_W; +alias PFILE_IN_CABINET_INFO_W = FILE_IN_CABINET_INFO_W*; struct SP_FILE_COPY_PARAMS_A { DWORD cbSize = SP_FILE_COPY_PARAMS_A.sizeof; @@ -1006,7 +1006,7 @@ struct SP_FILE_COPY_PARAMS_A { HINF LayoutInf; PCSTR SecurityDescriptor; } -alias SP_FILE_COPY_PARAMS_A* PSP_FILE_COPY_PARAMS_A; +alias PSP_FILE_COPY_PARAMS_A = SP_FILE_COPY_PARAMS_A*; struct SP_FILE_COPY_PARAMS_W { DWORD cbSize = SP_FILE_COPY_PARAMS_W.sizeof; @@ -1022,7 +1022,7 @@ struct SP_FILE_COPY_PARAMS_W { HINF LayoutInf; PCWSTR SecurityDescriptor; } -alias SP_FILE_COPY_PARAMS_W* PSP_FILE_COPY_PARAMS_W; +alias PSP_FILE_COPY_PARAMS_W = SP_FILE_COPY_PARAMS_W*; struct SP_DEVINFO_DATA { DWORD cbSize = SP_DEVINFO_DATA.sizeof; @@ -1030,7 +1030,7 @@ struct SP_DEVINFO_DATA { DWORD DevInst; ULONG_PTR Reserved; } -alias SP_DEVINFO_DATA* PSP_DEVINFO_DATA; +alias PSP_DEVINFO_DATA = SP_DEVINFO_DATA*; mixin AlignedStr!(_alignVal, "SP_DEVICE_INTERFACE_DATA", q{ DWORD cbSize = SP_DEVICE_INTERFACE_DATA.sizeof; @@ -1038,28 +1038,28 @@ mixin AlignedStr!(_alignVal, "SP_DEVICE_INTERFACE_DATA", q{ DWORD Flags; ULONG_PTR Reserved; }); -alias SP_DEVICE_INTERFACE_DATA* PSP_DEVICE_INTERFACE_DATA; -deprecated alias SP_DEVICE_INTERFACE_DATA SP_INTERFACE_DEVICE_DATA; -deprecated alias SP_DEVICE_INTERFACE_DATA* PSP_INTERFACE_DEVICE_DATA; +alias PSP_DEVICE_INTERFACE_DATA = SP_DEVICE_INTERFACE_DATA*; +deprecated alias SP_INTERFACE_DEVICE_DATA = SP_DEVICE_INTERFACE_DATA; +deprecated alias PSP_INTERFACE_DEVICE_DATA = SP_DEVICE_INTERFACE_DATA*; mixin AlignedStr!(_alignVal, "SP_DEVICE_INTERFACE_DETAIL_DATA_A", q{ DWORD cbSize = SP_DEVICE_INTERFACE_DETAIL_DATA_A.sizeof; CHAR[1] _DevicePath = 0; CHAR* DevicePath() return { return _DevicePath.ptr; } }); -alias SP_DEVICE_INTERFACE_DETAIL_DATA_A* PSP_DEVICE_INTERFACE_DETAIL_DATA_A; +alias PSP_DEVICE_INTERFACE_DETAIL_DATA_A = SP_DEVICE_INTERFACE_DETAIL_DATA_A*; mixin AlignedStr!(_alignVal, "SP_DEVICE_INTERFACE_DETAIL_DATA_W", q{ DWORD cbSize = SP_DEVICE_INTERFACE_DETAIL_DATA_W.sizeof; WCHAR[1] _DevicePath = 0; WCHAR* DevicePath() return { return _DevicePath.ptr; } }); -alias SP_DEVICE_INTERFACE_DETAIL_DATA_W* PSP_DEVICE_INTERFACE_DETAIL_DATA_W; +alias PSP_DEVICE_INTERFACE_DETAIL_DATA_W = SP_DEVICE_INTERFACE_DETAIL_DATA_W*; -deprecated alias SP_DEVICE_INTERFACE_DETAIL_DATA_A SP_INTERFACE_DEVICE_DETAIL_DATA_A; -deprecated alias SP_DEVICE_INTERFACE_DETAIL_DATA_A* PSP_INTERFACE_DEVICE_DETAIL_DATA_A; -deprecated alias SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_INTERFACE_DEVICE_DETAIL_DATA_W; -deprecated alias SP_DEVICE_INTERFACE_DETAIL_DATA_W* PSP_INTERFACE_DEVICE_DETAIL_DATA_W; +deprecated alias SP_INTERFACE_DEVICE_DETAIL_DATA_A = SP_DEVICE_INTERFACE_DETAIL_DATA_A; +deprecated alias PSP_INTERFACE_DEVICE_DETAIL_DATA_A = SP_DEVICE_INTERFACE_DETAIL_DATA_A*; +deprecated alias SP_INTERFACE_DEVICE_DETAIL_DATA_W = SP_DEVICE_INTERFACE_DETAIL_DATA_W; +deprecated alias PSP_INTERFACE_DEVICE_DETAIL_DATA_W = SP_DEVICE_INTERFACE_DETAIL_DATA_W*; mixin AlignedStr!(_alignVal, "SP_DEVINFO_LIST_DETAIL_DATA_A", q{ DWORD cbSize = SP_DEVINFO_LIST_DETAIL_DATA_A.sizeof; @@ -1067,7 +1067,7 @@ mixin AlignedStr!(_alignVal, "SP_DEVINFO_LIST_DETAIL_DATA_A", q{ HANDLE RemoteMachineHandle; CHAR[SP_MAX_MACHINENAME_LENGTH] RemoteMachineName = 0; }); -alias SP_DEVINFO_LIST_DETAIL_DATA_A* PSP_DEVINFO_LIST_DETAIL_DATA_A; +alias PSP_DEVINFO_LIST_DETAIL_DATA_A = SP_DEVINFO_LIST_DETAIL_DATA_A*; mixin AlignedStr!(_alignVal, "SP_DEVINFO_LIST_DETAIL_DATA_W", q{ DWORD cbSize = SP_DEVINFO_LIST_DETAIL_DATA_W.sizeof; @@ -1075,10 +1075,10 @@ mixin AlignedStr!(_alignVal, "SP_DEVINFO_LIST_DETAIL_DATA_W", q{ HANDLE RemoteMachineHandle; WCHAR[SP_MAX_MACHINENAME_LENGTH] RemoteMachineName = 0; }); -alias SP_DEVINFO_LIST_DETAIL_DATA_W* PSP_DEVINFO_LIST_DETAIL_DATA_W; +alias PSP_DEVINFO_LIST_DETAIL_DATA_W = SP_DEVINFO_LIST_DETAIL_DATA_W*; -extern(Windows) alias UINT function(PVOID, UINT, UINT_PTR, UINT_PTR) PSP_FILE_CALLBACK_A; -extern(Windows) alias UINT function(PVOID, UINT, UINT_PTR, UINT_PTR) PSP_FILE_CALLBACK_W; +extern(Windows) alias PSP_FILE_CALLBACK_A = UINT function(PVOID, UINT, UINT_PTR, UINT_PTR); +extern(Windows) alias PSP_FILE_CALLBACK_W = UINT function(PVOID, UINT, UINT_PTR, UINT_PTR); struct SP_DEVINSTALL_PARAMS_A { DWORD cbSize = SP_DEVINSTALL_PARAMS_A.sizeof; @@ -1092,7 +1092,7 @@ struct SP_DEVINSTALL_PARAMS_A { DWORD Reserved; CHAR[MAX_PATH] DriverPath = 0; } -alias SP_DEVINSTALL_PARAMS_A* PSP_DEVINSTALL_PARAMS_A; +alias PSP_DEVINSTALL_PARAMS_A = SP_DEVINSTALL_PARAMS_A*; struct SP_DEVINSTALL_PARAMS_W { DWORD cbSize = SP_DEVINSTALL_PARAMS_W.sizeof; @@ -1106,26 +1106,26 @@ struct SP_DEVINSTALL_PARAMS_W { DWORD Reserved; WCHAR[MAX_PATH] DriverPath = 0; } -alias SP_DEVINSTALL_PARAMS_W* PSP_DEVINSTALL_PARAMS_W; +alias PSP_DEVINSTALL_PARAMS_W = SP_DEVINSTALL_PARAMS_W*; struct SP_CLASSINSTALL_HEADER { DWORD cbSize = SP_CLASSINSTALL_HEADER.sizeof; DI_FUNCTION InstallFunction; } -alias SP_CLASSINSTALL_HEADER* PSP_CLASSINSTALL_HEADER; +alias PSP_CLASSINSTALL_HEADER = SP_CLASSINSTALL_HEADER*; struct SP_ENABLECLASS_PARAMS { SP_CLASSINSTALL_HEADER ClassInstallHeader; GUID ClassGuid; DWORD EnableMessage; } -alias SP_ENABLECLASS_PARAMS* PSP_ENABLECLASS_PARAMS; +alias PSP_ENABLECLASS_PARAMS = SP_ENABLECLASS_PARAMS*; struct SP_MOVEDEV_PARAMS { SP_CLASSINSTALL_HEADER ClassInstallHeader; SP_DEVINFO_DATA SourceDeviceInfoData; } -alias SP_MOVEDEV_PARAMS* PSP_MOVEDEV_PARAMS; +alias PSP_MOVEDEV_PARAMS = SP_MOVEDEV_PARAMS*; struct SP_PROPCHANGE_PARAMS { SP_CLASSINSTALL_HEADER ClassInstallHeader; @@ -1133,21 +1133,21 @@ struct SP_PROPCHANGE_PARAMS { DWORD Scope; DWORD HwProfile; } -alias SP_PROPCHANGE_PARAMS* PSP_PROPCHANGE_PARAMS; +alias PSP_PROPCHANGE_PARAMS = SP_PROPCHANGE_PARAMS*; struct SP_REMOVEDEVICE_PARAMS { SP_CLASSINSTALL_HEADER ClassInstallHeader; DWORD Scope; DWORD HwProfile; } -alias SP_REMOVEDEVICE_PARAMS* PSP_REMOVEDEVICE_PARAMS; +alias PSP_REMOVEDEVICE_PARAMS = SP_REMOVEDEVICE_PARAMS*; struct SP_UNREMOVEDEVICE_PARAMS { SP_CLASSINSTALL_HEADER ClassInstallHeader; DWORD Scope; DWORD HwProfile; } -alias SP_UNREMOVEDEVICE_PARAMS* PSP_UNREMOVEDEVICE_PARAMS; +alias PSP_UNREMOVEDEVICE_PARAMS = SP_UNREMOVEDEVICE_PARAMS*; struct SP_SELECTDEVICE_PARAMS_A { SP_CLASSINSTALL_HEADER ClassInstallHeader; @@ -1157,7 +1157,7 @@ struct SP_SELECTDEVICE_PARAMS_A { CHAR[MAX_SUBTITLE_LEN] SubTitle = 0; BYTE[2] Reserved; } -alias SP_SELECTDEVICE_PARAMS_A* PSP_SELECTDEVICE_PARAMS_A; +alias PSP_SELECTDEVICE_PARAMS_A = SP_SELECTDEVICE_PARAMS_A*; struct SP_SELECTDEVICE_PARAMS_W { SP_CLASSINSTALL_HEADER ClassInstallHeader; @@ -1166,16 +1166,16 @@ struct SP_SELECTDEVICE_PARAMS_W { WCHAR[MAX_LABEL_LEN] ListLabel = 0; WCHAR[MAX_SUBTITLE_LEN] SubTitle = 0; } -alias SP_SELECTDEVICE_PARAMS_W* PSP_SELECTDEVICE_PARAMS_W; +alias PSP_SELECTDEVICE_PARAMS_W = SP_SELECTDEVICE_PARAMS_W*; -extern(Windows) alias BOOL function(PVOID, DWORD) PDETECT_PROGRESS_NOTIFY; +extern(Windows) alias PDETECT_PROGRESS_NOTIFY = BOOL function(PVOID, DWORD); struct SP_DETECTDEVICE_PARAMS { SP_CLASSINSTALL_HEADER ClassInstallHeader; PDETECT_PROGRESS_NOTIFY DetectProgressNotify; PVOID ProgressNotifyParam; } -alias SP_DETECTDEVICE_PARAMS* PSP_DETECTDEVICE_PARAMS; +alias PSP_DETECTDEVICE_PARAMS = SP_DETECTDEVICE_PARAMS*; struct SP_INSTALLWIZARD_DATA { SP_CLASSINSTALL_HEADER ClassInstallHeader; @@ -1187,7 +1187,7 @@ struct SP_INSTALLWIZARD_DATA { LPARAM PrivateData; HWND hwndWizardDlg; } -alias SP_INSTALLWIZARD_DATA* PSP_INSTALLWIZARD_DATA; +alias PSP_INSTALLWIZARD_DATA = SP_INSTALLWIZARD_DATA*; struct SP_NEWDEVICEWIZARD_DATA { SP_CLASSINSTALL_HEADER ClassInstallHeader; @@ -1196,35 +1196,35 @@ struct SP_NEWDEVICEWIZARD_DATA { DWORD NumDynamicPages; HWND hwndWizardDlg; } -alias SP_NEWDEVICEWIZARD_DATA* PSP_NEWDEVICEWIZARD_DATA; -alias SP_NEWDEVICEWIZARD_DATA SP_ADDPROPERTYPAGE_DATA; -alias SP_NEWDEVICEWIZARD_DATA* PSP_ADDPROPERTYPAGE_DATA; +alias PSP_NEWDEVICEWIZARD_DATA = SP_NEWDEVICEWIZARD_DATA*; +alias SP_ADDPROPERTYPAGE_DATA = SP_NEWDEVICEWIZARD_DATA; +alias PSP_ADDPROPERTYPAGE_DATA = SP_NEWDEVICEWIZARD_DATA*; struct SP_TROUBLESHOOTER_PARAMS_A { SP_CLASSINSTALL_HEADER ClassInstallHeader; CHAR[MAX_PATH] ChmFile = 0; CHAR[MAX_PATH] HtmlTroubleShooter = 0; } -alias SP_TROUBLESHOOTER_PARAMS_A* PSP_TROUBLESHOOTER_PARAMS_A; +alias PSP_TROUBLESHOOTER_PARAMS_A = SP_TROUBLESHOOTER_PARAMS_A*; struct SP_TROUBLESHOOTER_PARAMS_W { SP_CLASSINSTALL_HEADER ClassInstallHeader; WCHAR[MAX_PATH] ChmFile = 0; WCHAR[MAX_PATH] HtmlTroubleShooter = 0; } -alias SP_TROUBLESHOOTER_PARAMS_W* PSP_TROUBLESHOOTER_PARAMS_W; +alias PSP_TROUBLESHOOTER_PARAMS_W = SP_TROUBLESHOOTER_PARAMS_W*; struct SP_POWERMESSAGEWAKE_PARAMS_A { SP_CLASSINSTALL_HEADER ClassInstallHeader; CHAR[LINE_LEN*2] PowerMessageWake = 0; } -alias SP_POWERMESSAGEWAKE_PARAMS_A* PSP_POWERMESSAGEWAKE_PARAMS_A; +alias PSP_POWERMESSAGEWAKE_PARAMS_A = SP_POWERMESSAGEWAKE_PARAMS_A*; struct SP_POWERMESSAGEWAKE_PARAMS_W { SP_CLASSINSTALL_HEADER ClassInstallHeader; WCHAR[LINE_LEN*2] PowerMessageWake = 0; } -alias SP_POWERMESSAGEWAKE_PARAMS_W* PSP_POWERMESSAGEWAKE_PARAMS_W; +alias PSP_POWERMESSAGEWAKE_PARAMS_W = SP_POWERMESSAGEWAKE_PARAMS_W*; mixin AlignedStr!(_alignVal, "SP_DRVINFO_DATA_V2_A", q{ DWORD cbSize = SP_DRVINFO_DATA_V2_A.sizeof; @@ -1236,7 +1236,7 @@ mixin AlignedStr!(_alignVal, "SP_DRVINFO_DATA_V2_A", q{ FILETIME DriverDate; DWORDLONG DriverVersion; }); -alias SP_DRVINFO_DATA_V2_A* PSP_DRVINFO_DATA_V2_A; +alias PSP_DRVINFO_DATA_V2_A = SP_DRVINFO_DATA_V2_A*; mixin AlignedStr!(_alignVal, "SP_DRVINFO_DATA_V2_W", q{ DWORD cbSize = SP_DRVINFO_DATA_V2_A.sizeof; @@ -1248,7 +1248,7 @@ mixin AlignedStr!(_alignVal, "SP_DRVINFO_DATA_V2_W", q{ FILETIME DriverDate; DWORDLONG DriverVersion; }); -alias SP_DRVINFO_DATA_V2_W* PSP_DRVINFO_DATA_V2_W; +alias PSP_DRVINFO_DATA_V2_W = SP_DRVINFO_DATA_V2_W*; struct SP_DRVINFO_DATA_V1_A { DWORD cbSize = SP_DRVINFO_DATA_V1_A.sizeof; @@ -1258,7 +1258,7 @@ struct SP_DRVINFO_DATA_V1_A { CHAR[LINE_LEN] MfgName = 0; CHAR[LINE_LEN] ProviderName = 0; } -alias SP_DRVINFO_DATA_V1_A* PSP_DRVINFO_DATA_V1_A; +alias PSP_DRVINFO_DATA_V1_A = SP_DRVINFO_DATA_V1_A*; struct SP_DRVINFO_DATA_V1_W { DWORD cbSize = SP_DRVINFO_DATA_V1_W.sizeof; @@ -1268,35 +1268,35 @@ struct SP_DRVINFO_DATA_V1_W { WCHAR[LINE_LEN] MfgName = 0; WCHAR[LINE_LEN] ProviderName = 0; } -alias SP_DRVINFO_DATA_V1_W* PSP_DRVINFO_DATA_V1_W; +alias PSP_DRVINFO_DATA_V1_W = SP_DRVINFO_DATA_V1_W*; version (Unicode) { - alias SP_DRVINFO_DATA_V1_W SP_DRVINFO_DATA_V1; - alias SP_DRVINFO_DATA_V2_W SP_DRVINFO_DATA_V2; + alias SP_DRVINFO_DATA_V1 = SP_DRVINFO_DATA_V1_W; + alias SP_DRVINFO_DATA_V2 = SP_DRVINFO_DATA_V2_W; } else { - alias SP_DRVINFO_DATA_V1_A SP_DRVINFO_DATA_V1; - alias SP_DRVINFO_DATA_V2_A SP_DRVINFO_DATA_V2; + alias SP_DRVINFO_DATA_V1 = SP_DRVINFO_DATA_V1_A; + alias SP_DRVINFO_DATA_V2 = SP_DRVINFO_DATA_V2_A; } -alias SP_DRVINFO_DATA_V1* PSP_DRVINFO_DATA_V1; -alias SP_DRVINFO_DATA_V2* PSP_DRVINFO_DATA_V2; +alias PSP_DRVINFO_DATA_V1 = SP_DRVINFO_DATA_V1*; +alias PSP_DRVINFO_DATA_V2 = SP_DRVINFO_DATA_V2*; static if (USE_SP_DRVINFO_DATA_V1) { - alias SP_DRVINFO_DATA_V1_A SP_DRVINFO_DATA_A; - alias SP_DRVINFO_DATA_V1_A* PSP_DRVINFO_DATA_A; - alias SP_DRVINFO_DATA_V1_W SP_DRVINFO_DATA_W; - alias SP_DRVINFO_DATA_V1_W* PSP_DRVINFO_DATA_W; - alias SP_DRVINFO_DATA_V1 SP_DRVINFO_DATA; - alias SP_DRVINFO_DATA_V1* PSP_DRVINFO_DATA; + alias SP_DRVINFO_DATA_A = SP_DRVINFO_DATA_V1_A; + alias PSP_DRVINFO_DATA_A = SP_DRVINFO_DATA_V1_A*; + alias SP_DRVINFO_DATA_W = SP_DRVINFO_DATA_V1_W; + alias PSP_DRVINFO_DATA_W = SP_DRVINFO_DATA_V1_W*; + alias SP_DRVINFO_DATA = SP_DRVINFO_DATA_V1; + alias PSP_DRVINFO_DATA = SP_DRVINFO_DATA_V1*; } else { - alias SP_DRVINFO_DATA_V2_A SP_DRVINFO_DATA_A; - alias SP_DRVINFO_DATA_V2_A* PSP_DRVINFO_DATA_A; - alias SP_DRVINFO_DATA_V2_W SP_DRVINFO_DATA_W; - alias SP_DRVINFO_DATA_V2_W* PSP_DRVINFO_DATA_W; - alias SP_DRVINFO_DATA_V2 SP_DRVINFO_DATA; - alias SP_DRVINFO_DATA_V2* PSP_DRVINFO_DATA; + alias SP_DRVINFO_DATA_A = SP_DRVINFO_DATA_V2_A; + alias PSP_DRVINFO_DATA_A = SP_DRVINFO_DATA_V2_A*; + alias SP_DRVINFO_DATA_W = SP_DRVINFO_DATA_V2_W; + alias PSP_DRVINFO_DATA_W = SP_DRVINFO_DATA_V2_W*; + alias SP_DRVINFO_DATA = SP_DRVINFO_DATA_V2; + alias PSP_DRVINFO_DATA = SP_DRVINFO_DATA_V2*; } -extern(Windows) alias DWORD function(HDEVINFO, PSP_DEVINFO_DATA, PSP_DEVINFO_DATA, PVOID) PSP_DETSIG_CMPPROC; +extern(Windows) alias PSP_DETSIG_CMPPROC = DWORD function(HDEVINFO, PSP_DEVINFO_DATA, PSP_DEVINFO_DATA, PVOID); mixin AlignedStr!(_alignVal, "SP_DRVINFO_DETAIL_DATA_A", q{ DWORD cbSize = SP_DRVINFO_DETAIL_DATA_A.sizeof; @@ -1310,7 +1310,7 @@ mixin AlignedStr!(_alignVal, "SP_DRVINFO_DETAIL_DATA_A", q{ CHAR[1] _HardwareID = 0; CHAR* HardwareID() return { return _HardwareID.ptr; } }); -alias SP_DRVINFO_DETAIL_DATA_A* PSP_DRVINFO_DETAIL_DATA_A; +alias PSP_DRVINFO_DETAIL_DATA_A = SP_DRVINFO_DETAIL_DATA_A*; mixin AlignedStr!(_alignVal, "SP_DRVINFO_DETAIL_DATA_W", q{ DWORD cbSize = SP_DRVINFO_DETAIL_DATA_W.sizeof; @@ -1324,7 +1324,7 @@ mixin AlignedStr!(_alignVal, "SP_DRVINFO_DETAIL_DATA_W", q{ WCHAR[1] _HardwareID = 0; WCHAR* HardwareID() return { return _HardwareID.ptr; } }); -alias SP_DRVINFO_DETAIL_DATA_W* PSP_DRVINFO_DETAIL_DATA_W; +alias PSP_DRVINFO_DETAIL_DATA_W = SP_DRVINFO_DETAIL_DATA_W*; struct SP_DRVINSTALL_PARAMS { DWORD cbSize = SP_DRVINSTALL_PARAMS.sizeof; @@ -1333,21 +1333,21 @@ struct SP_DRVINSTALL_PARAMS { DWORD_PTR PrivateData; DWORD Reserved; } -alias SP_DRVINSTALL_PARAMS* PSP_DRVINSTALL_PARAMS; +alias PSP_DRVINSTALL_PARAMS = SP_DRVINSTALL_PARAMS*; struct COINSTALLER_CONTEXT_DATA { BOOL PostProcessing; DWORD InstallResult; PVOID PrivateData; } -alias COINSTALLER_CONTEXT_DATA* PCOINSTALLER_CONTEXT_DATA; +alias PCOINSTALLER_CONTEXT_DATA = COINSTALLER_CONTEXT_DATA*; struct SP_CLASSIMAGELIST_DATA { DWORD cbSize = SP_CLASSIMAGELIST_DATA.sizeof; HIMAGELIST ImageList; ULONG_PTR Reserved; } -alias SP_CLASSIMAGELIST_DATA* PSP_CLASSIMAGELIST_DATA; +alias PSP_CLASSIMAGELIST_DATA = SP_CLASSIMAGELIST_DATA*; struct SP_PROPSHEETPAGE_REQUEST { DWORD cbSize = SP_PROPSHEETPAGE_REQUEST.sizeof; @@ -1355,88 +1355,88 @@ struct SP_PROPSHEETPAGE_REQUEST { HDEVINFO DeviceInfoSet; PSP_DEVINFO_DATA DeviceInfoData; } -alias SP_PROPSHEETPAGE_REQUEST* PSP_PROPSHEETPAGE_REQUEST; +alias PSP_PROPSHEETPAGE_REQUEST = SP_PROPSHEETPAGE_REQUEST*; struct SP_BACKUP_QUEUE_PARAMS_A { DWORD cbSize = SP_BACKUP_QUEUE_PARAMS_A.sizeof; CHAR[MAX_PATH] FullInfPath = 0; INT FilenameOffset; } -alias SP_BACKUP_QUEUE_PARAMS_A* PSP_BACKUP_QUEUE_PARAMS_A; +alias PSP_BACKUP_QUEUE_PARAMS_A = SP_BACKUP_QUEUE_PARAMS_A*; struct SP_BACKUP_QUEUE_PARAMS_W { DWORD cbSize = SP_BACKUP_QUEUE_PARAMS_W.sizeof; WCHAR[MAX_PATH] FullInfPath = 0; INT FilenameOffset; } -alias SP_BACKUP_QUEUE_PARAMS_W* PSP_BACKUP_QUEUE_PARAMS_W; +alias PSP_BACKUP_QUEUE_PARAMS_W = SP_BACKUP_QUEUE_PARAMS_W*; version (Unicode) { - alias SP_ORIGINAL_FILE_INFO_W SP_ORIGINAL_FILE_INFO; - alias SP_ORIGINAL_FILE_INFO_W* PSP_ORIGINAL_FILE_INFO; - alias FILEPATHS_W FILEPATHS; - alias FILEPATHS_W* PFILEPATHS; - alias SOURCE_MEDIA_W SOURCE_MEDIA; - alias SOURCE_MEDIA_W* PSOURCE_MEDIA; - alias CABINET_INFO_W CABINET_INFO; - alias CABINET_INFO_W* PCABINET_INFO; - alias FILE_IN_CABINET_INFO_W FILE_IN_CABINET_INFO; - alias FILE_IN_CABINET_INFO_W* PFILE_IN_CABINET_INFO; - alias SP_FILE_COPY_PARAMS_W SP_FILE_COPY_PARAMS; - alias SP_FILE_COPY_PARAMS_W* PSP_FILE_COPY_PARAMS; - alias SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_DEVICE_INTERFACE_DETAIL_DATA; - alias SP_DEVICE_INTERFACE_DETAIL_DATA_W* PSP_DEVICE_INTERFACE_DETAIL_DATA; + alias SP_ORIGINAL_FILE_INFO = SP_ORIGINAL_FILE_INFO_W; + alias PSP_ORIGINAL_FILE_INFO = SP_ORIGINAL_FILE_INFO_W*; + alias FILEPATHS = FILEPATHS_W; + alias PFILEPATHS = FILEPATHS_W*; + alias SOURCE_MEDIA = SOURCE_MEDIA_W; + alias PSOURCE_MEDIA = SOURCE_MEDIA_W*; + alias CABINET_INFO = CABINET_INFO_W; + alias PCABINET_INFO = CABINET_INFO_W*; + alias FILE_IN_CABINET_INFO = FILE_IN_CABINET_INFO_W; + alias PFILE_IN_CABINET_INFO = FILE_IN_CABINET_INFO_W*; + alias SP_FILE_COPY_PARAMS = SP_FILE_COPY_PARAMS_W; + alias PSP_FILE_COPY_PARAMS = SP_FILE_COPY_PARAMS_W*; + alias SP_DEVICE_INTERFACE_DETAIL_DATA = SP_DEVICE_INTERFACE_DETAIL_DATA_W; + alias PSP_DEVICE_INTERFACE_DETAIL_DATA = SP_DEVICE_INTERFACE_DETAIL_DATA_W*; deprecated { - alias SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_INTERFACE_DEVICE_DETAIL_DATA; - alias SP_DEVICE_INTERFACE_DETAIL_DATA_W* PSP_INTERFACE_DEVICE_DETAIL_DATA; + alias SP_INTERFACE_DEVICE_DETAIL_DATA = SP_DEVICE_INTERFACE_DETAIL_DATA_W; + alias PSP_INTERFACE_DEVICE_DETAIL_DATA = SP_DEVICE_INTERFACE_DETAIL_DATA_W*; } - alias SP_DEVINFO_LIST_DETAIL_DATA_W SP_DEVINFO_LIST_DETAIL_DATA; - alias SP_DEVINFO_LIST_DETAIL_DATA_W *PSP_DEVINFO_LIST_DETAIL_DATA; - alias SP_DEVINSTALL_PARAMS_W SP_DEVINSTALL_PARAMS; - alias SP_DEVINSTALL_PARAMS_W* PSP_DEVINSTALL_PARAMS; - alias SP_SELECTDEVICE_PARAMS_W SP_SELECTDEVICE_PARAMS; - alias SP_SELECTDEVICE_PARAMS_W* PSP_SELECTDEVICE_PARAMS; - alias SP_TROUBLESHOOTER_PARAMS_W SP_TROUBLESHOOTER_PARAMS; - alias SP_TROUBLESHOOTER_PARAMS_W* PSP_TROUBLESHOOTER_PARAMS; - alias SP_POWERMESSAGEWAKE_PARAMS_W SP_POWERMESSAGEWAKE_PARAMS; - alias SP_POWERMESSAGEWAKE_PARAMS_W* PSP_POWERMESSAGEWAKE_PARAMS; - alias SP_DRVINFO_DETAIL_DATA_W SP_DRVINFO_DETAIL_DATA; - alias SP_DRVINFO_DETAIL_DATA_W* PSP_DRVINFO_DETAIL_DATA; - alias SP_BACKUP_QUEUE_PARAMS_W SP_BACKUP_QUEUE_PARAMS; - alias SP_BACKUP_QUEUE_PARAMS_W* PSP_BACKUP_QUEUE_PARAMS; + alias SP_DEVINFO_LIST_DETAIL_DATA = SP_DEVINFO_LIST_DETAIL_DATA_W; + alias PSP_DEVINFO_LIST_DETAIL_DATA = SP_DEVINFO_LIST_DETAIL_DATA_W *; + alias SP_DEVINSTALL_PARAMS = SP_DEVINSTALL_PARAMS_W; + alias PSP_DEVINSTALL_PARAMS = SP_DEVINSTALL_PARAMS_W*; + alias SP_SELECTDEVICE_PARAMS = SP_SELECTDEVICE_PARAMS_W; + alias PSP_SELECTDEVICE_PARAMS = SP_SELECTDEVICE_PARAMS_W*; + alias SP_TROUBLESHOOTER_PARAMS = SP_TROUBLESHOOTER_PARAMS_W; + alias PSP_TROUBLESHOOTER_PARAMS = SP_TROUBLESHOOTER_PARAMS_W*; + alias SP_POWERMESSAGEWAKE_PARAMS = SP_POWERMESSAGEWAKE_PARAMS_W; + alias PSP_POWERMESSAGEWAKE_PARAMS = SP_POWERMESSAGEWAKE_PARAMS_W*; + alias SP_DRVINFO_DETAIL_DATA = SP_DRVINFO_DETAIL_DATA_W; + alias PSP_DRVINFO_DETAIL_DATA = SP_DRVINFO_DETAIL_DATA_W*; + alias SP_BACKUP_QUEUE_PARAMS = SP_BACKUP_QUEUE_PARAMS_W; + alias PSP_BACKUP_QUEUE_PARAMS = SP_BACKUP_QUEUE_PARAMS_W*; } else { - alias SP_ORIGINAL_FILE_INFO_A SP_ORIGINAL_FILE_INFO; - alias SP_ORIGINAL_FILE_INFO_A* PSP_ORIGINAL_FILE_INFO; - alias FILEPATHS_A FILEPATHS; - alias FILEPATHS_A* PFILEPATHS; - alias SOURCE_MEDIA_A SOURCE_MEDIA; - alias SOURCE_MEDIA_A* PSOURCE_MEDIA; - alias CABINET_INFO_A CABINET_INFO; - alias CABINET_INFO_A* PCABINET_INFO; - alias FILE_IN_CABINET_INFO_A FILE_IN_CABINET_INFO; - alias FILE_IN_CABINET_INFO_A* PFILE_IN_CABINET_INFO; - alias SP_FILE_COPY_PARAMS_A SP_FILE_COPY_PARAMS; - alias SP_FILE_COPY_PARAMS_A* PSP_FILE_COPY_PARAMS; - alias SP_DEVICE_INTERFACE_DETAIL_DATA_A SP_DEVICE_INTERFACE_DETAIL_DATA; - alias SP_DEVICE_INTERFACE_DETAIL_DATA_A* PSP_DEVICE_INTERFACE_DETAIL_DATA; + alias SP_ORIGINAL_FILE_INFO = SP_ORIGINAL_FILE_INFO_A; + alias PSP_ORIGINAL_FILE_INFO = SP_ORIGINAL_FILE_INFO_A*; + alias FILEPATHS = FILEPATHS_A; + alias PFILEPATHS = FILEPATHS_A*; + alias SOURCE_MEDIA = SOURCE_MEDIA_A; + alias PSOURCE_MEDIA = SOURCE_MEDIA_A*; + alias CABINET_INFO = CABINET_INFO_A; + alias PCABINET_INFO = CABINET_INFO_A*; + alias FILE_IN_CABINET_INFO = FILE_IN_CABINET_INFO_A; + alias PFILE_IN_CABINET_INFO = FILE_IN_CABINET_INFO_A*; + alias SP_FILE_COPY_PARAMS = SP_FILE_COPY_PARAMS_A; + alias PSP_FILE_COPY_PARAMS = SP_FILE_COPY_PARAMS_A*; + alias SP_DEVICE_INTERFACE_DETAIL_DATA = SP_DEVICE_INTERFACE_DETAIL_DATA_A; + alias PSP_DEVICE_INTERFACE_DETAIL_DATA = SP_DEVICE_INTERFACE_DETAIL_DATA_A*; deprecated { - alias SP_DEVICE_INTERFACE_DETAIL_DATA_A SP_INTERFACE_DEVICE_DETAIL_DATA; - alias SP_DEVICE_INTERFACE_DETAIL_DATA_A* PSP_INTERFACE_DEVICE_DETAIL_DATA; + alias SP_INTERFACE_DEVICE_DETAIL_DATA = SP_DEVICE_INTERFACE_DETAIL_DATA_A; + alias PSP_INTERFACE_DEVICE_DETAIL_DATA = SP_DEVICE_INTERFACE_DETAIL_DATA_A*; } - alias SP_DEVINFO_LIST_DETAIL_DATA_A SP_DEVINFO_LIST_DETAIL_DATA; - alias SP_DEVINFO_LIST_DETAIL_DATA_A* PSP_DEVINFO_LIST_DETAIL_DATA; - alias SP_DEVINSTALL_PARAMS_A SP_DEVINSTALL_PARAMS; - alias SP_DEVINSTALL_PARAMS_A* PSP_DEVINSTALL_PARAMS; - alias SP_SELECTDEVICE_PARAMS_A SP_SELECTDEVICE_PARAMS; - alias SP_SELECTDEVICE_PARAMS_A* PSP_SELECTDEVICE_PARAMS; - alias SP_TROUBLESHOOTER_PARAMS_A SP_TROUBLESHOOTER_PARAMS; - alias SP_TROUBLESHOOTER_PARAMS_A* PSP_TROUBLESHOOTER_PARAMS; - alias SP_POWERMESSAGEWAKE_PARAMS_A SP_POWERMESSAGEWAKE_PARAMS; - alias SP_POWERMESSAGEWAKE_PARAMS_A* PSP_POWERMESSAGEWAKE_PARAMS; - alias SP_DRVINFO_DETAIL_DATA_A SP_DRVINFO_DETAIL_DATA; - alias SP_DRVINFO_DETAIL_DATA_A* PSP_DRVINFO_DETAIL_DATA; - alias SP_BACKUP_QUEUE_PARAMS_A SP_BACKUP_QUEUE_PARAMS; - alias SP_BACKUP_QUEUE_PARAMS_A* PSP_BACKUP_QUEUE_PARAMS; + alias SP_DEVINFO_LIST_DETAIL_DATA = SP_DEVINFO_LIST_DETAIL_DATA_A; + alias PSP_DEVINFO_LIST_DETAIL_DATA = SP_DEVINFO_LIST_DETAIL_DATA_A*; + alias SP_DEVINSTALL_PARAMS = SP_DEVINSTALL_PARAMS_A; + alias PSP_DEVINSTALL_PARAMS = SP_DEVINSTALL_PARAMS_A*; + alias SP_SELECTDEVICE_PARAMS = SP_SELECTDEVICE_PARAMS_A; + alias PSP_SELECTDEVICE_PARAMS = SP_SELECTDEVICE_PARAMS_A*; + alias SP_TROUBLESHOOTER_PARAMS = SP_TROUBLESHOOTER_PARAMS_A; + alias PSP_TROUBLESHOOTER_PARAMS = SP_TROUBLESHOOTER_PARAMS_A*; + alias SP_POWERMESSAGEWAKE_PARAMS = SP_POWERMESSAGEWAKE_PARAMS_A; + alias PSP_POWERMESSAGEWAKE_PARAMS = SP_POWERMESSAGEWAKE_PARAMS_A*; + alias SP_DRVINFO_DETAIL_DATA = SP_DRVINFO_DETAIL_DATA_A; + alias PSP_DRVINFO_DETAIL_DATA = SP_DRVINFO_DETAIL_DATA_A*; + alias SP_BACKUP_QUEUE_PARAMS = SP_BACKUP_QUEUE_PARAMS_A; + alias PSP_BACKUP_QUEUE_PARAMS = SP_BACKUP_QUEUE_PARAMS_A*; } extern (Windows) { @@ -1732,253 +1732,253 @@ extern (Windows) { } deprecated { - alias SetupDiCreateDeviceInterfaceW SetupDiCreateInterfaceDeviceW; - alias SetupDiCreateDeviceInterfaceRegKeyW SetupDiCreateInterfaceDeviceRegKeyW; - alias SetupDiOpenDeviceInterfaceW SetupDiOpenInterfaceDeviceW; - alias SetupDiGetDeviceInterfaceDetailW SetupDiGetInterfaceDeviceDetailW; - alias SetupDiCreateDeviceInterfaceA SetupDiCreateInterfaceDeviceA; - alias SetupDiCreateDeviceInterfaceRegKeyA SetupDiCreateInterfaceDeviceRegKeyA; - alias SetupDiOpenDeviceInterfaceA SetupDiOpenInterfaceDeviceA; - alias SetupDiGetDeviceInterfaceDetailA SetupDiGetInterfaceDeviceDetailA; + alias SetupDiCreateInterfaceDeviceW = SetupDiCreateDeviceInterfaceW; + alias SetupDiCreateInterfaceDeviceRegKeyW = SetupDiCreateDeviceInterfaceRegKeyW; + alias SetupDiOpenInterfaceDeviceW = SetupDiOpenDeviceInterfaceW; + alias SetupDiGetInterfaceDeviceDetailW = SetupDiGetDeviceInterfaceDetailW; + alias SetupDiCreateInterfaceDeviceA = SetupDiCreateDeviceInterfaceA; + alias SetupDiCreateInterfaceDeviceRegKeyA = SetupDiCreateDeviceInterfaceRegKeyA; + alias SetupDiOpenInterfaceDeviceA = SetupDiOpenDeviceInterfaceA; + alias SetupDiGetInterfaceDeviceDetailA = SetupDiGetDeviceInterfaceDetailA; } version (Unicode) { - alias PSP_FILE_CALLBACK_W PSP_FILE_CALLBACK; - alias SetupAddInstallSectionToDiskSpaceListW SetupAddInstallSectionToDiskSpaceList; - alias SetupAddSectionToDiskSpaceListW SetupAddSectionToDiskSpaceList; - alias SetupAddToDiskSpaceListW SetupAddToDiskSpaceList; - alias SetupAddToSourceListW SetupAddToSourceList; - alias SetupAdjustDiskSpaceListW SetupAdjustDiskSpaceList; - alias SetupBackupErrorW SetupBackupError; - alias SetupCommitFileQueueW SetupCommitFileQueue; - alias SetupCopyErrorW SetupCopyError; - alias SetupCopyOEMInfW SetupCopyOEMInf; - alias SetupCreateDiskSpaceListW SetupCreateDiskSpaceList; - alias SetupDecompressOrCopyFileW SetupDecompressOrCopyFile; - alias SetupDefaultQueueCallbackW SetupDefaultQueueCallback; - alias SetupDeleteErrorW SetupDeleteError; - alias SetupDiBuildClassInfoListExW SetupDiBuildClassInfoListEx; - alias SetupDiClassGuidsFromNameExW SetupDiClassGuidsFromNameEx; - alias SetupDiClassGuidsFromNameW SetupDiClassGuidsFromName; - alias SetupDiClassNameFromGuidExW SetupDiClassNameFromGuidEx; - alias SetupDiClassNameFromGuidW SetupDiClassNameFromGuid; - alias SetupDiCreateDeviceInfoListExW SetupDiCreateDeviceInfoListEx; - alias SetupDiCreateDeviceInfoW SetupDiCreateDeviceInfo; - alias SetupDiCreateDeviceInterfaceRegKeyW SetupDiCreateDeviceInterfaceRegKey; - deprecated alias SetupDiCreateDeviceInterfaceRegKeyW SetupDiCreateInterfaceDeviceRegKey; - alias SetupDiCreateDeviceInterfaceW SetupDiCreateDeviceInterface; - deprecated alias SetupDiCreateDeviceInterfaceW SetupDiCreateInterfaceDevice; - alias SetupDiCreateDevRegKeyW SetupDiCreateDevRegKey; - alias SetupDiEnumDriverInfoW SetupDiEnumDriverInfo; - alias SetupDiGetActualSectionToInstallW SetupDiGetActualSectionToInstall; - alias SetupDiGetClassDescriptionExW SetupDiGetClassDescriptionEx; - alias SetupDiGetClassDescriptionW SetupDiGetClassDescription; - alias SetupDiGetClassDevPropertySheetsW SetupDiGetClassDevPropertySheets; - alias SetupDiGetClassDevsExW SetupDiGetClassDevsEx; - alias SetupDiGetClassDevsW SetupDiGetClassDevs; - alias SetupDiGetClassImageListExW SetupDiGetClassImageListEx; - alias SetupDiGetClassInstallParamsW SetupDiGetClassInstallParams; - alias SetupDiGetClassRegistryPropertyW SetupDiGetClassRegistryProperty; - alias SetupDiGetDeviceInfoListDetailW SetupDiGetDeviceInfoListDetail; - alias SetupDiGetDeviceInstallParamsW SetupDiGetDeviceInstallParams; - alias SetupDiGetDeviceInstanceIdW SetupDiGetDeviceInstanceId; - alias SetupDiGetDeviceInterfaceDetailW SetupDiGetDeviceInterfaceDetail; - deprecated alias SetupDiGetDeviceInterfaceDetailW SetupDiGetInterfaceDeviceDetail; - alias SetupDiGetDeviceRegistryPropertyW SetupDiGetDeviceRegistryProperty; - alias SetupDiGetDriverInfoDetailW SetupDiGetDriverInfoDetail; - alias SetupDiGetDriverInstallParamsW SetupDiGetDriverInstallParams; - alias SetupDiGetHwProfileFriendlyNameExW SetupDiGetHwProfileFriendlyNameEx; - alias SetupDiGetHwProfileFriendlyNameW SetupDiGetHwProfileFriendlyName; - alias SetupDiGetHwProfileListExW SetupDiGetHwProfileListEx; - alias SetupDiGetINFClassW SetupDiGetINFClass; - alias SetupDiGetSelectedDriverW SetupDiGetSelectedDriver; - alias SetupDiInstallClassExW SetupDiInstallClassEx; - alias SetupDiInstallClassW SetupDiInstallClass; - alias SetupDiOpenClassRegKeyExW SetupDiOpenClassRegKeyEx; - alias SetupDiOpenDeviceInfoW SetupDiOpenDeviceInfo; - alias SetupDiOpenDeviceInterfaceW SetupDiOpenDeviceInterface; - deprecated alias SetupDiOpenDeviceInterfaceW SetupDiOpenInterfaceDevice; - alias SetupDiSetClassInstallParamsW SetupDiSetClassInstallParams; - alias SetupDiSetClassRegistryPropertyW SetupDiSetClassRegistryProperty; - alias SetupDiSetDeviceInstallParamsW SetupDiSetDeviceInstallParams; - alias SetupDiSetDeviceRegistryPropertyW SetupDiSetDeviceRegistryProperty; - alias SetupDiSetDriverInstallParamsW SetupDiSetDriverInstallParams; - alias SetupDiSetSelectedDriverW SetupDiSetSelectedDriver; - alias SetupDuplicateDiskSpaceListW SetupDuplicateDiskSpaceList; - alias SetupFindFirstLineW SetupFindFirstLine; - alias SetupFindNextMatchLineW SetupFindNextMatchLine; - alias SetupFreeSourceListW SetupFreeSourceList; - alias SetupGetBackupInformationW SetupGetBackupInformation; - alias SetupGetFileCompressionInfoW SetupGetFileCompressionInfo; - alias SetupGetInfFileListW SetupGetInfFileList; - alias SetupGetInfInformationW SetupGetInfInformation; - alias SetupGetLineByIndexW SetupGetLineByIndex; - alias SetupGetLineCountW SetupGetLineCount; - alias SetupGetLineTextW SetupGetLineText; - alias SetupGetMultiSzFieldW SetupGetMultiSzField; - alias SetupGetSourceFileLocationW SetupGetSourceFileLocation; - alias SetupGetSourceFileSizeW SetupGetSourceFileSize; - alias SetupGetSourceInfoW SetupGetSourceInfo; - alias SetupGetStringFieldW SetupGetStringField; - alias SetupGetTargetPathW SetupGetTargetPath; - alias SetupInitializeFileLogW SetupInitializeFileLog; - alias SetupInstallFileExW SetupInstallFileEx; - alias SetupInstallFilesFromInfSectionW SetupInstallFilesFromInfSection; - alias SetupInstallFileW SetupInstallFile; - alias SetupInstallFromInfSectionW SetupInstallFromInfSection; - alias SetupInstallServicesFromInfSectionExW SetupInstallServicesFromInfSectionEx; - alias SetupInstallServicesFromInfSectionW SetupInstallServicesFromInfSection; - alias SetupIterateCabinetW SetupIterateCabinet; - alias SetupLogErrorW SetupLogError; - alias SetupLogFileW SetupLogFile; - alias SetupOpenAppendInfFileW SetupOpenAppendInfFile; - alias SetupOpenInfFileW SetupOpenInfFile; - alias SetupPromptForDiskW SetupPromptForDisk; - alias SetupQueryDrivesInDiskSpaceListW SetupQueryDrivesInDiskSpaceList; - alias SetupQueryFileLogW SetupQueryFileLog; - alias SetupQueryInfFileInformationW SetupQueryInfFileInformation; - alias SetupQueryInfOriginalFileInformationW SetupQueryInfOriginalFileInformation; - alias SetupQueryInfVersionInformationW SetupQueryInfVersionInformation; - alias SetupQuerySourceListW SetupQuerySourceList; - alias SetupQuerySpaceRequiredOnDriveW SetupQuerySpaceRequiredOnDrive; - alias SetupQueueCopyIndirectW SetupQueueCopyIndirect; - alias SetupQueueCopySectionW SetupQueueCopySection; - alias SetupQueueCopyW SetupQueueCopy; - alias SetupQueueDefaultCopyW SetupQueueDefaultCopy; - alias SetupQueueDeleteSectionW SetupQueueDeleteSection; - alias SetupQueueDeleteW SetupQueueDelete; - alias SetupQueueRenameSectionW SetupQueueRenameSection; - alias SetupQueueRenameW SetupQueueRename; - alias SetupRemoveFileLogEntryW SetupRemoveFileLogEntry; - alias SetupRemoveFromDiskSpaceListW SetupRemoveFromDiskSpaceList; - alias SetupRemoveFromSourceListW SetupRemoveFromSourceList; - alias SetupRemoveInstallSectionFromDiskSpaceListW SetupRemoveInstallSectionFromDiskSpaceList; - alias SetupRemoveSectionFromDiskSpaceListW SetupRemoveSectionFromDiskSpaceList; - alias SetupRenameErrorW SetupRenameError; - alias SetupScanFileQueueW SetupScanFileQueue; - alias SetupSetDirectoryIdExW SetupSetDirectoryIdEx; - alias SetupSetDirectoryIdW SetupSetDirectoryId; - alias SetupSetFileQueueAlternatePlatformW SetupSetFileQueueAlternatePlatform; - alias SetupSetPlatformPathOverrideW SetupSetPlatformPathOverride; - alias SetupSetSourceListW SetupSetSourceList; + alias PSP_FILE_CALLBACK = PSP_FILE_CALLBACK_W; + alias SetupAddInstallSectionToDiskSpaceList = SetupAddInstallSectionToDiskSpaceListW; + alias SetupAddSectionToDiskSpaceList = SetupAddSectionToDiskSpaceListW; + alias SetupAddToDiskSpaceList = SetupAddToDiskSpaceListW; + alias SetupAddToSourceList = SetupAddToSourceListW; + alias SetupAdjustDiskSpaceList = SetupAdjustDiskSpaceListW; + alias SetupBackupError = SetupBackupErrorW; + alias SetupCommitFileQueue = SetupCommitFileQueueW; + alias SetupCopyError = SetupCopyErrorW; + alias SetupCopyOEMInf = SetupCopyOEMInfW; + alias SetupCreateDiskSpaceList = SetupCreateDiskSpaceListW; + alias SetupDecompressOrCopyFile = SetupDecompressOrCopyFileW; + alias SetupDefaultQueueCallback = SetupDefaultQueueCallbackW; + alias SetupDeleteError = SetupDeleteErrorW; + alias SetupDiBuildClassInfoListEx = SetupDiBuildClassInfoListExW; + alias SetupDiClassGuidsFromNameEx = SetupDiClassGuidsFromNameExW; + alias SetupDiClassGuidsFromName = SetupDiClassGuidsFromNameW; + alias SetupDiClassNameFromGuidEx = SetupDiClassNameFromGuidExW; + alias SetupDiClassNameFromGuid = SetupDiClassNameFromGuidW; + alias SetupDiCreateDeviceInfoListEx = SetupDiCreateDeviceInfoListExW; + alias SetupDiCreateDeviceInfo = SetupDiCreateDeviceInfoW; + alias SetupDiCreateDeviceInterfaceRegKey = SetupDiCreateDeviceInterfaceRegKeyW; + deprecated alias SetupDiCreateInterfaceDeviceRegKey = SetupDiCreateDeviceInterfaceRegKeyW; + alias SetupDiCreateDeviceInterface = SetupDiCreateDeviceInterfaceW; + deprecated alias SetupDiCreateInterfaceDevice = SetupDiCreateDeviceInterfaceW; + alias SetupDiCreateDevRegKey = SetupDiCreateDevRegKeyW; + alias SetupDiEnumDriverInfo = SetupDiEnumDriverInfoW; + alias SetupDiGetActualSectionToInstall = SetupDiGetActualSectionToInstallW; + alias SetupDiGetClassDescriptionEx = SetupDiGetClassDescriptionExW; + alias SetupDiGetClassDescription = SetupDiGetClassDescriptionW; + alias SetupDiGetClassDevPropertySheets = SetupDiGetClassDevPropertySheetsW; + alias SetupDiGetClassDevsEx = SetupDiGetClassDevsExW; + alias SetupDiGetClassDevs = SetupDiGetClassDevsW; + alias SetupDiGetClassImageListEx = SetupDiGetClassImageListExW; + alias SetupDiGetClassInstallParams = SetupDiGetClassInstallParamsW; + alias SetupDiGetClassRegistryProperty = SetupDiGetClassRegistryPropertyW; + alias SetupDiGetDeviceInfoListDetail = SetupDiGetDeviceInfoListDetailW; + alias SetupDiGetDeviceInstallParams = SetupDiGetDeviceInstallParamsW; + alias SetupDiGetDeviceInstanceId = SetupDiGetDeviceInstanceIdW; + alias SetupDiGetDeviceInterfaceDetail = SetupDiGetDeviceInterfaceDetailW; + deprecated alias SetupDiGetInterfaceDeviceDetail = SetupDiGetDeviceInterfaceDetailW; + alias SetupDiGetDeviceRegistryProperty = SetupDiGetDeviceRegistryPropertyW; + alias SetupDiGetDriverInfoDetail = SetupDiGetDriverInfoDetailW; + alias SetupDiGetDriverInstallParams = SetupDiGetDriverInstallParamsW; + alias SetupDiGetHwProfileFriendlyNameEx = SetupDiGetHwProfileFriendlyNameExW; + alias SetupDiGetHwProfileFriendlyName = SetupDiGetHwProfileFriendlyNameW; + alias SetupDiGetHwProfileListEx = SetupDiGetHwProfileListExW; + alias SetupDiGetINFClass = SetupDiGetINFClassW; + alias SetupDiGetSelectedDriver = SetupDiGetSelectedDriverW; + alias SetupDiInstallClassEx = SetupDiInstallClassExW; + alias SetupDiInstallClass = SetupDiInstallClassW; + alias SetupDiOpenClassRegKeyEx = SetupDiOpenClassRegKeyExW; + alias SetupDiOpenDeviceInfo = SetupDiOpenDeviceInfoW; + alias SetupDiOpenDeviceInterface = SetupDiOpenDeviceInterfaceW; + deprecated alias SetupDiOpenInterfaceDevice = SetupDiOpenDeviceInterfaceW; + alias SetupDiSetClassInstallParams = SetupDiSetClassInstallParamsW; + alias SetupDiSetClassRegistryProperty = SetupDiSetClassRegistryPropertyW; + alias SetupDiSetDeviceInstallParams = SetupDiSetDeviceInstallParamsW; + alias SetupDiSetDeviceRegistryProperty = SetupDiSetDeviceRegistryPropertyW; + alias SetupDiSetDriverInstallParams = SetupDiSetDriverInstallParamsW; + alias SetupDiSetSelectedDriver = SetupDiSetSelectedDriverW; + alias SetupDuplicateDiskSpaceList = SetupDuplicateDiskSpaceListW; + alias SetupFindFirstLine = SetupFindFirstLineW; + alias SetupFindNextMatchLine = SetupFindNextMatchLineW; + alias SetupFreeSourceList = SetupFreeSourceListW; + alias SetupGetBackupInformation = SetupGetBackupInformationW; + alias SetupGetFileCompressionInfo = SetupGetFileCompressionInfoW; + alias SetupGetInfFileList = SetupGetInfFileListW; + alias SetupGetInfInformation = SetupGetInfInformationW; + alias SetupGetLineByIndex = SetupGetLineByIndexW; + alias SetupGetLineCount = SetupGetLineCountW; + alias SetupGetLineText = SetupGetLineTextW; + alias SetupGetMultiSzField = SetupGetMultiSzFieldW; + alias SetupGetSourceFileLocation = SetupGetSourceFileLocationW; + alias SetupGetSourceFileSize = SetupGetSourceFileSizeW; + alias SetupGetSourceInfo = SetupGetSourceInfoW; + alias SetupGetStringField = SetupGetStringFieldW; + alias SetupGetTargetPath = SetupGetTargetPathW; + alias SetupInitializeFileLog = SetupInitializeFileLogW; + alias SetupInstallFileEx = SetupInstallFileExW; + alias SetupInstallFilesFromInfSection = SetupInstallFilesFromInfSectionW; + alias SetupInstallFile = SetupInstallFileW; + alias SetupInstallFromInfSection = SetupInstallFromInfSectionW; + alias SetupInstallServicesFromInfSectionEx = SetupInstallServicesFromInfSectionExW; + alias SetupInstallServicesFromInfSection = SetupInstallServicesFromInfSectionW; + alias SetupIterateCabinet = SetupIterateCabinetW; + alias SetupLogError = SetupLogErrorW; + alias SetupLogFile = SetupLogFileW; + alias SetupOpenAppendInfFile = SetupOpenAppendInfFileW; + alias SetupOpenInfFile = SetupOpenInfFileW; + alias SetupPromptForDisk = SetupPromptForDiskW; + alias SetupQueryDrivesInDiskSpaceList = SetupQueryDrivesInDiskSpaceListW; + alias SetupQueryFileLog = SetupQueryFileLogW; + alias SetupQueryInfFileInformation = SetupQueryInfFileInformationW; + alias SetupQueryInfOriginalFileInformation = SetupQueryInfOriginalFileInformationW; + alias SetupQueryInfVersionInformation = SetupQueryInfVersionInformationW; + alias SetupQuerySourceList = SetupQuerySourceListW; + alias SetupQuerySpaceRequiredOnDrive = SetupQuerySpaceRequiredOnDriveW; + alias SetupQueueCopyIndirect = SetupQueueCopyIndirectW; + alias SetupQueueCopySection = SetupQueueCopySectionW; + alias SetupQueueCopy = SetupQueueCopyW; + alias SetupQueueDefaultCopy = SetupQueueDefaultCopyW; + alias SetupQueueDeleteSection = SetupQueueDeleteSectionW; + alias SetupQueueDelete = SetupQueueDeleteW; + alias SetupQueueRenameSection = SetupQueueRenameSectionW; + alias SetupQueueRename = SetupQueueRenameW; + alias SetupRemoveFileLogEntry = SetupRemoveFileLogEntryW; + alias SetupRemoveFromDiskSpaceList = SetupRemoveFromDiskSpaceListW; + alias SetupRemoveFromSourceList = SetupRemoveFromSourceListW; + alias SetupRemoveInstallSectionFromDiskSpaceList = SetupRemoveInstallSectionFromDiskSpaceListW; + alias SetupRemoveSectionFromDiskSpaceList = SetupRemoveSectionFromDiskSpaceListW; + alias SetupRenameError = SetupRenameErrorW; + alias SetupScanFileQueue = SetupScanFileQueueW; + alias SetupSetDirectoryIdEx = SetupSetDirectoryIdExW; + alias SetupSetDirectoryId = SetupSetDirectoryIdW; + alias SetupSetFileQueueAlternatePlatform = SetupSetFileQueueAlternatePlatformW; + alias SetupSetPlatformPathOverride = SetupSetPlatformPathOverrideW; + alias SetupSetSourceList = SetupSetSourceListW; } else { - alias PSP_FILE_CALLBACK_A PSP_FILE_CALLBACK; - alias SetupAddInstallSectionToDiskSpaceListA SetupAddInstallSectionToDiskSpaceList; - alias SetupAddSectionToDiskSpaceListA SetupAddSectionToDiskSpaceList; - alias SetupAddToDiskSpaceListA SetupAddToDiskSpaceList; - alias SetupAddToSourceListA SetupAddToSourceList; - alias SetupAdjustDiskSpaceListA SetupAdjustDiskSpaceList; - alias SetupBackupErrorA SetupBackupError; - alias SetupCommitFileQueueA SetupCommitFileQueue; - alias SetupCopyErrorA SetupCopyError; - alias SetupCopyOEMInfA SetupCopyOEMInf; - alias SetupCreateDiskSpaceListA SetupCreateDiskSpaceList; - alias SetupDecompressOrCopyFileA SetupDecompressOrCopyFile; - alias SetupDefaultQueueCallbackA SetupDefaultQueueCallback; - alias SetupDeleteErrorA SetupDeleteError; - alias SetupDiBuildClassInfoListExA SetupDiBuildClassInfoListEx; - alias SetupDiClassGuidsFromNameA SetupDiClassGuidsFromName; - alias SetupDiClassGuidsFromNameExA SetupDiClassGuidsFromNameEx; - alias SetupDiClassNameFromGuidA SetupDiClassNameFromGuid; - alias SetupDiClassNameFromGuidExA SetupDiClassNameFromGuidEx; - alias SetupDiCreateDeviceInfoA SetupDiCreateDeviceInfo; - alias SetupDiCreateDeviceInfoListExA SetupDiCreateDeviceInfoListEx; - alias SetupDiCreateDeviceInterfaceA SetupDiCreateDeviceInterface; - deprecated alias SetupDiCreateDeviceInterfaceA SetupDiCreateInterfaceDevice; - alias SetupDiCreateDeviceInterfaceRegKeyA SetupDiCreateDeviceInterfaceRegKey; - deprecated alias SetupDiCreateDeviceInterfaceRegKeyA SetupDiCreateInterfaceDeviceRegKey; - alias SetupDiCreateDevRegKeyA SetupDiCreateDevRegKey; - alias SetupDiDeleteDeviceInterfaceData SetupDiDeleteInterfaceDeviceData; - alias SetupDiEnumDriverInfoA SetupDiEnumDriverInfo; - alias SetupDiGetActualSectionToInstallA SetupDiGetActualSectionToInstall; - alias SetupDiGetClassDescriptionA SetupDiGetClassDescription; - alias SetupDiGetClassDescriptionExA SetupDiGetClassDescriptionEx; - alias SetupDiGetClassDevPropertySheetsA SetupDiGetClassDevPropertySheets; - alias SetupDiGetClassDevsA SetupDiGetClassDevs; - alias SetupDiGetClassDevsExA SetupDiGetClassDevsEx; - alias SetupDiGetClassImageListExA SetupDiGetClassImageListEx; - alias SetupDiGetClassInstallParamsA SetupDiGetClassInstallParams; - alias SetupDiGetClassRegistryPropertyA SetupDiGetClassRegistryProperty; - alias SetupDiGetDeviceInfoListDetailA SetupDiGetDeviceInfoListDetail; - alias SetupDiGetDeviceInstallParamsA SetupDiGetDeviceInstallParams; - alias SetupDiGetDeviceInstanceIdA SetupDiGetDeviceInstanceId; - alias SetupDiGetDeviceInterfaceDetailA SetupDiGetDeviceInterfaceDetail; - deprecated alias SetupDiGetDeviceInterfaceDetailA SetupDiGetInterfaceDeviceDetail; - alias SetupDiGetDeviceRegistryPropertyA SetupDiGetDeviceRegistryProperty; - alias SetupDiGetDriverInfoDetailA SetupDiGetDriverInfoDetail; - alias SetupDiGetDriverInstallParamsA SetupDiGetDriverInstallParams; - alias SetupDiGetHwProfileFriendlyNameA SetupDiGetHwProfileFriendlyName; - alias SetupDiGetHwProfileFriendlyNameExA SetupDiGetHwProfileFriendlyNameEx; - alias SetupDiGetHwProfileListExA SetupDiGetHwProfileListEx; - alias SetupDiGetINFClassA SetupDiGetINFClass; - alias SetupDiGetSelectedDriverA SetupDiGetSelectedDriver; - alias SetupDiInstallClassA SetupDiInstallClass; - alias SetupDiInstallClassExA SetupDiInstallClassEx; - alias SetupDiOpenClassRegKeyExA SetupDiOpenClassRegKeyEx; - alias SetupDiOpenDeviceInfoA SetupDiOpenDeviceInfo; - alias SetupDiOpenDeviceInterfaceA SetupDiOpenDeviceInterface; - deprecated alias SetupDiOpenDeviceInterfaceA SetupDiOpenInterfaceDevice; - alias SetupDiSetClassInstallParamsA SetupDiSetClassInstallParams; - alias SetupDiSetClassRegistryPropertyA SetupDiSetClassRegistryProperty; - alias SetupDiSetDeviceInstallParamsA SetupDiSetDeviceInstallParams; - alias SetupDiSetDeviceRegistryPropertyA SetupDiSetDeviceRegistryProperty; - alias SetupDiSetDriverInstallParamsA SetupDiSetDriverInstallParams; - alias SetupDiSetSelectedDriverA SetupDiSetSelectedDriver; - alias SetupDuplicateDiskSpaceListA SetupDuplicateDiskSpaceList; - alias SetupFindFirstLineA SetupFindFirstLine; - alias SetupFindNextMatchLineA SetupFindNextMatchLine; - alias SetupFreeSourceListA SetupFreeSourceList; - alias SetupGetBackupInformationA SetupGetBackupInformation; - alias SetupGetFileCompressionInfoA SetupGetFileCompressionInfo; - alias SetupGetInfFileListA SetupGetInfFileList; - alias SetupGetInfInformationA SetupGetInfInformation; - alias SetupGetLineByIndexA SetupGetLineByIndex; - alias SetupGetLineCountA SetupGetLineCount; - alias SetupGetLineTextA SetupGetLineText; - alias SetupGetMultiSzFieldA SetupGetMultiSzField; - alias SetupGetSourceFileLocationA SetupGetSourceFileLocation; - alias SetupGetSourceFileSizeA SetupGetSourceFileSize; - alias SetupGetSourceInfoA SetupGetSourceInfo; - alias SetupGetStringFieldA SetupGetStringField; - alias SetupGetTargetPathA SetupGetTargetPath; - alias SetupInitializeFileLogA SetupInitializeFileLog; - alias SetupInstallFileA SetupInstallFile; - alias SetupInstallFileExA SetupInstallFileEx; - alias SetupInstallFilesFromInfSectionA SetupInstallFilesFromInfSection; - alias SetupInstallFromInfSectionA SetupInstallFromInfSection; - alias SetupInstallServicesFromInfSectionA SetupInstallServicesFromInfSection; - alias SetupInstallServicesFromInfSectionExA SetupInstallServicesFromInfSectionEx; - alias SetupIterateCabinetA SetupIterateCabinet; - alias SetupLogErrorA SetupLogError; - alias SetupLogFileA SetupLogFile; - alias SetupOpenAppendInfFileA SetupOpenAppendInfFile; - alias SetupOpenInfFileA SetupOpenInfFile; - alias SetupPromptForDiskA SetupPromptForDisk; - alias SetupQueryDrivesInDiskSpaceListA SetupQueryDrivesInDiskSpaceList; - alias SetupQueryFileLogA SetupQueryFileLog; - alias SetupQueryInfFileInformationA SetupQueryInfFileInformation; - alias SetupQueryInfOriginalFileInformationA SetupQueryInfOriginalFileInformation; - alias SetupQueryInfVersionInformationA SetupQueryInfVersionInformation; - alias SetupQuerySourceListA SetupQuerySourceList; - alias SetupQuerySpaceRequiredOnDriveA SetupQuerySpaceRequiredOnDrive; - alias SetupQueueCopyA SetupQueueCopy; - alias SetupQueueCopyIndirectA SetupQueueCopyIndirect; - alias SetupQueueCopySectionA SetupQueueCopySection; - alias SetupQueueDefaultCopyA SetupQueueDefaultCopy; - alias SetupQueueDeleteA SetupQueueDelete; - alias SetupQueueDeleteSectionA SetupQueueDeleteSection; - alias SetupQueueRenameA SetupQueueRename; - alias SetupQueueRenameSectionA SetupQueueRenameSection; - alias SetupRemoveFileLogEntryA SetupRemoveFileLogEntry; - alias SetupRemoveFromDiskSpaceListA SetupRemoveFromDiskSpaceList; - alias SetupRemoveFromSourceListA SetupRemoveFromSourceList; - alias SetupRemoveInstallSectionFromDiskSpaceListA SetupRemoveInstallSectionFromDiskSpaceList; - alias SetupRemoveSectionFromDiskSpaceListA SetupRemoveSectionFromDiskSpaceList; - alias SetupRenameErrorA SetupRenameError; - alias SetupScanFileQueueA SetupScanFileQueue; - alias SetupSetDirectoryIdA SetupSetDirectoryId; - alias SetupSetDirectoryIdExA SetupSetDirectoryIdEx; - alias SetupSetFileQueueAlternatePlatformA SetupSetFileQueueAlternatePlatform; - alias SetupSetPlatformPathOverrideA SetupSetPlatformPathOverride; - alias SetupSetSourceListA SetupSetSourceList; + alias PSP_FILE_CALLBACK = PSP_FILE_CALLBACK_A; + alias SetupAddInstallSectionToDiskSpaceList = SetupAddInstallSectionToDiskSpaceListA; + alias SetupAddSectionToDiskSpaceList = SetupAddSectionToDiskSpaceListA; + alias SetupAddToDiskSpaceList = SetupAddToDiskSpaceListA; + alias SetupAddToSourceList = SetupAddToSourceListA; + alias SetupAdjustDiskSpaceList = SetupAdjustDiskSpaceListA; + alias SetupBackupError = SetupBackupErrorA; + alias SetupCommitFileQueue = SetupCommitFileQueueA; + alias SetupCopyError = SetupCopyErrorA; + alias SetupCopyOEMInf = SetupCopyOEMInfA; + alias SetupCreateDiskSpaceList = SetupCreateDiskSpaceListA; + alias SetupDecompressOrCopyFile = SetupDecompressOrCopyFileA; + alias SetupDefaultQueueCallback = SetupDefaultQueueCallbackA; + alias SetupDeleteError = SetupDeleteErrorA; + alias SetupDiBuildClassInfoListEx = SetupDiBuildClassInfoListExA; + alias SetupDiClassGuidsFromName = SetupDiClassGuidsFromNameA; + alias SetupDiClassGuidsFromNameEx = SetupDiClassGuidsFromNameExA; + alias SetupDiClassNameFromGuid = SetupDiClassNameFromGuidA; + alias SetupDiClassNameFromGuidEx = SetupDiClassNameFromGuidExA; + alias SetupDiCreateDeviceInfo = SetupDiCreateDeviceInfoA; + alias SetupDiCreateDeviceInfoListEx = SetupDiCreateDeviceInfoListExA; + alias SetupDiCreateDeviceInterface = SetupDiCreateDeviceInterfaceA; + deprecated alias SetupDiCreateInterfaceDevice = SetupDiCreateDeviceInterfaceA; + alias SetupDiCreateDeviceInterfaceRegKey = SetupDiCreateDeviceInterfaceRegKeyA; + deprecated alias SetupDiCreateInterfaceDeviceRegKey = SetupDiCreateDeviceInterfaceRegKeyA; + alias SetupDiCreateDevRegKey = SetupDiCreateDevRegKeyA; + alias SetupDiDeleteInterfaceDeviceData = SetupDiDeleteDeviceInterfaceData; + alias SetupDiEnumDriverInfo = SetupDiEnumDriverInfoA; + alias SetupDiGetActualSectionToInstall = SetupDiGetActualSectionToInstallA; + alias SetupDiGetClassDescription = SetupDiGetClassDescriptionA; + alias SetupDiGetClassDescriptionEx = SetupDiGetClassDescriptionExA; + alias SetupDiGetClassDevPropertySheets = SetupDiGetClassDevPropertySheetsA; + alias SetupDiGetClassDevs = SetupDiGetClassDevsA; + alias SetupDiGetClassDevsEx = SetupDiGetClassDevsExA; + alias SetupDiGetClassImageListEx = SetupDiGetClassImageListExA; + alias SetupDiGetClassInstallParams = SetupDiGetClassInstallParamsA; + alias SetupDiGetClassRegistryProperty = SetupDiGetClassRegistryPropertyA; + alias SetupDiGetDeviceInfoListDetail = SetupDiGetDeviceInfoListDetailA; + alias SetupDiGetDeviceInstallParams = SetupDiGetDeviceInstallParamsA; + alias SetupDiGetDeviceInstanceId = SetupDiGetDeviceInstanceIdA; + alias SetupDiGetDeviceInterfaceDetail = SetupDiGetDeviceInterfaceDetailA; + deprecated alias SetupDiGetInterfaceDeviceDetail = SetupDiGetDeviceInterfaceDetailA; + alias SetupDiGetDeviceRegistryProperty = SetupDiGetDeviceRegistryPropertyA; + alias SetupDiGetDriverInfoDetail = SetupDiGetDriverInfoDetailA; + alias SetupDiGetDriverInstallParams = SetupDiGetDriverInstallParamsA; + alias SetupDiGetHwProfileFriendlyName = SetupDiGetHwProfileFriendlyNameA; + alias SetupDiGetHwProfileFriendlyNameEx = SetupDiGetHwProfileFriendlyNameExA; + alias SetupDiGetHwProfileListEx = SetupDiGetHwProfileListExA; + alias SetupDiGetINFClass = SetupDiGetINFClassA; + alias SetupDiGetSelectedDriver = SetupDiGetSelectedDriverA; + alias SetupDiInstallClass = SetupDiInstallClassA; + alias SetupDiInstallClassEx = SetupDiInstallClassExA; + alias SetupDiOpenClassRegKeyEx = SetupDiOpenClassRegKeyExA; + alias SetupDiOpenDeviceInfo = SetupDiOpenDeviceInfoA; + alias SetupDiOpenDeviceInterface = SetupDiOpenDeviceInterfaceA; + deprecated alias SetupDiOpenInterfaceDevice = SetupDiOpenDeviceInterfaceA; + alias SetupDiSetClassInstallParams = SetupDiSetClassInstallParamsA; + alias SetupDiSetClassRegistryProperty = SetupDiSetClassRegistryPropertyA; + alias SetupDiSetDeviceInstallParams = SetupDiSetDeviceInstallParamsA; + alias SetupDiSetDeviceRegistryProperty = SetupDiSetDeviceRegistryPropertyA; + alias SetupDiSetDriverInstallParams = SetupDiSetDriverInstallParamsA; + alias SetupDiSetSelectedDriver = SetupDiSetSelectedDriverA; + alias SetupDuplicateDiskSpaceList = SetupDuplicateDiskSpaceListA; + alias SetupFindFirstLine = SetupFindFirstLineA; + alias SetupFindNextMatchLine = SetupFindNextMatchLineA; + alias SetupFreeSourceList = SetupFreeSourceListA; + alias SetupGetBackupInformation = SetupGetBackupInformationA; + alias SetupGetFileCompressionInfo = SetupGetFileCompressionInfoA; + alias SetupGetInfFileList = SetupGetInfFileListA; + alias SetupGetInfInformation = SetupGetInfInformationA; + alias SetupGetLineByIndex = SetupGetLineByIndexA; + alias SetupGetLineCount = SetupGetLineCountA; + alias SetupGetLineText = SetupGetLineTextA; + alias SetupGetMultiSzField = SetupGetMultiSzFieldA; + alias SetupGetSourceFileLocation = SetupGetSourceFileLocationA; + alias SetupGetSourceFileSize = SetupGetSourceFileSizeA; + alias SetupGetSourceInfo = SetupGetSourceInfoA; + alias SetupGetStringField = SetupGetStringFieldA; + alias SetupGetTargetPath = SetupGetTargetPathA; + alias SetupInitializeFileLog = SetupInitializeFileLogA; + alias SetupInstallFile = SetupInstallFileA; + alias SetupInstallFileEx = SetupInstallFileExA; + alias SetupInstallFilesFromInfSection = SetupInstallFilesFromInfSectionA; + alias SetupInstallFromInfSection = SetupInstallFromInfSectionA; + alias SetupInstallServicesFromInfSection = SetupInstallServicesFromInfSectionA; + alias SetupInstallServicesFromInfSectionEx = SetupInstallServicesFromInfSectionExA; + alias SetupIterateCabinet = SetupIterateCabinetA; + alias SetupLogError = SetupLogErrorA; + alias SetupLogFile = SetupLogFileA; + alias SetupOpenAppendInfFile = SetupOpenAppendInfFileA; + alias SetupOpenInfFile = SetupOpenInfFileA; + alias SetupPromptForDisk = SetupPromptForDiskA; + alias SetupQueryDrivesInDiskSpaceList = SetupQueryDrivesInDiskSpaceListA; + alias SetupQueryFileLog = SetupQueryFileLogA; + alias SetupQueryInfFileInformation = SetupQueryInfFileInformationA; + alias SetupQueryInfOriginalFileInformation = SetupQueryInfOriginalFileInformationA; + alias SetupQueryInfVersionInformation = SetupQueryInfVersionInformationA; + alias SetupQuerySourceList = SetupQuerySourceListA; + alias SetupQuerySpaceRequiredOnDrive = SetupQuerySpaceRequiredOnDriveA; + alias SetupQueueCopy = SetupQueueCopyA; + alias SetupQueueCopyIndirect = SetupQueueCopyIndirectA; + alias SetupQueueCopySection = SetupQueueCopySectionA; + alias SetupQueueDefaultCopy = SetupQueueDefaultCopyA; + alias SetupQueueDelete = SetupQueueDeleteA; + alias SetupQueueDeleteSection = SetupQueueDeleteSectionA; + alias SetupQueueRename = SetupQueueRenameA; + alias SetupQueueRenameSection = SetupQueueRenameSectionA; + alias SetupRemoveFileLogEntry = SetupRemoveFileLogEntryA; + alias SetupRemoveFromDiskSpaceList = SetupRemoveFromDiskSpaceListA; + alias SetupRemoveFromSourceList = SetupRemoveFromSourceListA; + alias SetupRemoveInstallSectionFromDiskSpaceList = SetupRemoveInstallSectionFromDiskSpaceListA; + alias SetupRemoveSectionFromDiskSpaceList = SetupRemoveSectionFromDiskSpaceListA; + alias SetupRenameError = SetupRenameErrorA; + alias SetupScanFileQueue = SetupScanFileQueueA; + alias SetupSetDirectoryId = SetupSetDirectoryIdA; + alias SetupSetDirectoryIdEx = SetupSetDirectoryIdExA; + alias SetupSetFileQueueAlternatePlatform = SetupSetFileQueueAlternatePlatformA; + alias SetupSetPlatformPathOverride = SetupSetPlatformPathOverrideA; + alias SetupSetSourceList = SetupSetSourceListA; } diff --git a/runtime/druntime/src/core/sys/windows/shellapi.d b/runtime/druntime/src/core/sys/windows/shellapi.d index 2ddf680e1f..9c19e018e6 100644 --- a/runtime/druntime/src/core/sys/windows/shellapi.d +++ b/runtime/druntime/src/core/sys/windows/shellapi.d @@ -187,7 +187,7 @@ enum SHERB_NOCONFIRMATION = 1; enum SHERB_NOPROGRESSUI = 2; enum SHERB_NOSOUND = 4; -alias WORD FILEOP_FLAGS, PRINTEROP_FLAGS; +alias FILEOP_FLAGS = WORD, PRINTEROP_FLAGS = WORD; alias HDROP = HANDLE; //align(2): // 1 in Win32, default in Win64 @@ -200,7 +200,7 @@ struct APPBARDATA { RECT rc; LPARAM lParam; } -alias APPBARDATA* PAPPBARDATA; +alias PAPPBARDATA = APPBARDATA*; struct NOTIFYICONDATAA { DWORD cbSize = NOTIFYICONDATAA.sizeof; @@ -227,7 +227,7 @@ struct NOTIFYICONDATAA { GUID guidItem; } } -alias NOTIFYICONDATAA* PNOTIFYICONDATAA; +alias PNOTIFYICONDATAA = NOTIFYICONDATAA*; struct NOTIFYICONDATAW { DWORD cbSize = NOTIFYICONDATAW.sizeof; @@ -254,7 +254,7 @@ struct NOTIFYICONDATAW { GUID guidItem; } } -alias NOTIFYICONDATAW* PNOTIFYICONDATAW; +alias PNOTIFYICONDATAW = NOTIFYICONDATAW*; struct SHELLEXECUTEINFOA { DWORD cbSize = SHELLEXECUTEINFOA.sizeof; @@ -273,7 +273,7 @@ struct SHELLEXECUTEINFOA { HANDLE hIcon; HANDLE hProcess; } -alias SHELLEXECUTEINFOA* LPSHELLEXECUTEINFOA; +alias LPSHELLEXECUTEINFOA = SHELLEXECUTEINFOA*; struct SHELLEXECUTEINFOW { DWORD cbSize = SHELLEXECUTEINFOW.sizeof; @@ -292,7 +292,7 @@ struct SHELLEXECUTEINFOW { HANDLE hIcon; HANDLE hProcess; } -alias SHELLEXECUTEINFOW* LPSHELLEXECUTEINFOW; +alias LPSHELLEXECUTEINFOW = SHELLEXECUTEINFOW*; align(1) struct SHFILEOPSTRUCTA { align(1): @@ -309,7 +309,7 @@ align(1): PVOID hNameMappings; LPCSTR lpszProgressTitle; } -alias SHFILEOPSTRUCTA* LPSHFILEOPSTRUCTA; +alias LPSHFILEOPSTRUCTA = SHFILEOPSTRUCTA*; align(1) struct SHFILEOPSTRUCTW { align(1): @@ -326,7 +326,7 @@ align(1): PVOID hNameMappings; LPCWSTR lpszProgressTitle; } -alias SHFILEOPSTRUCTW* LPSHFILEOPSTRUCTW; +alias LPSHFILEOPSTRUCTW = SHFILEOPSTRUCTW*; struct SHFILEINFOA { HICON hIcon; @@ -352,7 +352,7 @@ align(1): long i64Size; long i64NumItems; } -alias SHQUERYRBINFO* LPSHQUERYRBINFO; +alias LPSHQUERYRBINFO = SHQUERYRBINFO*; extern (Windows) nothrow @nogc { LPWSTR* CommandLineToArgvW(LPCWSTR, int*); @@ -391,43 +391,43 @@ extern (Windows) nothrow @nogc { } version (Unicode) { - alias NOTIFYICONDATAW NOTIFYICONDATA; - alias SHELLEXECUTEINFOW SHELLEXECUTEINFO; - alias SHFILEOPSTRUCTW SHFILEOPSTRUCT; - alias SHFILEINFOW SHFILEINFO; - alias DragQueryFileW DragQueryFile; - alias ExtractAssociatedIconW ExtractAssociatedIcon; - alias ExtractIconW ExtractIcon; - alias ExtractIconExW ExtractIconEx; - alias FindExecutableW FindExecutable; - alias Shell_NotifyIconW Shell_NotifyIcon; - alias ShellAboutW ShellAbout; - alias ShellExecuteW ShellExecute; - alias ShellExecuteExW ShellExecuteEx; - alias SHFileOperationW SHFileOperation; - alias SHGetFileInfoW SHGetFileInfo; - alias SHQueryRecycleBinW SHQueryRecycleBin; - alias SHEmptyRecycleBinW SHEmptyRecycleBin; + alias NOTIFYICONDATA = NOTIFYICONDATAW; + alias SHELLEXECUTEINFO = SHELLEXECUTEINFOW; + alias SHFILEOPSTRUCT = SHFILEOPSTRUCTW; + alias SHFILEINFO = SHFILEINFOW; + alias DragQueryFile = DragQueryFileW; + alias ExtractAssociatedIcon = ExtractAssociatedIconW; + alias ExtractIcon = ExtractIconW; + alias ExtractIconEx = ExtractIconExW; + alias FindExecutable = FindExecutableW; + alias Shell_NotifyIcon = Shell_NotifyIconW; + alias ShellAbout = ShellAboutW; + alias ShellExecute = ShellExecuteW; + alias ShellExecuteEx = ShellExecuteExW; + alias SHFileOperation = SHFileOperationW; + alias SHGetFileInfo = SHGetFileInfoW; + alias SHQueryRecycleBin = SHQueryRecycleBinW; + alias SHEmptyRecycleBin = SHEmptyRecycleBinW; } else { - alias NOTIFYICONDATAA NOTIFYICONDATA; - alias SHELLEXECUTEINFOA SHELLEXECUTEINFO; - alias SHFILEOPSTRUCTA SHFILEOPSTRUCT; - alias SHFILEINFOA SHFILEINFO; - alias DragQueryFileA DragQueryFile; - alias ExtractAssociatedIconA ExtractAssociatedIcon; - alias ExtractIconA ExtractIcon; - alias ExtractIconExA ExtractIconEx; - alias FindExecutableA FindExecutable; - alias Shell_NotifyIconA Shell_NotifyIcon; - alias ShellAboutA ShellAbout; - alias ShellExecuteA ShellExecute; - alias ShellExecuteExA ShellExecuteEx; - alias SHFileOperationA SHFileOperation; - alias SHGetFileInfoA SHGetFileInfo; - alias SHQueryRecycleBinA SHQueryRecycleBin; - alias SHEmptyRecycleBinA SHEmptyRecycleBin; + alias NOTIFYICONDATA = NOTIFYICONDATAA; + alias SHELLEXECUTEINFO = SHELLEXECUTEINFOA; + alias SHFILEOPSTRUCT = SHFILEOPSTRUCTA; + alias SHFILEINFO = SHFILEINFOA; + alias DragQueryFile = DragQueryFileA; + alias ExtractAssociatedIcon = ExtractAssociatedIconA; + alias ExtractIcon = ExtractIconA; + alias ExtractIconEx = ExtractIconExA; + alias FindExecutable = FindExecutableA; + alias Shell_NotifyIcon = Shell_NotifyIconA; + alias ShellAbout = ShellAboutA; + alias ShellExecute = ShellExecuteA; + alias ShellExecuteEx = ShellExecuteExA; + alias SHFileOperation = SHFileOperationA; + alias SHGetFileInfo = SHGetFileInfoA; + alias SHQueryRecycleBin = SHQueryRecycleBinA; + alias SHEmptyRecycleBin = SHEmptyRecycleBinA; } -alias NOTIFYICONDATA* PNOTIFYICONDATA; -alias SHELLEXECUTEINFO* LPSHELLEXECUTEINFO; -alias SHFILEOPSTRUCT* LPSHFILEOPSTRUCT; +alias PNOTIFYICONDATA = NOTIFYICONDATA*; +alias LPSHELLEXECUTEINFO = SHELLEXECUTEINFO*; +alias LPSHFILEOPSTRUCT = SHFILEOPSTRUCT*; diff --git a/runtime/druntime/src/core/sys/windows/shldisp.d b/runtime/druntime/src/core/sys/windows/shldisp.d index 144f90775e..dd5549d717 100644 --- a/runtime/druntime/src/core/sys/windows/shldisp.d +++ b/runtime/druntime/src/core/sys/windows/shldisp.d @@ -18,10 +18,10 @@ interface IAutoComplete : IUnknown { HRESULT Init(HWND, IUnknown, LPCOLESTR, LPCOLESTR); HRESULT Enable(BOOL); } -alias IAutoComplete LPAUTOCOMPLETE; +alias LPAUTOCOMPLETE = IAutoComplete; interface IAutoComplete2 : IAutoComplete { HRESULT SetOptions(DWORD); HRESULT GetOptions(DWORD*); } -alias IAutoComplete2 LPAUTOCOMPLETE2; +alias LPAUTOCOMPLETE2 = IAutoComplete2; diff --git a/runtime/druntime/src/core/sys/windows/shlobj.d b/runtime/druntime/src/core/sys/windows/shlobj.d index 0e292d4c71..07c5c903ff 100644 --- a/runtime/druntime/src/core/sys/windows/shlobj.d +++ b/runtime/druntime/src/core/sys/windows/shlobj.d @@ -53,13 +53,13 @@ enum BFFM_SETOKTEXT = WM_USER + 105; enum BFFM_SETEXPANDED = WM_USER + 106; version (Unicode) { - alias BFFM_SETSTATUSTEXTW BFFM_SETSTATUSTEXT; - alias BFFM_SETSELECTIONW BFFM_SETSELECTION; - alias BFFM_VALIDATEFAILEDW BFFM_VALIDATEFAILED; + alias BFFM_SETSTATUSTEXT = BFFM_SETSTATUSTEXTW; + alias BFFM_SETSELECTION = BFFM_SETSELECTIONW; + alias BFFM_VALIDATEFAILED = BFFM_VALIDATEFAILEDW; } else { - alias BFFM_SETSTATUSTEXTA BFFM_SETSTATUSTEXT; - alias BFFM_SETSELECTIONA BFFM_SETSELECTION; - alias BFFM_VALIDATEFAILEDA BFFM_VALIDATEFAILED; + alias BFFM_SETSTATUSTEXT = BFFM_SETSTATUSTEXTA; + alias BFFM_SETSELECTION = BFFM_SETSELECTIONA; + alias BFFM_VALIDATEFAILED = BFFM_VALIDATEFAILEDA; } enum DVASPECT_SHORTNAME = 2; @@ -112,11 +112,11 @@ enum SHCNF_FLUSH = 0x1000; enum SHCNF_FLUSHNOWAIT = 0x2000; version (Unicode) { - alias SHCNF_PATHW SHCNF_PATH; - alias SHCNF_PRINTERW SHCNF_PRINTER; + alias SHCNF_PATH = SHCNF_PATHW; + alias SHCNF_PRINTER = SHCNF_PRINTERW; } else { - alias SHCNF_PATHA SHCNF_PATH; - alias SHCNF_PRINTERA SHCNF_PRINTER; + alias SHCNF_PATH = SHCNF_PATHA; + alias SHCNF_PRINTER = SHCNF_PRINTERA; } enum SFGAOF : DWORD { @@ -256,15 +256,15 @@ const TCHAR[] CFSTR_INETURLW = "UniformResourceLocatorW"; version (Unicode) { - alias CFSTR_FILENAMEW CFSTR_FILENAME; - alias CFSTR_FILENAMEMAPW CFSTR_FILENAMEMAP; - alias CFSTR_FILEDESCRIPTORW CFSTR_FILEDESCRIPTOR; - alias CFSTR_INETURLW CFSTR_INETURL; + alias CFSTR_FILENAME = CFSTR_FILENAMEW; + alias CFSTR_FILENAMEMAP = CFSTR_FILENAMEMAPW; + alias CFSTR_FILEDESCRIPTOR = CFSTR_FILEDESCRIPTORW; + alias CFSTR_INETURL = CFSTR_INETURLW; } else { - alias CFSTR_FILENAMEA CFSTR_FILENAME; - alias CFSTR_FILENAMEMAPA CFSTR_FILENAMEMAP; - alias CFSTR_FILEDESCRIPTORA CFSTR_FILEDESCRIPTOR; - alias CFSTR_INETURLA CFSTR_INETURL; + alias CFSTR_FILENAME = CFSTR_FILENAMEA; + alias CFSTR_FILENAMEMAP = CFSTR_FILENAMEMAPA; + alias CFSTR_FILEDESCRIPTOR = CFSTR_FILEDESCRIPTORA; + alias CFSTR_INETURL = CFSTR_INETURLA; } const TCHAR[] CFSTR_PRINTERGROUP = "PrinterFriendlyName", @@ -291,13 +291,13 @@ enum GCS_VALIDATEW=6; enum GCS_UNICODE=4; version (Unicode) { - alias GCS_VERBW GCS_VERB; - alias GCS_HELPTEXTW GCS_HELPTEXT; - alias GCS_VALIDATEW GCS_VALIDATE; + alias GCS_VERB = GCS_VERBW; + alias GCS_HELPTEXT = GCS_HELPTEXTW; + alias GCS_VALIDATE = GCS_VALIDATEW; } else { - alias GCS_VERBA GCS_VERB; - alias GCS_HELPTEXTA GCS_HELPTEXT; - alias GCS_VALIDATEA GCS_VALIDATE; + alias GCS_VERB = GCS_VERBA; + alias GCS_HELPTEXT = GCS_HELPTEXTA; + alias GCS_VALIDATE = GCS_VALIDATEA; } const TCHAR[] @@ -386,28 +386,28 @@ enum SVGIO_ALLVIEW=2; enum UINT SV2GV_CURRENTVIEW=-1; enum UINT SV2GV_DEFAULTVIEW=-2; -alias DWORD SHGDNF; +alias SHGDNF = DWORD; struct CIDA { UINT cidl; UINT[1] aoffset; } -alias CIDA* LPIDA; +alias LPIDA = CIDA*; struct SHITEMID { USHORT cb; BYTE[1] abID; } -alias SHITEMID* LPSHITEMID; -alias const(SHITEMID)* LPCSHITEMID; +alias LPSHITEMID = SHITEMID*; +alias LPCSHITEMID = const(SHITEMID)*; struct ITEMIDLIST { SHITEMID mkid; } -alias ITEMIDLIST* LPITEMIDLIST; -alias const(ITEMIDLIST)* LPCITEMIDLIST; +alias LPITEMIDLIST = ITEMIDLIST*; +alias LPCITEMIDLIST = const(ITEMIDLIST)*; -extern (Windows) alias int function(HWND, UINT, LPARAM, LPARAM) BFFCALLBACK; +extern (Windows) alias BFFCALLBACK = int function(HWND, UINT, LPARAM, LPARAM); align (8) { struct BROWSEINFOA { @@ -420,7 +420,7 @@ struct BROWSEINFOA { LPARAM lParam; int iImage; } -alias BROWSEINFOA* PBROWSEINFOA, LPBROWSEINFOA; +alias PBROWSEINFOA = BROWSEINFOA*, LPBROWSEINFOA = BROWSEINFOA*; struct BROWSEINFOW { HWND hwndOwner; @@ -432,7 +432,7 @@ struct BROWSEINFOW { LPARAM lParam; int iImage; } -alias BROWSEINFOW* PBROWSEINFOW, LPBROWSEINFOW; +alias PBROWSEINFOW = BROWSEINFOW*, LPBROWSEINFOW = BROWSEINFOW*; } // align (8) struct CMINVOKECOMMANDINFO { @@ -446,7 +446,7 @@ struct CMINVOKECOMMANDINFO { DWORD dwHotKey; HANDLE hIcon; } -alias CMINVOKECOMMANDINFO* LPCMINVOKECOMMANDINFO; +alias LPCMINVOKECOMMANDINFO = CMINVOKECOMMANDINFO*; struct DROPFILES { DWORD pFiles; @@ -454,7 +454,7 @@ struct DROPFILES { BOOL fNC; BOOL fWide; } -alias DROPFILES* LPDROPFILES; +alias LPDROPFILES = DROPFILES*; enum SHGNO { SHGDN_NORMAL = 0, @@ -483,7 +483,7 @@ align(8) struct STRRET { char[MAX_PATH] cStr; } } -alias STRRET* LPSTRRET; +alias LPSTRRET = STRRET*; enum FD_FLAGS { FD_CLSID = 1, @@ -509,7 +509,7 @@ struct FILEDESCRIPTORA { DWORD nFileSizeLow; CHAR[MAX_PATH] cFileName = 0; } -alias FILEDESCRIPTORA* LPFILEDESCRIPTORA; +alias LPFILEDESCRIPTORA = FILEDESCRIPTORA*; struct FILEDESCRIPTORW { DWORD dwFlags; @@ -524,19 +524,19 @@ struct FILEDESCRIPTORW { DWORD nFileSizeLow; WCHAR[MAX_PATH] cFileName = 0; } -alias FILEDESCRIPTORW* LPFILEDESCRIPTORW; +alias LPFILEDESCRIPTORW = FILEDESCRIPTORW*; struct FILEGROUPDESCRIPTORA { UINT cItems; FILEDESCRIPTORA[1] fgd; } -alias FILEGROUPDESCRIPTORA* LPFILEGROUPDESCRIPTORA; +alias LPFILEGROUPDESCRIPTORA = FILEGROUPDESCRIPTORA*; struct FILEGROUPDESCRIPTORW { UINT cItems; FILEDESCRIPTORW[1] fgd; } -alias FILEGROUPDESCRIPTORW* LPFILEGROUPDESCRIPTORW; +alias LPFILEGROUPDESCRIPTORW = FILEGROUPDESCRIPTORW*; enum SLR_FLAGS { SLR_NO_UI = 1, @@ -555,7 +555,7 @@ enum SLGP_FLAGS { SLGP_RAWPATH=4 } -alias PBYTE LPVIEWSETTINGS; +alias LPVIEWSETTINGS = PBYTE; enum FOLDERFLAGS { FWF_AUTOARRANGE = 1, @@ -584,8 +584,8 @@ struct FOLDERSETTINGS { UINT ViewMode; UINT fFlags; } -alias FOLDERSETTINGS* LPFOLDERSETTINGS; -alias const(FOLDERSETTINGS)* LPCFOLDERSETTINGS; +alias LPFOLDERSETTINGS = FOLDERSETTINGS*; +alias LPCFOLDERSETTINGS = const(FOLDERSETTINGS)*; struct FVSHOWINFO { DWORD cbSize = this.sizeof; @@ -596,13 +596,13 @@ struct FVSHOWINFO { LPUNKNOWN punkRel; OLECHAR[MAX_PATH] strNewFile = 0; } -alias FVSHOWINFO* LPFVSHOWINFO; +alias LPFVSHOWINFO = FVSHOWINFO*; struct NRESARRAY { UINT cItems; NETRESOURCE[1] nr; } -alias NRESARRAY* LPNRESARRAY; +alias LPNRESARRAY = NRESARRAY*; enum { SBSC_HIDE, @@ -635,23 +635,23 @@ static if (_WIN32_IE >= 0x500) { WCHAR[80] wszFriendlyName = 0; WCHAR[2084] wszUrl = 0; } - alias EXTRASEARCH* LPEXTRASEARCH; + alias LPEXTRASEARCH = EXTRASEARCH*; - alias DWORD SHCOLSTATEF; + alias SHCOLSTATEF = DWORD; struct SHCOLUMNID { GUID fmtid; DWORD pid; } - alias SHCOLUMNID* LPSHCOLUMNID; - alias const(SHCOLUMNID)* LPCSHCOLUMNID; + alias LPSHCOLUMNID = SHCOLUMNID*; + alias LPCSHCOLUMNID = const(SHCOLUMNID)*; struct SHELLDETAILS { int fmt; int cxChar; STRRET str; } - alias SHELLDETAILS* LPSHELLDETAILS; + alias LPSHELLDETAILS = SHELLDETAILS*; struct PERSIST_FOLDER_TARGET_INFO { @@ -675,7 +675,7 @@ interface IEnumIDList : IUnknown { HRESULT Reset(); HRESULT Clone(IEnumIDList*); } -alias IEnumIDList LPENUMIDLIST; +alias LPENUMIDLIST = IEnumIDList; interface IObjMgr : IUnknown { HRESULT Append(IUnknown); @@ -687,12 +687,12 @@ interface IContextMenu : IUnknown { HRESULT InvokeCommand(LPCMINVOKECOMMANDINFO); HRESULT GetCommandString(UINT_PTR, UINT, PUINT, LPSTR, UINT); } -alias IContextMenu LPCONTEXTMENU; +alias LPCONTEXTMENU = IContextMenu; interface IContextMenu2 : IContextMenu { HRESULT HandleMenuMsg(UINT, WPARAM, LPARAM); } -alias IContextMenu2 LPCONTEXTMENU2; +alias LPCONTEXTMENU2 = IContextMenu2; static if (_WIN32_IE >= 0x500) { align(8) { @@ -701,8 +701,8 @@ static if (_WIN32_IE >= 0x500) { ULONG dwReserved; WCHAR[MAX_PATH] wszFolder = 0; } - alias SHCOLUMNINIT* LPSHCOLUMNINIT; - alias const(SHCOLUMNINIT)* LPCSHCOLUMNINIT; + alias LPSHCOLUMNINIT = SHCOLUMNINIT*; + alias LPCSHCOLUMNINIT = const(SHCOLUMNINIT)*; struct SHCOLUMNDATA { ULONG dwFlags; @@ -711,8 +711,8 @@ static if (_WIN32_IE >= 0x500) { WCHAR *pwszExt = null; WCHAR[MAX_PATH] wszFile = 0; } - alias SHCOLUMNDATA* LPSHCOLUMNDATA; - alias const(SHCOLUMNDATA)* LPCSHCOLUMNDATA; + alias LPSHCOLUMNDATA = SHCOLUMNDATA*; + alias LPCSHCOLUMNDATA = const(SHCOLUMNDATA)*; } enum MAX_COLUMN_NAME_LEN = 80; @@ -728,8 +728,8 @@ enum MAX_COLUMN_DESC_LEN = 128; WCHAR[MAX_COLUMN_NAME_LEN] wszTitle = 0; WCHAR[MAX_COLUMN_DESC_LEN] wszDescription = 0; } - alias SHCOLUMNINFO* LPSHCOLUMNINFO; - alias const(SHCOLUMNINFO)* LPCSHCOLUMNINFO; + alias LPSHCOLUMNINFO = SHCOLUMNINFO*; + alias LPCSHCOLUMNINFO = const(SHCOLUMNINFO)*; enum SHCOLSTATE { SHCOLSTATE_TYPE_STR = 0x00000001, @@ -759,32 +759,32 @@ interface IQueryInfo : IUnknown { interface IShellExtInit : IUnknown { HRESULT Initialize(LPCITEMIDLIST, LPDATAOBJECT, HKEY); } -alias IShellExtInit LPSHELLEXTINIT; +alias LPSHELLEXTINIT = IShellExtInit; interface IShellPropSheetExt : IUnknown { HRESULT AddPages(LPFNADDPROPSHEETPAGE, LPARAM); HRESULT ReplacePage(UINT, LPFNADDPROPSHEETPAGE, LPARAM); } -alias IShellPropSheetExt LPSHELLPROPSHEETEXT; +alias LPSHELLPROPSHEETEXT = IShellPropSheetExt; interface IExtractIconA : IUnknown { HRESULT GetIconLocation(UINT, LPSTR, UINT, int*, PUINT); HRESULT Extract(LPCSTR, UINT, HICON*, HICON*, UINT); } -alias IExtractIconA LPEXTRACTICONA; +alias LPEXTRACTICONA = IExtractIconA; interface IExtractIconW : IUnknown { HRESULT GetIconLocation(UINT, LPWSTR, UINT, int*, PUINT); HRESULT Extract(LPCWSTR, UINT, HICON*, HICON*, UINT); } -alias IExtractIconW LPEXTRACTICONW; +alias LPEXTRACTICONW = IExtractIconW; version (Unicode) { - alias IExtractIconW IExtractIcon; - alias LPEXTRACTICONW LPEXTRACTICON; + alias IExtractIcon = IExtractIconW; + alias LPEXTRACTICON = LPEXTRACTICONW; } else { - alias IExtractIconA IExtractIcon; - alias LPEXTRACTICONA LPEXTRACTICON; + alias IExtractIcon = IExtractIconA; + alias LPEXTRACTICON = LPEXTRACTICONA; } interface IShellLinkA : IUnknown { @@ -842,7 +842,7 @@ interface IShellFolder : IUnknown { HRESULT GetDisplayNameOf(LPCITEMIDLIST, DWORD, LPSTRRET); HRESULT SetNameOf(HWND, LPCITEMIDLIST, LPCOLESTR, DWORD, LPITEMIDLIST*); } -alias IShellFolder LPSHELLFOLDER; +alias LPSHELLFOLDER = IShellFolder; static if (_WIN32_IE >= 0x500) { @@ -852,7 +852,7 @@ interface IEnumExtraSearch: IUnknown { HRESULT Reset(); HRESULT Clone(IEnumExtraSearch*); } -alias IEnumExtraSearch LPENUMEXTRASEARCH; +alias LPENUMEXTRASEARCH = IEnumExtraSearch; interface IShellFolder2 : IShellFolder { HRESULT GetDefaultSearchGUID(GUID*); @@ -863,27 +863,27 @@ interface IShellFolder2 : IShellFolder { HRESULT GetDetailsOf(LPCITEMIDLIST, UINT, SHELLDETAILS*); HRESULT MapColumnToSCID(UINT, SHCOLUMNID*); } -alias IShellFolder2 LPSHELLFOLDER2; +alias LPSHELLFOLDER2 = IShellFolder2; } /* _WIN32_IE >= 0x500 */ interface ICopyHook : IUnknown { UINT CopyCallback(HWND, UINT, UINT, LPCSTR, DWORD, LPCSTR, DWORD); } -alias ICopyHook LPCOPYHOOK; +alias LPCOPYHOOK = ICopyHook; interface IFileViewerSite : IUnknown { HRESULT SetPinnedWindow(HWND); HRESULT GetPinnedWindow(HWND*); } -alias IFileViewerSite LPFILEVIEWERSITE; +alias LPFILEVIEWERSITE = IFileViewerSite; interface IFileViewer : IUnknown { HRESULT ShowInitialize(LPFILEVIEWERSITE); HRESULT Show(LPFVSHOWINFO); HRESULT PrintTo(LPSTR, BOOL); } -alias IFileViewer LPFILEVIEWER; +alias LPFILEVIEWER = IFileViewer; interface IFileSystemBindData : IUnknown { HRESULT SetFindData(const(WIN32_FIND_DATAW)*); @@ -894,7 +894,7 @@ interface IPersistFolder : IPersist { HRESULT GetClassID(CLSID*); HRESULT Initialize(LPCITEMIDLIST); } -alias IPersistFolder LPPERSISTFOLDER; +alias LPPERSISTFOLDER = IPersistFolder; static if (_WIN32_IE >= 0x400 || _WIN32_WINNT >= 0x500) { @@ -903,7 +903,7 @@ interface IPersistFolder2 : IPersistFolder { HRESULT Initialize(LPCITEMIDLIST); HRESULT GetCurFolder(LPITEMIDLIST*); } -alias IPersistFolder2 LPPERSISTFOLDER2; +alias LPPERSISTFOLDER2 = IPersistFolder2; }/* _WIN32_IE >= 0x400 || _WIN32_WINNT >= 0x500 */ @@ -916,12 +916,12 @@ interface IPersistFolder3 : IPersistFolder2 { HRESULT InitializeEx(IBindCtx, LPCITEMIDLIST, const(PERSIST_FOLDER_TARGET_INFO)*); HRESULT GetFolderTargetInfo(PERSIST_FOLDER_TARGET_INFO*); } -alias IPersistFolder3 LPPERSISTFOLDER3; +alias LPPERSISTFOLDER3 = IPersistFolder3; } /* _WIN32_IE >= 0x500 */ -alias IShellBrowser LPSHELLBROWSER; -alias IShellView LPSHELLVIEW; +alias LPSHELLBROWSER = IShellBrowser; +alias LPSHELLVIEW = IShellView; interface IShellBrowser : IOleWindow { HRESULT GetWindow(HWND*); @@ -966,9 +966,9 @@ interface ICommDlgBrowser : IUnknown { HRESULT OnStateChange(IShellView, ULONG); HRESULT IncludeObject(IShellView, LPCITEMIDLIST); } -alias ICommDlgBrowser LPCOMMDLGBROWSER; +alias LPCOMMDLGBROWSER = ICommDlgBrowser; -alias GUID SHELLVIEWID; +alias SHELLVIEWID = GUID; struct SV2CVW2_PARAMS { DWORD cbSize = this.sizeof; @@ -979,7 +979,7 @@ struct SV2CVW2_PARAMS { const(SHELLVIEWID)* pvid; HWND hwndView; } -alias SV2CVW2_PARAMS* LPSV2CVW2_PARAMS; +alias LPSV2CVW2_PARAMS = SV2CVW2_PARAMS*; interface IShellView2 : IShellView { HRESULT GetWindow(HWND*); @@ -1014,7 +1014,7 @@ interface IShellExecuteHookW : IUnknown { interface IShellIcon : IUnknown { HRESULT GetIconOf(LPCITEMIDLIST, UINT, PINT); } -alias IShellIcon LPSHELLICON; +alias LPSHELLICON = IShellIcon; struct SHELLFLAGSTATE { short _bf; @@ -1064,7 +1064,7 @@ struct SHELLFLAGSTATE { @property bool fHideIcons()(bool f) { _bf = cast(ushort) ((_bf & ~0xEFFF) | (f << 12)); return f; } @property ubyte fRestFlags()(ubyte f) { _bf = cast(ushort) ((_bf & ~0x1FFF) | (f << 13)); return cast(ubyte) (f & 7); } } -alias SHELLFLAGSTATE* LPSHELLFLAGSTATE; +alias LPSHELLFLAGSTATE = SHELLFLAGSTATE*; enum SSF_SHOWALLOBJECTS = 0x1; enum SSF_SHOWEXTENSIONS = 0x2; @@ -1172,7 +1172,7 @@ static if (_WIN32_WINNT >= 0x500) { return cast(ushort) (f & 0x1FFF); } } - alias SHELLSTATE* LPSHELLSTATE; + alias LPSHELLSTATE = SHELLSTATE*; } static if (_WIN32_IE >= 0x500) { @@ -1183,7 +1183,7 @@ static if (_WIN32_IE >= 0x500) { HBITMAP hbmpDragImage; COLORREF crColorKey; } - alias SHDRAGIMAGE* LPSHDRAGIMAGE; + alias LPSHDRAGIMAGE = SHDRAGIMAGE*; } interface IDragSourceHelper : IUnknown { @@ -1249,7 +1249,7 @@ static if (_WIN32_WINNT >= 0x501) { DWORD dwDescriptionId; CLSID clsid; } - alias SHDESCRIPTIONID* LPSHDESCRIPTIONID; + alias LPSHDESCRIPTIONID = SHDESCRIPTIONID*; BOOL PathResolve(LPWSTR, LPCWSTR*, UINT); HRESULT SHGetFolderPathAndSubDirA(HWND, int, HANDLE, DWORD, LPCSTR, LPSTR); @@ -1280,52 +1280,52 @@ static if (_WIN32_WINNT >= 0x500) { } version (Unicode) { - alias IShellExecuteHookW IShellExecuteHook; - alias IShellLinkW IShellLink; - alias BROWSEINFOW BROWSEINFO; - alias SHBrowseForFolderW SHBrowseForFolder; - alias SHGetDataFromIDListW SHGetDataFromIDList; - alias SHGetPathFromIDListW SHGetPathFromIDList; + alias IShellExecuteHook = IShellExecuteHookW; + alias IShellLink = IShellLinkW; + alias BROWSEINFO = BROWSEINFOW; + alias SHBrowseForFolder = SHBrowseForFolderW; + alias SHGetDataFromIDList = SHGetDataFromIDListW; + alias SHGetPathFromIDList = SHGetPathFromIDListW; static if (_WIN32_IE >= 0x400) { - alias SHGetSpecialFolderPathW SHGetSpecialFolderPath; + alias SHGetSpecialFolderPath = SHGetSpecialFolderPathW; } - alias SHGetFolderPathW SHGetFolderPath; + alias SHGetFolderPath = SHGetFolderPathW; static if (_WIN32_WINNT >= 0x500) { - alias SHGetIconOverlayIndexW SHGetIconOverlayIndex; - alias SHCreateDirectoryExW SHCreateDirectoryEx; + alias SHGetIconOverlayIndex = SHGetIconOverlayIndexW; + alias SHCreateDirectoryEx = SHCreateDirectoryExW; } static if (_WIN32_WINNT >= 0x501) { - alias SHGetFolderPathAndSubDirW SHGetFolderPathAndSubDir; + alias SHGetFolderPathAndSubDir = SHGetFolderPathAndSubDirW; } - alias FILEDESCRIPTORW FILEDESCRIPTOR; - alias LPFILEDESCRIPTORW LPFILEDESCRIPTOR; - alias FILEGROUPDESCRIPTORW FILEGROUPDESCRIPTOR; - alias LPFILEGROUPDESCRIPTORW LPFILEGROUPDESCRIPTOR; + alias FILEDESCRIPTOR = FILEDESCRIPTORW; + alias LPFILEDESCRIPTOR = LPFILEDESCRIPTORW; + alias FILEGROUPDESCRIPTOR = FILEGROUPDESCRIPTORW; + alias LPFILEGROUPDESCRIPTOR = LPFILEGROUPDESCRIPTORW; } else { - alias IShellExecuteHookA IShellExecuteHook; - alias IShellLinkA IShellLink; - alias BROWSEINFOA BROWSEINFO; - alias SHBrowseForFolderA SHBrowseForFolder; - alias SHGetDataFromIDListA SHGetDataFromIDList; - alias SHGetPathFromIDListA SHGetPathFromIDList; + alias IShellExecuteHook = IShellExecuteHookA; + alias IShellLink = IShellLinkA; + alias BROWSEINFO = BROWSEINFOA; + alias SHBrowseForFolder = SHBrowseForFolderA; + alias SHGetDataFromIDList = SHGetDataFromIDListA; + alias SHGetPathFromIDList = SHGetPathFromIDListA; static if (_WIN32_IE >= 0x400) { - alias SHGetSpecialFolderPathA SHGetSpecialFolderPath; + alias SHGetSpecialFolderPath = SHGetSpecialFolderPathA; } - alias SHGetFolderPathA SHGetFolderPath; + alias SHGetFolderPath = SHGetFolderPathA; static if (_WIN32_WINNT >= 0x500) { - alias SHGetIconOverlayIndexA SHGetIconOverlayIndex; - alias SHCreateDirectoryExA SHCreateDirectoryEx; + alias SHGetIconOverlayIndex = SHGetIconOverlayIndexA; + alias SHCreateDirectoryEx = SHCreateDirectoryExA; } static if (_WIN32_WINNT >= 0x501) { - alias SHGetFolderPathAndSubDirA SHGetFolderPathAndSubDir; + alias SHGetFolderPathAndSubDir = SHGetFolderPathAndSubDirA; } - alias FILEDESCRIPTORA FILEDESCRIPTOR; - alias LPFILEDESCRIPTORA LPFILEDESCRIPTOR; - alias FILEGROUPDESCRIPTORA FILEGROUPDESCRIPTOR; - alias LPFILEGROUPDESCRIPTORA LPFILEGROUPDESCRIPTOR; + alias FILEDESCRIPTOR = FILEDESCRIPTORA; + alias LPFILEDESCRIPTOR = LPFILEDESCRIPTORA; + alias FILEGROUPDESCRIPTOR = FILEGROUPDESCRIPTORA; + alias LPFILEGROUPDESCRIPTOR = LPFILEGROUPDESCRIPTORA; } -alias BROWSEINFO* PBROWSEINFO, LPBROWSEINFO; +alias PBROWSEINFO = BROWSEINFO*, LPBROWSEINFO = BROWSEINFO*; static if (_WIN32_WINNT >= 0x501) { interface IFolderView : IUnknown { @@ -1344,5 +1344,5 @@ static if (_WIN32_WINNT >= 0x501) { HRESULT SelectItem(int, DWORD); HRESULT SetCurrentViewMode(UINT); } - alias IFolderView LPFOLDERVIEW; + alias LPFOLDERVIEW = IFolderView; } diff --git a/runtime/druntime/src/core/sys/windows/shlwapi.d b/runtime/druntime/src/core/sys/windows/shlwapi.d index 3562003a41..d44d6a80f8 100644 --- a/runtime/druntime/src/core/sys/windows/shlwapi.d +++ b/runtime/druntime/src/core/sys/windows/shlwapi.d @@ -91,7 +91,7 @@ enum ASSOCDATA ASSOCDATA_QUERYCLASSSTORE } -alias DWORD ASSOCF; +alias ASSOCF = DWORD; enum SHREGDEL_FLAGS { @@ -121,11 +121,11 @@ enum URLIS } alias HUSKEY = HANDLE; -alias HUSKEY* PHUSKEY; +alias PHUSKEY = HUSKEY*; extern (Windows) { - alias HRESULT function (DLLVERSIONINFO *) DLLGETVERSIONPROC; + alias DLLGETVERSIONPROC = HRESULT function (DLLVERSIONINFO *); } @@ -458,275 +458,275 @@ IStream SHOpenRegStreamA(HKEY, LPCSTR, LPCSTR, DWORD); IStream SHOpenRegStreamW(HKEY, LPCWSTR, LPCWSTR, DWORD); version (Unicode) { -alias ChrCmpIW ChrCmpI; -alias IntlStrEqNW IntlStrEqN; -alias IntlStrEqNIW IntlStrEqNI; -alias IntlStrEqWorkerW IntlStrEqWorker; -alias SHStrDupW SHStrDup; -alias StrCatW StrCat; -alias StrCatBuffW StrCatBuff; -alias StrChrW StrChr; -alias StrChrIW StrChrI; -alias StrCmpW StrCmp; -alias StrCmpIW StrCmpI; -alias StrCmpNIW StrCmpNI; -alias StrCmpNW StrCmpN; -alias StrCpyNW StrCpyN; -alias StrCpyW StrCpy; -alias StrCSpnIW StrCSpnI; -alias StrCSpnW StrCSpn; -alias StrDupW StrDup; -alias StrFormatByteSizeW StrFormatByteSize; -alias StrFormatKBSizeW StrFormatKBSize; -alias StrFromTimeIntervalW StrFromTimeInterval; -alias StrIsIntlEqualW StrIsIntlEqual; -alias StrNCatW StrNCat; -alias StrPBrkW StrPBrk; -alias StrRChrW StrRChr; -alias StrRChrIW StrRChrI; -alias StrRetToBufW StrRetToBuf; -alias StrRetToStrW StrRetToStr; -alias StrRStrIW StrRStrI; -alias StrSpnW StrSpn; -alias StrStrIW StrStrI; -alias StrStrW StrStr; -alias StrToIntW StrToInt; -alias StrToIntExW StrToIntEx; -alias StrTrimW StrTrim; -alias PathAddBackslashW PathAddBackslash; -alias PathAddExtensionW PathAddExtension; -alias PathAppendW PathAppend; -alias PathBuildRootW PathBuildRoot; -alias PathCanonicalizeW PathCanonicalize; -alias PathCombineW PathCombine; -alias PathCommonPrefixW PathCommonPrefix; -alias PathCompactPathW PathCompactPath; -alias PathCompactPathExW PathCompactPathEx; -alias PathCreateFromUrlW PathCreateFromUrl; -alias PathFileExistsW PathFileExists; -alias PathFindExtensionW PathFindExtension; -alias PathFindFileNameW PathFindFileName; -alias PathFindNextComponentW PathFindNextComponent; -alias PathFindOnPathW PathFindOnPath; -alias PathFindSuffixArrayW PathFindSuffixArray; -alias PathGetArgsW PathGetArgs; -alias PathGetCharTypeW PathGetCharType; -alias PathGetDriveNumberW PathGetDriveNumber; -alias PathIsContentTypeW PathIsContentType; -alias PathIsDirectoryEmptyW PathIsDirectoryEmpty; -alias PathIsDirectoryW PathIsDirectory; -alias PathIsFileSpecW PathIsFileSpec; -alias PathIsLFNFileSpecW PathIsLFNFileSpec; -alias PathIsNetworkPathW PathIsNetworkPath; -alias PathIsPrefixW PathIsPrefix; -alias PathIsRelativeW PathIsRelative; -alias PathIsRootW PathIsRoot; -alias PathIsSameRootW PathIsSameRoot; -alias PathIsSystemFolderW PathIsSystemFolder; -alias PathIsUNCServerShareW PathIsUNCServerShare; -alias PathIsUNCServerW PathIsUNCServer; -alias PathIsUNCW PathIsUNC; -alias PathIsURLW PathIsURL; -alias PathMakePrettyW PathMakePretty; -alias PathMakeSystemFolderW PathMakeSystemFolder; -alias PathMatchSpecW PathMatchSpec; -alias PathParseIconLocationW PathParseIconLocation; -alias PathQuoteSpacesW PathQuoteSpaces; -alias PathRelativePathToW PathRelativePathTo; -alias PathRemoveArgsW PathRemoveArgs; -alias PathRemoveBackslashW PathRemoveBackslash; -alias PathRemoveBlanksW PathRemoveBlanks; -alias PathRemoveExtensionW PathRemoveExtension; -alias PathRemoveFileSpecW PathRemoveFileSpec; -alias PathRenameExtensionW PathRenameExtension; -alias PathSearchAndQualifyW PathSearchAndQualify; -alias PathSetDlgItemPathW PathSetDlgItemPath; -alias PathSkipRootW PathSkipRoot; -alias PathStripPathW PathStripPath; -alias PathStripToRootW PathStripToRoot; -alias PathUndecorateW PathUndecorate; -alias PathUnExpandEnvStringsW PathUnExpandEnvStrings; -alias PathUnmakeSystemFolderW PathUnmakeSystemFolder; -alias PathUnquoteSpacesW PathUnquoteSpaces; -alias SHCreateStreamOnFileW SHCreateStreamOnFile; -alias SHOpenRegStreamW SHOpenRegStream; -alias SHOpenRegStream2W SHOpenRegStream2; -alias SHCopyKeyW SHCopyKey; -alias SHDeleteEmptyKeyW SHDeleteEmptyKey; -alias SHDeleteKeyW SHDeleteKey; -alias SHEnumKeyExW SHEnumKeyEx; -alias SHQueryInfoKeyW SHQueryInfoKey; -alias SHQueryValueExW SHQueryValueEx; -alias SHEnumValueW SHEnumValue; -alias SHGetValueW SHGetValue; -alias SHSetValueW SHSetValue; -alias SHDeleteValueW SHDeleteValue; -alias AssocQueryKeyW AssocQueryKey; -alias AssocQueryStringByKeyW AssocQueryStringByKey; -alias AssocQueryStringW AssocQueryString; -alias UrlApplySchemeW UrlApplyScheme; -alias UrlCanonicalizeW UrlCanonicalize; -alias UrlCombineW UrlCombine; -alias UrlCompareW UrlCompare; -alias UrlCreateFromPathW UrlCreateFromPath; -alias UrlEscapeW UrlEscape; -alias UrlGetLocationW UrlGetLocation; -alias UrlGetPartW UrlGetPart; -alias UrlHashW UrlHash; -alias UrlIsW UrlIs; -alias UrlIsFileUrlW UrlIsFileUrl; -alias UrlIsNoHistoryW UrlIsNoHistory; -alias UrlIsOpaqueW UrlIsOpaque; -alias UrlUnescapeW UrlUnescape; -alias UrlUnescapeInPlaceW UrlUnescapeInPlace; -alias SHRegCreateUSKeyW SHRegCreateUSKey; -alias SHRegDeleteEmptyUSKeyW SHRegDeleteEmptyUSKey; -alias SHRegDeleteUSValueW SHRegDeleteUSValue; -alias SHRegEnumUSKeyW SHRegEnumUSKey; -alias SHRegEnumUSValueW SHRegEnumUSValue; -alias SHRegGetBoolUSValueW SHRegGetBoolUSValue; -alias SHRegGetPathW SHRegGetPath; -alias SHRegGetUSValueW SHRegGetUSValue; -alias SHRegOpenUSKeyW SHRegOpenUSKey; -alias SHRegQueryInfoUSKeyW SHRegQueryInfoUSKey; -alias SHRegQueryUSValueW SHRegQueryUSValue; -alias SHRegSetPathW SHRegSetPath; -alias SHRegSetUSValueW SHRegSetUSValue; -alias SHRegWriteUSValueW SHRegWriteUSValue; +alias ChrCmpI = ChrCmpIW; +alias IntlStrEqN = IntlStrEqNW; +alias IntlStrEqNI = IntlStrEqNIW; +alias IntlStrEqWorker = IntlStrEqWorkerW; +alias SHStrDup = SHStrDupW; +alias StrCat = StrCatW; +alias StrCatBuff = StrCatBuffW; +alias StrChr = StrChrW; +alias StrChrI = StrChrIW; +alias StrCmp = StrCmpW; +alias StrCmpI = StrCmpIW; +alias StrCmpNI = StrCmpNIW; +alias StrCmpN = StrCmpNW; +alias StrCpyN = StrCpyNW; +alias StrCpy = StrCpyW; +alias StrCSpnI = StrCSpnIW; +alias StrCSpn = StrCSpnW; +alias StrDup = StrDupW; +alias StrFormatByteSize = StrFormatByteSizeW; +alias StrFormatKBSize = StrFormatKBSizeW; +alias StrFromTimeInterval = StrFromTimeIntervalW; +alias StrIsIntlEqual = StrIsIntlEqualW; +alias StrNCat = StrNCatW; +alias StrPBrk = StrPBrkW; +alias StrRChr = StrRChrW; +alias StrRChrI = StrRChrIW; +alias StrRetToBuf = StrRetToBufW; +alias StrRetToStr = StrRetToStrW; +alias StrRStrI = StrRStrIW; +alias StrSpn = StrSpnW; +alias StrStrI = StrStrIW; +alias StrStr = StrStrW; +alias StrToInt = StrToIntW; +alias StrToIntEx = StrToIntExW; +alias StrTrim = StrTrimW; +alias PathAddBackslash = PathAddBackslashW; +alias PathAddExtension = PathAddExtensionW; +alias PathAppend = PathAppendW; +alias PathBuildRoot = PathBuildRootW; +alias PathCanonicalize = PathCanonicalizeW; +alias PathCombine = PathCombineW; +alias PathCommonPrefix = PathCommonPrefixW; +alias PathCompactPath = PathCompactPathW; +alias PathCompactPathEx = PathCompactPathExW; +alias PathCreateFromUrl = PathCreateFromUrlW; +alias PathFileExists = PathFileExistsW; +alias PathFindExtension = PathFindExtensionW; +alias PathFindFileName = PathFindFileNameW; +alias PathFindNextComponent = PathFindNextComponentW; +alias PathFindOnPath = PathFindOnPathW; +alias PathFindSuffixArray = PathFindSuffixArrayW; +alias PathGetArgs = PathGetArgsW; +alias PathGetCharType = PathGetCharTypeW; +alias PathGetDriveNumber = PathGetDriveNumberW; +alias PathIsContentType = PathIsContentTypeW; +alias PathIsDirectoryEmpty = PathIsDirectoryEmptyW; +alias PathIsDirectory = PathIsDirectoryW; +alias PathIsFileSpec = PathIsFileSpecW; +alias PathIsLFNFileSpec = PathIsLFNFileSpecW; +alias PathIsNetworkPath = PathIsNetworkPathW; +alias PathIsPrefix = PathIsPrefixW; +alias PathIsRelative = PathIsRelativeW; +alias PathIsRoot = PathIsRootW; +alias PathIsSameRoot = PathIsSameRootW; +alias PathIsSystemFolder = PathIsSystemFolderW; +alias PathIsUNCServerShare = PathIsUNCServerShareW; +alias PathIsUNCServer = PathIsUNCServerW; +alias PathIsUNC = PathIsUNCW; +alias PathIsURL = PathIsURLW; +alias PathMakePretty = PathMakePrettyW; +alias PathMakeSystemFolder = PathMakeSystemFolderW; +alias PathMatchSpec = PathMatchSpecW; +alias PathParseIconLocation = PathParseIconLocationW; +alias PathQuoteSpaces = PathQuoteSpacesW; +alias PathRelativePathTo = PathRelativePathToW; +alias PathRemoveArgs = PathRemoveArgsW; +alias PathRemoveBackslash = PathRemoveBackslashW; +alias PathRemoveBlanks = PathRemoveBlanksW; +alias PathRemoveExtension = PathRemoveExtensionW; +alias PathRemoveFileSpec = PathRemoveFileSpecW; +alias PathRenameExtension = PathRenameExtensionW; +alias PathSearchAndQualify = PathSearchAndQualifyW; +alias PathSetDlgItemPath = PathSetDlgItemPathW; +alias PathSkipRoot = PathSkipRootW; +alias PathStripPath = PathStripPathW; +alias PathStripToRoot = PathStripToRootW; +alias PathUndecorate = PathUndecorateW; +alias PathUnExpandEnvStrings = PathUnExpandEnvStringsW; +alias PathUnmakeSystemFolder = PathUnmakeSystemFolderW; +alias PathUnquoteSpaces = PathUnquoteSpacesW; +alias SHCreateStreamOnFile = SHCreateStreamOnFileW; +alias SHOpenRegStream = SHOpenRegStreamW; +alias SHOpenRegStream2 = SHOpenRegStream2W; +alias SHCopyKey = SHCopyKeyW; +alias SHDeleteEmptyKey = SHDeleteEmptyKeyW; +alias SHDeleteKey = SHDeleteKeyW; +alias SHEnumKeyEx = SHEnumKeyExW; +alias SHQueryInfoKey = SHQueryInfoKeyW; +alias SHQueryValueEx = SHQueryValueExW; +alias SHEnumValue = SHEnumValueW; +alias SHGetValue = SHGetValueW; +alias SHSetValue = SHSetValueW; +alias SHDeleteValue = SHDeleteValueW; +alias AssocQueryKey = AssocQueryKeyW; +alias AssocQueryStringByKey = AssocQueryStringByKeyW; +alias AssocQueryString = AssocQueryStringW; +alias UrlApplyScheme = UrlApplySchemeW; +alias UrlCanonicalize = UrlCanonicalizeW; +alias UrlCombine = UrlCombineW; +alias UrlCompare = UrlCompareW; +alias UrlCreateFromPath = UrlCreateFromPathW; +alias UrlEscape = UrlEscapeW; +alias UrlGetLocation = UrlGetLocationW; +alias UrlGetPart = UrlGetPartW; +alias UrlHash = UrlHashW; +alias UrlIs = UrlIsW; +alias UrlIsFileUrl = UrlIsFileUrlW; +alias UrlIsNoHistory = UrlIsNoHistoryW; +alias UrlIsOpaque = UrlIsOpaqueW; +alias UrlUnescape = UrlUnescapeW; +alias UrlUnescapeInPlace = UrlUnescapeInPlaceW; +alias SHRegCreateUSKey = SHRegCreateUSKeyW; +alias SHRegDeleteEmptyUSKey = SHRegDeleteEmptyUSKeyW; +alias SHRegDeleteUSValue = SHRegDeleteUSValueW; +alias SHRegEnumUSKey = SHRegEnumUSKeyW; +alias SHRegEnumUSValue = SHRegEnumUSValueW; +alias SHRegGetBoolUSValue = SHRegGetBoolUSValueW; +alias SHRegGetPath = SHRegGetPathW; +alias SHRegGetUSValue = SHRegGetUSValueW; +alias SHRegOpenUSKey = SHRegOpenUSKeyW; +alias SHRegQueryInfoUSKey = SHRegQueryInfoUSKeyW; +alias SHRegQueryUSValue = SHRegQueryUSValueW; +alias SHRegSetPath = SHRegSetPathW; +alias SHRegSetUSValue = SHRegSetUSValueW; +alias SHRegWriteUSValue = SHRegWriteUSValueW; //alias wnsprintfW wnsprintf; //alias wvnsprintfW wvnsprintf; } else { -alias ChrCmpIA ChrCmpI; -alias IntlStrEqNA IntlStrEqN; -alias IntlStrEqNIA IntlStrEqNI; -alias IntlStrEqWorkerA IntlStrEqWorker; -alias SHStrDupA SHStrDup; -alias StrCatBuffA StrCatBuff; -alias StrChrA StrChr; -alias StrChrIA StrChrI; -alias StrCmpNIA StrCmpNI; -alias StrCmpNA StrCmpN; -alias StrCSpnIA StrCSpnI; -alias StrCSpnA StrCSpn; -alias StrDupA StrDup; -alias StrFormatByteSizeA StrFormatByteSize; -alias StrFormatKBSizeA StrFormatKBSize; -alias StrFromTimeIntervalA StrFromTimeInterval; -alias StrIsIntlEqualA StrIsIntlEqual; -alias StrNCatA StrNCat; -alias StrPBrkA StrPBrk; -alias StrRChrA StrRChr; -alias StrRChrIA StrRChrI; -alias StrRetToBufA StrRetToBuf; -alias StrRetToStrA StrRetToStr; -alias StrRStrIA StrRStrI; -alias StrSpnA StrSpn; -alias StrStrIA StrStrI; -alias StrStrA StrStr; -alias StrToIntA StrToInt; -alias StrToIntExA StrToIntEx; -alias StrTrimA StrTrim; -alias PathAddBackslashA PathAddBackslash; -alias PathAddExtensionA PathAddExtension; -alias PathAppendA PathAppend; -alias PathBuildRootA PathBuildRoot; -alias PathCanonicalizeA PathCanonicalize; -alias PathCombineA PathCombine; -alias PathCommonPrefixA PathCommonPrefix; -alias PathCompactPathA PathCompactPath; -alias PathCompactPathExA PathCompactPathEx; -alias PathCreateFromUrlA PathCreateFromUrl; -alias PathFileExistsA PathFileExists; -alias PathFindExtensionA PathFindExtension; -alias PathFindFileNameA PathFindFileName; -alias PathFindNextComponentA PathFindNextComponent; -alias PathFindOnPathA PathFindOnPath; -alias PathFindSuffixArrayA PathFindSuffixArray; -alias PathGetArgsA PathGetArgs; -alias PathGetCharTypeA PathGetCharType; -alias PathGetDriveNumberA PathGetDriveNumber; -alias PathIsContentTypeA PathIsContentType; -alias PathIsDirectoryEmptyA PathIsDirectoryEmpty; -alias PathIsDirectoryA PathIsDirectory; -alias PathIsFileSpecA PathIsFileSpec; -alias PathIsLFNFileSpecA PathIsLFNFileSpec; -alias PathIsNetworkPathA PathIsNetworkPath; -alias PathIsPrefixA PathIsPrefix; -alias PathIsRelativeA PathIsRelative; -alias PathIsRootA PathIsRoot; -alias PathIsSameRootA PathIsSameRoot; -alias PathIsSystemFolderA PathIsSystemFolder; -alias PathIsUNCServerShareA PathIsUNCServerShare; -alias PathIsUNCServerA PathIsUNCServer; -alias PathIsUNCA PathIsUNC; -alias PathIsURLA PathIsURL; -alias PathMakePrettyA PathMakePretty; -alias PathMakeSystemFolderA PathMakeSystemFolder; -alias PathMatchSpecA PathMatchSpec; -alias PathParseIconLocationA PathParseIconLocation; -alias PathQuoteSpacesA PathQuoteSpaces; -alias PathRelativePathToA PathRelativePathTo; -alias PathRemoveArgsA PathRemoveArgs; -alias PathRemoveBackslashA PathRemoveBackslash; -alias PathRemoveBlanksA PathRemoveBlanks; -alias PathRemoveExtensionA PathRemoveExtension; -alias PathRemoveFileSpecA PathRemoveFileSpec; -alias PathRenameExtensionA PathRenameExtension; -alias PathSearchAndQualifyA PathSearchAndQualify; -alias PathSetDlgItemPathA PathSetDlgItemPath; -alias PathSkipRootA PathSkipRoot; -alias PathStripPathA PathStripPath; -alias PathStripToRootA PathStripToRoot; -alias PathUndecorateA PathUndecorate; -alias PathUnExpandEnvStringsA PathUnExpandEnvStrings; -alias PathUnmakeSystemFolderA PathUnmakeSystemFolder; -alias PathUnquoteSpacesA PathUnquoteSpaces; -alias SHCreateStreamOnFileA SHCreateStreamOnFile; -alias SHOpenRegStreamA SHOpenRegStream; -alias SHOpenRegStream2A SHOpenRegStream2; -alias SHCopyKeyA SHCopyKey; -alias SHDeleteEmptyKeyA SHDeleteEmptyKey; -alias SHDeleteKeyA SHDeleteKey; -alias SHEnumKeyExA SHEnumKeyEx; -alias SHQueryInfoKeyA SHQueryInfoKey; -alias SHQueryValueExA SHQueryValueEx; -alias SHEnumValueA SHEnumValue; -alias SHGetValueA SHGetValue; -alias SHSetValueA SHSetValue; -alias SHDeleteValueA SHDeleteValue; -alias AssocQueryKeyA AssocQueryKey; -alias AssocQueryStringByKeyA AssocQueryStringByKey; -alias AssocQueryStringA AssocQueryString; -alias UrlApplySchemeA UrlApplyScheme; -alias UrlCanonicalizeA UrlCanonicalize; -alias UrlCombineA UrlCombine; -alias UrlCompareA UrlCompare; -alias UrlCreateFromPathA UrlCreateFromPath; -alias UrlEscapeA UrlEscape; -alias UrlGetLocationA UrlGetLocation; -alias UrlGetPartA UrlGetPart; -alias UrlHashA UrlHash; -alias UrlIsA UrlIs; -alias UrlIsNoHistoryA UrlIsNoHistory; -alias UrlIsOpaqueA UrlIsOpaque; -alias UrlUnescapeA UrlUnescape; -alias UrlUnescapeInPlaceA UrlUnescapeInPlace; -alias SHRegCreateUSKeyA SHRegCreateUSKey; -alias SHRegDeleteEmptyUSKeyA SHRegDeleteEmptyUSKey; -alias SHRegDeleteUSValueA SHRegDeleteUSValue; -alias SHRegEnumUSKeyA SHRegEnumUSKey; -alias SHRegEnumUSValueA SHRegEnumUSValue; -alias SHRegGetBoolUSValueA SHRegGetBoolUSValue; -alias SHRegGetPathA SHRegGetPath; -alias SHRegGetUSValueA SHRegGetUSValue; -alias SHRegOpenUSKeyA SHRegOpenUSKey; -alias SHRegQueryInfoUSKeyA SHRegQueryInfoUSKey; -alias SHRegQueryUSValueA SHRegQueryUSValue; -alias SHRegSetPathA SHRegSetPath; -alias SHRegSetUSValueA SHRegSetUSValue; -alias SHRegWriteUSValueA SHRegWriteUSValue; +alias ChrCmpI = ChrCmpIA; +alias IntlStrEqN = IntlStrEqNA; +alias IntlStrEqNI = IntlStrEqNIA; +alias IntlStrEqWorker = IntlStrEqWorkerA; +alias SHStrDup = SHStrDupA; +alias StrCatBuff = StrCatBuffA; +alias StrChr = StrChrA; +alias StrChrI = StrChrIA; +alias StrCmpNI = StrCmpNIA; +alias StrCmpN = StrCmpNA; +alias StrCSpnI = StrCSpnIA; +alias StrCSpn = StrCSpnA; +alias StrDup = StrDupA; +alias StrFormatByteSize = StrFormatByteSizeA; +alias StrFormatKBSize = StrFormatKBSizeA; +alias StrFromTimeInterval = StrFromTimeIntervalA; +alias StrIsIntlEqual = StrIsIntlEqualA; +alias StrNCat = StrNCatA; +alias StrPBrk = StrPBrkA; +alias StrRChr = StrRChrA; +alias StrRChrI = StrRChrIA; +alias StrRetToBuf = StrRetToBufA; +alias StrRetToStr = StrRetToStrA; +alias StrRStrI = StrRStrIA; +alias StrSpn = StrSpnA; +alias StrStrI = StrStrIA; +alias StrStr = StrStrA; +alias StrToInt = StrToIntA; +alias StrToIntEx = StrToIntExA; +alias StrTrim = StrTrimA; +alias PathAddBackslash = PathAddBackslashA; +alias PathAddExtension = PathAddExtensionA; +alias PathAppend = PathAppendA; +alias PathBuildRoot = PathBuildRootA; +alias PathCanonicalize = PathCanonicalizeA; +alias PathCombine = PathCombineA; +alias PathCommonPrefix = PathCommonPrefixA; +alias PathCompactPath = PathCompactPathA; +alias PathCompactPathEx = PathCompactPathExA; +alias PathCreateFromUrl = PathCreateFromUrlA; +alias PathFileExists = PathFileExistsA; +alias PathFindExtension = PathFindExtensionA; +alias PathFindFileName = PathFindFileNameA; +alias PathFindNextComponent = PathFindNextComponentA; +alias PathFindOnPath = PathFindOnPathA; +alias PathFindSuffixArray = PathFindSuffixArrayA; +alias PathGetArgs = PathGetArgsA; +alias PathGetCharType = PathGetCharTypeA; +alias PathGetDriveNumber = PathGetDriveNumberA; +alias PathIsContentType = PathIsContentTypeA; +alias PathIsDirectoryEmpty = PathIsDirectoryEmptyA; +alias PathIsDirectory = PathIsDirectoryA; +alias PathIsFileSpec = PathIsFileSpecA; +alias PathIsLFNFileSpec = PathIsLFNFileSpecA; +alias PathIsNetworkPath = PathIsNetworkPathA; +alias PathIsPrefix = PathIsPrefixA; +alias PathIsRelative = PathIsRelativeA; +alias PathIsRoot = PathIsRootA; +alias PathIsSameRoot = PathIsSameRootA; +alias PathIsSystemFolder = PathIsSystemFolderA; +alias PathIsUNCServerShare = PathIsUNCServerShareA; +alias PathIsUNCServer = PathIsUNCServerA; +alias PathIsUNC = PathIsUNCA; +alias PathIsURL = PathIsURLA; +alias PathMakePretty = PathMakePrettyA; +alias PathMakeSystemFolder = PathMakeSystemFolderA; +alias PathMatchSpec = PathMatchSpecA; +alias PathParseIconLocation = PathParseIconLocationA; +alias PathQuoteSpaces = PathQuoteSpacesA; +alias PathRelativePathTo = PathRelativePathToA; +alias PathRemoveArgs = PathRemoveArgsA; +alias PathRemoveBackslash = PathRemoveBackslashA; +alias PathRemoveBlanks = PathRemoveBlanksA; +alias PathRemoveExtension = PathRemoveExtensionA; +alias PathRemoveFileSpec = PathRemoveFileSpecA; +alias PathRenameExtension = PathRenameExtensionA; +alias PathSearchAndQualify = PathSearchAndQualifyA; +alias PathSetDlgItemPath = PathSetDlgItemPathA; +alias PathSkipRoot = PathSkipRootA; +alias PathStripPath = PathStripPathA; +alias PathStripToRoot = PathStripToRootA; +alias PathUndecorate = PathUndecorateA; +alias PathUnExpandEnvStrings = PathUnExpandEnvStringsA; +alias PathUnmakeSystemFolder = PathUnmakeSystemFolderA; +alias PathUnquoteSpaces = PathUnquoteSpacesA; +alias SHCreateStreamOnFile = SHCreateStreamOnFileA; +alias SHOpenRegStream = SHOpenRegStreamA; +alias SHOpenRegStream2 = SHOpenRegStream2A; +alias SHCopyKey = SHCopyKeyA; +alias SHDeleteEmptyKey = SHDeleteEmptyKeyA; +alias SHDeleteKey = SHDeleteKeyA; +alias SHEnumKeyEx = SHEnumKeyExA; +alias SHQueryInfoKey = SHQueryInfoKeyA; +alias SHQueryValueEx = SHQueryValueExA; +alias SHEnumValue = SHEnumValueA; +alias SHGetValue = SHGetValueA; +alias SHSetValue = SHSetValueA; +alias SHDeleteValue = SHDeleteValueA; +alias AssocQueryKey = AssocQueryKeyA; +alias AssocQueryStringByKey = AssocQueryStringByKeyA; +alias AssocQueryString = AssocQueryStringA; +alias UrlApplyScheme = UrlApplySchemeA; +alias UrlCanonicalize = UrlCanonicalizeA; +alias UrlCombine = UrlCombineA; +alias UrlCompare = UrlCompareA; +alias UrlCreateFromPath = UrlCreateFromPathA; +alias UrlEscape = UrlEscapeA; +alias UrlGetLocation = UrlGetLocationA; +alias UrlGetPart = UrlGetPartA; +alias UrlHash = UrlHashA; +alias UrlIs = UrlIsA; +alias UrlIsNoHistory = UrlIsNoHistoryA; +alias UrlIsOpaque = UrlIsOpaqueA; +alias UrlUnescape = UrlUnescapeA; +alias UrlUnescapeInPlace = UrlUnescapeInPlaceA; +alias SHRegCreateUSKey = SHRegCreateUSKeyA; +alias SHRegDeleteEmptyUSKey = SHRegDeleteEmptyUSKeyA; +alias SHRegDeleteUSValue = SHRegDeleteUSValueA; +alias SHRegEnumUSKey = SHRegEnumUSKeyA; +alias SHRegEnumUSValue = SHRegEnumUSValueA; +alias SHRegGetBoolUSValue = SHRegGetBoolUSValueA; +alias SHRegGetPath = SHRegGetPathA; +alias SHRegGetUSValue = SHRegGetUSValueA; +alias SHRegOpenUSKey = SHRegOpenUSKeyA; +alias SHRegQueryInfoUSKey = SHRegQueryInfoUSKeyA; +alias SHRegQueryUSValue = SHRegQueryUSValueA; +alias SHRegSetPath = SHRegSetPathA; +alias SHRegSetUSValue = SHRegSetUSValueA; +alias SHRegWriteUSValue = SHRegWriteUSValueA; //alias wnsprintfA wnsprintf; //alias wvnsprintfA wvnsprintf; } -alias StrToInt StrToLong; +alias StrToLong = StrToInt; diff --git a/runtime/druntime/src/core/sys/windows/snmp.d b/runtime/druntime/src/core/sys/windows/snmp.d index 62c81e1357..9f7ae54544 100644 --- a/runtime/druntime/src/core/sys/windows/snmp.d +++ b/runtime/druntime/src/core/sys/windows/snmp.d @@ -145,10 +145,10 @@ enum : DWORD { SNMP_AUTHAPI_TRIV_AUTH_FAILED, } -alias INT SNMPAPI; -alias LONG AsnInteger32; -alias ULONG AsnUnsigned32, AsnCounter32, AsnGauge32, AsnTimeticks; -alias ULARGE_INTEGER AsnCounter64; +alias SNMPAPI = INT; +alias AsnInteger32 = LONG; +alias AsnUnsigned32 = ULONG, AsnCounter32 = ULONG, AsnGauge32 = ULONG, AsnTimeticks = ULONG; +alias AsnCounter64 = ULARGE_INTEGER; align (4): @@ -158,15 +158,14 @@ align (4): UINT length; BOOL dynamic; } -alias AsnOctetString AsnBits, AsnSequence, AsnImplicitSequence, - AsnIPAddress, AsnNetworkAddress, AsnDisplayString, AsnOpaque; +alias AsnBits = AsnOctetString, AsnSequence = AsnOctetString, AsnImplicitSequence = AsnOctetString, AsnIPAddress = AsnOctetString, AsnNetworkAddress = AsnOctetString, AsnDisplayString = AsnOctetString, AsnOpaque = AsnOctetString; struct AsnObjectIdentifier { align (4): UINT idLength; UINT* ids; } -alias AsnObjectIdentifier AsnObjectName; +alias AsnObjectName = AsnObjectIdentifier; struct AsnAny { align (4): @@ -187,7 +186,7 @@ align (4): } _asnValue asnValue; } -alias AsnAny AsnObjectSyntax; +alias AsnObjectSyntax = AsnAny; struct SnmpVarBind { align (4): @@ -240,37 +239,37 @@ extern (Windows) { VOID SnmpUtilVarBindListFree(SnmpVarBindList*); } -alias SnmpUtilMemAlloc SNMP_malloc; -alias SnmpUtilMemFree SNMP_free; -alias SnmpUtilMemReAlloc SNMP_realloc; -alias SnmpUtilMemAlloc SNMP_DBG_malloc; -alias SnmpUtilMemFree SNMP_DBG_free; -alias SnmpUtilMemReAlloc SNMP_DBG_realloc; -alias SnmpUtilOidAppend SNMP_oidappend; -alias SnmpUtilOidCmp SNMP_oidcmp; -alias SnmpUtilOidCpy SNMP_oidcpy; -alias SnmpUtilOidFree SNMP_oidfree; -alias SnmpUtilOidNCmp SNMP_oidncmp; -alias SnmpUtilPrintAsnAny SNMP_printany; -alias SnmpUtilVarBindCpy SNMP_CopyVarBind; -alias SnmpUtilVarBindListCpy SNMP_CopyVarBindList; -alias SnmpUtilVarBindFree SNMP_FreeVarBind; -alias SnmpUtilVarBindListFree SNMP_FreeVarBindList; -alias ASN_IPADDRESS ASN_RFC1155_IPADDRESS; -alias ASN_COUNTER32 ASN_RFC1155_COUNTER; -alias ASN_GAUGE32 ASN_RFC1155_GAUGE; -alias ASN_TIMETICKS ASN_RFC1155_TIMETICKS; -alias ASN_OPAQUE ASN_RFC1155_OPAQUE; -alias ASN_OCTETSTRING ASN_RFC1213_DISPSTRING; -alias SNMP_PDU_GET ASN_RFC1157_GETREQUEST; -alias SNMP_PDU_GETNEXT ASN_RFC1157_GETNEXTREQUEST; -alias SNMP_PDU_RESPONSE ASN_RFC1157_GETRESPONSE; -alias SNMP_PDU_SET ASN_RFC1157_SETREQUEST; -alias SNMP_PDU_V1TRAP ASN_RFC1157_TRAP; -alias ASN_CONTEXT ASN_CONTEXTSPECIFIC; -alias ASN_PRIMITIVE ASN_PRIMATIVE; -alias SnmpVarBindList RFC1157VarBindList; -alias SnmpVarBind RFC1157VarBind; -alias AsnInteger32 AsnInteger; -alias AsnCounter32 AsnCounter; -alias AsnGauge32 AsnGauge; +alias SNMP_malloc = SnmpUtilMemAlloc; +alias SNMP_free = SnmpUtilMemFree; +alias SNMP_realloc = SnmpUtilMemReAlloc; +alias SNMP_DBG_malloc = SnmpUtilMemAlloc; +alias SNMP_DBG_free = SnmpUtilMemFree; +alias SNMP_DBG_realloc = SnmpUtilMemReAlloc; +alias SNMP_oidappend = SnmpUtilOidAppend; +alias SNMP_oidcmp = SnmpUtilOidCmp; +alias SNMP_oidcpy = SnmpUtilOidCpy; +alias SNMP_oidfree = SnmpUtilOidFree; +alias SNMP_oidncmp = SnmpUtilOidNCmp; +alias SNMP_printany = SnmpUtilPrintAsnAny; +alias SNMP_CopyVarBind = SnmpUtilVarBindCpy; +alias SNMP_CopyVarBindList = SnmpUtilVarBindListCpy; +alias SNMP_FreeVarBind = SnmpUtilVarBindFree; +alias SNMP_FreeVarBindList = SnmpUtilVarBindListFree; +alias ASN_RFC1155_IPADDRESS = ASN_IPADDRESS; +alias ASN_RFC1155_COUNTER = ASN_COUNTER32; +alias ASN_RFC1155_GAUGE = ASN_GAUGE32; +alias ASN_RFC1155_TIMETICKS = ASN_TIMETICKS; +alias ASN_RFC1155_OPAQUE = ASN_OPAQUE; +alias ASN_RFC1213_DISPSTRING = ASN_OCTETSTRING; +alias ASN_RFC1157_GETREQUEST = SNMP_PDU_GET; +alias ASN_RFC1157_GETNEXTREQUEST = SNMP_PDU_GETNEXT; +alias ASN_RFC1157_GETRESPONSE = SNMP_PDU_RESPONSE; +alias ASN_RFC1157_SETREQUEST = SNMP_PDU_SET; +alias ASN_RFC1157_TRAP = SNMP_PDU_V1TRAP; +alias ASN_CONTEXTSPECIFIC = ASN_CONTEXT; +alias ASN_PRIMATIVE = ASN_PRIMITIVE; +alias RFC1157VarBindList = SnmpVarBindList; +alias RFC1157VarBind = SnmpVarBind; +alias AsnInteger = AsnInteger32; +alias AsnCounter = AsnCounter32; +alias AsnGauge = AsnGauge32; diff --git a/runtime/druntime/src/core/sys/windows/sqltypes.d b/runtime/druntime/src/core/sys/windows/sqltypes.d index ca91f01585..81741eec0d 100644 --- a/runtime/druntime/src/core/sys/windows/sqltypes.d +++ b/runtime/druntime/src/core/sys/windows/sqltypes.d @@ -22,22 +22,22 @@ version (ANSI) {} else version = Unicode; import core.sys.windows.windef; import core.sys.windows.basetyps; // for GUID -alias byte SCHAR, SQLSCHAR; -alias int SDWORD, SLONG, SQLINTEGER; -alias short SWORD, SSHORT, RETCODE, SQLSMALLINT; -alias ULONG UDWORD; -alias USHORT UWORD, SQLUSMALLINT; -alias double SDOUBLE, LDOUBLE; -alias float SFLOAT; -alias PVOID PTR, HENV, HDBC, HSTMT, SQLPOINTER; -alias UCHAR SQLCHAR; +alias SCHAR = byte, SQLSCHAR = byte; +alias SDWORD = int, SLONG = int, SQLINTEGER = int; +alias SWORD = short, SSHORT = short, RETCODE = short, SQLSMALLINT = short; +alias UDWORD = ULONG; +alias UWORD = USHORT, SQLUSMALLINT = USHORT; +alias SDOUBLE = double, LDOUBLE = double; +alias SFLOAT = float; +alias PTR = PVOID, HENV = PVOID, HDBC = PVOID, HSTMT = PVOID, SQLPOINTER = PVOID; +alias SQLCHAR = UCHAR; // #ifndef _WIN64 -alias UDWORD SQLUINTEGER; +alias SQLUINTEGER = UDWORD; // #endif //static if (ODBCVER >= 0x0300) { -alias HANDLE SQLHANDLE; -alias SQLHANDLE SQLHENV, SQLHDBC, SQLHSTMT, SQLHDESC; +alias SQLHANDLE = HANDLE; +alias SQLHENV = SQLHANDLE, SQLHDBC = SQLHANDLE, SQLHSTMT = SQLHANDLE, SQLHDESC = SQLHANDLE; /* } else { alias void* SQLHENV; @@ -45,29 +45,29 @@ alias void* SQLHDBC; alias void* SQLHSTMT; } */ -alias SQLSMALLINT SQLRETURN; -alias HWND SQLHWND; -alias ULONG BOOKMARK; +alias SQLRETURN = SQLSMALLINT; +alias SQLHWND = HWND; +alias BOOKMARK = ULONG; -alias SQLINTEGER SQLLEN, SQLROWOFFSET; -alias SQLUINTEGER SQLROWCOUNT, SQLULEN; -alias DWORD SQLTRANSID; -alias SQLUSMALLINT SQLSETPOSIROW; -alias wchar SQLWCHAR; +alias SQLLEN = SQLINTEGER, SQLROWOFFSET = SQLINTEGER; +alias SQLROWCOUNT = SQLUINTEGER, SQLULEN = SQLUINTEGER; +alias SQLTRANSID = DWORD; +alias SQLSETPOSIROW = SQLUSMALLINT; +alias SQLWCHAR = wchar; version (Unicode) { - alias SQLWCHAR SQLTCHAR; + alias SQLTCHAR = SQLWCHAR; } else { - alias SQLCHAR SQLTCHAR; + alias SQLTCHAR = SQLCHAR; } //static if (ODBCVER >= 0x0300) { -alias ubyte SQLDATE, SQLDECIMAL; -alias double SQLDOUBLE, SQLFLOAT; -alias ubyte SQLNUMERIC; -alias float SQLREAL; -alias ubyte SQLTIME, SQLTIMESTAMP, SQLVARCHAR; -alias long ODBCINT64, SQLBIGINT; -alias ulong SQLUBIGINT; +alias SQLDATE = ubyte, SQLDECIMAL = ubyte; +alias SQLDOUBLE = double, SQLFLOAT = double; +alias SQLNUMERIC = ubyte; +alias SQLREAL = float; +alias SQLTIME = ubyte, SQLTIMESTAMP = ubyte, SQLVARCHAR = ubyte; +alias ODBCINT64 = long, SQLBIGINT = long; +alias SQLUBIGINT = ulong; //} //Everything above this line may by used by odbcinst.d @@ -97,9 +97,9 @@ struct TIMESTAMP_STRUCT { } //static if (ODBCVER >= 0x0300) { -alias DATE_STRUCT SQL_DATE_STRUCT; -alias TIME_STRUCT SQL_TIME_STRUCT; -alias TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT; +alias SQL_DATE_STRUCT = DATE_STRUCT; +alias SQL_TIME_STRUCT = TIME_STRUCT; +alias SQL_TIMESTAMP_STRUCT = TIMESTAMP_STRUCT; enum SQLINTERVAL { SQL_IS_YEAR = 1, @@ -149,4 +149,4 @@ struct SQL_NUMERIC_STRUCT { SQLCHAR[SQL_MAX_NUMERIC_LEN] val; } // } ODBCVER >= 0x0300 -alias GUID SQLGUID; +alias SQLGUID = GUID; diff --git a/runtime/druntime/src/core/sys/windows/sqlucode.d b/runtime/druntime/src/core/sys/windows/sqlucode.d index d20952d5b4..b42b2838a3 100644 --- a/runtime/druntime/src/core/sys/windows/sqlucode.d +++ b/runtime/druntime/src/core/sys/windows/sqlucode.d @@ -123,41 +123,41 @@ extern (Windows) { } version (Unicode) { - alias SQLBrowseConnectW SQLBrowseConnect; - alias SQLColAttributeW SQLColAttribute; - alias SQLColAttributesW SQLColAttributes; - alias SQLColumnPrivilegesW SQLColumnPrivileges; - alias SQLColumnsW SQLColumns; - alias SQLConnectW SQLConnect; - alias SQLDataSourcesW SQLDataSources; - alias SQLDescribeColW SQLDescribeCol; - alias SQLDriverConnectW SQLDriverConnect; - alias SQLDriversW SQLDrivers; - alias SQLErrorW SQLError; - alias SQLExecDirectW SQLExecDirect; - alias SQLForeignKeysW SQLForeignKeys; - alias SQLGetConnectAttrW SQLGetConnectAttr; - alias SQLGetConnectOptionW SQLGetConnectOption; - alias SQLGetCursorNameW SQLGetCursorName; - alias SQLGetDescFieldW SQLGetDescField; - alias SQLGetDescRecW SQLGetDescRec; - alias SQLGetDiagFieldW SQLGetDiagField; - alias SQLGetDiagRecW SQLGetDiagRec; - alias SQLGetInfoW SQLGetInfo; - alias SQLGetStmtAttrW SQLGetStmtAttr; - alias SQLGetTypeInfoW SQLGetTypeInfo; - alias SQLNativeSqlW SQLNativeSql; - alias SQLPrepareW SQLPrepare; - alias SQLPrimaryKeysW SQLPrimaryKeys; - alias SQLProcedureColumnsW SQLProcedureColumns; - alias SQLProceduresW SQLProcedures; - alias SQLSetConnectAttrW SQLSetConnectAttr; - alias SQLSetConnectOptionW SQLSetConnectOption; - alias SQLSetCursorNameW SQLSetCursorName; - alias SQLSetDescFieldW SQLSetDescField; - alias SQLSetStmtAttrW SQLSetStmtAttr; - alias SQLSpecialColumnsW SQLSpecialColumns; - alias SQLStatisticsW SQLStatistics; - alias SQLTablePrivilegesW SQLTablePrivileges; - alias SQLTablesW SQLTables; + alias SQLBrowseConnect = SQLBrowseConnectW; + alias SQLColAttribute = SQLColAttributeW; + alias SQLColAttributes = SQLColAttributesW; + alias SQLColumnPrivileges = SQLColumnPrivilegesW; + alias SQLColumns = SQLColumnsW; + alias SQLConnect = SQLConnectW; + alias SQLDataSources = SQLDataSourcesW; + alias SQLDescribeCol = SQLDescribeColW; + alias SQLDriverConnect = SQLDriverConnectW; + alias SQLDrivers = SQLDriversW; + alias SQLError = SQLErrorW; + alias SQLExecDirect = SQLExecDirectW; + alias SQLForeignKeys = SQLForeignKeysW; + alias SQLGetConnectAttr = SQLGetConnectAttrW; + alias SQLGetConnectOption = SQLGetConnectOptionW; + alias SQLGetCursorName = SQLGetCursorNameW; + alias SQLGetDescField = SQLGetDescFieldW; + alias SQLGetDescRec = SQLGetDescRecW; + alias SQLGetDiagField = SQLGetDiagFieldW; + alias SQLGetDiagRec = SQLGetDiagRecW; + alias SQLGetInfo = SQLGetInfoW; + alias SQLGetStmtAttr = SQLGetStmtAttrW; + alias SQLGetTypeInfo = SQLGetTypeInfoW; + alias SQLNativeSql = SQLNativeSqlW; + alias SQLPrepare = SQLPrepareW; + alias SQLPrimaryKeys = SQLPrimaryKeysW; + alias SQLProcedureColumns = SQLProcedureColumnsW; + alias SQLProcedures = SQLProceduresW; + alias SQLSetConnectAttr = SQLSetConnectAttrW; + alias SQLSetConnectOption = SQLSetConnectOptionW; + alias SQLSetCursorName = SQLSetCursorNameW; + alias SQLSetDescField = SQLSetDescFieldW; + alias SQLSetStmtAttr = SQLSetStmtAttrW; + alias SQLSpecialColumns = SQLSpecialColumnsW; + alias SQLStatistics = SQLStatisticsW; + alias SQLTablePrivileges = SQLTablePrivilegesW; + alias SQLTables = SQLTablesW; } diff --git a/runtime/druntime/src/core/sys/windows/sspi.d b/runtime/druntime/src/core/sys/windows/sspi.d index 3686c6f96f..81cd6c5ea5 100644 --- a/runtime/druntime/src/core/sys/windows/sspi.d +++ b/runtime/druntime/src/core/sys/windows/sspi.d @@ -76,8 +76,8 @@ enum UNISP_NAME_A = "Microsoft Unified Security Protocol Provider"; enum UNISP_NAME_W = "Microsoft Unified Security Protocol Provider"w; enum SECBUFFER_VERSION = 0; -alias UNICODE_STRING SECURITY_STRING; -alias UNICODE_STRING* PSECURITY_STRING; +alias SECURITY_STRING = UNICODE_STRING; +alias PSECURITY_STRING = UNICODE_STRING*; extern(Windows): @@ -85,29 +85,29 @@ struct SecHandle { ULONG_PTR dwLower; ULONG_PTR dwUpper; } -alias SecHandle* PSecHandle; +alias PSecHandle = SecHandle*; struct SecBuffer { ULONG cbBuffer; ULONG BufferType; PVOID pvBuffer; } -alias SecBuffer* PSecBuffer; -alias SecHandle CredHandle; -alias PSecHandle PCredHandle; -alias SecHandle CtxtHandle; -alias PSecHandle PCtxtHandle; +alias PSecBuffer = SecBuffer*; +alias CredHandle = SecHandle; +alias PCredHandle = PSecHandle; +alias CtxtHandle = SecHandle; +alias PCtxtHandle = PSecHandle; struct SECURITY_INTEGER { uint LowPart; int HighPart; } -alias SECURITY_INTEGER TimeStamp; -alias SECURITY_INTEGER* PTimeStamp; +alias TimeStamp = SECURITY_INTEGER; +alias PTimeStamp = SECURITY_INTEGER*; struct SecBufferDesc { ULONG ulVersion; ULONG cBuffers; PSecBuffer pBuffers; } -alias SecBufferDesc* PSecBufferDesc; +alias PSecBufferDesc = SecBufferDesc*; struct SecPkgContext_StreamSizes { ULONG cbHeader; ULONG cbTrailer; @@ -115,22 +115,22 @@ struct SecPkgContext_StreamSizes { ULONG cBuffers; ULONG cbBlockSize; } -alias SecPkgContext_StreamSizes* PSecPkgContext_StreamSizes; +alias PSecPkgContext_StreamSizes = SecPkgContext_StreamSizes*; struct SecPkgContext_Sizes { ULONG cbMaxToken; ULONG cbMaxSignature; ULONG cbBlockSize; ULONG cbSecurityTrailer; } -alias SecPkgContext_Sizes* PSecPkgContext_Sizes; +alias PSecPkgContext_Sizes = SecPkgContext_Sizes*; struct SecPkgContext_AuthorityW { SEC_WCHAR* sAuthorityName; } -alias SecPkgContext_AuthorityW* PSecPkgContext_AuthorityW; +alias PSecPkgContext_AuthorityW = SecPkgContext_AuthorityW*; struct SecPkgContext_AuthorityA { SEC_CHAR* sAuthorityName; } -alias SecPkgContext_AuthorityA* PSecPkgContext_AuthorityA; +alias PSecPkgContext_AuthorityA = SecPkgContext_AuthorityA*; struct SecPkgContext_KeyInfoW { SEC_WCHAR* sSignatureAlgorithmName; SEC_WCHAR* sEncryptAlgorithmName; @@ -138,7 +138,7 @@ struct SecPkgContext_KeyInfoW { ULONG SignatureAlgorithm; ULONG EncryptAlgorithm; } -alias SecPkgContext_KeyInfoW* PSecPkgContext_KeyInfoW; +alias PSecPkgContext_KeyInfoW = SecPkgContext_KeyInfoW*; struct SecPkgContext_KeyInfoA { SEC_CHAR* sSignatureAlgorithmName; SEC_CHAR* sEncryptAlgorithmName; @@ -146,20 +146,20 @@ struct SecPkgContext_KeyInfoA { ULONG SignatureAlgorithm; ULONG EncryptAlgorithm; } -alias SecPkgContext_KeyInfoA* PSecPkgContext_KeyInfoA; +alias PSecPkgContext_KeyInfoA = SecPkgContext_KeyInfoA*; struct SecPkgContext_LifeSpan { TimeStamp tsStart; TimeStamp tsExpiry; } -alias SecPkgContext_LifeSpan* PSecPkgContext_LifeSpan; +alias PSecPkgContext_LifeSpan = SecPkgContext_LifeSpan*; struct SecPkgContext_NamesW { SEC_WCHAR* sUserName; } -alias SecPkgContext_NamesW* PSecPkgContext_NamesW; +alias PSecPkgContext_NamesW = SecPkgContext_NamesW*; struct SecPkgContext_NamesA { SEC_CHAR* sUserName; } -alias SecPkgContext_NamesA* PSecPkgContext_NamesA; +alias PSecPkgContext_NamesA = SecPkgContext_NamesA*; struct SecPkgInfoW { ULONG fCapabilities; USHORT wVersion; @@ -168,7 +168,7 @@ struct SecPkgInfoW { SEC_WCHAR* Name; SEC_WCHAR* Comment; } -alias SecPkgInfoW* PSecPkgInfoW; +alias PSecPkgInfoW = SecPkgInfoW*; struct SecPkgInfoA { ULONG fCapabilities; USHORT wVersion; @@ -177,51 +177,51 @@ struct SecPkgInfoA { SEC_CHAR* Name; SEC_CHAR* Comment; } -alias SecPkgInfoA* PSecPkgInfoA; +alias PSecPkgInfoA = SecPkgInfoA*; /* supported only in win2k+, so it should be a PSecPkgInfoW */ /* PSDK does not say it has ANSI/Unicode versions */ struct SecPkgContext_PackageInfo { PSecPkgInfoW PackageInfo; } -alias SecPkgContext_PackageInfo* PSecPkgContext_PackageInfo; +alias PSecPkgContext_PackageInfo = SecPkgContext_PackageInfo*; struct SecPkgCredentials_NamesW { SEC_WCHAR* sUserName; } -alias SecPkgCredentials_NamesW* PSecPkgCredentials_NamesW; +alias PSecPkgCredentials_NamesW = SecPkgCredentials_NamesW*; struct SecPkgCredentials_NamesA { SEC_CHAR* sUserName; } -alias SecPkgCredentials_NamesA* PSecPkgCredentials_NamesA; +alias PSecPkgCredentials_NamesA = SecPkgCredentials_NamesA*; /* TODO: missing type in SDK */ -alias void function() SEC_GET_KEY_FN; +alias SEC_GET_KEY_FN = void function(); -alias SECURITY_STATUS function(PULONG,PSecPkgInfoW*) ENUMERATE_SECURITY_PACKAGES_FN_W; -alias SECURITY_STATUS function(PULONG,PSecPkgInfoA*) ENUMERATE_SECURITY_PACKAGES_FN_A; -alias SECURITY_STATUS function(PCredHandle,ULONG,PVOID) QUERY_CREDENTIALS_ATTRIBUTES_FN_W; -alias SECURITY_STATUS function(PCredHandle,ULONG,PVOID) QUERY_CREDENTIALS_ATTRIBUTES_FN_A; -alias SECURITY_STATUS function(SEC_WCHAR*,SEC_WCHAR*,ULONG,PLUID,PVOID,SEC_GET_KEY_FN,PVOID,PCredHandle,PTimeStamp) ACQUIRE_CREDENTIALS_HANDLE_FN_W; -alias SECURITY_STATUS function(SEC_CHAR*,SEC_CHAR*,ULONG,PLUID,PVOID,SEC_GET_KEY_FN,PVOID,PCredHandle,PTimeStamp) ACQUIRE_CREDENTIALS_HANDLE_FN_A; -alias SECURITY_STATUS function(PCredHandle) FREE_CREDENTIALS_HANDLE_FN; -alias SECURITY_STATUS function(PCredHandle,PCtxtHandle,SEC_WCHAR*,ULONG,ULONG,ULONG,PSecBufferDesc,ULONG,PCtxtHandle,PSecBufferDesc,PULONG,PTimeStamp) INITIALIZE_SECURITY_CONTEXT_FN_W; -alias SECURITY_STATUS function(PCredHandle,PCtxtHandle,SEC_CHAR*,ULONG,ULONG,ULONG,PSecBufferDesc,ULONG,PCtxtHandle,PSecBufferDesc,PULONG,PTimeStamp) INITIALIZE_SECURITY_CONTEXT_FN_A; -alias SECURITY_STATUS function(PCredHandle,PCtxtHandle,PSecBufferDesc,ULONG,ULONG,PCtxtHandle,PSecBufferDesc,PULONG,PTimeStamp) ACCEPT_SECURITY_CONTEXT_FN; -alias SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc) COMPLETE_AUTH_TOKEN_FN; -alias SECURITY_STATUS function(PCtxtHandle) DELETE_SECURITY_CONTEXT_FN; -alias SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc) APPLY_CONTROL_TOKEN_FN_W; -alias SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc) APPLY_CONTROL_TOKEN_FN_A; -alias SECURITY_STATUS function(PCtxtHandle,ULONG,PVOID) QUERY_CONTEXT_ATTRIBUTES_FN_A; -alias SECURITY_STATUS function(PCtxtHandle,ULONG,PVOID) QUERY_CONTEXT_ATTRIBUTES_FN_W; -alias SECURITY_STATUS function(PCtxtHandle) IMPERSONATE_SECURITY_CONTEXT_FN; -alias SECURITY_STATUS function(PCtxtHandle) REVERT_SECURITY_CONTEXT_FN; -alias SECURITY_STATUS function(PCtxtHandle,ULONG,PSecBufferDesc,ULONG) MAKE_SIGNATURE_FN; -alias SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc,ULONG,PULONG) VERIFY_SIGNATURE_FN; -alias SECURITY_STATUS function(PVOID) FREE_CONTEXT_BUFFER_FN; -alias SECURITY_STATUS function(SEC_CHAR*,PSecPkgInfoA*) QUERY_SECURITY_PACKAGE_INFO_FN_A; -alias SECURITY_STATUS function(PCtxtHandle,HANDLE*) QUERY_SECURITY_CONTEXT_TOKEN_FN; -alias SECURITY_STATUS function(SEC_WCHAR*,PSecPkgInfoW*) QUERY_SECURITY_PACKAGE_INFO_FN_W; -alias SECURITY_STATUS function(PCtxtHandle,ULONG,PSecBufferDesc,ULONG) ENCRYPT_MESSAGE_FN; -alias SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc,ULONG,PULONG) DECRYPT_MESSAGE_FN; +alias ENUMERATE_SECURITY_PACKAGES_FN_W = SECURITY_STATUS function(PULONG,PSecPkgInfoW*); +alias ENUMERATE_SECURITY_PACKAGES_FN_A = SECURITY_STATUS function(PULONG,PSecPkgInfoA*); +alias QUERY_CREDENTIALS_ATTRIBUTES_FN_W = SECURITY_STATUS function(PCredHandle,ULONG,PVOID); +alias QUERY_CREDENTIALS_ATTRIBUTES_FN_A = SECURITY_STATUS function(PCredHandle,ULONG,PVOID); +alias ACQUIRE_CREDENTIALS_HANDLE_FN_W = SECURITY_STATUS function(SEC_WCHAR*,SEC_WCHAR*,ULONG,PLUID,PVOID,SEC_GET_KEY_FN,PVOID,PCredHandle,PTimeStamp); +alias ACQUIRE_CREDENTIALS_HANDLE_FN_A = SECURITY_STATUS function(SEC_CHAR*,SEC_CHAR*,ULONG,PLUID,PVOID,SEC_GET_KEY_FN,PVOID,PCredHandle,PTimeStamp); +alias FREE_CREDENTIALS_HANDLE_FN = SECURITY_STATUS function(PCredHandle); +alias INITIALIZE_SECURITY_CONTEXT_FN_W = SECURITY_STATUS function(PCredHandle,PCtxtHandle,SEC_WCHAR*,ULONG,ULONG,ULONG,PSecBufferDesc,ULONG,PCtxtHandle,PSecBufferDesc,PULONG,PTimeStamp); +alias INITIALIZE_SECURITY_CONTEXT_FN_A = SECURITY_STATUS function(PCredHandle,PCtxtHandle,SEC_CHAR*,ULONG,ULONG,ULONG,PSecBufferDesc,ULONG,PCtxtHandle,PSecBufferDesc,PULONG,PTimeStamp); +alias ACCEPT_SECURITY_CONTEXT_FN = SECURITY_STATUS function(PCredHandle,PCtxtHandle,PSecBufferDesc,ULONG,ULONG,PCtxtHandle,PSecBufferDesc,PULONG,PTimeStamp); +alias COMPLETE_AUTH_TOKEN_FN = SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc); +alias DELETE_SECURITY_CONTEXT_FN = SECURITY_STATUS function(PCtxtHandle); +alias APPLY_CONTROL_TOKEN_FN_W = SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc); +alias APPLY_CONTROL_TOKEN_FN_A = SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc); +alias QUERY_CONTEXT_ATTRIBUTES_FN_A = SECURITY_STATUS function(PCtxtHandle,ULONG,PVOID); +alias QUERY_CONTEXT_ATTRIBUTES_FN_W = SECURITY_STATUS function(PCtxtHandle,ULONG,PVOID); +alias IMPERSONATE_SECURITY_CONTEXT_FN = SECURITY_STATUS function(PCtxtHandle); +alias REVERT_SECURITY_CONTEXT_FN = SECURITY_STATUS function(PCtxtHandle); +alias MAKE_SIGNATURE_FN = SECURITY_STATUS function(PCtxtHandle,ULONG,PSecBufferDesc,ULONG); +alias VERIFY_SIGNATURE_FN = SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc,ULONG,PULONG); +alias FREE_CONTEXT_BUFFER_FN = SECURITY_STATUS function(PVOID); +alias QUERY_SECURITY_PACKAGE_INFO_FN_A = SECURITY_STATUS function(SEC_CHAR*,PSecPkgInfoA*); +alias QUERY_SECURITY_CONTEXT_TOKEN_FN = SECURITY_STATUS function(PCtxtHandle,HANDLE*); +alias QUERY_SECURITY_PACKAGE_INFO_FN_W = SECURITY_STATUS function(SEC_WCHAR*,PSecPkgInfoW*); +alias ENCRYPT_MESSAGE_FN = SECURITY_STATUS function(PCtxtHandle,ULONG,PSecBufferDesc,ULONG); +alias DECRYPT_MESSAGE_FN = SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc,ULONG,PULONG); /* No, it really is FreeCredentialsHandle, see the thread beginning * http://sourceforge.net/mailarchive/message.php?msg_id=4321080 for a @@ -255,7 +255,7 @@ struct SecurityFunctionTableW{ ENCRYPT_MESSAGE_FN EncryptMessage; DECRYPT_MESSAGE_FN DecryptMessage; } -alias SecurityFunctionTableW* PSecurityFunctionTableW; +alias PSecurityFunctionTableW = SecurityFunctionTableW*; struct SecurityFunctionTableA{ uint dwVersion; ENUMERATE_SECURITY_PACKAGES_FN_A EnumerateSecurityPackagesA; @@ -285,9 +285,9 @@ struct SecurityFunctionTableA{ ENCRYPT_MESSAGE_FN EncryptMessage; DECRYPT_MESSAGE_FN DecryptMessage; } -alias SecurityFunctionTableA* PSecurityFunctionTableA; -alias PSecurityFunctionTableA function() INIT_SECURITY_INTERFACE_A; -alias PSecurityFunctionTableW function() INIT_SECURITY_INTERFACE_W; +alias PSecurityFunctionTableA = SecurityFunctionTableA*; +alias INIT_SECURITY_INTERFACE_A = PSecurityFunctionTableA function(); +alias INIT_SECURITY_INTERFACE_W = PSecurityFunctionTableW function(); SECURITY_STATUS FreeCredentialsHandle(PCredHandle); SECURITY_STATUS EnumerateSecurityPackagesA(PULONG,PSecPkgInfoA*); @@ -321,61 +321,61 @@ PSecurityFunctionTableA InitSecurityInterfaceA(); PSecurityFunctionTableW InitSecurityInterfaceW(); version (Unicode) { - alias UNISP_NAME_W UNISP_NAME; - alias SecPkgInfoW SecPkgInfo; - alias PSecPkgInfoW PSecPkgInfo; - alias SecPkgCredentials_NamesW SecPkgCredentials_Names; - alias PSecPkgCredentials_NamesW PSecPkgCredentials_Names; - alias SecPkgContext_AuthorityW SecPkgContext_Authority; - alias PSecPkgContext_AuthorityW PSecPkgContext_Authority; - alias SecPkgContext_KeyInfoW SecPkgContext_KeyInfo; - alias PSecPkgContext_KeyInfoW PSecPkgContext_KeyInfo; - alias SecPkgContext_NamesW SecPkgContext_Names; - alias PSecPkgContext_NamesW PSecPkgContext_Names; - alias SecurityFunctionTableW SecurityFunctionTable; - alias PSecurityFunctionTableW PSecurityFunctionTable; - alias AcquireCredentialsHandleW AcquireCredentialsHandle; - alias EnumerateSecurityPackagesW EnumerateSecurityPackages; - alias InitializeSecurityContextW InitializeSecurityContext; - alias QueryContextAttributesW QueryContextAttributes; - alias QueryCredentialsAttributesW QueryCredentialsAttributes; - alias QuerySecurityPackageInfoW QuerySecurityPackageInfo; - alias ApplyControlTokenW ApplyControlToken; - alias ENUMERATE_SECURITY_PACKAGES_FN_W ENUMERATE_SECURITY_PACKAGES_FN; - alias QUERY_CREDENTIALS_ATTRIBUTES_FN_W QUERY_CREDENTIALS_ATTRIBUTES_FN; - alias ACQUIRE_CREDENTIALS_HANDLE_FN_W ACQUIRE_CREDENTIALS_HANDLE_FN; - alias INITIALIZE_SECURITY_CONTEXT_FN_W INITIALIZE_SECURITY_CONTEXT_FN; - alias APPLY_CONTROL_TOKEN_FN_W APPLY_CONTROL_TOKEN_FN; - alias QUERY_CONTEXT_ATTRIBUTES_FN_W QUERY_CONTEXT_ATTRIBUTES_FN; - alias QUERY_SECURITY_PACKAGE_INFO_FN_W QUERY_SECURITY_PACKAGE_INFO_FN; - alias INIT_SECURITY_INTERFACE_W INIT_SECURITY_INTERFACE; + alias UNISP_NAME = UNISP_NAME_W; + alias SecPkgInfo = SecPkgInfoW; + alias PSecPkgInfo = PSecPkgInfoW; + alias SecPkgCredentials_Names = SecPkgCredentials_NamesW; + alias PSecPkgCredentials_Names = PSecPkgCredentials_NamesW; + alias SecPkgContext_Authority = SecPkgContext_AuthorityW; + alias PSecPkgContext_Authority = PSecPkgContext_AuthorityW; + alias SecPkgContext_KeyInfo = SecPkgContext_KeyInfoW; + alias PSecPkgContext_KeyInfo = PSecPkgContext_KeyInfoW; + alias SecPkgContext_Names = SecPkgContext_NamesW; + alias PSecPkgContext_Names = PSecPkgContext_NamesW; + alias SecurityFunctionTable = SecurityFunctionTableW; + alias PSecurityFunctionTable = PSecurityFunctionTableW; + alias AcquireCredentialsHandle = AcquireCredentialsHandleW; + alias EnumerateSecurityPackages = EnumerateSecurityPackagesW; + alias InitializeSecurityContext = InitializeSecurityContextW; + alias QueryContextAttributes = QueryContextAttributesW; + alias QueryCredentialsAttributes = QueryCredentialsAttributesW; + alias QuerySecurityPackageInfo = QuerySecurityPackageInfoW; + alias ApplyControlToken = ApplyControlTokenW; + alias ENUMERATE_SECURITY_PACKAGES_FN = ENUMERATE_SECURITY_PACKAGES_FN_W; + alias QUERY_CREDENTIALS_ATTRIBUTES_FN = QUERY_CREDENTIALS_ATTRIBUTES_FN_W; + alias ACQUIRE_CREDENTIALS_HANDLE_FN = ACQUIRE_CREDENTIALS_HANDLE_FN_W; + alias INITIALIZE_SECURITY_CONTEXT_FN = INITIALIZE_SECURITY_CONTEXT_FN_W; + alias APPLY_CONTROL_TOKEN_FN = APPLY_CONTROL_TOKEN_FN_W; + alias QUERY_CONTEXT_ATTRIBUTES_FN = QUERY_CONTEXT_ATTRIBUTES_FN_W; + alias QUERY_SECURITY_PACKAGE_INFO_FN = QUERY_SECURITY_PACKAGE_INFO_FN_W; + alias INIT_SECURITY_INTERFACE = INIT_SECURITY_INTERFACE_W; }else{ - alias UNISP_NAME_A UNISP_NAME; - alias SecPkgInfoA SecPkgInfo; - alias PSecPkgInfoA PSecPkgInfo; - alias SecPkgCredentials_NamesA SecPkgCredentials_Names; - alias PSecPkgCredentials_NamesA PSecPkgCredentials_Names; - alias SecPkgContext_AuthorityA SecPkgContext_Authority; - alias PSecPkgContext_AuthorityA PSecPkgContext_Authority; - alias SecPkgContext_KeyInfoA SecPkgContext_KeyInfo; - alias PSecPkgContext_KeyInfoA PSecPkgContext_KeyInfo; - alias SecPkgContext_NamesA SecPkgContext_Names; - alias PSecPkgContext_NamesA PSecPkgContext_Names; - alias SecurityFunctionTableA SecurityFunctionTable; - alias PSecurityFunctionTableA PSecurityFunctionTable; - alias AcquireCredentialsHandleA AcquireCredentialsHandle; - alias EnumerateSecurityPackagesA EnumerateSecurityPackages; - alias InitializeSecurityContextA InitializeSecurityContext; - alias QueryContextAttributesA QueryContextAttributes; - alias QueryCredentialsAttributesA QueryCredentialsAttributes; - alias QuerySecurityPackageInfoA QuerySecurityPackageInfo; - alias ApplyControlTokenA ApplyControlToken; - alias ENUMERATE_SECURITY_PACKAGES_FN_A ENUMERATE_SECURITY_PACKAGES_FN; - alias QUERY_CREDENTIALS_ATTRIBUTES_FN_A QUERY_CREDENTIALS_ATTRIBUTES_FN; - alias ACQUIRE_CREDENTIALS_HANDLE_FN_A ACQUIRE_CREDENTIALS_HANDLE_FN; - alias INITIALIZE_SECURITY_CONTEXT_FN_A INITIALIZE_SECURITY_CONTEXT_FN; - alias APPLY_CONTROL_TOKEN_FN_A APPLY_CONTROL_TOKEN_FN; - alias QUERY_CONTEXT_ATTRIBUTES_FN_A QUERY_CONTEXT_ATTRIBUTES_FN; - alias QUERY_SECURITY_PACKAGE_INFO_FN_A QUERY_SECURITY_PACKAGE_INFO_FN; - alias INIT_SECURITY_INTERFACE_A INIT_SECURITY_INTERFACE; + alias UNISP_NAME = UNISP_NAME_A; + alias SecPkgInfo = SecPkgInfoA; + alias PSecPkgInfo = PSecPkgInfoA; + alias SecPkgCredentials_Names = SecPkgCredentials_NamesA; + alias PSecPkgCredentials_Names = PSecPkgCredentials_NamesA; + alias SecPkgContext_Authority = SecPkgContext_AuthorityA; + alias PSecPkgContext_Authority = PSecPkgContext_AuthorityA; + alias SecPkgContext_KeyInfo = SecPkgContext_KeyInfoA; + alias PSecPkgContext_KeyInfo = PSecPkgContext_KeyInfoA; + alias SecPkgContext_Names = SecPkgContext_NamesA; + alias PSecPkgContext_Names = PSecPkgContext_NamesA; + alias SecurityFunctionTable = SecurityFunctionTableA; + alias PSecurityFunctionTable = PSecurityFunctionTableA; + alias AcquireCredentialsHandle = AcquireCredentialsHandleA; + alias EnumerateSecurityPackages = EnumerateSecurityPackagesA; + alias InitializeSecurityContext = InitializeSecurityContextA; + alias QueryContextAttributes = QueryContextAttributesA; + alias QueryCredentialsAttributes = QueryCredentialsAttributesA; + alias QuerySecurityPackageInfo = QuerySecurityPackageInfoA; + alias ApplyControlToken = ApplyControlTokenA; + alias ENUMERATE_SECURITY_PACKAGES_FN = ENUMERATE_SECURITY_PACKAGES_FN_A; + alias QUERY_CREDENTIALS_ATTRIBUTES_FN = QUERY_CREDENTIALS_ATTRIBUTES_FN_A; + alias ACQUIRE_CREDENTIALS_HANDLE_FN = ACQUIRE_CREDENTIALS_HANDLE_FN_A; + alias INITIALIZE_SECURITY_CONTEXT_FN = INITIALIZE_SECURITY_CONTEXT_FN_A; + alias APPLY_CONTROL_TOKEN_FN = APPLY_CONTROL_TOKEN_FN_A; + alias QUERY_CONTEXT_ATTRIBUTES_FN = QUERY_CONTEXT_ATTRIBUTES_FN_A; + alias QUERY_SECURITY_PACKAGE_INFO_FN = QUERY_SECURITY_PACKAGE_INFO_FN_A; + alias INIT_SECURITY_INTERFACE = INIT_SECURITY_INTERFACE_A; } diff --git a/runtime/druntime/src/core/sys/windows/stacktrace.d b/runtime/druntime/src/core/sys/windows/stacktrace.d index 04aafd3f60..4367e34fef 100644 --- a/runtime/druntime/src/core/sys/windows/stacktrace.d +++ b/runtime/druntime/src/core/sys/windows/stacktrace.d @@ -27,7 +27,7 @@ debug(PRINTF) import core.stdc.stdio; extern(Windows) void RtlCaptureContext(CONTEXT* ContextRecord) @nogc; extern(Windows) DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR pBuffer, DWORD nSize); -extern(Windows) alias USHORT function(ULONG FramesToSkip, ULONG FramesToCapture, PVOID *BackTrace, PULONG BackTraceHash) @nogc RtlCaptureStackBackTraceFunc; +extern(Windows) alias RtlCaptureStackBackTraceFunc = USHORT function(ULONG FramesToSkip, ULONG FramesToCapture, PVOID *BackTrace, PULONG BackTraceHash) @nogc; private __gshared RtlCaptureStackBackTraceFunc RtlCaptureStackBackTrace; private __gshared CRITICAL_SECTION mutex; // cannot use core.sync.mutex.Mutex unfortunately (cyclic dependency...) diff --git a/runtime/druntime/src/core/sys/windows/stdc/time.d b/runtime/druntime/src/core/sys/windows/stdc/time.d index c3fa12216c..3146008cb9 100644 --- a/runtime/druntime/src/core/sys/windows/stdc/time.d +++ b/runtime/druntime/src/core/sys/windows/stdc/time.d @@ -39,9 +39,9 @@ struct tm } /// -alias c_long time_t; +alias time_t = c_long; /// -alias c_long clock_t; +alias clock_t = c_long; enum clock_t CLOCKS_PER_SEC = 1000; clock_t clock(); diff --git a/runtime/druntime/src/core/sys/windows/subauth.d b/runtime/druntime/src/core/sys/windows/subauth.d index 8240d9f478..c8de6d07f6 100644 --- a/runtime/druntime/src/core/sys/windows/subauth.d +++ b/runtime/druntime/src/core/sys/windows/subauth.d @@ -107,13 +107,13 @@ alias STRING* PSTRING; +/ alias SAM_HANDLE = HANDLE; -alias SAM_HANDLE* PSAM_HANDLE; +alias PSAM_HANDLE = SAM_HANDLE*; struct OLD_LARGE_INTEGER { ULONG LowPart; LONG HighPart; } -alias OLD_LARGE_INTEGER* POLD_LARGE_INTEGER; +alias POLD_LARGE_INTEGER = OLD_LARGE_INTEGER*; enum NETLOGON_LOGON_INFO_CLASS { NetlogonInteractiveInformation = 1, @@ -133,42 +133,42 @@ enum CLEAR_BLOCK_LENGTH = 8; struct CYPHER_BLOCK { CHAR[CYPHER_BLOCK_LENGTH] data = 0; } -alias CYPHER_BLOCK* PCYPHER_BLOCK; +alias PCYPHER_BLOCK = CYPHER_BLOCK*; struct CLEAR_BLOCK { CHAR[CLEAR_BLOCK_LENGTH] data = 0; } -alias CLEAR_BLOCK* PCLEAR_BLOCK; +alias PCLEAR_BLOCK = CLEAR_BLOCK*; struct LM_OWF_PASSWORD { CYPHER_BLOCK[2] data; } -alias LM_OWF_PASSWORD* PLM_OWF_PASSWORD; +alias PLM_OWF_PASSWORD = LM_OWF_PASSWORD*; struct USER_SESSION_KEY { CYPHER_BLOCK[2] data; } -alias USER_SESSION_KEY* PUSER_SESSION_KEY; +alias PUSER_SESSION_KEY = USER_SESSION_KEY*; -alias CLEAR_BLOCK LM_CHALLENGE; -alias LM_CHALLENGE* PLM_CHALLENGE; +alias LM_CHALLENGE = CLEAR_BLOCK; +alias PLM_CHALLENGE = LM_CHALLENGE*; -alias LM_OWF_PASSWORD NT_OWF_PASSWORD; -alias NT_OWF_PASSWORD* PNT_OWF_PASSWORD; -alias LM_CHALLENGE NT_CHALLENGE; -alias NT_CHALLENGE* PNT_CHALLENGE; +alias NT_OWF_PASSWORD = LM_OWF_PASSWORD; +alias PNT_OWF_PASSWORD = NT_OWF_PASSWORD*; +alias NT_CHALLENGE = LM_CHALLENGE; +alias PNT_CHALLENGE = NT_CHALLENGE*; struct LOGON_HOURS { USHORT UnitsPerWeek; PUCHAR LogonHours; } -alias LOGON_HOURS* PLOGON_HOURS; +alias PLOGON_HOURS = LOGON_HOURS*; struct SR_SECURITY_DESCRIPTOR { ULONG Length; PUCHAR SecurityDescriptor; } -alias SR_SECURITY_DESCRIPTOR* PSR_SECURITY_DESCRIPTOR; +alias PSR_SECURITY_DESCRIPTOR = SR_SECURITY_DESCRIPTOR*; align(4): struct USER_ALL_INFORMATION { @@ -206,7 +206,7 @@ struct USER_ALL_INFORMATION { BOOLEAN PasswordExpired; BOOLEAN PrivateDataSensitive; } -alias USER_ALL_INFORMATION* PUSER_ALL_INFORMATION; +alias PUSER_ALL_INFORMATION = USER_ALL_INFORMATION*; align: struct MSV1_0_VALIDATION_INFO { @@ -220,7 +220,7 @@ struct MSV1_0_VALIDATION_INFO { ULONG WhichFields; ULONG UserId; } -alias MSV1_0_VALIDATION_INFO* PMSV1_0_VALIDATION_INFO; +alias PMSV1_0_VALIDATION_INFO = MSV1_0_VALIDATION_INFO*; struct NETLOGON_LOGON_IDENTITY_INFO { UNICODE_STRING LogonDomainName; @@ -229,14 +229,14 @@ struct NETLOGON_LOGON_IDENTITY_INFO { UNICODE_STRING UserName; UNICODE_STRING Workstation; } -alias NETLOGON_LOGON_IDENTITY_INFO* PNETLOGON_LOGON_IDENTITY_INFO; +alias PNETLOGON_LOGON_IDENTITY_INFO = NETLOGON_LOGON_IDENTITY_INFO*; struct NETLOGON_INTERACTIVE_INFO { NETLOGON_LOGON_IDENTITY_INFO Identity; LM_OWF_PASSWORD LmOwfPassword; NT_OWF_PASSWORD NtOwfPassword; } -alias NETLOGON_INTERACTIVE_INFO* PNETLOGON_INTERACTIVE_INFO; +alias PNETLOGON_INTERACTIVE_INFO = NETLOGON_INTERACTIVE_INFO*; struct NETLOGON_GENERIC_INFO { NETLOGON_LOGON_IDENTITY_INFO Identity; @@ -244,7 +244,7 @@ struct NETLOGON_GENERIC_INFO { ULONG DataLength; PUCHAR LogonData; } -alias NETLOGON_GENERIC_INFO* PNETLOGON_GENERIC_INFO; +alias PNETLOGON_GENERIC_INFO = NETLOGON_GENERIC_INFO*; struct NETLOGON_NETWORK_INFO { NETLOGON_LOGON_IDENTITY_INFO Identity; @@ -252,14 +252,14 @@ struct NETLOGON_NETWORK_INFO { STRING NtChallengeResponse; STRING LmChallengeResponse; } -alias NETLOGON_NETWORK_INFO* PNETLOGON_NETWORK_INFO; +alias PNETLOGON_NETWORK_INFO = NETLOGON_NETWORK_INFO*; struct NETLOGON_SERVICE_INFO { NETLOGON_LOGON_IDENTITY_INFO Identity; LM_OWF_PASSWORD LmOwfPassword; NT_OWF_PASSWORD NtOwfPassword; } -alias NETLOGON_SERVICE_INFO* PNETLOGON_SERVICE_INFO; +alias PNETLOGON_SERVICE_INFO = NETLOGON_SERVICE_INFO*; extern (Windows) { NTSTATUS Msv1_0SubAuthenticationRoutine(NETLOGON_LOGON_INFO_CLASS,PVOID, diff --git a/runtime/druntime/src/core/sys/windows/threadaux.d b/runtime/druntime/src/core/sys/windows/threadaux.d index 40b833c1aa..afc163f617 100644 --- a/runtime/druntime/src/core/sys/windows/threadaux.d +++ b/runtime/druntime/src/core/sys/windows/threadaux.d @@ -50,7 +50,7 @@ struct thread_aux wchar* Buffer; } // process or thread ID, documentation says it is a HANDLE, but it's actually the ID (a DWORD) - alias size_t PTID; + alias PTID = size_t; struct _SYSTEM_PROCESS_INFORMATION { @@ -274,7 +274,7 @@ struct thread_aux } // execute function on the TLS for the given thread - alias extern(C) void function() externCVoidFunc; + alias externCVoidFunc = extern(C) void function(); static void impersonate_thread( uint id, externCVoidFunc fn ) { impersonate_thread(id, () => fn()); @@ -337,11 +337,11 @@ struct thread_aux public: // forward as few symbols as possible into the "global" name space -alias thread_aux.getTEB getTEB; -alias thread_aux.getThreadStackBottom getThreadStackBottom; -alias thread_aux.OpenThreadHandle OpenThreadHandle; -alias thread_aux.enumProcessThreads enumProcessThreads; -alias thread_aux.impersonate_thread impersonate_thread; +alias getTEB = thread_aux.getTEB; +alias getThreadStackBottom = thread_aux.getThreadStackBottom; +alias OpenThreadHandle = thread_aux.OpenThreadHandle; +alias enumProcessThreads = thread_aux.enumProcessThreads; +alias impersonate_thread = thread_aux.impersonate_thread; // get the start of the TLS memory of the thread with the given handle void* GetTlsDataAddress( HANDLE hnd ) nothrow diff --git a/runtime/druntime/src/core/sys/windows/tlhelp32.d b/runtime/druntime/src/core/sys/windows/tlhelp32.d index ecbfe38ab4..6a5d58be6e 100644 --- a/runtime/druntime/src/core/sys/windows/tlhelp32.d +++ b/runtime/druntime/src/core/sys/windows/tlhelp32.d @@ -42,8 +42,8 @@ struct HEAPLIST32 { ULONG_PTR th32HeapID; DWORD dwFlags; } -alias HEAPLIST32* PHEAPLIST32; -alias HEAPLIST32* LPHEAPLIST32; +alias PHEAPLIST32 = HEAPLIST32*; +alias LPHEAPLIST32 = HEAPLIST32*; struct HEAPENTRY32 { SIZE_T dwSize; @@ -56,8 +56,8 @@ struct HEAPENTRY32 { DWORD th32ProcessID; ULONG_PTR th32HeapID; } -alias HEAPENTRY32* PHEAPENTRY32; -alias HEAPENTRY32* LPHEAPENTRY32; +alias PHEAPENTRY32 = HEAPENTRY32*; +alias LPHEAPENTRY32 = HEAPENTRY32*; struct PROCESSENTRY32W { DWORD dwSize; @@ -71,8 +71,8 @@ struct PROCESSENTRY32W { DWORD dwFlags; WCHAR[MAX_PATH] szExeFile = 0; } -alias PROCESSENTRY32W* PPROCESSENTRY32W; -alias PROCESSENTRY32W* LPPROCESSENTRY32W; +alias PPROCESSENTRY32W = PROCESSENTRY32W*; +alias LPPROCESSENTRY32W = PROCESSENTRY32W*; struct THREADENTRY32 { DWORD dwSize; @@ -83,8 +83,8 @@ struct THREADENTRY32 { LONG tpDeltaPri; DWORD dwFlags; } -alias THREADENTRY32* PTHREADENTRY32; -alias THREADENTRY32* LPTHREADENTRY32; +alias PTHREADENTRY32 = THREADENTRY32*; +alias LPTHREADENTRY32 = THREADENTRY32*; struct MODULEENTRY32W { DWORD dwSize; @@ -98,17 +98,17 @@ struct MODULEENTRY32W { WCHAR[MAX_MODULE_NAME32 + 1] szModule = 0; WCHAR[MAX_PATH] szExePath = 0; } -alias MODULEENTRY32W* PMODULEENTRY32W; -alias MODULEENTRY32W* LPMODULEENTRY32W; +alias PMODULEENTRY32W = MODULEENTRY32W*; +alias LPMODULEENTRY32W = MODULEENTRY32W*; version (Unicode) { - alias PROCESSENTRY32W PROCESSENTRY32; - alias PPROCESSENTRY32W PPROCESSENTRY32; - alias LPPROCESSENTRY32W LPPROCESSENTRY32; + alias PROCESSENTRY32 = PROCESSENTRY32W; + alias PPROCESSENTRY32 = PPROCESSENTRY32W; + alias LPPROCESSENTRY32 = LPPROCESSENTRY32W; - alias MODULEENTRY32W MODULEENTRY32; - alias PMODULEENTRY32W PMODULEENTRY32; - alias LPMODULEENTRY32W LPMODULEENTRY32; + alias MODULEENTRY32 = MODULEENTRY32W; + alias PMODULEENTRY32 = PMODULEENTRY32W; + alias LPMODULEENTRY32 = LPMODULEENTRY32W; } else { struct PROCESSENTRY32 { DWORD dwSize; @@ -122,8 +122,8 @@ version (Unicode) { DWORD dwFlags; CHAR[MAX_PATH] szExeFile = 0; } - alias PROCESSENTRY32* PPROCESSENTRY32; - alias PROCESSENTRY32* LPPROCESSENTRY32; + alias PPROCESSENTRY32 = PROCESSENTRY32*; + alias LPPROCESSENTRY32 = PROCESSENTRY32*; struct MODULEENTRY32 { DWORD dwSize; @@ -137,8 +137,8 @@ version (Unicode) { char[MAX_MODULE_NAME32 + 1] szModule = 0; char[MAX_PATH] szExePath = 0; } - alias MODULEENTRY32* PMODULEENTRY32; - alias MODULEENTRY32* LPMODULEENTRY32; + alias PMODULEENTRY32 = MODULEENTRY32*; + alias LPMODULEENTRY32 = MODULEENTRY32*; } @@ -158,10 +158,10 @@ extern(Windows) nothrow @nogc { } version (Unicode) { - alias Module32FirstW Module32First; - alias Module32NextW Module32Next; - alias Process32FirstW Process32First; - alias Process32NextW Process32Next; + alias Module32First = Module32FirstW; + alias Module32Next = Module32NextW; + alias Process32First = Process32FirstW; + alias Process32Next = Process32NextW; } else { extern(Windows) nothrow @nogc { BOOL Module32First(HANDLE,LPMODULEENTRY32); diff --git a/runtime/druntime/src/core/sys/windows/unknwn.d b/runtime/druntime/src/core/sys/windows/unknwn.d index 0b00279227..d2a3472648 100644 --- a/runtime/druntime/src/core/sys/windows/unknwn.d +++ b/runtime/druntime/src/core/sys/windows/unknwn.d @@ -27,13 +27,13 @@ extern (Windows) { ULONG Release(); } - alias IUnknown LPUNKNOWN; + alias LPUNKNOWN = IUnknown; interface IClassFactory : IUnknown { HRESULT CreateInstance(IUnknown UnkOuter, IID* riid, void** pvObject); HRESULT LockServer(BOOL fLock); } - alias IClassFactory LPCLASSFACTORY; + alias LPCLASSFACTORY = IClassFactory; /+ // These do not seem to be necessary (or desirable) for D. diff --git a/runtime/druntime/src/core/sys/windows/vfw.d b/runtime/druntime/src/core/sys/windows/vfw.d index 313895f4ac..8f0adf38be 100644 --- a/runtime/druntime/src/core/sys/windows/vfw.d +++ b/runtime/druntime/src/core/sys/windows/vfw.d @@ -38,7 +38,7 @@ DWORD MKFOURCC(char ch0, char ch1, char ch2, char ch3) { enum ICVERSION = 0x0104; -alias HANDLE HIC; +alias HIC = HANDLE; enum BI_1632 = 0x32333631; @@ -656,7 +656,7 @@ struct COMPVARS { LPVOID lpState; LONG cbState; } -alias COMPVARS* PCOMPVARS; +alias PCOMPVARS = COMPVARS*; enum ICMF_COMPVARS_VALID = 0x00000001; @@ -734,7 +734,7 @@ struct DRAWDIBTIME { LONG timeBlt; LONG timeSetDIBits; } -alias DRAWDIBTIME* LPDRAWDIBTIME; +alias LPDRAWDIBTIME = DRAWDIBTIME*; extern (Windows) { BOOL DrawDibTime(HDRAWDIB hdd, LPDRAWDIBTIME lpddtime); @@ -755,9 +755,9 @@ extern (Windows) { int SrcX, int SrcY, int SrcXE, int SrcYE); } -alias DWORD FOURCC; +alias FOURCC = DWORD; -alias WORD TWOCC; +alias TWOCC = WORD; enum formtypeAVI = mmioFOURCC!('A', 'V', 'I', ' '); enum listtypeAVIHEADER = mmioFOURCC!('h', 'd', 'r', 'l'); @@ -892,7 +892,7 @@ struct AVISTREAMINFOW { DWORD dwFormatChangeCount; WCHAR[64] szName = 0; } -alias AVISTREAMINFOW* LPAVISTREAMINFOW; +alias LPAVISTREAMINFOW = AVISTREAMINFOW*; struct AVISTREAMINFOA { DWORD fccType; @@ -914,14 +914,14 @@ struct AVISTREAMINFOA { DWORD dwFormatChangeCount; char[64] szName = 0; } -alias AVISTREAMINFOA* LPAVISTREAMINFOA; +alias LPAVISTREAMINFOA = AVISTREAMINFOA*; version (Unicode) { - alias AVISTREAMINFOW AVISTREAMINFO; - alias LPAVISTREAMINFOW LPAVISTREAMINFO; + alias AVISTREAMINFO = AVISTREAMINFOW; + alias LPAVISTREAMINFO = LPAVISTREAMINFOW; } else { // Unicode - alias AVISTREAMINFOA AVISTREAMINFO; - alias LPAVISTREAMINFOA LPAVISTREAMINFO; + alias AVISTREAMINFO = AVISTREAMINFOA; + alias LPAVISTREAMINFO = LPAVISTREAMINFOA; } enum AVISTREAMINFO_DISABLED = 0x00000001; @@ -941,7 +941,7 @@ struct AVIFILEINFOW { DWORD dwEditCount; WCHAR[64] szFileType = 0; } -alias AVIFILEINFOW* LPAVIFILEINFOW; +alias LPAVIFILEINFOW = AVIFILEINFOW*; struct AVIFILEINFOA { DWORD dwMaxBytesPerSec; @@ -957,14 +957,14 @@ struct AVIFILEINFOA { DWORD dwEditCount; char[64] szFileType = 0; } -alias AVIFILEINFOA* LPAVIFILEINFOA; +alias LPAVIFILEINFOA = AVIFILEINFOA*; version (Unicode) { - alias AVIFILEINFOW AVIFILEINFO; - alias LPAVIFILEINFOW LPAVIFILEINFO; + alias AVIFILEINFO = AVIFILEINFOW; + alias LPAVIFILEINFO = LPAVIFILEINFOW; } else { // Unicode - alias AVIFILEINFOA AVIFILEINFO; - alias LPAVIFILEINFOA LPAVIFILEINFO; + alias AVIFILEINFO = AVIFILEINFOA; + alias LPAVIFILEINFO = LPAVIFILEINFOA; } enum { @@ -983,7 +983,7 @@ enum { } extern (Windows) { - alias BOOL function(int) AVISAVECALLBACK; + alias AVISAVECALLBACK = BOOL function(int); } struct AVICOMPRESSOPTIONS { @@ -999,7 +999,7 @@ struct AVICOMPRESSOPTIONS { DWORD cbParms; DWORD dwInterleaveEvery; } -alias AVICOMPRESSOPTIONS* LPAVICOMPRESSOPTIONS; +alias LPAVICOMPRESSOPTIONS = AVICOMPRESSOPTIONS*; enum { AVICOMPRESSF_INTERLEAVE = 0x00000001, @@ -1512,9 +1512,9 @@ extern (Windows) { } version (Unicode) { - alias MCIWndCreateW MCIWndCreate; + alias MCIWndCreate = MCIWndCreateW; } else { // Unicode - alias MCIWndCreateA MCIWndCreate; + alias MCIWndCreate = MCIWndCreateA; } extern(Windows) { @@ -1542,9 +1542,9 @@ enum { } version (Unicode) { - alias MCIWNDF_NOTIFYMEDIAW MCIWNDF_NOTIFYMEDIA; + alias MCIWNDF_NOTIFYMEDIA = MCIWNDF_NOTIFYMEDIAW; } else { // Unicode - alias MCIWNDF_NOTIFYMEDIAA MCIWNDF_NOTIFYMEDIA; + alias MCIWNDF_NOTIFYMEDIA = MCIWNDF_NOTIFYMEDIAA; } enum { @@ -1763,29 +1763,29 @@ enum { } version (Unicode) { - alias MCIWNDM_SENDSTRINGW MCIWNDM_SENDSTRING; - alias MCIWNDM_GETPOSITIONW MCIWNDM_GETPOSITION; - alias MCIWNDM_GETMODEW MCIWNDM_GETMODE; - alias MCIWNDM_SETTIMEFORMATW MCIWNDM_SETTIMEFORMAT; - alias MCIWNDM_GETTIMEFORMATW MCIWNDM_GETTIMEFORMAT; - alias MCIWNDM_GETFILENAMEW MCIWNDM_GETFILENAME; - alias MCIWNDM_GETDEVICEW MCIWNDM_GETDEVICE; - alias MCIWNDM_GETERRORW MCIWNDM_GETERROR; - alias MCIWNDM_NEWW MCIWNDM_NEW; - alias MCIWNDM_RETURNSTRINGW MCIWNDM_RETURNSTRING; - alias MCIWNDM_OPENW MCIWNDM_OPEN; + alias MCIWNDM_SENDSTRING = MCIWNDM_SENDSTRINGW; + alias MCIWNDM_GETPOSITION = MCIWNDM_GETPOSITIONW; + alias MCIWNDM_GETMODE = MCIWNDM_GETMODEW; + alias MCIWNDM_SETTIMEFORMAT = MCIWNDM_SETTIMEFORMATW; + alias MCIWNDM_GETTIMEFORMAT = MCIWNDM_GETTIMEFORMATW; + alias MCIWNDM_GETFILENAME = MCIWNDM_GETFILENAMEW; + alias MCIWNDM_GETDEVICE = MCIWNDM_GETDEVICEW; + alias MCIWNDM_GETERROR = MCIWNDM_GETERRORW; + alias MCIWNDM_NEW = MCIWNDM_NEWW; + alias MCIWNDM_RETURNSTRING = MCIWNDM_RETURNSTRINGW; + alias MCIWNDM_OPEN = MCIWNDM_OPENW; } else { // Unicode - alias MCIWNDM_SENDSTRINGA MCIWNDM_SENDSTRING; - alias MCIWNDM_GETPOSITIONA MCIWNDM_GETPOSITION; - alias MCIWNDM_GETMODEA MCIWNDM_GETMODE; - alias MCIWNDM_SETTIMEFORMATA MCIWNDM_SETTIMEFORMAT; - alias MCIWNDM_GETTIMEFORMATA MCIWNDM_GETTIMEFORMAT; - alias MCIWNDM_GETFILENAMEA MCIWNDM_GETFILENAME; - alias MCIWNDM_GETDEVICEA MCIWNDM_GETDEVICE; - alias MCIWNDM_GETERRORA MCIWNDM_GETERROR; - alias MCIWNDM_NEWA MCIWNDM_NEW; - alias MCIWNDM_RETURNSTRINGA MCIWNDM_RETURNSTRING; - alias MCIWNDM_OPENA MCIWNDM_OPEN; + alias MCIWNDM_SENDSTRING = MCIWNDM_SENDSTRINGA; + alias MCIWNDM_GETPOSITION = MCIWNDM_GETPOSITIONA; + alias MCIWNDM_GETMODE = MCIWNDM_GETMODEA; + alias MCIWNDM_SETTIMEFORMAT = MCIWNDM_SETTIMEFORMATA; + alias MCIWNDM_GETTIMEFORMAT = MCIWNDM_GETTIMEFORMATA; + alias MCIWNDM_GETFILENAME = MCIWNDM_GETFILENAMEA; + alias MCIWNDM_GETDEVICE = MCIWNDM_GETDEVICEA; + alias MCIWNDM_GETERROR = MCIWNDM_GETERRORA; + alias MCIWNDM_NEW = MCIWNDM_NEWA; + alias MCIWNDM_RETURNSTRING = MCIWNDM_RETURNSTRINGA; + alias MCIWNDM_OPEN = MCIWNDM_OPENA; } enum { @@ -1825,8 +1825,8 @@ enum { MCI_MODE_OPEN, } -alias HANDLE HVIDEO; -alias HVIDEO* LPHVIDEO; +alias HVIDEO = HANDLE; +alias LPHVIDEO = HVIDEO*; // Error Return Values @@ -1894,7 +1894,7 @@ struct VIDEOHDR { DWORD dwFlags; DWORD_PTR[4]dwReserved; } -alias VIDEOHDR* PVIDEOHDR, LPVIDEOHDR; +alias PVIDEOHDR = VIDEOHDR*, LPVIDEOHDR = VIDEOHDR*; enum { VHDR_DONE = 0x00000001, @@ -1915,7 +1915,7 @@ struct CHANNEL_CAPS { DWORD dwDstRectWidthMod; DWORD dwDstRectHeightMod; } -alias CHANNEL_CAPS* PCHANNEL_CAPS, LPCHANNEL_CAPS; +alias PCHANNEL_CAPS = CHANNEL_CAPS*, LPCHANNEL_CAPS = CHANNEL_CAPS*; enum { VCAPS_OVERLAY = 0x00000001, @@ -1986,11 +1986,11 @@ enum { } version (Unicode) { - alias WM_CAP_SET_CALLBACK_ERRORW WM_CAP_SET_CALLBACK_ERROR; - alias WM_CAP_SET_CALLBACK_STATUSW WM_CAP_SET_CALLBACK_STATUS; + alias WM_CAP_SET_CALLBACK_ERROR = WM_CAP_SET_CALLBACK_ERRORW; + alias WM_CAP_SET_CALLBACK_STATUS = WM_CAP_SET_CALLBACK_STATUSW; } else { // Unicode - alias WM_CAP_SET_CALLBACK_ERRORA WM_CAP_SET_CALLBACK_ERROR; - alias WM_CAP_SET_CALLBACK_STATUSA WM_CAP_SET_CALLBACK_STATUS; + alias WM_CAP_SET_CALLBACK_ERROR = WM_CAP_SET_CALLBACK_ERRORA; + alias WM_CAP_SET_CALLBACK_STATUS = WM_CAP_SET_CALLBACK_STATUSA; } enum { @@ -2010,11 +2010,11 @@ enum { } version (Unicode) { - alias WM_CAP_DRIVER_GET_NAMEW WM_CAP_DRIVER_GET_NAME; - alias WM_CAP_DRIVER_GET_VERSIONW WM_CAP_DRIVER_GET_VERSION; + alias WM_CAP_DRIVER_GET_NAME = WM_CAP_DRIVER_GET_NAMEW; + alias WM_CAP_DRIVER_GET_VERSION = WM_CAP_DRIVER_GET_VERSIONW; } else { // Unicode - alias WM_CAP_DRIVER_GET_NAMEA WM_CAP_DRIVER_GET_NAME; - alias WM_CAP_DRIVER_GET_VERSIONA WM_CAP_DRIVER_GET_VERSION; + alias WM_CAP_DRIVER_GET_NAME = WM_CAP_DRIVER_GET_NAMEA; + alias WM_CAP_DRIVER_GET_VERSION = WM_CAP_DRIVER_GET_VERSIONA; } enum { @@ -2031,15 +2031,15 @@ enum { } version (Unicode) { - alias WM_CAP_FILE_SET_CAPTURE_FILEW WM_CAP_FILE_SET_CAPTURE_FILE; - alias WM_CAP_FILE_GET_CAPTURE_FILEW WM_CAP_FILE_GET_CAPTURE_FILE; - alias WM_CAP_FILE_SAVEASW WM_CAP_FILE_SAVEAS; - alias WM_CAP_FILE_SAVEDIBW WM_CAP_FILE_SAVEDIB; + alias WM_CAP_FILE_SET_CAPTURE_FILE = WM_CAP_FILE_SET_CAPTURE_FILEW; + alias WM_CAP_FILE_GET_CAPTURE_FILE = WM_CAP_FILE_GET_CAPTURE_FILEW; + alias WM_CAP_FILE_SAVEAS = WM_CAP_FILE_SAVEASW; + alias WM_CAP_FILE_SAVEDIB = WM_CAP_FILE_SAVEDIBW; } else { // Unicode - alias WM_CAP_FILE_SET_CAPTURE_FILEA WM_CAP_FILE_SET_CAPTURE_FILE; - alias WM_CAP_FILE_GET_CAPTURE_FILEA WM_CAP_FILE_GET_CAPTURE_FILE; - alias WM_CAP_FILE_SAVEASA WM_CAP_FILE_SAVEAS; - alias WM_CAP_FILE_SAVEDIBA WM_CAP_FILE_SAVEDIB; + alias WM_CAP_FILE_SET_CAPTURE_FILE = WM_CAP_FILE_SET_CAPTURE_FILEA; + alias WM_CAP_FILE_GET_CAPTURE_FILE = WM_CAP_FILE_GET_CAPTURE_FILEA; + alias WM_CAP_FILE_SAVEAS = WM_CAP_FILE_SAVEASA; + alias WM_CAP_FILE_SAVEDIB = WM_CAP_FILE_SAVEDIBA; } enum { @@ -2074,11 +2074,11 @@ enum { } version (Unicode) { - alias WM_CAP_SET_MCI_DEVICEW WM_CAP_SET_MCI_DEVICE; - alias WM_CAP_GET_MCI_DEVICEW WM_CAP_GET_MCI_DEVICE; + alias WM_CAP_SET_MCI_DEVICE = WM_CAP_SET_MCI_DEVICEW; + alias WM_CAP_GET_MCI_DEVICE = WM_CAP_GET_MCI_DEVICEW; } else { // Unicode - alias WM_CAP_SET_MCI_DEVICEA WM_CAP_SET_MCI_DEVICE; - alias WM_CAP_GET_MCI_DEVICEA WM_CAP_GET_MCI_DEVICE; + alias WM_CAP_SET_MCI_DEVICE = WM_CAP_SET_MCI_DEVICEA; + alias WM_CAP_GET_MCI_DEVICE = WM_CAP_GET_MCI_DEVICEA; } enum { @@ -2095,11 +2095,11 @@ enum { } version (Unicode) { - alias WM_CAP_PAL_OPENW WM_CAP_PAL_OPEN; - alias WM_CAP_PAL_SAVEW WM_CAP_PAL_SAVE; + alias WM_CAP_PAL_OPEN = WM_CAP_PAL_OPENW; + alias WM_CAP_PAL_SAVE = WM_CAP_PAL_SAVEW; } else { // Unicode - alias WM_CAP_PAL_OPENA WM_CAP_PAL_OPEN; - alias WM_CAP_PAL_SAVEA WM_CAP_PAL_SAVE; + alias WM_CAP_PAL_OPEN = WM_CAP_PAL_OPENA; + alias WM_CAP_PAL_SAVE = WM_CAP_PAL_SAVEA; } enum { @@ -2202,7 +2202,7 @@ struct CAPDRIVERCAPS { HANDLE hVideoExtIn; HANDLE hVideoExtOut; } -alias CAPDRIVERCAPS* PCAPDRIVERCAPS, LPCAPDRIVERCAPS; +alias PCAPDRIVERCAPS = CAPDRIVERCAPS*, LPCAPDRIVERCAPS = CAPDRIVERCAPS*; struct CAPSTATUS { UINT uiImageWidth; @@ -2224,7 +2224,7 @@ struct CAPSTATUS { UINT wNumVideoAllocated; UINT wNumAudioAllocated; } -alias CAPSTATUS* PCAPSTATUS, LPCAPSTATUS; +alias PCAPSTATUS = CAPSTATUS*, LPCAPSTATUS = CAPSTATUS*; struct CAPTUREPARMS { DWORD dwRequestMicroSecPerFrame; @@ -2252,7 +2252,7 @@ struct CAPTUREPARMS { BOOL fDisableWriteCache; UINT AVStreamMaster; } -alias CAPTUREPARMS* PCAPTUREPARMS, LPCAPTUREPARMS; +alias PCAPTUREPARMS = CAPTUREPARMS*, LPCAPTUREPARMS = CAPTUREPARMS*; enum AVSTREAMMASTER_AUDIO = 0; enum AVSTREAMMASTER_NONE = 1; @@ -2262,30 +2262,30 @@ struct CAPINFOCHUNK { LPVOID lpData; LONG cbData; } -alias CAPINFOCHUNK* PCAPINFOCHUNK, LPCAPINFOCHUNK; +alias PCAPINFOCHUNK = CAPINFOCHUNK*, LPCAPINFOCHUNK = CAPINFOCHUNK*; // Callback Definitions extern (Windows) { - alias LRESULT function(HWND hWnd) CAPYIELDCALLBACK; - alias LRESULT function(HWND hWnd, int nID, LPCWSTR lpsz) CAPSTATUSCALLBACKW; - alias LRESULT function(HWND hWnd, int nID, LPCWSTR lpsz) CAPERRORCALLBACKW; - alias LRESULT function(HWND hWnd, int nID, LPCSTR lpsz) CAPSTATUSCALLBACKA; - alias LRESULT function(HWND hWnd, int nID, LPCSTR lpsz) CAPERRORCALLBACKA; + alias CAPYIELDCALLBACK = LRESULT function(HWND hWnd); + alias CAPSTATUSCALLBACKW = LRESULT function(HWND hWnd, int nID, LPCWSTR lpsz); + alias CAPERRORCALLBACKW = LRESULT function(HWND hWnd, int nID, LPCWSTR lpsz); + alias CAPSTATUSCALLBACKA = LRESULT function(HWND hWnd, int nID, LPCSTR lpsz); + alias CAPERRORCALLBACKA = LRESULT function(HWND hWnd, int nID, LPCSTR lpsz); } version (Unicode) { - alias CAPSTATUSCALLBACKW CAPSTATUSCALLBACK; - alias CAPERRORCALLBACKW CAPERRORCALLBACK; + alias CAPSTATUSCALLBACK = CAPSTATUSCALLBACKW; + alias CAPERRORCALLBACK = CAPERRORCALLBACKW; } else { // Unicode - alias CAPSTATUSCALLBACKA CAPSTATUSCALLBACK; - alias CAPERRORCALLBACKA CAPERRORCALLBACK; + alias CAPSTATUSCALLBACK = CAPSTATUSCALLBACKA; + alias CAPERRORCALLBACK = CAPERRORCALLBACKA; } extern (Windows) { - alias LRESULT function(HWND hWnd, LPVIDEOHDR lpVHdr) CAPVIDEOCALLBACK; - alias LRESULT function(HWND hWnd, LPWAVEHDR lpWHdr) CAPWAVECALLBACK; - alias LRESULT function(HWND hWnd, int nState) CAPCONTROLCALLBACK; + alias CAPVIDEOCALLBACK = LRESULT function(HWND hWnd, LPVIDEOHDR lpVHdr); + alias CAPWAVECALLBACK = LRESULT function(HWND hWnd, LPWAVEHDR lpWHdr); + alias CAPCONTROLCALLBACK = LRESULT function(HWND hWnd, int nState); } // CapControlCallback states @@ -2300,11 +2300,11 @@ extern (Windows) { } version (Unicode) { - alias capCreateCaptureWindowW capCreateCaptureWindow; - alias capGetDriverDescriptionW capGetDriverDescription; + alias capCreateCaptureWindow = capCreateCaptureWindowW; + alias capGetDriverDescription = capGetDriverDescriptionW; } else { // Unicode - alias capCreateCaptureWindowA capCreateCaptureWindow; - alias capGetDriverDescriptionA capGetDriverDescription; + alias capCreateCaptureWindow = capCreateCaptureWindowA; + alias capGetDriverDescription = capGetDriverDescriptionA; } // New Information chunk IDs @@ -2392,9 +2392,9 @@ extern (Windows) { } version (Unicode) { - alias GetOpenFileNamePreviewW GetOpenFileNamePreview; - alias GetSaveFileNamePreviewW GetSaveFileNamePreview; + alias GetOpenFileNamePreview = GetOpenFileNamePreviewW; + alias GetSaveFileNamePreview = GetSaveFileNamePreviewW; } else { // Unicode - alias GetOpenFileNamePreviewA GetOpenFileNamePreview; - alias GetSaveFileNamePreviewA GetSaveFileNamePreview; + alias GetOpenFileNamePreview = GetOpenFileNamePreviewA; + alias GetSaveFileNamePreview = GetSaveFileNamePreviewA; } diff --git a/runtime/druntime/src/core/sys/windows/winbase.d b/runtime/druntime/src/core/sys/windows/winbase.d index 2c2905b635..0a5a4c8a51 100644 --- a/runtime/druntime/src/core/sys/windows/winbase.d +++ b/runtime/druntime/src/core/sys/windows/winbase.d @@ -154,7 +154,7 @@ struct COMMPROP { WCHAR* wcProvChar() return { return &_wcProvChar; } } -alias COMMPROP* LPCOMMPROP; +alias LPCOMMPROP = COMMPROP*; // ---------- @@ -907,7 +907,7 @@ struct FILETIME { DWORD dwLowDateTime; DWORD dwHighDateTime; } -alias FILETIME* PFILETIME, LPFILETIME; +alias PFILETIME = FILETIME*, LPFILETIME = FILETIME*; struct BY_HANDLE_FILE_INFORMATION { DWORD dwFileAttributes; @@ -921,7 +921,7 @@ struct BY_HANDLE_FILE_INFORMATION { DWORD nFileIndexHigh; DWORD nFileIndexLow; } -alias BY_HANDLE_FILE_INFORMATION* LPBY_HANDLE_FILE_INFORMATION; +alias LPBY_HANDLE_FILE_INFORMATION = BY_HANDLE_FILE_INFORMATION*; struct DCB { DWORD DCBlength = DCB.sizeof; @@ -984,7 +984,7 @@ struct DCB { char EvtChar = 0; WORD wReserved1; } -alias DCB* LPDCB; +alias LPDCB = DCB*; struct COMMCONFIG { DWORD dwSize = COMMCONFIG.sizeof; @@ -998,7 +998,7 @@ struct COMMCONFIG { WCHAR* wcProviderData() return { return &_wcProviderData; } } -alias COMMCONFIG* LPCOMMCONFIG; +alias LPCOMMCONFIG = COMMCONFIG*; struct COMMTIMEOUTS { DWORD ReadIntervalTimeout; @@ -1007,7 +1007,7 @@ struct COMMTIMEOUTS { DWORD WriteTotalTimeoutMultiplier; DWORD WriteTotalTimeoutConstant; } -alias COMMTIMEOUTS* LPCOMMTIMEOUTS; +alias LPCOMMTIMEOUTS = COMMTIMEOUTS*; struct COMSTAT { /+ @@ -1040,7 +1040,7 @@ struct COMSTAT { DWORD cbInQue; DWORD cbOutQue; } -alias COMSTAT* LPCOMSTAT; +alias LPCOMSTAT = COMSTAT*; struct CREATE_PROCESS_DEBUG_INFO { HANDLE hFile; @@ -1054,30 +1054,30 @@ struct CREATE_PROCESS_DEBUG_INFO { LPVOID lpImageName; WORD fUnicode; } -alias CREATE_PROCESS_DEBUG_INFO* LPCREATE_PROCESS_DEBUG_INFO; +alias LPCREATE_PROCESS_DEBUG_INFO = CREATE_PROCESS_DEBUG_INFO*; struct CREATE_THREAD_DEBUG_INFO { HANDLE hThread; LPVOID lpThreadLocalBase; LPTHREAD_START_ROUTINE lpStartAddress; } -alias CREATE_THREAD_DEBUG_INFO* LPCREATE_THREAD_DEBUG_INFO; +alias LPCREATE_THREAD_DEBUG_INFO = CREATE_THREAD_DEBUG_INFO*; struct EXCEPTION_DEBUG_INFO { EXCEPTION_RECORD ExceptionRecord; DWORD dwFirstChance; } -alias EXCEPTION_DEBUG_INFO* LPEXCEPTION_DEBUG_INFO; +alias LPEXCEPTION_DEBUG_INFO = EXCEPTION_DEBUG_INFO*; struct EXIT_THREAD_DEBUG_INFO { DWORD dwExitCode; } -alias EXIT_THREAD_DEBUG_INFO* LPEXIT_THREAD_DEBUG_INFO; +alias LPEXIT_THREAD_DEBUG_INFO = EXIT_THREAD_DEBUG_INFO*; struct EXIT_PROCESS_DEBUG_INFO { DWORD dwExitCode; } -alias EXIT_PROCESS_DEBUG_INFO* LPEXIT_PROCESS_DEBUG_INFO; +alias LPEXIT_PROCESS_DEBUG_INFO = EXIT_PROCESS_DEBUG_INFO*; struct LOAD_DLL_DEBUG_INFO { HANDLE hFile; @@ -1087,25 +1087,25 @@ struct LOAD_DLL_DEBUG_INFO { LPVOID lpImageName; WORD fUnicode; } -alias LOAD_DLL_DEBUG_INFO* LPLOAD_DLL_DEBUG_INFO; +alias LPLOAD_DLL_DEBUG_INFO = LOAD_DLL_DEBUG_INFO*; struct UNLOAD_DLL_DEBUG_INFO { LPVOID lpBaseOfDll; } -alias UNLOAD_DLL_DEBUG_INFO* LPUNLOAD_DLL_DEBUG_INFO; +alias LPUNLOAD_DLL_DEBUG_INFO = UNLOAD_DLL_DEBUG_INFO*; struct OUTPUT_DEBUG_STRING_INFO { LPSTR lpDebugStringData; WORD fUnicode; WORD nDebugStringLength; } -alias OUTPUT_DEBUG_STRING_INFO* LPOUTPUT_DEBUG_STRING_INFO; +alias LPOUTPUT_DEBUG_STRING_INFO = OUTPUT_DEBUG_STRING_INFO*; struct RIP_INFO { DWORD dwError; DWORD dwType; } -alias RIP_INFO* LPRIP_INFO; +alias LPRIP_INFO = RIP_INFO*; struct DEBUG_EVENT { DWORD dwDebugEventCode; @@ -1123,7 +1123,7 @@ struct DEBUG_EVENT { RIP_INFO RipInfo; } } -alias DEBUG_EVENT* LPDEBUG_EVENT; +alias LPDEBUG_EVENT = DEBUG_EVENT*; struct OVERLAPPED { ULONG_PTR Internal; @@ -1137,7 +1137,7 @@ struct OVERLAPPED { } HANDLE hEvent; } -alias OVERLAPPED* POVERLAPPED, LPOVERLAPPED; +alias POVERLAPPED = OVERLAPPED*, LPOVERLAPPED = OVERLAPPED*; struct STARTUPINFOA { DWORD cb = STARTUPINFOA.sizeof; @@ -1159,7 +1159,7 @@ struct STARTUPINFOA { HANDLE hStdOutput; HANDLE hStdError; } -alias STARTUPINFOA* LPSTARTUPINFOA; +alias LPSTARTUPINFOA = STARTUPINFOA*; struct STARTUPINFOW { DWORD cb = STARTUPINFOW.sizeof; @@ -1181,8 +1181,8 @@ struct STARTUPINFOW { HANDLE hStdOutput; HANDLE hStdError; } -alias STARTUPINFOW STARTUPINFO_W; -alias STARTUPINFOW* LPSTARTUPINFOW, LPSTARTUPINFO_W; +alias STARTUPINFO_W = STARTUPINFOW; +alias LPSTARTUPINFOW = STARTUPINFOW*, LPSTARTUPINFO_W = STARTUPINFOW*; struct PROCESS_INFORMATION { HANDLE hProcess; @@ -1190,7 +1190,7 @@ struct PROCESS_INFORMATION { DWORD dwProcessId; DWORD dwThreadId; } -alias PROCESS_INFORMATION* PPROCESS_INFORMATION, LPPROCESS_INFORMATION; +alias PPROCESS_INFORMATION = PROCESS_INFORMATION*, LPPROCESS_INFORMATION = PROCESS_INFORMATION*; /* struct CRITICAL_SECTION_DEBUG { @@ -1216,10 +1216,10 @@ alias CRITICAL_SECTION* PCRITICAL_SECTION, LPCRITICAL_SECTION; */ alias CRITICAL_SECTION_DEBUG = RTL_CRITICAL_SECTION_DEBUG; -alias CRITICAL_SECTION_DEBUG* PCRITICAL_SECTION_DEBUG; +alias PCRITICAL_SECTION_DEBUG = CRITICAL_SECTION_DEBUG*; alias CRITICAL_SECTION = RTL_CRITICAL_SECTION; -alias CRITICAL_SECTION* PCRITICAL_SECTION, LPCRITICAL_SECTION; +alias PCRITICAL_SECTION = CRITICAL_SECTION*, LPCRITICAL_SECTION = CRITICAL_SECTION*; struct SYSTEMTIME { WORD wYear; @@ -1231,7 +1231,7 @@ struct SYSTEMTIME { WORD wSecond; WORD wMilliseconds; } -alias SYSTEMTIME* LPSYSTEMTIME; +alias LPSYSTEMTIME = SYSTEMTIME*; struct WIN32_FILE_ATTRIBUTE_DATA { DWORD dwFileAttributes; @@ -1241,7 +1241,7 @@ struct WIN32_FILE_ATTRIBUTE_DATA { DWORD nFileSizeHigh; DWORD nFileSizeLow; } -alias WIN32_FILE_ATTRIBUTE_DATA* LPWIN32_FILE_ATTRIBUTE_DATA; +alias LPWIN32_FILE_ATTRIBUTE_DATA = WIN32_FILE_ATTRIBUTE_DATA*; struct WIN32_FIND_DATAA { DWORD dwFileAttributes; @@ -1261,7 +1261,7 @@ struct WIN32_FIND_DATAA { CHAR[14] cAlternateFileName = 0; // #endif } -alias WIN32_FIND_DATAA* PWIN32_FIND_DATAA, LPWIN32_FIND_DATAA; +alias PWIN32_FIND_DATAA = WIN32_FIND_DATAA*, LPWIN32_FIND_DATAA = WIN32_FIND_DATAA*; struct WIN32_FIND_DATAW { DWORD dwFileAttributes; @@ -1281,7 +1281,7 @@ struct WIN32_FIND_DATAW { WCHAR[14] cAlternateFileName = 0; // #endif } -alias WIN32_FIND_DATAW* PWIN32_FIND_DATAW, LPWIN32_FIND_DATAW; +alias PWIN32_FIND_DATAW = WIN32_FIND_DATAW*, LPWIN32_FIND_DATAW = WIN32_FIND_DATAW*; struct WIN32_STREAM_ID { DWORD dwStreamId; @@ -1292,7 +1292,7 @@ struct WIN32_STREAM_ID { WCHAR* cStreamName() return { return &_cStreamName; } } -alias WIN32_STREAM_ID* LPWIN32_STREAM_ID; +alias LPWIN32_STREAM_ID = WIN32_STREAM_ID*; static if (_WIN32_WINNT >= 0x601) { enum FINDEX_INFO_LEVELS { @@ -1324,14 +1324,14 @@ struct HW_PROFILE_INFOA { CHAR[HW_PROFILE_GUIDLEN] szHwProfileGuid = 0; CHAR[MAX_PROFILE_LEN] szHwProfileName = 0; } -alias HW_PROFILE_INFOA* LPHW_PROFILE_INFOA; +alias LPHW_PROFILE_INFOA = HW_PROFILE_INFOA*; struct HW_PROFILE_INFOW { DWORD dwDockInfo; WCHAR[HW_PROFILE_GUIDLEN] szHwProfileGuid = 0; WCHAR[MAX_PROFILE_LEN] szHwProfileName = 0; } -alias HW_PROFILE_INFOW* LPHW_PROFILE_INFOW; +alias LPHW_PROFILE_INFOW = HW_PROFILE_INFOW*; /* ??? MSDN documents this only for Windows CE/Mobile, but it's used by * GetFileAttributesEx, which is in desktop Windows. @@ -1404,7 +1404,7 @@ struct SYSTEM_INFO { WORD wProcessorLevel; WORD wProcessorRevision; } -alias SYSTEM_INFO* LPSYSTEM_INFO; +alias LPSYSTEM_INFO = SYSTEM_INFO*; static if (_WIN32_WINNT >= 0x500) { struct SYSTEM_POWER_STATUS { @@ -1415,7 +1415,7 @@ static if (_WIN32_WINNT >= 0x500) { DWORD BatteryLifeTime; DWORD BatteryFullLifeTime; } - alias SYSTEM_POWER_STATUS* LPSYSTEM_POWER_STATUS; + alias LPSYSTEM_POWER_STATUS = SYSTEM_POWER_STATUS*; } struct TIME_ZONE_INFORMATION { @@ -1427,7 +1427,7 @@ struct TIME_ZONE_INFORMATION { SYSTEMTIME DaylightDate; LONG DaylightBias; } -alias TIME_ZONE_INFORMATION* LPTIME_ZONE_INFORMATION; +alias LPTIME_ZONE_INFORMATION = TIME_ZONE_INFORMATION*; // Does not exist in Windows headers, only MSDN // documentation (for TIME_ZONE_INFORMATION). @@ -1452,7 +1452,7 @@ struct MEMORYSTATUS { SIZE_T dwTotalVirtual; SIZE_T dwAvailVirtual; } -alias MEMORYSTATUS* LPMEMORYSTATUS; +alias LPMEMORYSTATUS = MEMORYSTATUS*; static if (_WIN32_WINNT >= 0x500) { struct MEMORYSTATUSEX { @@ -1466,7 +1466,7 @@ static if (_WIN32_WINNT >= 0x500) { DWORDLONG ullAvailVirtual; DWORDLONG ullAvailExtendedVirtual; } - alias MEMORYSTATUSEX* LPMEMORYSTATUSEX; + alias LPMEMORYSTATUSEX = MEMORYSTATUSEX*; } struct LDT_ENTRY { @@ -1520,7 +1520,7 @@ struct LDT_ENTRY { } +/ } -alias LDT_ENTRY* PLDT_ENTRY, LPLDT_ENTRY; +alias PLDT_ENTRY = LDT_ENTRY*, LPLDT_ENTRY = LDT_ENTRY*; /* As with the other memory management functions and structures, MSDN's * Windows version info shall be taken with a cup of salt. @@ -1546,7 +1546,7 @@ struct PROCESS_HEAP_ENTRY { _Region Region; } } -alias PROCESS_HEAP_ENTRY* LPPROCESS_HEAP_ENTRY; +alias LPPROCESS_HEAP_ENTRY = PROCESS_HEAP_ENTRY*; struct OFSTRUCT { BYTE cBytes = OFSTRUCT.sizeof; @@ -1556,7 +1556,7 @@ struct OFSTRUCT { WORD Reserved2; CHAR[128] szPathName = 0; // const OFS_MAXPATHNAME = 128; } -alias OFSTRUCT* LPOFSTRUCT, POFSTRUCT; +alias LPOFSTRUCT = OFSTRUCT*, POFSTRUCT = OFSTRUCT*; /* ??? MSDN documents this only for Windows CE, but it's used by * ImageGetCertificateData, which is in desktop Windows. @@ -1569,7 +1569,7 @@ struct WIN_CERTIFICATE { BYTE* bCertificate() return { return &_bCertificate; } } -alias WIN_CERTIFICATE* LPWIN_CERTIFICATE; +alias LPWIN_CERTIFICATE = WIN_CERTIFICATE*; static if (_WIN32_WINNT >= 0x500) { enum COMPUTER_NAME_FORMAT { @@ -1597,8 +1597,8 @@ static if (_WIN32_WINNT >= 0x501) { LPCSTR lpApplicationName; HMODULE hModule; } - alias ACTCTXA* PACTCTXA; - alias const(ACTCTXA)* PCACTCTXA; + alias PACTCTXA = ACTCTXA*; + alias PCACTCTXA = const(ACTCTXA)*; struct ACTCTXW { ULONG cbSize = this.sizeof; @@ -1611,8 +1611,8 @@ static if (_WIN32_WINNT >= 0x501) { LPCWSTR lpApplicationName; HMODULE hModule; } - alias ACTCTXW* PACTCTXW; - alias const(ACTCTXW)* PCACTCTXW; + alias PACTCTXW = ACTCTXW*; + alias PCACTCTXW = const(ACTCTXW)*; struct ACTCTX_SECTION_KEYED_DATA { ULONG cbSize = this.sizeof; @@ -1626,8 +1626,8 @@ static if (_WIN32_WINNT >= 0x501) { HANDLE hActCtx; HANDLE ulAssemblyRosterIndex; } - alias ACTCTX_SECTION_KEYED_DATA* PACTCTX_SECTION_KEYED_DATA; - alias const(ACTCTX_SECTION_KEYED_DATA)* PCACTCTX_SECTION_KEYED_DATA; + alias PACTCTX_SECTION_KEYED_DATA = ACTCTX_SECTION_KEYED_DATA*; + alias PCACTCTX_SECTION_KEYED_DATA = const(ACTCTX_SECTION_KEYED_DATA)*; enum MEMORY_RESOURCE_NOTIFICATION_TYPE { LowMemoryResourceNotification, @@ -1640,7 +1640,7 @@ static if (_WIN32_WINNT >= 0x410) { /* apparently used only by SetThreadExecutionState (Win2000+) * and DDK functions (version compatibility not established) */ - alias DWORD EXECUTION_STATE; + alias EXECUTION_STATE = DWORD; } // CreateSymbolicLink, GetFileInformationByHandleEx @@ -1673,26 +1673,26 @@ static if (_WIN32_WINNT >= 0x600) { // Callbacks extern (Windows) { - alias DWORD function(LPVOID) LPTHREAD_START_ROUTINE; - alias DWORD function(LARGE_INTEGER, LARGE_INTEGER, LARGE_INTEGER, LARGE_INTEGER, - DWORD, DWORD, HANDLE, HANDLE, LPVOID) LPPROGRESS_ROUTINE; - alias void function(PVOID) LPFIBER_START_ROUTINE; - - alias BOOL function(HMODULE, LPCSTR, LPCSTR, WORD, LONG_PTR) ENUMRESLANGPROCA; - alias BOOL function(HMODULE, LPCWSTR, LPCWSTR, WORD, LONG_PTR) ENUMRESLANGPROCW; - alias BOOL function(HMODULE, LPCSTR, LPSTR, LONG_PTR) ENUMRESNAMEPROCA; - alias BOOL function(HMODULE, LPCWSTR, LPWSTR, LONG_PTR) ENUMRESNAMEPROCW; - alias BOOL function(HMODULE, LPSTR, LONG_PTR) ENUMRESTYPEPROCA; - alias BOOL function(HMODULE, LPWSTR, LONG_PTR) ENUMRESTYPEPROCW; - alias void function(DWORD, DWORD, LPOVERLAPPED) LPOVERLAPPED_COMPLETION_ROUTINE; - alias LONG function(LPEXCEPTION_POINTERS) PTOP_LEVEL_EXCEPTION_FILTER; - alias PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER; - - alias void function(ULONG_PTR) PAPCFUNC; - alias void function(PVOID, DWORD, DWORD) PTIMERAPCROUTINE; + alias LPTHREAD_START_ROUTINE = DWORD function(LPVOID); + alias LPPROGRESS_ROUTINE = DWORD function(LARGE_INTEGER, LARGE_INTEGER, LARGE_INTEGER, LARGE_INTEGER, + DWORD, DWORD, HANDLE, HANDLE, LPVOID); + alias LPFIBER_START_ROUTINE = void function(PVOID); + + alias ENUMRESLANGPROCA = BOOL function(HMODULE, LPCSTR, LPCSTR, WORD, LONG_PTR); + alias ENUMRESLANGPROCW = BOOL function(HMODULE, LPCWSTR, LPCWSTR, WORD, LONG_PTR); + alias ENUMRESNAMEPROCA = BOOL function(HMODULE, LPCSTR, LPSTR, LONG_PTR); + alias ENUMRESNAMEPROCW = BOOL function(HMODULE, LPCWSTR, LPWSTR, LONG_PTR); + alias ENUMRESTYPEPROCA = BOOL function(HMODULE, LPSTR, LONG_PTR); + alias ENUMRESTYPEPROCW = BOOL function(HMODULE, LPWSTR, LONG_PTR); + alias LPOVERLAPPED_COMPLETION_ROUTINE = void function(DWORD, DWORD, LPOVERLAPPED); + alias PTOP_LEVEL_EXCEPTION_FILTER = LONG function(LPEXCEPTION_POINTERS); + alias LPTOP_LEVEL_EXCEPTION_FILTER = PTOP_LEVEL_EXCEPTION_FILTER; + + alias PAPCFUNC = void function(ULONG_PTR); + alias PTIMERAPCROUTINE = void function(PVOID, DWORD, DWORD); static if (_WIN32_WINNT >= 0x500) { - alias void function(PVOID, BOOLEAN) WAITORTIMERCALLBACK; + alias WAITORTIMERCALLBACK = void function(PVOID, BOOLEAN); } } @@ -1895,7 +1895,7 @@ WINBASEAPI DWORD WINAPI GetCurrentThreadId(void); */ DWORD GetCurrentThreadId(); - alias GetTickCount GetCurrentTime; + alias GetCurrentTime = GetTickCount; BOOL GetDefaultCommConfigA(LPCSTR, LPCOMMCONFIG, PDWORD); BOOL GetDefaultCommConfigW(LPCWSTR, LPCOMMCONFIG, PDWORD); @@ -2574,368 +2574,368 @@ version (LittleEndian) nothrow @nogc mixin DECLARE_AW!("STARTUPINFO"); version (Unicode) { //alias STARTUPINFOW STARTUPINFO; - alias WIN32_FIND_DATAW WIN32_FIND_DATA; - alias ENUMRESLANGPROCW ENUMRESLANGPROC; - alias ENUMRESNAMEPROCW ENUMRESNAMEPROC; - alias ENUMRESTYPEPROCW ENUMRESTYPEPROC; - alias AddAtomW AddAtom; - alias BeginUpdateResourceW BeginUpdateResource; - alias BuildCommDCBW BuildCommDCB; - alias BuildCommDCBAndTimeoutsW BuildCommDCBAndTimeouts; - alias CallNamedPipeW CallNamedPipe; - alias CommConfigDialogW CommConfigDialog; - alias CopyFileW CopyFile; - alias CopyFileExW CopyFileEx; - alias CreateDirectoryW CreateDirectory; - alias CreateDirectoryExW CreateDirectoryEx; - alias CreateEventW CreateEvent; - alias CreateFileW CreateFile; - alias CreateMailslotW CreateMailslot; - alias CreateMutexW CreateMutex; - alias CreateProcessW CreateProcess; - alias CreateSemaphoreW CreateSemaphore; - alias DeleteFileW DeleteFile; - alias EndUpdateResourceW EndUpdateResource; - alias EnumResourceLanguagesW EnumResourceLanguages; - alias EnumResourceNamesW EnumResourceNames; - alias EnumResourceTypesW EnumResourceTypes; - alias ExpandEnvironmentStringsW ExpandEnvironmentStrings; - alias FatalAppExitW FatalAppExit; - alias FindAtomW FindAtom; - alias FindFirstChangeNotificationW FindFirstChangeNotification; - alias FindFirstFileW FindFirstFile; - alias FindNextFileW FindNextFile; - alias FindResourceW FindResource; - alias FindResourceExW FindResourceEx; - alias FormatMessageW FormatMessage; - alias FreeEnvironmentStringsW FreeEnvironmentStrings; - alias GetAtomNameW GetAtomName; - alias GetCommandLineW GetCommandLine; - alias GetComputerNameW GetComputerName; - alias GetCurrentDirectoryW GetCurrentDirectory; - alias GetDefaultCommConfigW GetDefaultCommConfig; - alias GetDiskFreeSpaceW GetDiskFreeSpace; - alias GetDiskFreeSpaceExW GetDiskFreeSpaceEx; - alias GetDriveTypeW GetDriveType; - alias GetEnvironmentStringsW GetEnvironmentStrings; - alias GetEnvironmentVariableW GetEnvironmentVariable; - alias GetFileAttributesW GetFileAttributes; - alias GetFullPathNameW GetFullPathName; - alias GetLogicalDriveStringsW GetLogicalDriveStrings; - alias GetModuleFileNameW GetModuleFileName; - alias GetModuleHandleW GetModuleHandle; - alias GetNamedPipeHandleStateW GetNamedPipeHandleState; - alias GetPrivateProfileIntW GetPrivateProfileInt; - alias GetPrivateProfileSectionW GetPrivateProfileSection; - alias GetPrivateProfileSectionNamesW GetPrivateProfileSectionNames; - alias GetPrivateProfileStringW GetPrivateProfileString; - alias GetPrivateProfileStructW GetPrivateProfileStruct; - alias GetProfileIntW GetProfileInt; - alias GetProfileSectionW GetProfileSection; - alias GetProfileStringW GetProfileString; - alias GetShortPathNameW GetShortPathName; - alias GetStartupInfoW GetStartupInfo; - alias GetSystemDirectoryW GetSystemDirectory; - alias GetTempFileNameW GetTempFileName; - alias GetTempPathW GetTempPath; - alias GetUserNameW GetUserName; - alias GetVersionExW GetVersionEx; - alias GetVolumeInformationW GetVolumeInformation; - alias GetWindowsDirectoryW GetWindowsDirectory; - alias GlobalAddAtomW GlobalAddAtom; - alias GlobalFindAtomW GlobalFindAtom; - alias GlobalGetAtomNameW GlobalGetAtomName; - alias IsBadStringPtrW IsBadStringPtr; - alias LoadLibraryW LoadLibrary; - alias LoadLibraryExW LoadLibraryEx; - alias lstrcatW lstrcat; - alias lstrcmpW lstrcmp; - alias lstrcmpiW lstrcmpi; - alias lstrcpyW lstrcpy; - alias lstrcpynW lstrcpyn; - alias lstrlenW lstrlen; - alias MoveFileW MoveFile; - alias OpenEventW OpenEvent; - alias OpenMutexW OpenMutex; - alias OpenSemaphoreW OpenSemaphore; - alias OutputDebugStringW OutputDebugString; - alias RemoveDirectoryW RemoveDirectory; - alias SearchPathW SearchPath; - alias SetComputerNameW SetComputerName; - alias SetCurrentDirectoryW SetCurrentDirectory; - alias SetDefaultCommConfigW SetDefaultCommConfig; - alias SetEnvironmentVariableW SetEnvironmentVariable; - alias SetFileAttributesW SetFileAttributes; - alias SetVolumeLabelW SetVolumeLabel; - alias WaitNamedPipeW WaitNamedPipe; - alias WritePrivateProfileSectionW WritePrivateProfileSection; - alias WritePrivateProfileStringW WritePrivateProfileString; - alias WritePrivateProfileStructW WritePrivateProfileStruct; - alias WriteProfileSectionW WriteProfileSection; - alias WriteProfileStringW WriteProfileString; - alias CreateWaitableTimerW CreateWaitableTimer; - alias GetFileAttributesExW GetFileAttributesEx; - alias GetLongPathNameW GetLongPathName; - alias QueryDosDeviceW QueryDosDevice; - - alias HW_PROFILE_INFOW HW_PROFILE_INFO; - alias AccessCheckAndAuditAlarmW AccessCheckAndAuditAlarm; - alias BackupEventLogW BackupEventLog; - alias ClearEventLogW ClearEventLog; - alias CreateNamedPipeW CreateNamedPipe; - alias CreateProcessAsUserW CreateProcessAsUser; - alias DefineDosDeviceW DefineDosDevice; - alias FindFirstFileExW FindFirstFileEx; - alias GetBinaryTypeW GetBinaryType; - alias GetCompressedFileSizeW GetCompressedFileSize; - alias GetFileSecurityW GetFileSecurity; - alias LogonUserW LogonUser; - alias LookupAccountNameW LookupAccountName; - alias LookupAccountSidW LookupAccountSid; - alias LookupPrivilegeDisplayNameW LookupPrivilegeDisplayName; - alias LookupPrivilegeNameW LookupPrivilegeName; - alias LookupPrivilegeValueW LookupPrivilegeValue; - alias MoveFileExW MoveFileEx; - alias ObjectCloseAuditAlarmW ObjectCloseAuditAlarm; - alias ObjectDeleteAuditAlarmW ObjectDeleteAuditAlarm; - alias ObjectOpenAuditAlarmW ObjectOpenAuditAlarm; - alias ObjectPrivilegeAuditAlarmW ObjectPrivilegeAuditAlarm; - alias OpenBackupEventLogW OpenBackupEventLog; - alias OpenEventLogW OpenEventLog; - alias PrivilegedServiceAuditAlarmW PrivilegedServiceAuditAlarm; - alias ReadEventLogW ReadEventLog; - alias RegisterEventSourceW RegisterEventSource; - alias ReportEventW ReportEvent; - alias SetFileSecurityW SetFileSecurity; - alias UpdateResourceW UpdateResource; + alias WIN32_FIND_DATA = WIN32_FIND_DATAW; + alias ENUMRESLANGPROC = ENUMRESLANGPROCW; + alias ENUMRESNAMEPROC = ENUMRESNAMEPROCW; + alias ENUMRESTYPEPROC = ENUMRESTYPEPROCW; + alias AddAtom = AddAtomW; + alias BeginUpdateResource = BeginUpdateResourceW; + alias BuildCommDCB = BuildCommDCBW; + alias BuildCommDCBAndTimeouts = BuildCommDCBAndTimeoutsW; + alias CallNamedPipe = CallNamedPipeW; + alias CommConfigDialog = CommConfigDialogW; + alias CopyFile = CopyFileW; + alias CopyFileEx = CopyFileExW; + alias CreateDirectory = CreateDirectoryW; + alias CreateDirectoryEx = CreateDirectoryExW; + alias CreateEvent = CreateEventW; + alias CreateFile = CreateFileW; + alias CreateMailslot = CreateMailslotW; + alias CreateMutex = CreateMutexW; + alias CreateProcess = CreateProcessW; + alias CreateSemaphore = CreateSemaphoreW; + alias DeleteFile = DeleteFileW; + alias EndUpdateResource = EndUpdateResourceW; + alias EnumResourceLanguages = EnumResourceLanguagesW; + alias EnumResourceNames = EnumResourceNamesW; + alias EnumResourceTypes = EnumResourceTypesW; + alias ExpandEnvironmentStrings = ExpandEnvironmentStringsW; + alias FatalAppExit = FatalAppExitW; + alias FindAtom = FindAtomW; + alias FindFirstChangeNotification = FindFirstChangeNotificationW; + alias FindFirstFile = FindFirstFileW; + alias FindNextFile = FindNextFileW; + alias FindResource = FindResourceW; + alias FindResourceEx = FindResourceExW; + alias FormatMessage = FormatMessageW; + alias FreeEnvironmentStrings = FreeEnvironmentStringsW; + alias GetAtomName = GetAtomNameW; + alias GetCommandLine = GetCommandLineW; + alias GetComputerName = GetComputerNameW; + alias GetCurrentDirectory = GetCurrentDirectoryW; + alias GetDefaultCommConfig = GetDefaultCommConfigW; + alias GetDiskFreeSpace = GetDiskFreeSpaceW; + alias GetDiskFreeSpaceEx = GetDiskFreeSpaceExW; + alias GetDriveType = GetDriveTypeW; + alias GetEnvironmentStrings = GetEnvironmentStringsW; + alias GetEnvironmentVariable = GetEnvironmentVariableW; + alias GetFileAttributes = GetFileAttributesW; + alias GetFullPathName = GetFullPathNameW; + alias GetLogicalDriveStrings = GetLogicalDriveStringsW; + alias GetModuleFileName = GetModuleFileNameW; + alias GetModuleHandle = GetModuleHandleW; + alias GetNamedPipeHandleState = GetNamedPipeHandleStateW; + alias GetPrivateProfileInt = GetPrivateProfileIntW; + alias GetPrivateProfileSection = GetPrivateProfileSectionW; + alias GetPrivateProfileSectionNames = GetPrivateProfileSectionNamesW; + alias GetPrivateProfileString = GetPrivateProfileStringW; + alias GetPrivateProfileStruct = GetPrivateProfileStructW; + alias GetProfileInt = GetProfileIntW; + alias GetProfileSection = GetProfileSectionW; + alias GetProfileString = GetProfileStringW; + alias GetShortPathName = GetShortPathNameW; + alias GetStartupInfo = GetStartupInfoW; + alias GetSystemDirectory = GetSystemDirectoryW; + alias GetTempFileName = GetTempFileNameW; + alias GetTempPath = GetTempPathW; + alias GetUserName = GetUserNameW; + alias GetVersionEx = GetVersionExW; + alias GetVolumeInformation = GetVolumeInformationW; + alias GetWindowsDirectory = GetWindowsDirectoryW; + alias GlobalAddAtom = GlobalAddAtomW; + alias GlobalFindAtom = GlobalFindAtomW; + alias GlobalGetAtomName = GlobalGetAtomNameW; + alias IsBadStringPtr = IsBadStringPtrW; + alias LoadLibrary = LoadLibraryW; + alias LoadLibraryEx = LoadLibraryExW; + alias lstrcat = lstrcatW; + alias lstrcmp = lstrcmpW; + alias lstrcmpi = lstrcmpiW; + alias lstrcpy = lstrcpyW; + alias lstrcpyn = lstrcpynW; + alias lstrlen = lstrlenW; + alias MoveFile = MoveFileW; + alias OpenEvent = OpenEventW; + alias OpenMutex = OpenMutexW; + alias OpenSemaphore = OpenSemaphoreW; + alias OutputDebugString = OutputDebugStringW; + alias RemoveDirectory = RemoveDirectoryW; + alias SearchPath = SearchPathW; + alias SetComputerName = SetComputerNameW; + alias SetCurrentDirectory = SetCurrentDirectoryW; + alias SetDefaultCommConfig = SetDefaultCommConfigW; + alias SetEnvironmentVariable = SetEnvironmentVariableW; + alias SetFileAttributes = SetFileAttributesW; + alias SetVolumeLabel = SetVolumeLabelW; + alias WaitNamedPipe = WaitNamedPipeW; + alias WritePrivateProfileSection = WritePrivateProfileSectionW; + alias WritePrivateProfileString = WritePrivateProfileStringW; + alias WritePrivateProfileStruct = WritePrivateProfileStructW; + alias WriteProfileSection = WriteProfileSectionW; + alias WriteProfileString = WriteProfileStringW; + alias CreateWaitableTimer = CreateWaitableTimerW; + alias GetFileAttributesEx = GetFileAttributesExW; + alias GetLongPathName = GetLongPathNameW; + alias QueryDosDevice = QueryDosDeviceW; + + alias HW_PROFILE_INFO = HW_PROFILE_INFOW; + alias AccessCheckAndAuditAlarm = AccessCheckAndAuditAlarmW; + alias BackupEventLog = BackupEventLogW; + alias ClearEventLog = ClearEventLogW; + alias CreateNamedPipe = CreateNamedPipeW; + alias CreateProcessAsUser = CreateProcessAsUserW; + alias DefineDosDevice = DefineDosDeviceW; + alias FindFirstFileEx = FindFirstFileExW; + alias GetBinaryType = GetBinaryTypeW; + alias GetCompressedFileSize = GetCompressedFileSizeW; + alias GetFileSecurity = GetFileSecurityW; + alias LogonUser = LogonUserW; + alias LookupAccountName = LookupAccountNameW; + alias LookupAccountSid = LookupAccountSidW; + alias LookupPrivilegeDisplayName = LookupPrivilegeDisplayNameW; + alias LookupPrivilegeName = LookupPrivilegeNameW; + alias LookupPrivilegeValue = LookupPrivilegeValueW; + alias MoveFileEx = MoveFileExW; + alias ObjectCloseAuditAlarm = ObjectCloseAuditAlarmW; + alias ObjectDeleteAuditAlarm = ObjectDeleteAuditAlarmW; + alias ObjectOpenAuditAlarm = ObjectOpenAuditAlarmW; + alias ObjectPrivilegeAuditAlarm = ObjectPrivilegeAuditAlarmW; + alias OpenBackupEventLog = OpenBackupEventLogW; + alias OpenEventLog = OpenEventLogW; + alias PrivilegedServiceAuditAlarm = PrivilegedServiceAuditAlarmW; + alias ReadEventLog = ReadEventLogW; + alias RegisterEventSource = RegisterEventSourceW; + alias ReportEvent = ReportEventW; + alias SetFileSecurity = SetFileSecurityW; + alias UpdateResource = UpdateResourceW; static if (_WIN32_WINNT >= 0x500) { - alias CreateFileMappingW CreateFileMapping; - alias CreateHardLinkW CreateHardLink; - alias CreateJobObjectW CreateJobObject; - alias DeleteVolumeMountPointW DeleteVolumeMountPoint; - alias DnsHostnameToComputerNameW DnsHostnameToComputerName; - alias EncryptFileW EncryptFile; - alias FileEncryptionStatusW FileEncryptionStatus; - alias FindFirstVolumeW FindFirstVolume; - alias FindFirstVolumeMountPointW FindFirstVolumeMountPoint; - alias FindNextVolumeW FindNextVolume; - alias FindNextVolumeMountPointW FindNextVolumeMountPoint; - alias GetModuleHandleExW GetModuleHandleEx; - alias GetSystemWindowsDirectoryW GetSystemWindowsDirectory; - alias GetVolumeNameForVolumeMountPointW GetVolumeNameForVolumeMountPoint; - alias GetVolumePathNameW GetVolumePathName; - alias OpenFileMappingW OpenFileMapping; - alias ReplaceFileW ReplaceFile; - alias SetVolumeMountPointW SetVolumeMountPoint; - alias VerifyVersionInfoW VerifyVersionInfo; + alias CreateFileMapping = CreateFileMappingW; + alias CreateHardLink = CreateHardLinkW; + alias CreateJobObject = CreateJobObjectW; + alias DeleteVolumeMountPoint = DeleteVolumeMountPointW; + alias DnsHostnameToComputerName = DnsHostnameToComputerNameW; + alias EncryptFile = EncryptFileW; + alias FileEncryptionStatus = FileEncryptionStatusW; + alias FindFirstVolume = FindFirstVolumeW; + alias FindFirstVolumeMountPoint = FindFirstVolumeMountPointW; + alias FindNextVolume = FindNextVolumeW; + alias FindNextVolumeMountPoint = FindNextVolumeMountPointW; + alias GetModuleHandleEx = GetModuleHandleExW; + alias GetSystemWindowsDirectory = GetSystemWindowsDirectoryW; + alias GetVolumeNameForVolumeMountPoint = GetVolumeNameForVolumeMountPointW; + alias GetVolumePathName = GetVolumePathNameW; + alias OpenFileMapping = OpenFileMappingW; + alias ReplaceFile = ReplaceFileW; + alias SetVolumeMountPoint = SetVolumeMountPointW; + alias VerifyVersionInfo = VerifyVersionInfoW; } static if (_WIN32_WINNT >= 0x501) { - alias ACTCTXW ACTCTX; - alias CheckNameLegalDOS8Dot3W CheckNameLegalDOS8Dot3; - alias CreateActCtxW CreateActCtx; - alias FindActCtxSectionStringW FindActCtxSectionString; - alias GetSystemWow64DirectoryW GetSystemWow64Directory; - alias GetVolumePathNamesForVolumeNameW GetVolumePathNamesForVolumeName; - alias SetFileShortNameW SetFileShortName; + alias ACTCTX = ACTCTXW; + alias CheckNameLegalDOS8Dot3 = CheckNameLegalDOS8Dot3W; + alias CreateActCtx = CreateActCtxW; + alias FindActCtxSectionString = FindActCtxSectionStringW; + alias GetSystemWow64Directory = GetSystemWow64DirectoryW; + alias GetVolumePathNamesForVolumeName = GetVolumePathNamesForVolumeNameW; + alias SetFileShortName = SetFileShortNameW; } static if (_WIN32_WINNT >= 0x502) { - alias SetFirmwareEnvironmentVariableW SetFirmwareEnvironmentVariable; - alias SetDllDirectoryW SetDllDirectory; - alias GetDllDirectoryW GetDllDirectory; + alias SetFirmwareEnvironmentVariable = SetFirmwareEnvironmentVariableW; + alias SetDllDirectory = SetDllDirectoryW; + alias GetDllDirectory = GetDllDirectoryW; } static if (_WIN32_WINNT >= 0x600) { - alias CreateSymbolicLinkW CreateSymbolicLink; + alias CreateSymbolicLink = CreateSymbolicLinkW; } } else { //alias STARTUPINFOA STARTUPINFO; - alias WIN32_FIND_DATAA WIN32_FIND_DATA; - alias ENUMRESLANGPROCW ENUMRESLANGPROC; - alias ENUMRESNAMEPROCW ENUMRESNAMEPROC; - alias ENUMRESTYPEPROCW ENUMRESTYPEPROC; - alias AddAtomA AddAtom; - alias BeginUpdateResourceA BeginUpdateResource; - alias BuildCommDCBA BuildCommDCB; - alias BuildCommDCBAndTimeoutsA BuildCommDCBAndTimeouts; - alias CallNamedPipeA CallNamedPipe; - alias CommConfigDialogA CommConfigDialog; - alias CopyFileA CopyFile; - alias CopyFileExA CopyFileEx; - alias CreateDirectoryA CreateDirectory; - alias CreateDirectoryExA CreateDirectoryEx; - alias CreateEventA CreateEvent; - alias CreateFileA CreateFile; - alias CreateMailslotA CreateMailslot; - alias CreateMutexA CreateMutex; - alias CreateProcessA CreateProcess; - alias CreateSemaphoreA CreateSemaphore; - alias DeleteFileA DeleteFile; - alias EndUpdateResourceA EndUpdateResource; - alias EnumResourceLanguagesA EnumResourceLanguages; - alias EnumResourceNamesA EnumResourceNames; - alias EnumResourceTypesA EnumResourceTypes; - alias ExpandEnvironmentStringsA ExpandEnvironmentStrings; - alias FatalAppExitA FatalAppExit; - alias FindAtomA FindAtom; - alias FindFirstChangeNotificationA FindFirstChangeNotification; - alias FindFirstFileA FindFirstFile; - alias FindNextFileA FindNextFile; - alias FindResourceA FindResource; - alias FindResourceExA FindResourceEx; - alias FormatMessageA FormatMessage; - alias FreeEnvironmentStringsA FreeEnvironmentStrings; - alias GetAtomNameA GetAtomName; - alias GetCommandLineA GetCommandLine; - alias GetComputerNameA GetComputerName; - alias GetCurrentDirectoryA GetCurrentDirectory; - alias GetDefaultCommConfigA GetDefaultCommConfig; - alias GetDiskFreeSpaceA GetDiskFreeSpace; - alias GetDiskFreeSpaceExA GetDiskFreeSpaceEx; - alias GetDriveTypeA GetDriveType; - alias GetEnvironmentStringsA GetEnvironmentStrings; - alias GetEnvironmentVariableA GetEnvironmentVariable; - alias GetFileAttributesA GetFileAttributes; - alias GetFullPathNameA GetFullPathName; - alias GetLogicalDriveStringsA GetLogicalDriveStrings; - alias GetNamedPipeHandleStateA GetNamedPipeHandleState; - alias GetModuleHandleA GetModuleHandle; - alias GetModuleFileNameA GetModuleFileName; - alias GetPrivateProfileIntA GetPrivateProfileInt; - alias GetPrivateProfileSectionA GetPrivateProfileSection; - alias GetPrivateProfileSectionNamesA GetPrivateProfileSectionNames; - alias GetPrivateProfileStringA GetPrivateProfileString; - alias GetPrivateProfileStructA GetPrivateProfileStruct; - alias GetProfileIntA GetProfileInt; - alias GetProfileSectionA GetProfileSection; - alias GetProfileStringA GetProfileString; - alias GetShortPathNameA GetShortPathName; - alias GetStartupInfoA GetStartupInfo; - alias GetSystemDirectoryA GetSystemDirectory; - alias GetTempFileNameA GetTempFileName; - alias GetTempPathA GetTempPath; - alias GetUserNameA GetUserName; - alias GetVersionExA GetVersionEx; - alias GetVolumeInformationA GetVolumeInformation; - alias GetWindowsDirectoryA GetWindowsDirectory; - alias GlobalAddAtomA GlobalAddAtom; - alias GlobalFindAtomA GlobalFindAtom; - alias GlobalGetAtomNameA GlobalGetAtomName; - alias IsBadStringPtrA IsBadStringPtr; - alias LoadLibraryA LoadLibrary; - alias LoadLibraryExA LoadLibraryEx; - alias lstrcatA lstrcat; - alias lstrcmpA lstrcmp; - alias lstrcmpiA lstrcmpi; - alias lstrcpyA lstrcpy; - alias lstrcpynA lstrcpyn; - alias lstrlenA lstrlen; - alias MoveFileA MoveFile; - alias OpenEventA OpenEvent; - alias OpenMutexA OpenMutex; - alias OpenSemaphoreA OpenSemaphore; - alias OutputDebugStringA OutputDebugString; - alias RemoveDirectoryA RemoveDirectory; - alias SearchPathA SearchPath; - alias SetComputerNameA SetComputerName; - alias SetCurrentDirectoryA SetCurrentDirectory; - alias SetDefaultCommConfigA SetDefaultCommConfig; - alias SetEnvironmentVariableA SetEnvironmentVariable; - alias SetFileAttributesA SetFileAttributes; - alias SetVolumeLabelA SetVolumeLabel; - alias WaitNamedPipeA WaitNamedPipe; - alias WritePrivateProfileSectionA WritePrivateProfileSection; - alias WritePrivateProfileStringA WritePrivateProfileString; - alias WritePrivateProfileStructA WritePrivateProfileStruct; - alias WriteProfileSectionA WriteProfileSection; - alias WriteProfileStringA WriteProfileString; - alias CreateWaitableTimerA CreateWaitableTimer; - alias GetFileAttributesExA GetFileAttributesEx; - alias GetLongPathNameA GetLongPathName; - alias QueryDosDeviceA QueryDosDevice; - - alias HW_PROFILE_INFOA HW_PROFILE_INFO; - alias AccessCheckAndAuditAlarmA AccessCheckAndAuditAlarm; - alias BackupEventLogA BackupEventLog; - alias ClearEventLogA ClearEventLog; - alias CreateNamedPipeA CreateNamedPipe; - alias CreateProcessAsUserA CreateProcessAsUser; - alias DefineDosDeviceA DefineDosDevice; - alias FindFirstFileExA FindFirstFileEx; - alias GetBinaryTypeA GetBinaryType; - alias GetCompressedFileSizeA GetCompressedFileSize; - alias GetFileSecurityA GetFileSecurity; - alias LogonUserA LogonUser; - alias LookupAccountNameA LookupAccountName; - alias LookupAccountSidA LookupAccountSid; - alias LookupPrivilegeDisplayNameA LookupPrivilegeDisplayName; - alias LookupPrivilegeNameA LookupPrivilegeName; - alias LookupPrivilegeValueA LookupPrivilegeValue; - alias MoveFileExA MoveFileEx; - alias ObjectCloseAuditAlarmA ObjectCloseAuditAlarm; - alias ObjectDeleteAuditAlarmA ObjectDeleteAuditAlarm; - alias ObjectOpenAuditAlarmA ObjectOpenAuditAlarm; - alias ObjectPrivilegeAuditAlarmA ObjectPrivilegeAuditAlarm; - alias OpenBackupEventLogA OpenBackupEventLog; - alias OpenEventLogA OpenEventLog; - alias PrivilegedServiceAuditAlarmA PrivilegedServiceAuditAlarm; - alias ReadEventLogA ReadEventLog; - alias RegisterEventSourceA RegisterEventSource; - alias ReportEventA ReportEvent; - alias SetFileSecurityA SetFileSecurity; - alias UpdateResourceA UpdateResource; + alias WIN32_FIND_DATA = WIN32_FIND_DATAA; + alias ENUMRESLANGPROC = ENUMRESLANGPROCW; + alias ENUMRESNAMEPROC = ENUMRESNAMEPROCW; + alias ENUMRESTYPEPROC = ENUMRESTYPEPROCW; + alias AddAtom = AddAtomA; + alias BeginUpdateResource = BeginUpdateResourceA; + alias BuildCommDCB = BuildCommDCBA; + alias BuildCommDCBAndTimeouts = BuildCommDCBAndTimeoutsA; + alias CallNamedPipe = CallNamedPipeA; + alias CommConfigDialog = CommConfigDialogA; + alias CopyFile = CopyFileA; + alias CopyFileEx = CopyFileExA; + alias CreateDirectory = CreateDirectoryA; + alias CreateDirectoryEx = CreateDirectoryExA; + alias CreateEvent = CreateEventA; + alias CreateFile = CreateFileA; + alias CreateMailslot = CreateMailslotA; + alias CreateMutex = CreateMutexA; + alias CreateProcess = CreateProcessA; + alias CreateSemaphore = CreateSemaphoreA; + alias DeleteFile = DeleteFileA; + alias EndUpdateResource = EndUpdateResourceA; + alias EnumResourceLanguages = EnumResourceLanguagesA; + alias EnumResourceNames = EnumResourceNamesA; + alias EnumResourceTypes = EnumResourceTypesA; + alias ExpandEnvironmentStrings = ExpandEnvironmentStringsA; + alias FatalAppExit = FatalAppExitA; + alias FindAtom = FindAtomA; + alias FindFirstChangeNotification = FindFirstChangeNotificationA; + alias FindFirstFile = FindFirstFileA; + alias FindNextFile = FindNextFileA; + alias FindResource = FindResourceA; + alias FindResourceEx = FindResourceExA; + alias FormatMessage = FormatMessageA; + alias FreeEnvironmentStrings = FreeEnvironmentStringsA; + alias GetAtomName = GetAtomNameA; + alias GetCommandLine = GetCommandLineA; + alias GetComputerName = GetComputerNameA; + alias GetCurrentDirectory = GetCurrentDirectoryA; + alias GetDefaultCommConfig = GetDefaultCommConfigA; + alias GetDiskFreeSpace = GetDiskFreeSpaceA; + alias GetDiskFreeSpaceEx = GetDiskFreeSpaceExA; + alias GetDriveType = GetDriveTypeA; + alias GetEnvironmentStrings = GetEnvironmentStringsA; + alias GetEnvironmentVariable = GetEnvironmentVariableA; + alias GetFileAttributes = GetFileAttributesA; + alias GetFullPathName = GetFullPathNameA; + alias GetLogicalDriveStrings = GetLogicalDriveStringsA; + alias GetNamedPipeHandleState = GetNamedPipeHandleStateA; + alias GetModuleHandle = GetModuleHandleA; + alias GetModuleFileName = GetModuleFileNameA; + alias GetPrivateProfileInt = GetPrivateProfileIntA; + alias GetPrivateProfileSection = GetPrivateProfileSectionA; + alias GetPrivateProfileSectionNames = GetPrivateProfileSectionNamesA; + alias GetPrivateProfileString = GetPrivateProfileStringA; + alias GetPrivateProfileStruct = GetPrivateProfileStructA; + alias GetProfileInt = GetProfileIntA; + alias GetProfileSection = GetProfileSectionA; + alias GetProfileString = GetProfileStringA; + alias GetShortPathName = GetShortPathNameA; + alias GetStartupInfo = GetStartupInfoA; + alias GetSystemDirectory = GetSystemDirectoryA; + alias GetTempFileName = GetTempFileNameA; + alias GetTempPath = GetTempPathA; + alias GetUserName = GetUserNameA; + alias GetVersionEx = GetVersionExA; + alias GetVolumeInformation = GetVolumeInformationA; + alias GetWindowsDirectory = GetWindowsDirectoryA; + alias GlobalAddAtom = GlobalAddAtomA; + alias GlobalFindAtom = GlobalFindAtomA; + alias GlobalGetAtomName = GlobalGetAtomNameA; + alias IsBadStringPtr = IsBadStringPtrA; + alias LoadLibrary = LoadLibraryA; + alias LoadLibraryEx = LoadLibraryExA; + alias lstrcat = lstrcatA; + alias lstrcmp = lstrcmpA; + alias lstrcmpi = lstrcmpiA; + alias lstrcpy = lstrcpyA; + alias lstrcpyn = lstrcpynA; + alias lstrlen = lstrlenA; + alias MoveFile = MoveFileA; + alias OpenEvent = OpenEventA; + alias OpenMutex = OpenMutexA; + alias OpenSemaphore = OpenSemaphoreA; + alias OutputDebugString = OutputDebugStringA; + alias RemoveDirectory = RemoveDirectoryA; + alias SearchPath = SearchPathA; + alias SetComputerName = SetComputerNameA; + alias SetCurrentDirectory = SetCurrentDirectoryA; + alias SetDefaultCommConfig = SetDefaultCommConfigA; + alias SetEnvironmentVariable = SetEnvironmentVariableA; + alias SetFileAttributes = SetFileAttributesA; + alias SetVolumeLabel = SetVolumeLabelA; + alias WaitNamedPipe = WaitNamedPipeA; + alias WritePrivateProfileSection = WritePrivateProfileSectionA; + alias WritePrivateProfileString = WritePrivateProfileStringA; + alias WritePrivateProfileStruct = WritePrivateProfileStructA; + alias WriteProfileSection = WriteProfileSectionA; + alias WriteProfileString = WriteProfileStringA; + alias CreateWaitableTimer = CreateWaitableTimerA; + alias GetFileAttributesEx = GetFileAttributesExA; + alias GetLongPathName = GetLongPathNameA; + alias QueryDosDevice = QueryDosDeviceA; + + alias HW_PROFILE_INFO = HW_PROFILE_INFOA; + alias AccessCheckAndAuditAlarm = AccessCheckAndAuditAlarmA; + alias BackupEventLog = BackupEventLogA; + alias ClearEventLog = ClearEventLogA; + alias CreateNamedPipe = CreateNamedPipeA; + alias CreateProcessAsUser = CreateProcessAsUserA; + alias DefineDosDevice = DefineDosDeviceA; + alias FindFirstFileEx = FindFirstFileExA; + alias GetBinaryType = GetBinaryTypeA; + alias GetCompressedFileSize = GetCompressedFileSizeA; + alias GetFileSecurity = GetFileSecurityA; + alias LogonUser = LogonUserA; + alias LookupAccountName = LookupAccountNameA; + alias LookupAccountSid = LookupAccountSidA; + alias LookupPrivilegeDisplayName = LookupPrivilegeDisplayNameA; + alias LookupPrivilegeName = LookupPrivilegeNameA; + alias LookupPrivilegeValue = LookupPrivilegeValueA; + alias MoveFileEx = MoveFileExA; + alias ObjectCloseAuditAlarm = ObjectCloseAuditAlarmA; + alias ObjectDeleteAuditAlarm = ObjectDeleteAuditAlarmA; + alias ObjectOpenAuditAlarm = ObjectOpenAuditAlarmA; + alias ObjectPrivilegeAuditAlarm = ObjectPrivilegeAuditAlarmA; + alias OpenBackupEventLog = OpenBackupEventLogA; + alias OpenEventLog = OpenEventLogA; + alias PrivilegedServiceAuditAlarm = PrivilegedServiceAuditAlarmA; + alias ReadEventLog = ReadEventLogA; + alias RegisterEventSource = RegisterEventSourceA; + alias ReportEvent = ReportEventA; + alias SetFileSecurity = SetFileSecurityA; + alias UpdateResource = UpdateResourceA; static if (_WIN32_WINNT >= 0x500) { - alias CreateFileMappingA CreateFileMapping; - alias CreateHardLinkA CreateHardLink; - alias CreateJobObjectA CreateJobObject; - alias DeleteVolumeMountPointA DeleteVolumeMountPoint; - alias DnsHostnameToComputerNameA DnsHostnameToComputerName; - alias EncryptFileA EncryptFile; - alias FileEncryptionStatusA FileEncryptionStatus; - alias FindFirstVolumeA FindFirstVolume; - alias FindFirstVolumeMountPointA FindFirstVolumeMountPoint; - alias FindNextVolumeA FindNextVolume; - alias FindNextVolumeMountPointA FindNextVolumeMountPoint; - alias GetModuleHandleExA GetModuleHandleEx; - alias GetSystemWindowsDirectoryA GetSystemWindowsDirectory; - alias GetVolumeNameForVolumeMountPointA GetVolumeNameForVolumeMountPoint; - alias GetVolumePathNameA GetVolumePathName; - alias OpenFileMappingA OpenFileMapping; - alias ReplaceFileA ReplaceFile; - alias SetVolumeMountPointA SetVolumeMountPoint; - alias VerifyVersionInfoA VerifyVersionInfo; + alias CreateFileMapping = CreateFileMappingA; + alias CreateHardLink = CreateHardLinkA; + alias CreateJobObject = CreateJobObjectA; + alias DeleteVolumeMountPoint = DeleteVolumeMountPointA; + alias DnsHostnameToComputerName = DnsHostnameToComputerNameA; + alias EncryptFile = EncryptFileA; + alias FileEncryptionStatus = FileEncryptionStatusA; + alias FindFirstVolume = FindFirstVolumeA; + alias FindFirstVolumeMountPoint = FindFirstVolumeMountPointA; + alias FindNextVolume = FindNextVolumeA; + alias FindNextVolumeMountPoint = FindNextVolumeMountPointA; + alias GetModuleHandleEx = GetModuleHandleExA; + alias GetSystemWindowsDirectory = GetSystemWindowsDirectoryA; + alias GetVolumeNameForVolumeMountPoint = GetVolumeNameForVolumeMountPointA; + alias GetVolumePathName = GetVolumePathNameA; + alias OpenFileMapping = OpenFileMappingA; + alias ReplaceFile = ReplaceFileA; + alias SetVolumeMountPoint = SetVolumeMountPointA; + alias VerifyVersionInfo = VerifyVersionInfoA; } static if (_WIN32_WINNT >= 0x501) { - alias ACTCTXA ACTCTX; - alias CheckNameLegalDOS8Dot3A CheckNameLegalDOS8Dot3; - alias CreateActCtxA CreateActCtx; - alias FindActCtxSectionStringA FindActCtxSectionString; - alias GetSystemWow64DirectoryA GetSystemWow64Directory; - alias GetVolumePathNamesForVolumeNameA GetVolumePathNamesForVolumeName; - alias SetFileShortNameA SetFileShortName; + alias ACTCTX = ACTCTXA; + alias CheckNameLegalDOS8Dot3 = CheckNameLegalDOS8Dot3A; + alias CreateActCtx = CreateActCtxA; + alias FindActCtxSectionString = FindActCtxSectionStringA; + alias GetSystemWow64Directory = GetSystemWow64DirectoryA; + alias GetVolumePathNamesForVolumeName = GetVolumePathNamesForVolumeNameA; + alias SetFileShortName = SetFileShortNameA; } static if (_WIN32_WINNT >= 0x502) { - alias GetDllDirectoryA GetDllDirectory; - alias SetDllDirectoryA SetDllDirectory; - alias SetFirmwareEnvironmentVariableA SetFirmwareEnvironmentVariable; + alias GetDllDirectory = GetDllDirectoryA; + alias SetDllDirectory = SetDllDirectoryA; + alias SetFirmwareEnvironmentVariable = SetFirmwareEnvironmentVariableA; } static if (_WIN32_WINNT >= 0x600) { - alias CreateSymbolicLinkA CreateSymbolicLink; + alias CreateSymbolicLink = CreateSymbolicLinkA; } } -alias STARTUPINFO* LPSTARTUPINFO; -alias WIN32_FIND_DATA* LPWIN32_FIND_DATA; +alias LPSTARTUPINFO = STARTUPINFO*; +alias LPWIN32_FIND_DATA = WIN32_FIND_DATA*; -alias HW_PROFILE_INFO* LPHW_PROFILE_INFO; +alias LPHW_PROFILE_INFO = HW_PROFILE_INFO*; static if (_WIN32_WINNT >= 0x501) { - alias ACTCTX* PACTCTX, PCACTCTX; + alias PACTCTX = ACTCTX*, PCACTCTX = ACTCTX*; } diff --git a/runtime/druntime/src/core/sys/windows/winber.d b/runtime/druntime/src/core/sys/windows/winber.d index b21193896b..55c5b0ab4c 100644 --- a/runtime/druntime/src/core/sys/windows/winber.d +++ b/runtime/druntime/src/core/sys/windows/winber.d @@ -34,16 +34,16 @@ version (Windows): */ struct BerElement; -alias int ber_int_t, ber_slen_t; -alias uint ber_uint_t, ber_len_t, ber_tag_t; +alias ber_int_t = int, ber_slen_t = int; +alias ber_uint_t = uint, ber_len_t = uint, ber_tag_t = uint; align(4): struct BerValue { ber_len_t bv_len; char* bv_val; } -alias BerValue LDAP_BERVAL, BERVAL; -alias BerValue* PLDAP_BERVAL, PBERVAL; +alias LDAP_BERVAL = BerValue, BERVAL = BerValue; +alias PLDAP_BERVAL = BerValue*, PBERVAL = BerValue*; enum ber_tag_t LBER_ERROR = -1, diff --git a/runtime/druntime/src/core/sys/windows/wincon.d b/runtime/druntime/src/core/sys/windows/wincon.d index a00ba2e31d..0a4de9ef7b 100644 --- a/runtime/druntime/src/core/sys/windows/wincon.d +++ b/runtime/druntime/src/core/sys/windows/wincon.d @@ -117,7 +117,7 @@ struct CHAR_INFO { } WORD Attributes; } -alias CHAR_INFO* PCHAR_INFO; +alias PCHAR_INFO = CHAR_INFO*; struct SMALL_RECT { SHORT Left; @@ -125,25 +125,25 @@ struct SMALL_RECT { SHORT Right; SHORT Bottom; } -alias SMALL_RECT* PSMALL_RECT; +alias PSMALL_RECT = SMALL_RECT*; struct CONSOLE_CURSOR_INFO { DWORD dwSize; BOOL bVisible; } -alias CONSOLE_CURSOR_INFO* PCONSOLE_CURSOR_INFO; +alias PCONSOLE_CURSOR_INFO = CONSOLE_CURSOR_INFO*; struct COORD { SHORT X; SHORT Y; } -alias COORD* PCOORD; +alias PCOORD = COORD*; struct CONSOLE_FONT_INFO { DWORD nFont; COORD dwFontSize; } -alias CONSOLE_FONT_INFO* PCONSOLE_FONT_INFO; +alias PCONSOLE_FONT_INFO = CONSOLE_FONT_INFO*; struct CONSOLE_SCREEN_BUFFER_INFO { COORD dwSize; @@ -152,9 +152,9 @@ struct CONSOLE_SCREEN_BUFFER_INFO { SMALL_RECT srWindow; COORD dwMaximumWindowSize; } -alias CONSOLE_SCREEN_BUFFER_INFO* PCONSOLE_SCREEN_BUFFER_INFO; +alias PCONSOLE_SCREEN_BUFFER_INFO = CONSOLE_SCREEN_BUFFER_INFO*; -alias extern(Windows) BOOL function(DWORD) nothrow PHANDLER_ROUTINE; +alias PHANDLER_ROUTINE = extern(Windows) BOOL function(DWORD) nothrow; struct KEY_EVENT_RECORD { BOOL bKeyDown; @@ -172,7 +172,7 @@ struct KEY_EVENT_RECORD { } DWORD dwControlKeyState; } -alias KEY_EVENT_RECORD* PKEY_EVENT_RECORD; +alias PKEY_EVENT_RECORD = KEY_EVENT_RECORD*; struct MOUSE_EVENT_RECORD { COORD dwMousePosition; @@ -180,22 +180,22 @@ struct MOUSE_EVENT_RECORD { DWORD dwControlKeyState; DWORD dwEventFlags; } -alias MOUSE_EVENT_RECORD* PMOUSE_EVENT_RECORD; +alias PMOUSE_EVENT_RECORD = MOUSE_EVENT_RECORD*; struct WINDOW_BUFFER_SIZE_RECORD { COORD dwSize; } -alias WINDOW_BUFFER_SIZE_RECORD* PWINDOW_BUFFER_SIZE_RECORD; +alias PWINDOW_BUFFER_SIZE_RECORD = WINDOW_BUFFER_SIZE_RECORD*; struct MENU_EVENT_RECORD { UINT dwCommandId; } -alias MENU_EVENT_RECORD* PMENU_EVENT_RECORD; +alias PMENU_EVENT_RECORD = MENU_EVENT_RECORD*; struct FOCUS_EVENT_RECORD { BOOL bSetFocus; } -alias FOCUS_EVENT_RECORD* PFOCUS_EVENT_RECORD; +alias PFOCUS_EVENT_RECORD = FOCUS_EVENT_RECORD*; struct INPUT_RECORD { WORD EventType; @@ -215,7 +215,7 @@ struct INPUT_RECORD { _Event Event; } } -alias INPUT_RECORD* PINPUT_RECORD; +alias PINPUT_RECORD = INPUT_RECORD*; extern (Windows) nothrow @nogc: @@ -286,31 +286,31 @@ BOOL WriteConsoleOutputCharacterA(HANDLE, LPCSTR, DWORD, COORD, PDWORD); BOOL WriteConsoleOutputCharacterW(HANDLE, LPCWSTR, DWORD, COORD, PDWORD); version (Unicode) { - alias FillConsoleOutputCharacterW FillConsoleOutputCharacter; - alias GetConsoleTitleW GetConsoleTitle; - alias PeekConsoleInputW PeekConsoleInput; - alias ReadConsoleW ReadConsole; - alias ReadConsoleInputW ReadConsoleInput; - alias ReadConsoleOutputW ReadConsoleOutput; - alias ReadConsoleOutputCharacterW ReadConsoleOutputCharacter; - alias ScrollConsoleScreenBufferW ScrollConsoleScreenBuffer; - alias SetConsoleTitleW SetConsoleTitle; - alias WriteConsoleW WriteConsole; - alias WriteConsoleInputW WriteConsoleInput; - alias WriteConsoleOutputW WriteConsoleOutput; - alias WriteConsoleOutputCharacterW WriteConsoleOutputCharacter; + alias FillConsoleOutputCharacter = FillConsoleOutputCharacterW; + alias GetConsoleTitle = GetConsoleTitleW; + alias PeekConsoleInput = PeekConsoleInputW; + alias ReadConsole = ReadConsoleW; + alias ReadConsoleInput = ReadConsoleInputW; + alias ReadConsoleOutput = ReadConsoleOutputW; + alias ReadConsoleOutputCharacter = ReadConsoleOutputCharacterW; + alias ScrollConsoleScreenBuffer = ScrollConsoleScreenBufferW; + alias SetConsoleTitle = SetConsoleTitleW; + alias WriteConsole = WriteConsoleW; + alias WriteConsoleInput = WriteConsoleInputW; + alias WriteConsoleOutput = WriteConsoleOutputW; + alias WriteConsoleOutputCharacter = WriteConsoleOutputCharacterW; } else { - alias FillConsoleOutputCharacterA FillConsoleOutputCharacter; - alias GetConsoleTitleA GetConsoleTitle; - alias PeekConsoleInputA PeekConsoleInput; - alias ReadConsoleA ReadConsole; - alias ReadConsoleInputA ReadConsoleInput; - alias ReadConsoleOutputA ReadConsoleOutput; - alias ReadConsoleOutputCharacterA ReadConsoleOutputCharacter; - alias ScrollConsoleScreenBufferA ScrollConsoleScreenBuffer; - alias SetConsoleTitleA SetConsoleTitle; - alias WriteConsoleA WriteConsole; - alias WriteConsoleInputA WriteConsoleInput; - alias WriteConsoleOutputA WriteConsoleOutput; - alias WriteConsoleOutputCharacterA WriteConsoleOutputCharacter; + alias FillConsoleOutputCharacter = FillConsoleOutputCharacterA; + alias GetConsoleTitle = GetConsoleTitleA; + alias PeekConsoleInput = PeekConsoleInputA; + alias ReadConsole = ReadConsoleA; + alias ReadConsoleInput = ReadConsoleInputA; + alias ReadConsoleOutput = ReadConsoleOutputA; + alias ReadConsoleOutputCharacter = ReadConsoleOutputCharacterA; + alias ScrollConsoleScreenBuffer = ScrollConsoleScreenBufferA; + alias SetConsoleTitle = SetConsoleTitleA; + alias WriteConsole = WriteConsoleA; + alias WriteConsoleInput = WriteConsoleInputA; + alias WriteConsoleOutput = WriteConsoleOutputA; + alias WriteConsoleOutputCharacter = WriteConsoleOutputCharacterA; } diff --git a/runtime/druntime/src/core/sys/windows/wincrypt.d b/runtime/druntime/src/core/sys/windows/wincrypt.d index f068a3a795..ab83f006b0 100644 --- a/runtime/druntime/src/core/sys/windows/wincrypt.d +++ b/runtime/druntime/src/core/sys/windows/wincrypt.d @@ -500,27 +500,21 @@ enum { } -alias UINT ALG_ID; -alias ULONG_PTR HCRYPTPROV, HCRYPTKEY, HCRYPTHASH; -alias PVOID HCERTSTORE, HCRYPTMSG, HCERTCHAINENGINE; +alias ALG_ID = UINT; +alias HCRYPTPROV = ULONG_PTR, HCRYPTKEY = ULONG_PTR, HCRYPTHASH = ULONG_PTR; +alias HCERTSTORE = PVOID, HCRYPTMSG = PVOID, HCERTCHAINENGINE = PVOID; struct VTableProvStruc { FARPROC FuncVerifyImage; } -alias VTableProvStruc* PVTableProvStruc; +alias PVTableProvStruc = VTableProvStruc*; struct _CRYPTOAPI_BLOB { DWORD cbData; BYTE* pbData; } -alias _CRYPTOAPI_BLOB CRYPT_INTEGER_BLOB, CRYPT_UINT_BLOB, - CRYPT_OBJID_BLOB, CERT_NAME_BLOB, CERT_RDN_VALUE_BLOB, CERT_BLOB, - CRL_BLOB, DATA_BLOB, CRYPT_DATA_BLOB, CRYPT_HASH_BLOB, - CRYPT_DIGEST_BLOB, CRYPT_DER_BLOB, CRYPT_ATTR_BLOB; -alias _CRYPTOAPI_BLOB* PCRYPT_INTEGER_BLOB, PCRYPT_UINT_BLOB, - PCRYPT_OBJID_BLOB, PCERT_NAME_BLOB, PCERT_RDN_VALUE_BLOB, PCERT_BLOB, - PCRL_BLOB, PDATA_BLOB, PCRYPT_DATA_BLOB, PCRYPT_HASH_BLOB, - PCRYPT_DIGEST_BLOB, PCRYPT_DER_BLOB, PCRYPT_ATTR_BLOB; +alias CRYPT_INTEGER_BLOB = _CRYPTOAPI_BLOB, CRYPT_UINT_BLOB = _CRYPTOAPI_BLOB, CRYPT_OBJID_BLOB = _CRYPTOAPI_BLOB, CERT_NAME_BLOB = _CRYPTOAPI_BLOB, CERT_RDN_VALUE_BLOB = _CRYPTOAPI_BLOB, CERT_BLOB = _CRYPTOAPI_BLOB, CRL_BLOB = _CRYPTOAPI_BLOB, DATA_BLOB = _CRYPTOAPI_BLOB, CRYPT_DATA_BLOB = _CRYPTOAPI_BLOB, CRYPT_HASH_BLOB = _CRYPTOAPI_BLOB, CRYPT_DIGEST_BLOB = _CRYPTOAPI_BLOB, CRYPT_DER_BLOB = _CRYPTOAPI_BLOB, CRYPT_ATTR_BLOB = _CRYPTOAPI_BLOB; +alias PCRYPT_INTEGER_BLOB = _CRYPTOAPI_BLOB*, PCRYPT_UINT_BLOB = _CRYPTOAPI_BLOB*, PCRYPT_OBJID_BLOB = _CRYPTOAPI_BLOB*, PCERT_NAME_BLOB = _CRYPTOAPI_BLOB*, PCERT_RDN_VALUE_BLOB = _CRYPTOAPI_BLOB*, PCERT_BLOB = _CRYPTOAPI_BLOB*, PCRL_BLOB = _CRYPTOAPI_BLOB*, PDATA_BLOB = _CRYPTOAPI_BLOB*, PCRYPT_DATA_BLOB = _CRYPTOAPI_BLOB*, PCRYPT_HASH_BLOB = _CRYPTOAPI_BLOB*, PCRYPT_DIGEST_BLOB = _CRYPTOAPI_BLOB*, PCRYPT_DER_BLOB = _CRYPTOAPI_BLOB*, PCRYPT_ATTR_BLOB = _CRYPTOAPI_BLOB*; // not described in SDK; has the same layout as HTTPSPolicyCallbackData struct SSL_EXTRA_CERT_CHAIN_POLICY_PARA { @@ -529,9 +523,8 @@ struct SSL_EXTRA_CERT_CHAIN_POLICY_PARA { DWORD fdwChecks; LPWSTR pwszServerName; } -alias SSL_EXTRA_CERT_CHAIN_POLICY_PARA HTTPSPolicyCallbackData; -alias SSL_EXTRA_CERT_CHAIN_POLICY_PARA* PSSL_EXTRA_CERT_CHAIN_POLICY_PARA, - PHTTPSPolicyCallbackData; +alias HTTPSPolicyCallbackData = SSL_EXTRA_CERT_CHAIN_POLICY_PARA; +alias PSSL_EXTRA_CERT_CHAIN_POLICY_PARA = SSL_EXTRA_CERT_CHAIN_POLICY_PARA*, PHTTPSPolicyCallbackData = SSL_EXTRA_CERT_CHAIN_POLICY_PARA*; /* #if (_WIN32_WINNT>=0x500) */ struct CERT_CHAIN_POLICY_PARA { @@ -539,7 +532,7 @@ struct CERT_CHAIN_POLICY_PARA { DWORD dwFlags; void* pvExtraPolicyPara; } -alias CERT_CHAIN_POLICY_PARA* PCERT_CHAIN_POLICY_PARA; +alias PCERT_CHAIN_POLICY_PARA = CERT_CHAIN_POLICY_PARA*; struct CERT_CHAIN_POLICY_STATUS { DWORD cbSize = CERT_CHAIN_POLICY_STATUS.sizeof; @@ -548,34 +541,34 @@ struct CERT_CHAIN_POLICY_STATUS { LONG lElementIndex; void* pvExtraPolicyStatus; } -alias CERT_CHAIN_POLICY_STATUS* PCERT_CHAIN_POLICY_STATUS; +alias PCERT_CHAIN_POLICY_STATUS = CERT_CHAIN_POLICY_STATUS*; /* #endif */ struct CRYPT_ALGORITHM_IDENTIFIER { LPSTR pszObjId; CRYPT_OBJID_BLOB Parameters; } -alias CRYPT_ALGORITHM_IDENTIFIER* PCRYPT_ALGORITHM_IDENTIFIER; +alias PCRYPT_ALGORITHM_IDENTIFIER = CRYPT_ALGORITHM_IDENTIFIER*; struct CRYPT_BIT_BLOB { DWORD cbData; BYTE* pbData; DWORD cUnusedBits; } -alias CRYPT_BIT_BLOB* PCRYPT_BIT_BLOB; +alias PCRYPT_BIT_BLOB = CRYPT_BIT_BLOB*; struct CERT_PUBLIC_KEY_INFO { CRYPT_ALGORITHM_IDENTIFIER Algorithm; CRYPT_BIT_BLOB PublicKey; } -alias CERT_PUBLIC_KEY_INFO* PCERT_PUBLIC_KEY_INFO; +alias PCERT_PUBLIC_KEY_INFO = CERT_PUBLIC_KEY_INFO*; struct CERT_EXTENSION { LPSTR pszObjId; BOOL fCritical; CRYPT_OBJID_BLOB Value; } -alias CERT_EXTENSION* PCERT_EXTENSION; +alias PCERT_EXTENSION = CERT_EXTENSION*; struct CERT_INFO { DWORD dwVersion; @@ -591,7 +584,7 @@ struct CERT_INFO { DWORD cExtension; PCERT_EXTENSION rgExtension; } -alias CERT_INFO* PCERT_INFO; +alias PCERT_INFO = CERT_INFO*; struct CERT_CONTEXT { DWORD dwCertEncodingType; @@ -600,21 +593,21 @@ struct CERT_CONTEXT { PCERT_INFO pCertInfo; HCERTSTORE hCertStore; } -alias CERT_CONTEXT* PCERT_CONTEXT; -alias const(CERT_CONTEXT)* PCCERT_CONTEXT; +alias PCERT_CONTEXT = CERT_CONTEXT*; +alias PCCERT_CONTEXT = const(CERT_CONTEXT)*; struct CTL_USAGE { DWORD cUsageIdentifier; LPSTR* rgpszUsageIdentifier; } -alias CTL_USAGE CERT_ENHKEY_USAGE; -alias CTL_USAGE* PCTRL_USAGE, PCERT_ENHKEY_USAGE; +alias CERT_ENHKEY_USAGE = CTL_USAGE; +alias PCTRL_USAGE = CTL_USAGE*, PCERT_ENHKEY_USAGE = CTL_USAGE*; struct CERT_USAGE_MATCH { DWORD dwType; CERT_ENHKEY_USAGE Usage; } -alias CERT_USAGE_MATCH* PCERT_USAGE_MATCH; +alias PCERT_USAGE_MATCH = CERT_USAGE_MATCH*; /* #if (_WIN32_WINNT>=0x500) */ struct CERT_CHAIN_PARA { @@ -627,10 +620,9 @@ struct CERT_CHAIN_PARA { DWORD dwRevocationFreshnessTime; //#endif } -alias CERT_CHAIN_PARA* PCERT_CHAIN_PARA; +alias PCERT_CHAIN_PARA = CERT_CHAIN_PARA*; -extern (Windows) alias BOOL function(PCCERT_CONTEXT, void*) - PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK; +extern (Windows) alias PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK = BOOL function(PCCERT_CONTEXT, void*); struct CERT_CHAIN_FIND_BY_ISSUER_PARA { DWORD cbSize = CERT_CHAIN_FIND_BY_ISSUER_PARA.sizeof; @@ -644,14 +636,14 @@ struct CERT_CHAIN_FIND_BY_ISSUER_PARA { DWORD* pdwIssuerChainIndex; DWORD* pdwIssuerElementIndex; } -alias CERT_CHAIN_FIND_BY_ISSUER_PARA* PCERT_CHAIN_FIND_BY_ISSUER_PARA; +alias PCERT_CHAIN_FIND_BY_ISSUER_PARA = CERT_CHAIN_FIND_BY_ISSUER_PARA*; /* #endif */ struct CERT_TRUST_STATUS { DWORD dwErrorStatus; DWORD dwInfoStatus; } -alias CERT_TRUST_STATUS* PCERT_TRUST_STATUS; +alias PCERT_TRUST_STATUS = CERT_TRUST_STATUS*; struct CRL_ENTRY { CRYPT_INTEGER_BLOB SerialNumber; @@ -659,7 +651,7 @@ struct CRL_ENTRY { DWORD cExtension; PCERT_EXTENSION rgExtension; } -alias CRL_ENTRY* PCRL_ENTRY; +alias PCRL_ENTRY = CRL_ENTRY*; struct CRL_INFO { DWORD dwVersion; @@ -672,7 +664,7 @@ struct CRL_INFO { DWORD cExtension; PCERT_EXTENSION rgExtension; } -alias CRL_INFO* PCRL_INFO; +alias PCRL_INFO = CRL_INFO*; struct CRL_CONTEXT { DWORD dwCertEncodingType; @@ -681,8 +673,8 @@ struct CRL_CONTEXT { PCRL_INFO pCrlInfo; HCERTSTORE hCertStore; } -alias CRL_CONTEXT* PCRL_CONTEXT; -alias const(CRL_CONTEXT)* PCCRL_CONTEXT; +alias PCRL_CONTEXT = CRL_CONTEXT*; +alias PCCRL_CONTEXT = const(CRL_CONTEXT)*; struct CERT_REVOCATION_CRL_INFO { DWORD cbSize = CERT_REVOCATION_CRL_INFO.sizeof; @@ -691,7 +683,7 @@ struct CERT_REVOCATION_CRL_INFO { PCRL_ENTRY pCrlEntry; BOOL fDeltaCrlEntry; } -alias CERT_REVOCATION_CRL_INFO* PCERT_REVOCATION_CRL_INFO; +alias PCERT_REVOCATION_CRL_INFO = CERT_REVOCATION_CRL_INFO*; struct CERT_REVOCATION_INFO { DWORD cbSize = CERT_REVOCATION_INFO.sizeof; @@ -702,7 +694,7 @@ struct CERT_REVOCATION_INFO { DWORD dwFreshnessTime; PCERT_REVOCATION_CRL_INFO pCrlInfo; } -alias CERT_REVOCATION_INFO* PCERT_REVOCATION_INFO; +alias PCERT_REVOCATION_INFO = CERT_REVOCATION_INFO*; /* #if (_WIN32_WINNT>=0x500) */ struct CERT_CHAIN_ELEMENT { @@ -713,7 +705,7 @@ struct CERT_CHAIN_ELEMENT { PCERT_ENHKEY_USAGE pIssuanceUsage; PCERT_ENHKEY_USAGE pApplicationUsage; } -alias CERT_CHAIN_ELEMENT* PCERT_CHAIN_ELEMENT; +alias PCERT_CHAIN_ELEMENT = CERT_CHAIN_ELEMENT*; /* #endif */ struct CRYPT_ATTRIBUTE { @@ -721,14 +713,14 @@ struct CRYPT_ATTRIBUTE { DWORD cValue; PCRYPT_ATTR_BLOB rgValue; } -alias CRYPT_ATTRIBUTE* PCRYPT_ATTRIBUTE; +alias PCRYPT_ATTRIBUTE = CRYPT_ATTRIBUTE*; struct CTL_ENTRY { CRYPT_DATA_BLOB SubjectIdentifier; DWORD cAttribute; PCRYPT_ATTRIBUTE rgAttribute; } -alias CTL_ENTRY* PCTL_ENTRY; +alias PCTL_ENTRY = CTL_ENTRY*; struct CTL_INFO { DWORD dwVersion; @@ -743,7 +735,7 @@ struct CTL_INFO { DWORD cExtension; PCERT_EXTENSION rgExtension; } -alias CTL_INFO* PCTL_INFO; +alias PCTL_INFO = CTL_INFO*; struct CTL_CONTEXT { DWORD dwMsgAndCertEncodingType; @@ -755,15 +747,15 @@ struct CTL_CONTEXT { BYTE* pbCtlContent; DWORD cbCtlContent; } -alias CTL_CONTEXT* PCTL_CONTEXT; -alias const(CTL_CONTEXT)* PCCTL_CONTEXT; +alias PCTL_CONTEXT = CTL_CONTEXT*; +alias PCCTL_CONTEXT = const(CTL_CONTEXT)*; struct CERT_TRUST_LIST_INFO { DWORD cbSize = CERT_TRUST_LIST_INFO.sizeof; PCTL_ENTRY pCtlEntry; PCCTL_CONTEXT pCtlContext; } -alias CERT_TRUST_LIST_INFO* PCERT_TRUST_LIST_INFO; +alias PCERT_TRUST_LIST_INFO = CERT_TRUST_LIST_INFO*; struct CERT_SIMPLE_CHAIN { DWORD cbSize = CERT_SIMPLE_CHAIN.sizeof; @@ -774,10 +766,10 @@ struct CERT_SIMPLE_CHAIN { BOOL fHasRevocationFreshnessTime; DWORD dwRevocationFreshnessTime; } -alias CERT_SIMPLE_CHAIN* PCERT_SIMPLE_CHAIN; +alias PCERT_SIMPLE_CHAIN = CERT_SIMPLE_CHAIN*; /* #if (_WIN32_WINNT>=0x500) */ -alias const(CERT_CHAIN_CONTEXT)* PCCERT_CHAIN_CONTEXT; +alias PCCERT_CHAIN_CONTEXT = const(CERT_CHAIN_CONTEXT)*; struct CERT_CHAIN_CONTEXT { DWORD cbSize = CERT_CHAIN_CONTEXT.sizeof; CERT_TRUST_STATUS TrustStatus; @@ -788,7 +780,7 @@ struct CERT_CHAIN_CONTEXT { BOOL fHasRevocationFreshnessTime; DWORD dwRevocationFreshnessTime; } -alias CERT_CHAIN_CONTEXT* PCERT_CHAIN_CONTEXT; +alias PCERT_CHAIN_CONTEXT = CERT_CHAIN_CONTEXT*; /* #endif */ struct PROV_ENUMALGS { @@ -804,7 +796,7 @@ struct PUBLICKEYSTRUC { WORD reserved; ALG_ID aiKeyAlg; } -alias PUBLICKEYSTRUC BLOBHEADER; +alias BLOBHEADER = PUBLICKEYSTRUC; struct RSAPUBKEY { DWORD magic; @@ -819,7 +811,7 @@ struct HMAC_INFO { BYTE* pbOuterString; DWORD cbOuterString; } -alias HMAC_INFO* PHMAC_INFO; +alias PHMAC_INFO = HMAC_INFO*; extern (Windows) @nogc nothrow { BOOL CertCloseStore(HCERTSTORE, DWORD); @@ -882,21 +874,21 @@ const(void)*, PCCERT_CHAIN_CONTEXT); } version (Unicode) { - alias CertNameToStrW CertNameToStr; - alias CryptAcquireContextW CryptAcquireContext; - alias CryptSignHashW CryptSignHash; - alias CryptVerifySignatureW CryptVerifySignature; - alias CryptSetProviderW CryptSetProvider; - alias CertOpenSystemStoreW CertOpenSystemStore; + alias CertNameToStr = CertNameToStrW; + alias CryptAcquireContext = CryptAcquireContextW; + alias CryptSignHash = CryptSignHashW; + alias CryptVerifySignature = CryptVerifySignatureW; + alias CryptSetProvider = CryptSetProviderW; + alias CertOpenSystemStore = CertOpenSystemStoreW; /+alias CERT_FIND_SUBJECT_STR_W CERT_FIND_SUBJECT_STR; alias CERT_FIND_ISSUER_STR_W CERT_FIND_ISSUER_STR;+/ } else { - alias CertNameToStrA CertNameToStr; - alias CryptAcquireContextA CryptAcquireContext; - alias CryptSignHashA CryptSignHash; - alias CryptVerifySignatureA CryptVerifySignature; - alias CryptSetProviderA CryptSetProvider; - alias CertOpenSystemStoreA CertOpenSystemStore; + alias CertNameToStr = CertNameToStrA; + alias CryptAcquireContext = CryptAcquireContextA; + alias CryptSignHash = CryptSignHashA; + alias CryptVerifySignature = CryptVerifySignatureA; + alias CryptSetProvider = CryptSetProviderA; + alias CertOpenSystemStore = CertOpenSystemStoreA; /+alias CERT_FIND_SUBJECT_STR_A CERT_FIND_SUBJECT_STR; alias CERT_FIND_ISSUER_STR_A CERT_FIND_ISSUER_STR;+/ } diff --git a/runtime/druntime/src/core/sys/windows/windef.d b/runtime/druntime/src/core/sys/windows/windef.d index 105be44c5b..80f6874634 100644 --- a/runtime/druntime/src/core/sys/windows/windef.d +++ b/runtime/druntime/src/core/sys/windows/windef.d @@ -59,20 +59,20 @@ static assert (is(typeof({ test(NULL); }))); -alias ubyte BYTE; -alias ubyte* PBYTE, LPBYTE; -alias ushort USHORT, WORD, ATOM; -alias ushort* PUSHORT, PWORD, LPWORD; -alias uint ULONG, DWORD, UINT, COLORREF; -alias uint* PULONG, PDWORD, LPDWORD, PUINT, LPUINT, LPCOLORREF; -alias int WINBOOL, BOOL, INT, LONG, HFILE, HRESULT; -alias int* PWINBOOL, LPWINBOOL, PBOOL, LPBOOL, PINT, LPINT, LPLONG; -alias float FLOAT; -alias float* PFLOAT; -alias const(void)* PCVOID, LPCVOID; - -alias UINT_PTR WPARAM; -alias LONG_PTR LPARAM, LRESULT; +alias BYTE = ubyte; +alias PBYTE = ubyte*, LPBYTE = ubyte*; +alias USHORT = ushort, WORD = ushort, ATOM = ushort; +alias PUSHORT = ushort*, PWORD = ushort*, LPWORD = ushort*; +alias ULONG = uint, DWORD = uint, UINT = uint, COLORREF = uint; +alias PULONG = uint*, PDWORD = uint*, LPDWORD = uint*, PUINT = uint*, LPUINT = uint*, LPCOLORREF = uint*; +alias WINBOOL = int, BOOL = int, INT = int, LONG = int, HFILE = int, HRESULT = int; +alias PWINBOOL = int*, LPWINBOOL = int*, PBOOL = int*, LPBOOL = int*, PINT = int*, LPINT = int*, LPLONG = int*; +alias FLOAT = float; +alias PFLOAT = float*; +alias PCVOID = const(void)*, LPCVOID = const(void)*; + +alias WPARAM = UINT_PTR; +alias LPARAM = LONG_PTR, LRESULT = LONG_PTR; alias HHOOK = HANDLE; alias HGLOBAL = HANDLE; @@ -106,14 +106,14 @@ alias HWND = HANDLE; alias HWINSTA = HANDLE; alias HKL = HANDLE; alias HCURSOR = HANDLE; -alias HKEY* PHKEY; +alias PHKEY = HKEY*; static if (_WIN32_WINNT >= 0x500) { alias HTERMINAL = HANDLE; alias HWINEVENTHOOK = HANDLE; } -alias extern (Windows) INT_PTR function() nothrow FARPROC, NEARPROC, PROC; +alias FARPROC = extern (Windows) INT_PTR function() nothrow, NEARPROC = extern (Windows) INT_PTR function() nothrow, PROC = extern (Windows) INT_PTR function() nothrow; struct RECT { LONG left; @@ -121,29 +121,29 @@ struct RECT { LONG right; LONG bottom; } -alias RECT RECTL; -alias RECT* PRECT, NPRECT, LPRECT, PRECTL, LPRECTL; -alias const(RECT)* LPCRECT, LPCRECTL; +alias RECTL = RECT; +alias PRECT = RECT*, NPRECT = RECT*, LPRECT = RECT*, PRECTL = RECT*, LPRECTL = RECT*; +alias LPCRECT = const(RECT)*, LPCRECTL = const(RECT)*; struct POINT { LONG x; LONG y; } -alias POINT POINTL; -alias POINT* PPOINT, NPPOINT, LPPOINT, PPOINTL, LPPOINTL; +alias POINTL = POINT; +alias PPOINT = POINT*, NPPOINT = POINT*, LPPOINT = POINT*, PPOINTL = POINT*, LPPOINTL = POINT*; struct SIZE { LONG cx; LONG cy; } -alias SIZE SIZEL; -alias SIZE* PSIZE, LPSIZE, PSIZEL, LPSIZEL; +alias SIZEL = SIZE; +alias PSIZE = SIZE*, LPSIZE = SIZE*, PSIZEL = SIZE*, LPSIZEL = SIZE*; struct POINTS { SHORT x; SHORT y; } -alias POINTS* PPOINTS, LPPOINTS; +alias PPOINTS = POINTS*, LPPOINTS = POINTS*; enum : BOOL { FALSE = 0, diff --git a/runtime/druntime/src/core/sys/windows/winerror.d b/runtime/druntime/src/core/sys/windows/winerror.d index 865319b3c3..6886650f08 100644 --- a/runtime/druntime/src/core/sys/windows/winerror.d +++ b/runtime/druntime/src/core/sys/windows/winerror.d @@ -15,7 +15,7 @@ version (Windows): import core.sys.windows.windef; -alias int SCODE; // was in core.sys.windows.wtypes. +alias SCODE = int; // was in core.sys.windows.wtypes. enum : uint { ERROR_SUCCESS = 0, diff --git a/runtime/druntime/src/core/sys/windows/wingdi.d b/runtime/druntime/src/core/sys/windows/wingdi.d index c7b0c8bf95..b88059aaf6 100644 --- a/runtime/druntime/src/core/sys/windows/wingdi.d +++ b/runtime/druntime/src/core/sys/windows/wingdi.d @@ -418,7 +418,7 @@ enum { } enum ERROR = 0; -alias ERROR RGN_ERROR; +alias RGN_ERROR = ERROR; // CreateDIBitmap() enum DWORD CBM_INIT = 4; @@ -1395,7 +1395,7 @@ struct PSINJECTDATA { WORD InjectionPoint; WORD PageNumber; } -alias PSINJECTDATA* PPSINJECTDATA; +alias PPSINJECTDATA = PSINJECTDATA*; /* Constants for PSINJECTDATA.InjectionPoint field */ enum { @@ -1980,14 +1980,14 @@ struct ABC { UINT abcB; int abcC; } -alias ABC* PABC, NPABC, LPABC; +alias PABC = ABC*, NPABC = ABC*, LPABC = ABC*; struct ABCFLOAT { FLOAT abcfA; FLOAT abcfB; FLOAT abcfC; } -alias ABCFLOAT* PABCFLOAT, NPABCFLOAT, LPABCFLOAT; +alias PABCFLOAT = ABCFLOAT*, NPABCFLOAT = ABCFLOAT*, LPABCFLOAT = ABCFLOAT*; struct BITMAP { LONG bmType; @@ -1998,7 +1998,7 @@ struct BITMAP { WORD bmBitsPixel; LPVOID bmBits; } -alias BITMAP* PBITMAP, NPBITMAP, LPBITMAP; +alias PBITMAP = BITMAP*, NPBITMAP = BITMAP*, LPBITMAP = BITMAP*; struct BITMAPCOREHEADER { DWORD bcSize; @@ -2007,7 +2007,7 @@ struct BITMAPCOREHEADER { WORD bcPlanes; WORD bcBitCount; } -alias BITMAPCOREHEADER* PBITMAPCOREHEADER, LPBITMAPCOREHEADER; +alias PBITMAPCOREHEADER = BITMAPCOREHEADER*, LPBITMAPCOREHEADER = BITMAPCOREHEADER*; align(1): struct RGBTRIPLE { @@ -2015,7 +2015,7 @@ struct RGBTRIPLE { BYTE rgbtGreen; BYTE rgbtRed; } -alias RGBTRIPLE* LPRGBTRIPLE; +alias LPRGBTRIPLE = RGBTRIPLE*; align(2): struct BITMAPFILEHEADER { @@ -2026,7 +2026,7 @@ align(2): WORD bfReserved2; DWORD bfOffBits; } -alias BITMAPFILEHEADER* LPBITMAPFILEHEADER, PBITMAPFILEHEADER; +alias LPBITMAPFILEHEADER = BITMAPFILEHEADER*, PBITMAPFILEHEADER = BITMAPFILEHEADER*; align: @@ -2034,7 +2034,7 @@ struct BITMAPCOREINFO { BITMAPCOREHEADER bmciHeader; RGBTRIPLE[1] bmciColors; } -alias BITMAPCOREINFO* LPBITMAPCOREINFO, PBITMAPCOREINFO; +alias LPBITMAPCOREINFO = BITMAPCOREINFO*, PBITMAPCOREINFO = BITMAPCOREINFO*; struct BITMAPINFOHEADER { DWORD biSize; @@ -2050,7 +2050,7 @@ struct BITMAPINFOHEADER { DWORD biClrImportant; } -alias BITMAPINFOHEADER* LPBITMAPINFOHEADER, PBITMAPINFOHEADER; +alias LPBITMAPINFOHEADER = BITMAPINFOHEADER*, PBITMAPINFOHEADER = BITMAPINFOHEADER*; struct RGBQUAD { BYTE rgbBlue; @@ -2058,32 +2058,32 @@ struct RGBQUAD { BYTE rgbRed; BYTE rgbReserved; } -alias RGBQUAD* LPRGBQUAD; +alias LPRGBQUAD = RGBQUAD*; struct BITMAPINFO { BITMAPINFOHEADER bmiHeader; RGBQUAD[1] bmiColors; } -alias BITMAPINFO* PBITMAPINFO, LPBITMAPINFO; +alias PBITMAPINFO = BITMAPINFO*, LPBITMAPINFO = BITMAPINFO*; -alias int FXPT16DOT16; -alias int* LPFXPT16DOT16; -alias int FXPT2DOT30; -alias int* LPFXPT2DOT30; +alias FXPT16DOT16 = int; +alias LPFXPT16DOT16 = int*; +alias FXPT2DOT30 = int; +alias LPFXPT2DOT30 = int*; struct CIEXYZ { FXPT2DOT30 ciexyzX; FXPT2DOT30 ciexyzY; FXPT2DOT30 ciexyzZ; } -alias CIEXYZ* LPCIEXYZ; +alias LPCIEXYZ = CIEXYZ*; struct CIEXYZTRIPLE { CIEXYZ ciexyzRed; CIEXYZ ciexyzGreen; CIEXYZ ciexyzBlue; } -alias CIEXYZTRIPLE* LPCIEXYZTRIPLE; +alias LPCIEXYZTRIPLE = CIEXYZTRIPLE*; struct BITMAPV4HEADER { DWORD bV4Size; @@ -2107,7 +2107,7 @@ struct BITMAPV4HEADER { DWORD bV4GammaGreen; DWORD bV4GammaBlue; } -alias BITMAPV4HEADER* LPBITMAPV4HEADER, PBITMAPV4HEADER; +alias LPBITMAPV4HEADER = BITMAPV4HEADER*, PBITMAPV4HEADER = BITMAPV4HEADER*; struct BITMAPV5HEADER { DWORD bV5Size; @@ -2135,20 +2135,20 @@ struct BITMAPV5HEADER { DWORD bV5ProfileSize; DWORD bV5Reserved; } -alias BITMAPV5HEADER* LPBITMAPV5HEADER, PBITMAPV5HEADER; +alias LPBITMAPV5HEADER = BITMAPV5HEADER*, PBITMAPV5HEADER = BITMAPV5HEADER*; struct FONTSIGNATURE { DWORD[4] fsUsb; DWORD[2] fsCsb; } -alias FONTSIGNATURE* PFONTSIGNATURE, LPFONTSIGNATURE; +alias PFONTSIGNATURE = FONTSIGNATURE*, LPFONTSIGNATURE = FONTSIGNATURE*; struct CHARSETINFO { UINT ciCharset; UINT ciACP; FONTSIGNATURE fs; } -alias CHARSETINFO* PCHARSETINFO, NPCHARSETINFO, LPCHARSETINFO; +alias PCHARSETINFO = CHARSETINFO*, NPCHARSETINFO = CHARSETINFO*, LPCHARSETINFO = CHARSETINFO*; struct COLORADJUSTMENT { WORD caSize; @@ -2164,7 +2164,7 @@ struct COLORADJUSTMENT { SHORT caColorfulness; SHORT caRedGreenTint; } -alias COLORADJUSTMENT* PCOLORADJUSTMENT, LPCOLORADJUSTMENT; +alias PCOLORADJUSTMENT = COLORADJUSTMENT*, LPCOLORADJUSTMENT = COLORADJUSTMENT*; struct DEVMODEA { BYTE[CCHDEVICENAME] dmDeviceName; @@ -2214,7 +2214,7 @@ struct DEVMODEA { DWORD dmPanningWidth; DWORD dmPanningHeight; } -alias DEVMODEA* PDEVMODEA, NPDEVMODEA, LPDEVMODEA; +alias PDEVMODEA = DEVMODEA*, NPDEVMODEA = DEVMODEA*, LPDEVMODEA = DEVMODEA*; struct DEVMODEW { WCHAR[CCHDEVICENAME] dmDeviceName = 0; @@ -2265,7 +2265,7 @@ struct DEVMODEW { DWORD dmPanningWidth; DWORD dmPanningHeight; } -alias DEVMODEW* PDEVMODEW, NPDEVMODEW, LPDEVMODEW; +alias PDEVMODEW = DEVMODEW*, NPDEVMODEW = DEVMODEW*, LPDEVMODEW = DEVMODEW*; /* * Information about output options @@ -2274,7 +2274,7 @@ struct PSFEATURE_OUTPUT { BOOL bPageIndependent; BOOL bSetPageDevice; } -alias PSFEATURE_OUTPUT* PPSFEATURE_OUTPUT; +alias PPSFEATURE_OUTPUT = PSFEATURE_OUTPUT*; /* * Information about custom paper size @@ -2286,7 +2286,7 @@ struct PSFEATURE_CUSTPAPER { LONG lWidthOffset; LONG lHeightOffset; } -alias PSFEATURE_CUSTPAPER* PPSFEATURE_CUSTPAPER; +alias PPSFEATURE_CUSTPAPER = PSFEATURE_CUSTPAPER*; struct DIBSECTION { BITMAP dsBm; @@ -2295,7 +2295,7 @@ struct DIBSECTION { HANDLE dshSection; DWORD dsOffset; } -alias DIBSECTION* PDIBSECTION; +alias PDIBSECTION = DIBSECTION*; struct DOCINFOA { int cbSize = DOCINFOA.sizeof; @@ -2304,7 +2304,7 @@ struct DOCINFOA { LPCSTR lpszDatatype; DWORD fwType; } -alias DOCINFOA* LPDOCINFOA; +alias LPDOCINFOA = DOCINFOA*; struct DOCINFOW { int cbSize = DOCINFOW.sizeof; @@ -2313,7 +2313,7 @@ struct DOCINFOW { LPCWSTR lpszDatatype; DWORD fwType; } -alias DOCINFOW* LPDOCINFOW; +alias LPDOCINFOW = DOCINFOW*; struct PANOSE { @@ -2328,7 +2328,7 @@ struct PANOSE { BYTE bMidline; BYTE bXHeight; } -alias PANOSE* LPPANOSE; +alias LPPANOSE = PANOSE*; struct LOGFONTA { LONG lfHeight; @@ -2346,7 +2346,7 @@ struct LOGFONTA { BYTE lfPitchAndFamily; CHAR[LF_FACESIZE] lfFaceName = 0; } -alias LOGFONTA* PLOGFONTA, NPLOGFONTA, LPLOGFONTA; +alias PLOGFONTA = LOGFONTA*, NPLOGFONTA = LOGFONTA*, LPLOGFONTA = LOGFONTA*; struct LOGFONTW { LONG lfHeight; @@ -2364,7 +2364,7 @@ struct LOGFONTW { BYTE lfPitchAndFamily; WCHAR[LF_FACESIZE] lfFaceName = 0; } -alias LOGFONTW* PLOGFONTW, NPLOGFONTW, LPLOGFONTW; +alias PLOGFONTW = LOGFONTW*, NPLOGFONTW = LOGFONTW*, LPLOGFONTW = LOGFONTW*; struct EXTLOGFONTA { LOGFONTA elfLogFont; @@ -2378,7 +2378,7 @@ struct EXTLOGFONTA { DWORD elfCulture; PANOSE elfPanose; } -alias EXTLOGFONTA* PEXTLOGFONTA, NPEXTLOGFONTA, LPEXTLOGFONTA; +alias PEXTLOGFONTA = EXTLOGFONTA*, NPEXTLOGFONTA = EXTLOGFONTA*, LPEXTLOGFONTA = EXTLOGFONTA*; struct EXTLOGFONTW { LOGFONTW elfLogFont; @@ -2392,14 +2392,14 @@ struct EXTLOGFONTW { DWORD elfCulture; PANOSE elfPanose; } -alias EXTLOGFONTW* PEXTLOGFONTW, NPEXTLOGFONTW, LPEXTLOGFONTW; +alias PEXTLOGFONTW = EXTLOGFONTW*, NPEXTLOGFONTW = EXTLOGFONTW*, LPEXTLOGFONTW = EXTLOGFONTW*; struct LOGPEN { UINT lopnStyle; POINT lopnWidth; COLORREF lopnColor; } -alias LOGPEN* PLOGPEN, NPLOGPEN, LPLOGPEN; +alias PLOGPEN = LOGPEN*, NPLOGPEN = LOGPEN*, LPLOGPEN = LOGPEN*; // ---------------------- EMR ------------ @@ -2407,7 +2407,7 @@ struct EMR { DWORD iType; DWORD nSize; } -alias EMR* PEMR; +alias PEMR = EMR*; struct EMRANGLEARC { EMR emr; @@ -2416,7 +2416,7 @@ struct EMRANGLEARC { FLOAT eStartAngle; FLOAT eSweepAngle; } -alias EMRANGLEARC* PEMRANGLEARC; +alias PEMRANGLEARC = EMRANGLEARC*; struct EMRARC { EMR emr; @@ -2424,13 +2424,13 @@ struct EMRARC { POINTL ptlStart; POINTL ptlEnd; } -alias EMRARC* PEMRARC; -alias EMRARC EMRARCTO; -alias EMRARCTO* PEMRARCTO; -alias EMRARC EMRCHORD; -alias EMRCHORD* PEMRCHORD; -alias EMRARC EMRPIE; -alias EMRPIE* PEMRPIE; +alias PEMRARC = EMRARC*; +alias EMRARCTO = EMRARC; +alias PEMRARCTO = EMRARCTO*; +alias EMRCHORD = EMRARC; +alias PEMRCHORD = EMRCHORD*; +alias EMRPIE = EMRARC; +alias PEMRPIE = EMRPIE*; struct XFORM { FLOAT eM11; @@ -2440,7 +2440,7 @@ struct XFORM { FLOAT eDx; FLOAT eDy; } -alias XFORM* PXFORM, LPXFORM; +alias PXFORM = XFORM*, LPXFORM = XFORM*; struct EMRBITBLT { EMR emr; @@ -2460,32 +2460,32 @@ struct EMRBITBLT { DWORD offBitsSrc; DWORD cbBitsSrc; } -alias EMRBITBLT* PEMRBITBLT; +alias PEMRBITBLT = EMRBITBLT*; struct LOGBRUSH { UINT lbStyle; COLORREF lbColor; ULONG_PTR lbHatch; } -alias LOGBRUSH PATTERN; -alias LOGBRUSH* PLOGBRUSH, NPLOGBRUSH, LPLOGBRUSH; -alias PATTERN* PPATTERN, NPPATTERN, LPPATTERN; +alias PATTERN = LOGBRUSH; +alias PLOGBRUSH = LOGBRUSH*, NPLOGBRUSH = LOGBRUSH*, LPLOGBRUSH = LOGBRUSH*; +alias PPATTERN = PATTERN*, NPPATTERN = PATTERN*, LPPATTERN = PATTERN*; struct LOGBRUSH32 { UINT lbStyle; COLORREF lbColor; ULONG lbHatch; } -alias LOGBRUSH32* PLOGBRUSH32, NPLOGBRUSH32, LPLOGBRUSH32; +alias PLOGBRUSH32 = LOGBRUSH32*, NPLOGBRUSH32 = LOGBRUSH32*, LPLOGBRUSH32 = LOGBRUSH32*; struct EMRCREATEBRUSHINDIRECT { EMR emr; DWORD ihBrush; LOGBRUSH32 lb; } -alias EMRCREATEBRUSHINDIRECT* PEMRCREATEBRUSHINDIRECT; +alias PEMRCREATEBRUSHINDIRECT = EMRCREATEBRUSHINDIRECT*; -alias LONG LCSCSTYPE, LCSGAMUTMATCH; +alias LCSCSTYPE = LONG, LCSGAMUTMATCH = LONG; struct LOGCOLORSPACEA { DWORD lcsSignature; @@ -2499,7 +2499,7 @@ struct LOGCOLORSPACEA { DWORD lcsGammaBlue; CHAR[MAX_PATH] lcsFilename = 0; } -alias LOGCOLORSPACEA* LPLOGCOLORSPACEA; +alias LPLOGCOLORSPACEA = LOGCOLORSPACEA*; struct LOGCOLORSPACEW { DWORD lcsSignature; @@ -2513,9 +2513,9 @@ struct LOGCOLORSPACEW { DWORD lcsGammaBlue; WCHAR[MAX_PATH] lcsFilename = 0; } -alias LOGCOLORSPACEW* LPLOGCOLORSPACEW; +alias LPLOGCOLORSPACEW = LOGCOLORSPACEW*; -alias USHORT COLOR16; +alias COLOR16 = USHORT; struct TRIVERTEX { LONG x; LONG y; @@ -2524,14 +2524,14 @@ struct TRIVERTEX { COLOR16 Blue; COLOR16 Alpha; } -alias TRIVERTEX* PTRIVERTEX, LPTRIVERTEX; +alias PTRIVERTEX = TRIVERTEX*, LPTRIVERTEX = TRIVERTEX*; struct EMRGLSRECORD { EMR emr; DWORD cbData; BYTE[1] Data; } -alias EMRGLSRECORD* PEMRGLSRECORD; +alias PEMRGLSRECORD = EMRGLSRECORD*; struct EMRGLSBOUNDEDRECORD { EMR emr; @@ -2539,30 +2539,30 @@ struct EMRGLSBOUNDEDRECORD { DWORD cbData; BYTE[1] Data; } -alias EMRGLSBOUNDEDRECORD* PEMRGLSBOUNDEDRECORD; +alias PEMRGLSBOUNDEDRECORD = EMRGLSBOUNDEDRECORD*; struct EMRPIXELFORMAT { EMR emr; PIXELFORMATDESCRIPTOR pfd; } -alias EMRPIXELFORMAT* PEMRPIXELFORMAT; +alias PEMRPIXELFORMAT = EMRPIXELFORMAT*; struct EMRCREATECOLORSPACE { EMR emr; DWORD ihCS; LOGCOLORSPACEA lcs; // ANSI version } -alias EMRCREATECOLORSPACE* PEMRCREATECOLORSPACE; +alias PEMRCREATECOLORSPACE = EMRCREATECOLORSPACE*; struct EMRSETCOLORSPACE { EMR emr; DWORD ihCS; } -alias EMRSETCOLORSPACE* PEMRSETCOLORSPACE; -alias EMRSETCOLORSPACE EMRSELECTCOLORSPACE; -alias EMRSELECTCOLORSPACE* PEMRSELECTCOLORSPACE; -alias EMRSETCOLORSPACE EMRDELETECOLORSPACE; -alias EMRDELETECOLORSPACE* PEMRDELETECOLORSPACE; +alias PEMRSETCOLORSPACE = EMRSETCOLORSPACE*; +alias EMRSELECTCOLORSPACE = EMRSETCOLORSPACE; +alias PEMRSELECTCOLORSPACE = EMRSELECTCOLORSPACE*; +alias EMRDELETECOLORSPACE = EMRSETCOLORSPACE; +alias PEMRDELETECOLORSPACE = EMRDELETECOLORSPACE*; static if (_WIN32_WINNT >= 0x500) { @@ -2572,9 +2572,9 @@ static if (_WIN32_WINNT >= 0x500) { INT cbEscData; BYTE[1] EscData; } - alias EMREXTESCAPE* PEMREXTESCAPE; - alias EMREXTESCAPE EMRDRAWESCAPE; - alias EMRDRAWESCAPE* PEMRDRAWESCAPE; + alias PEMREXTESCAPE = EMREXTESCAPE*; + alias EMRDRAWESCAPE = EMREXTESCAPE; + alias PEMRDRAWESCAPE = EMRDRAWESCAPE*; struct EMRNAMEDESCAPE { EMR emr; @@ -2583,7 +2583,7 @@ static if (_WIN32_WINNT >= 0x500) { INT cbEscData; BYTE[1] EscData; } - alias EMRNAMEDESCAPE* PEMRNAMEDESCAPE; + alias PEMRNAMEDESCAPE = EMRNAMEDESCAPE*; struct EMRSETICMPROFILE { EMR emr; @@ -2592,11 +2592,11 @@ static if (_WIN32_WINNT >= 0x500) { DWORD cbData; BYTE[1] Data; } - alias EMRSETICMPROFILE* PEMRSETICMPROFILE; - alias EMRSETICMPROFILE EMRSETICMPROFILEA; - alias EMRSETICMPROFILEA* PEMRSETICMPROFILEA; - alias EMRSETICMPROFILE EMRSETICMPROFILEW; - alias EMRSETICMPROFILEW* PEMRSETICMPROFILEW; + alias PEMRSETICMPROFILE = EMRSETICMPROFILE*; + alias EMRSETICMPROFILEA = EMRSETICMPROFILE; + alias PEMRSETICMPROFILEA = EMRSETICMPROFILEA*; + alias EMRSETICMPROFILEW = EMRSETICMPROFILE; + alias PEMRSETICMPROFILEW = EMRSETICMPROFILEW*; struct EMRCREATECOLORSPACEW { EMR emr; @@ -2606,7 +2606,7 @@ static if (_WIN32_WINNT >= 0x500) { DWORD cbData; BYTE[1] Data; } - alias EMRCREATECOLORSPACEW* PEMRCREATECOLORSPACEW; + alias PEMRCREATECOLORSPACEW = EMRCREATECOLORSPACEW*; struct EMRCOLORMATCHTOTARGET { EMR emr; @@ -2616,7 +2616,7 @@ static if (_WIN32_WINNT >= 0x500) { DWORD cbData; BYTE[1] Data; } - alias EMRCOLORMATCHTOTARGET* PEMRCOLORMATCHTOTARGET; + alias PEMRCOLORMATCHTOTARGET = EMRCOLORMATCHTOTARGET*; struct EMRCOLORCORRECTPALETTE { EMR emr; @@ -2625,7 +2625,7 @@ static if (_WIN32_WINNT >= 0x500) { DWORD nPalEntries; DWORD nReserved; } - alias EMRCOLORCORRECTPALETTE* PEMRCOLORCORRECTPALETTE; + alias PEMRCOLORCORRECTPALETTE = EMRCOLORCORRECTPALETTE*; struct EMRALPHABLEND { EMR emr; @@ -2647,7 +2647,7 @@ static if (_WIN32_WINNT >= 0x500) { LONG cxSrc; LONG cySrc; } - alias EMRALPHABLEND* PEMRALPHABLEND; + alias PEMRALPHABLEND = EMRALPHABLEND*; struct EMRGRADIENTFILL { EMR emr; @@ -2657,7 +2657,7 @@ static if (_WIN32_WINNT >= 0x500) { ULONG ulMode; TRIVERTEX[1] Ver; } - alias EMRGRADIENTFILL* PEMRGRADIENTFILL; + alias PEMRGRADIENTFILL = EMRGRADIENTFILL*; struct EMRTRANSPARENTBLT { EMR emr; @@ -2679,7 +2679,7 @@ static if (_WIN32_WINNT >= 0x500) { LONG cxSrc; LONG cySrc; } - alias EMRTRANSPARENTBLT* PEMRTRANSPARENTBLT; + alias PEMRTRANSPARENTBLT = EMRTRANSPARENTBLT*; } struct EMRCREATEDIBPATTERNBRUSHPT { @@ -2691,7 +2691,7 @@ struct EMRCREATEDIBPATTERNBRUSHPT { DWORD offBits; DWORD cbBits; } -alias EMRCREATEDIBPATTERNBRUSHPT* PEMRCREATEDIBPATTERNBRUSHPT; +alias PEMRCREATEDIBPATTERNBRUSHPT = EMRCREATEDIBPATTERNBRUSHPT*; struct EMRCREATEMONOBRUSH { EMR emr; @@ -2702,7 +2702,7 @@ struct EMRCREATEMONOBRUSH { DWORD offBits; DWORD cbBits; } -alias EMRCREATEMONOBRUSH* PEMRCREATEMONOBRUSH; +alias PEMRCREATEMONOBRUSH = EMRCREATEMONOBRUSH*; struct PALETTEENTRY { BYTE peRed; @@ -2710,37 +2710,37 @@ struct PALETTEENTRY { BYTE peBlue; BYTE peFlags; } -alias PALETTEENTRY* PPALETTEENTRY, LPPALETTEENTRY; +alias PPALETTEENTRY = PALETTEENTRY*, LPPALETTEENTRY = PALETTEENTRY*; struct LOGPALETTE { WORD palVersion; WORD palNumEntries; PALETTEENTRY[1] palPalEntry; } -alias LOGPALETTE* PLOGPALETTE, NPLOGPALETTE, LPLOGPALETTE; +alias PLOGPALETTE = LOGPALETTE*, NPLOGPALETTE = LOGPALETTE*, LPLOGPALETTE = LOGPALETTE*; struct EMRCREATEPALETTE { EMR emr; DWORD ihPal; LOGPALETTE lgpl; } -alias EMRCREATEPALETTE* PEMRCREATEPALETTE; +alias PEMRCREATEPALETTE = EMRCREATEPALETTE*; struct EMRCREATEPEN { EMR emr; DWORD ihPen; LOGPEN lopn; } -alias EMRCREATEPEN* PEMRCREATEPEN; +alias PEMRCREATEPEN = EMRCREATEPEN*; struct EMRELLIPSE { EMR emr; RECTL rclBox; } -alias EMRELLIPSE* PEMRELLIPSE; +alias PEMRELLIPSE = EMRELLIPSE*; -alias EMRELLIPSE EMRRECTANGLE; -alias EMRRECTANGLE* PEMRRECTANGLE; +alias EMRRECTANGLE = EMRELLIPSE; +alias PEMRRECTANGLE = EMRRECTANGLE*; struct EMREOF { EMR emr; @@ -2748,22 +2748,22 @@ struct EMREOF { DWORD offPalEntries; DWORD nSizeLast; } -alias EMREOF* PEMREOF; +alias PEMREOF = EMREOF*; struct EMREXCLUDECLIPRECT { EMR emr; RECTL rclClip; } -alias EMREXCLUDECLIPRECT* PEMREXCLUDECLIPRECT; -alias EMREXCLUDECLIPRECT EMRINTERSECTCLIPRECT; -alias EMRINTERSECTCLIPRECT* PEMRINTERSECTCLIPRECT; +alias PEMREXCLUDECLIPRECT = EMREXCLUDECLIPRECT*; +alias EMRINTERSECTCLIPRECT = EMREXCLUDECLIPRECT; +alias PEMRINTERSECTCLIPRECT = EMRINTERSECTCLIPRECT*; struct EMREXTCREATEFONTINDIRECTW { EMR emr; DWORD ihFont; EXTLOGFONTW elfw; } -alias EMREXTCREATEFONTINDIRECTW* PEMREXTCREATEFONTINDIRECTW; +alias PEMREXTCREATEFONTINDIRECTW = EMREXTCREATEFONTINDIRECTW*; struct EXTLOGPEN { UINT elpPenStyle; @@ -2774,7 +2774,7 @@ struct EXTLOGPEN { DWORD elpNumEntries; DWORD[1] elpStyleEntry; } -alias EXTLOGPEN* PEXTLOGPEN, NPEXTLOGPEN, LPEXTLOGPEN; +alias PEXTLOGPEN = EXTLOGPEN*, NPEXTLOGPEN = EXTLOGPEN*, LPEXTLOGPEN = EXTLOGPEN*; struct EXTLOGPEN32 { UINT elpPenStyle; @@ -2785,7 +2785,7 @@ struct EXTLOGPEN32 { DWORD elpNumEntries; DWORD[1] elpStyleEntry; } -alias EXTLOGPEN32* PEXTLOGPEN32, NPEXTLOGPEN32, LPEXTLOGPEN32; +alias PEXTLOGPEN32 = EXTLOGPEN32*, NPEXTLOGPEN32 = EXTLOGPEN32*, LPEXTLOGPEN32 = EXTLOGPEN32*; struct EMREXTCREATEPEN { EMR emr; @@ -2796,7 +2796,7 @@ struct EMREXTCREATEPEN { DWORD cbBits; EXTLOGPEN32 elp; } -alias EMREXTCREATEPEN* PEMREXTCREATEPEN; +alias PEMREXTCREATEPEN = EMREXTCREATEPEN*; struct EMREXTFLOODFILL { EMR emr; @@ -2804,7 +2804,7 @@ struct EMREXTFLOODFILL { COLORREF crColor; DWORD iMode; } -alias EMREXTFLOODFILL* PEMREXTFLOODFILL; +alias PEMREXTFLOODFILL = EMREXTFLOODFILL*; struct EMREXTSELECTCLIPRGN { EMR emr; @@ -2812,7 +2812,7 @@ struct EMREXTSELECTCLIPRGN { DWORD iMode; BYTE [1]RgnData; } -alias EMREXTSELECTCLIPRGN* PEMREXTSELECTCLIPRGN; +alias PEMREXTSELECTCLIPRGN = EMREXTSELECTCLIPRGN*; struct EMRTEXT { POINTL ptlReference; @@ -2822,7 +2822,7 @@ struct EMRTEXT { RECTL rcl; DWORD offDx; } -alias EMRTEXT* PEMRTEXT; +alias PEMRTEXT = EMRTEXT*; struct EMREXTTEXTOUTA { EMR emr; @@ -2832,21 +2832,21 @@ struct EMREXTTEXTOUTA { FLOAT eyScale; EMRTEXT emrtext; } -alias EMREXTTEXTOUTA* PEMREXTTEXTOUTA; -alias EMREXTTEXTOUTA EMREXTTEXTOUTW; -alias EMREXTTEXTOUTW* PEMREXTTEXTOUTW; +alias PEMREXTTEXTOUTA = EMREXTTEXTOUTA*; +alias EMREXTTEXTOUTW = EMREXTTEXTOUTA; +alias PEMREXTTEXTOUTW = EMREXTTEXTOUTW*; struct EMRFILLPATH { EMR emr; RECTL rclBounds; } -alias EMRFILLPATH* PEMRFILLPATH; +alias PEMRFILLPATH = EMRFILLPATH*; -alias EMRFILLPATH EMRSTROKEANDFILLPATH; -alias EMRSTROKEANDFILLPATH* PEMRSTROKEANDFILLPATH; +alias EMRSTROKEANDFILLPATH = EMRFILLPATH; +alias PEMRSTROKEANDFILLPATH = EMRSTROKEANDFILLPATH*; -alias EMRFILLPATH EMRSTROKEPATH; -alias EMRSTROKEPATH* PEMRSTROKEPATH; +alias EMRSTROKEPATH = EMRFILLPATH; +alias PEMRSTROKEPATH = EMRSTROKEPATH*; struct EMRFILLRGN { EMR emr; @@ -2855,7 +2855,7 @@ struct EMRFILLRGN { DWORD ihBrush; BYTE[1] RgnData; } -alias EMRFILLRGN* PEMRFILLRGN; +alias PEMRFILLRGN = EMRFILLRGN*; struct EMRFORMAT { DWORD dSignature; @@ -2863,7 +2863,7 @@ struct EMRFORMAT { DWORD cbData; DWORD offData; } -alias EMRFORMAT* PEMRFORMAT; +alias PEMRFORMAT = EMRFORMAT*; struct EMRFRAMERGN { EMR emr; @@ -2873,14 +2873,14 @@ struct EMRFRAMERGN { SIZEL szlStroke; BYTE[1] RgnData; } -alias EMRFRAMERGN* PEMRFRAMERGN; +alias PEMRFRAMERGN = EMRFRAMERGN*; struct EMRGDICOMMENT { EMR emr; DWORD cbData; BYTE[1] Data; } -alias EMRGDICOMMENT* PEMRGDICOMMENT; +alias PEMRGDICOMMENT = EMRGDICOMMENT*; struct EMRINVERTRGN { EMR emr; @@ -2888,17 +2888,17 @@ struct EMRINVERTRGN { DWORD cbRgnData; BYTE[1] RgnData; } -alias EMRINVERTRGN* PEMRINVERTRGN; -alias EMRINVERTRGN EMRPAINTRGN; -alias EMRPAINTRGN* PEMRPAINTRGN; +alias PEMRINVERTRGN = EMRINVERTRGN*; +alias EMRPAINTRGN = EMRINVERTRGN; +alias PEMRPAINTRGN = EMRPAINTRGN*; struct EMRLINETO { EMR emr; POINTL ptl; } -alias EMRLINETO* PEMRLINETO; -alias EMRLINETO EMRMOVETOEX; -alias EMRMOVETOEX* PEMRMOVETOEX; +alias PEMRLINETO = EMRLINETO*; +alias EMRMOVETOEX = EMRLINETO; +alias PEMRMOVETOEX = EMRMOVETOEX*; struct EMRMASKBLT { EMR emr; @@ -2925,20 +2925,20 @@ struct EMRMASKBLT { DWORD offBitsMask; DWORD cbBitsMask; } -alias EMRMASKBLT* PEMRMASKBLT; +alias PEMRMASKBLT = EMRMASKBLT*; struct EMRMODIFYWORLDTRANSFORM { EMR emr; XFORM xform; DWORD iMode; } -alias EMRMODIFYWORLDTRANSFORM* PEMRMODIFYWORLDTRANSFORM; +alias PEMRMODIFYWORLDTRANSFORM = EMRMODIFYWORLDTRANSFORM*; struct EMROFFSETCLIPRGN { EMR emr; POINTL ptlOffset; } -alias EMROFFSETCLIPRGN* PEMROFFSETCLIPRGN; +alias PEMROFFSETCLIPRGN = EMROFFSETCLIPRGN*; struct EMRPLGBLT { EMR emr; @@ -2963,7 +2963,7 @@ struct EMRPLGBLT { DWORD offBitsMask; DWORD cbBitsMask; } -alias EMRPLGBLT* PEMRPLGBLT; +alias PEMRPLGBLT = EMRPLGBLT*; struct EMRPOLYDRAW { EMR emr; @@ -2972,7 +2972,7 @@ struct EMRPOLYDRAW { POINTL[1] aptl; BYTE[1] abTypes; } -alias EMRPOLYDRAW* PEMRPOLYDRAW; +alias PEMRPOLYDRAW = EMRPOLYDRAW*; struct EMRPOLYDRAW16 { EMR emr; @@ -2981,7 +2981,7 @@ struct EMRPOLYDRAW16 { POINTS[1] apts; BYTE[1] abTypes; } -alias EMRPOLYDRAW16* PEMRPOLYDRAW16; +alias PEMRPOLYDRAW16 = EMRPOLYDRAW16*; struct EMRPOLYLINE { EMR emr; @@ -2989,15 +2989,15 @@ struct EMRPOLYLINE { DWORD cptl; POINTL[1] aptl; } -alias EMRPOLYLINE* PEMRPOLYLINE; -alias EMRPOLYLINE EMRPOLYBEZIER; -alias EMRPOLYBEZIER* PEMRPOLYBEZIER; -alias EMRPOLYLINE EMRPOLYGON; -alias EMRPOLYGON* PEMRPOLYGON; -alias EMRPOLYLINE EMRPOLYBEZIERTO; -alias EMRPOLYBEZIERTO* PEMRPOLYBEZIERTO; -alias EMRPOLYLINE EMRPOLYLINETO; -alias EMRPOLYLINETO* PEMRPOLYLINETO; +alias PEMRPOLYLINE = EMRPOLYLINE*; +alias EMRPOLYBEZIER = EMRPOLYLINE; +alias PEMRPOLYBEZIER = EMRPOLYBEZIER*; +alias EMRPOLYGON = EMRPOLYLINE; +alias PEMRPOLYGON = EMRPOLYGON*; +alias EMRPOLYBEZIERTO = EMRPOLYLINE; +alias PEMRPOLYBEZIERTO = EMRPOLYBEZIERTO*; +alias EMRPOLYLINETO = EMRPOLYLINE; +alias PEMRPOLYLINETO = EMRPOLYLINETO*; struct EMRPOLYLINE16 { EMR emr; @@ -3005,15 +3005,15 @@ struct EMRPOLYLINE16 { DWORD cpts; POINTS[1] apts; } -alias EMRPOLYLINE16* PEMRPOLYLINE16; -alias EMRPOLYLINE16 EMRPOLYBEZIER16; -alias EMRPOLYBEZIER16* PEMRPOLYBEZIER16; -alias EMRPOLYLINE16 EMRPOLYGON16; -alias EMRPOLYGON16* PEMRPOLYGON16; -alias EMRPOLYLINE16 EMRPOLYBEZIERTO16; -alias EMRPOLYBEZIERTO16* PEMRPOLYBEZIERTO16; -alias EMRPOLYLINE16 EMRPOLYLINETO16; -alias EMRPOLYLINETO16* PEMRPOLYLINETO16; +alias PEMRPOLYLINE16 = EMRPOLYLINE16*; +alias EMRPOLYBEZIER16 = EMRPOLYLINE16; +alias PEMRPOLYBEZIER16 = EMRPOLYBEZIER16*; +alias EMRPOLYGON16 = EMRPOLYLINE16; +alias PEMRPOLYGON16 = EMRPOLYGON16*; +alias EMRPOLYBEZIERTO16 = EMRPOLYLINE16; +alias PEMRPOLYBEZIERTO16 = EMRPOLYBEZIERTO16*; +alias EMRPOLYLINETO16 = EMRPOLYLINE16; +alias PEMRPOLYLINETO16 = EMRPOLYLINETO16*; struct EMRPOLYPOLYLINE { EMR emr; @@ -3023,9 +3023,9 @@ struct EMRPOLYPOLYLINE { DWORD[1] aPolyCounts; POINTL[1] aptl; } -alias EMRPOLYPOLYLINE* PEMRPOLYPOLYLINE; -alias EMRPOLYPOLYLINE EMRPOLYPOLYGON; -alias EMRPOLYPOLYGON* PEMRPOLYPOLYGON; +alias PEMRPOLYPOLYLINE = EMRPOLYPOLYLINE*; +alias EMRPOLYPOLYGON = EMRPOLYPOLYLINE; +alias PEMRPOLYPOLYGON = EMRPOLYPOLYGON*; struct EMRPOLYPOLYLINE16 { EMR emr; @@ -3035,9 +3035,9 @@ struct EMRPOLYPOLYLINE16 { DWORD[1] aPolyCounts; POINTS[1] apts; } -alias EMRPOLYPOLYLINE16* PEMRPOLYPOLYLINE16; -alias EMRPOLYPOLYLINE16 EMRPOLYPOLYGON16; -alias EMRPOLYPOLYGON16* PEMRPOLYPOLYGON16; +alias PEMRPOLYPOLYLINE16 = EMRPOLYPOLYLINE16*; +alias EMRPOLYPOLYGON16 = EMRPOLYPOLYLINE16; +alias PEMRPOLYPOLYGON16 = EMRPOLYPOLYGON16*; struct EMRPOLYTEXTOUTA { EMR emr; @@ -3048,29 +3048,29 @@ struct EMRPOLYTEXTOUTA { LONG cStrings; EMRTEXT[1] aemrtext; } -alias EMRPOLYTEXTOUTA* PEMRPOLYTEXTOUTA; -alias EMRPOLYTEXTOUTA EMRPOLYTEXTOUTW; -alias EMRPOLYTEXTOUTW* PEMRPOLYTEXTOUTW; +alias PEMRPOLYTEXTOUTA = EMRPOLYTEXTOUTA*; +alias EMRPOLYTEXTOUTW = EMRPOLYTEXTOUTA; +alias PEMRPOLYTEXTOUTW = EMRPOLYTEXTOUTW*; struct EMRRESIZEPALETTE { EMR emr; DWORD ihPal; DWORD cEntries; } -alias EMRRESIZEPALETTE* PEMRRESIZEPALETTE; +alias PEMRRESIZEPALETTE = EMRRESIZEPALETTE*; struct EMRRESTOREDC { EMR emr; LONG iRelative; } -alias EMRRESTOREDC* PEMRRESTOREDC; +alias PEMRRESTOREDC = EMRRESTOREDC*; struct EMRROUNDRECT { EMR emr; RECTL rclBox; SIZEL szlCorner; } -alias EMRROUNDRECT* PEMRROUNDRECT; +alias PEMRROUNDRECT = EMRROUNDRECT*; struct EMRSCALEVIEWPORTEXTEX { EMR emr; @@ -3079,43 +3079,43 @@ struct EMRSCALEVIEWPORTEXTEX { LONG yNum; LONG yDenom; } -alias EMRSCALEVIEWPORTEXTEX* PEMRSCALEVIEWPORTEXTEX; -alias EMRSCALEVIEWPORTEXTEX EMRSCALEWINDOWEXTEX; -alias EMRSCALEWINDOWEXTEX* PEMRSCALEWINDOWEXTEX; +alias PEMRSCALEVIEWPORTEXTEX = EMRSCALEVIEWPORTEXTEX*; +alias EMRSCALEWINDOWEXTEX = EMRSCALEVIEWPORTEXTEX; +alias PEMRSCALEWINDOWEXTEX = EMRSCALEWINDOWEXTEX*; struct EMRSELECTOBJECT { EMR emr; DWORD ihObject; } -alias EMRSELECTOBJECT* PEMRSELECTOBJECT; -alias EMRSELECTOBJECT EMRDELETEOBJECT; -alias EMRDELETEOBJECT* PEMRDELETEOBJECT; +alias PEMRSELECTOBJECT = EMRSELECTOBJECT*; +alias EMRDELETEOBJECT = EMRSELECTOBJECT; +alias PEMRDELETEOBJECT = EMRDELETEOBJECT*; struct EMRSELECTPALETTE { EMR emr; DWORD ihPal; } -alias EMRSELECTPALETTE* PEMRSELECTPALETTE; +alias PEMRSELECTPALETTE = EMRSELECTPALETTE*; struct EMRSETARCDIRECTION { EMR emr; DWORD iArcDirection; } -alias EMRSETARCDIRECTION* PEMRSETARCDIRECTION; +alias PEMRSETARCDIRECTION = EMRSETARCDIRECTION*; struct EMRSETTEXTCOLOR { EMR emr; COLORREF crColor; } -alias EMRSETTEXTCOLOR* PEMRSETTEXTCOLOR; -alias EMRSETTEXTCOLOR EMRSETBKCOLOR; -alias EMRSETBKCOLOR* PEMRSETBKCOLOR; +alias PEMRSETTEXTCOLOR = EMRSETTEXTCOLOR*; +alias EMRSETBKCOLOR = EMRSETTEXTCOLOR; +alias PEMRSETBKCOLOR = EMRSETBKCOLOR*; struct EMRSETCOLORADJUSTMENT { EMR emr; COLORADJUSTMENT ColorAdjustment; } -alias EMRSETCOLORADJUSTMENT* PEMRSETCOLORADJUSTMENT; +alias PEMRSETCOLORADJUSTMENT = EMRSETCOLORADJUSTMENT*; struct EMRSETDIBITSTODEVICE { EMR emr; @@ -3134,19 +3134,19 @@ struct EMRSETDIBITSTODEVICE { DWORD iStartScan; DWORD cScans; } -alias EMRSETDIBITSTODEVICE* PEMRSETDIBITSTODEVICE; +alias PEMRSETDIBITSTODEVICE = EMRSETDIBITSTODEVICE*; struct EMRSETMAPPERFLAGS { EMR emr; DWORD dwFlags; } -alias EMRSETMAPPERFLAGS* PEMRSETMAPPERFLAGS; +alias PEMRSETMAPPERFLAGS = EMRSETMAPPERFLAGS*; struct EMRSETMITERLIMIT { EMR emr; FLOAT eMiterLimit; } -alias EMRSETMITERLIMIT* PEMRSETMITERLIMIT; +alias PEMRSETMITERLIMIT = EMRSETMITERLIMIT*; struct EMRSETPALETTEENTRIES { EMR emr; @@ -3155,38 +3155,38 @@ struct EMRSETPALETTEENTRIES { DWORD cEntries; PALETTEENTRY[1] aPalEntries; } -alias EMRSETPALETTEENTRIES* PEMRSETPALETTEENTRIES; +alias PEMRSETPALETTEENTRIES = EMRSETPALETTEENTRIES*; struct EMRSETPIXELV { EMR emr; POINTL ptlPixel; COLORREF crColor; } -alias EMRSETPIXELV* PEMRSETPIXELV; +alias PEMRSETPIXELV = EMRSETPIXELV*; struct EMRSETVIEWPORTEXTEX { EMR emr; SIZEL szlExtent; } -alias EMRSETVIEWPORTEXTEX* PEMRSETVIEWPORTEXTEX; -alias EMRSETVIEWPORTEXTEX EMRSETWINDOWEXTEX; -alias EMRSETWINDOWEXTEX* PEMRSETWINDOWEXTEX; +alias PEMRSETVIEWPORTEXTEX = EMRSETVIEWPORTEXTEX*; +alias EMRSETWINDOWEXTEX = EMRSETVIEWPORTEXTEX; +alias PEMRSETWINDOWEXTEX = EMRSETWINDOWEXTEX*; struct EMRSETVIEWPORTORGEX { EMR emr; POINTL ptlOrigin; } -alias EMRSETVIEWPORTORGEX* PEMRSETVIEWPORTORGEX; -alias EMRSETVIEWPORTORGEX EMRSETWINDOWORGEX; -alias EMRSETWINDOWORGEX* PEMRSETWINDOWORGEX; -alias EMRSETVIEWPORTORGEX EMRSETBRUSHORGEX; -alias EMRSETBRUSHORGEX* PEMRSETBRUSHORGEX; +alias PEMRSETVIEWPORTORGEX = EMRSETVIEWPORTORGEX*; +alias EMRSETWINDOWORGEX = EMRSETVIEWPORTORGEX; +alias PEMRSETWINDOWORGEX = EMRSETWINDOWORGEX*; +alias EMRSETBRUSHORGEX = EMRSETVIEWPORTORGEX; +alias PEMRSETBRUSHORGEX = EMRSETBRUSHORGEX*; struct EMRSETWORLDTRANSFORM { EMR emr; XFORM xform; } -alias EMRSETWORLDTRANSFORM* PEMRSETWORLDTRANSFORM; +alias PEMRSETWORLDTRANSFORM = EMRSETWORLDTRANSFORM*; struct EMRSTRETCHBLT { EMR emr; @@ -3208,7 +3208,7 @@ struct EMRSTRETCHBLT { LONG cxSrc; LONG cySrc; } -alias EMRSTRETCHBLT* PEMRSTRETCHBLT; +alias PEMRSTRETCHBLT = EMRSTRETCHBLT*; struct EMRSTRETCHDIBITS { EMR emr; @@ -3228,53 +3228,53 @@ struct EMRSTRETCHDIBITS { LONG cxDest; LONG cyDest; } -alias EMRSTRETCHDIBITS* PEMRSTRETCHDIBITS; +alias PEMRSTRETCHDIBITS = EMRSTRETCHDIBITS*; struct EMRABORTPATH { EMR emr; } -alias EMRABORTPATH* PEMRABORTPATH; -alias EMRABORTPATH EMRBEGINPATH; -alias EMRBEGINPATH* PEMRBEGINPATH; -alias EMRABORTPATH EMRENDPATH; -alias EMRENDPATH* PEMRENDPATH; -alias EMRABORTPATH EMRCLOSEFIGURE; -alias EMRCLOSEFIGURE* PEMRCLOSEFIGURE; -alias EMRABORTPATH EMRFLATTENPATH; -alias EMRFLATTENPATH* PEMRFLATTENPATH; -alias EMRABORTPATH EMRWIDENPATH; -alias EMRWIDENPATH* PEMRWIDENPATH; -alias EMRABORTPATH EMRSETMETARGN; -alias EMRSETMETARGN* PEMRSETMETARGN; -alias EMRABORTPATH EMRSAVEDC; -alias EMRSAVEDC* PEMRSAVEDC; -alias EMRABORTPATH EMRREALIZEPALETTE; -alias EMRREALIZEPALETTE* PEMRREALIZEPALETTE; +alias PEMRABORTPATH = EMRABORTPATH*; +alias EMRBEGINPATH = EMRABORTPATH; +alias PEMRBEGINPATH = EMRBEGINPATH*; +alias EMRENDPATH = EMRABORTPATH; +alias PEMRENDPATH = EMRENDPATH*; +alias EMRCLOSEFIGURE = EMRABORTPATH; +alias PEMRCLOSEFIGURE = EMRCLOSEFIGURE*; +alias EMRFLATTENPATH = EMRABORTPATH; +alias PEMRFLATTENPATH = EMRFLATTENPATH*; +alias EMRWIDENPATH = EMRABORTPATH; +alias PEMRWIDENPATH = EMRWIDENPATH*; +alias EMRSETMETARGN = EMRABORTPATH; +alias PEMRSETMETARGN = EMRSETMETARGN*; +alias EMRSAVEDC = EMRABORTPATH; +alias PEMRSAVEDC = EMRSAVEDC*; +alias EMRREALIZEPALETTE = EMRABORTPATH; +alias PEMRREALIZEPALETTE = EMRREALIZEPALETTE*; struct EMRSELECTCLIPPATH { EMR emr; DWORD iMode; } -alias EMRSELECTCLIPPATH* PEMRSELECTCLIPPATH; -alias EMRSELECTCLIPPATH EMRSETBKMODE; -alias EMRSETBKMODE* PEMRSETBKMODE; -alias EMRSELECTCLIPPATH EMRSETMAPMODE; -alias EMRSETMAPMODE* PEMRSETMAPMODE; -alias EMRSELECTCLIPPATH EMRSETPOLYFILLMODE; -alias EMRSETPOLYFILLMODE* PEMRSETPOLYFILLMODE; -alias EMRSELECTCLIPPATH EMRSETROP2; -alias EMRSETROP2* PEMRSETROP2; -alias EMRSELECTCLIPPATH EMRSETSTRETCHBLTMODE; -alias EMRSETSTRETCHBLTMODE* PEMRSETSTRETCHBLTMODE; -alias EMRSELECTCLIPPATH EMRSETICMMODE; -alias EMRSETICMMODE* PEMRSETICMMODE; -alias EMRSELECTCLIPPATH EMRSETTEXTALIGN; -alias EMRSETTEXTALIGN* PEMRSETTEXTALIGN; -alias EMRSELECTCLIPPATH EMRENABLEICM; -alias EMRENABLEICM* PEMRENABLEICM; +alias PEMRSELECTCLIPPATH = EMRSELECTCLIPPATH*; +alias EMRSETBKMODE = EMRSELECTCLIPPATH; +alias PEMRSETBKMODE = EMRSETBKMODE*; +alias EMRSETMAPMODE = EMRSELECTCLIPPATH; +alias PEMRSETMAPMODE = EMRSETMAPMODE*; +alias EMRSETPOLYFILLMODE = EMRSELECTCLIPPATH; +alias PEMRSETPOLYFILLMODE = EMRSETPOLYFILLMODE*; +alias EMRSETROP2 = EMRSELECTCLIPPATH; +alias PEMRSETROP2 = EMRSETROP2*; +alias EMRSETSTRETCHBLTMODE = EMRSELECTCLIPPATH; +alias PEMRSETSTRETCHBLTMODE = EMRSETSTRETCHBLTMODE*; +alias EMRSETICMMODE = EMRSELECTCLIPPATH; +alias PEMRSETICMMODE = EMRSETICMMODE*; +alias EMRSETTEXTALIGN = EMRSELECTCLIPPATH; +alias PEMRSETTEXTALIGN = EMRSETTEXTALIGN*; +alias EMRENABLEICM = EMRSELECTCLIPPATH; +alias PEMRENABLEICM = EMRENABLEICM*; static if (_WIN32_WINNT >= 0x500) { - alias EMRSELECTCLIPPATH EMRSETLAYOUT; - alias EMRSETLAYOUT* PEMRSETLAYOUT; + alias EMRSETLAYOUT = EMRSELECTCLIPPATH; + alias PEMRSETLAYOUT = EMRSETLAYOUT*; } align(2): @@ -3288,8 +3288,8 @@ align(2): DWORD mtMaxRecord; WORD mtNoParameters; } -alias METAHEADER* PMETAHEADER; -alias METAHEADER* LPMETAHEADER; +alias PMETAHEADER = METAHEADER*; +alias LPMETAHEADER = METAHEADER*; align: @@ -3316,29 +3316,29 @@ struct ENHMETAHEADER { SIZEL szlMicrometers; } } -alias ENHMETAHEADER* PENHMETAHEADER, LPENHMETAHEADER; +alias PENHMETAHEADER = ENHMETAHEADER*, LPENHMETAHEADER = ENHMETAHEADER*; struct METARECORD { DWORD rdSize; WORD rdFunction; WORD[1] rdParm; } -alias METARECORD* PMETARECORD; -alias METARECORD* LPMETARECORD; +alias PMETARECORD = METARECORD*; +alias LPMETARECORD = METARECORD*; struct ENHMETARECORD { DWORD iType; DWORD nSize; DWORD[1] dParm; } -alias ENHMETARECORD* PENHMETARECORD, LPENHMETARECORD; +alias PENHMETARECORD = ENHMETARECORD*, LPENHMETARECORD = ENHMETARECORD*; // --- struct HANDLETABLE { HGDIOBJ[1] objectHandle; } -alias HANDLETABLE* PHANDLETABLE, LPHANDLETABLE; +alias PHANDLETABLE = HANDLETABLE*, LPHANDLETABLE = HANDLETABLE*; struct TEXTMETRICA { LONG tmHeight; @@ -3362,7 +3362,7 @@ struct TEXTMETRICA { BYTE tmPitchAndFamily; BYTE tmCharSet; } -alias TEXTMETRICA* PTEXTMETRICA, NPTEXTMETRICA, LPTEXTMETRICA; +alias PTEXTMETRICA = TEXTMETRICA*, NPTEXTMETRICA = TEXTMETRICA*, LPTEXTMETRICA = TEXTMETRICA*; struct TEXTMETRICW { LONG tmHeight; @@ -3386,7 +3386,7 @@ struct TEXTMETRICW { BYTE tmPitchAndFamily; BYTE tmCharSet; } -alias TEXTMETRICW* PTEXTMETRICW, NPTEXTMETRICW, LPTEXTMETRICW; +alias PTEXTMETRICW = TEXTMETRICW*, NPTEXTMETRICW = TEXTMETRICW*, LPTEXTMETRICW = TEXTMETRICW*; struct RGNDATAHEADER { DWORD dwSize; @@ -3395,13 +3395,13 @@ struct RGNDATAHEADER { DWORD nRgnSize; RECT rcBound; } -alias RGNDATAHEADER* PRGNDATAHEADER; +alias PRGNDATAHEADER = RGNDATAHEADER*; struct RGNDATA { RGNDATAHEADER rdh; char[1] Buffer = 0; } -alias RGNDATA* PRGNDATA, NPRGNDATA, LPRGNDATA; +alias PRGNDATA = RGNDATA*, NPRGNDATA = RGNDATA*, LPRGNDATA = RGNDATA*; /* for GetRandomRgn */ enum SYSRGN=4; @@ -3416,7 +3416,7 @@ struct GCP_RESULTSA { UINT nGlyphs; UINT nMaxFit; } -alias GCP_RESULTSA* LPGCP_RESULTSA; +alias LPGCP_RESULTSA = GCP_RESULTSA*; struct GCP_RESULTSW { DWORD lStructSize; @@ -3429,7 +3429,7 @@ struct GCP_RESULTSW { UINT nGlyphs; UINT nMaxFit; } -alias GCP_RESULTSW* LPGCP_RESULTSW; +alias LPGCP_RESULTSW = GCP_RESULTSW*; struct GLYPHMETRICS { UINT gmBlackBoxX; @@ -3438,14 +3438,14 @@ struct GLYPHMETRICS { short gmCellIncX; short gmCellIncY; } -alias GLYPHMETRICS* LPGLYPHMETRICS; +alias LPGLYPHMETRICS = GLYPHMETRICS*; static if (_WIN32_WINNT >= 0x500) { struct WCRANGE { WCHAR wcLow = 0; USHORT cGlyphs; } - alias WCRANGE* PWCRANGE, LPWCRANGE; + alias PWCRANGE = WCRANGE*, LPWCRANGE = WCRANGE*; struct GLYPHSET { DWORD cbThis; @@ -3454,7 +3454,7 @@ static if (_WIN32_WINNT >= 0x500) { DWORD cRanges; WCRANGE[1] ranges; } - alias GLYPHSET* PGLYPHSET, LPGLYPHSET; + alias PGLYPHSET = GLYPHSET*, LPGLYPHSET = GLYPHSET*; enum DWORD GS_8BIT_INDICES = 0x00000001; } @@ -3464,7 +3464,7 @@ struct KERNINGPAIR { WORD wSecond; int iKernAmount; } -alias KERNINGPAIR* LPKERNINGPAIR; +alias LPKERNINGPAIR = KERNINGPAIR*; struct FIXED { WORD fract; @@ -3477,7 +3477,7 @@ struct MAT2 { FIXED eM21; FIXED eM22; } -alias MAT2* LPMAT2; +alias LPMAT2 = MAT2*; struct OUTLINETEXTMETRICA { UINT otmSize; @@ -3513,7 +3513,7 @@ struct OUTLINETEXTMETRICA { PSTR otmpStyleName; PSTR otmpFullName; } -alias OUTLINETEXTMETRICA* POUTLINETEXTMETRICA, NPOUTLINETEXTMETRICA, LPOUTLINETEXTMETRICA; +alias POUTLINETEXTMETRICA = OUTLINETEXTMETRICA*, NPOUTLINETEXTMETRICA = OUTLINETEXTMETRICA*, LPOUTLINETEXTMETRICA = OUTLINETEXTMETRICA*; struct OUTLINETEXTMETRICW { UINT otmSize; @@ -3549,14 +3549,14 @@ struct OUTLINETEXTMETRICW { PSTR otmpStyleName; PSTR otmpFullName; } -alias OUTLINETEXTMETRICW* POUTLINETEXTMETRICW, NPOUTLINETEXTMETRICW, LPOUTLINETEXTMETRICW; +alias POUTLINETEXTMETRICW = OUTLINETEXTMETRICW*, NPOUTLINETEXTMETRICW = OUTLINETEXTMETRICW*, LPOUTLINETEXTMETRICW = OUTLINETEXTMETRICW*; struct RASTERIZER_STATUS { short nSize; short wFlags; short nLanguageID; } -alias RASTERIZER_STATUS* LPRASTERIZER_STATUS; +alias LPRASTERIZER_STATUS = RASTERIZER_STATUS*; struct POLYTEXTA { int x; @@ -3567,7 +3567,7 @@ struct POLYTEXTA { RECT rcl; int* pdx; } -alias POLYTEXTA* PPOLYTEXTA, NPPOLYTEXTA, LPPOLYTEXTA; +alias PPOLYTEXTA = POLYTEXTA*, NPPOLYTEXTA = POLYTEXTA*, LPPOLYTEXTA = POLYTEXTA*; struct POLYTEXTW { int x; @@ -3578,7 +3578,7 @@ struct POLYTEXTW { RECT rcl; int* pdx; } -alias POLYTEXTW* PPOLYTEXTW, NPPOLYTEXTW, LPPOLYTEXTW; +alias PPOLYTEXTW = POLYTEXTW*, NPPOLYTEXTW = POLYTEXTW*, LPPOLYTEXTW = POLYTEXTW*; struct PIXELFORMATDESCRIPTOR { WORD nSize; @@ -3608,7 +3608,7 @@ struct PIXELFORMATDESCRIPTOR { DWORD dwVisibleMask; DWORD dwDamageMask; } -alias PIXELFORMATDESCRIPTOR* PPIXELFORMATDESCRIPTOR, LPPIXELFORMATDESCRIPTOR; +alias PPIXELFORMATDESCRIPTOR = PIXELFORMATDESCRIPTOR*, LPPIXELFORMATDESCRIPTOR = PIXELFORMATDESCRIPTOR*; struct METAFILEPICT { LONG mm; @@ -3616,16 +3616,16 @@ struct METAFILEPICT { LONG yExt; HMETAFILE hMF; } -alias METAFILEPICT* LPMETAFILEPICT; +alias LPMETAFILEPICT = METAFILEPICT*; struct LOCALESIGNATURE { DWORD[4] lsUsb; DWORD[2] lsCsbDefault; DWORD[2] lsCsbSupported; } -alias LOCALESIGNATURE* PLOCALESIGNATURE, LPLOCALESIGNATURE; +alias PLOCALESIGNATURE = LOCALESIGNATURE*, LPLOCALESIGNATURE = LOCALESIGNATURE*; -alias LONG LCSTYPE; /* What this for? */ +alias LCSTYPE = LONG; /* What this for? */ align(4): struct NEWTEXTMETRICA { @@ -3654,7 +3654,7 @@ struct NEWTEXTMETRICA { UINT ntmCellHeight; UINT ntmAvgWidth; } -alias NEWTEXTMETRICA* PNEWTEXTMETRICA, NPNEWTEXTMETRICA, LPNEWTEXTMETRICA; +alias PNEWTEXTMETRICA = NEWTEXTMETRICA*, NPNEWTEXTMETRICA = NEWTEXTMETRICA*, LPNEWTEXTMETRICA = NEWTEXTMETRICA*; struct NEWTEXTMETRICW { LONG tmHeight; @@ -3682,7 +3682,7 @@ struct NEWTEXTMETRICW { UINT ntmCellHeight; UINT ntmAvgWidth; } -alias NEWTEXTMETRICW* PNEWTEXTMETRICW, NPNEWTEXTMETRICW, LPNEWTEXTMETRICW; +alias PNEWTEXTMETRICW = NEWTEXTMETRICW*, NPNEWTEXTMETRICW = NEWTEXTMETRICW*, LPNEWTEXTMETRICW = NEWTEXTMETRICW*; align: struct NEWTEXTMETRICEXA { @@ -3702,21 +3702,21 @@ struct PELARRAY { LONG paYExt; BYTE paRGBs; } -alias PELARRAY* PPELARRAY, NPPELARRAY, LPPELARRAY; +alias PPELARRAY = PELARRAY*, NPPELARRAY = PELARRAY*, LPPELARRAY = PELARRAY*; struct ENUMLOGFONTA { LOGFONTA elfLogFont; BYTE[LF_FULLFACESIZE] elfFullName; BYTE[LF_FACESIZE] elfStyle; } -alias ENUMLOGFONTA* LPENUMLOGFONTA; +alias LPENUMLOGFONTA = ENUMLOGFONTA*; struct ENUMLOGFONTW { LOGFONTW elfLogFont; WCHAR[LF_FULLFACESIZE] elfFullName = 0; WCHAR[LF_FACESIZE] elfStyle = 0; } -alias ENUMLOGFONTW* LPENUMLOGFONTW; +alias LPENUMLOGFONTW = ENUMLOGFONTW*; struct ENUMLOGFONTEXA { LOGFONTA elfLogFont; @@ -3724,7 +3724,7 @@ struct ENUMLOGFONTEXA { BYTE[LF_FACESIZE] elfStyle; BYTE[LF_FACESIZE] elfScript; } -alias ENUMLOGFONTEXA* LPENUMLOGFONTEXA; +alias LPENUMLOGFONTEXA = ENUMLOGFONTEXA*; struct ENUMLOGFONTEXW { LOGFONTW elfLogFont; @@ -3732,33 +3732,33 @@ struct ENUMLOGFONTEXW { WCHAR[LF_FACESIZE] elfStyle = 0; WCHAR[LF_FACESIZE] elfScript = 0; } -alias ENUMLOGFONTEXW* LPENUMLOGFONTEXW; +alias LPENUMLOGFONTEXW = ENUMLOGFONTEXW*; struct POINTFX { FIXED x; FIXED y; } -alias POINTFX* LPPOINTFX; +alias LPPOINTFX = POINTFX*; struct TTPOLYCURVE { WORD wType; WORD cpfx; POINTFX[1] apfx; } -alias TTPOLYCURVE* LPTTPOLYCURVE; +alias LPTTPOLYCURVE = TTPOLYCURVE*; struct TTPOLYGONHEADER { DWORD cb; DWORD dwType; POINTFX pfxStart; } -alias TTPOLYGONHEADER* LPTTPOLYGONHEADER; +alias LPTTPOLYGONHEADER = TTPOLYGONHEADER*; struct POINTFLOAT { FLOAT x; FLOAT y; } -alias POINTFLOAT* PPOINTFLOAT; +alias PPOINTFLOAT = POINTFLOAT*; struct GLYPHMETRICSFLOAT { FLOAT gmfBlackBoxX; @@ -3767,7 +3767,7 @@ struct GLYPHMETRICSFLOAT { FLOAT gmfCellIncX; FLOAT gmfCellIncY; } -alias GLYPHMETRICSFLOAT* PGLYPHMETRICSFLOAT, LPGLYPHMETRICSFLOAT; +alias PGLYPHMETRICSFLOAT = GLYPHMETRICSFLOAT*, LPGLYPHMETRICSFLOAT = GLYPHMETRICSFLOAT*; struct LAYERPLANEDESCRIPTOR { WORD nSize; @@ -3795,7 +3795,7 @@ struct LAYERPLANEDESCRIPTOR { BYTE bReserved; COLORREF crTransparent; } -alias LAYERPLANEDESCRIPTOR* PLAYERPLANEDESCRIPTOR, LPLAYERPLANEDESCRIPTOR; +alias PLAYERPLANEDESCRIPTOR = LAYERPLANEDESCRIPTOR*, LPLAYERPLANEDESCRIPTOR = LAYERPLANEDESCRIPTOR*; struct BLENDFUNCTION { BYTE BlendOp; @@ -3803,7 +3803,7 @@ struct BLENDFUNCTION { BYTE SourceConstantAlpha; BYTE AlphaFormat; } -alias BLENDFUNCTION* PBLENDFUNCTION, LPBLENDFUNCTION; +alias PBLENDFUNCTION = BLENDFUNCTION*, LPBLENDFUNCTION = BLENDFUNCTION*; enum MM_MAX_NUMAXES = 16; @@ -3812,7 +3812,7 @@ struct DESIGNVECTOR { DWORD dvNumAxes; LONG[MM_MAX_NUMAXES] dvValues; } -alias DESIGNVECTOR* PDESIGNVECTOR, LPDESIGNVECTOR; +alias PDESIGNVECTOR = DESIGNVECTOR*, LPDESIGNVECTOR = DESIGNVECTOR*; enum STAMP_DESIGNVECTOR = 0x8000000 + 'd' + ('v' << 8); enum STAMP_AXESLIST = 0x8000000 + 'a' + ('l' << 8); @@ -3825,24 +3825,24 @@ enum MM_MAX_AXES_NAMELEN = 16; LONG axMaxValue; BYTE[MM_MAX_AXES_NAMELEN] axAxisName; } - alias AXISINFOA* PAXISINFOA, LPAXISINFOA; + alias PAXISINFOA = AXISINFOA*, LPAXISINFOA = AXISINFOA*; struct AXISINFOW { LONG axMinValue; LONG axMaxValue; WCHAR[MM_MAX_AXES_NAMELEN] axAxisName = 0; } - alias AXISINFOW* PAXISINFOW, LPAXISINFOW; + alias PAXISINFOW = AXISINFOW*, LPAXISINFOW = AXISINFOW*; version (Unicode) { - alias AXISINFOW AXISINFO; - alias PAXISINFOW PAXISINFO; - alias LPAXISINFOW LPAXISINFO; + alias AXISINFO = AXISINFOW; + alias PAXISINFO = PAXISINFOW; + alias LPAXISINFO = LPAXISINFOW; } else { - alias AXISINFOA AXISINFO; - alias PAXISINFOA PAXISINFO; - alias LPAXISINFOA LPAXISINFO; + alias AXISINFO = AXISINFOA; + alias PAXISINFO = PAXISINFOA; + alias LPAXISINFO = LPAXISINFOA; } struct AXESLISTA { @@ -3850,68 +3850,68 @@ enum MM_MAX_AXES_NAMELEN = 16; DWORD axlNumAxes; AXISINFOA[MM_MAX_NUMAXES] axlAxisInfo; } - alias AXESLISTA* PAXESLISTA, LPAXESLISTA; + alias PAXESLISTA = AXESLISTA*, LPAXESLISTA = AXESLISTA*; struct AXESLISTW { DWORD axlReserved; DWORD axlNumAxes; AXISINFOW[MM_MAX_NUMAXES] axlAxisInfo; } - alias AXESLISTW* PAXESLISTW, LPAXESLISTW; + alias PAXESLISTW = AXESLISTW*, LPAXESLISTW = AXESLISTW*; version (Unicode) { - alias AXESLISTW AXESLIST; - alias PAXESLISTW PAXESLIST; - alias LPAXESLISTW LPAXESLIST; + alias AXESLIST = AXESLISTW; + alias PAXESLIST = PAXESLISTW; + alias LPAXESLIST = LPAXESLISTW; } else { - alias AXESLISTA AXESLIST; - alias PAXESLISTA PAXESLIST; - alias LPAXESLISTA LPAXESLIST; + alias AXESLIST = AXESLISTA; + alias PAXESLIST = PAXESLISTA; + alias LPAXESLIST = LPAXESLISTA; } struct ENUMLOGFONTEXDVA { ENUMLOGFONTEXA elfEnumLogfontEx; DESIGNVECTOR elfDesignVector; } - alias ENUMLOGFONTEXDVA* PENUMLOGFONTEXDVA, LPENUMLOGFONTEXDVA; + alias PENUMLOGFONTEXDVA = ENUMLOGFONTEXDVA*, LPENUMLOGFONTEXDVA = ENUMLOGFONTEXDVA*; struct ENUMLOGFONTEXDVW { ENUMLOGFONTEXW elfEnumLogfontEx; DESIGNVECTOR elfDesignVector; } - alias ENUMLOGFONTEXDVW* PENUMLOGFONTEXDVW, LPENUMLOGFONTEXDVW; + alias PENUMLOGFONTEXDVW = ENUMLOGFONTEXDVW*, LPENUMLOGFONTEXDVW = ENUMLOGFONTEXDVW*; extern(Windows) nothrow @nogc { HFONT CreateFontIndirectExA(const(ENUMLOGFONTEXDVA)*); HFONT CreateFontIndirectExW(const(ENUMLOGFONTEXDVW)*); } version (Unicode) - alias CreateFontIndirectExW CreateFontIndirectEx; + alias CreateFontIndirectEx = CreateFontIndirectExW; else - alias CreateFontIndirectExA CreateFontIndirectEx; + alias CreateFontIndirectEx = CreateFontIndirectExA; struct ENUMTEXTMETRICA { NEWTEXTMETRICEXA etmNewTextMetricEx; AXESLISTA etmAxesList; } - alias ENUMTEXTMETRICA* PENUMTEXTMETRICA, LPENUMTEXTMETRICA; + alias PENUMTEXTMETRICA = ENUMTEXTMETRICA*, LPENUMTEXTMETRICA = ENUMTEXTMETRICA*; struct ENUMTEXTMETRICW { NEWTEXTMETRICEXW etmNewTextMetricEx; AXESLISTW etmAxesList; } - alias ENUMTEXTMETRICW* PENUMTEXTMETRICW, LPENUMTEXTMETRICW; + alias PENUMTEXTMETRICW = ENUMTEXTMETRICW*, LPENUMTEXTMETRICW = ENUMTEXTMETRICW*; version (Unicode) { - alias ENUMTEXTMETRICW ENUMTEXTMETRIC; - alias PENUMTEXTMETRICW PENUMTEXTMETRIC; - alias LPENUMTEXTMETRICW LPENUMTEXTMETRIC; + alias ENUMTEXTMETRIC = ENUMTEXTMETRICW; + alias PENUMTEXTMETRIC = PENUMTEXTMETRICW; + alias LPENUMTEXTMETRIC = LPENUMTEXTMETRICW; } else { - alias ENUMTEXTMETRICA ENUMTEXTMETRIC; - alias PENUMTEXTMETRICA PENUMTEXTMETRIC; - alias LPENUMTEXTMETRICA LPENUMTEXTMETRIC; + alias ENUMTEXTMETRIC = ENUMTEXTMETRICA; + alias PENUMTEXTMETRIC = PENUMTEXTMETRICA; + alias LPENUMTEXTMETRIC = LPENUMTEXTMETRICA; } } /* _WIN32_WINNT >= 0x500 */ @@ -3920,13 +3920,13 @@ struct GRADIENT_TRIANGLE { ULONG Vertex2; ULONG Vertex3; } -alias GRADIENT_TRIANGLE* PGRADIENT_TRIANGLE, LPGRADIENT_TRIANGLE; +alias PGRADIENT_TRIANGLE = GRADIENT_TRIANGLE*, LPGRADIENT_TRIANGLE = GRADIENT_TRIANGLE*; struct GRADIENT_RECT { ULONG UpperLeft; ULONG LowerRight; } -alias GRADIENT_RECT* PGRADIENT_RECT, LPGRADIENT_RECT; +alias PGRADIENT_RECT = GRADIENT_RECT*, LPGRADIENT_RECT = GRADIENT_RECT*; struct DISPLAY_DEVICEA { DWORD cb; @@ -3936,7 +3936,7 @@ struct DISPLAY_DEVICEA { CHAR[128] DeviceID = 0; CHAR[128] DeviceKey = 0; } -alias DISPLAY_DEVICEA* PDISPLAY_DEVICEA, LPDISPLAY_DEVICEA; +alias PDISPLAY_DEVICEA = DISPLAY_DEVICEA*, LPDISPLAY_DEVICEA = DISPLAY_DEVICEA*; struct DISPLAY_DEVICEW { DWORD cb; @@ -3946,7 +3946,7 @@ struct DISPLAY_DEVICEW { WCHAR[128] DeviceID = 0; WCHAR[128] DeviceKey = 0; } -alias DISPLAY_DEVICEW* PDISPLAY_DEVICEW, LPDISPLAY_DEVICEW; +alias PDISPLAY_DEVICEW = DISPLAY_DEVICEW*, LPDISPLAY_DEVICEW = DISPLAY_DEVICEW*; struct DRAWPATRECT { POINT ptPosition; @@ -3954,22 +3954,22 @@ struct DRAWPATRECT { WORD wStyle; WORD wPattern; } -alias DRAWPATRECT* PDRAWPATRECT; +alias PDRAWPATRECT = DRAWPATRECT*; // --------- // Callbacks extern (Windows) { - alias BOOL function (HDC, int) ABORTPROC; - alias int function (HDC, HANDLETABLE*, METARECORD*, int, LPARAM) MFENUMPROC; - alias int function (HDC, HANDLETABLE*, const(ENHMETARECORD)*, int, LPARAM) ENHMFENUMPROC; - alias int function (const(LOGFONTA)*, const(TEXTMETRICA)*, DWORD, LPARAM) FONTENUMPROCA, OLDFONTENUMPROCA; - alias int function (const(LOGFONTW)*, const(TEXTMETRICW)*, DWORD, LPARAM) FONTENUMPROCW, OLDFONTENUMPROCW; - alias int function (LPSTR, LPARAM) ICMENUMPROCA; - alias int function (LPWSTR, LPARAM) ICMENUMPROCW; - alias void function (LPVOID, LPARAM) GOBJENUMPROC; - alias void function (int, int, LPARAM) LINEDDAPROC; - alias UINT function (HWND, HMODULE, LPDEVMODEA, LPSTR, LPSTR, LPDEVMODEA, LPSTR, UINT) LPFNDEVMODE; - alias DWORD function (LPSTR, LPSTR, UINT, LPSTR, LPDEVMODEA) LPFNDEVCAPS; + alias ABORTPROC = BOOL function (HDC, int); + alias MFENUMPROC = int function (HDC, HANDLETABLE*, METARECORD*, int, LPARAM); + alias ENHMFENUMPROC = int function (HDC, HANDLETABLE*, const(ENHMETARECORD)*, int, LPARAM); + alias FONTENUMPROCA = int function (const(LOGFONTA)*, const(TEXTMETRICA)*, DWORD, LPARAM), OLDFONTENUMPROCA = int function (const(LOGFONTA)*, const(TEXTMETRICA)*, DWORD, LPARAM); + alias FONTENUMPROCW = int function (const(LOGFONTW)*, const(TEXTMETRICW)*, DWORD, LPARAM), OLDFONTENUMPROCW = int function (const(LOGFONTW)*, const(TEXTMETRICW)*, DWORD, LPARAM); + alias ICMENUMPROCA = int function (LPSTR, LPARAM); + alias ICMENUMPROCW = int function (LPWSTR, LPARAM); + alias GOBJENUMPROC = void function (LPVOID, LPARAM); + alias LINEDDAPROC = void function (int, int, LPARAM); + alias LPFNDEVMODE = UINT function (HWND, HMODULE, LPDEVMODEA, LPSTR, LPSTR, LPDEVMODEA, LPSTR, UINT); + alias LPFNDEVCAPS = DWORD function (LPSTR, LPSTR, UINT, LPSTR, LPDEVMODEA); } // --------- @@ -4382,7 +4382,7 @@ extern(Windows) nothrow @nogc { BOOL wglUseFontOutlinesW(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT); static if (_WIN32_WINNT >= 0x500) { - alias WGLSWAP* PWGLSWAP; + alias PWGLSWAP = WGLSWAP*; struct WGLSWAP { HDC hdc; UINT uiFlags; @@ -4417,169 +4417,169 @@ static if (_WIN32_WINNT >= 0x500) { } // extern (Windows) version (Unicode) { - alias WCHAR BCHAR; - alias DOCINFOW DOCINFO; - alias LOGFONTW LOGFONT; - - alias TEXTMETRICW TEXTMETRIC; - alias NPTEXTMETRICW NPTEXTMETRIC; - alias ICMENUMPROCW ICMENUMPROC; - alias FONTENUMPROCW FONTENUMPROC; - alias DEVMODEW DEVMODE; - - alias EXTLOGFONTW EXTLOGFONT; - alias GCP_RESULTSW GCP_RESULTS; - alias OUTLINETEXTMETRICW OUTLINETEXTMETRIC; - alias POLYTEXTW POLYTEXT; - alias LOGCOLORSPACEW LOGCOLORSPACE; - alias NEWTEXTMETRICW NEWTEXTMETRIC; - alias NEWTEXTMETRICEXW NEWTEXTMETRICEX; - alias ENUMLOGFONTW ENUMLOGFONT; - alias ENUMLOGFONTEXW ENUMLOGFONTEX; - alias DISPLAY_DEVICEW DISPLAY_DEVICE; - alias AddFontResourceW AddFontResource; - - alias CopyEnhMetaFileW CopyEnhMetaFile; - alias CopyMetaFileW CopyMetaFile; - alias CreateColorSpaceW CreateColorSpace; - alias CreateDCW CreateDC; - alias CreateEnhMetaFileW CreateEnhMetaFile; - alias CreateFontW CreateFont; - alias CreateFontIndirectW CreateFontIndirect; - alias CreateICW CreateIC; - alias CreateMetaFileW CreateMetaFile; - alias CreateScalableFontResourceW CreateScalableFontResource; - alias DeviceCapabilitiesW DeviceCapabilities; - alias EnumFontFamiliesW EnumFontFamilies; - alias EnumFontFamiliesExW EnumFontFamiliesEx; - alias EnumFontsW EnumFonts; - alias EnumICMProfilesW EnumICMProfiles; - alias ExtTextOutW ExtTextOut; - alias GetCharABCWidthsFloatW GetCharABCWidthsFloat; - alias GetCharABCWidthsW GetCharABCWidths; - alias GetCharacterPlacementW GetCharacterPlacement; - alias GetCharWidth32W GetCharWidth32; - alias GetCharWidthFloatW GetCharWidthFloat; - alias GetCharWidthW GetCharWidth; - alias GetEnhMetaFileW GetEnhMetaFile; - alias GetEnhMetaFileDescriptionW GetEnhMetaFileDescription; - alias GetGlyphOutlineW GetGlyphOutline; - alias GetICMProfileW GetICMProfile; - alias GetKerningPairsW GetKerningPairs; - alias GetLogColorSpaceW GetLogColorSpace; - alias GetMetaFileW GetMetaFile; - alias GetObjectW GetObject; - alias GetOutlineTextMetricsW GetOutlineTextMetrics; - alias GetTextExtentPointW GetTextExtentPoint; - alias GetTextExtentExPointW GetTextExtentExPoint; - alias GetTextExtentPoint32W GetTextExtentPoint32; - alias GetTextFaceW GetTextFace; - alias GetTextMetricsW GetTextMetrics; - alias PolyTextOutW PolyTextOut; - alias RemoveFontResourceW RemoveFontResource; - - alias ResetDCW ResetDC; - alias SetICMProfileW SetICMProfile; - alias StartDocW StartDoc; - alias TextOutW TextOut; - alias UpdateICMRegKeyW UpdateICMRegKey; - alias wglUseFontBitmapsW wglUseFontBitmaps; - alias wglUseFontOutlinesW wglUseFontOutlines; + alias BCHAR = WCHAR; + alias DOCINFO = DOCINFOW; + alias LOGFONT = LOGFONTW; + + alias TEXTMETRIC = TEXTMETRICW; + alias NPTEXTMETRIC = NPTEXTMETRICW; + alias ICMENUMPROC = ICMENUMPROCW; + alias FONTENUMPROC = FONTENUMPROCW; + alias DEVMODE = DEVMODEW; + + alias EXTLOGFONT = EXTLOGFONTW; + alias GCP_RESULTS = GCP_RESULTSW; + alias OUTLINETEXTMETRIC = OUTLINETEXTMETRICW; + alias POLYTEXT = POLYTEXTW; + alias LOGCOLORSPACE = LOGCOLORSPACEW; + alias NEWTEXTMETRIC = NEWTEXTMETRICW; + alias NEWTEXTMETRICEX = NEWTEXTMETRICEXW; + alias ENUMLOGFONT = ENUMLOGFONTW; + alias ENUMLOGFONTEX = ENUMLOGFONTEXW; + alias DISPLAY_DEVICE = DISPLAY_DEVICEW; + alias AddFontResource = AddFontResourceW; + + alias CopyEnhMetaFile = CopyEnhMetaFileW; + alias CopyMetaFile = CopyMetaFileW; + alias CreateColorSpace = CreateColorSpaceW; + alias CreateDC = CreateDCW; + alias CreateEnhMetaFile = CreateEnhMetaFileW; + alias CreateFont = CreateFontW; + alias CreateFontIndirect = CreateFontIndirectW; + alias CreateIC = CreateICW; + alias CreateMetaFile = CreateMetaFileW; + alias CreateScalableFontResource = CreateScalableFontResourceW; + alias DeviceCapabilities = DeviceCapabilitiesW; + alias EnumFontFamilies = EnumFontFamiliesW; + alias EnumFontFamiliesEx = EnumFontFamiliesExW; + alias EnumFonts = EnumFontsW; + alias EnumICMProfiles = EnumICMProfilesW; + alias ExtTextOut = ExtTextOutW; + alias GetCharABCWidthsFloat = GetCharABCWidthsFloatW; + alias GetCharABCWidths = GetCharABCWidthsW; + alias GetCharacterPlacement = GetCharacterPlacementW; + alias GetCharWidth32 = GetCharWidth32W; + alias GetCharWidthFloat = GetCharWidthFloatW; + alias GetCharWidth = GetCharWidthW; + alias GetEnhMetaFile = GetEnhMetaFileW; + alias GetEnhMetaFileDescription = GetEnhMetaFileDescriptionW; + alias GetGlyphOutline = GetGlyphOutlineW; + alias GetICMProfile = GetICMProfileW; + alias GetKerningPairs = GetKerningPairsW; + alias GetLogColorSpace = GetLogColorSpaceW; + alias GetMetaFile = GetMetaFileW; + alias GetObject = GetObjectW; + alias GetOutlineTextMetrics = GetOutlineTextMetricsW; + alias GetTextExtentPoint = GetTextExtentPointW; + alias GetTextExtentExPoint = GetTextExtentExPointW; + alias GetTextExtentPoint32 = GetTextExtentPoint32W; + alias GetTextFace = GetTextFaceW; + alias GetTextMetrics = GetTextMetricsW; + alias PolyTextOut = PolyTextOutW; + alias RemoveFontResource = RemoveFontResourceW; + + alias ResetDC = ResetDCW; + alias SetICMProfile = SetICMProfileW; + alias StartDoc = StartDocW; + alias TextOut = TextOutW; + alias UpdateICMRegKey = UpdateICMRegKeyW; + alias wglUseFontBitmaps = wglUseFontBitmapsW; + alias wglUseFontOutlines = wglUseFontOutlinesW; static if (_WIN32_WINNT >= 0x500) { - alias ENUMLOGFONTEXDVW ENUMLOGFONTEXDV; - alias PENUMLOGFONTEXDVW PENUMLOGFONTEXDV; - alias LPENUMLOGFONTEXDVW LPENUMLOGFONTEXDV; - alias AddFontResourceExW AddFontResourceEx; - alias RemoveFontResourceExW RemoveFontResourceEx; - alias GetGlyphIndicesW GetGlyphIndices; + alias ENUMLOGFONTEXDV = ENUMLOGFONTEXDVW; + alias PENUMLOGFONTEXDV = PENUMLOGFONTEXDVW; + alias LPENUMLOGFONTEXDV = LPENUMLOGFONTEXDVW; + alias AddFontResourceEx = AddFontResourceExW; + alias RemoveFontResourceEx = RemoveFontResourceExW; + alias GetGlyphIndices = GetGlyphIndicesW; } } else { /* non-unicode build */ - alias BYTE BCHAR; - alias DOCINFOA DOCINFO; - alias LOGFONTA LOGFONT; - alias TEXTMETRICA TEXTMETRIC; - alias NPTEXTMETRICA NPTEXTMETRIC; - alias ICMENUMPROCA ICMENUMPROC; - alias FONTENUMPROCA FONTENUMPROC; - alias DEVMODEA DEVMODE; - alias EXTLOGFONTA EXTLOGFONT; - alias GCP_RESULTSA GCP_RESULTS; - alias OUTLINETEXTMETRICA OUTLINETEXTMETRIC; - alias POLYTEXTA POLYTEXT; - alias LOGCOLORSPACEA LOGCOLORSPACE; - alias NEWTEXTMETRICA NEWTEXTMETRIC; - alias NEWTEXTMETRICEXA NEWTEXTMETRICEX; - alias ENUMLOGFONTA ENUMLOGFONT; - alias ENUMLOGFONTEXA ENUMLOGFONTEX; - alias DISPLAY_DEVICEA DISPLAY_DEVICE; - - alias AddFontResourceA AddFontResource; - alias CopyEnhMetaFileA CopyEnhMetaFile; - alias CopyMetaFileA CopyMetaFile; - alias CreateColorSpaceA CreateColorSpace; - alias CreateDCA CreateDC; - alias CreateEnhMetaFileA CreateEnhMetaFile; - alias CreateFontA CreateFont; - alias CreateFontIndirectA CreateFontIndirect; - alias CreateICA CreateIC; - alias CreateMetaFileA CreateMetaFile; - alias CreateScalableFontResourceA CreateScalableFontResource; - alias DeviceCapabilitiesA DeviceCapabilities; - alias EnumFontFamiliesA EnumFontFamilies; - alias EnumFontFamiliesExA EnumFontFamiliesEx; - alias EnumFontsA EnumFonts; - alias EnumICMProfilesA EnumICMProfiles; - alias ExtTextOutA ExtTextOut; - alias GetCharWidthFloatA GetCharWidthFloat; - alias GetCharWidthA GetCharWidth; - alias GetCharacterPlacementA GetCharacterPlacement; - alias GetCharABCWidthsA GetCharABCWidths; - alias GetCharABCWidthsFloatA GetCharABCWidthsFloat; - alias GetCharWidth32A GetCharWidth32; - alias GetEnhMetaFileA GetEnhMetaFile; - alias GetEnhMetaFileDescriptionA GetEnhMetaFileDescription; - alias GetGlyphOutlineA GetGlyphOutline; - alias GetICMProfileA GetICMProfile; - alias GetKerningPairsA GetKerningPairs; - alias GetLogColorSpaceA GetLogColorSpace; - alias GetMetaFileA GetMetaFile; - alias GetObjectA GetObject; - alias GetOutlineTextMetricsA GetOutlineTextMetrics; - alias GetTextExtentPointA GetTextExtentPoint; - alias GetTextExtentExPointA GetTextExtentExPoint; - alias GetTextExtentPoint32A GetTextExtentPoint32; - alias GetTextFaceA GetTextFace; - alias GetTextMetricsA GetTextMetrics; - alias PolyTextOutA PolyTextOut; - alias RemoveFontResourceA RemoveFontResource; - alias ResetDCA ResetDC; - alias SetICMProfileA SetICMProfile; - alias StartDocA StartDoc; - alias TextOutA TextOut; - alias UpdateICMRegKeyA UpdateICMRegKey; - alias wglUseFontBitmapsA wglUseFontBitmaps; - alias wglUseFontOutlinesA wglUseFontOutlines; + alias BCHAR = BYTE; + alias DOCINFO = DOCINFOA; + alias LOGFONT = LOGFONTA; + alias TEXTMETRIC = TEXTMETRICA; + alias NPTEXTMETRIC = NPTEXTMETRICA; + alias ICMENUMPROC = ICMENUMPROCA; + alias FONTENUMPROC = FONTENUMPROCA; + alias DEVMODE = DEVMODEA; + alias EXTLOGFONT = EXTLOGFONTA; + alias GCP_RESULTS = GCP_RESULTSA; + alias OUTLINETEXTMETRIC = OUTLINETEXTMETRICA; + alias POLYTEXT = POLYTEXTA; + alias LOGCOLORSPACE = LOGCOLORSPACEA; + alias NEWTEXTMETRIC = NEWTEXTMETRICA; + alias NEWTEXTMETRICEX = NEWTEXTMETRICEXA; + alias ENUMLOGFONT = ENUMLOGFONTA; + alias ENUMLOGFONTEX = ENUMLOGFONTEXA; + alias DISPLAY_DEVICE = DISPLAY_DEVICEA; + + alias AddFontResource = AddFontResourceA; + alias CopyEnhMetaFile = CopyEnhMetaFileA; + alias CopyMetaFile = CopyMetaFileA; + alias CreateColorSpace = CreateColorSpaceA; + alias CreateDC = CreateDCA; + alias CreateEnhMetaFile = CreateEnhMetaFileA; + alias CreateFont = CreateFontA; + alias CreateFontIndirect = CreateFontIndirectA; + alias CreateIC = CreateICA; + alias CreateMetaFile = CreateMetaFileA; + alias CreateScalableFontResource = CreateScalableFontResourceA; + alias DeviceCapabilities = DeviceCapabilitiesA; + alias EnumFontFamilies = EnumFontFamiliesA; + alias EnumFontFamiliesEx = EnumFontFamiliesExA; + alias EnumFonts = EnumFontsA; + alias EnumICMProfiles = EnumICMProfilesA; + alias ExtTextOut = ExtTextOutA; + alias GetCharWidthFloat = GetCharWidthFloatA; + alias GetCharWidth = GetCharWidthA; + alias GetCharacterPlacement = GetCharacterPlacementA; + alias GetCharABCWidths = GetCharABCWidthsA; + alias GetCharABCWidthsFloat = GetCharABCWidthsFloatA; + alias GetCharWidth32 = GetCharWidth32A; + alias GetEnhMetaFile = GetEnhMetaFileA; + alias GetEnhMetaFileDescription = GetEnhMetaFileDescriptionA; + alias GetGlyphOutline = GetGlyphOutlineA; + alias GetICMProfile = GetICMProfileA; + alias GetKerningPairs = GetKerningPairsA; + alias GetLogColorSpace = GetLogColorSpaceA; + alias GetMetaFile = GetMetaFileA; + alias GetObject = GetObjectA; + alias GetOutlineTextMetrics = GetOutlineTextMetricsA; + alias GetTextExtentPoint = GetTextExtentPointA; + alias GetTextExtentExPoint = GetTextExtentExPointA; + alias GetTextExtentPoint32 = GetTextExtentPoint32A; + alias GetTextFace = GetTextFaceA; + alias GetTextMetrics = GetTextMetricsA; + alias PolyTextOut = PolyTextOutA; + alias RemoveFontResource = RemoveFontResourceA; + alias ResetDC = ResetDCA; + alias SetICMProfile = SetICMProfileA; + alias StartDoc = StartDocA; + alias TextOut = TextOutA; + alias UpdateICMRegKey = UpdateICMRegKeyA; + alias wglUseFontBitmaps = wglUseFontBitmapsA; + alias wglUseFontOutlines = wglUseFontOutlinesA; static if (_WIN32_WINNT >= 0x500) { - alias ENUMLOGFONTEXDVA ENUMLOGFONTEXDV; - alias PENUMLOGFONTEXDVA PENUMLOGFONTEXDV; - alias LPENUMLOGFONTEXDVA LPENUMLOGFONTEXDV; - alias AddFontResourceExA AddFontResourceEx; - alias RemoveFontResourceExA RemoveFontResourceEx; - alias GetGlyphIndicesA GetGlyphIndices; + alias ENUMLOGFONTEXDV = ENUMLOGFONTEXDVA; + alias PENUMLOGFONTEXDV = PENUMLOGFONTEXDVA; + alias LPENUMLOGFONTEXDV = LPENUMLOGFONTEXDVA; + alias AddFontResourceEx = AddFontResourceExA; + alias RemoveFontResourceEx = RemoveFontResourceExA; + alias GetGlyphIndices = GetGlyphIndicesA; } } // Common to both ASCII & UNICODE -alias DOCINFO* LPDOCINFO; -alias LOGFONT* PLOGFONT, NPLOGFONT, LPLOGFONT; -alias TEXTMETRIC* PTEXTMETRIC, LPTEXTMETRIC; -alias DEVMODE* PDEVMODE, NPDEVMODE, LPDEVMODE; -alias EXTLOGFONT* PEXTLOGFONT, NPEXTLOGFONT, LPEXTLOGFONT; -alias GCP_RESULTS* LPGCP_RESULTS; -alias OUTLINETEXTMETRIC* POUTLINETEXTMETRIC, NPOUTLINETEXTMETRIC, LPOUTLINETEXTMETRIC; -alias POLYTEXT* PPOLYTEXT, NPPOLYTEXT, LPPOLYTEXT; -alias LOGCOLORSPACE* LPLOGCOLORSPACE; -alias NEWTEXTMETRIC* PNEWTEXTMETRIC, NPNEWTEXTMETRIC, LPNEWTEXTMETRIC; -alias ENUMLOGFONT* LPENUMLOGFONT; -alias ENUMLOGFONTEX* LPENUMLOGFONTEX; -alias DISPLAY_DEVICE* PDISPLAY_DEVICE, LPDISPLAY_DEVICE; +alias LPDOCINFO = DOCINFO*; +alias PLOGFONT = LOGFONT*, NPLOGFONT = LOGFONT*, LPLOGFONT = LOGFONT*; +alias PTEXTMETRIC = TEXTMETRIC*, LPTEXTMETRIC = TEXTMETRIC*; +alias PDEVMODE = DEVMODE*, NPDEVMODE = DEVMODE*, LPDEVMODE = DEVMODE*; +alias PEXTLOGFONT = EXTLOGFONT*, NPEXTLOGFONT = EXTLOGFONT*, LPEXTLOGFONT = EXTLOGFONT*; +alias LPGCP_RESULTS = GCP_RESULTS*; +alias POUTLINETEXTMETRIC = OUTLINETEXTMETRIC*, NPOUTLINETEXTMETRIC = OUTLINETEXTMETRIC*, LPOUTLINETEXTMETRIC = OUTLINETEXTMETRIC*; +alias PPOLYTEXT = POLYTEXT*, NPPOLYTEXT = POLYTEXT*, LPPOLYTEXT = POLYTEXT*; +alias LPLOGCOLORSPACE = LOGCOLORSPACE*; +alias PNEWTEXTMETRIC = NEWTEXTMETRIC*, NPNEWTEXTMETRIC = NEWTEXTMETRIC*, LPNEWTEXTMETRIC = NEWTEXTMETRIC*; +alias LPENUMLOGFONT = ENUMLOGFONT*; +alias LPENUMLOGFONTEX = ENUMLOGFONTEX*; +alias PDISPLAY_DEVICE = DISPLAY_DEVICE*, LPDISPLAY_DEVICE = DISPLAY_DEVICE*; diff --git a/runtime/druntime/src/core/sys/windows/winhttp.d b/runtime/druntime/src/core/sys/windows/winhttp.d index 1de3b9366a..ac3e7baa83 100644 --- a/runtime/druntime/src/core/sys/windows/winhttp.d +++ b/runtime/druntime/src/core/sys/windows/winhttp.d @@ -373,7 +373,7 @@ enum : DWORD { WINHTTP_FLAG_SECURE_PROTOCOL_TLS1) } -alias extern(Windows) int fnWINHTTP_STATUS_CALLBACK(HINTERNET hInternet, DWORD_PTR dwContext, +alias fnWINHTTP_STATUS_CALLBACK = extern(Windows) int(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation,DWORD dwStatusInformationLength); alias WINHTTP_STATUS_CALLBACK = fnWINHTTP_STATUS_CALLBACK*; alias LPWINHTTP_STATUS_CALLBACK = WINHTTP_STATUS_CALLBACK*; diff --git a/runtime/druntime/src/core/sys/windows/wininet.d b/runtime/druntime/src/core/sys/windows/wininet.d index 790d4d01dc..d1a47f8190 100644 --- a/runtime/druntime/src/core/sys/windows/wininet.d +++ b/runtime/druntime/src/core/sys/windows/wininet.d @@ -746,11 +746,11 @@ alias HINTERNET = HANDLE; HANDLE h; alias h this; }*/ -alias HINTERNET* LPHINTERNET; +alias LPHINTERNET = HINTERNET*; -alias LONGLONG GROUPID; -alias WORD INTERNET_PORT; -alias WORD* LPINTERNET_PORT; +alias GROUPID = LONGLONG; +alias INTERNET_PORT = WORD; +alias LPINTERNET_PORT = WORD*; enum INTERNET_SCHEME { INTERNET_SCHEME_PARTIAL = -2, @@ -770,13 +770,13 @@ enum INTERNET_SCHEME { INTERNET_SCHEME_FIRST = INTERNET_SCHEME_FTP, INTERNET_SCHEME_LAST = INTERNET_SCHEME_RES } -alias INTERNET_SCHEME* LPINTERNET_SCHEME; +alias LPINTERNET_SCHEME = INTERNET_SCHEME*; struct INTERNET_ASYNC_RESULT { DWORD_PTR dwResult; DWORD dwError; } -alias INTERNET_ASYNC_RESULT* LPINTERNET_ASYNC_RESULT; +alias LPINTERNET_ASYNC_RESULT = INTERNET_ASYNC_RESULT*; struct INTERNET_DIAGNOSTIC_SOCKET_INFO { DWORD_PTR Socket; @@ -784,20 +784,20 @@ struct INTERNET_DIAGNOSTIC_SOCKET_INFO { DWORD DestPort; DWORD Flags; } -alias INTERNET_DIAGNOSTIC_SOCKET_INFO* LPINTERNET_DIAGNOSTIC_SOCKET_INFO; +alias LPINTERNET_DIAGNOSTIC_SOCKET_INFO = INTERNET_DIAGNOSTIC_SOCKET_INFO*; struct INTERNET_PREFETCH_STATUS { DWORD dwStatus; DWORD dwSize; } -alias INTERNET_PREFETCH_STATUS* LPINTERNET_PREFETCH_STATUS; +alias LPINTERNET_PREFETCH_STATUS = INTERNET_PREFETCH_STATUS*; struct INTERNET_PROXY_INFO { DWORD dwAccessType; LPCTSTR lpszProxy; LPCTSTR lpszProxyBypass; } -alias INTERNET_PROXY_INFO* LPINTERNET_PROXY_INFO; +alias LPINTERNET_PROXY_INFO = INTERNET_PROXY_INFO*; struct INTERNET_PER_CONN_OPTIONA { DWORD dwOption; @@ -807,7 +807,7 @@ struct INTERNET_PER_CONN_OPTIONA { FILETIME ftValue; } } -alias INTERNET_PER_CONN_OPTIONA* LPINTERNET_PER_CONN_OPTIONA; +alias LPINTERNET_PER_CONN_OPTIONA = INTERNET_PER_CONN_OPTIONA*; struct INTERNET_PER_CONN_OPTIONW { DWORD dwOption; @@ -817,7 +817,7 @@ struct INTERNET_PER_CONN_OPTIONW { FILETIME ftValue; } } -alias INTERNET_PER_CONN_OPTIONW* LPINTERNET_PER_CONN_OPTIONW; +alias LPINTERNET_PER_CONN_OPTIONW = INTERNET_PER_CONN_OPTIONW*; struct INTERNET_PER_CONN_OPTION_LISTA { DWORD dwSize; @@ -826,7 +826,7 @@ struct INTERNET_PER_CONN_OPTION_LISTA { DWORD dwOptionError; LPINTERNET_PER_CONN_OPTIONA pOptions; } -alias INTERNET_PER_CONN_OPTION_LISTA* LPINTERNET_PER_CONN_OPTION_LISTA; +alias LPINTERNET_PER_CONN_OPTION_LISTA = INTERNET_PER_CONN_OPTION_LISTA*; struct INTERNET_PER_CONN_OPTION_LISTW { DWORD dwSize; @@ -835,7 +835,7 @@ struct INTERNET_PER_CONN_OPTION_LISTW { DWORD dwOptionError; LPINTERNET_PER_CONN_OPTIONW pOptions; } -alias INTERNET_PER_CONN_OPTION_LISTW* LPINTERNET_PER_CONN_OPTION_LISTW; +alias LPINTERNET_PER_CONN_OPTION_LISTW = INTERNET_PER_CONN_OPTION_LISTW*; enum { INTERNET_PER_CONN_FLAGS = 1, @@ -871,7 +871,7 @@ struct INTERNET_VERSION_INFO { DWORD dwMajorVersion; DWORD dwMinorVersion; } -alias INTERNET_VERSION_INFO* LPINTERNET_VERSION_INFO; +alias LPINTERNET_VERSION_INFO = INTERNET_VERSION_INFO*; struct URL_COMPONENTSA { DWORD dwStructSize = URL_COMPONENTSA.sizeof; @@ -890,7 +890,7 @@ struct URL_COMPONENTSA { LPSTR lpszExtraInfo; DWORD dwExtraInfoLength; } -alias URL_COMPONENTSA* LPURL_COMPONENTSA; +alias LPURL_COMPONENTSA = URL_COMPONENTSA*; struct URL_COMPONENTSW { DWORD dwStructSize = URL_COMPONENTSW.sizeof; @@ -909,7 +909,7 @@ struct URL_COMPONENTSW { LPWSTR lpszExtraInfo; DWORD dwExtraInfoLength; } -alias URL_COMPONENTSW* LPURL_COMPONENTSW; +alias LPURL_COMPONENTSW = URL_COMPONENTSW*; struct INTERNET_CERTIFICATE_INFO { FILETIME ftExpiry; @@ -921,11 +921,10 @@ struct INTERNET_CERTIFICATE_INFO { LPTSTR lpszEncryptionAlgName; DWORD dwKeySize; } -alias INTERNET_CERTIFICATE_INFO* LPINTERNET_CERTIFICATE_INFO; +alias LPINTERNET_CERTIFICATE_INFO = INTERNET_CERTIFICATE_INFO*; -extern (Windows) alias void function(HINTERNET, DWORD_PTR, DWORD, PVOID, DWORD) - INTERNET_STATUS_CALLBACK; -alias INTERNET_STATUS_CALLBACK* LPINTERNET_STATUS_CALLBACK; +extern (Windows) alias INTERNET_STATUS_CALLBACK = void function(HINTERNET, DWORD_PTR, DWORD, PVOID, DWORD); +alias LPINTERNET_STATUS_CALLBACK = INTERNET_STATUS_CALLBACK*; enum INTERNET_INVALID_STATUS_CALLBACK = cast(INTERNET_STATUS_CALLBACK) -1; @@ -938,7 +937,7 @@ struct GOPHER_FIND_DATAA { FILETIME LastModificationTime; CHAR[MAX_GOPHER_LOCATOR_LENGTH+1] Locator = 0; } -alias GOPHER_FIND_DATAA* LPGOPHER_FIND_DATAA; +alias LPGOPHER_FIND_DATAA = GOPHER_FIND_DATAA*; struct GOPHER_FIND_DATAW { WCHAR[MAX_GOPHER_DISPLAY_TEXT+1] DisplayString = 0; @@ -948,49 +947,49 @@ struct GOPHER_FIND_DATAW { FILETIME LastModificationTime; WCHAR[MAX_GOPHER_LOCATOR_LENGTH+1] Locator = 0; } -alias GOPHER_FIND_DATAW* LPGOPHER_FIND_DATAW; +alias LPGOPHER_FIND_DATAW = GOPHER_FIND_DATAW*; struct GOPHER_ADMIN_ATTRIBUTE_TYPE { LPCTSTR Comment; LPCTSTR EmailAddress; } -alias GOPHER_ADMIN_ATTRIBUTE_TYPE* LPGOPHER_ADMIN_ATTRIBUTE_TYPE; +alias LPGOPHER_ADMIN_ATTRIBUTE_TYPE = GOPHER_ADMIN_ATTRIBUTE_TYPE*; struct GOPHER_MOD_DATE_ATTRIBUTE_TYPE { FILETIME DateAndTime; } -alias GOPHER_MOD_DATE_ATTRIBUTE_TYPE* LPGOPHER_MOD_DATE_ATTRIBUTE_TYPE; +alias LPGOPHER_MOD_DATE_ATTRIBUTE_TYPE = GOPHER_MOD_DATE_ATTRIBUTE_TYPE*; struct GOPHER_TTL_ATTRIBUTE_TYPE { DWORD Ttl; } -alias GOPHER_TTL_ATTRIBUTE_TYPE* LPGOPHER_TTL_ATTRIBUTE_TYPE; +alias LPGOPHER_TTL_ATTRIBUTE_TYPE = GOPHER_TTL_ATTRIBUTE_TYPE*; struct GOPHER_SCORE_ATTRIBUTE_TYPE { INT Score; } -alias GOPHER_SCORE_ATTRIBUTE_TYPE* LPGOPHER_SCORE_ATTRIBUTE_TYPE; +alias LPGOPHER_SCORE_ATTRIBUTE_TYPE = GOPHER_SCORE_ATTRIBUTE_TYPE*; struct GOPHER_SCORE_RANGE_ATTRIBUTE_TYPE { INT LowerBound; INT UpperBound; } -alias GOPHER_SCORE_RANGE_ATTRIBUTE_TYPE* LPGOPHER_SCORE_RANGE_ATTRIBUTE_TYPE; +alias LPGOPHER_SCORE_RANGE_ATTRIBUTE_TYPE = GOPHER_SCORE_RANGE_ATTRIBUTE_TYPE*; struct GOPHER_SITE_ATTRIBUTE_TYPE { LPCTSTR Site; } -alias GOPHER_SITE_ATTRIBUTE_TYPE* LPGOPHER_SITE_ATTRIBUTE_TYPE; +alias LPGOPHER_SITE_ATTRIBUTE_TYPE = GOPHER_SITE_ATTRIBUTE_TYPE*; struct GOPHER_ORGANIZATION_ATTRIBUTE_TYPE { LPCTSTR Organization; } -alias GOPHER_ORGANIZATION_ATTRIBUTE_TYPE* LPGOPHER_ORGANIZATION_ATTRIBUTE_TYPE; +alias LPGOPHER_ORGANIZATION_ATTRIBUTE_TYPE = GOPHER_ORGANIZATION_ATTRIBUTE_TYPE*; struct GOPHER_LOCATION_ATTRIBUTE_TYPE { LPCTSTR Location; } -alias GOPHER_LOCATION_ATTRIBUTE_TYPE* LPGOPHER_LOCATION_ATTRIBUTE_TYPE; +alias LPGOPHER_LOCATION_ATTRIBUTE_TYPE = GOPHER_LOCATION_ATTRIBUTE_TYPE*; struct GOPHER_GEOGRAPHICAL_LOCATION_ATTRIBUTE_TYPE { INT DegreesNorth; @@ -1000,52 +999,51 @@ struct GOPHER_GEOGRAPHICAL_LOCATION_ATTRIBUTE_TYPE { INT MinutesEast; INT SecondsEast; } -alias GOPHER_GEOGRAPHICAL_LOCATION_ATTRIBUTE_TYPE* - LPGOPHER_GEOGRAPHICAL_LOCATION_ATTRIBUTE_TYPE; +alias LPGOPHER_GEOGRAPHICAL_LOCATION_ATTRIBUTE_TYPE = GOPHER_GEOGRAPHICAL_LOCATION_ATTRIBUTE_TYPE*; struct GOPHER_TIMEZONE_ATTRIBUTE_TYPE { INT Zone; } -alias GOPHER_TIMEZONE_ATTRIBUTE_TYPE* LPGOPHER_TIMEZONE_ATTRIBUTE_TYPE; +alias LPGOPHER_TIMEZONE_ATTRIBUTE_TYPE = GOPHER_TIMEZONE_ATTRIBUTE_TYPE*; struct GOPHER_PROVIDER_ATTRIBUTE_TYPE { LPCTSTR Provider; } -alias GOPHER_PROVIDER_ATTRIBUTE_TYPE* LPGOPHER_PROVIDER_ATTRIBUTE_TYPE; +alias LPGOPHER_PROVIDER_ATTRIBUTE_TYPE = GOPHER_PROVIDER_ATTRIBUTE_TYPE*; struct GOPHER_VERSION_ATTRIBUTE_TYPE { LPCTSTR Version; } -alias GOPHER_VERSION_ATTRIBUTE_TYPE* LPGOPHER_VERSION_ATTRIBUTE_TYPE; +alias LPGOPHER_VERSION_ATTRIBUTE_TYPE = GOPHER_VERSION_ATTRIBUTE_TYPE*; struct GOPHER_ABSTRACT_ATTRIBUTE_TYPE { LPCTSTR ShortAbstract; LPCTSTR AbstractFile; } -alias GOPHER_ABSTRACT_ATTRIBUTE_TYPE* LPGOPHER_ABSTRACT_ATTRIBUTE_TYPE; +alias LPGOPHER_ABSTRACT_ATTRIBUTE_TYPE = GOPHER_ABSTRACT_ATTRIBUTE_TYPE*; struct GOPHER_VIEW_ATTRIBUTE_TYPE { LPCTSTR ContentType; LPCTSTR Language; DWORD Size; } -alias GOPHER_VIEW_ATTRIBUTE_TYPE* LPGOPHER_VIEW_ATTRIBUTE_TYPE; +alias LPGOPHER_VIEW_ATTRIBUTE_TYPE = GOPHER_VIEW_ATTRIBUTE_TYPE*; struct GOPHER_VERONICA_ATTRIBUTE_TYPE { BOOL TreeWalk; } -alias GOPHER_VERONICA_ATTRIBUTE_TYPE* LPGOPHER_VERONICA_ATTRIBUTE_TYPE; +alias LPGOPHER_VERONICA_ATTRIBUTE_TYPE = GOPHER_VERONICA_ATTRIBUTE_TYPE*; struct GOPHER_ASK_ATTRIBUTE_TYPE { LPCTSTR QuestionType; LPCTSTR QuestionText; } -alias GOPHER_ASK_ATTRIBUTE_TYPE* LPGOPHER_ASK_ATTRIBUTE_TYPE; +alias LPGOPHER_ASK_ATTRIBUTE_TYPE = GOPHER_ASK_ATTRIBUTE_TYPE*; struct GOPHER_UNKNOWN_ATTRIBUTE_TYPE { LPCTSTR Text; } -alias GOPHER_UNKNOWN_ATTRIBUTE_TYPE* LPGOPHER_UNKNOWN_ATTRIBUTE_TYPE; +alias LPGOPHER_UNKNOWN_ATTRIBUTE_TYPE = GOPHER_UNKNOWN_ATTRIBUTE_TYPE*; struct GOPHER_ATTRIBUTE_TYPE { DWORD CategoryId; @@ -1070,11 +1068,10 @@ struct GOPHER_ATTRIBUTE_TYPE { GOPHER_UNKNOWN_ATTRIBUTE_TYPE Unknown; } /+AttributeType;+/ } -alias GOPHER_ATTRIBUTE_TYPE* LPGOPHER_ATTRIBUTE_TYPE; +alias LPGOPHER_ATTRIBUTE_TYPE = GOPHER_ATTRIBUTE_TYPE*; extern (Windows) -alias BOOL function(LPGOPHER_ATTRIBUTE_TYPE, DWORD) - GOPHER_ATTRIBUTE_ENUMERATOR; +alias GOPHER_ATTRIBUTE_ENUMERATOR = BOOL function(LPGOPHER_ATTRIBUTE_TYPE, DWORD); struct INTERNET_CACHE_ENTRY_INFOA { DWORD dwStructSize = INTERNET_CACHE_ENTRY_INFOA.sizeof; @@ -1094,7 +1091,7 @@ struct INTERNET_CACHE_ENTRY_INFOA { LPSTR lpszFileExtension; DWORD dwReserved; } -alias INTERNET_CACHE_ENTRY_INFOA* LPINTERNET_CACHE_ENTRY_INFOA; +alias LPINTERNET_CACHE_ENTRY_INFOA = INTERNET_CACHE_ENTRY_INFOA*; struct INTERNET_CACHE_ENTRY_INFOW { DWORD dwStructSize = INTERNET_CACHE_ENTRY_INFOW.sizeof; @@ -1114,7 +1111,7 @@ struct INTERNET_CACHE_ENTRY_INFOW { LPWSTR lpszFileExtension; DWORD dwReserved; } -alias INTERNET_CACHE_ENTRY_INFOW* LPINTERNET_CACHE_ENTRY_INFOW; +alias LPINTERNET_CACHE_ENTRY_INFOW = INTERNET_CACHE_ENTRY_INFOW*; struct INTERNET_BUFFERSA { DWORD dwStructSize = INTERNET_BUFFERSA.sizeof; @@ -1128,7 +1125,7 @@ struct INTERNET_BUFFERSA { DWORD dwOffsetLow; DWORD dwOffsetHigh; } -alias INTERNET_BUFFERSA* LPINTERNET_BUFFERSA; +alias LPINTERNET_BUFFERSA = INTERNET_BUFFERSA*; struct INTERNET_BUFFERSW { DWORD dwStructSize = INTERNET_BUFFERSW.sizeof; @@ -1142,7 +1139,7 @@ struct INTERNET_BUFFERSW { DWORD dwOffsetLow; DWORD dwOffsetHigh; } -alias INTERNET_BUFFERSW* LPINTERNET_BUFFERSW; +alias LPINTERNET_BUFFERSW = INTERNET_BUFFERSW*; enum size_t GROUP_OWNER_STORAGE_SIZE = 4, @@ -1157,7 +1154,7 @@ struct INTERNET_CACHE_GROUP_INFOA { DWORD[GROUP_OWNER_STORAGE_SIZE] dwOwnerStorage; CHAR[GROUPNAME_MAX_LENGTH] szGroupName = 0; } -alias INTERNET_CACHE_GROUP_INFOA* LPINTERNET_CACHE_GROUP_INFOA; +alias LPINTERNET_CACHE_GROUP_INFOA = INTERNET_CACHE_GROUP_INFOA*; struct INTERNET_CACHE_GROUP_INFOW { DWORD dwGroupSize; @@ -1168,7 +1165,7 @@ struct INTERNET_CACHE_GROUP_INFOW { DWORD[GROUP_OWNER_STORAGE_SIZE] dwOwnerStorage; WCHAR[GROUPNAME_MAX_LENGTH] szGroupName = 0; } -alias INTERNET_CACHE_GROUP_INFOW* LPINTERNET_CACHE_GROUP_INFOW; +alias LPINTERNET_CACHE_GROUP_INFOW = INTERNET_CACHE_GROUP_INFOW*; extern (Windows) { BOOL InternetTimeFromSystemTime(SYSTEMTIME*, DWORD, LPSTR, DWORD); @@ -1331,129 +1328,129 @@ extern (Windows) { } version (Unicode) { - alias INTERNET_PER_CONN_OPTIONW INTERNET_PER_CONN_OPTION; - alias LPINTERNET_PER_CONN_OPTIONW LPINTERNET_PER_CONN_OPTION; - alias INTERNET_PER_CONN_OPTION_LISTW INTERNET_PER_CONN_OPTION_LIST; - alias LPINTERNET_PER_CONN_OPTION_LISTW LPINTERNET_PER_CONN_OPTION_LIST; - alias URL_COMPONENTSW URL_COMPONENTS; - alias LPURL_COMPONENTSW LPURL_COMPONENTS; - alias GOPHER_FIND_DATAW GOPHER_FIND_DATA; - alias LPGOPHER_FIND_DATAW LPGOPHER_FIND_DATA; - alias INTERNET_CACHE_ENTRY_INFOW INTERNET_CACHE_ENTRY_INFO; - alias LPINTERNET_CACHE_ENTRY_INFOW LPINTERNET_CACHE_ENTRY_INFO; - alias INTERNET_BUFFERSW INTERNET_BUFFERS; - alias INTERNET_CACHE_GROUP_INFOW INTERNET_CACHE_GROUP_INFO; - alias LPINTERNET_CACHE_GROUP_INFOW LPINTERNET_CACHE_GROUP_INFO; - alias InternetCrackUrlW InternetCrackUrl; - alias InternetCreateUrlW InternetCreateUrl; - alias InternetCanonicalizeUrlW InternetCanonicalizeUrl; - alias InternetCheckConnectionW InternetCheckConnection; - alias InternetCombineUrlW InternetCombineUrl; - alias InternetOpenW InternetOpen; - alias InternetConnectW InternetConnect; - alias InternetOpenUrlW InternetOpenUrl; - alias InternetFindNextFileW InternetFindNextFile; - alias InternetQueryOptionW InternetQueryOption; - alias InternetSetOptionW InternetSetOption; - alias InternetSetOptionExW InternetSetOptionEx; - alias InternetGetLastResponseInfoW InternetGetLastResponseInfo; - alias InternetReadFileExW InternetReadFileEx; - alias FtpFindFirstFileW FtpFindFirstFile; - alias FtpGetFileW FtpGetFile; - alias FtpPutFileW FtpPutFile; - alias FtpDeleteFileW FtpDeleteFile; - alias FtpRenameFileW FtpRenameFile; - alias FtpOpenFileW FtpOpenFile; - alias FtpCreateDirectoryW FtpCreateDirectory; - alias FtpRemoveDirectoryW FtpRemoveDirectory; - alias FtpSetCurrentDirectoryW FtpSetCurrentDirectory; - alias FtpGetCurrentDirectoryW FtpGetCurrentDirectory; - alias FtpCommandW FtpCommand; - alias GopherGetLocatorTypeW GopherGetLocatorType; - alias GopherCreateLocatorW GopherCreateLocator; - alias GopherFindFirstFileW GopherFindFirstFile; - alias GopherOpenFileW GopherOpenFile; - alias GopherGetAttributeW GopherGetAttribute; - alias HttpSendRequestW HttpSendRequest; - alias HttpOpenRequestW HttpOpenRequest; - alias HttpAddRequestHeadersW HttpAddRequestHeaders; - alias HttpQueryInfoW HttpQueryInfo; - alias InternetSetCookieW InternetSetCookie; - alias InternetGetCookieW InternetGetCookie; - alias CreateUrlCacheEntryW CreateUrlCacheEntry; - alias RetrieveUrlCacheEntryStreamW RetrieveUrlCacheEntryStream; - alias FindNextUrlCacheEntryW FindNextUrlCacheEntry; - alias CommitUrlCacheEntryW CommitUrlCacheEntry; - alias GetUrlCacheEntryInfoW GetUrlCacheEntryInfo; - alias SetUrlCacheEntryInfoW SetUrlCacheEntryInfo; - alias FindFirstUrlCacheEntryW FindFirstUrlCacheEntry; - alias RetrieveUrlCacheEntryFileW RetrieveUrlCacheEntryFile; - alias HttpSendRequestExW HttpSendRequestEx; - alias HttpEndRequestW HttpEndRequest; - alias GetUrlCacheGroupAttributeW GetUrlCacheGroupAttribute; - alias SetUrlCacheGroupAttributeW SetUrlCacheGroupAttribute; + alias INTERNET_PER_CONN_OPTION = INTERNET_PER_CONN_OPTIONW; + alias LPINTERNET_PER_CONN_OPTION = LPINTERNET_PER_CONN_OPTIONW; + alias INTERNET_PER_CONN_OPTION_LIST = INTERNET_PER_CONN_OPTION_LISTW; + alias LPINTERNET_PER_CONN_OPTION_LIST = LPINTERNET_PER_CONN_OPTION_LISTW; + alias URL_COMPONENTS = URL_COMPONENTSW; + alias LPURL_COMPONENTS = LPURL_COMPONENTSW; + alias GOPHER_FIND_DATA = GOPHER_FIND_DATAW; + alias LPGOPHER_FIND_DATA = LPGOPHER_FIND_DATAW; + alias INTERNET_CACHE_ENTRY_INFO = INTERNET_CACHE_ENTRY_INFOW; + alias LPINTERNET_CACHE_ENTRY_INFO = LPINTERNET_CACHE_ENTRY_INFOW; + alias INTERNET_BUFFERS = INTERNET_BUFFERSW; + alias INTERNET_CACHE_GROUP_INFO = INTERNET_CACHE_GROUP_INFOW; + alias LPINTERNET_CACHE_GROUP_INFO = LPINTERNET_CACHE_GROUP_INFOW; + alias InternetCrackUrl = InternetCrackUrlW; + alias InternetCreateUrl = InternetCreateUrlW; + alias InternetCanonicalizeUrl = InternetCanonicalizeUrlW; + alias InternetCheckConnection = InternetCheckConnectionW; + alias InternetCombineUrl = InternetCombineUrlW; + alias InternetOpen = InternetOpenW; + alias InternetConnect = InternetConnectW; + alias InternetOpenUrl = InternetOpenUrlW; + alias InternetFindNextFile = InternetFindNextFileW; + alias InternetQueryOption = InternetQueryOptionW; + alias InternetSetOption = InternetSetOptionW; + alias InternetSetOptionEx = InternetSetOptionExW; + alias InternetGetLastResponseInfo = InternetGetLastResponseInfoW; + alias InternetReadFileEx = InternetReadFileExW; + alias FtpFindFirstFile = FtpFindFirstFileW; + alias FtpGetFile = FtpGetFileW; + alias FtpPutFile = FtpPutFileW; + alias FtpDeleteFile = FtpDeleteFileW; + alias FtpRenameFile = FtpRenameFileW; + alias FtpOpenFile = FtpOpenFileW; + alias FtpCreateDirectory = FtpCreateDirectoryW; + alias FtpRemoveDirectory = FtpRemoveDirectoryW; + alias FtpSetCurrentDirectory = FtpSetCurrentDirectoryW; + alias FtpGetCurrentDirectory = FtpGetCurrentDirectoryW; + alias FtpCommand = FtpCommandW; + alias GopherGetLocatorType = GopherGetLocatorTypeW; + alias GopherCreateLocator = GopherCreateLocatorW; + alias GopherFindFirstFile = GopherFindFirstFileW; + alias GopherOpenFile = GopherOpenFileW; + alias GopherGetAttribute = GopherGetAttributeW; + alias HttpSendRequest = HttpSendRequestW; + alias HttpOpenRequest = HttpOpenRequestW; + alias HttpAddRequestHeaders = HttpAddRequestHeadersW; + alias HttpQueryInfo = HttpQueryInfoW; + alias InternetSetCookie = InternetSetCookieW; + alias InternetGetCookie = InternetGetCookieW; + alias CreateUrlCacheEntry = CreateUrlCacheEntryW; + alias RetrieveUrlCacheEntryStream = RetrieveUrlCacheEntryStreamW; + alias FindNextUrlCacheEntry = FindNextUrlCacheEntryW; + alias CommitUrlCacheEntry = CommitUrlCacheEntryW; + alias GetUrlCacheEntryInfo = GetUrlCacheEntryInfoW; + alias SetUrlCacheEntryInfo = SetUrlCacheEntryInfoW; + alias FindFirstUrlCacheEntry = FindFirstUrlCacheEntryW; + alias RetrieveUrlCacheEntryFile = RetrieveUrlCacheEntryFileW; + alias HttpSendRequestEx = HttpSendRequestExW; + alias HttpEndRequest = HttpEndRequestW; + alias GetUrlCacheGroupAttribute = GetUrlCacheGroupAttributeW; + alias SetUrlCacheGroupAttribute = SetUrlCacheGroupAttributeW; } else { - alias INTERNET_PER_CONN_OPTIONA INTERNET_PER_CONN_OPTION; - alias LPINTERNET_PER_CONN_OPTIONA LPINTERNET_PER_CONN_OPTION; - alias INTERNET_PER_CONN_OPTION_LISTA INTERNET_PER_CONN_OPTION_LIST; - alias LPINTERNET_PER_CONN_OPTION_LISTA LPINTERNET_PER_CONN_OPTION_LIST; - alias URL_COMPONENTSA URL_COMPONENTS; - alias LPURL_COMPONENTSA LPURL_COMPONENTS; - alias GOPHER_FIND_DATAA GOPHER_FIND_DATA; - alias LPGOPHER_FIND_DATAA LPGOPHER_FIND_DATA; - alias INTERNET_CACHE_ENTRY_INFOA INTERNET_CACHE_ENTRY_INFO; - alias LPINTERNET_CACHE_ENTRY_INFOA LPINTERNET_CACHE_ENTRY_INFO; - alias INTERNET_BUFFERSA INTERNET_BUFFERS; - alias INTERNET_CACHE_GROUP_INFOA INTERNET_CACHE_GROUP_INFO; - alias LPINTERNET_CACHE_GROUP_INFOA LPINTERNET_CACHE_GROUP_INFO; - alias GopherGetAttributeA GopherGetAttribute; - alias InternetCrackUrlA InternetCrackUrl; - alias InternetCreateUrlA InternetCreateUrl; - alias InternetCanonicalizeUrlA InternetCanonicalizeUrl; - alias InternetCheckConnectionA InternetCheckConnection; - alias InternetCombineUrlA InternetCombineUrl; - alias InternetOpenA InternetOpen; - alias InternetConnectA InternetConnect; - alias InternetOpenUrlA InternetOpenUrl; - alias InternetFindNextFileA InternetFindNextFile; - alias InternetQueryOptionA InternetQueryOption; - alias InternetSetOptionA InternetSetOption; - alias InternetSetOptionExA InternetSetOptionEx; - alias InternetGetLastResponseInfoA InternetGetLastResponseInfo; - alias InternetReadFileExA InternetReadFileEx; - alias FtpFindFirstFileA FtpFindFirstFile; - alias FtpGetFileA FtpGetFile; - alias FtpPutFileA FtpPutFile; - alias FtpDeleteFileA FtpDeleteFile; - alias FtpRenameFileA FtpRenameFile; - alias FtpOpenFileA FtpOpenFile; - alias FtpCreateDirectoryA FtpCreateDirectory; - alias FtpRemoveDirectoryA FtpRemoveDirectory; - alias FtpSetCurrentDirectoryA FtpSetCurrentDirectory; - alias FtpGetCurrentDirectoryA FtpGetCurrentDirectory; - alias FtpCommandA FtpCommand; - alias GopherGetLocatorTypeA GopherGetLocatorType; - alias GopherCreateLocatorA GopherCreateLocator; - alias GopherFindFirstFileA GopherFindFirstFile; - alias GopherOpenFileA GopherOpenFile; - alias HttpSendRequestA HttpSendRequest; - alias HttpOpenRequestA HttpOpenRequest; - alias HttpAddRequestHeadersA HttpAddRequestHeaders; - alias HttpQueryInfoA HttpQueryInfo; - alias InternetSetCookieA InternetSetCookie; - alias InternetGetCookieA InternetGetCookie; - alias CreateUrlCacheEntryA CreateUrlCacheEntry; - alias RetrieveUrlCacheEntryStreamA RetrieveUrlCacheEntryStream; - alias FindNextUrlCacheEntryA FindNextUrlCacheEntry; - alias CommitUrlCacheEntryA CommitUrlCacheEntry; - alias GetUrlCacheEntryInfoA GetUrlCacheEntryInfo; - alias SetUrlCacheEntryInfoA SetUrlCacheEntryInfo; - alias FindFirstUrlCacheEntryA FindFirstUrlCacheEntry; - alias RetrieveUrlCacheEntryFileA RetrieveUrlCacheEntryFile; - alias HttpSendRequestExA HttpSendRequestEx; - alias HttpEndRequestA HttpEndRequest; - alias GetUrlCacheGroupAttributeA GetUrlCacheGroupAttribute; - alias SetUrlCacheGroupAttributeA SetUrlCacheGroupAttribute; -} - -alias INTERNET_BUFFERS* LPINTERNET_BUFFERS; + alias INTERNET_PER_CONN_OPTION = INTERNET_PER_CONN_OPTIONA; + alias LPINTERNET_PER_CONN_OPTION = LPINTERNET_PER_CONN_OPTIONA; + alias INTERNET_PER_CONN_OPTION_LIST = INTERNET_PER_CONN_OPTION_LISTA; + alias LPINTERNET_PER_CONN_OPTION_LIST = LPINTERNET_PER_CONN_OPTION_LISTA; + alias URL_COMPONENTS = URL_COMPONENTSA; + alias LPURL_COMPONENTS = LPURL_COMPONENTSA; + alias GOPHER_FIND_DATA = GOPHER_FIND_DATAA; + alias LPGOPHER_FIND_DATA = LPGOPHER_FIND_DATAA; + alias INTERNET_CACHE_ENTRY_INFO = INTERNET_CACHE_ENTRY_INFOA; + alias LPINTERNET_CACHE_ENTRY_INFO = LPINTERNET_CACHE_ENTRY_INFOA; + alias INTERNET_BUFFERS = INTERNET_BUFFERSA; + alias INTERNET_CACHE_GROUP_INFO = INTERNET_CACHE_GROUP_INFOA; + alias LPINTERNET_CACHE_GROUP_INFO = LPINTERNET_CACHE_GROUP_INFOA; + alias GopherGetAttribute = GopherGetAttributeA; + alias InternetCrackUrl = InternetCrackUrlA; + alias InternetCreateUrl = InternetCreateUrlA; + alias InternetCanonicalizeUrl = InternetCanonicalizeUrlA; + alias InternetCheckConnection = InternetCheckConnectionA; + alias InternetCombineUrl = InternetCombineUrlA; + alias InternetOpen = InternetOpenA; + alias InternetConnect = InternetConnectA; + alias InternetOpenUrl = InternetOpenUrlA; + alias InternetFindNextFile = InternetFindNextFileA; + alias InternetQueryOption = InternetQueryOptionA; + alias InternetSetOption = InternetSetOptionA; + alias InternetSetOptionEx = InternetSetOptionExA; + alias InternetGetLastResponseInfo = InternetGetLastResponseInfoA; + alias InternetReadFileEx = InternetReadFileExA; + alias FtpFindFirstFile = FtpFindFirstFileA; + alias FtpGetFile = FtpGetFileA; + alias FtpPutFile = FtpPutFileA; + alias FtpDeleteFile = FtpDeleteFileA; + alias FtpRenameFile = FtpRenameFileA; + alias FtpOpenFile = FtpOpenFileA; + alias FtpCreateDirectory = FtpCreateDirectoryA; + alias FtpRemoveDirectory = FtpRemoveDirectoryA; + alias FtpSetCurrentDirectory = FtpSetCurrentDirectoryA; + alias FtpGetCurrentDirectory = FtpGetCurrentDirectoryA; + alias FtpCommand = FtpCommandA; + alias GopherGetLocatorType = GopherGetLocatorTypeA; + alias GopherCreateLocator = GopherCreateLocatorA; + alias GopherFindFirstFile = GopherFindFirstFileA; + alias GopherOpenFile = GopherOpenFileA; + alias HttpSendRequest = HttpSendRequestA; + alias HttpOpenRequest = HttpOpenRequestA; + alias HttpAddRequestHeaders = HttpAddRequestHeadersA; + alias HttpQueryInfo = HttpQueryInfoA; + alias InternetSetCookie = InternetSetCookieA; + alias InternetGetCookie = InternetGetCookieA; + alias CreateUrlCacheEntry = CreateUrlCacheEntryA; + alias RetrieveUrlCacheEntryStream = RetrieveUrlCacheEntryStreamA; + alias FindNextUrlCacheEntry = FindNextUrlCacheEntryA; + alias CommitUrlCacheEntry = CommitUrlCacheEntryA; + alias GetUrlCacheEntryInfo = GetUrlCacheEntryInfoA; + alias SetUrlCacheEntryInfo = SetUrlCacheEntryInfoA; + alias FindFirstUrlCacheEntry = FindFirstUrlCacheEntryA; + alias RetrieveUrlCacheEntryFile = RetrieveUrlCacheEntryFileA; + alias HttpSendRequestEx = HttpSendRequestExA; + alias HttpEndRequest = HttpEndRequestA; + alias GetUrlCacheGroupAttribute = GetUrlCacheGroupAttributeA; + alias SetUrlCacheGroupAttribute = SetUrlCacheGroupAttributeA; +} + +alias LPINTERNET_BUFFERS = INTERNET_BUFFERS*; diff --git a/runtime/druntime/src/core/sys/windows/winioctl.d b/runtime/druntime/src/core/sys/windows/winioctl.d index f9db05d9d6..087b3351ba 100644 --- a/runtime/druntime/src/core/sys/windows/winioctl.d +++ b/runtime/druntime/src/core/sys/windows/winioctl.d @@ -19,7 +19,7 @@ enum size_t HISTOGRAM_BUCKET_SIZE = HISTOGRAM_BUCKET.sizeof, DISK_HISTOGRAM_SIZE = DISK_HISTOGRAM.sizeof; -alias DWORD DEVICE_TYPE; +alias DEVICE_TYPE = DWORD; enum : DEVICE_TYPE { FILE_DEVICE_BEEP = 1, @@ -233,8 +233,8 @@ enum { DISK_BINNING } -alias WORD BAD_TRACK_NUMBER; -alias WORD* PBAD_TRACK_NUMBER; +alias BAD_TRACK_NUMBER = WORD; +alias PBAD_TRACK_NUMBER = WORD*; enum BIN_TYPES { RequestSize, RequestLocation @@ -244,13 +244,13 @@ struct BIN_RANGE { LARGE_INTEGER StartValue; LARGE_INTEGER Length; } -alias BIN_RANGE* PBIN_RANGE; +alias PBIN_RANGE = BIN_RANGE*; struct BIN_COUNT { BIN_RANGE BinRange; DWORD BinCount; } -alias BIN_COUNT* PBIN_COUNT; +alias PBIN_COUNT = BIN_COUNT*; struct BIN_RESULTS { DWORD NumberOfBins; @@ -258,7 +258,7 @@ struct BIN_RESULTS { BIN_COUNT* BinCounts() return { return &_BinCounts; } } -alias BIN_RESULTS* PBIN_RESULTS; +alias PBIN_RESULTS = BIN_RESULTS*; enum PARTITION_STYLE { PARTITION_STYLE_MBR, @@ -270,12 +270,12 @@ struct CREATE_DISK_GPT { GUID DiskId; DWORD MaxPartitionCount; } -alias CREATE_DISK_GPT* PCREATE_DISK_GPT; +alias PCREATE_DISK_GPT = CREATE_DISK_GPT*; struct CREATE_DISK_MBR { DWORD Signature; } -alias CREATE_DISK_MBR* PCREATE_DISK_MBR; +alias PCREATE_DISK_MBR = CREATE_DISK_MBR*; struct CREATE_DISK { PARTITION_STYLE PartitionStyle; @@ -284,7 +284,7 @@ struct CREATE_DISK { CREATE_DISK_GPT Gpt; } } -alias CREATE_DISK* PCREATE_DISK; +alias PCREATE_DISK = CREATE_DISK*; enum DISK_CACHE_RETENTION_PRIORITY { EqualPriority, @@ -314,7 +314,7 @@ struct DISK_CACHE_INFORMATION { _BlockPrefetch BlockPrefetch; } } -alias DISK_CACHE_INFORMATION* PDISK_CACHE_INFORMATION; +alias PDISK_CACHE_INFORMATION = DISK_CACHE_INFORMATION*; enum DETECTION_TYPE { DetectNone, @@ -329,7 +329,7 @@ struct DISK_INT13_INFO { WORD MaxHeads; WORD NumberDrives; } -alias DISK_INT13_INFO* PDISK_INT13_INFO; +alias PDISK_INT13_INFO = DISK_INT13_INFO*; struct DISK_EX_INT13_INFO { WORD ExBufferSize; @@ -341,7 +341,7 @@ struct DISK_EX_INT13_INFO { WORD ExSectorSize; WORD ExReserved; } -alias DISK_EX_INT13_INFO* PDISK_EX_INT13_INFO; +alias PDISK_EX_INT13_INFO = DISK_EX_INT13_INFO*; struct DISK_DETECTION_INFO { DWORD SizeOfDetectInfo; @@ -349,7 +349,7 @@ struct DISK_DETECTION_INFO { DISK_INT13_INFO Int13; DISK_EX_INT13_INFO ExInt13; } -alias DISK_DETECTION_INFO* PDISK_DETECTION_INFO; +alias PDISK_DETECTION_INFO = DISK_DETECTION_INFO*; enum MEDIA_TYPE { Unknown, @@ -379,7 +379,7 @@ enum MEDIA_TYPE { F3_240M_512, F3_32M_512 } -alias MEDIA_TYPE* PMEDIA_TYPE; +alias PMEDIA_TYPE = MEDIA_TYPE*; struct DISK_GEOMETRY { LARGE_INTEGER Cylinders; @@ -388,7 +388,7 @@ struct DISK_GEOMETRY { DWORD SectorsPerTrack; DWORD BytesPerSector; } -alias DISK_GEOMETRY* PDISK_GEOMETRY; +alias PDISK_GEOMETRY = DISK_GEOMETRY*; struct DISK_GEOMETRY_EX { DISK_GEOMETRY Geometry; @@ -397,13 +397,13 @@ struct DISK_GEOMETRY_EX { BYTE* Data() return { return &_Data; } } -alias DISK_GEOMETRY_EX* PDISK_GEOMETRY_EX; +alias PDISK_GEOMETRY_EX = DISK_GEOMETRY_EX*; struct DISK_GROW_PARTITION { DWORD PartitionNumber; LARGE_INTEGER BytesToGrow; } -alias DISK_GROW_PARTITION* PDISK_GROW_PARTITION; +alias PDISK_GROW_PARTITION = DISK_GROW_PARTITION*; struct DISK_PARTITION_INFO { DWORD SizeOfPartitionInfo; @@ -417,7 +417,7 @@ struct DISK_PARTITION_INFO { //} Gpt; } } -alias DISK_PARTITION_INFO* PDISK_PARTITION_INFO; +alias PDISK_PARTITION_INFO = DISK_PARTITION_INFO*; struct DISK_PERFORMANCE { LARGE_INTEGER BytesRead; @@ -428,7 +428,7 @@ struct DISK_PERFORMANCE { DWORD WriteCount; DWORD QueueDepth; } -alias DISK_PERFORMANCE* PDISK_PERFORMANCE; +alias PDISK_PERFORMANCE = DISK_PERFORMANCE*; struct DISK_RECORD { LARGE_INTEGER ByteOffset; @@ -439,21 +439,21 @@ struct DISK_RECORD { BYTE DeviceNumber; BOOLEAN ReadRequest; } -alias DISK_RECORD* PDISK_RECORD; +alias PDISK_RECORD = DISK_RECORD*; struct DISK_LOGGING { BYTE Function; PVOID BufferAddress; DWORD BufferSize; } -alias DISK_LOGGING* PDISK_LOGGING; +alias PDISK_LOGGING = DISK_LOGGING*; struct DISKQUOTA_USER_INFORMATION { LONGLONG QuotaUsed; LONGLONG QuotaThreshold; LONGLONG QuotaLimit; } -alias DISKQUOTA_USER_INFORMATION* PDISKQUOTA_USER_INFORMATION; +alias PDISKQUOTA_USER_INFORMATION = DISKQUOTA_USER_INFORMATION*; struct FORMAT_PARAMETERS { MEDIA_TYPE MediaType; @@ -462,7 +462,7 @@ struct FORMAT_PARAMETERS { DWORD StartHeadNumber; DWORD EndHeadNumber; } -alias FORMAT_PARAMETERS* PFORMAT_PARAMETERS; +alias PFORMAT_PARAMETERS = FORMAT_PARAMETERS*; struct FORMAT_EX_PARAMETERS { MEDIA_TYPE MediaType; @@ -476,7 +476,7 @@ struct FORMAT_EX_PARAMETERS { WORD* SectorNumber() return { return &_SectorNumber; } } -alias FORMAT_EX_PARAMETERS* PFORMAT_EX_PARAMETERS; +alias PFORMAT_EX_PARAMETERS = FORMAT_EX_PARAMETERS*; struct GET_LENGTH_INFORMATION { LARGE_INTEGER Length; @@ -486,7 +486,7 @@ struct HISTOGRAM_BUCKET { DWORD Reads; DWORD Writes; } -alias HISTOGRAM_BUCKET* PHISTOGRAM_BUCKET; +alias PHISTOGRAM_BUCKET = HISTOGRAM_BUCKET*; struct DISK_HISTOGRAM { LARGE_INTEGER DiskSize; @@ -501,14 +501,14 @@ struct DISK_HISTOGRAM { DWORD WriteCount; PHISTOGRAM_BUCKET Histogram; } -alias DISK_HISTOGRAM* PDISK_HISTOGRAM; +alias PDISK_HISTOGRAM = DISK_HISTOGRAM*; struct DISK_EXTENT { DWORD DiskNumber; LARGE_INTEGER StartingOffset; LARGE_INTEGER ExtentLength; } -alias DISK_EXTENT* PDISK_EXTENT; +alias PDISK_EXTENT = DISK_EXTENT*; struct VOLUME_DISK_EXTENTS { DWORD NumberOfDiskExtents; @@ -516,7 +516,7 @@ struct VOLUME_DISK_EXTENTS { DISK_EXTENT* Extents() return { return &_Extents; } } -alias VOLUME_DISK_EXTENTS* PVOLUME_DISK_EXTENTS; +alias PVOLUME_DISK_EXTENTS = VOLUME_DISK_EXTENTS*; struct PARTITION_INFORMATION { LARGE_INTEGER StartingOffset; @@ -528,7 +528,7 @@ struct PARTITION_INFORMATION { BOOLEAN RecognizedPartition; BOOLEAN RewritePartition; } -alias PARTITION_INFORMATION* PPARTITION_INFORMATION; +alias PPARTITION_INFORMATION = PARTITION_INFORMATION*; struct DRIVE_LAYOUT_INFORMATION { DWORD PartitionCount; @@ -537,7 +537,7 @@ struct DRIVE_LAYOUT_INFORMATION { PARTITION_INFORMATION* PartitionEntry() return { return &_PartitionEntry; } } -alias DRIVE_LAYOUT_INFORMATION* PDRIVE_LAYOUT_INFORMATION; +alias PDRIVE_LAYOUT_INFORMATION = DRIVE_LAYOUT_INFORMATION*; struct DRIVE_LAYOUT_INFORMATION_GPT { GUID DiskId; @@ -545,12 +545,12 @@ struct DRIVE_LAYOUT_INFORMATION_GPT { LARGE_INTEGER UsableLength; ULONG MaxPartitionCount; } -alias DRIVE_LAYOUT_INFORMATION_GPT* PDRIVE_LAYOUT_INFORMATION_GPT; +alias PDRIVE_LAYOUT_INFORMATION_GPT = DRIVE_LAYOUT_INFORMATION_GPT*; struct DRIVE_LAYOUT_INFORMATION_MBR { ULONG Signature; } -alias DRIVE_LAYOUT_INFORMATION_MBR* PDRIVE_LAYOUT_INFORMATION_MBR; +alias PDRIVE_LAYOUT_INFORMATION_MBR = DRIVE_LAYOUT_INFORMATION_MBR*; struct PARTITION_INFORMATION_MBR { BYTE PartitionType; @@ -589,7 +589,7 @@ struct DRIVE_LAYOUT_INFORMATION_EX { PARTITION_INFORMATION_EX* PartitionEntry() return { return &_PartitionEntry; } } -alias DRIVE_LAYOUT_INFORMATION_EX* PDRIVE_LAYOUT_INFORMATION_EX; +alias PDRIVE_LAYOUT_INFORMATION_EX = DRIVE_LAYOUT_INFORMATION_EX*; struct MOVE_FILE_DATA { HANDLE FileHandle; @@ -597,7 +597,7 @@ struct MOVE_FILE_DATA { LARGE_INTEGER StartingLcn; DWORD ClusterCount; } -alias MOVE_FILE_DATA* PMOVE_FILE_DATA; +alias PMOVE_FILE_DATA = MOVE_FILE_DATA*; struct PERF_BIN { DWORD NumberOfBins; @@ -606,12 +606,12 @@ struct PERF_BIN { BIN_RANGE* BinsRanges() return { return &_BinsRanges; } } -alias PERF_BIN* PPERF_BIN; +alias PPERF_BIN = PERF_BIN*; struct PREVENT_MEDIA_REMOVAL { BOOLEAN PreventMediaRemoval; } -alias PREVENT_MEDIA_REMOVAL* PPREVENT_MEDIA_REMOVAL; +alias PPREVENT_MEDIA_REMOVAL = PREVENT_MEDIA_REMOVAL*; struct RETRIEVAL_POINTERS_BUFFER { DWORD ExtentCount; @@ -625,7 +625,7 @@ struct RETRIEVAL_POINTERS_BUFFER { Extent* Extents() return { return &_Extents; } } -alias RETRIEVAL_POINTERS_BUFFER* PRETRIEVAL_POINTERS_BUFFER; +alias PRETRIEVAL_POINTERS_BUFFER = RETRIEVAL_POINTERS_BUFFER*; struct REASSIGN_BLOCKS { WORD Reserved; @@ -634,28 +634,28 @@ struct REASSIGN_BLOCKS { DWORD* BlockNumber() return { return &_BlockNumber; } } -alias REASSIGN_BLOCKS* PREASSIGN_BLOCKS; +alias PREASSIGN_BLOCKS = REASSIGN_BLOCKS*; struct SET_PARTITION_INFORMATION { BYTE PartitionType; } -alias SET_PARTITION_INFORMATION* PSET_PARTITION_INFORMATION; +alias PSET_PARTITION_INFORMATION = SET_PARTITION_INFORMATION*; struct STARTING_LCN_INPUT_BUFFER { LARGE_INTEGER StartingLcn; } -alias STARTING_LCN_INPUT_BUFFER* PSTARTING_LCN_INPUT_BUFFER; +alias PSTARTING_LCN_INPUT_BUFFER = STARTING_LCN_INPUT_BUFFER*; struct STARTING_VCN_INPUT_BUFFER { LARGE_INTEGER StartingVcn; } -alias STARTING_VCN_INPUT_BUFFER* PSTARTING_VCN_INPUT_BUFFER; +alias PSTARTING_VCN_INPUT_BUFFER = STARTING_VCN_INPUT_BUFFER*; struct VERIFY_INFORMATION { LARGE_INTEGER StartingOffset; DWORD Length; } -alias VERIFY_INFORMATION* PVERIFY_INFORMATION; +alias PVERIFY_INFORMATION = VERIFY_INFORMATION*; struct VOLUME_BITMAP_BUFFER { LARGE_INTEGER StartingLcn; @@ -664,7 +664,7 @@ struct VOLUME_BITMAP_BUFFER { BYTE* Buffer() return { return &_Buffer; } } -alias VOLUME_BITMAP_BUFFER* PVOLUME_BITMAP_BUFFER; +alias PVOLUME_BITMAP_BUFFER = VOLUME_BITMAP_BUFFER*; struct NTFS_VOLUME_DATA_BUFFER { LARGE_INTEGER VolumeSerialNumber; @@ -682,7 +682,7 @@ struct NTFS_VOLUME_DATA_BUFFER { LARGE_INTEGER MftZoneStart; LARGE_INTEGER MftZoneEnd; } -alias NTFS_VOLUME_DATA_BUFFER* PNTFS_VOLUME_DATA_BUFFER; +alias PNTFS_VOLUME_DATA_BUFFER = NTFS_VOLUME_DATA_BUFFER*; bool IsRecognizedPartition(BYTE t) { diff --git a/runtime/druntime/src/core/sys/windows/winldap.d b/runtime/druntime/src/core/sys/windows/winldap.d index bcdb2b33a7..c927ddea16 100644 --- a/runtime/druntime/src/core/sys/windows/winldap.d +++ b/runtime/druntime/src/core/sys/windows/winldap.d @@ -297,7 +297,7 @@ struct LDAP { PCHAR ld_matched; PCHAR ld_error; } -alias LDAP* PLDAP; +alias PLDAP = LDAP*; // should be opaque structure struct LDAPMessage { @@ -308,13 +308,13 @@ struct LDAPMessage { LDAPMessage* lm_next; ULONG lm_time; } -alias LDAPMessage* PLDAPMessage; +alias PLDAPMessage = LDAPMessage*; struct LDAP_TIMEVAL { LONG tv_sec; LONG tv_usec; } -alias LDAP_TIMEVAL* PLDAP_TIMEVAL; +alias PLDAP_TIMEVAL = LDAP_TIMEVAL*; struct LDAPAPIInfoA { int ldapai_info_version; @@ -324,7 +324,7 @@ struct LDAPAPIInfoA { char* ldapai_vendor_name; int ldapai_vendor_version; } -alias LDAPAPIInfoA* PLDAPAPIInfoA; +alias PLDAPAPIInfoA = LDAPAPIInfoA*; struct LDAPAPIInfoW { int ldapai_info_version; @@ -334,35 +334,35 @@ struct LDAPAPIInfoW { PWCHAR ldapai_vendor_name; int ldapai_vendor_version; } -alias LDAPAPIInfoW* PLDAPAPIInfoW; +alias PLDAPAPIInfoW = LDAPAPIInfoW*; struct LDAPAPIFeatureInfoA { int ldapaif_info_version; char* ldapaif_name; int ldapaif_version; } -alias LDAPAPIFeatureInfoA* PLDAPAPIFeatureInfoA; +alias PLDAPAPIFeatureInfoA = LDAPAPIFeatureInfoA*; struct LDAPAPIFeatureInfoW { int ldapaif_info_version; PWCHAR ldapaif_name; int ldapaif_version; } -alias LDAPAPIFeatureInfoW* PLDAPAPIFeatureInfoW; +alias PLDAPAPIFeatureInfoW = LDAPAPIFeatureInfoW*; struct LDAPControlA { PCHAR ldctl_oid; BerValue ldctl_value; BOOLEAN ldctl_iscritical; } -alias LDAPControlA* PLDAPControlA; +alias PLDAPControlA = LDAPControlA*; struct LDAPControlW { PWCHAR ldctl_oid; BerValue ldctl_value; BOOLEAN ldctl_iscritical; } -alias LDAPControlW* PLDAPControlW; +alias PLDAPControlW = LDAPControlW*; /* Do we really need these? In MinGW, LDAPModA/W have only mod_op, mod_type * and mod_vals, and macros are used to simulate anonymous unions in those @@ -389,7 +389,7 @@ struct LDAPModA { BerValue** mod_bvalues; } } -alias LDAPModA* PLDAPModA; +alias PLDAPModA = LDAPModA*; struct LDAPModW { ULONG mod_op; @@ -402,39 +402,39 @@ struct LDAPModW { BerValue** mod_bvalues; } } -alias LDAPModW* PLDAPModW; +alias PLDAPModW = LDAPModW*; /* Opaque structure * http://msdn.microsoft.com/library/en-us/ldap/ldap/ldapsearch.asp */ struct LDAPSearch; -alias LDAPSearch* PLDAPSearch; +alias PLDAPSearch = LDAPSearch*; struct LDAPSortKeyA { PCHAR sk_attrtype; PCHAR sk_matchruleoid; BOOLEAN sk_reverseorder; } -alias LDAPSortKeyA* PLDAPSortKeyA; +alias PLDAPSortKeyA = LDAPSortKeyA*; struct LDAPSortKeyW { PWCHAR sk_attrtype; PWCHAR sk_matchruleoid; BOOLEAN sk_reverseorder; } -alias LDAPSortKeyW* PLDAPSortKeyW; +alias PLDAPSortKeyW = LDAPSortKeyW*; /* MinGW defines these as immediate function typedefs, which don't translate * well into D. */ extern (C) { - alias ULONG function(PLDAP, PLDAP, PWCHAR, PCHAR, ULONG, PVOID, PVOID, - PLDAP*) QUERYFORCONNECTION; - alias BOOLEAN function(PLDAP, PLDAP, PWCHAR, PCHAR, PLDAP, ULONG, PVOID, - PVOID, ULONG) NOTIFYOFNEWCONNECTION; - alias ULONG function(PLDAP, PLDAP) DEREFERENCECONNECTION; - alias BOOLEAN function(PLDAP, PSecPkgContext_IssuerListInfoEx, - PCCERT_CONTEXT*) QUERYCLIENTCERT; + alias QUERYFORCONNECTION = ULONG function(PLDAP, PLDAP, PWCHAR, PCHAR, ULONG, PVOID, PVOID, + PLDAP*); + alias NOTIFYOFNEWCONNECTION = BOOLEAN function(PLDAP, PLDAP, PWCHAR, PCHAR, PLDAP, ULONG, PVOID, + PVOID, ULONG); + alias DEREFERENCECONNECTION = ULONG function(PLDAP, PLDAP); + alias QUERYCLIENTCERT = BOOLEAN function(PLDAP, PSecPkgContext_IssuerListInfoEx, + PCCERT_CONTEXT*); } struct LDAP_REFERRAL_CALLBACK { @@ -443,7 +443,7 @@ struct LDAP_REFERRAL_CALLBACK { NOTIFYOFNEWCONNECTION* NotifyRoutine; DEREFERENCECONNECTION* DereferenceRoutine; } -alias LDAP_REFERRAL_CALLBACK* PLDAP_REFERRAL_CALLBACK; +alias PLDAP_REFERRAL_CALLBACK = LDAP_REFERRAL_CALLBACK*; struct LDAPVLVInfo { int ldvlv_version; @@ -689,173 +689,173 @@ extern (C) { } version (Unicode) { - alias LDAPControlW LDAPControl; - alias PLDAPControlW PLDAPControl; - alias LDAPModW LDAPMod; - alias LDAPModW PLDAPMod; - alias LDAPSortKeyW LDAPSortKey; - alias PLDAPSortKeyW PLDAPSortKey; - alias LDAPAPIInfoW LDAPAPIInfo; - alias PLDAPAPIInfoW PLDAPAPIInfo; - alias LDAPAPIFeatureInfoW LDAPAPIFeatureInfo; - alias PLDAPAPIFeatureInfoW PLDAPAPIFeatureInfo; - alias cldap_openW cldap_open; - alias ldap_openW ldap_open; - alias ldap_simple_bindW ldap_simple_bind; - alias ldap_simple_bind_sW ldap_simple_bind_s; - alias ldap_sasl_bindW ldap_sasl_bind; - alias ldap_sasl_bind_sW ldap_sasl_bind_s; - alias ldap_initW ldap_init; - alias ldap_sslinitW ldap_sslinit; - alias ldap_get_optionW ldap_get_option; - alias ldap_set_optionW ldap_set_option; - alias ldap_start_tls_sW ldap_start_tls_s; - alias ldap_addW ldap_add; - alias ldap_add_extW ldap_add_ext; - alias ldap_add_sW ldap_add_s; - alias ldap_add_ext_sW ldap_add_ext_s; - alias ldap_compareW ldap_compare; - alias ldap_compare_extW ldap_compare_ext; - alias ldap_compare_sW ldap_compare_s; - alias ldap_compare_ext_sW ldap_compare_ext_s; - alias ldap_deleteW ldap_delete; - alias ldap_delete_extW ldap_delete_ext; - alias ldap_delete_sW ldap_delete_s; - alias ldap_delete_ext_sW ldap_delete_ext_s; - alias ldap_extended_operation_sW ldap_extended_operation_s; - alias ldap_extended_operationW ldap_extended_operation; - alias ldap_modifyW ldap_modify; - alias ldap_modify_extW ldap_modify_ext; - alias ldap_modify_sW ldap_modify_s; - alias ldap_modify_ext_sW ldap_modify_ext_s; - alias ldap_check_filterW ldap_check_filter; - alias ldap_count_valuesW ldap_count_values; - alias ldap_create_page_controlW ldap_create_page_control; - alias ldap_create_sort_controlW ldap_create_sort_control; - alias ldap_create_vlv_controlW ldap_create_vlv_control; - alias ldap_encode_sort_controlW ldap_encode_sort_control; - alias ldap_escape_filter_elementW ldap_escape_filter_element; - alias ldap_first_attributeW ldap_first_attribute; - alias ldap_next_attributeW ldap_next_attribute; - alias ldap_get_valuesW ldap_get_values; - alias ldap_get_values_lenW ldap_get_values_len; - alias ldap_parse_extended_resultW ldap_parse_extended_result; - alias ldap_parse_page_controlW ldap_parse_page_control; - alias ldap_parse_referenceW ldap_parse_reference; - alias ldap_parse_resultW ldap_parse_result; - alias ldap_parse_sort_controlW ldap_parse_sort_control; - alias ldap_parse_vlv_controlW ldap_parse_vlv_control; - alias ldap_searchW ldap_search; - alias ldap_search_sW ldap_search_s; - alias ldap_search_stW ldap_search_st; - alias ldap_search_extW ldap_search_ext; - alias ldap_search_ext_sW ldap_search_ext_s; - alias ldap_search_init_pageW ldap_search_init_page; - alias ldap_err2stringW ldap_err2string; - alias ldap_control_freeW ldap_control_free; - alias ldap_controls_freeW ldap_controls_free; - alias ldap_free_controlsW ldap_free_controls; - alias ldap_memfreeW ldap_memfree; - alias ldap_value_freeW ldap_value_free; - alias ldap_dn2ufnW ldap_dn2ufn; - alias ldap_ufn2dnW ldap_ufn2dn; - alias ldap_explode_dnW ldap_explode_dn; - alias ldap_get_dnW ldap_get_dn; - alias ldap_rename_extW ldap_rename; - alias ldap_rename_ext_sW ldap_rename_s; - alias ldap_rename_extW ldap_rename_ext; - alias ldap_rename_ext_sW ldap_rename_ext_s; + alias LDAPControl = LDAPControlW; + alias PLDAPControl = PLDAPControlW; + alias LDAPMod = LDAPModW; + alias PLDAPMod = LDAPModW; + alias LDAPSortKey = LDAPSortKeyW; + alias PLDAPSortKey = PLDAPSortKeyW; + alias LDAPAPIInfo = LDAPAPIInfoW; + alias PLDAPAPIInfo = PLDAPAPIInfoW; + alias LDAPAPIFeatureInfo = LDAPAPIFeatureInfoW; + alias PLDAPAPIFeatureInfo = PLDAPAPIFeatureInfoW; + alias cldap_open = cldap_openW; + alias ldap_open = ldap_openW; + alias ldap_simple_bind = ldap_simple_bindW; + alias ldap_simple_bind_s = ldap_simple_bind_sW; + alias ldap_sasl_bind = ldap_sasl_bindW; + alias ldap_sasl_bind_s = ldap_sasl_bind_sW; + alias ldap_init = ldap_initW; + alias ldap_sslinit = ldap_sslinitW; + alias ldap_get_option = ldap_get_optionW; + alias ldap_set_option = ldap_set_optionW; + alias ldap_start_tls_s = ldap_start_tls_sW; + alias ldap_add = ldap_addW; + alias ldap_add_ext = ldap_add_extW; + alias ldap_add_s = ldap_add_sW; + alias ldap_add_ext_s = ldap_add_ext_sW; + alias ldap_compare = ldap_compareW; + alias ldap_compare_ext = ldap_compare_extW; + alias ldap_compare_s = ldap_compare_sW; + alias ldap_compare_ext_s = ldap_compare_ext_sW; + alias ldap_delete = ldap_deleteW; + alias ldap_delete_ext = ldap_delete_extW; + alias ldap_delete_s = ldap_delete_sW; + alias ldap_delete_ext_s = ldap_delete_ext_sW; + alias ldap_extended_operation_s = ldap_extended_operation_sW; + alias ldap_extended_operation = ldap_extended_operationW; + alias ldap_modify = ldap_modifyW; + alias ldap_modify_ext = ldap_modify_extW; + alias ldap_modify_s = ldap_modify_sW; + alias ldap_modify_ext_s = ldap_modify_ext_sW; + alias ldap_check_filter = ldap_check_filterW; + alias ldap_count_values = ldap_count_valuesW; + alias ldap_create_page_control = ldap_create_page_controlW; + alias ldap_create_sort_control = ldap_create_sort_controlW; + alias ldap_create_vlv_control = ldap_create_vlv_controlW; + alias ldap_encode_sort_control = ldap_encode_sort_controlW; + alias ldap_escape_filter_element = ldap_escape_filter_elementW; + alias ldap_first_attribute = ldap_first_attributeW; + alias ldap_next_attribute = ldap_next_attributeW; + alias ldap_get_values = ldap_get_valuesW; + alias ldap_get_values_len = ldap_get_values_lenW; + alias ldap_parse_extended_result = ldap_parse_extended_resultW; + alias ldap_parse_page_control = ldap_parse_page_controlW; + alias ldap_parse_reference = ldap_parse_referenceW; + alias ldap_parse_result = ldap_parse_resultW; + alias ldap_parse_sort_control = ldap_parse_sort_controlW; + alias ldap_parse_vlv_control = ldap_parse_vlv_controlW; + alias ldap_search = ldap_searchW; + alias ldap_search_s = ldap_search_sW; + alias ldap_search_st = ldap_search_stW; + alias ldap_search_ext = ldap_search_extW; + alias ldap_search_ext_s = ldap_search_ext_sW; + alias ldap_search_init_page = ldap_search_init_pageW; + alias ldap_err2string = ldap_err2stringW; + alias ldap_control_free = ldap_control_freeW; + alias ldap_controls_free = ldap_controls_freeW; + alias ldap_free_controls = ldap_free_controlsW; + alias ldap_memfree = ldap_memfreeW; + alias ldap_value_free = ldap_value_freeW; + alias ldap_dn2ufn = ldap_dn2ufnW; + alias ldap_ufn2dn = ldap_ufn2dnW; + alias ldap_explode_dn = ldap_explode_dnW; + alias ldap_get_dn = ldap_get_dnW; + alias ldap_rename = ldap_rename_extW; + alias ldap_rename_s = ldap_rename_ext_sW; + alias ldap_rename_ext = ldap_rename_extW; + alias ldap_rename_ext_s = ldap_rename_ext_sW; deprecated { - alias ldap_bindW ldap_bind; - alias ldap_bind_sW ldap_bind_s; - alias ldap_modrdnW ldap_modrdn; - alias ldap_modrdn_sW ldap_modrdn_s; - alias ldap_modrdn2W ldap_modrdn2; - alias ldap_modrdn2_sW ldap_modrdn2_s; + alias ldap_bind = ldap_bindW; + alias ldap_bind_s = ldap_bind_sW; + alias ldap_modrdn = ldap_modrdnW; + alias ldap_modrdn_s = ldap_modrdn_sW; + alias ldap_modrdn2 = ldap_modrdn2W; + alias ldap_modrdn2_s = ldap_modrdn2_sW; } } else { - alias LDAPControlA LDAPControl; - alias PLDAPControlA PLDAPControl; - alias LDAPModA LDAPMod; - alias LDAPModA PLDAPMod; - alias LDAPSortKeyA LDAPSortKey; - alias PLDAPSortKeyA PLDAPSortKey; - alias LDAPAPIInfoA LDAPAPIInfo; - alias PLDAPAPIInfoA PLDAPAPIInfo; - alias LDAPAPIFeatureInfoA LDAPAPIFeatureInfo; - alias PLDAPAPIFeatureInfoA PLDAPAPIFeatureInfo; - alias cldap_openA cldap_open; - alias ldap_openA ldap_open; - alias ldap_simple_bindA ldap_simple_bind; - alias ldap_simple_bind_sA ldap_simple_bind_s; - alias ldap_sasl_bindA ldap_sasl_bind; - alias ldap_sasl_bind_sA ldap_sasl_bind_s; - alias ldap_initA ldap_init; - alias ldap_sslinitA ldap_sslinit; - alias ldap_get_optionA ldap_get_option; - alias ldap_set_optionA ldap_set_option; - alias ldap_start_tls_sA ldap_start_tls_s; - alias ldap_addA ldap_add; - alias ldap_add_extA ldap_add_ext; - alias ldap_add_sA ldap_add_s; - alias ldap_add_ext_sA ldap_add_ext_s; - alias ldap_compareA ldap_compare; - alias ldap_compare_extA ldap_compare_ext; - alias ldap_compare_sA ldap_compare_s; - alias ldap_compare_ext_sA ldap_compare_ext_s; - alias ldap_deleteA ldap_delete; - alias ldap_delete_extA ldap_delete_ext; - alias ldap_delete_sA ldap_delete_s; - alias ldap_delete_ext_sA ldap_delete_ext_s; - alias ldap_extended_operation_sA ldap_extended_operation_s; - alias ldap_extended_operationA ldap_extended_operation; - alias ldap_modifyA ldap_modify; - alias ldap_modify_extA ldap_modify_ext; - alias ldap_modify_sA ldap_modify_s; - alias ldap_modify_ext_sA ldap_modify_ext_s; - alias ldap_check_filterA ldap_check_filter; - alias ldap_count_valuesA ldap_count_values; - alias ldap_create_page_controlA ldap_create_page_control; - alias ldap_create_sort_controlA ldap_create_sort_control; - alias ldap_create_vlv_controlA ldap_create_vlv_control; - alias ldap_encode_sort_controlA ldap_encode_sort_control; - alias ldap_escape_filter_elementA ldap_escape_filter_element; - alias ldap_first_attributeA ldap_first_attribute; - alias ldap_next_attributeA ldap_next_attribute; - alias ldap_get_valuesA ldap_get_values; - alias ldap_get_values_lenA ldap_get_values_len; - alias ldap_parse_extended_resultA ldap_parse_extended_result; - alias ldap_parse_page_controlA ldap_parse_page_control; - alias ldap_parse_referenceA ldap_parse_reference; - alias ldap_parse_resultA ldap_parse_result; - alias ldap_parse_sort_controlA ldap_parse_sort_control; - alias ldap_parse_vlv_controlA ldap_parse_vlv_control; - alias ldap_searchA ldap_search; - alias ldap_search_sA ldap_search_s; - alias ldap_search_stA ldap_search_st; - alias ldap_search_extA ldap_search_ext; - alias ldap_search_ext_sA ldap_search_ext_s; - alias ldap_search_init_pageA ldap_search_init_page; - alias ldap_err2stringA ldap_err2string; - alias ldap_control_freeA ldap_control_free; - alias ldap_controls_freeA ldap_controls_free; - alias ldap_free_controlsA ldap_free_controls; - alias ldap_memfreeA ldap_memfree; - alias ldap_value_freeA ldap_value_free; - alias ldap_dn2ufnA ldap_dn2ufn; - alias ldap_ufn2dnA ldap_ufn2dn; - alias ldap_explode_dnA ldap_explode_dn; - alias ldap_get_dnA ldap_get_dn; - alias ldap_rename_extA ldap_rename; - alias ldap_rename_ext_sA ldap_rename_s; - alias ldap_rename_extA ldap_rename_ext; - alias ldap_rename_ext_sA ldap_rename_ext_s; + alias LDAPControl = LDAPControlA; + alias PLDAPControl = PLDAPControlA; + alias LDAPMod = LDAPModA; + alias PLDAPMod = LDAPModA; + alias LDAPSortKey = LDAPSortKeyA; + alias PLDAPSortKey = PLDAPSortKeyA; + alias LDAPAPIInfo = LDAPAPIInfoA; + alias PLDAPAPIInfo = PLDAPAPIInfoA; + alias LDAPAPIFeatureInfo = LDAPAPIFeatureInfoA; + alias PLDAPAPIFeatureInfo = PLDAPAPIFeatureInfoA; + alias cldap_open = cldap_openA; + alias ldap_open = ldap_openA; + alias ldap_simple_bind = ldap_simple_bindA; + alias ldap_simple_bind_s = ldap_simple_bind_sA; + alias ldap_sasl_bind = ldap_sasl_bindA; + alias ldap_sasl_bind_s = ldap_sasl_bind_sA; + alias ldap_init = ldap_initA; + alias ldap_sslinit = ldap_sslinitA; + alias ldap_get_option = ldap_get_optionA; + alias ldap_set_option = ldap_set_optionA; + alias ldap_start_tls_s = ldap_start_tls_sA; + alias ldap_add = ldap_addA; + alias ldap_add_ext = ldap_add_extA; + alias ldap_add_s = ldap_add_sA; + alias ldap_add_ext_s = ldap_add_ext_sA; + alias ldap_compare = ldap_compareA; + alias ldap_compare_ext = ldap_compare_extA; + alias ldap_compare_s = ldap_compare_sA; + alias ldap_compare_ext_s = ldap_compare_ext_sA; + alias ldap_delete = ldap_deleteA; + alias ldap_delete_ext = ldap_delete_extA; + alias ldap_delete_s = ldap_delete_sA; + alias ldap_delete_ext_s = ldap_delete_ext_sA; + alias ldap_extended_operation_s = ldap_extended_operation_sA; + alias ldap_extended_operation = ldap_extended_operationA; + alias ldap_modify = ldap_modifyA; + alias ldap_modify_ext = ldap_modify_extA; + alias ldap_modify_s = ldap_modify_sA; + alias ldap_modify_ext_s = ldap_modify_ext_sA; + alias ldap_check_filter = ldap_check_filterA; + alias ldap_count_values = ldap_count_valuesA; + alias ldap_create_page_control = ldap_create_page_controlA; + alias ldap_create_sort_control = ldap_create_sort_controlA; + alias ldap_create_vlv_control = ldap_create_vlv_controlA; + alias ldap_encode_sort_control = ldap_encode_sort_controlA; + alias ldap_escape_filter_element = ldap_escape_filter_elementA; + alias ldap_first_attribute = ldap_first_attributeA; + alias ldap_next_attribute = ldap_next_attributeA; + alias ldap_get_values = ldap_get_valuesA; + alias ldap_get_values_len = ldap_get_values_lenA; + alias ldap_parse_extended_result = ldap_parse_extended_resultA; + alias ldap_parse_page_control = ldap_parse_page_controlA; + alias ldap_parse_reference = ldap_parse_referenceA; + alias ldap_parse_result = ldap_parse_resultA; + alias ldap_parse_sort_control = ldap_parse_sort_controlA; + alias ldap_parse_vlv_control = ldap_parse_vlv_controlA; + alias ldap_search = ldap_searchA; + alias ldap_search_s = ldap_search_sA; + alias ldap_search_st = ldap_search_stA; + alias ldap_search_ext = ldap_search_extA; + alias ldap_search_ext_s = ldap_search_ext_sA; + alias ldap_search_init_page = ldap_search_init_pageA; + alias ldap_err2string = ldap_err2stringA; + alias ldap_control_free = ldap_control_freeA; + alias ldap_controls_free = ldap_controls_freeA; + alias ldap_free_controls = ldap_free_controlsA; + alias ldap_memfree = ldap_memfreeA; + alias ldap_value_free = ldap_value_freeA; + alias ldap_dn2ufn = ldap_dn2ufnA; + alias ldap_ufn2dn = ldap_ufn2dnA; + alias ldap_explode_dn = ldap_explode_dnA; + alias ldap_get_dn = ldap_get_dnA; + alias ldap_rename = ldap_rename_extA; + alias ldap_rename_s = ldap_rename_ext_sA; + alias ldap_rename_ext = ldap_rename_extA; + alias ldap_rename_ext_s = ldap_rename_ext_sA; deprecated { - alias ldap_bindA ldap_bind; - alias ldap_bind_sA ldap_bind_s; - alias ldap_modrdnA ldap_modrdn; - alias ldap_modrdn_sA ldap_modrdn_s; - alias ldap_modrdn2A ldap_modrdn2; - alias ldap_modrdn2_sA ldap_modrdn2_s; + alias ldap_bind = ldap_bindA; + alias ldap_bind_s = ldap_bind_sA; + alias ldap_modrdn = ldap_modrdnA; + alias ldap_modrdn_s = ldap_modrdn_sA; + alias ldap_modrdn2 = ldap_modrdn2A; + alias ldap_modrdn2_s = ldap_modrdn2_sA; } } diff --git a/runtime/druntime/src/core/sys/windows/winnetwk.d b/runtime/druntime/src/core/sys/windows/winnetwk.d index 568c2e89e4..e85df4c9ff 100644 --- a/runtime/druntime/src/core/sys/windows/winnetwk.d +++ b/runtime/druntime/src/core/sys/windows/winnetwk.d @@ -209,7 +209,7 @@ struct NETRESOURCEA { LPSTR lpComment; LPSTR lpProvider; } -alias NETRESOURCEA* LPNETRESOURCEA; +alias LPNETRESOURCEA = NETRESOURCEA*; struct NETRESOURCEW { DWORD dwScope; @@ -221,7 +221,7 @@ struct NETRESOURCEW { LPWSTR lpComment ; LPWSTR lpProvider; } -alias NETRESOURCEW* LPNETRESOURCEW; +alias LPNETRESOURCEW = NETRESOURCEW*; struct CONNECTDLGSTRUCTA { DWORD cbStructure; @@ -230,7 +230,7 @@ struct CONNECTDLGSTRUCTA { DWORD dwFlags; DWORD dwDevNum; } -alias CONNECTDLGSTRUCTA* LPCONNECTDLGSTRUCTA; +alias LPCONNECTDLGSTRUCTA = CONNECTDLGSTRUCTA*; struct CONNECTDLGSTRUCTW { DWORD cbStructure; @@ -239,7 +239,7 @@ struct CONNECTDLGSTRUCTW { DWORD dwFlags; DWORD dwDevNum; } -alias CONNECTDLGSTRUCTW* LPCONNECTDLGSTRUCTW; +alias LPCONNECTDLGSTRUCTW = CONNECTDLGSTRUCTW*; struct DISCDLGSTRUCTA { DWORD cbStructure; @@ -248,7 +248,7 @@ struct DISCDLGSTRUCTA { LPSTR lpRemoteName; DWORD dwFlags; } -alias DISCDLGSTRUCTA* LPDISCDLGSTRUCTA; +alias LPDISCDLGSTRUCTA = DISCDLGSTRUCTA*; struct DISCDLGSTRUCTW { DWORD cbStructure; @@ -257,31 +257,31 @@ struct DISCDLGSTRUCTW { LPWSTR lpRemoteName; DWORD dwFlags; } -alias DISCDLGSTRUCTW* LPDISCDLGSTRUCTW; +alias LPDISCDLGSTRUCTW = DISCDLGSTRUCTW*; struct UNIVERSAL_NAME_INFOA { LPSTR lpUniversalName; } -alias UNIVERSAL_NAME_INFOA* LPUNIVERSAL_NAME_INFOA; +alias LPUNIVERSAL_NAME_INFOA = UNIVERSAL_NAME_INFOA*; struct UNIVERSAL_NAME_INFOW { LPWSTR lpUniversalName; } -alias UNIVERSAL_NAME_INFOW* LPUNIVERSAL_NAME_INFOW; +alias LPUNIVERSAL_NAME_INFOW = UNIVERSAL_NAME_INFOW*; struct REMOTE_NAME_INFOA { LPSTR lpUniversalName; LPSTR lpConnectionName; LPSTR lpRemainingPath; } -alias REMOTE_NAME_INFOA* LPREMOTE_NAME_INFOA; +alias LPREMOTE_NAME_INFOA = REMOTE_NAME_INFOA*; struct REMOTE_NAME_INFOW { LPWSTR lpUniversalName; LPWSTR lpConnectionName; LPWSTR lpRemainingPath; } -alias REMOTE_NAME_INFOW* LPREMOTE_NAME_INFOW; +alias LPREMOTE_NAME_INFOW = REMOTE_NAME_INFOW*; struct NETINFOSTRUCT { DWORD cbStructure; @@ -293,17 +293,15 @@ struct NETINFOSTRUCT { DWORD dwPrinters; DWORD dwDrives; } -alias NETINFOSTRUCT* LPNETINFOSTRUCT; +alias LPNETINFOSTRUCT = NETINFOSTRUCT*; extern (Windows) { - alias UINT function(LPCSTR, LPSTR, UINT) PFNGETPROFILEPATHA; - alias UINT function(LPCWSTR, LPWSTR, UINT) PFNGETPROFILEPATHW; - alias UINT function(LPCSTR, LPCSTR, DWORD) PFNRECONCILEPROFILEA; - alias UINT function(LPCWSTR, LPCWSTR, DWORD) PFNRECONCILEPROFILEW; - alias BOOL function(HWND, LPCSTR, LPCSTR, LPCSTR, DWORD) - PFNPROCESSPOLICIESA; - alias BOOL function(HWND, LPCWSTR, LPCWSTR, LPCWSTR, DWORD) - PFNPROCESSPOLICIESW; + alias PFNGETPROFILEPATHA = UINT function(LPCSTR, LPSTR, UINT); + alias PFNGETPROFILEPATHW = UINT function(LPCWSTR, LPWSTR, UINT); + alias PFNRECONCILEPROFILEA = UINT function(LPCSTR, LPCSTR, DWORD); + alias PFNRECONCILEPROFILEW = UINT function(LPCWSTR, LPCWSTR, DWORD); + alias PFNPROCESSPOLICIESA = BOOL function(HWND, LPCSTR, LPCSTR, LPCSTR, DWORD); + alias PFNPROCESSPOLICIESW = BOOL function(HWND, LPCWSTR, LPCWSTR, LPCWSTR, DWORD); } struct NETCONNECTINFOSTRUCT { @@ -313,7 +311,7 @@ struct NETCONNECTINFOSTRUCT { DWORD dwDelay; DWORD dwOptDataSize; } -alias NETCONNECTINFOSTRUCT* LPNETCONNECTINFOSTRUCT; +alias LPNETCONNECTINFOSTRUCT = NETCONNECTINFOSTRUCT*; extern (Windows) nothrow @nogc { DWORD WNetAddConnection2A(LPNETRESOURCEA, LPCSTR, LPCSTR, DWORD); @@ -370,71 +368,71 @@ extern (Windows) nothrow @nogc { } version (Unicode) { - alias PFNGETPROFILEPATHW PFNGETPROFILEPATH; - alias PFNRECONCILEPROFILEW PFNRECONCILEPROFILE; - alias PFNPROCESSPOLICIESW PFNPROCESSPOLICIES; - alias NETRESOURCEW NETRESOURCE; - alias CONNECTDLGSTRUCTW CONNECTDLGSTRUCT; - alias DISCDLGSTRUCTW DISCDLGSTRUCT; - alias REMOTE_NAME_INFOW REMOTE_NAME_INFO; - alias UNIVERSAL_NAME_INFOW UNIVERSAL_NAME_INFO; - alias WNetAddConnection2W WNetAddConnection2; - alias WNetAddConnection3W WNetAddConnection3; - alias WNetCancelConnection2W WNetCancelConnection2; - alias WNetGetConnectionW WNetGetConnection; - alias WNetUseConnectionW WNetUseConnection; - alias WNetSetConnectionW WNetSetConnection; - alias WNetConnectionDialog1W WNetConnectionDialog1; - alias WNetDisconnectDialog1W WNetDisconnectDialog1; - alias WNetOpenEnumW WNetOpenEnum; - alias WNetEnumResourceW WNetEnumResource; - alias WNetGetUniversalNameW WNetGetUniversalName; - alias WNetGetUserW WNetGetUser; - alias WNetGetProviderNameW WNetGetProviderName; - alias WNetGetNetworkInformationW WNetGetNetworkInformation; - alias WNetGetResourceInformationW WNetGetResourceInformation; - alias WNetGetResourceParentW WNetGetResourceParent; - alias WNetGetLastErrorW WNetGetLastError; - alias MultinetGetConnectionPerformanceW MultinetGetConnectionPerformance; + alias PFNGETPROFILEPATH = PFNGETPROFILEPATHW; + alias PFNRECONCILEPROFILE = PFNRECONCILEPROFILEW; + alias PFNPROCESSPOLICIES = PFNPROCESSPOLICIESW; + alias NETRESOURCE = NETRESOURCEW; + alias CONNECTDLGSTRUCT = CONNECTDLGSTRUCTW; + alias DISCDLGSTRUCT = DISCDLGSTRUCTW; + alias REMOTE_NAME_INFO = REMOTE_NAME_INFOW; + alias UNIVERSAL_NAME_INFO = UNIVERSAL_NAME_INFOW; + alias WNetAddConnection2 = WNetAddConnection2W; + alias WNetAddConnection3 = WNetAddConnection3W; + alias WNetCancelConnection2 = WNetCancelConnection2W; + alias WNetGetConnection = WNetGetConnectionW; + alias WNetUseConnection = WNetUseConnectionW; + alias WNetSetConnection = WNetSetConnectionW; + alias WNetConnectionDialog1 = WNetConnectionDialog1W; + alias WNetDisconnectDialog1 = WNetDisconnectDialog1W; + alias WNetOpenEnum = WNetOpenEnumW; + alias WNetEnumResource = WNetEnumResourceW; + alias WNetGetUniversalName = WNetGetUniversalNameW; + alias WNetGetUser = WNetGetUserW; + alias WNetGetProviderName = WNetGetProviderNameW; + alias WNetGetNetworkInformation = WNetGetNetworkInformationW; + alias WNetGetResourceInformation = WNetGetResourceInformationW; + alias WNetGetResourceParent = WNetGetResourceParentW; + alias WNetGetLastError = WNetGetLastErrorW; + alias MultinetGetConnectionPerformance = MultinetGetConnectionPerformanceW; deprecated { - alias WNetAddConnectionW WNetAddConnection; - alias WNetCancelConnectionW WNetCancelConnection; + alias WNetAddConnection = WNetAddConnectionW; + alias WNetCancelConnection = WNetCancelConnectionW; } } else { - alias PFNGETPROFILEPATHA PFNGETPROFILEPATH; - alias PFNRECONCILEPROFILEA PFNRECONCILEPROFILE; - alias PFNPROCESSPOLICIESA PFNPROCESSPOLICIES; - alias NETRESOURCEA NETRESOURCE; - alias CONNECTDLGSTRUCTA CONNECTDLGSTRUCT; - alias DISCDLGSTRUCTA DISCDLGSTRUCT; - alias REMOTE_NAME_INFOA REMOTE_NAME_INFO; - alias UNIVERSAL_NAME_INFOA UNIVERSAL_NAME_INFO; - alias WNetAddConnection2A WNetAddConnection2; - alias WNetAddConnection3A WNetAddConnection3; - alias WNetCancelConnection2A WNetCancelConnection2; - alias WNetGetConnectionA WNetGetConnection; - alias WNetUseConnectionA WNetUseConnection; - alias WNetSetConnectionA WNetSetConnection; - alias WNetConnectionDialog1A WNetConnectionDialog1; - alias WNetDisconnectDialog1A WNetDisconnectDialog1; - alias WNetOpenEnumA WNetOpenEnum; - alias WNetEnumResourceA WNetEnumResource; - alias WNetGetUniversalNameA WNetGetUniversalName; - alias WNetGetUserA WNetGetUser; - alias WNetGetProviderNameA WNetGetProviderName; - alias WNetGetNetworkInformationA WNetGetNetworkInformation; - alias WNetGetResourceInformationA WNetGetResourceInformation; - alias WNetGetResourceParentA WNetGetResourceParent; - alias WNetGetLastErrorA WNetGetLastError; - alias MultinetGetConnectionPerformanceA MultinetGetConnectionPerformance; + alias PFNGETPROFILEPATH = PFNGETPROFILEPATHA; + alias PFNRECONCILEPROFILE = PFNRECONCILEPROFILEA; + alias PFNPROCESSPOLICIES = PFNPROCESSPOLICIESA; + alias NETRESOURCE = NETRESOURCEA; + alias CONNECTDLGSTRUCT = CONNECTDLGSTRUCTA; + alias DISCDLGSTRUCT = DISCDLGSTRUCTA; + alias REMOTE_NAME_INFO = REMOTE_NAME_INFOA; + alias UNIVERSAL_NAME_INFO = UNIVERSAL_NAME_INFOA; + alias WNetAddConnection2 = WNetAddConnection2A; + alias WNetAddConnection3 = WNetAddConnection3A; + alias WNetCancelConnection2 = WNetCancelConnection2A; + alias WNetGetConnection = WNetGetConnectionA; + alias WNetUseConnection = WNetUseConnectionA; + alias WNetSetConnection = WNetSetConnectionA; + alias WNetConnectionDialog1 = WNetConnectionDialog1A; + alias WNetDisconnectDialog1 = WNetDisconnectDialog1A; + alias WNetOpenEnum = WNetOpenEnumA; + alias WNetEnumResource = WNetEnumResourceA; + alias WNetGetUniversalName = WNetGetUniversalNameA; + alias WNetGetUser = WNetGetUserA; + alias WNetGetProviderName = WNetGetProviderNameA; + alias WNetGetNetworkInformation = WNetGetNetworkInformationA; + alias WNetGetResourceInformation = WNetGetResourceInformationA; + alias WNetGetResourceParent = WNetGetResourceParentA; + alias WNetGetLastError = WNetGetLastErrorA; + alias MultinetGetConnectionPerformance = MultinetGetConnectionPerformanceA; deprecated { - alias WNetAddConnectionA WNetAddConnection; - alias WNetCancelConnectionA WNetCancelConnection; + alias WNetAddConnection = WNetAddConnectionA; + alias WNetCancelConnection = WNetCancelConnectionA; } } -alias NETRESOURCE* LPNETRESOURCE; -alias CONNECTDLGSTRUCT* LPCONNECTDLGSTRUCT; -alias DISCDLGSTRUCT* LPDISCDLGSTRUCT; -alias REMOTE_NAME_INFO* LPREMOTE_NAME_INFO; -alias UNIVERSAL_NAME_INFO* LPUNIVERSAL_NAME_INFO; +alias LPNETRESOURCE = NETRESOURCE*; +alias LPCONNECTDLGSTRUCT = CONNECTDLGSTRUCT*; +alias LPDISCDLGSTRUCT = DISCDLGSTRUCT*; +alias LPREMOTE_NAME_INFO = REMOTE_NAME_INFO*; +alias LPUNIVERSAL_NAME_INFO = UNIVERSAL_NAME_INFO*; diff --git a/runtime/druntime/src/core/sys/windows/winnls.d b/runtime/druntime/src/core/sys/windows/winnls.d index f2b5409102..f55ce4f906 100644 --- a/runtime/druntime/src/core/sys/windows/winnls.d +++ b/runtime/druntime/src/core/sys/windows/winnls.d @@ -15,7 +15,7 @@ pragma(lib, "kernel32"); import core.sys.windows.basetsd, core.sys.windows.w32api, core.sys.windows.winbase, core.sys.windows.windef; -alias DWORD LCTYPE, CALTYPE, CALID, LGRPID, GEOID, GEOTYPE, GEOCLASS; +alias LCTYPE = DWORD, CALTYPE = DWORD, CALID = DWORD, LGRPID = DWORD, GEOID = DWORD, GEOTYPE = DWORD, GEOCLASS = DWORD; enum size_t MAX_DEFAULTCHAR = 2, @@ -496,31 +496,27 @@ enum DWORD WC_NO_BEST_FIT_CHARS = 1024; } // (_WIN32_WINNT >= 0x500) extern (Windows) { - alias BOOL function(LPSTR) CALINFO_ENUMPROCA; - alias BOOL function(LPWSTR) CALINFO_ENUMPROCW; - alias BOOL function(LPSTR, CALID) CALINFO_ENUMPROCEXA; - alias BOOL function(LPWSTR, CALID) CALINFO_ENUMPROCEXW; - alias BOOL function(LGRPID, LPSTR, LPSTR, DWORD, LONG_PTR) - LANGUAGEGROUP_ENUMPROCA; - alias BOOL function(LGRPID, LPWSTR, LPWSTR, DWORD, LONG_PTR) - LANGUAGEGROUP_ENUMPROCW; - alias BOOL function(LGRPID, LCID, LPSTR, LONG_PTR) - LANGGROUPLOCALE_ENUMPROCA; - alias BOOL function(LGRPID, LCID, LPWSTR, LONG_PTR) - LANGGROUPLOCALE_ENUMPROCW; - alias BOOL function(LPWSTR, LONG_PTR) UILANGUAGE_ENUMPROCW; - alias BOOL function(LPSTR, LONG_PTR) UILANGUAGE_ENUMPROCA; - alias BOOL function(LPSTR) LOCALE_ENUMPROCA; - alias BOOL function(LPWSTR) LOCALE_ENUMPROCW; - alias BOOL function(LPSTR) CODEPAGE_ENUMPROCA; - alias BOOL function(LPWSTR) CODEPAGE_ENUMPROCW; - alias BOOL function(LPSTR) DATEFMT_ENUMPROCA; - alias BOOL function(LPWSTR) DATEFMT_ENUMPROCW; - alias BOOL function(LPSTR, CALID) DATEFMT_ENUMPROCEXA; - alias BOOL function(LPWSTR, CALID) DATEFMT_ENUMPROCEXW; - alias BOOL function(LPSTR) TIMEFMT_ENUMPROCA; - alias BOOL function(LPWSTR) TIMEFMT_ENUMPROCW; - alias BOOL function(GEOID) GEO_ENUMPROC; + alias CALINFO_ENUMPROCA = BOOL function(LPSTR); + alias CALINFO_ENUMPROCW = BOOL function(LPWSTR); + alias CALINFO_ENUMPROCEXA = BOOL function(LPSTR, CALID); + alias CALINFO_ENUMPROCEXW = BOOL function(LPWSTR, CALID); + alias LANGUAGEGROUP_ENUMPROCA = BOOL function(LGRPID, LPSTR, LPSTR, DWORD, LONG_PTR); + alias LANGUAGEGROUP_ENUMPROCW = BOOL function(LGRPID, LPWSTR, LPWSTR, DWORD, LONG_PTR); + alias LANGGROUPLOCALE_ENUMPROCA = BOOL function(LGRPID, LCID, LPSTR, LONG_PTR); + alias LANGGROUPLOCALE_ENUMPROCW = BOOL function(LGRPID, LCID, LPWSTR, LONG_PTR); + alias UILANGUAGE_ENUMPROCW = BOOL function(LPWSTR, LONG_PTR); + alias UILANGUAGE_ENUMPROCA = BOOL function(LPSTR, LONG_PTR); + alias LOCALE_ENUMPROCA = BOOL function(LPSTR); + alias LOCALE_ENUMPROCW = BOOL function(LPWSTR); + alias CODEPAGE_ENUMPROCA = BOOL function(LPSTR); + alias CODEPAGE_ENUMPROCW = BOOL function(LPWSTR); + alias DATEFMT_ENUMPROCA = BOOL function(LPSTR); + alias DATEFMT_ENUMPROCW = BOOL function(LPWSTR); + alias DATEFMT_ENUMPROCEXA = BOOL function(LPSTR, CALID); + alias DATEFMT_ENUMPROCEXW = BOOL function(LPWSTR, CALID); + alias TIMEFMT_ENUMPROCA = BOOL function(LPSTR); + alias TIMEFMT_ENUMPROCW = BOOL function(LPWSTR); + alias GEO_ENUMPROC = BOOL function(GEOID); } enum NLS_FUNCTION { @@ -551,7 +547,7 @@ struct CPINFO { BYTE[MAX_DEFAULTCHAR] DefaultChar; BYTE[MAX_LEADBYTES] LeadByte; } -alias CPINFO* LPCPINFO; +alias LPCPINFO = CPINFO*; struct CPINFOEXA { UINT MaxCharSize; @@ -561,7 +557,7 @@ struct CPINFOEXA { UINT CodePage; CHAR[MAX_PATH] CodePageName = 0; } -alias CPINFOEXA* LPCPINFOEXA; +alias LPCPINFOEXA = CPINFOEXA*; struct CPINFOEXW { UINT MaxCharSize; @@ -571,7 +567,7 @@ struct CPINFOEXW { UINT CodePage; WCHAR[MAX_PATH] CodePageName = 0; } -alias CPINFOEXW* LPCPINFOEXW; +alias LPCPINFOEXW = CPINFOEXW*; struct CURRENCYFMTA { UINT NumDigits; @@ -583,7 +579,7 @@ struct CURRENCYFMTA { UINT PositiveOrder; LPSTR lpCurrencySymbol; } -alias CURRENCYFMTA* LPCURRENCYFMTA; +alias LPCURRENCYFMTA = CURRENCYFMTA*; struct CURRENCYFMTW { UINT NumDigits; @@ -595,14 +591,14 @@ struct CURRENCYFMTW { UINT PositiveOrder; LPWSTR lpCurrencySymbol; } -alias CURRENCYFMTW* LPCURRENCYFMTW; +alias LPCURRENCYFMTW = CURRENCYFMTW*; struct NLSVERSIONINFO { DWORD dwNLSVersionInfoSize; DWORD dwNLSVersion; DWORD dwDefinedVersion; } -alias NLSVERSIONINFO* LPNLSVERSIONINFO; +alias LPNLSVERSIONINFO = NLSVERSIONINFO*; struct NUMBERFMTA { UINT NumDigits; @@ -612,7 +608,7 @@ struct NUMBERFMTA { LPSTR lpThousandSep; UINT NegativeOrder; } -alias NUMBERFMTA* LPNUMBERFMTA; +alias LPNUMBERFMTA = NUMBERFMTA*; struct NUMBERFMTW { UINT NumDigits; @@ -622,7 +618,7 @@ struct NUMBERFMTW { LPWSTR lpThousandSep; UINT NegativeOrder; } -alias NUMBERFMTW* LPNUMBERFMTW; +alias LPNUMBERFMTW = NUMBERFMTW*; extern (Windows) nothrow @nogc { int CompareStringA(LCID, DWORD, LPCSTR, int, LPCSTR, int); @@ -716,96 +712,96 @@ extern (Windows) nothrow @nogc { } version (Unicode) { - alias CALINFO_ENUMPROCW CALINFO_ENUMPROC; - alias CALINFO_ENUMPROCEXW CALINFO_ENUMPROCEX; - alias LOCALE_ENUMPROCW LOCALE_ENUMPROC; - alias CODEPAGE_ENUMPROCW CODEPAGE_ENUMPROC; - alias DATEFMT_ENUMPROCW DATEFMT_ENUMPROC; - alias DATEFMT_ENUMPROCEXW DATEFMT_ENUMPROCEX; - alias TIMEFMT_ENUMPROCW TIMEFMT_ENUMPROC; - alias LANGUAGEGROUP_ENUMPROCW LANGUAGEGROUP_ENUMPROC; - alias LANGGROUPLOCALE_ENUMPROCW LANGGROUPLOCALE_ENUMPROC; - alias UILANGUAGE_ENUMPROCW UILANGUAGE_ENUMPROC; - alias CPINFOEXW CPINFOEX; - alias LPCPINFOEXW LPCPINFOEX; - alias CURRENCYFMTW CURRENCYFMT; - alias LPCURRENCYFMTW LPCURRENCYFMT; - alias NUMBERFMTW NUMBERFMT; - alias LPNUMBERFMTW LPNUMBERFMT; - alias CompareStringW CompareString; - alias EnumCalendarInfoW EnumCalendarInfo; - alias EnumSystemCodePagesW EnumSystemCodePages; - alias EnumSystemLocalesW EnumSystemLocales; - alias EnumTimeFormatsW EnumTimeFormats; - alias FoldStringW FoldString; - alias GetCalendarInfoW GetCalendarInfo; - alias GetCPInfoExW GetCPInfoEx; - alias GetCurrencyFormatW GetCurrencyFormat; - alias GetDateFormatW GetDateFormat; - alias GetGeoInfoW GetGeoInfo; - alias GetLocaleInfoW GetLocaleInfo; - alias GetNumberFormatW GetNumberFormat; - alias GetStringTypeExW GetStringTypeEx; - alias GetTimeFormatW GetTimeFormat; - alias LCMapStringW LCMapString; - alias SetCalendarInfoW SetCalendarInfo; - alias SetLocaleInfoW SetLocaleInfo; + alias CALINFO_ENUMPROC = CALINFO_ENUMPROCW; + alias CALINFO_ENUMPROCEX = CALINFO_ENUMPROCEXW; + alias LOCALE_ENUMPROC = LOCALE_ENUMPROCW; + alias CODEPAGE_ENUMPROC = CODEPAGE_ENUMPROCW; + alias DATEFMT_ENUMPROC = DATEFMT_ENUMPROCW; + alias DATEFMT_ENUMPROCEX = DATEFMT_ENUMPROCEXW; + alias TIMEFMT_ENUMPROC = TIMEFMT_ENUMPROCW; + alias LANGUAGEGROUP_ENUMPROC = LANGUAGEGROUP_ENUMPROCW; + alias LANGGROUPLOCALE_ENUMPROC = LANGGROUPLOCALE_ENUMPROCW; + alias UILANGUAGE_ENUMPROC = UILANGUAGE_ENUMPROCW; + alias CPINFOEX = CPINFOEXW; + alias LPCPINFOEX = LPCPINFOEXW; + alias CURRENCYFMT = CURRENCYFMTW; + alias LPCURRENCYFMT = LPCURRENCYFMTW; + alias NUMBERFMT = NUMBERFMTW; + alias LPNUMBERFMT = LPNUMBERFMTW; + alias CompareString = CompareStringW; + alias EnumCalendarInfo = EnumCalendarInfoW; + alias EnumSystemCodePages = EnumSystemCodePagesW; + alias EnumSystemLocales = EnumSystemLocalesW; + alias EnumTimeFormats = EnumTimeFormatsW; + alias FoldString = FoldStringW; + alias GetCalendarInfo = GetCalendarInfoW; + alias GetCPInfoEx = GetCPInfoExW; + alias GetCurrencyFormat = GetCurrencyFormatW; + alias GetDateFormat = GetDateFormatW; + alias GetGeoInfo = GetGeoInfoW; + alias GetLocaleInfo = GetLocaleInfoW; + alias GetNumberFormat = GetNumberFormatW; + alias GetStringTypeEx = GetStringTypeExW; + alias GetTimeFormat = GetTimeFormatW; + alias LCMapString = LCMapStringW; + alias SetCalendarInfo = SetCalendarInfoW; + alias SetLocaleInfo = SetLocaleInfoW; static if (_WIN32_WINNT >= 0x410) { - alias EnumCalendarInfoExW EnumCalendarInfoEx; - alias EnumDateFormatsExW EnumDateFormatsEx; + alias EnumCalendarInfoEx = EnumCalendarInfoExW; + alias EnumDateFormatsEx = EnumDateFormatsExW; } static if (_WIN32_WINNT >= 0x500) { - alias EnumSystemLanguageGroupsW EnumSystemLanguageGroups; - alias EnumLanguageGroupLocalesW EnumLanguageGroupLocales; - alias EnumUILanguagesW EnumUILanguages; + alias EnumSystemLanguageGroups = EnumSystemLanguageGroupsW; + alias EnumLanguageGroupLocales = EnumLanguageGroupLocalesW; + alias EnumUILanguages = EnumUILanguagesW; } } else { - alias CALINFO_ENUMPROCA CALINFO_ENUMPROC; - alias CALINFO_ENUMPROCEXA CALINFO_ENUMPROCEX; - alias LOCALE_ENUMPROCA LOCALE_ENUMPROC; - alias CODEPAGE_ENUMPROCA CODEPAGE_ENUMPROC; - alias DATEFMT_ENUMPROCA DATEFMT_ENUMPROC; - alias DATEFMT_ENUMPROCEXA DATEFMT_ENUMPROCEX; - alias TIMEFMT_ENUMPROCA TIMEFMT_ENUMPROC; - alias LANGUAGEGROUP_ENUMPROCA LANGUAGEGROUP_ENUMPROC; - alias LANGGROUPLOCALE_ENUMPROCA LANGGROUPLOCALE_ENUMPROC; - alias UILANGUAGE_ENUMPROCA UILANGUAGE_ENUMPROC; - alias CPINFOEXA CPINFOEX; - alias LPCPINFOEXA LPCPINFOEX; - alias CURRENCYFMTA CURRENCYFMT; - alias LPCURRENCYFMTA LPCURRENCYFMT; - alias NUMBERFMTA NUMBERFMT; - alias LPNUMBERFMTA LPNUMBERFMT; - alias CompareStringA CompareString; - alias EnumCalendarInfoA EnumCalendarInfo; - alias EnumSystemCodePagesA EnumSystemCodePages; - alias EnumSystemLocalesA EnumSystemLocales; - alias EnumTimeFormatsA EnumTimeFormats; - alias FoldStringA FoldString; - alias GetCalendarInfoA GetCalendarInfo; - alias GetCPInfoExA GetCPInfoEx; - alias GetCurrencyFormatA GetCurrencyFormat; - alias GetDateFormatA GetDateFormat; - alias GetGeoInfoA GetGeoInfo; - alias GetLocaleInfoA GetLocaleInfo; - alias GetNumberFormatA GetNumberFormat; - alias GetStringTypeExA GetStringTypeEx; - alias GetTimeFormatA GetTimeFormat; - alias LCMapStringA LCMapString; - alias SetCalendarInfoA SetCalendarInfo; - alias SetLocaleInfoA SetLocaleInfo; + alias CALINFO_ENUMPROC = CALINFO_ENUMPROCA; + alias CALINFO_ENUMPROCEX = CALINFO_ENUMPROCEXA; + alias LOCALE_ENUMPROC = LOCALE_ENUMPROCA; + alias CODEPAGE_ENUMPROC = CODEPAGE_ENUMPROCA; + alias DATEFMT_ENUMPROC = DATEFMT_ENUMPROCA; + alias DATEFMT_ENUMPROCEX = DATEFMT_ENUMPROCEXA; + alias TIMEFMT_ENUMPROC = TIMEFMT_ENUMPROCA; + alias LANGUAGEGROUP_ENUMPROC = LANGUAGEGROUP_ENUMPROCA; + alias LANGGROUPLOCALE_ENUMPROC = LANGGROUPLOCALE_ENUMPROCA; + alias UILANGUAGE_ENUMPROC = UILANGUAGE_ENUMPROCA; + alias CPINFOEX = CPINFOEXA; + alias LPCPINFOEX = LPCPINFOEXA; + alias CURRENCYFMT = CURRENCYFMTA; + alias LPCURRENCYFMT = LPCURRENCYFMTA; + alias NUMBERFMT = NUMBERFMTA; + alias LPNUMBERFMT = LPNUMBERFMTA; + alias CompareString = CompareStringA; + alias EnumCalendarInfo = EnumCalendarInfoA; + alias EnumSystemCodePages = EnumSystemCodePagesA; + alias EnumSystemLocales = EnumSystemLocalesA; + alias EnumTimeFormats = EnumTimeFormatsA; + alias FoldString = FoldStringA; + alias GetCalendarInfo = GetCalendarInfoA; + alias GetCPInfoEx = GetCPInfoExA; + alias GetCurrencyFormat = GetCurrencyFormatA; + alias GetDateFormat = GetDateFormatA; + alias GetGeoInfo = GetGeoInfoA; + alias GetLocaleInfo = GetLocaleInfoA; + alias GetNumberFormat = GetNumberFormatA; + alias GetStringTypeEx = GetStringTypeExA; + alias GetTimeFormat = GetTimeFormatA; + alias LCMapString = LCMapStringA; + alias SetCalendarInfo = SetCalendarInfoA; + alias SetLocaleInfo = SetLocaleInfoA; static if (_WIN32_WINNT >= 0x410) { - alias EnumCalendarInfoExA EnumCalendarInfoEx; - alias EnumDateFormatsExA EnumDateFormatsEx; + alias EnumCalendarInfoEx = EnumCalendarInfoExA; + alias EnumDateFormatsEx = EnumDateFormatsExA; } static if (_WIN32_WINNT >= 0x500) { - alias EnumSystemLanguageGroupsA EnumSystemLanguageGroups; - alias EnumLanguageGroupLocalesA EnumLanguageGroupLocales; - alias EnumUILanguagesA EnumUILanguages; + alias EnumSystemLanguageGroups = EnumSystemLanguageGroupsA; + alias EnumLanguageGroupLocales = EnumLanguageGroupLocalesA; + alias EnumUILanguages = EnumUILanguagesA; } } diff --git a/runtime/druntime/src/core/sys/windows/winnt.d b/runtime/druntime/src/core/sys/windows/winnt.d index 097a2b6fd4..c3189f1dac 100644 --- a/runtime/druntime/src/core/sys/windows/winnt.d +++ b/runtime/druntime/src/core/sys/windows/winnt.d @@ -19,48 +19,48 @@ The following macros are unneeded for D: FIELD_OFFSET(t,f), CONTAINING_RECORD(address, type, field) */ -alias void VOID; -alias char CHAR, CCHAR; -alias wchar WCHAR; -alias bool BOOLEAN; -alias byte FCHAR; -alias ubyte UCHAR; -alias short SHORT; -alias ushort LANGID, FSHORT; -alias uint LCID, FLONG, ACCESS_MASK; -alias long LONGLONG, USN; -alias ulong DWORDLONG, ULONGLONG; - -alias void* PVOID, LPVOID; -alias char* PSZ, PCHAR, PCCHAR, LPCH, PCH, LPSTR, PSTR; -alias wchar* PWCHAR, LPWCH, PWCH, LPWSTR, PWSTR; -alias bool* PBOOLEAN; -alias ubyte* PUCHAR; -alias short* PSHORT; -alias int* PLONG; -alias uint* PLCID, PACCESS_MASK; -alias long* PLONGLONG; -alias ulong* PDWORDLONG, PULONGLONG; +alias VOID = void; +alias CHAR = char, CCHAR = char; +alias WCHAR = wchar; +alias BOOLEAN = bool; +alias FCHAR = byte; +alias UCHAR = ubyte; +alias SHORT = short; +alias LANGID = ushort, FSHORT = ushort; +alias LCID = uint, FLONG = uint, ACCESS_MASK = uint; +alias LONGLONG = long, USN = long; +alias DWORDLONG = ulong, ULONGLONG = ulong; + +alias PVOID = void*, LPVOID = void*; +alias PSZ = char*, PCHAR = char*, PCCHAR = char*, LPCH = char*, PCH = char*, LPSTR = char*, PSTR = char*; +alias PWCHAR = wchar*, LPWCH = wchar*, PWCH = wchar*, LPWSTR = wchar*, PWSTR = wchar*; +alias PBOOLEAN = bool*; +alias PUCHAR = ubyte*; +alias PSHORT = short*; +alias PLONG = int*; +alias PLCID = uint*, PACCESS_MASK = uint*; +alias PLONGLONG = long*; +alias PDWORDLONG = ulong*, PULONGLONG = ulong*; // FIXME(MinGW) for __WIN64 -alias void* PVOID64; +alias PVOID64 = void*; // const versions -alias const(char)* PCCH, LPCCH, PCSTR, LPCSTR; -alias const(wchar)* LPCWCH, PCWCH, LPCWSTR, PCWSTR; +alias PCCH = const(char)*, LPCCH = const(char)*, PCSTR = const(char)*, LPCSTR = const(char)*; +alias LPCWCH = const(wchar)*, PCWCH = const(wchar)*, LPCWSTR = const(wchar)*, PCWSTR = const(wchar)*; -alias PSTR* PZPSTR; -alias PWSTR* PZPWSTR; +alias PZPSTR = PSTR*; +alias PZPWSTR = PWSTR*; version (Unicode) { - alias WCHAR TCHAR, _TCHAR; + alias TCHAR = WCHAR, _TCHAR = WCHAR; } else { - alias CHAR TCHAR, _TCHAR; + alias TCHAR = CHAR, _TCHAR = CHAR; } -alias TCHAR TBYTE; -alias TCHAR* PTCH , PTBYTE, LPTCH , PTSTR , LPTSTR , LP, PTCHAR; -alias const(TCHAR)* PCTCH, LPCTCH, PCTSTR, LPCTSTR ; +alias TBYTE = TCHAR; +alias PTCH = TCHAR*, PTBYTE = TCHAR*, LPTCH = TCHAR*, PTSTR = TCHAR*, LPTSTR = TCHAR*, LP = TCHAR*, PTCHAR = TCHAR*; +alias PCTCH = const(TCHAR)*, LPCTCH = const(TCHAR)*, PCTSTR = const(TCHAR)*, LPCTSTR = const(TCHAR)*; enum char ANSI_NULL = '\0'; enum wchar UNICODE_NULL = '\0'; @@ -1669,10 +1669,10 @@ enum SECURITY_IMPERSONATION_LEVEL { SecurityImpersonation, SecurityDelegation } -alias SECURITY_IMPERSONATION_LEVEL* PSECURITY_IMPERSONATION_LEVEL; +alias PSECURITY_IMPERSONATION_LEVEL = SECURITY_IMPERSONATION_LEVEL*; -alias BOOLEAN SECURITY_CONTEXT_TRACKING_MODE; -alias BOOLEAN* PSECURITY_CONTEXT_TRACKING_MODE; +alias SECURITY_CONTEXT_TRACKING_MODE = BOOLEAN; +alias PSECURITY_CONTEXT_TRACKING_MODE = BOOLEAN*; enum size_t SECURITY_DESCRIPTOR_MIN_LENGTH = 20; @@ -1978,42 +1978,42 @@ struct GENERIC_MAPPING { ACCESS_MASK GenericExecute; ACCESS_MASK GenericAll; } -alias GENERIC_MAPPING* PGENERIC_MAPPING; +alias PGENERIC_MAPPING = GENERIC_MAPPING*; struct ACE_HEADER { BYTE AceType; BYTE AceFlags; WORD AceSize; } -alias ACE_HEADER* PACE_HEADER; +alias PACE_HEADER = ACE_HEADER*; struct ACCESS_ALLOWED_ACE { ACE_HEADER Header; ACCESS_MASK Mask; DWORD SidStart; } -alias ACCESS_ALLOWED_ACE* PACCESS_ALLOWED_ACE; +alias PACCESS_ALLOWED_ACE = ACCESS_ALLOWED_ACE*; struct ACCESS_DENIED_ACE { ACE_HEADER Header; ACCESS_MASK Mask; DWORD SidStart; } -alias ACCESS_DENIED_ACE* PACCESS_DENIED_ACE; +alias PACCESS_DENIED_ACE = ACCESS_DENIED_ACE*; struct SYSTEM_AUDIT_ACE { ACE_HEADER Header; ACCESS_MASK Mask; DWORD SidStart; } -alias SYSTEM_AUDIT_ACE *PSYSTEM_AUDIT_ACE; +alias PSYSTEM_AUDIT_ACE = SYSTEM_AUDIT_ACE *; struct SYSTEM_ALARM_ACE { ACE_HEADER Header; ACCESS_MASK Mask; DWORD SidStart; } -alias SYSTEM_ALARM_ACE* PSYSTEM_ALARM_ACE; +alias PSYSTEM_ALARM_ACE = SYSTEM_ALARM_ACE*; struct ACCESS_ALLOWED_OBJECT_ACE { ACE_HEADER Header; @@ -2023,7 +2023,7 @@ struct ACCESS_ALLOWED_OBJECT_ACE { GUID InheritedObjectType; DWORD SidStart; } -alias ACCESS_ALLOWED_OBJECT_ACE* PACCESS_ALLOWED_OBJECT_ACE; +alias PACCESS_ALLOWED_OBJECT_ACE = ACCESS_ALLOWED_OBJECT_ACE*; struct ACCESS_DENIED_OBJECT_ACE { ACE_HEADER Header; @@ -2033,7 +2033,7 @@ struct ACCESS_DENIED_OBJECT_ACE { GUID InheritedObjectType; DWORD SidStart; } -alias ACCESS_DENIED_OBJECT_ACE* PACCESS_DENIED_OBJECT_ACE; +alias PACCESS_DENIED_OBJECT_ACE = ACCESS_DENIED_OBJECT_ACE*; struct SYSTEM_AUDIT_OBJECT_ACE { ACE_HEADER Header; @@ -2043,7 +2043,7 @@ struct SYSTEM_AUDIT_OBJECT_ACE { GUID InheritedObjectType; DWORD SidStart; } -alias SYSTEM_AUDIT_OBJECT_ACE* PSYSTEM_AUDIT_OBJECT_ACE; +alias PSYSTEM_AUDIT_OBJECT_ACE = SYSTEM_AUDIT_OBJECT_ACE*; struct SYSTEM_ALARM_OBJECT_ACE { ACE_HEADER Header; @@ -2053,7 +2053,7 @@ struct SYSTEM_ALARM_OBJECT_ACE { GUID InheritedObjectType; DWORD SidStart; } -alias SYSTEM_ALARM_OBJECT_ACE* PSYSTEM_ALARM_OBJECT_ACE; +alias PSYSTEM_ALARM_OBJECT_ACE = SYSTEM_ALARM_OBJECT_ACE*; struct ACL { BYTE AclRevision; @@ -2062,7 +2062,7 @@ struct ACL { WORD AceCount; WORD Sbz2; } -alias ACL* PACL; +alias PACL = ACL*; struct ACL_REVISION_INFORMATION { DWORD AclRevision; @@ -2158,7 +2158,7 @@ enum INITIAL_FPCSR = 0x027f; ULONGLONG Low; LONGLONG High; } - alias M128A* PM128A; + alias PM128A = M128A*; struct XMM_SAVE_AREA32 { @@ -2179,7 +2179,7 @@ enum INITIAL_FPCSR = 0x027f; M128A[16] XmmRegisters; BYTE[96] Reserved4; } - alias XMM_SAVE_AREA32 PXMM_SAVE_AREA32; + alias PXMM_SAVE_AREA32 = XMM_SAVE_AREA32; enum LEGACY_SAVE_AREA_LENGTH = XMM_SAVE_AREA32.sizeof; align(16) struct CONTEXT @@ -2262,7 +2262,7 @@ enum LEGACY_SAVE_AREA_LENGTH = XMM_SAVE_AREA32.sizeof; // Versions for PowerPC, Alpha, SHX, and MIPS removed. } -alias CONTEXT* PCONTEXT, LPCONTEXT; +alias PCONTEXT = CONTEXT*, LPCONTEXT = CONTEXT*; struct EXCEPTION_RECORD { DWORD ExceptionCode; @@ -2272,13 +2272,13 @@ struct EXCEPTION_RECORD { DWORD NumberParameters; ULONG_PTR[EXCEPTION_MAXIMUM_PARAMETERS] ExceptionInformation; } -alias EXCEPTION_RECORD* PEXCEPTION_RECORD, LPEXCEPTION_RECORD; +alias PEXCEPTION_RECORD = EXCEPTION_RECORD*, LPEXCEPTION_RECORD = EXCEPTION_RECORD*; struct EXCEPTION_POINTERS { PEXCEPTION_RECORD ExceptionRecord; PCONTEXT ContextRecord; } -alias EXCEPTION_POINTERS* PEXCEPTION_POINTERS, LPEXCEPTION_POINTERS; +alias PEXCEPTION_POINTERS = EXCEPTION_POINTERS*, LPEXCEPTION_POINTERS = EXCEPTION_POINTERS*; union LARGE_INTEGER { struct { @@ -2287,7 +2287,7 @@ union LARGE_INTEGER { } long QuadPart; } -alias LARGE_INTEGER* PLARGE_INTEGER; +alias PLARGE_INTEGER = LARGE_INTEGER*; union ULARGE_INTEGER { struct { @@ -2296,10 +2296,10 @@ union ULARGE_INTEGER { } ulong QuadPart; } -alias ULARGE_INTEGER* PULARGE_INTEGER; +alias PULARGE_INTEGER = ULARGE_INTEGER*; -alias LARGE_INTEGER LUID; -alias LUID* PLUID; +alias LUID = LARGE_INTEGER; +alias PLUID = LUID*; enum LUID SYSTEM_LUID = { QuadPart:999 }; @@ -2307,7 +2307,7 @@ align(4) struct LUID_AND_ATTRIBUTES { LUID Luid; DWORD Attributes; } -alias LUID_AND_ATTRIBUTES* PLUID_AND_ATTRIBUTES; +alias PLUID_AND_ATTRIBUTES = LUID_AND_ATTRIBUTES*; align(4) struct PRIVILEGE_SET { DWORD PrivilegeCount; @@ -2316,14 +2316,14 @@ align(4) struct PRIVILEGE_SET { LUID_AND_ATTRIBUTES* Privilege() return { return &_Privilege; } } -alias PRIVILEGE_SET* PPRIVILEGE_SET; +alias PPRIVILEGE_SET = PRIVILEGE_SET*; struct SECURITY_ATTRIBUTES { DWORD nLength; LPVOID lpSecurityDescriptor; BOOL bInheritHandle; } -alias SECURITY_ATTRIBUTES* PSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES; +alias PSECURITY_ATTRIBUTES = SECURITY_ATTRIBUTES*, LPSECURITY_ATTRIBUTES = SECURITY_ATTRIBUTES*; struct SECURITY_QUALITY_OF_SERVICE { DWORD Length; @@ -2331,9 +2331,9 @@ struct SECURITY_QUALITY_OF_SERVICE { SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; BOOLEAN EffectiveOnly; } -alias SECURITY_QUALITY_OF_SERVICE* PSECURITY_QUALITY_OF_SERVICE; +alias PSECURITY_QUALITY_OF_SERVICE = SECURITY_QUALITY_OF_SERVICE*; -alias PVOID PACCESS_TOKEN; +alias PACCESS_TOKEN = PVOID; struct SE_IMPERSONATION_STATE { PACCESS_TOKEN Token; @@ -2341,14 +2341,14 @@ struct SE_IMPERSONATION_STATE { BOOLEAN EffectiveOnly; SECURITY_IMPERSONATION_LEVEL Level; } -alias SE_IMPERSONATION_STATE* PSE_IMPERSONATION_STATE; +alias PSE_IMPERSONATION_STATE = SE_IMPERSONATION_STATE*; struct SID_IDENTIFIER_AUTHORITY { BYTE[6] Value; } -alias SID_IDENTIFIER_AUTHORITY* PSID_IDENTIFIER_AUTHORITY, LPSID_IDENTIFIER_AUTHORITY; +alias PSID_IDENTIFIER_AUTHORITY = SID_IDENTIFIER_AUTHORITY*, LPSID_IDENTIFIER_AUTHORITY = SID_IDENTIFIER_AUTHORITY*; -alias PVOID PSID; +alias PSID = PVOID; struct SID { BYTE Revision; @@ -2358,19 +2358,19 @@ struct SID { DWORD* SubAuthority() return { return &_SubAuthority; } } -alias SID* PISID; +alias PISID = SID*; struct SID_AND_ATTRIBUTES { PSID Sid; DWORD Attributes; } -alias SID_AND_ATTRIBUTES* PSID_AND_ATTRIBUTES; +alias PSID_AND_ATTRIBUTES = SID_AND_ATTRIBUTES*; struct TOKEN_SOURCE { CHAR[TOKEN_SOURCE_LENGTH] SourceName = 0; LUID SourceIdentifier; } -alias TOKEN_SOURCE* PTOKEN_SOURCE; +alias PTOKEN_SOURCE = TOKEN_SOURCE*; struct TOKEN_CONTROL { LUID TokenId; @@ -2378,12 +2378,12 @@ struct TOKEN_CONTROL { LUID ModifiedId; TOKEN_SOURCE TokenSource; } -alias TOKEN_CONTROL* PTOKEN_CONTROL; +alias PTOKEN_CONTROL = TOKEN_CONTROL*; struct TOKEN_DEFAULT_DACL { PACL DefaultDacl; } -alias TOKEN_DEFAULT_DACL* PTOKEN_DEFAULT_DACL; +alias PTOKEN_DEFAULT_DACL = TOKEN_DEFAULT_DACL*; struct TOKEN_GROUPS { DWORD GroupCount; @@ -2391,18 +2391,18 @@ struct TOKEN_GROUPS { SID_AND_ATTRIBUTES* Groups() return { return &_Groups; } } -alias TOKEN_GROUPS* PTOKEN_GROUPS, LPTOKEN_GROUPS; +alias PTOKEN_GROUPS = TOKEN_GROUPS*, LPTOKEN_GROUPS = TOKEN_GROUPS*; struct TOKEN_OWNER { PSID Owner; } -alias TOKEN_OWNER* PTOKEN_OWNER; +alias PTOKEN_OWNER = TOKEN_OWNER*; enum SECURITY_MAX_SID_SIZE = 68; struct TOKEN_PRIMARY_GROUP { PSID PrimaryGroup; } -alias TOKEN_PRIMARY_GROUP* PTOKEN_PRIMARY_GROUP; +alias PTOKEN_PRIMARY_GROUP = TOKEN_PRIMARY_GROUP*; struct TOKEN_PRIVILEGES { DWORD PrivilegeCount; @@ -2410,13 +2410,13 @@ struct TOKEN_PRIVILEGES { LUID_AND_ATTRIBUTES* Privileges() return { return &_Privileges; } } -alias TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES, LPTOKEN_PRIVILEGES; +alias PTOKEN_PRIVILEGES = TOKEN_PRIVILEGES*, LPTOKEN_PRIVILEGES = TOKEN_PRIVILEGES*; enum TOKEN_TYPE { TokenPrimary = 1, TokenImpersonation } -alias TOKEN_TYPE* PTOKEN_TYPE; +alias PTOKEN_TYPE = TOKEN_TYPE*; struct TOKEN_STATISTICS { LUID TokenId; @@ -2430,21 +2430,21 @@ struct TOKEN_STATISTICS { DWORD PrivilegeCount; LUID ModifiedId; } -alias TOKEN_STATISTICS* PTOKEN_STATISTICS; +alias PTOKEN_STATISTICS = TOKEN_STATISTICS*; struct TOKEN_USER { SID_AND_ATTRIBUTES User; } -alias TOKEN_USER* PTOKEN_USER; +alias PTOKEN_USER = TOKEN_USER*; struct TOKEN_MANDATORY_LABEL { SID_AND_ATTRIBUTES Label; } alias PTOKEN_MANDATORY_LABEL = TOKEN_MANDATORY_LABEL*; -alias DWORD SECURITY_INFORMATION; -alias SECURITY_INFORMATION* PSECURITY_INFORMATION; -alias WORD SECURITY_DESCRIPTOR_CONTROL; -alias SECURITY_DESCRIPTOR_CONTROL* PSECURITY_DESCRIPTOR_CONTROL; +alias SECURITY_INFORMATION = DWORD; +alias PSECURITY_INFORMATION = SECURITY_INFORMATION*; +alias SECURITY_DESCRIPTOR_CONTROL = WORD; +alias PSECURITY_DESCRIPTOR_CONTROL = SECURITY_DESCRIPTOR_CONTROL*; struct SECURITY_DESCRIPTOR { BYTE Revision; @@ -2455,7 +2455,7 @@ struct SECURITY_DESCRIPTOR { PACL Sacl; PACL Dacl; } -alias SECURITY_DESCRIPTOR* PSECURITY_DESCRIPTOR, PISECURITY_DESCRIPTOR; +alias PSECURITY_DESCRIPTOR = SECURITY_DESCRIPTOR*, PISECURITY_DESCRIPTOR = SECURITY_DESCRIPTOR*; enum TOKEN_ELEVATION_TYPE { TokenElevationTypeDefault = 1, TokenElevationTypeFull, @@ -2525,7 +2525,7 @@ enum SID_NAME_USE { SidTypeUnknown, SidTypeComputer } -alias SID_NAME_USE* PSID_NAME_USE; +alias PSID_NAME_USE = SID_NAME_USE*; enum WELL_KNOWN_SID_TYPE { WinNullSid = 0, @@ -2632,7 +2632,7 @@ struct QUOTA_LIMITS { SIZE_T PagefileLimit; LARGE_INTEGER TimeLimit; } -alias QUOTA_LIMITS* PQUOTA_LIMITS; +alias PQUOTA_LIMITS = QUOTA_LIMITS*; struct IO_COUNTERS { ULONGLONG ReadOperationCount; @@ -2642,7 +2642,7 @@ struct IO_COUNTERS { ULONGLONG WriteTransferCount; ULONGLONG OtherTransferCount; } -alias IO_COUNTERS* PIO_COUNTERS; +alias PIO_COUNTERS = IO_COUNTERS*; struct FILE_NOTIFY_INFORMATION { DWORD NextEntryOffset; @@ -2652,13 +2652,13 @@ struct FILE_NOTIFY_INFORMATION { WCHAR* FileName() return { return &_FileName; } } -alias FILE_NOTIFY_INFORMATION* PFILE_NOTIFY_INFORMATION; +alias PFILE_NOTIFY_INFORMATION = FILE_NOTIFY_INFORMATION*; struct TAPE_ERASE { DWORD Type; BOOLEAN Immediate; } -alias TAPE_ERASE* PTAPE_ERASE; +alias PTAPE_ERASE = TAPE_ERASE*; struct TAPE_GET_DRIVE_PARAMETERS { BOOLEAN ECC; @@ -2673,7 +2673,7 @@ struct TAPE_GET_DRIVE_PARAMETERS { DWORD FeaturesHigh; DWORD EOTWarningZoneSize; } -alias TAPE_GET_DRIVE_PARAMETERS* PTAPE_GET_DRIVE_PARAMETERS; +alias PTAPE_GET_DRIVE_PARAMETERS = TAPE_GET_DRIVE_PARAMETERS*; struct TAPE_GET_MEDIA_PARAMETERS { LARGE_INTEGER Capacity; @@ -2682,7 +2682,7 @@ struct TAPE_GET_MEDIA_PARAMETERS { DWORD PartitionCount; BOOLEAN WriteProtected; } -alias TAPE_GET_MEDIA_PARAMETERS* PTAPE_GET_MEDIA_PARAMETERS; +alias PTAPE_GET_MEDIA_PARAMETERS = TAPE_GET_MEDIA_PARAMETERS*; struct TAPE_GET_POSITION { ULONG Type; @@ -2690,13 +2690,13 @@ struct TAPE_GET_POSITION { ULONG OffsetLow; ULONG OffsetHigh; } -alias TAPE_GET_POSITION* PTAPE_GET_POSITION; +alias PTAPE_GET_POSITION = TAPE_GET_POSITION*; struct TAPE_PREPARE { DWORD Operation; BOOLEAN Immediate; } -alias TAPE_PREPARE* PTAPE_PREPARE; +alias PTAPE_PREPARE = TAPE_PREPARE*; struct TAPE_SET_DRIVE_PARAMETERS { BOOLEAN ECC; @@ -2705,12 +2705,12 @@ struct TAPE_SET_DRIVE_PARAMETERS { BOOLEAN ReportSetmarks; ULONG EOTWarningZoneSize; } -alias TAPE_SET_DRIVE_PARAMETERS* PTAPE_SET_DRIVE_PARAMETERS; +alias PTAPE_SET_DRIVE_PARAMETERS = TAPE_SET_DRIVE_PARAMETERS*; struct TAPE_SET_MEDIA_PARAMETERS { ULONG BlockSize; } -alias TAPE_SET_MEDIA_PARAMETERS* PTAPE_SET_MEDIA_PARAMETERS; +alias PTAPE_SET_MEDIA_PARAMETERS = TAPE_SET_MEDIA_PARAMETERS*; struct TAPE_SET_POSITION { DWORD Method; @@ -2718,21 +2718,21 @@ struct TAPE_SET_POSITION { LARGE_INTEGER Offset; BOOLEAN Immediate; } -alias TAPE_SET_POSITION* PTAPE_SET_POSITION; +alias PTAPE_SET_POSITION = TAPE_SET_POSITION*; struct TAPE_WRITE_MARKS { DWORD Type; DWORD Count; BOOLEAN Immediate; } -alias TAPE_WRITE_MARKS* PTAPE_WRITE_MARKS; +alias PTAPE_WRITE_MARKS = TAPE_WRITE_MARKS*; struct TAPE_CREATE_PARTITION { DWORD Method; DWORD Count; DWORD Size; } -alias TAPE_CREATE_PARTITION* PTAPE_CREATE_PARTITION; +alias PTAPE_CREATE_PARTITION = TAPE_CREATE_PARTITION*; struct MEMORY_BASIC_INFORMATION { PVOID BaseAddress; @@ -2743,7 +2743,7 @@ struct MEMORY_BASIC_INFORMATION { DWORD Protect; DWORD Type; } -alias MEMORY_BASIC_INFORMATION* PMEMORY_BASIC_INFORMATION; +alias PMEMORY_BASIC_INFORMATION = MEMORY_BASIC_INFORMATION*; struct MESSAGE_RESOURCE_ENTRY { WORD Length; @@ -2752,14 +2752,14 @@ struct MESSAGE_RESOURCE_ENTRY { BYTE* Text() return { return &_Text; } } -alias MESSAGE_RESOURCE_ENTRY* PMESSAGE_RESOURCE_ENTRY; +alias PMESSAGE_RESOURCE_ENTRY = MESSAGE_RESOURCE_ENTRY*; struct MESSAGE_RESOURCE_BLOCK { DWORD LowId; DWORD HighId; DWORD OffsetToEntries; } -alias MESSAGE_RESOURCE_BLOCK* PMESSAGE_RESOURCE_BLOCK; +alias PMESSAGE_RESOURCE_BLOCK = MESSAGE_RESOURCE_BLOCK*; struct MESSAGE_RESOURCE_DATA { DWORD NumberOfBlocks; @@ -2767,14 +2767,14 @@ struct MESSAGE_RESOURCE_DATA { MESSAGE_RESOURCE_BLOCK* Blocks() return { return &_Blocks; } } -alias MESSAGE_RESOURCE_DATA* PMESSAGE_RESOURCE_DATA; +alias PMESSAGE_RESOURCE_DATA = MESSAGE_RESOURCE_DATA*; struct LIST_ENTRY { LIST_ENTRY* Flink; LIST_ENTRY* Blink; } -alias LIST_ENTRY* PLIST_ENTRY; -alias LIST_ENTRY _LIST_ENTRY; +alias PLIST_ENTRY = LIST_ENTRY*; +alias _LIST_ENTRY = LIST_ENTRY; struct SINGLE_LIST_ENTRY { SINGLE_LIST_ENTRY* Next; @@ -2786,9 +2786,9 @@ version (Win64) { SLIST_ENTRY* Next; } } else { - alias SINGLE_LIST_ENTRY SLIST_ENTRY; + alias SLIST_ENTRY = SINGLE_LIST_ENTRY; } -alias SINGLE_LIST_ENTRY* PSINGLE_LIST_ENTRY, PSLIST_ENTRY; +alias PSINGLE_LIST_ENTRY = SINGLE_LIST_ENTRY*, PSLIST_ENTRY = SINGLE_LIST_ENTRY*; union SLIST_HEADER { ULONGLONG Alignment; @@ -2798,7 +2798,7 @@ union SLIST_HEADER { WORD Sequence; } } -alias SLIST_HEADER* PSLIST_HEADER; +alias PSLIST_HEADER = SLIST_HEADER*; struct RTL_CRITICAL_SECTION_DEBUG { WORD Type; @@ -2809,8 +2809,8 @@ struct RTL_CRITICAL_SECTION_DEBUG { DWORD ContentionCount; DWORD[2] Spare; } -alias RTL_CRITICAL_SECTION_DEBUG* PRTL_CRITICAL_SECTION_DEBUG; -alias RTL_CRITICAL_SECTION_DEBUG _RTL_CRITICAL_SECTION_DEBUG; +alias PRTL_CRITICAL_SECTION_DEBUG = RTL_CRITICAL_SECTION_DEBUG*; +alias _RTL_CRITICAL_SECTION_DEBUG = RTL_CRITICAL_SECTION_DEBUG; struct RTL_CRITICAL_SECTION { PRTL_CRITICAL_SECTION_DEBUG DebugInfo; @@ -2821,8 +2821,8 @@ struct RTL_CRITICAL_SECTION { ULONG_PTR SpinCount; alias Reserved = SpinCount; } -alias RTL_CRITICAL_SECTION* PRTL_CRITICAL_SECTION; -alias RTL_CRITICAL_SECTION _RTL_CRITICAL_SECTION; +alias PRTL_CRITICAL_SECTION = RTL_CRITICAL_SECTION*; +alias _RTL_CRITICAL_SECTION = RTL_CRITICAL_SECTION; struct EVENTLOGRECORD { DWORD Length; @@ -2842,7 +2842,7 @@ struct EVENTLOGRECORD { DWORD DataLength; DWORD DataOffset; } -alias EVENTLOGRECORD* PEVENTLOGRECORD; +alias PEVENTLOGRECORD = EVENTLOGRECORD*; struct OSVERSIONINFOA { DWORD dwOSVersionInfoSize = OSVERSIONINFOA.sizeof; @@ -2852,7 +2852,7 @@ struct OSVERSIONINFOA { DWORD dwPlatformId; CHAR[128] szCSDVersion = 0; } -alias OSVERSIONINFOA* POSVERSIONINFOA, LPOSVERSIONINFOA; +alias POSVERSIONINFOA = OSVERSIONINFOA*, LPOSVERSIONINFOA = OSVERSIONINFOA*; struct OSVERSIONINFOW { DWORD dwOSVersionInfoSize = OSVERSIONINFOW.sizeof; @@ -2862,7 +2862,7 @@ struct OSVERSIONINFOW { DWORD dwPlatformId; WCHAR[128] szCSDVersion = 0; } -alias OSVERSIONINFOW* POSVERSIONINFOW, LPOSVERSIONINFOW; +alias POSVERSIONINFOW = OSVERSIONINFOW*, LPOSVERSIONINFOW = OSVERSIONINFOW*; struct OSVERSIONINFOEXA { DWORD dwOSVersionInfoSize; @@ -2877,7 +2877,7 @@ struct OSVERSIONINFOEXA { BYTE wProductType; BYTE wReserved; } -alias OSVERSIONINFOEXA* POSVERSIONINFOEXA, LPOSVERSIONINFOEXA; +alias POSVERSIONINFOEXA = OSVERSIONINFOEXA*, LPOSVERSIONINFOEXA = OSVERSIONINFOEXA*; struct OSVERSIONINFOEXW { DWORD dwOSVersionInfoSize; @@ -2892,7 +2892,7 @@ struct OSVERSIONINFOEXW { BYTE wProductType; BYTE wReserved; } -alias OSVERSIONINFOEXW* POSVERSIONINFOEXW, LPOSVERSIONINFOEXW; +alias POSVERSIONINFOEXW = OSVERSIONINFOEXW*, LPOSVERSIONINFOEXW = OSVERSIONINFOEXW*; align(2) struct IMAGE_VXD_HEADER { WORD e32_magic; @@ -2947,7 +2947,7 @@ align(2) struct IMAGE_VXD_HEADER { WORD e32_devid; WORD e32_ddkver; } -alias IMAGE_VXD_HEADER* PIMAGE_VXD_HEADER; +alias PIMAGE_VXD_HEADER = IMAGE_VXD_HEADER*; align(4): struct IMAGE_FILE_HEADER { @@ -2959,14 +2959,14 @@ struct IMAGE_FILE_HEADER { WORD SizeOfOptionalHeader; WORD Characteristics; } -alias IMAGE_FILE_HEADER* PIMAGE_FILE_HEADER; +alias PIMAGE_FILE_HEADER = IMAGE_FILE_HEADER*; // const IMAGE_SIZEOF_FILE_HEADER = IMAGE_FILE_HEADER.sizeof; struct IMAGE_DATA_DIRECTORY { DWORD VirtualAddress; DWORD Size; } -alias IMAGE_DATA_DIRECTORY* PIMAGE_DATA_DIRECTORY; +alias PIMAGE_DATA_DIRECTORY = IMAGE_DATA_DIRECTORY*; struct IMAGE_OPTIONAL_HEADER32 { WORD Magic; @@ -3001,7 +3001,7 @@ struct IMAGE_OPTIONAL_HEADER32 { DWORD NumberOfRvaAndSizes; IMAGE_DATA_DIRECTORY[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] DataDirectory; } -alias IMAGE_OPTIONAL_HEADER32* PIMAGE_OPTIONAL_HEADER32; +alias PIMAGE_OPTIONAL_HEADER32 = IMAGE_OPTIONAL_HEADER32*; struct IMAGE_OPTIONAL_HEADER64 { WORD Magic; @@ -3035,7 +3035,7 @@ struct IMAGE_OPTIONAL_HEADER64 { DWORD NumberOfRvaAndSizes; IMAGE_DATA_DIRECTORY[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] DataDirectory; } -alias IMAGE_OPTIONAL_HEADER64* PIMAGE_OPTIONAL_HEADER64; +alias PIMAGE_OPTIONAL_HEADER64 = IMAGE_OPTIONAL_HEADER64*; struct IMAGE_ROM_OPTIONAL_HEADER { WORD Magic; @@ -3052,7 +3052,7 @@ struct IMAGE_ROM_OPTIONAL_HEADER { DWORD[4] CprMask; DWORD GpValue; } -alias IMAGE_ROM_OPTIONAL_HEADER* PIMAGE_ROM_OPTIONAL_HEADER; +alias PIMAGE_ROM_OPTIONAL_HEADER = IMAGE_ROM_OPTIONAL_HEADER*; align(2): struct IMAGE_DOS_HEADER { @@ -3076,7 +3076,7 @@ struct IMAGE_DOS_HEADER { WORD[10] e_res2; LONG e_lfanew; } -alias IMAGE_DOS_HEADER* PIMAGE_DOS_HEADER; +alias PIMAGE_DOS_HEADER = IMAGE_DOS_HEADER*; struct IMAGE_OS2_HEADER { WORD ne_magic; @@ -3110,27 +3110,27 @@ struct IMAGE_OS2_HEADER { WORD ne_swaparea; WORD ne_expver; } -alias IMAGE_OS2_HEADER* PIMAGE_OS2_HEADER; +alias PIMAGE_OS2_HEADER = IMAGE_OS2_HEADER*; align(4) struct IMAGE_NT_HEADERS32 { DWORD Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER32 OptionalHeader; } -alias IMAGE_NT_HEADERS32* PIMAGE_NT_HEADERS32; +alias PIMAGE_NT_HEADERS32 = IMAGE_NT_HEADERS32*; align(4) struct IMAGE_NT_HEADERS64 { DWORD Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER64 OptionalHeader; } -alias IMAGE_NT_HEADERS64* PIMAGE_NT_HEADERS64; +alias PIMAGE_NT_HEADERS64 = IMAGE_NT_HEADERS64*; struct IMAGE_ROM_HEADERS { IMAGE_FILE_HEADER FileHeader; IMAGE_ROM_OPTIONAL_HEADER OptionalHeader; } -alias IMAGE_ROM_HEADERS* PIMAGE_ROM_HEADERS; +alias PIMAGE_ROM_HEADERS = IMAGE_ROM_HEADERS*; struct IMAGE_SECTION_HEADER { BYTE[IMAGE_SIZEOF_SHORT_NAME] Name; @@ -3148,7 +3148,7 @@ struct IMAGE_SECTION_HEADER { WORD NumberOfLinenumbers; DWORD Characteristics; } -alias IMAGE_SECTION_HEADER* PIMAGE_SECTION_HEADER; +alias PIMAGE_SECTION_HEADER = IMAGE_SECTION_HEADER*; struct IMAGE_SYMBOL { union _N { @@ -3167,7 +3167,7 @@ struct IMAGE_SYMBOL { BYTE StorageClass; BYTE NumberOfAuxSymbols; } -alias IMAGE_SYMBOL* PIMAGE_SYMBOL; +alias PIMAGE_SYMBOL = IMAGE_SYMBOL*; union IMAGE_AUX_SYMBOL { struct _Sym { @@ -3210,7 +3210,7 @@ union IMAGE_AUX_SYMBOL { } _Section Section; } -alias IMAGE_AUX_SYMBOL* PIMAGE_AUX_SYMBOL; +alias PIMAGE_AUX_SYMBOL = IMAGE_AUX_SYMBOL*; struct IMAGE_COFF_SYMBOLS_HEADER { DWORD NumberOfSymbols; @@ -3222,7 +3222,7 @@ struct IMAGE_COFF_SYMBOLS_HEADER { DWORD RvaToFirstByteOfData; DWORD RvaToLastByteOfData; } -alias IMAGE_COFF_SYMBOLS_HEADER* PIMAGE_COFF_SYMBOLS_HEADER; +alias PIMAGE_COFF_SYMBOLS_HEADER = IMAGE_COFF_SYMBOLS_HEADER*; struct IMAGE_RELOCATION { union { @@ -3232,13 +3232,13 @@ struct IMAGE_RELOCATION { DWORD SymbolTableIndex; WORD Type; } -alias IMAGE_RELOCATION* PIMAGE_RELOCATION; +alias PIMAGE_RELOCATION = IMAGE_RELOCATION*; align(4) struct IMAGE_BASE_RELOCATION { DWORD VirtualAddress; DWORD SizeOfBlock; } -alias IMAGE_BASE_RELOCATION* PIMAGE_BASE_RELOCATION; +alias PIMAGE_BASE_RELOCATION = IMAGE_BASE_RELOCATION*; align(2) struct IMAGE_LINENUMBER { union _Type { @@ -3248,7 +3248,7 @@ align(2) struct IMAGE_LINENUMBER { _Type Type; WORD Linenumber; } -alias IMAGE_LINENUMBER* PIMAGE_LINENUMBER; +alias PIMAGE_LINENUMBER = IMAGE_LINENUMBER*; align(4): struct IMAGE_ARCHIVE_MEMBER_HEADER { @@ -3260,7 +3260,7 @@ struct IMAGE_ARCHIVE_MEMBER_HEADER { BYTE[10] Size; BYTE[2] EndHeader; } -alias IMAGE_ARCHIVE_MEMBER_HEADER* PIMAGE_ARCHIVE_MEMBER_HEADER; +alias PIMAGE_ARCHIVE_MEMBER_HEADER = IMAGE_ARCHIVE_MEMBER_HEADER*; struct IMAGE_EXPORT_DIRECTORY { DWORD Characteristics; @@ -3275,7 +3275,7 @@ struct IMAGE_EXPORT_DIRECTORY { DWORD AddressOfNames; DWORD AddressOfNameOrdinals; } -alias IMAGE_EXPORT_DIRECTORY* PIMAGE_EXPORT_DIRECTORY; +alias PIMAGE_EXPORT_DIRECTORY = IMAGE_EXPORT_DIRECTORY*; struct IMAGE_IMPORT_BY_NAME { WORD Hint; @@ -3283,7 +3283,7 @@ struct IMAGE_IMPORT_BY_NAME { BYTE* Name() return { return &_Name; } } -alias IMAGE_IMPORT_BY_NAME* PIMAGE_IMPORT_BY_NAME; +alias PIMAGE_IMPORT_BY_NAME = IMAGE_IMPORT_BY_NAME*; struct IMAGE_THUNK_DATA32 { union _u1 { @@ -3294,7 +3294,7 @@ struct IMAGE_THUNK_DATA32 { } _u1 u1; } -alias IMAGE_THUNK_DATA32* PIMAGE_THUNK_DATA32; +alias PIMAGE_THUNK_DATA32 = IMAGE_THUNK_DATA32*; struct IMAGE_THUNK_DATA64 { union _u1 { @@ -3305,7 +3305,7 @@ struct IMAGE_THUNK_DATA64 { } _u1 u1; } -alias IMAGE_THUNK_DATA64* PIMAGE_THUNK_DATA64; +alias PIMAGE_THUNK_DATA64 = IMAGE_THUNK_DATA64*; struct IMAGE_IMPORT_DESCRIPTOR { union { @@ -3317,21 +3317,21 @@ struct IMAGE_IMPORT_DESCRIPTOR { DWORD Name; DWORD FirstThunk; } -alias IMAGE_IMPORT_DESCRIPTOR* PIMAGE_IMPORT_DESCRIPTOR; +alias PIMAGE_IMPORT_DESCRIPTOR = IMAGE_IMPORT_DESCRIPTOR*; struct IMAGE_BOUND_IMPORT_DESCRIPTOR { DWORD TimeDateStamp; WORD OffsetModuleName; WORD NumberOfModuleForwarderRefs; } -alias IMAGE_BOUND_IMPORT_DESCRIPTOR* PIMAGE_BOUND_IMPORT_DESCRIPTOR; +alias PIMAGE_BOUND_IMPORT_DESCRIPTOR = IMAGE_BOUND_IMPORT_DESCRIPTOR*; struct IMAGE_BOUND_FORWARDER_REF { DWORD TimeDateStamp; WORD OffsetModuleName; WORD Reserved; } -alias IMAGE_BOUND_FORWARDER_REF* PIMAGE_BOUND_FORWARDER_REF; +alias PIMAGE_BOUND_FORWARDER_REF = IMAGE_BOUND_FORWARDER_REF*; struct IMAGE_TLS_DIRECTORY32 { DWORD StartAddressOfRawData; @@ -3341,7 +3341,7 @@ struct IMAGE_TLS_DIRECTORY32 { DWORD SizeOfZeroFill; DWORD Characteristics; } -alias IMAGE_TLS_DIRECTORY32* PIMAGE_TLS_DIRECTORY32; +alias PIMAGE_TLS_DIRECTORY32 = IMAGE_TLS_DIRECTORY32*; struct IMAGE_TLS_DIRECTORY64 { ULONGLONG StartAddressOfRawData; @@ -3351,7 +3351,7 @@ struct IMAGE_TLS_DIRECTORY64 { DWORD SizeOfZeroFill; DWORD Characteristics; } -alias IMAGE_TLS_DIRECTORY64* PIMAGE_TLS_DIRECTORY64; +alias PIMAGE_TLS_DIRECTORY64 = IMAGE_TLS_DIRECTORY64*; struct IMAGE_RESOURCE_DIRECTORY { DWORD Characteristics; @@ -3361,7 +3361,7 @@ struct IMAGE_RESOURCE_DIRECTORY { WORD NumberOfNamedEntries; WORD NumberOfIdEntries; } -alias IMAGE_RESOURCE_DIRECTORY* PIMAGE_RESOURCE_DIRECTORY; +alias PIMAGE_RESOURCE_DIRECTORY = IMAGE_RESOURCE_DIRECTORY*; struct IMAGE_RESOURCE_DIRECTORY_ENTRY { union { @@ -3401,7 +3401,7 @@ struct IMAGE_RESOURCE_DIRECTORY_ENTRY { OffsetToData = (OffsetToData & 0x7FFFFFFF) | (d << 31); return d; } } -alias IMAGE_RESOURCE_DIRECTORY_ENTRY* PIMAGE_RESOURCE_DIRECTORY_ENTRY; +alias PIMAGE_RESOURCE_DIRECTORY_ENTRY = IMAGE_RESOURCE_DIRECTORY_ENTRY*; struct IMAGE_RESOURCE_DIRECTORY_STRING { WORD Length; @@ -3409,7 +3409,7 @@ struct IMAGE_RESOURCE_DIRECTORY_STRING { CHAR* NameString() return { return &_NameString; } } -alias IMAGE_RESOURCE_DIRECTORY_STRING* PIMAGE_RESOURCE_DIRECTORY_STRING; +alias PIMAGE_RESOURCE_DIRECTORY_STRING = IMAGE_RESOURCE_DIRECTORY_STRING*; struct IMAGE_RESOURCE_DIR_STRING_U { WORD Length; @@ -3417,7 +3417,7 @@ struct IMAGE_RESOURCE_DIR_STRING_U { WCHAR* NameString() return { return &_NameString; } } -alias IMAGE_RESOURCE_DIR_STRING_U* PIMAGE_RESOURCE_DIR_STRING_U; +alias PIMAGE_RESOURCE_DIR_STRING_U = IMAGE_RESOURCE_DIR_STRING_U*; struct IMAGE_RESOURCE_DATA_ENTRY { DWORD OffsetToData; @@ -3425,7 +3425,7 @@ struct IMAGE_RESOURCE_DATA_ENTRY { DWORD CodePage; DWORD Reserved; } -alias IMAGE_RESOURCE_DATA_ENTRY* PIMAGE_RESOURCE_DATA_ENTRY; +alias PIMAGE_RESOURCE_DATA_ENTRY = IMAGE_RESOURCE_DATA_ENTRY*; struct IMAGE_LOAD_CONFIG_DIRECTORY32 { DWORD Characteristics; @@ -3443,7 +3443,7 @@ struct IMAGE_LOAD_CONFIG_DIRECTORY32 { DWORD ProcessHeapFlags; DWORD[4] Reserved; } -alias IMAGE_LOAD_CONFIG_DIRECTORY32* PIMAGE_LOAD_CONFIG_DIRECTORY32; +alias PIMAGE_LOAD_CONFIG_DIRECTORY32 = IMAGE_LOAD_CONFIG_DIRECTORY32*; struct IMAGE_LOAD_CONFIG_DIRECTORY64 { DWORD Characteristics; @@ -3465,14 +3465,14 @@ struct IMAGE_LOAD_CONFIG_DIRECTORY64 { ULONGLONG EditList; DWORD[2] Reserved; } -alias IMAGE_LOAD_CONFIG_DIRECTORY64* PIMAGE_LOAD_CONFIG_DIRECTORY64; +alias PIMAGE_LOAD_CONFIG_DIRECTORY64 = IMAGE_LOAD_CONFIG_DIRECTORY64*; version (Win64) { - alias IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY; + alias IMAGE_LOAD_CONFIG_DIRECTORY = IMAGE_LOAD_CONFIG_DIRECTORY64; } else { - alias IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY; + alias IMAGE_LOAD_CONFIG_DIRECTORY = IMAGE_LOAD_CONFIG_DIRECTORY32; } -alias IMAGE_LOAD_CONFIG_DIRECTORY* PIMAGE_LOAD_CONFIG_DIRECTORY; +alias PIMAGE_LOAD_CONFIG_DIRECTORY = IMAGE_LOAD_CONFIG_DIRECTORY*; // Note versions for Alpha, Alpha64, ARM removed. struct IMAGE_RUNTIME_FUNCTION_ENTRY { @@ -3483,7 +3483,7 @@ struct IMAGE_RUNTIME_FUNCTION_ENTRY { DWORD UnwindData; } } -alias IMAGE_RUNTIME_FUNCTION_ENTRY* PIMAGE_RUNTIME_FUNCTION_ENTRY; +alias PIMAGE_RUNTIME_FUNCTION_ENTRY = IMAGE_RUNTIME_FUNCTION_ENTRY*; struct IMAGE_CE_RUNTIME_FUNCTION_ENTRY { uint FuncStart; @@ -3512,7 +3512,7 @@ struct IMAGE_CE_RUNTIME_FUNCTION_ENTRY { _bf = (_bf & ~0x80000000) | (e << 31); return e; } } -alias IMAGE_CE_RUNTIME_FUNCTION_ENTRY* PIMAGE_CE_RUNTIME_FUNCTION_ENTRY; +alias PIMAGE_CE_RUNTIME_FUNCTION_ENTRY = IMAGE_CE_RUNTIME_FUNCTION_ENTRY*; struct IMAGE_DEBUG_DIRECTORY { DWORD Characteristics; @@ -3524,7 +3524,7 @@ struct IMAGE_DEBUG_DIRECTORY { DWORD AddressOfRawData; DWORD PointerToRawData; } -alias IMAGE_DEBUG_DIRECTORY* PIMAGE_DEBUG_DIRECTORY; +alias PIMAGE_DEBUG_DIRECTORY = IMAGE_DEBUG_DIRECTORY*; struct FPO_DATA { DWORD ulOffStart; @@ -3560,7 +3560,7 @@ struct FPO_DATA { return cast(ubyte)(c & 0x03); } } -alias FPO_DATA* PFPO_DATA; +alias PFPO_DATA = FPO_DATA*; struct IMAGE_DEBUG_MISC { DWORD DataType; @@ -3571,14 +3571,14 @@ struct IMAGE_DEBUG_MISC { BYTE* Data() return { return &_Data; } } -alias IMAGE_DEBUG_MISC* PIMAGE_DEBUG_MISC; +alias PIMAGE_DEBUG_MISC = IMAGE_DEBUG_MISC*; struct IMAGE_FUNCTION_ENTRY { DWORD StartingAddress; DWORD EndingAddress; DWORD EndOfPrologue; } -alias IMAGE_FUNCTION_ENTRY* PIMAGE_FUNCTION_ENTRY; +alias PIMAGE_FUNCTION_ENTRY = IMAGE_FUNCTION_ENTRY*; struct IMAGE_FUNCTION_ENTRY64 { ULONGLONG StartingAddress; @@ -3588,7 +3588,7 @@ struct IMAGE_FUNCTION_ENTRY64 { ULONGLONG UnwindInfoAddress; } } -alias IMAGE_FUNCTION_ENTRY64* PIMAGE_FUNCTION_ENTRY64; +alias PIMAGE_FUNCTION_ENTRY64 = IMAGE_FUNCTION_ENTRY64*; struct IMAGE_SEPARATE_DEBUG_HEADER { WORD Signature; @@ -3605,7 +3605,7 @@ struct IMAGE_SEPARATE_DEBUG_HEADER { DWORD SectionAlignment; DWORD[2] Reserved; } -alias IMAGE_SEPARATE_DEBUG_HEADER* PIMAGE_SEPARATE_DEBUG_HEADER; +alias PIMAGE_SEPARATE_DEBUG_HEADER = IMAGE_SEPARATE_DEBUG_HEADER*; enum SERVICE_NODE_TYPE { DriverType = SERVICE_KERNEL_DRIVER, @@ -3630,11 +3630,11 @@ enum SERVICE_ERROR_TYPE { SevereError = SERVICE_ERROR_SEVERE, CriticalError = SERVICE_ERROR_CRITICAL } -alias SERVICE_ERROR_TYPE _CM_ERROR_CONTROL_TYPE; +alias _CM_ERROR_CONTROL_TYPE = SERVICE_ERROR_TYPE; //DAC: According to MSJ, 'UnderTheHood', May 1996, this // structure is not documented in any official Microsoft header file. -alias void EXCEPTION_REGISTRATION_RECORD; +alias EXCEPTION_REGISTRATION_RECORD = void; align: struct NT_TIB { @@ -3649,7 +3649,7 @@ struct NT_TIB { PVOID ArbitraryUserPointer; NT_TIB *Self; } -alias NT_TIB* PNT_TIB; +alias PNT_TIB = NT_TIB*; struct REPARSE_DATA_BUFFER { DWORD ReparseTag; @@ -3686,7 +3686,7 @@ struct REPARSE_DATA_BUFFER { _MountPointReparseBuffer MountPointReparseBuffer; } } -alias REPARSE_DATA_BUFFER *PREPARSE_DATA_BUFFER; +alias PREPARSE_DATA_BUFFER = REPARSE_DATA_BUFFER *; struct REPARSE_GUID_DATA_BUFFER { DWORD ReparseTag; @@ -3700,7 +3700,7 @@ struct REPARSE_GUID_DATA_BUFFER { } _GenericReparseBuffer GenericReparseBuffer; } -alias REPARSE_GUID_DATA_BUFFER* PREPARSE_GUID_DATA_BUFFER; +alias PREPARSE_GUID_DATA_BUFFER = REPARSE_GUID_DATA_BUFFER*; enum size_t REPARSE_DATA_BUFFER_HEADER_SIZE = REPARSE_DATA_BUFFER.GenericReparseBuffer.offsetof, @@ -3712,13 +3712,13 @@ struct REPARSE_POINT_INFORMATION { WORD ReparseDataLength; WORD UnparsedNameLength; } -alias REPARSE_POINT_INFORMATION* PREPARSE_POINT_INFORMATION; +alias PREPARSE_POINT_INFORMATION = REPARSE_POINT_INFORMATION*; union FILE_SEGMENT_ELEMENT { PVOID64 Buffer; ULONGLONG Alignment; } -alias FILE_SEGMENT_ELEMENT* PFILE_SEGMENT_ELEMENT; +alias PFILE_SEGMENT_ELEMENT = FILE_SEGMENT_ELEMENT*; // JOBOBJECT_BASIC_LIMIT_INFORMATION.LimitFlags constants enum DWORD @@ -3796,7 +3796,7 @@ struct JOBOBJECT_BASIC_ACCOUNTING_INFORMATION { DWORD ActiveProcesses; DWORD TotalTerminatedProcesses; } -alias JOBOBJECT_BASIC_ACCOUNTING_INFORMATION* PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION; +alias PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION = JOBOBJECT_BASIC_ACCOUNTING_INFORMATION*; struct JOBOBJECT_BASIC_LIMIT_INFORMATION { LARGE_INTEGER PerProcessUserTimeLimit; @@ -3809,7 +3809,7 @@ struct JOBOBJECT_BASIC_LIMIT_INFORMATION { DWORD PriorityClass; DWORD SchedulingClass; } -alias JOBOBJECT_BASIC_LIMIT_INFORMATION* PJOBOBJECT_BASIC_LIMIT_INFORMATION; +alias PJOBOBJECT_BASIC_LIMIT_INFORMATION = JOBOBJECT_BASIC_LIMIT_INFORMATION*; struct JOBOBJECT_BASIC_PROCESS_ID_LIST { DWORD NumberOfAssignedProcesses; @@ -3818,12 +3818,12 @@ struct JOBOBJECT_BASIC_PROCESS_ID_LIST { ULONG_PTR* ProcessIdList() return { return &_ProcessIdList; } } -alias JOBOBJECT_BASIC_PROCESS_ID_LIST* PJOBOBJECT_BASIC_PROCESS_ID_LIST; +alias PJOBOBJECT_BASIC_PROCESS_ID_LIST = JOBOBJECT_BASIC_PROCESS_ID_LIST*; struct JOBOBJECT_BASIC_UI_RESTRICTIONS { DWORD UIRestrictionsClass; } -alias JOBOBJECT_BASIC_UI_RESTRICTIONS* PJOBOBJECT_BASIC_UI_RESTRICTIONS; +alias PJOBOBJECT_BASIC_UI_RESTRICTIONS = JOBOBJECT_BASIC_UI_RESTRICTIONS*; struct JOBOBJECT_SECURITY_LIMIT_INFORMATION { DWORD SecurityLimitFlags; @@ -3832,24 +3832,24 @@ struct JOBOBJECT_SECURITY_LIMIT_INFORMATION { PTOKEN_PRIVILEGES PrivilegesToDelete; PTOKEN_GROUPS RestrictedSids; } -alias JOBOBJECT_SECURITY_LIMIT_INFORMATION* PJOBOBJECT_SECURITY_LIMIT_INFORMATION; +alias PJOBOBJECT_SECURITY_LIMIT_INFORMATION = JOBOBJECT_SECURITY_LIMIT_INFORMATION*; struct JOBOBJECT_END_OF_JOB_TIME_INFORMATION { DWORD EndOfJobTimeAction; } -alias JOBOBJECT_END_OF_JOB_TIME_INFORMATION* PJOBOBJECT_END_OF_JOB_TIME_INFORMATION; +alias PJOBOBJECT_END_OF_JOB_TIME_INFORMATION = JOBOBJECT_END_OF_JOB_TIME_INFORMATION*; struct JOBOBJECT_ASSOCIATE_COMPLETION_PORT { PVOID CompletionKey; HANDLE CompletionPort; } -alias JOBOBJECT_ASSOCIATE_COMPLETION_PORT* PJOBOBJECT_ASSOCIATE_COMPLETION_PORT; +alias PJOBOBJECT_ASSOCIATE_COMPLETION_PORT = JOBOBJECT_ASSOCIATE_COMPLETION_PORT*; struct JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION { JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo; IO_COUNTERS IoInfo; } -alias JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION; +alias PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION = JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION *; struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION { JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation; @@ -3859,12 +3859,12 @@ struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION { SIZE_T PeakProcessMemoryUsed; SIZE_T PeakJobMemoryUsed; } -alias JOBOBJECT_EXTENDED_LIMIT_INFORMATION* PJOBOBJECT_EXTENDED_LIMIT_INFORMATION; +alias PJOBOBJECT_EXTENDED_LIMIT_INFORMATION = JOBOBJECT_EXTENDED_LIMIT_INFORMATION*; struct JOBOBJECT_JOBSET_INFORMATION { DWORD MemberLevel; } -alias JOBOBJECT_JOBSET_INFORMATION* PJOBOBJECT_JOBSET_INFORMATION; +alias PJOBOBJECT_JOBSET_INFORMATION = JOBOBJECT_JOBSET_INFORMATION*; // MinGW: Making these defines conditional on _WIN32_WINNT will break ddk includes //static if (_WIN32_WINNT >= 0x500) { @@ -3880,7 +3880,7 @@ enum LATENCY_TIME { LT_DONT_CARE, LT_LOWEST_LATENCY } -alias LATENCY_TIME* PLATENCY_TIME; +alias PLATENCY_TIME = LATENCY_TIME*; enum SYSTEM_POWER_STATE { PowerSystemUnspecified, @@ -3892,7 +3892,7 @@ enum SYSTEM_POWER_STATE { PowerSystemShutdown, PowerSystemMaximum } -alias SYSTEM_POWER_STATE* PSYSTEM_POWER_STATE; +alias PSYSTEM_POWER_STATE = SYSTEM_POWER_STATE*; enum POWER_SYSTEM_MAXIMUM = SYSTEM_POWER_STATE.PowerSystemMaximum; @@ -3906,7 +3906,7 @@ enum POWER_ACTION { PowerActionShutdownOff, PowerActionWarmEject } -alias POWER_ACTION* PPOWER_ACTION; +alias PPOWER_ACTION = POWER_ACTION*; static if (_WIN32_WINNT >= 0x600) { enum SYSTEM_POWER_CONDITION { @@ -3915,7 +3915,7 @@ static if (_WIN32_WINNT >= 0x600) { PoHot, PoConditionMaximum } - alias SYSTEM_POWER_CONDITION* PSYSTEM_POWER_CONDITION; + alias PSYSTEM_POWER_CONDITION = SYSTEM_POWER_CONDITION*; } enum DEVICE_POWER_STATE { @@ -3926,21 +3926,21 @@ enum DEVICE_POWER_STATE { PowerDeviceD3, PowerDeviceMaximum } -alias DEVICE_POWER_STATE* PDEVICE_POWER_STATE; +alias PDEVICE_POWER_STATE = DEVICE_POWER_STATE*; align(4): struct BATTERY_REPORTING_SCALE { DWORD Granularity; DWORD Capacity; } -alias BATTERY_REPORTING_SCALE* PBATTERY_REPORTING_SCALE; +alias PBATTERY_REPORTING_SCALE = BATTERY_REPORTING_SCALE*; struct POWER_ACTION_POLICY { POWER_ACTION Action; ULONG Flags; ULONG EventCode; } -alias POWER_ACTION_POLICY* PPOWER_ACTION_POLICY; +alias PPOWER_ACTION_POLICY = POWER_ACTION_POLICY*; // POWER_ACTION_POLICY.Flags constants enum ULONG @@ -3981,7 +3981,7 @@ struct SYSTEM_POWER_LEVEL { POWER_ACTION_POLICY PowerPolicy; SYSTEM_POWER_STATE MinSystemState; } -alias SYSTEM_POWER_LEVEL* PSYSTEM_POWER_LEVEL; +alias PSYSTEM_POWER_LEVEL = SYSTEM_POWER_LEVEL*; struct SYSTEM_POWER_POLICY { ULONG Revision; @@ -4013,7 +4013,7 @@ struct SYSTEM_POWER_POLICY { UCHAR MinThrottle; POWER_ACTION_POLICY OverThrottled; } -alias SYSTEM_POWER_POLICY* PSYSTEM_POWER_POLICY; +alias PSYSTEM_POWER_POLICY = SYSTEM_POWER_POLICY*; struct SYSTEM_POWER_CAPABILITIES { BOOLEAN PowerButtonPresent; @@ -4045,7 +4045,7 @@ struct SYSTEM_POWER_CAPABILITIES { SYSTEM_POWER_STATE MinDeviceWakeState; SYSTEM_POWER_STATE DefaultLowLatencyWake; } -alias SYSTEM_POWER_CAPABILITIES* PSYSTEM_POWER_CAPABILITIES; +alias PSYSTEM_POWER_CAPABILITIES = SYSTEM_POWER_CAPABILITIES*; struct SYSTEM_BATTERY_STATE { BOOLEAN AcOnLine; @@ -4060,7 +4060,7 @@ struct SYSTEM_BATTERY_STATE { ULONG DefaultAlert1; ULONG DefaultAlert2; } -alias SYSTEM_BATTERY_STATE* PSYSTEM_BATTERY_STATE; +alias PSYSTEM_BATTERY_STATE = SYSTEM_BATTERY_STATE*; enum POWER_INFORMATION_LEVEL { SystemPowerPolicyAc, @@ -4095,7 +4095,7 @@ struct SYSTEM_POWER_INFORMATION { ULONG TimeRemaining; UCHAR CoolingMode; } -alias SYSTEM_POWER_INFORMATION* PSYSTEM_POWER_INFORMATION; +alias PSYSTEM_POWER_INFORMATION = SYSTEM_POWER_INFORMATION*; //#endif struct PROCESSOR_POWER_POLICY_INFO { @@ -4118,7 +4118,7 @@ struct PROCESSOR_POWER_POLICY_INFO { ULONG Reserved : 30; +/ } -alias PROCESSOR_POWER_POLICY_INFO* PPROCESSOR_POWER_POLICY_INFO; +alias PPROCESSOR_POWER_POLICY_INFO = PROCESSOR_POWER_POLICY_INFO*; struct PROCESSOR_POWER_POLICY { ULONG Revision; @@ -4128,7 +4128,7 @@ struct PROCESSOR_POWER_POLICY { ULONG PolicyCount; PROCESSOR_POWER_POLICY_INFO[3] Policy; } -alias PROCESSOR_POWER_POLICY* PPROCESSOR_POWER_POLICY; +alias PPROCESSOR_POWER_POLICY = PROCESSOR_POWER_POLICY*; struct ADMINISTRATOR_POWER_POLICY { SYSTEM_POWER_STATE MinSleep; @@ -4138,16 +4138,16 @@ struct ADMINISTRATOR_POWER_POLICY { ULONG MinSpindownTimeout; ULONG MaxSpindownTimeout; } -alias ADMINISTRATOR_POWER_POLICY* PADMINISTRATOR_POWER_POLICY; +alias PADMINISTRATOR_POWER_POLICY = ADMINISTRATOR_POWER_POLICY*; //}//#endif /* _WIN32_WINNT >= 0x500 */ extern (Windows) { - alias void function(PVOID, DWORD, PVOID) PIMAGE_TLS_CALLBACK; + alias PIMAGE_TLS_CALLBACK = void function(PVOID, DWORD, PVOID); static if (_WIN32_WINNT >= 0x500) { - alias LONG function(PEXCEPTION_POINTERS) PVECTORED_EXCEPTION_HANDLER; - alias void function(PVOID, BOOLEAN) WAITORTIMERCALLBACKFUNC; + alias PVECTORED_EXCEPTION_HANDLER = LONG function(PEXCEPTION_POINTERS); + alias WAITORTIMERCALLBACKFUNC = void function(PVOID, BOOLEAN); } } @@ -4183,10 +4183,8 @@ static if (_WIN32_WINNT >= 0x501) { PCWSTR lpAssemblyPolicyPath; PCWSTR lpAssemblyDirectoryName; } - alias ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION* - PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION; - alias const(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION)* - PCACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION; + alias PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION = ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION*; + alias PCACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION = const(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION)*; struct ACTIVATION_CONTEXT_DETAILED_INFORMATION { DWORD dwFlags; @@ -4202,17 +4200,15 @@ static if (_WIN32_WINNT >= 0x501) { PCWSTR lpRootConfigurationPath; PCWSTR lpAppDirPath; } - alias ACTIVATION_CONTEXT_DETAILED_INFORMATION* - PACTIVATION_CONTEXT_DETAILED_INFORMATION; - alias const(ACTIVATION_CONTEXT_DETAILED_INFORMATION)* - PCACTIVATION_CONTEXT_DETAILED_INFORMATION; + alias PACTIVATION_CONTEXT_DETAILED_INFORMATION = ACTIVATION_CONTEXT_DETAILED_INFORMATION*; + alias PCACTIVATION_CONTEXT_DETAILED_INFORMATION = const(ACTIVATION_CONTEXT_DETAILED_INFORMATION)*; struct ACTIVATION_CONTEXT_QUERY_INDEX { ULONG ulAssemblyIndex; ULONG ulFileIndexInAssembly; } - alias ACTIVATION_CONTEXT_QUERY_INDEX* PACTIVATION_CONTEXT_QUERY_INDEX; - alias const(ACTIVATION_CONTEXT_QUERY_INDEX)* PCACTIVATION_CONTEXT_QUERY_INDEX; + alias PACTIVATION_CONTEXT_QUERY_INDEX = ACTIVATION_CONTEXT_QUERY_INDEX*; + alias PCACTIVATION_CONTEXT_QUERY_INDEX = const(ACTIVATION_CONTEXT_QUERY_INDEX)*; struct ASSEMBLY_FILE_DETAILED_INFORMATION { DWORD ulFlags; @@ -4221,22 +4217,20 @@ static if (_WIN32_WINNT >= 0x501) { PCWSTR lpFileName; PCWSTR lpFilePath; } - alias ASSEMBLY_FILE_DETAILED_INFORMATION* - PASSEMBLY_FILE_DETAILED_INFORMATION; - alias const(ASSEMBLY_FILE_DETAILED_INFORMATION)* - PCASSEMBLY_FILE_DETAILED_INFORMATION; + alias PASSEMBLY_FILE_DETAILED_INFORMATION = ASSEMBLY_FILE_DETAILED_INFORMATION*; + alias PCASSEMBLY_FILE_DETAILED_INFORMATION = const(ASSEMBLY_FILE_DETAILED_INFORMATION)*; } version (Unicode) { - alias OSVERSIONINFOW OSVERSIONINFO; - alias OSVERSIONINFOEXW OSVERSIONINFOEX; + alias OSVERSIONINFO = OSVERSIONINFOW; + alias OSVERSIONINFOEX = OSVERSIONINFOEXW; } else { - alias OSVERSIONINFOA OSVERSIONINFO; - alias OSVERSIONINFOEXA OSVERSIONINFOEX; + alias OSVERSIONINFO = OSVERSIONINFOA; + alias OSVERSIONINFOEX = OSVERSIONINFOEXA; } -alias OSVERSIONINFO* POSVERSIONINFO, LPOSVERSIONINFO; -alias OSVERSIONINFOEX* POSVERSIONINFOEX, LPOSVERSIONINFOEX; +alias POSVERSIONINFO = OSVERSIONINFO*, LPOSVERSIONINFO = OSVERSIONINFO*; +alias POSVERSIONINFOEX = OSVERSIONINFOEX*, LPOSVERSIONINFOEX = OSVERSIONINFOEX*; static if (_WIN32_WINNT >= 0x500) { @@ -4246,29 +4240,29 @@ static if (_WIN32_WINNT >= 0x500) { version (Win64) { enum WORD IMAGE_NT_OPTIONAL_HDR_MAGIC = IMAGE_NT_OPTIONAL_HDR64_MAGIC; - alias IMAGE_ORDINAL_FLAG64 IMAGE_ORDINAL_FLAG; - alias IMAGE_SNAP_BY_ORDINAL64 IMAGE_SNAP_BY_ORDINAL; - alias IMAGE_ORDINAL64 IMAGE_ORDINAL; - alias IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER; - alias IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS; - alias IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA; - alias IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY; + alias IMAGE_ORDINAL_FLAG = IMAGE_ORDINAL_FLAG64; + alias IMAGE_SNAP_BY_ORDINAL = IMAGE_SNAP_BY_ORDINAL64; + alias IMAGE_ORDINAL = IMAGE_ORDINAL64; + alias IMAGE_OPTIONAL_HEADER = IMAGE_OPTIONAL_HEADER64; + alias IMAGE_NT_HEADERS = IMAGE_NT_HEADERS64; + alias IMAGE_THUNK_DATA = IMAGE_THUNK_DATA64; + alias IMAGE_TLS_DIRECTORY = IMAGE_TLS_DIRECTORY64; } else { enum WORD IMAGE_NT_OPTIONAL_HDR_MAGIC = IMAGE_NT_OPTIONAL_HDR32_MAGIC; - alias IMAGE_ORDINAL_FLAG32 IMAGE_ORDINAL_FLAG; - alias IMAGE_ORDINAL32 IMAGE_ORDINAL; - alias IMAGE_SNAP_BY_ORDINAL32 IMAGE_SNAP_BY_ORDINAL; - alias IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER; - alias IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS; - alias IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA; - alias IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY; + alias IMAGE_ORDINAL_FLAG = IMAGE_ORDINAL_FLAG32; + alias IMAGE_ORDINAL = IMAGE_ORDINAL32; + alias IMAGE_SNAP_BY_ORDINAL = IMAGE_SNAP_BY_ORDINAL32; + alias IMAGE_OPTIONAL_HEADER = IMAGE_OPTIONAL_HEADER32; + alias IMAGE_NT_HEADERS = IMAGE_NT_HEADERS32; + alias IMAGE_THUNK_DATA = IMAGE_THUNK_DATA32; + alias IMAGE_TLS_DIRECTORY = IMAGE_TLS_DIRECTORY32; } -alias IMAGE_OPTIONAL_HEADER* PIMAGE_OPTIONAL_HEADER; -alias IMAGE_NT_HEADERS* PIMAGE_NT_HEADERS; -alias IMAGE_THUNK_DATA* PIMAGE_THUNK_DATA; -alias IMAGE_TLS_DIRECTORY* PIMAGE_TLS_DIRECTORY; +alias PIMAGE_OPTIONAL_HEADER = IMAGE_OPTIONAL_HEADER*; +alias PIMAGE_NT_HEADERS = IMAGE_NT_HEADERS*; +alias PIMAGE_THUNK_DATA = IMAGE_THUNK_DATA*; +alias PIMAGE_TLS_DIRECTORY = IMAGE_TLS_DIRECTORY*; // TODO: MinGW implements these in assembly. How to translate? PVOID GetCurrentFiber(); diff --git a/runtime/druntime/src/core/sys/windows/winperf.d b/runtime/druntime/src/core/sys/windows/winperf.d index 77638c88af..111dcb2bae 100644 --- a/runtime/druntime/src/core/sys/windows/winperf.d +++ b/runtime/druntime/src/core/sys/windows/winperf.d @@ -97,7 +97,7 @@ struct PERF_DATA_BLOCK { DWORD SystemNameLength; DWORD SystemNameOffset; } -alias PERF_DATA_BLOCK * PPERF_DATA_BLOCK; +alias PPERF_DATA_BLOCK = PERF_DATA_BLOCK *; struct PERF_OBJECT_TYPE { DWORD TotalByteLength; @@ -123,7 +123,7 @@ version (Win64) { LARGE_INTEGER PerfTime; LARGE_INTEGER PerfFreq; } -alias PERF_OBJECT_TYPE * PPERF_OBJECT_TYPE; +alias PPERF_OBJECT_TYPE = PERF_OBJECT_TYPE *; struct PERF_COUNTER_DEFINITION { DWORD ByteLength; @@ -145,7 +145,7 @@ version (Win64) { DWORD CounterSize; DWORD CounterOffset; } -alias PERF_COUNTER_DEFINITION * PPERF_COUNTER_DEFINITION; +alias PPERF_COUNTER_DEFINITION = PERF_COUNTER_DEFINITION *; struct PERF_INSTANCE_DEFINITION { DWORD ByteLength; @@ -155,14 +155,14 @@ struct PERF_INSTANCE_DEFINITION { DWORD NameOffset; DWORD NameLength; } -alias PERF_INSTANCE_DEFINITION * PPERF_INSTANCE_DEFINITION; +alias PPERF_INSTANCE_DEFINITION = PERF_INSTANCE_DEFINITION *; struct PERF_COUNTER_BLOCK { DWORD ByteLength; } -alias PERF_COUNTER_BLOCK * PPERF_COUNTER_BLOCK; +alias PPERF_COUNTER_BLOCK = PERF_COUNTER_BLOCK *; extern (Windows): -alias DWORD function (LPWSTR) PM_OPEN_PROC; -alias DWORD function (LPWSTR,PVOID*,PDWORD,PDWORD) PM_COLLECT_PROC; -alias DWORD function () PM_CLOSE_PROC; +alias PM_OPEN_PROC = DWORD function (LPWSTR); +alias PM_COLLECT_PROC = DWORD function (LPWSTR,PVOID*,PDWORD,PDWORD); +alias PM_CLOSE_PROC = DWORD function (); diff --git a/runtime/druntime/src/core/sys/windows/winreg.d b/runtime/druntime/src/core/sys/windows/winreg.d index 6bffe88f25..d1add92c6d 100644 --- a/runtime/druntime/src/core/sys/windows/winreg.d +++ b/runtime/druntime/src/core/sys/windows/winreg.d @@ -60,7 +60,7 @@ enum DWORD REG_NOTIFY_CHANGE_LAST_SET = 4, REG_NOTIFY_CHANGE_SECURITY = 8; -alias ACCESS_MASK REGSAM; +alias REGSAM = ACCESS_MASK; struct VALENTA { LPSTR ve_valuename; @@ -68,7 +68,7 @@ struct VALENTA { DWORD_PTR ve_valueptr; DWORD ve_type; } -alias VALENTA* PVALENTA; +alias PVALENTA = VALENTA*; struct VALENTW { LPWSTR ve_valuename; @@ -76,7 +76,7 @@ struct VALENTW { DWORD_PTR ve_valueptr; DWORD ve_type; } -alias VALENTW* PVALENTW; +alias PVALENTW = VALENTW*; // RRF - Registry Routine Flags (for RegGetValue) static if (_WIN32_WINNT >= 0x600) { @@ -184,72 +184,72 @@ extern (Windows) nothrow @nogc { } version (Unicode) { - alias VALENTW VALENT; - alias RegConnectRegistryW RegConnectRegistry; - alias RegCreateKeyExW RegCreateKeyEx; - alias RegDeleteKeyW RegDeleteKey; - alias RegDeleteValueW RegDeleteValue; - alias RegEnumKeyExW RegEnumKeyEx; - alias RegEnumValueW RegEnumValue; - alias RegLoadKeyW RegLoadKey; - alias RegOpenKeyExW RegOpenKeyEx; - alias RegQueryInfoKeyW RegQueryInfoKey; - alias RegQueryMultipleValuesW RegQueryMultipleValues; - alias RegQueryValueExW RegQueryValueEx; - alias RegReplaceKeyW RegReplaceKey; - alias RegSaveKeyW RegSaveKey; - alias RegSetValueExW RegSetValueEx; - alias RegUnLoadKeyW RegUnLoadKey; - - alias AbortSystemShutdownW AbortSystemShutdown; - alias InitiateSystemShutdownW InitiateSystemShutdown; - alias RegRestoreKeyW RegRestoreKey; + alias VALENT = VALENTW; + alias RegConnectRegistry = RegConnectRegistryW; + alias RegCreateKeyEx = RegCreateKeyExW; + alias RegDeleteKey = RegDeleteKeyW; + alias RegDeleteValue = RegDeleteValueW; + alias RegEnumKeyEx = RegEnumKeyExW; + alias RegEnumValue = RegEnumValueW; + alias RegLoadKey = RegLoadKeyW; + alias RegOpenKeyEx = RegOpenKeyExW; + alias RegQueryInfoKey = RegQueryInfoKeyW; + alias RegQueryMultipleValues = RegQueryMultipleValuesW; + alias RegQueryValueEx = RegQueryValueExW; + alias RegReplaceKey = RegReplaceKeyW; + alias RegSaveKey = RegSaveKeyW; + alias RegSetValueEx = RegSetValueExW; + alias RegUnLoadKey = RegUnLoadKeyW; + + alias AbortSystemShutdown = AbortSystemShutdownW; + alias InitiateSystemShutdown = InitiateSystemShutdownW; + alias RegRestoreKey = RegRestoreKeyW; static if (_WIN32_WINNT >= 0x501) { - alias RegSaveKeyExA RegSaveKeyEx; + alias RegSaveKeyEx = RegSaveKeyExA; } static if (_WIN32_WINNT >= 0x600) { - alias RegGetValueW RegGetValue; + alias RegGetValue = RegGetValueW; } //deprecated { - alias RegCreateKeyW RegCreateKey; - alias RegEnumKeyW RegEnumKey; - alias RegOpenKeyW RegOpenKey; - alias RegQueryValueW RegQueryValue; - alias RegSetValueW RegSetValue; + alias RegCreateKey = RegCreateKeyW; + alias RegEnumKey = RegEnumKeyW; + alias RegOpenKey = RegOpenKeyW; + alias RegQueryValue = RegQueryValueW; + alias RegSetValue = RegSetValueW; //} } else { - alias VALENTA VALENT; - alias RegConnectRegistryA RegConnectRegistry; - alias RegCreateKeyExA RegCreateKeyEx; - alias RegDeleteKeyA RegDeleteKey; - alias RegDeleteValueA RegDeleteValue; - alias RegEnumKeyExA RegEnumKeyEx; - alias RegEnumValueA RegEnumValue; - alias RegLoadKeyA RegLoadKey; - alias RegOpenKeyExA RegOpenKeyEx; - alias RegQueryInfoKeyA RegQueryInfoKey; - alias RegQueryMultipleValuesA RegQueryMultipleValues; - alias RegQueryValueExA RegQueryValueEx; - alias RegReplaceKeyA RegReplaceKey; - alias RegSaveKeyA RegSaveKey; - alias RegSetValueExA RegSetValueEx; - alias RegUnLoadKeyA RegUnLoadKey; - alias AbortSystemShutdownA AbortSystemShutdown; - alias InitiateSystemShutdownA InitiateSystemShutdown; - alias RegRestoreKeyW RegRestoreKey; + alias VALENT = VALENTA; + alias RegConnectRegistry = RegConnectRegistryA; + alias RegCreateKeyEx = RegCreateKeyExA; + alias RegDeleteKey = RegDeleteKeyA; + alias RegDeleteValue = RegDeleteValueA; + alias RegEnumKeyEx = RegEnumKeyExA; + alias RegEnumValue = RegEnumValueA; + alias RegLoadKey = RegLoadKeyA; + alias RegOpenKeyEx = RegOpenKeyExA; + alias RegQueryInfoKey = RegQueryInfoKeyA; + alias RegQueryMultipleValues = RegQueryMultipleValuesA; + alias RegQueryValueEx = RegQueryValueExA; + alias RegReplaceKey = RegReplaceKeyA; + alias RegSaveKey = RegSaveKeyA; + alias RegSetValueEx = RegSetValueExA; + alias RegUnLoadKey = RegUnLoadKeyA; + alias AbortSystemShutdown = AbortSystemShutdownA; + alias InitiateSystemShutdown = InitiateSystemShutdownA; + alias RegRestoreKey = RegRestoreKeyW; static if (_WIN32_WINNT >= 0x501) { - alias RegSaveKeyExA RegSaveKeyEx; + alias RegSaveKeyEx = RegSaveKeyExA; } static if (_WIN32_WINNT >= 0x600) { - alias RegGetValueA RegGetValue; + alias RegGetValue = RegGetValueA; } //deprecated { - alias RegCreateKeyA RegCreateKey; - alias RegEnumKeyA RegEnumKey; - alias RegOpenKeyA RegOpenKey; - alias RegQueryValueA RegQueryValue; - alias RegSetValueA RegSetValue; + alias RegCreateKey = RegCreateKeyA; + alias RegEnumKey = RegEnumKeyA; + alias RegOpenKey = RegOpenKeyA; + alias RegQueryValue = RegQueryValueA; + alias RegSetValue = RegSetValueA; //} } -alias VALENT* PVALENT; +alias PVALENT = VALENT*; diff --git a/runtime/druntime/src/core/sys/windows/winsock2.d b/runtime/druntime/src/core/sys/windows/winsock2.d index 626f79e89c..c2cc1864e1 100644 --- a/runtime/druntime/src/core/sys/windows/winsock2.d +++ b/runtime/druntime/src/core/sys/windows/winsock2.d @@ -653,8 +653,8 @@ struct sockaddr short sa_family; ubyte[14] sa_data; } -alias sockaddr SOCKADDR; -alias SOCKADDR* PSOCKADDR, LPSOCKADDR; +alias SOCKADDR = sockaddr; +alias PSOCKADDR = SOCKADDR*, LPSOCKADDR = SOCKADDR*; struct sockaddr_storage { @@ -663,8 +663,8 @@ struct sockaddr_storage long __ss_align; char[112] __ss_pad2 = void; } -alias sockaddr_storage SOCKADDR_STORAGE; -alias SOCKADDR_STORAGE* PSOCKADDR_STORAGE; +alias SOCKADDR_STORAGE = sockaddr_storage; +alias PSOCKADDR_STORAGE = SOCKADDR_STORAGE*; struct sockaddr_in { @@ -673,8 +673,8 @@ struct sockaddr_in in_addr sin_addr; ubyte[8] sin_zero; } -alias sockaddr_in SOCKADDR_IN; -alias SOCKADDR_IN* PSOCKADDR_IN, LPSOCKADDR_IN; +alias SOCKADDR_IN = sockaddr_in; +alias PSOCKADDR_IN = SOCKADDR_IN*, LPSOCKADDR_IN = SOCKADDR_IN*; struct sockaddr_in6 diff --git a/runtime/druntime/src/core/sys/windows/winspool.d b/runtime/druntime/src/core/sys/windows/winspool.d index 12942fb771..2827efef10 100644 --- a/runtime/druntime/src/core/sys/windows/winspool.d +++ b/runtime/druntime/src/core/sys/windows/winspool.d @@ -251,23 +251,23 @@ struct ADDJOB_INFO_1A { LPSTR Path; DWORD JobId; } -alias ADDJOB_INFO_1A* PADDJOB_INFO_1A, LPADDJOB_INFO_1A; +alias PADDJOB_INFO_1A = ADDJOB_INFO_1A*, LPADDJOB_INFO_1A = ADDJOB_INFO_1A*; struct ADDJOB_INFO_1W { LPWSTR Path; DWORD JobId; } -alias ADDJOB_INFO_1W* PADDJOB_INFO_1W, LPADDJOB_INFO_1W; +alias PADDJOB_INFO_1W = ADDJOB_INFO_1W*, LPADDJOB_INFO_1W = ADDJOB_INFO_1W*; struct DATATYPES_INFO_1A { LPSTR pName; } -alias DATATYPES_INFO_1A* PDATATYPES_INFO_1A, LPDATATYPES_INFO_1A; +alias PDATATYPES_INFO_1A = DATATYPES_INFO_1A*, LPDATATYPES_INFO_1A = DATATYPES_INFO_1A*; struct DATATYPES_INFO_1W { LPWSTR pName; } -alias DATATYPES_INFO_1W* PDATATYPES_INFO_1W, LPDATATYPES_INFO_1W; +alias PDATATYPES_INFO_1W = DATATYPES_INFO_1W*, LPDATATYPES_INFO_1W = DATATYPES_INFO_1W*; struct JOB_INFO_1A { DWORD JobId; @@ -284,7 +284,7 @@ struct JOB_INFO_1A { DWORD PagesPrinted; SYSTEMTIME Submitted; } -alias JOB_INFO_1A* PJOB_INFO_1A, LPJOB_INFO_1A; +alias PJOB_INFO_1A = JOB_INFO_1A*, LPJOB_INFO_1A = JOB_INFO_1A*; struct JOB_INFO_1W { DWORD JobId; @@ -301,7 +301,7 @@ struct JOB_INFO_1W { DWORD PagesPrinted; SYSTEMTIME Submitted; } -alias JOB_INFO_1W* PJOB_INFO_1W, LPJOB_INFO_1W; +alias PJOB_INFO_1W = JOB_INFO_1W*, LPJOB_INFO_1W = JOB_INFO_1W*; struct JOB_INFO_2A { DWORD JobId; @@ -328,7 +328,7 @@ struct JOB_INFO_2A { DWORD Time; DWORD PagesPrinted; } -alias JOB_INFO_2A* PJOB_INFO_2A, LPJOB_INFO_2A; +alias PJOB_INFO_2A = JOB_INFO_2A*, LPJOB_INFO_2A = JOB_INFO_2A*; struct JOB_INFO_2W { DWORD JobId; @@ -355,21 +355,21 @@ struct JOB_INFO_2W { DWORD Time; DWORD PagesPrinted; } -alias JOB_INFO_2W* PJOB_INFO_2W, LPJOB_INFO_2W; +alias PJOB_INFO_2W = JOB_INFO_2W*, LPJOB_INFO_2W = JOB_INFO_2W*; struct DOC_INFO_1A { LPSTR pDocName; LPSTR pOutputFile; LPSTR pDatatype; } -alias DOC_INFO_1A* PDOC_INFO_1A, LPDOC_INFO_1A; +alias PDOC_INFO_1A = DOC_INFO_1A*, LPDOC_INFO_1A = DOC_INFO_1A*; struct DOC_INFO_1W { LPWSTR pDocName; LPWSTR pOutputFile; LPWSTR pDatatype; } -alias DOC_INFO_1W* PDOC_INFO_1W, LPDOC_INFO_1W; +alias PDOC_INFO_1W = DOC_INFO_1W*, LPDOC_INFO_1W = DOC_INFO_1W*; struct DOC_INFO_2A { LPSTR pDocName; @@ -378,7 +378,7 @@ struct DOC_INFO_2A { DWORD dwMode; DWORD JobId; } -alias DOC_INFO_2A* PDOC_INFO_2A, LPDOC_INFO_2A; +alias PDOC_INFO_2A = DOC_INFO_2A*, LPDOC_INFO_2A = DOC_INFO_2A*; struct DOC_INFO_2W { LPWSTR pDocName; @@ -387,17 +387,17 @@ struct DOC_INFO_2W { DWORD dwMode; DWORD JobId; } -alias DOC_INFO_2W* PDOC_INFO_2W, LPDOC_INFO_2W; +alias PDOC_INFO_2W = DOC_INFO_2W*, LPDOC_INFO_2W = DOC_INFO_2W*; struct DRIVER_INFO_1A { LPSTR pName; } -alias DRIVER_INFO_1A* PDRIVER_INFO_1A, LPDRIVER_INFO_1A; +alias PDRIVER_INFO_1A = DRIVER_INFO_1A*, LPDRIVER_INFO_1A = DRIVER_INFO_1A*; struct DRIVER_INFO_1W { LPWSTR pName; } -alias DRIVER_INFO_1W* PDRIVER_INFO_1W, LPDRIVER_INFO_1W; +alias PDRIVER_INFO_1W = DRIVER_INFO_1W*, LPDRIVER_INFO_1W = DRIVER_INFO_1W*; struct DRIVER_INFO_2A { DWORD cVersion; @@ -407,7 +407,7 @@ struct DRIVER_INFO_2A { LPSTR pDataFile; LPSTR pConfigFile; } -alias DRIVER_INFO_2A* PDRIVER_INFO_2A, LPDRIVER_INFO_2A; +alias PDRIVER_INFO_2A = DRIVER_INFO_2A*, LPDRIVER_INFO_2A = DRIVER_INFO_2A*; struct DRIVER_INFO_2W { DWORD cVersion; @@ -417,7 +417,7 @@ struct DRIVER_INFO_2W { LPWSTR pDataFile; LPWSTR pConfigFile; } -alias DRIVER_INFO_2W* PDRIVER_INFO_2W, LPDRIVER_INFO_2W; +alias PDRIVER_INFO_2W = DRIVER_INFO_2W*, LPDRIVER_INFO_2W = DRIVER_INFO_2W*; struct DRIVER_INFO_3A { DWORD cVersion; @@ -431,7 +431,7 @@ struct DRIVER_INFO_3A { LPSTR pMonitorName; LPSTR pDefaultDataType; } -alias DRIVER_INFO_3A* PDRIVER_INFO_3A, LPDRIVER_INFO_3A; +alias PDRIVER_INFO_3A = DRIVER_INFO_3A*, LPDRIVER_INFO_3A = DRIVER_INFO_3A*; struct DRIVER_INFO_3W { DWORD cVersion; @@ -445,41 +445,41 @@ struct DRIVER_INFO_3W { LPWSTR pMonitorName; LPWSTR pDefaultDataType; } -alias DRIVER_INFO_3W* PDRIVER_INFO_3W, LPDRIVER_INFO_3W; +alias PDRIVER_INFO_3W = DRIVER_INFO_3W*, LPDRIVER_INFO_3W = DRIVER_INFO_3W*; struct MONITOR_INFO_1A { LPSTR pName; } -alias MONITOR_INFO_1A* PMONITOR_INFO_1A, LPMONITOR_INFO_1A; +alias PMONITOR_INFO_1A = MONITOR_INFO_1A*, LPMONITOR_INFO_1A = MONITOR_INFO_1A*; struct MONITOR_INFO_1W { LPWSTR pName; } -alias MONITOR_INFO_1W* PMONITOR_INFO_1W, LPMONITOR_INFO_1W; +alias PMONITOR_INFO_1W = MONITOR_INFO_1W*, LPMONITOR_INFO_1W = MONITOR_INFO_1W*; struct PORT_INFO_1A { LPSTR pName; } -alias PORT_INFO_1A* PPORT_INFO_1A, LPPORT_INFO_1A; +alias PPORT_INFO_1A = PORT_INFO_1A*, LPPORT_INFO_1A = PORT_INFO_1A*; struct PORT_INFO_1W { LPWSTR pName; } -alias PORT_INFO_1W* PPORT_INFO_1W, LPPORT_INFO_1W; +alias PPORT_INFO_1W = PORT_INFO_1W*, LPPORT_INFO_1W = PORT_INFO_1W*; struct MONITOR_INFO_2A { LPSTR pName; LPSTR pEnvironment; LPSTR pDLLName; } -alias MONITOR_INFO_2A* PMONITOR_INFO_2A, LPMONITOR_INFO_2A; +alias PMONITOR_INFO_2A = MONITOR_INFO_2A*, LPMONITOR_INFO_2A = MONITOR_INFO_2A*; struct MONITOR_INFO_2W { LPWSTR pName; LPWSTR pEnvironment; LPWSTR pDLLName; } -alias MONITOR_INFO_2W* PMONITOR_INFO_2W, LPMONITOR_INFO_2W; +alias PMONITOR_INFO_2W = MONITOR_INFO_2W*, LPMONITOR_INFO_2W = MONITOR_INFO_2W*; struct PORT_INFO_2A { LPSTR pPortName; @@ -488,7 +488,7 @@ struct PORT_INFO_2A { DWORD fPortType; DWORD Reserved; } -alias PORT_INFO_2A* PPORT_INFO_2A, LPPORT_INFO_2A; +alias PPORT_INFO_2A = PORT_INFO_2A*, LPPORT_INFO_2A = PORT_INFO_2A*; struct PORT_INFO_2W { LPWSTR pPortName; @@ -497,21 +497,21 @@ struct PORT_INFO_2W { DWORD fPortType; DWORD Reserved; } -alias PORT_INFO_2W* PPORT_INFO_2W, LPPORT_INFO_2W; +alias PPORT_INFO_2W = PORT_INFO_2W*, LPPORT_INFO_2W = PORT_INFO_2W*; struct PORT_INFO_3A { DWORD dwStatus; LPSTR pszStatus; DWORD dwSeverity; } -alias PORT_INFO_3A* PPORT_INFO_3A, LPPORT_INFO_3A; +alias PPORT_INFO_3A = PORT_INFO_3A*, LPPORT_INFO_3A = PORT_INFO_3A*; struct PORT_INFO_3W { DWORD dwStatus; LPWSTR pszStatus; DWORD dwSeverity; } -alias PORT_INFO_3W* PPORT_INFO_3W, LPPORT_INFO_3W; +alias PPORT_INFO_3W = PORT_INFO_3W*, LPPORT_INFO_3W = PORT_INFO_3W*; struct PRINTER_INFO_1A { DWORD Flags; @@ -519,7 +519,7 @@ struct PRINTER_INFO_1A { LPSTR pName; LPSTR pComment; } -alias PRINTER_INFO_1A* PPRINTER_INFO_1A, LPPRINTER_INFO_1A; +alias PPRINTER_INFO_1A = PRINTER_INFO_1A*, LPPRINTER_INFO_1A = PRINTER_INFO_1A*; struct PRINTER_INFO_1W { DWORD Flags; @@ -527,7 +527,7 @@ struct PRINTER_INFO_1W { LPWSTR pName; LPWSTR pComment; } -alias PRINTER_INFO_1W* PPRINTER_INFO_1W, LPPRINTER_INFO_1W; +alias PPRINTER_INFO_1W = PRINTER_INFO_1W*, LPPRINTER_INFO_1W = PRINTER_INFO_1W*; struct PRINTER_INFO_2A { LPSTR pServerName; @@ -552,7 +552,7 @@ struct PRINTER_INFO_2A { DWORD cJobs; DWORD AveragePPM; } -alias PRINTER_INFO_2A* PPRINTER_INFO_2A, LPPRINTER_INFO_2A; +alias PPRINTER_INFO_2A = PRINTER_INFO_2A*, LPPRINTER_INFO_2A = PRINTER_INFO_2A*; struct PRINTER_INFO_2W { LPWSTR pServerName; @@ -577,26 +577,26 @@ struct PRINTER_INFO_2W { DWORD cJobs; DWORD AveragePPM; } -alias PRINTER_INFO_2W* PPRINTER_INFO_2W, LPPRINTER_INFO_2W; +alias PPRINTER_INFO_2W = PRINTER_INFO_2W*, LPPRINTER_INFO_2W = PRINTER_INFO_2W*; struct PRINTER_INFO_3 { PSECURITY_DESCRIPTOR pSecurityDescriptor; } -alias PRINTER_INFO_3* PPRINTER_INFO_3, LPPRINTER_INFO_3; +alias PPRINTER_INFO_3 = PRINTER_INFO_3*, LPPRINTER_INFO_3 = PRINTER_INFO_3*; struct PRINTER_INFO_4A { LPSTR pPrinterName; LPSTR pServerName; DWORD Attributes; } -alias PRINTER_INFO_4A* PPRINTER_INFO_4A, LPPRINTER_INFO_4A; +alias PPRINTER_INFO_4A = PRINTER_INFO_4A*, LPPRINTER_INFO_4A = PRINTER_INFO_4A*; struct PRINTER_INFO_4W { LPWSTR pPrinterName; LPWSTR pServerName; DWORD Attributes; } -alias PRINTER_INFO_4W* PPRINTER_INFO_4W, LPPRINTER_INFO_4W; +alias PPRINTER_INFO_4W = PRINTER_INFO_4W*, LPPRINTER_INFO_4W = PRINTER_INFO_4W*; struct PRINTER_INFO_5A { LPSTR pPrinterName; @@ -605,7 +605,7 @@ struct PRINTER_INFO_5A { DWORD DeviceNotSelectedTimeout; DWORD TransmissionRetryTimeout; } -alias PRINTER_INFO_5A* PPRINTER_INFO_5A, LPPRINTER_INFO_5A; +alias PPRINTER_INFO_5A = PRINTER_INFO_5A*, LPPRINTER_INFO_5A = PRINTER_INFO_5A*; struct PRINTER_INFO_5W { LPWSTR pPrinterName; @@ -614,22 +614,22 @@ struct PRINTER_INFO_5W { DWORD DeviceNotSelectedTimeout; DWORD TransmissionRetryTimeout; } -alias PRINTER_INFO_5W* PPRINTER_INFO_5W, LPPRINTER_INFO_5W; +alias PPRINTER_INFO_5W = PRINTER_INFO_5W*, LPPRINTER_INFO_5W = PRINTER_INFO_5W*; struct PRINTER_INFO_6 { DWORD dwStatus; } -alias PRINTER_INFO_6* PPRINTER_INFO_6, LPPRINTER_INFO_6; +alias PPRINTER_INFO_6 = PRINTER_INFO_6*, LPPRINTER_INFO_6 = PRINTER_INFO_6*; struct PRINTPROCESSOR_INFO_1A { LPSTR pName; } -alias PRINTPROCESSOR_INFO_1A* PPRINTPROCESSOR_INFO_1A, LPPRINTPROCESSOR_INFO_1A; +alias PPRINTPROCESSOR_INFO_1A = PRINTPROCESSOR_INFO_1A*, LPPRINTPROCESSOR_INFO_1A = PRINTPROCESSOR_INFO_1A*; struct PRINTPROCESSOR_INFO_1W { LPWSTR pName; } -alias PRINTPROCESSOR_INFO_1W* PPRINTPROCESSOR_INFO_1W, LPPRINTPROCESSOR_INFO_1W; +alias PPRINTPROCESSOR_INFO_1W = PRINTPROCESSOR_INFO_1W*, LPPRINTPROCESSOR_INFO_1W = PRINTPROCESSOR_INFO_1W*; struct PRINTER_NOTIFY_INFO_DATA { WORD Type; @@ -646,7 +646,7 @@ struct PRINTER_NOTIFY_INFO_DATA { } _NotifyData NotifyData; } -alias PRINTER_NOTIFY_INFO_DATA* PPRINTER_NOTIFY_INFO_DATA, LPPRINTER_NOTIFY_INFO_DATA; +alias PPRINTER_NOTIFY_INFO_DATA = PRINTER_NOTIFY_INFO_DATA*, LPPRINTER_NOTIFY_INFO_DATA = PRINTER_NOTIFY_INFO_DATA*; struct PRINTER_NOTIFY_INFO { DWORD Version; @@ -654,7 +654,7 @@ struct PRINTER_NOTIFY_INFO { DWORD Count; PRINTER_NOTIFY_INFO_DATA[1] aData; } -alias PRINTER_NOTIFY_INFO* PPRINTER_NOTIFY_INFO, LPPRINTER_NOTIFY_INFO; +alias PPRINTER_NOTIFY_INFO = PRINTER_NOTIFY_INFO*, LPPRINTER_NOTIFY_INFO = PRINTER_NOTIFY_INFO*; struct FORM_INFO_1A { DWORD Flags; @@ -662,7 +662,7 @@ struct FORM_INFO_1A { SIZEL Size; RECTL ImageableArea; } -alias FORM_INFO_1A* PFORM_INFO_1A, LPFORM_INFO_1A; +alias PFORM_INFO_1A = FORM_INFO_1A*, LPFORM_INFO_1A = FORM_INFO_1A*; struct FORM_INFO_1W { DWORD Flags; @@ -670,21 +670,21 @@ struct FORM_INFO_1W { SIZEL Size; RECTL ImageableArea; } -alias FORM_INFO_1W* PFORM_INFO_1W, LPFORM_INFO_1W; +alias PFORM_INFO_1W = FORM_INFO_1W*, LPFORM_INFO_1W = FORM_INFO_1W*; struct PRINTER_DEFAULTSA { LPSTR pDatatype; LPDEVMODE pDevMode; ACCESS_MASK DesiredAccess; } -alias PRINTER_DEFAULTSA* PPRINTER_DEFAULTSA, LPPRINTER_DEFAULTSA; +alias PPRINTER_DEFAULTSA = PRINTER_DEFAULTSA*, LPPRINTER_DEFAULTSA = PRINTER_DEFAULTSA*; struct PRINTER_DEFAULTSW { LPWSTR pDatatype; LPDEVMODE pDevMode; ACCESS_MASK DesiredAccess; } -alias PRINTER_DEFAULTSW* PPRINTER_DEFAULTSW, LPPRINTER_DEFAULTSW; +alias PPRINTER_DEFAULTSW = PRINTER_DEFAULTSW*, LPPRINTER_DEFAULTSW = PRINTER_DEFAULTSW*; extern (Windows): BOOL AbortPrinter(HANDLE); @@ -800,165 +800,165 @@ BOOL WritePrinter(HANDLE, PVOID, DWORD, PDWORD); version (Unicode) { -alias JOB_INFO_1W JOB_INFO_1; -alias JOB_INFO_2W JOB_INFO_2; -alias ADDJOB_INFO_1W ADDJOB_INFO_1; -alias DATATYPES_INFO_1W DATATYPES_INFO_1; -alias MONITOR_INFO_1W MONITOR_INFO_1; -alias MONITOR_INFO_2W MONITOR_INFO_2; -alias DOC_INFO_1W DOC_INFO_1; -alias DOC_INFO_2W DOC_INFO_2; -alias PORT_INFO_1W PORT_INFO_1; -alias PORT_INFO_2W PORT_INFO_2; -alias PORT_INFO_3W PORT_INFO_3; -alias DRIVER_INFO_2W DRIVER_INFO_2; -alias PRINTER_INFO_1W PRINTER_INFO_1; -alias PRINTER_INFO_2W PRINTER_INFO_2; -alias PRINTER_INFO_4W PRINTER_INFO_4; -alias PRINTER_INFO_5W PRINTER_INFO_5; -alias PRINTPROCESSOR_INFO_1W PRINTPROCESSOR_INFO_1; -alias FORM_INFO_1W FORM_INFO_1; -alias PRINTER_DEFAULTSW PRINTER_DEFAULTS; - -alias AddFormW AddForm; -alias AddJobW AddJob; -alias AddMonitorW AddMonitor; -alias AddPortW AddPort; -alias AddPrinterW AddPrinter; -alias AddPrinterConnectionW AddPrinterConnection; -alias AddPrinterDriverW AddPrinterDriver; -alias AddPrintProcessorW AddPrintProcessor; -alias AddPrintProvidorW AddPrintProvidor; -alias AdvancedDocumentPropertiesW AdvancedDocumentProperties; -alias ConfigurePortW ConfigurePort; -alias DeleteFormW DeleteForm; -alias DeleteMonitorW DeleteMonitor; -alias DeletePortW DeletePort; -alias DeletePrinterConnectionW DeletePrinterConnection; -alias DeletePrinterDataW DeletePrinterData; -alias DeletePrinterDriverW DeletePrinterDriver; -alias DeletePrintProcessorW DeletePrintProcessor; -alias DeletePrintProvidorW DeletePrintProvidor; -alias DocumentPropertiesW DocumentProperties; -alias EnumFormsW EnumForms; -alias EnumJobsW EnumJobs; -alias EnumMonitorsW EnumMonitors; -alias EnumPortsW EnumPorts; -alias EnumPrinterDataW EnumPrinterData; -alias EnumPrinterDriversW EnumPrinterDrivers; -alias EnumPrintersW EnumPrinters; -alias EnumPrintProcessorDatatypesW EnumPrintProcessorDatatypes; -alias EnumPrintProcessorsW EnumPrintProcessors; +alias JOB_INFO_1 = JOB_INFO_1W; +alias JOB_INFO_2 = JOB_INFO_2W; +alias ADDJOB_INFO_1 = ADDJOB_INFO_1W; +alias DATATYPES_INFO_1 = DATATYPES_INFO_1W; +alias MONITOR_INFO_1 = MONITOR_INFO_1W; +alias MONITOR_INFO_2 = MONITOR_INFO_2W; +alias DOC_INFO_1 = DOC_INFO_1W; +alias DOC_INFO_2 = DOC_INFO_2W; +alias PORT_INFO_1 = PORT_INFO_1W; +alias PORT_INFO_2 = PORT_INFO_2W; +alias PORT_INFO_3 = PORT_INFO_3W; +alias DRIVER_INFO_2 = DRIVER_INFO_2W; +alias PRINTER_INFO_1 = PRINTER_INFO_1W; +alias PRINTER_INFO_2 = PRINTER_INFO_2W; +alias PRINTER_INFO_4 = PRINTER_INFO_4W; +alias PRINTER_INFO_5 = PRINTER_INFO_5W; +alias PRINTPROCESSOR_INFO_1 = PRINTPROCESSOR_INFO_1W; +alias FORM_INFO_1 = FORM_INFO_1W; +alias PRINTER_DEFAULTS = PRINTER_DEFAULTSW; + +alias AddForm = AddFormW; +alias AddJob = AddJobW; +alias AddMonitor = AddMonitorW; +alias AddPort = AddPortW; +alias AddPrinter = AddPrinterW; +alias AddPrinterConnection = AddPrinterConnectionW; +alias AddPrinterDriver = AddPrinterDriverW; +alias AddPrintProcessor = AddPrintProcessorW; +alias AddPrintProvidor = AddPrintProvidorW; +alias AdvancedDocumentProperties = AdvancedDocumentPropertiesW; +alias ConfigurePort = ConfigurePortW; +alias DeleteForm = DeleteFormW; +alias DeleteMonitor = DeleteMonitorW; +alias DeletePort = DeletePortW; +alias DeletePrinterConnection = DeletePrinterConnectionW; +alias DeletePrinterData = DeletePrinterDataW; +alias DeletePrinterDriver = DeletePrinterDriverW; +alias DeletePrintProcessor = DeletePrintProcessorW; +alias DeletePrintProvidor = DeletePrintProvidorW; +alias DocumentProperties = DocumentPropertiesW; +alias EnumForms = EnumFormsW; +alias EnumJobs = EnumJobsW; +alias EnumMonitors = EnumMonitorsW; +alias EnumPorts = EnumPortsW; +alias EnumPrinterData = EnumPrinterDataW; +alias EnumPrinterDrivers = EnumPrinterDriversW; +alias EnumPrinters = EnumPrintersW; +alias EnumPrintProcessorDatatypes = EnumPrintProcessorDatatypesW; +alias EnumPrintProcessors = EnumPrintProcessorsW; static if (_WIN32_WINNT >= 0x500) { -alias GetDefaultPrinterW GetDefaultPrinter; -} - -alias GetFormW GetForm; -alias GetJobW GetJob; -alias GetPrinterW GetPrinter; -alias GetPrinterDataW GetPrinterData; -alias GetPrinterDriverW GetPrinterDriver; -alias GetPrinterDriverDirectoryW GetPrinterDriverDirectory; -alias GetPrintProcessorDirectoryW GetPrintProcessorDirectory; -alias OpenPrinterW OpenPrinter; -alias PrinterMessageBoxW PrinterMessageBox; -alias ResetPrinterW ResetPrinter; -alias SetFormW SetForm; -alias SetJobW SetJob; -alias SetPrinterW SetPrinter; -alias SetPrinterDataW SetPrinterData; -alias StartDocPrinterW StartDocPrinter; +alias GetDefaultPrinter = GetDefaultPrinterW; +} + +alias GetForm = GetFormW; +alias GetJob = GetJobW; +alias GetPrinter = GetPrinterW; +alias GetPrinterData = GetPrinterDataW; +alias GetPrinterDriver = GetPrinterDriverW; +alias GetPrinterDriverDirectory = GetPrinterDriverDirectoryW; +alias GetPrintProcessorDirectory = GetPrintProcessorDirectoryW; +alias OpenPrinter = OpenPrinterW; +alias PrinterMessageBox = PrinterMessageBoxW; +alias ResetPrinter = ResetPrinterW; +alias SetForm = SetFormW; +alias SetJob = SetJobW; +alias SetPrinter = SetPrinterW; +alias SetPrinterData = SetPrinterDataW; +alias StartDocPrinter = StartDocPrinterW; } else { -alias JOB_INFO_1A JOB_INFO_1; -alias JOB_INFO_2A JOB_INFO_2; -alias ADDJOB_INFO_1A ADDJOB_INFO_1; -alias DATATYPES_INFO_1A DATATYPES_INFO_1; -alias MONITOR_INFO_1A MONITOR_INFO_1; -alias MONITOR_INFO_2A MONITOR_INFO_2; -alias DOC_INFO_1A DOC_INFO_1; -alias DOC_INFO_2A DOC_INFO_2; -alias PORT_INFO_1A PORT_INFO_1; -alias PORT_INFO_2A PORT_INFO_2; -alias PORT_INFO_3A PORT_INFO_3; -alias DRIVER_INFO_2A DRIVER_INFO_2; -alias PRINTER_INFO_1A PRINTER_INFO_1; -alias PRINTER_INFO_2A PRINTER_INFO_2; -alias PRINTER_INFO_4A PRINTER_INFO_4; -alias PRINTER_INFO_5A PRINTER_INFO_5; -alias PRINTPROCESSOR_INFO_1A PRINTPROCESSOR_INFO_1; -alias FORM_INFO_1A FORM_INFO_1; -alias PRINTER_DEFAULTSA PRINTER_DEFAULTS; - -alias AddFormA AddForm; -alias AddJobA AddJob; -alias AddMonitorA AddMonitor; -alias AddPortA AddPort; -alias AddPrinterA AddPrinter; -alias AddPrinterConnectionA AddPrinterConnection; -alias AddPrinterDriverA AddPrinterDriver; -alias AddPrintProcessorA AddPrintProcessor; -alias AddPrintProvidorA AddPrintProvidor; -alias AdvancedDocumentPropertiesA AdvancedDocumentProperties; -alias ConfigurePortA ConfigurePort; -alias DeleteFormA DeleteForm; -alias DeleteMonitorA DeleteMonitor; -alias DeletePortA DeletePort; -alias DeletePrinterConnectionA DeletePrinterConnection; -alias DeletePrinterDataA DeletePrinterData; -alias DeletePrinterDriverA DeletePrinterDriver; -alias DeletePrintProcessorA DeletePrintProcessor; -alias DeletePrintProvidorA DeletePrintProvidor; -alias DocumentPropertiesA DocumentProperties; -alias EnumFormsA EnumForms; -alias EnumJobsA EnumJobs; -alias EnumMonitorsA EnumMonitors; -alias EnumPortsA EnumPorts; -alias EnumPrinterDataA EnumPrinterData; -alias EnumPrinterDriversA EnumPrinterDrivers; -alias EnumPrintersA EnumPrinters; -alias EnumPrintProcessorDatatypesA EnumPrintProcessorDatatypes; -alias EnumPrintProcessorsA EnumPrintProcessors; +alias JOB_INFO_1 = JOB_INFO_1A; +alias JOB_INFO_2 = JOB_INFO_2A; +alias ADDJOB_INFO_1 = ADDJOB_INFO_1A; +alias DATATYPES_INFO_1 = DATATYPES_INFO_1A; +alias MONITOR_INFO_1 = MONITOR_INFO_1A; +alias MONITOR_INFO_2 = MONITOR_INFO_2A; +alias DOC_INFO_1 = DOC_INFO_1A; +alias DOC_INFO_2 = DOC_INFO_2A; +alias PORT_INFO_1 = PORT_INFO_1A; +alias PORT_INFO_2 = PORT_INFO_2A; +alias PORT_INFO_3 = PORT_INFO_3A; +alias DRIVER_INFO_2 = DRIVER_INFO_2A; +alias PRINTER_INFO_1 = PRINTER_INFO_1A; +alias PRINTER_INFO_2 = PRINTER_INFO_2A; +alias PRINTER_INFO_4 = PRINTER_INFO_4A; +alias PRINTER_INFO_5 = PRINTER_INFO_5A; +alias PRINTPROCESSOR_INFO_1 = PRINTPROCESSOR_INFO_1A; +alias FORM_INFO_1 = FORM_INFO_1A; +alias PRINTER_DEFAULTS = PRINTER_DEFAULTSA; + +alias AddForm = AddFormA; +alias AddJob = AddJobA; +alias AddMonitor = AddMonitorA; +alias AddPort = AddPortA; +alias AddPrinter = AddPrinterA; +alias AddPrinterConnection = AddPrinterConnectionA; +alias AddPrinterDriver = AddPrinterDriverA; +alias AddPrintProcessor = AddPrintProcessorA; +alias AddPrintProvidor = AddPrintProvidorA; +alias AdvancedDocumentProperties = AdvancedDocumentPropertiesA; +alias ConfigurePort = ConfigurePortA; +alias DeleteForm = DeleteFormA; +alias DeleteMonitor = DeleteMonitorA; +alias DeletePort = DeletePortA; +alias DeletePrinterConnection = DeletePrinterConnectionA; +alias DeletePrinterData = DeletePrinterDataA; +alias DeletePrinterDriver = DeletePrinterDriverA; +alias DeletePrintProcessor = DeletePrintProcessorA; +alias DeletePrintProvidor = DeletePrintProvidorA; +alias DocumentProperties = DocumentPropertiesA; +alias EnumForms = EnumFormsA; +alias EnumJobs = EnumJobsA; +alias EnumMonitors = EnumMonitorsA; +alias EnumPorts = EnumPortsA; +alias EnumPrinterData = EnumPrinterDataA; +alias EnumPrinterDrivers = EnumPrinterDriversA; +alias EnumPrinters = EnumPrintersA; +alias EnumPrintProcessorDatatypes = EnumPrintProcessorDatatypesA; +alias EnumPrintProcessors = EnumPrintProcessorsA; static if (_WIN32_WINNT >= 0x500) { -alias GetDefaultPrinterA GetDefaultPrinter; -} - -alias GetFormA GetForm; -alias GetJobA GetJob; -alias GetPrinterA GetPrinter; -alias GetPrinterDataA GetPrinterData; -alias GetPrinterDriverA GetPrinterDriver; -alias GetPrinterDriverDirectoryA GetPrinterDriverDirectory; -alias GetPrintProcessorDirectoryA GetPrintProcessorDirectory; -alias OpenPrinterA OpenPrinter; -alias PrinterMessageBoxA PrinterMessageBox; -alias ResetPrinterA ResetPrinter; -alias SetFormA SetForm; -alias SetJobA SetJob; -alias SetPrinterA SetPrinter; -alias SetPrinterDataA SetPrinterData; -alias StartDocPrinterA StartDocPrinter; -} - -alias JOB_INFO_1* PJOB_INFO_1, LPJOB_INFO_1; -alias JOB_INFO_2* PJOB_INFO_2, LPJOB_INFO_2; -alias ADDJOB_INFO_1* PADDJOB_INFO_1, LPADDJOB_INFO_1; -alias DATATYPES_INFO_1* PDATATYPES_INFO_1, LPDATATYPES_INFO_1; -alias MONITOR_INFO_1* PMONITOR_INFO_1, LPMONITOR_INFO_1; -alias MONITOR_INFO_2* PMONITOR_INFO_2, LPMONITOR_INFO_2; -alias DOC_INFO_1* PDOC_INFO_1, LPDOC_INFO_1; -alias DOC_INFO_2* PDOC_INFO_2, LPDOC_INFO_2; -alias PORT_INFO_1* PPORT_INFO_1, LPPORT_INFO_1; -alias PORT_INFO_2* PPORT_INFO_2, LPPORT_INFO_2; -alias PORT_INFO_3* PPORT_INFO_3, LPPORT_INFO_3; -alias DRIVER_INFO_2* PDRIVER_INFO_2, LPDRIVER_INFO_2; -alias PRINTER_INFO_1* PPRINTER_INFO_1, LPPRINTER_INFO_1; -alias PRINTER_INFO_2* PPRINTER_INFO_2, LPPRINTER_INFO_2; -alias PRINTER_INFO_4* PPRINTER_INFO_4, LPPRINTER_INFO_4; -alias PRINTER_INFO_5* PPRINTER_INFO_5, LPPRINTER_INFO_5; -alias PRINTPROCESSOR_INFO_1* PPRINTPROCESSOR_INFO_1, LPPRINTPROCESSOR_INFO_1; -alias FORM_INFO_1* PFORM_INFO_1, LPFORM_INFO_1; -alias PRINTER_DEFAULTS* PPRINTER_DEFAULTS, LPPRINTER_DEFAULTS; +alias GetDefaultPrinter = GetDefaultPrinterA; +} + +alias GetForm = GetFormA; +alias GetJob = GetJobA; +alias GetPrinter = GetPrinterA; +alias GetPrinterData = GetPrinterDataA; +alias GetPrinterDriver = GetPrinterDriverA; +alias GetPrinterDriverDirectory = GetPrinterDriverDirectoryA; +alias GetPrintProcessorDirectory = GetPrintProcessorDirectoryA; +alias OpenPrinter = OpenPrinterA; +alias PrinterMessageBox = PrinterMessageBoxA; +alias ResetPrinter = ResetPrinterA; +alias SetForm = SetFormA; +alias SetJob = SetJobA; +alias SetPrinter = SetPrinterA; +alias SetPrinterData = SetPrinterDataA; +alias StartDocPrinter = StartDocPrinterA; +} + +alias PJOB_INFO_1 = JOB_INFO_1*, LPJOB_INFO_1 = JOB_INFO_1*; +alias PJOB_INFO_2 = JOB_INFO_2*, LPJOB_INFO_2 = JOB_INFO_2*; +alias PADDJOB_INFO_1 = ADDJOB_INFO_1*, LPADDJOB_INFO_1 = ADDJOB_INFO_1*; +alias PDATATYPES_INFO_1 = DATATYPES_INFO_1*, LPDATATYPES_INFO_1 = DATATYPES_INFO_1*; +alias PMONITOR_INFO_1 = MONITOR_INFO_1*, LPMONITOR_INFO_1 = MONITOR_INFO_1*; +alias PMONITOR_INFO_2 = MONITOR_INFO_2*, LPMONITOR_INFO_2 = MONITOR_INFO_2*; +alias PDOC_INFO_1 = DOC_INFO_1*, LPDOC_INFO_1 = DOC_INFO_1*; +alias PDOC_INFO_2 = DOC_INFO_2*, LPDOC_INFO_2 = DOC_INFO_2*; +alias PPORT_INFO_1 = PORT_INFO_1*, LPPORT_INFO_1 = PORT_INFO_1*; +alias PPORT_INFO_2 = PORT_INFO_2*, LPPORT_INFO_2 = PORT_INFO_2*; +alias PPORT_INFO_3 = PORT_INFO_3*, LPPORT_INFO_3 = PORT_INFO_3*; +alias PDRIVER_INFO_2 = DRIVER_INFO_2*, LPDRIVER_INFO_2 = DRIVER_INFO_2*; +alias PPRINTER_INFO_1 = PRINTER_INFO_1*, LPPRINTER_INFO_1 = PRINTER_INFO_1*; +alias PPRINTER_INFO_2 = PRINTER_INFO_2*, LPPRINTER_INFO_2 = PRINTER_INFO_2*; +alias PPRINTER_INFO_4 = PRINTER_INFO_4*, LPPRINTER_INFO_4 = PRINTER_INFO_4*; +alias PPRINTER_INFO_5 = PRINTER_INFO_5*, LPPRINTER_INFO_5 = PRINTER_INFO_5*; +alias PPRINTPROCESSOR_INFO_1 = PRINTPROCESSOR_INFO_1*, LPPRINTPROCESSOR_INFO_1 = PRINTPROCESSOR_INFO_1*; +alias PFORM_INFO_1 = FORM_INFO_1*, LPFORM_INFO_1 = FORM_INFO_1*; +alias PPRINTER_DEFAULTS = PRINTER_DEFAULTS*, LPPRINTER_DEFAULTS = PRINTER_DEFAULTS*; diff --git a/runtime/druntime/src/core/sys/windows/winsvc.d b/runtime/druntime/src/core/sys/windows/winsvc.d index a34cd25820..248bd2a0a9 100644 --- a/runtime/druntime/src/core/sys/windows/winsvc.d +++ b/runtime/druntime/src/core/sys/windows/winsvc.d @@ -111,21 +111,21 @@ struct SERVICE_STATUS { DWORD dwCheckPoint; DWORD dwWaitHint; } -alias SERVICE_STATUS* LPSERVICE_STATUS; +alias LPSERVICE_STATUS = SERVICE_STATUS*; struct ENUM_SERVICE_STATUSA { LPSTR lpServiceName; LPSTR lpDisplayName; SERVICE_STATUS ServiceStatus; } -alias ENUM_SERVICE_STATUSA* LPENUM_SERVICE_STATUSA; +alias LPENUM_SERVICE_STATUSA = ENUM_SERVICE_STATUSA*; struct ENUM_SERVICE_STATUSW { LPWSTR lpServiceName; LPWSTR lpDisplayName; SERVICE_STATUS ServiceStatus; } -alias ENUM_SERVICE_STATUSW* LPENUM_SERVICE_STATUSW; +alias LPENUM_SERVICE_STATUSW = ENUM_SERVICE_STATUSW*; struct QUERY_SERVICE_CONFIGA { DWORD dwServiceType; @@ -138,7 +138,7 @@ struct QUERY_SERVICE_CONFIGA { LPSTR lpServiceStartName; LPSTR lpDisplayName; } -alias QUERY_SERVICE_CONFIGA* LPQUERY_SERVICE_CONFIGA; +alias LPQUERY_SERVICE_CONFIGA = QUERY_SERVICE_CONFIGA*; struct QUERY_SERVICE_CONFIGW { DWORD dwServiceType; @@ -151,47 +151,47 @@ struct QUERY_SERVICE_CONFIGW { LPWSTR lpServiceStartName; LPWSTR lpDisplayName; } -alias QUERY_SERVICE_CONFIGW* LPQUERY_SERVICE_CONFIGW; +alias LPQUERY_SERVICE_CONFIGW = QUERY_SERVICE_CONFIGW*; struct QUERY_SERVICE_LOCK_STATUSA { DWORD fIsLocked; LPSTR lpLockOwner; DWORD dwLockDuration; } -alias QUERY_SERVICE_LOCK_STATUSA* LPQUERY_SERVICE_LOCK_STATUSA; +alias LPQUERY_SERVICE_LOCK_STATUSA = QUERY_SERVICE_LOCK_STATUSA*; struct QUERY_SERVICE_LOCK_STATUSW { DWORD fIsLocked; LPWSTR lpLockOwner; DWORD dwLockDuration; } -alias QUERY_SERVICE_LOCK_STATUSW* LPQUERY_SERVICE_LOCK_STATUSW; +alias LPQUERY_SERVICE_LOCK_STATUSW = QUERY_SERVICE_LOCK_STATUSW*; extern (Windows) { - alias void function(DWORD, LPSTR*) LPSERVICE_MAIN_FUNCTIONA; - alias void function(DWORD, LPWSTR*) LPSERVICE_MAIN_FUNCTIONW; + alias LPSERVICE_MAIN_FUNCTIONA = void function(DWORD, LPSTR*); + alias LPSERVICE_MAIN_FUNCTIONW = void function(DWORD, LPWSTR*); } struct SERVICE_TABLE_ENTRYA { LPSTR lpServiceName; LPSERVICE_MAIN_FUNCTIONA lpServiceProc; } -alias SERVICE_TABLE_ENTRYA* LPSERVICE_TABLE_ENTRYA; +alias LPSERVICE_TABLE_ENTRYA = SERVICE_TABLE_ENTRYA*; struct SERVICE_TABLE_ENTRYW { LPWSTR lpServiceName; LPSERVICE_MAIN_FUNCTIONW lpServiceProc; } -alias SERVICE_TABLE_ENTRYW* LPSERVICE_TABLE_ENTRYW; +alias LPSERVICE_TABLE_ENTRYW = SERVICE_TABLE_ENTRYW*; alias SC_HANDLE = HANDLE; -alias SC_HANDLE* LPSC_HANDLE; -alias void* SC_LOCK; +alias LPSC_HANDLE = SC_HANDLE*; +alias SC_LOCK = void*; alias SERVICE_STATUS_HANDLE = HANDLE; extern (Windows) { - alias void function(DWORD) LPHANDLER_FUNCTION; - alias DWORD function(DWORD, DWORD, LPVOID, LPVOID) LPHANDLER_FUNCTION_EX; + alias LPHANDLER_FUNCTION = void function(DWORD); + alias LPHANDLER_FUNCTION_EX = DWORD function(DWORD, DWORD, LPVOID, LPVOID); } static if (_WIN32_WINNT >= 0x500) { @@ -206,7 +206,7 @@ static if (_WIN32_WINNT >= 0x500) { DWORD dwProcessId; DWORD dwServiceFlags; } - alias SERVICE_STATUS_PROCESS* LPSERVICE_STATUS_PROCESS; + alias LPSERVICE_STATUS_PROCESS = SERVICE_STATUS_PROCESS*; enum SC_STATUS_TYPE { SC_STATUS_PROCESS_INFO = 0 @@ -221,24 +221,24 @@ static if (_WIN32_WINNT >= 0x500) { LPSTR lpDisplayName; SERVICE_STATUS_PROCESS ServiceStatusProcess; } - alias ENUM_SERVICE_STATUS_PROCESSA* LPENUM_SERVICE_STATUS_PROCESSA; + alias LPENUM_SERVICE_STATUS_PROCESSA = ENUM_SERVICE_STATUS_PROCESSA*; struct ENUM_SERVICE_STATUS_PROCESSW { LPWSTR lpServiceName; LPWSTR lpDisplayName; SERVICE_STATUS_PROCESS ServiceStatusProcess; } - alias ENUM_SERVICE_STATUS_PROCESSW* LPENUM_SERVICE_STATUS_PROCESSW; + alias LPENUM_SERVICE_STATUS_PROCESSW = ENUM_SERVICE_STATUS_PROCESSW*; struct SERVICE_DESCRIPTIONA { LPSTR lpDescription; } - alias SERVICE_DESCRIPTIONA* LPSERVICE_DESCRIPTIONA; + alias LPSERVICE_DESCRIPTIONA = SERVICE_DESCRIPTIONA*; struct SERVICE_DESCRIPTIONW { LPWSTR lpDescription; } - alias SERVICE_DESCRIPTIONW* LPSERVICE_DESCRIPTIONW; + alias LPSERVICE_DESCRIPTIONW = SERVICE_DESCRIPTIONW*; enum SC_ACTION_TYPE { SC_ACTION_NONE, @@ -251,7 +251,7 @@ static if (_WIN32_WINNT >= 0x500) { SC_ACTION_TYPE Type; DWORD Delay; } - alias SC_ACTION* LPSC_ACTION; + alias LPSC_ACTION = SC_ACTION*; struct SERVICE_FAILURE_ACTIONSA { DWORD dwResetPeriod; @@ -260,7 +260,7 @@ static if (_WIN32_WINNT >= 0x500) { DWORD cActions; SC_ACTION* lpsaActions; } - alias SERVICE_FAILURE_ACTIONSA* LPSERVICE_FAILURE_ACTIONSA; + alias LPSERVICE_FAILURE_ACTIONSA = SERVICE_FAILURE_ACTIONSA*; struct SERVICE_FAILURE_ACTIONSW { DWORD dwResetPeriod; @@ -269,7 +269,7 @@ static if (_WIN32_WINNT >= 0x500) { DWORD cActions; SC_ACTION* lpsaActions; } - alias SERVICE_FAILURE_ACTIONSW* LPSERVICE_FAILURE_ACTIONSW; + alias LPSERVICE_FAILURE_ACTIONSW = SERVICE_FAILURE_ACTIONSW*; } extern (Windows) nothrow @nogc { @@ -348,80 +348,80 @@ extern (Windows) nothrow @nogc { } version (Unicode) { - alias ENUM_SERVICE_STATUSW ENUM_SERVICE_STATUS; - alias QUERY_SERVICE_CONFIGW QUERY_SERVICE_CONFIG; - alias QUERY_SERVICE_LOCK_STATUSW QUERY_SERVICE_LOCK_STATUS; - alias LPSERVICE_MAIN_FUNCTIONW LPSERVICE_MAIN_FUNCTION; - alias SERVICE_TABLE_ENTRYW SERVICE_TABLE_ENTRY; - alias ChangeServiceConfigW ChangeServiceConfig; - alias CreateServiceW CreateService; - alias EnumDependentServicesW EnumDependentServices; - alias EnumServicesStatusW EnumServicesStatus; - alias GetServiceDisplayNameW GetServiceDisplayName; - alias GetServiceKeyNameW GetServiceKeyName; - alias OpenSCManagerW OpenSCManager; - alias OpenServiceW OpenService; - alias QueryServiceConfigW QueryServiceConfig; - alias QueryServiceLockStatusW QueryServiceLockStatus; - alias RegisterServiceCtrlHandlerW RegisterServiceCtrlHandler; - alias StartServiceW StartService; - alias StartServiceCtrlDispatcherW StartServiceCtrlDispatcher; + alias ENUM_SERVICE_STATUS = ENUM_SERVICE_STATUSW; + alias QUERY_SERVICE_CONFIG = QUERY_SERVICE_CONFIGW; + alias QUERY_SERVICE_LOCK_STATUS = QUERY_SERVICE_LOCK_STATUSW; + alias LPSERVICE_MAIN_FUNCTION = LPSERVICE_MAIN_FUNCTIONW; + alias SERVICE_TABLE_ENTRY = SERVICE_TABLE_ENTRYW; + alias ChangeServiceConfig = ChangeServiceConfigW; + alias CreateService = CreateServiceW; + alias EnumDependentServices = EnumDependentServicesW; + alias EnumServicesStatus = EnumServicesStatusW; + alias GetServiceDisplayName = GetServiceDisplayNameW; + alias GetServiceKeyName = GetServiceKeyNameW; + alias OpenSCManager = OpenSCManagerW; + alias OpenService = OpenServiceW; + alias QueryServiceConfig = QueryServiceConfigW; + alias QueryServiceLockStatus = QueryServiceLockStatusW; + alias RegisterServiceCtrlHandler = RegisterServiceCtrlHandlerW; + alias StartService = StartServiceW; + alias StartServiceCtrlDispatcher = StartServiceCtrlDispatcherW; static if (_WIN32_WINNT >= 0x500) { - alias ENUM_SERVICE_STATUS_PROCESSW ENUM_SERVICE_STATUS_PROCESS; - alias SERVICE_DESCRIPTIONW SERVICE_DESCRIPTION; - alias SERVICE_FAILURE_ACTIONSW SERVICE_FAILURE_ACTIONS; - alias EnumServicesStatusExW EnumServicesStatusEx; - alias QueryServiceConfig2W QueryServiceConfig2; - alias RegisterServiceCtrlHandlerExW RegisterServiceCtrlHandlerEx; + alias ENUM_SERVICE_STATUS_PROCESS = ENUM_SERVICE_STATUS_PROCESSW; + alias SERVICE_DESCRIPTION = SERVICE_DESCRIPTIONW; + alias SERVICE_FAILURE_ACTIONS = SERVICE_FAILURE_ACTIONSW; + alias EnumServicesStatusEx = EnumServicesStatusExW; + alias QueryServiceConfig2 = QueryServiceConfig2W; + alias RegisterServiceCtrlHandlerEx = RegisterServiceCtrlHandlerExW; } static if (_WIN32_WINNT >= 0x501) { - alias ChangeServiceConfig2W ChangeServiceConfig2; + alias ChangeServiceConfig2 = ChangeServiceConfig2W; } } else { - alias ENUM_SERVICE_STATUSA ENUM_SERVICE_STATUS; - alias QUERY_SERVICE_CONFIGA QUERY_SERVICE_CONFIG; - alias QUERY_SERVICE_LOCK_STATUSA QUERY_SERVICE_LOCK_STATUS; - alias LPSERVICE_MAIN_FUNCTIONA LPSERVICE_MAIN_FUNCTION; - alias SERVICE_TABLE_ENTRYA SERVICE_TABLE_ENTRY; - alias ChangeServiceConfigA ChangeServiceConfig; - alias CreateServiceA CreateService; - alias EnumDependentServicesA EnumDependentServices; - alias EnumServicesStatusA EnumServicesStatus; - alias GetServiceDisplayNameA GetServiceDisplayName; - alias GetServiceKeyNameA GetServiceKeyName; - alias OpenSCManagerA OpenSCManager; - alias OpenServiceA OpenService; - alias QueryServiceConfigA QueryServiceConfig; - alias QueryServiceLockStatusA QueryServiceLockStatus; - alias RegisterServiceCtrlHandlerA RegisterServiceCtrlHandler; - alias StartServiceA StartService; - alias StartServiceCtrlDispatcherA StartServiceCtrlDispatcher; + alias ENUM_SERVICE_STATUS = ENUM_SERVICE_STATUSA; + alias QUERY_SERVICE_CONFIG = QUERY_SERVICE_CONFIGA; + alias QUERY_SERVICE_LOCK_STATUS = QUERY_SERVICE_LOCK_STATUSA; + alias LPSERVICE_MAIN_FUNCTION = LPSERVICE_MAIN_FUNCTIONA; + alias SERVICE_TABLE_ENTRY = SERVICE_TABLE_ENTRYA; + alias ChangeServiceConfig = ChangeServiceConfigA; + alias CreateService = CreateServiceA; + alias EnumDependentServices = EnumDependentServicesA; + alias EnumServicesStatus = EnumServicesStatusA; + alias GetServiceDisplayName = GetServiceDisplayNameA; + alias GetServiceKeyName = GetServiceKeyNameA; + alias OpenSCManager = OpenSCManagerA; + alias OpenService = OpenServiceA; + alias QueryServiceConfig = QueryServiceConfigA; + alias QueryServiceLockStatus = QueryServiceLockStatusA; + alias RegisterServiceCtrlHandler = RegisterServiceCtrlHandlerA; + alias StartService = StartServiceA; + alias StartServiceCtrlDispatcher = StartServiceCtrlDispatcherA; static if (_WIN32_WINNT >= 0x500) { - alias ENUM_SERVICE_STATUS_PROCESSA ENUM_SERVICE_STATUS_PROCESS; - alias SERVICE_DESCRIPTIONA SERVICE_DESCRIPTION; - alias SERVICE_FAILURE_ACTIONSA SERVICE_FAILURE_ACTIONS; - alias EnumServicesStatusExA EnumServicesStatusEx; - alias QueryServiceConfig2A QueryServiceConfig2; - alias RegisterServiceCtrlHandlerExA RegisterServiceCtrlHandlerEx; + alias ENUM_SERVICE_STATUS_PROCESS = ENUM_SERVICE_STATUS_PROCESSA; + alias SERVICE_DESCRIPTION = SERVICE_DESCRIPTIONA; + alias SERVICE_FAILURE_ACTIONS = SERVICE_FAILURE_ACTIONSA; + alias EnumServicesStatusEx = EnumServicesStatusExA; + alias QueryServiceConfig2 = QueryServiceConfig2A; + alias RegisterServiceCtrlHandlerEx = RegisterServiceCtrlHandlerExA; } static if (_WIN32_WINNT >= 0x501) { - alias ChangeServiceConfig2A ChangeServiceConfig2; + alias ChangeServiceConfig2 = ChangeServiceConfig2A; } } -alias ENUM_SERVICE_STATUS* LPENUM_SERVICE_STATUS; -alias QUERY_SERVICE_CONFIG* LPQUERY_SERVICE_CONFIG; -alias QUERY_SERVICE_LOCK_STATUS* LPQUERY_SERVICE_LOCK_STATUS; -alias SERVICE_TABLE_ENTRY* LPSERVICE_TABLE_ENTRY; +alias LPENUM_SERVICE_STATUS = ENUM_SERVICE_STATUS*; +alias LPQUERY_SERVICE_CONFIG = QUERY_SERVICE_CONFIG*; +alias LPQUERY_SERVICE_LOCK_STATUS = QUERY_SERVICE_LOCK_STATUS*; +alias LPSERVICE_TABLE_ENTRY = SERVICE_TABLE_ENTRY*; static if (_WIN32_WINNT >= 0x500) { - alias ENUM_SERVICE_STATUS_PROCESS* LPENUM_SERVICE_STATUS_PROCESS; - alias SERVICE_DESCRIPTION* LPSERVICE_DESCRIPTION; - alias SERVICE_FAILURE_ACTIONS* LPSERVICE_FAILURE_ACTIONS; + alias LPENUM_SERVICE_STATUS_PROCESS = ENUM_SERVICE_STATUS_PROCESS*; + alias LPSERVICE_DESCRIPTION = SERVICE_DESCRIPTION*; + alias LPSERVICE_FAILURE_ACTIONS = SERVICE_FAILURE_ACTIONS*; } diff --git a/runtime/druntime/src/core/sys/windows/winuser.d b/runtime/druntime/src/core/sys/windows/winuser.d index a7917b774f..dddaeb0535 100644 --- a/runtime/druntime/src/core/sys/windows/winuser.d +++ b/runtime/druntime/src/core/sys/windows/winuser.d @@ -721,13 +721,13 @@ enum GCL_MENUNAME = -8; enum GCL_STYLE = -26; enum GCL_WNDPROC = -24; -alias GCL_HICONSM GCLP_HICONSM; -alias GCL_HICON GCLP_HICON; -alias GCL_HCURSOR GCLP_HCURSOR; -alias GCL_HBRBACKGROUND GCLP_HBRBACKGROUND; -alias GCL_HMODULE GCLP_HMODULE; -alias GCL_MENUNAME GCLP_MENUNAME; -alias GCL_WNDPROC GCLP_WNDPROC; +alias GCLP_HICONSM = GCL_HICONSM; +alias GCLP_HICON = GCL_HICON; +alias GCLP_HCURSOR = GCL_HCURSOR; +alias GCLP_HBRBACKGROUND = GCL_HBRBACKGROUND; +alias GCLP_HMODULE = GCL_HMODULE; +alias GCLP_MENUNAME = GCL_MENUNAME; +alias GCLP_WNDPROC = GCL_WNDPROC; enum { IDC_ARROW = MAKEINTRESOURCE_T!(32512), @@ -2468,31 +2468,31 @@ enum { // Callbacks // --------- extern (Windows) nothrow { - alias INT_PTR function(HWND, UINT, WPARAM, LPARAM) DLGPROC; - alias void function(HWND, UINT, UINT_PTR, DWORD) TIMERPROC; - alias BOOL function(HDC, LPARAM, int) GRAYSTRINGPROC; - alias LRESULT function(int, WPARAM, LPARAM) HOOKPROC; - alias BOOL function(HWND, LPCSTR, HANDLE) PROPENUMPROCA; - alias BOOL function(HWND, LPCWSTR, HANDLE) PROPENUMPROCW; - alias BOOL function(HWND, LPSTR, HANDLE, ULONG_PTR) PROPENUMPROCEXA; - alias BOOL function(HWND, LPWSTR, HANDLE, ULONG_PTR) PROPENUMPROCEXW; - alias int function(LPSTR, int, int, int) EDITWORDBREAKPROCA; - alias int function(LPWSTR, int, int, int) EDITWORDBREAKPROCW; - alias LRESULT function(HWND, UINT, WPARAM, LPARAM) WNDPROC; - alias BOOL function(HDC, LPARAM, WPARAM, int, int) DRAWSTATEPROC; - alias BOOL function(HWND, LPARAM) WNDENUMPROC; - alias BOOL function(HWND, LPARAM) ENUMWINDOWSPROC; - alias void function(LPHELPINFO) MSGBOXCALLBACK; - - alias BOOL function(HMONITOR, HDC, LPRECT, LPARAM) MONITORENUMPROC; - alias BOOL function(LPSTR, LPARAM) NAMEENUMPROCA; - alias BOOL function(LPWSTR, LPARAM) NAMEENUMPROCW; - alias void function(HWND, UINT, ULONG_PTR, LRESULT) SENDASYNCPROC; - - alias NAMEENUMPROCA DESKTOPENUMPROCA; - alias NAMEENUMPROCW DESKTOPENUMPROCW; - alias NAMEENUMPROCA WINSTAENUMPROCA; - alias NAMEENUMPROCW WINSTAENUMPROCW; + alias DLGPROC = INT_PTR function(HWND, UINT, WPARAM, LPARAM); + alias TIMERPROC = void function(HWND, UINT, UINT_PTR, DWORD); + alias GRAYSTRINGPROC = BOOL function(HDC, LPARAM, int); + alias HOOKPROC = LRESULT function(int, WPARAM, LPARAM); + alias PROPENUMPROCA = BOOL function(HWND, LPCSTR, HANDLE); + alias PROPENUMPROCW = BOOL function(HWND, LPCWSTR, HANDLE); + alias PROPENUMPROCEXA = BOOL function(HWND, LPSTR, HANDLE, ULONG_PTR); + alias PROPENUMPROCEXW = BOOL function(HWND, LPWSTR, HANDLE, ULONG_PTR); + alias EDITWORDBREAKPROCA = int function(LPSTR, int, int, int); + alias EDITWORDBREAKPROCW = int function(LPWSTR, int, int, int); + alias WNDPROC = LRESULT function(HWND, UINT, WPARAM, LPARAM); + alias DRAWSTATEPROC = BOOL function(HDC, LPARAM, WPARAM, int, int); + alias WNDENUMPROC = BOOL function(HWND, LPARAM); + alias ENUMWINDOWSPROC = BOOL function(HWND, LPARAM); + alias MSGBOXCALLBACK = void function(LPHELPINFO); + + alias MONITORENUMPROC = BOOL function(HMONITOR, HDC, LPRECT, LPARAM); + alias NAMEENUMPROCA = BOOL function(LPSTR, LPARAM); + alias NAMEENUMPROCW = BOOL function(LPWSTR, LPARAM); + alias SENDASYNCPROC = void function(HWND, UINT, ULONG_PTR, LRESULT); + + alias DESKTOPENUMPROCA = NAMEENUMPROCA; + alias DESKTOPENUMPROCW = NAMEENUMPROCW; + alias WINSTAENUMPROCA = NAMEENUMPROCA; + alias WINSTAENUMPROCW = NAMEENUMPROCW; } alias HDWP = HANDLE; @@ -2505,27 +2505,27 @@ struct MENUGETOBJECTINFO { PVOID riid; PVOID pvObj; } -alias MENUGETOBJECTINFO* PMENUGETOBJECTINFO; +alias PMENUGETOBJECTINFO = MENUGETOBJECTINFO*; struct ACCEL { BYTE fVirt; WORD key; WORD cmd; } -alias ACCEL* LPACCEL; +alias LPACCEL = ACCEL*; struct ACCESSTIMEOUT { UINT cbSize = ACCESSTIMEOUT.sizeof; DWORD dwFlags; DWORD iTimeOutMSec; } -alias ACCESSTIMEOUT* LPACCESSTIMEOUT; +alias LPACCESSTIMEOUT = ACCESSTIMEOUT*; struct ANIMATIONINFO { UINT cbSize = ANIMATIONINFO.sizeof; int iMinAnimate; } -alias ANIMATIONINFO* LPANIMATIONINFO; +alias LPANIMATIONINFO = ANIMATIONINFO*; struct CREATESTRUCTA { LPVOID lpCreateParams; @@ -2541,7 +2541,7 @@ struct CREATESTRUCTA { LPCSTR lpszClass; DWORD dwExStyle; } -alias CREATESTRUCTA* LPCREATESTRUCTA; +alias LPCREATESTRUCTA = CREATESTRUCTA*; struct CREATESTRUCTW { LPVOID lpCreateParams; @@ -2557,25 +2557,25 @@ struct CREATESTRUCTW { LPCWSTR lpszClass; DWORD dwExStyle; } -alias CREATESTRUCTW* LPCREATESTRUCTW; +alias LPCREATESTRUCTW = CREATESTRUCTW*; struct CBT_CREATEWNDA { LPCREATESTRUCTA lpcs; HWND hwndInsertAfter; } -alias CBT_CREATEWNDA* LPCBT_CREATEWNDA; +alias LPCBT_CREATEWNDA = CBT_CREATEWNDA*; struct CBT_CREATEWNDW { LPCREATESTRUCTW lpcs; HWND hwndInsertAfter; } -alias CBT_CREATEWNDW* LPCBT_CREATEWNDW; +alias LPCBT_CREATEWNDW = CBT_CREATEWNDW*; struct CBTACTIVATESTRUCT { BOOL fMouse; HWND hWndActive; } -alias CBTACTIVATESTRUCT* LPCBTACTIVATESTRUCT; +alias LPCBTACTIVATESTRUCT = CBTACTIVATESTRUCT*; static if (_WIN32_WINNT >= 0x501) { @@ -2584,7 +2584,7 @@ struct WTSSESSION_NOTIFICATION DWORD cbSize; DWORD dwSessionId; } -alias WTSSESSION_NOTIFICATION* PWTSSESSION_NOTIFICATION; +alias PWTSSESSION_NOTIFICATION = WTSSESSION_NOTIFICATION*; } @@ -2592,7 +2592,7 @@ struct CLIENTCREATESTRUCT { HANDLE hWindowMenu; UINT idFirstChild; } -alias CLIENTCREATESTRUCT* LPCLIENTCREATESTRUCT; +alias LPCLIENTCREATESTRUCT = CLIENTCREATESTRUCT*; struct COMPAREITEMSTRUCT { UINT CtlType; @@ -2604,14 +2604,14 @@ struct COMPAREITEMSTRUCT { ULONG_PTR itemData2; DWORD dwLocaleId; } -alias COMPAREITEMSTRUCT* LPCOMPAREITEMSTRUCT; +alias LPCOMPAREITEMSTRUCT = COMPAREITEMSTRUCT*; struct COPYDATASTRUCT { ULONG_PTR dwData; DWORD cbData; PVOID lpData; } -alias COPYDATASTRUCT* PCOPYDATASTRUCT; +alias PCOPYDATASTRUCT = COPYDATASTRUCT*; struct CURSORSHAPE { int xHotSpot; @@ -2622,7 +2622,7 @@ struct CURSORSHAPE { BYTE Planes; BYTE BitsPixel; } -alias CURSORSHAPE* LPCURSORSHAPE; +alias LPCURSORSHAPE = CURSORSHAPE*; struct CWPRETSTRUCT { LRESULT lResult; @@ -2638,7 +2638,7 @@ struct CWPSTRUCT { UINT message; HWND hwnd; } -alias CWPSTRUCT* PCWPSTRUCT; +alias PCWPSTRUCT = CWPSTRUCT*; struct DEBUGHOOKINFO { DWORD idThread; @@ -2647,7 +2647,7 @@ struct DEBUGHOOKINFO { WPARAM wParam; int code; } -alias DEBUGHOOKINFO* PDEBUGHOOKINFO, LPDEBUGHOOKINFO; +alias PDEBUGHOOKINFO = DEBUGHOOKINFO*, LPDEBUGHOOKINFO = DEBUGHOOKINFO*; struct DELETEITEMSTRUCT { UINT CtlType; @@ -2656,7 +2656,7 @@ struct DELETEITEMSTRUCT { HWND hwndItem; ULONG_PTR itemData; } -alias DELETEITEMSTRUCT* PDELETEITEMSTRUCT, LPDELETEITEMSTRUCT; +alias PDELETEITEMSTRUCT = DELETEITEMSTRUCT*, LPDELETEITEMSTRUCT = DELETEITEMSTRUCT*; align(2): struct DLGITEMTEMPLATE { @@ -2668,7 +2668,7 @@ struct DLGITEMTEMPLATE { short cy; WORD id; } -alias DLGITEMTEMPLATE* LPDLGITEMTEMPLATE; +alias LPDLGITEMTEMPLATE = DLGITEMTEMPLATE*; struct DLGTEMPLATE { DWORD style; @@ -2679,8 +2679,8 @@ struct DLGTEMPLATE { short cx; short cy; } -alias DLGTEMPLATE* LPDLGTEMPLATE, LPDLGTEMPLATEA, LPDLGTEMPLATEW; -alias const(DLGTEMPLATE)* LPCDLGTEMPLATE, LPCDLGTEMPLATEA, LPCDLGTEMPLATEW; +alias LPDLGTEMPLATE = DLGTEMPLATE*, LPDLGTEMPLATEA = DLGTEMPLATE*, LPDLGTEMPLATEW = DLGTEMPLATE*; +alias LPCDLGTEMPLATE = const(DLGTEMPLATE)*, LPCDLGTEMPLATEA = const(DLGTEMPLATE)*, LPCDLGTEMPLATEW = const(DLGTEMPLATE)*; align: @@ -2695,7 +2695,7 @@ struct DRAWITEMSTRUCT { RECT rcItem; ULONG_PTR itemData; } -alias DRAWITEMSTRUCT* LPDRAWITEMSTRUCT, PDRAWITEMSTRUCT; +alias LPDRAWITEMSTRUCT = DRAWITEMSTRUCT*, PDRAWITEMSTRUCT = DRAWITEMSTRUCT*; struct DRAWTEXTPARAMS { UINT cbSize = DRAWTEXTPARAMS.sizeof; @@ -2704,7 +2704,7 @@ struct DRAWTEXTPARAMS { int iRightMargin; UINT uiLengthDrawn; } -alias DRAWTEXTPARAMS* LPDRAWTEXTPARAMS; +alias LPDRAWTEXTPARAMS = DRAWTEXTPARAMS*; struct PAINTSTRUCT { HDC hdc; @@ -2714,7 +2714,7 @@ struct PAINTSTRUCT { BOOL fIncUpdate; BYTE[32] rgbReserved; } -alias PAINTSTRUCT* PPAINTSTRUCT, NPPAINTSTRUCT, LPPAINTSTRUCT; +alias PPAINTSTRUCT = PAINTSTRUCT*, NPPAINTSTRUCT = PAINTSTRUCT*, LPPAINTSTRUCT = PAINTSTRUCT*; struct MSG { HWND hwnd; @@ -2724,7 +2724,7 @@ struct MSG { DWORD time; POINT pt; } -alias MSG* NPMSG, LPMSG, PMSG; +alias NPMSG = MSG*, LPMSG = MSG*, PMSG = MSG*; struct ICONINFO { BOOL fIcon; @@ -2733,14 +2733,14 @@ struct ICONINFO { HBITMAP hbmMask; HBITMAP hbmColor; } -alias ICONINFO* PICONINFO; +alias PICONINFO = ICONINFO*; struct NMHDR { HWND hwndFrom; UINT_PTR idFrom; UINT code; } -alias NMHDR* LPNMHDR; +alias LPNMHDR = NMHDR*; struct WNDCLASSA { UINT style; @@ -2754,7 +2754,7 @@ struct WNDCLASSA { LPCSTR lpszMenuName; LPCSTR lpszClassName; } -alias WNDCLASSA* NPWNDCLASSA, LPWNDCLASSA, PWNDCLASSA; +alias NPWNDCLASSA = WNDCLASSA*, LPWNDCLASSA = WNDCLASSA*, PWNDCLASSA = WNDCLASSA*; struct WNDCLASSW { UINT style; @@ -2768,7 +2768,7 @@ struct WNDCLASSW { LPCWSTR lpszMenuName; LPCWSTR lpszClassName; } -alias WNDCLASSW* NPWNDCLASSW, LPWNDCLASSW, PWNDCLASSW; +alias NPWNDCLASSW = WNDCLASSW*, LPWNDCLASSW = WNDCLASSW*, PWNDCLASSW = WNDCLASSW*; struct WNDCLASSEXA { UINT cbSize = WNDCLASSEXA.sizeof; @@ -2784,7 +2784,7 @@ struct WNDCLASSEXA { LPCSTR lpszClassName; HICON hIconSm; } -alias WNDCLASSEXA* NPWNDCLASSEXA, LPWNDCLASSEXA, PWNDCLASSEXA; +alias NPWNDCLASSEXA = WNDCLASSEXA*, LPWNDCLASSEXA = WNDCLASSEXA*, PWNDCLASSEXA = WNDCLASSEXA*; struct WNDCLASSEXW { UINT cbSize = WNDCLASSEXW.sizeof; @@ -2800,7 +2800,7 @@ struct WNDCLASSEXW { LPCWSTR lpszClassName; HICON hIconSm; } -alias WNDCLASSEXW* LPWNDCLASSEXW, PWNDCLASSEXW; +alias LPWNDCLASSEXW = WNDCLASSEXW*, PWNDCLASSEXW = WNDCLASSEXW*; struct MENUITEMINFOA { UINT cbSize = MENUITEMINFOA.sizeof; @@ -2816,8 +2816,8 @@ struct MENUITEMINFOA { UINT cch; HBITMAP hbmpItem; } -alias MENUITEMINFOA* LPMENUITEMINFOA; -alias const(MENUITEMINFOA)* LPCMENUITEMINFOA; +alias LPMENUITEMINFOA = MENUITEMINFOA*; +alias LPCMENUITEMINFOA = const(MENUITEMINFOA)*; struct MENUITEMINFOW { UINT cbSize = MENUITEMINFOW.sizeof; @@ -2833,8 +2833,8 @@ struct MENUITEMINFOW { UINT cch; HBITMAP hbmpItem; } -alias MENUITEMINFOW* LPMENUITEMINFOW; -alias const(MENUITEMINFOW)* LPCMENUITEMINFOW; +alias LPMENUITEMINFOW = MENUITEMINFOW*; +alias LPCMENUITEMINFOW = const(MENUITEMINFOW)*; struct SCROLLINFO { UINT cbSize = this.sizeof; @@ -2845,8 +2845,8 @@ struct SCROLLINFO { int nPos; int nTrackPos; } -alias SCROLLINFO* LPSCROLLINFO; -alias const(SCROLLINFO)* LPCSCROLLINFO; +alias LPSCROLLINFO = SCROLLINFO*; +alias LPCSCROLLINFO = const(SCROLLINFO)*; struct WINDOWPLACEMENT { UINT length; @@ -2856,7 +2856,7 @@ struct WINDOWPLACEMENT { POINT ptMaxPosition; RECT rcNormalPosition; } -alias WINDOWPLACEMENT* LPWINDOWPLACEMENT, PWINDOWPLACEMENT; +alias LPWINDOWPLACEMENT = WINDOWPLACEMENT*, PWINDOWPLACEMENT = WINDOWPLACEMENT*; struct MENUITEMTEMPLATEHEADER { WORD versionNumber; @@ -2869,9 +2869,9 @@ struct MENUITEMTEMPLATE { WCHAR[1] mtString = 0; } -alias void MENUTEMPLATE, MENUTEMPLATEA, MENUTEMPLATEW; +alias MENUTEMPLATE = void, MENUTEMPLATEA = void, MENUTEMPLATEW = void; -alias MENUTEMPLATE* LPMENUTEMPLATEA, LPMENUTEMPLATEW, LPMENUTEMPLATE; +alias LPMENUTEMPLATEA = MENUTEMPLATE*, LPMENUTEMPLATEW = MENUTEMPLATE*, LPMENUTEMPLATE = MENUTEMPLATE*; struct HELPINFO { UINT cbSize = this.sizeof; @@ -2881,7 +2881,7 @@ struct HELPINFO { DWORD_PTR dwContextId; POINT MousePos; } -alias HELPINFO* LPHELPINFO; +alias LPHELPINFO = HELPINFO*; struct MSGBOXPARAMSA { UINT cbSize = this.sizeof; @@ -2895,7 +2895,7 @@ struct MSGBOXPARAMSA { MSGBOXCALLBACK lpfnMsgBoxCallback; DWORD dwLanguageId; } -alias MSGBOXPARAMSA* PMSGBOXPARAMSA, LPMSGBOXPARAMSA; +alias PMSGBOXPARAMSA = MSGBOXPARAMSA*, LPMSGBOXPARAMSA = MSGBOXPARAMSA*; struct MSGBOXPARAMSW { UINT cbSize = this.sizeof; @@ -2909,7 +2909,7 @@ struct MSGBOXPARAMSW { MSGBOXCALLBACK lpfnMsgBoxCallback; DWORD dwLanguageId; } -alias MSGBOXPARAMSW* PMSGBOXPARAMSW, LPMSGBOXPARAMSW; +alias PMSGBOXPARAMSW = MSGBOXPARAMSW*, LPMSGBOXPARAMSW = MSGBOXPARAMSW*; struct USEROBJECTFLAGS { BOOL fInherit; @@ -2931,14 +2931,14 @@ struct HIGHCONTRASTA { DWORD dwFlags; LPSTR lpszDefaultScheme; } -alias HIGHCONTRASTA* LPHIGHCONTRASTA; +alias LPHIGHCONTRASTA = HIGHCONTRASTA*; struct HIGHCONTRASTW { UINT cbSize = this.sizeof; DWORD dwFlags; LPWSTR lpszDefaultScheme; } -alias HIGHCONTRASTW* LPHIGHCONTRASTW; +alias LPHIGHCONTRASTW = HIGHCONTRASTW*; struct ICONMETRICSA { UINT cbSize = this.sizeof; @@ -2947,7 +2947,7 @@ struct ICONMETRICSA { int iTitleWrap; LOGFONTA lfFont; } -alias ICONMETRICSA* LPICONMETRICSA; +alias LPICONMETRICSA = ICONMETRICSA*; struct ICONMETRICSW { UINT cbSize = this.sizeof; @@ -2956,7 +2956,7 @@ struct ICONMETRICSW { int iTitleWrap; LOGFONTW lfFont; } -alias ICONMETRICSW* LPICONMETRICSW; +alias LPICONMETRICSW = ICONMETRICSW*; struct MINIMIZEDMETRICS { UINT cbSize = this.sizeof; @@ -2965,7 +2965,7 @@ struct MINIMIZEDMETRICS { int iVertGap; int iArrange; } -alias MINIMIZEDMETRICS* LPMINIMIZEDMETRICS; +alias LPMINIMIZEDMETRICS = MINIMIZEDMETRICS*; struct MOUSEKEYS { UINT cbSize = this.sizeof; @@ -2976,7 +2976,7 @@ struct MOUSEKEYS { DWORD dwReserved1; DWORD dwReserved2; } -alias MOUSEKEYS* LPMOUSEKEYS; +alias LPMOUSEKEYS = MOUSEKEYS*; struct NONCLIENTMETRICSA { UINT cbSize = this.sizeof; @@ -2995,7 +2995,7 @@ struct NONCLIENTMETRICSA { LOGFONTA lfStatusFont; LOGFONTA lfMessageFont; } -alias NONCLIENTMETRICSA* LPNONCLIENTMETRICSA; +alias LPNONCLIENTMETRICSA = NONCLIENTMETRICSA*; struct NONCLIENTMETRICSW { UINT cbSize = this.sizeof; @@ -3014,7 +3014,7 @@ struct NONCLIENTMETRICSW { LOGFONTW lfStatusFont; LOGFONTW lfMessageFont; } -alias NONCLIENTMETRICSW* LPNONCLIENTMETRICSW; +alias LPNONCLIENTMETRICSW = NONCLIENTMETRICSW*; struct SERIALKEYSA { UINT cbSize = this.sizeof; @@ -3025,7 +3025,7 @@ struct SERIALKEYSA { UINT iPortState; UINT iActive; } -alias SERIALKEYSA* LPSERIALKEYSA; +alias LPSERIALKEYSA = SERIALKEYSA*; struct SERIALKEYSW { UINT cbSize = this.sizeof; @@ -3036,7 +3036,7 @@ struct SERIALKEYSW { UINT iPortState; UINT iActive; } -alias SERIALKEYSW* LPSERIALKEYSW; +alias LPSERIALKEYSW = SERIALKEYSW*; struct SOUNDSENTRYA { UINT cbSize = this.sizeof; @@ -3052,7 +3052,7 @@ struct SOUNDSENTRYA { LPSTR lpszWindowsEffectDLL; DWORD iWindowsEffectOrdinal; } -alias SOUNDSENTRYA* LPSOUNDSENTRYA; +alias LPSOUNDSENTRYA = SOUNDSENTRYA*; struct SOUNDSENTRYW { UINT cbSize = this.sizeof; @@ -3068,13 +3068,13 @@ struct SOUNDSENTRYW { LPWSTR lpszWindowsEffectDLL; DWORD iWindowsEffectOrdinal; } -alias SOUNDSENTRYW* LPSOUNDSENTRYW; +alias LPSOUNDSENTRYW = SOUNDSENTRYW*; struct STICKYKEYS { DWORD cbSize = this.sizeof; DWORD dwFlags; } -alias STICKYKEYS* LPSTICKYKEYS; +alias LPSTICKYKEYS = STICKYKEYS*; struct TOGGLEKEYS { DWORD cbSize = this.sizeof; @@ -3087,7 +3087,7 @@ struct MOUSEHOOKSTRUCT { UINT wHitTestCode; ULONG_PTR dwExtraInfo; } -alias MOUSEHOOKSTRUCT* LPMOUSEHOOKSTRUCT, PMOUSEHOOKSTRUCT; +alias LPMOUSEHOOKSTRUCT = MOUSEHOOKSTRUCT*, PMOUSEHOOKSTRUCT = MOUSEHOOKSTRUCT*; struct TRACKMOUSEEVENT { DWORD cbSize = this.sizeof; @@ -3095,13 +3095,13 @@ struct TRACKMOUSEEVENT { HWND hwndTrack; DWORD dwHoverTime; } -alias TRACKMOUSEEVENT* LPTRACKMOUSEEVENT; +alias LPTRACKMOUSEEVENT = TRACKMOUSEEVENT*; struct TPMPARAMS { UINT cbSize = this.sizeof; RECT rcExclude; } -alias TPMPARAMS* LPTPMPARAMS; +alias LPTPMPARAMS = TPMPARAMS*; struct EVENTMSG { UINT message; @@ -3110,7 +3110,7 @@ struct EVENTMSG { DWORD time; HWND hwnd; } -alias EVENTMSG* PEVENTMSGMSG, LPEVENTMSGMSG, PEVENTMSG, LPEVENTMSG; +alias PEVENTMSGMSG = EVENTMSG*, LPEVENTMSGMSG = EVENTMSG*, PEVENTMSG = EVENTMSG*, LPEVENTMSG = EVENTMSG*; struct WINDOWPOS { HWND hwnd; @@ -3121,13 +3121,13 @@ struct WINDOWPOS { int cy; UINT flags; } -alias WINDOWPOS* PWINDOWPOS, LPWINDOWPOS; +alias PWINDOWPOS = WINDOWPOS*, LPWINDOWPOS = WINDOWPOS*; struct NCCALCSIZE_PARAMS { RECT[3] rgrc; PWINDOWPOS lppos; } -alias NCCALCSIZE_PARAMS* LPNCCALCSIZE_PARAMS; +alias LPNCCALCSIZE_PARAMS = NCCALCSIZE_PARAMS*; struct MDICREATESTRUCTA { LPCSTR szClass; @@ -3140,7 +3140,7 @@ struct MDICREATESTRUCTA { DWORD style; LPARAM lParam; } -alias MDICREATESTRUCTA* LPMDICREATESTRUCTA; +alias LPMDICREATESTRUCTA = MDICREATESTRUCTA*; struct MDICREATESTRUCTW { LPCWSTR szClass; @@ -3153,7 +3153,7 @@ struct MDICREATESTRUCTW { DWORD style; LPARAM lParam; } -alias MDICREATESTRUCTW* LPMDICREATESTRUCTW; +alias LPMDICREATESTRUCTW = MDICREATESTRUCTW*; struct MINMAXINFO { POINT ptReserved; @@ -3162,14 +3162,14 @@ struct MINMAXINFO { POINT ptMinTrackSize; POINT ptMaxTrackSize; } -alias MINMAXINFO* PMINMAXINFO, LPMINMAXINFO; +alias PMINMAXINFO = MINMAXINFO*, LPMINMAXINFO = MINMAXINFO*; struct MDINEXTMENU { HMENU hmenuIn; HMENU hmenuNext; HWND hwndNext; } -alias MDINEXTMENU* PMDINEXTMENU, LPMDINEXTMENU; +alias PMDINEXTMENU = MDINEXTMENU*, LPMDINEXTMENU = MDINEXTMENU*; struct MEASUREITEMSTRUCT { UINT CtlType; @@ -3179,7 +3179,7 @@ struct MEASUREITEMSTRUCT { UINT itemHeight; ULONG_PTR itemData; } -alias MEASUREITEMSTRUCT* PMEASUREITEMSTRUCT, LPMEASUREITEMSTRUCT; +alias PMEASUREITEMSTRUCT = MEASUREITEMSTRUCT*, LPMEASUREITEMSTRUCT = MEASUREITEMSTRUCT*; struct DROPSTRUCT { HWND hwndSource; @@ -3189,23 +3189,23 @@ struct DROPSTRUCT { POINT ptDrop; DWORD dwControlData; } -alias DROPSTRUCT* PDROPSTRUCT, LPDROPSTRUCT; +alias PDROPSTRUCT = DROPSTRUCT*, LPDROPSTRUCT = DROPSTRUCT*; -alias DWORD HELPPOLY; +alias HELPPOLY = DWORD; struct MULTIKEYHELPA { DWORD mkSize; CHAR mkKeylist = 0; CHAR[1] szKeyphrase = 0; } -alias MULTIKEYHELPA* PMULTIKEYHELPA, LPMULTIKEYHELPA; +alias PMULTIKEYHELPA = MULTIKEYHELPA*, LPMULTIKEYHELPA = MULTIKEYHELPA*; struct MULTIKEYHELPW { DWORD mkSize; WCHAR mkKeylist = 0; WCHAR[1] szKeyphrase = 0; } -alias MULTIKEYHELPW* PMULTIKEYHELPW, LPMULTIKEYHELPW; +alias PMULTIKEYHELPW = MULTIKEYHELPW*, LPMULTIKEYHELPW = MULTIKEYHELPW*; struct HELPWININFOA { int wStructSize; @@ -3216,7 +3216,7 @@ struct HELPWININFOA { int wMax; CHAR[2] rgchMember = 0; } -alias HELPWININFOA* PHELPWININFOA, LPHELPWININFOA; +alias PHELPWININFOA = HELPWININFOA*, LPHELPWININFOA = HELPWININFOA*; struct HELPWININFOW { int wStructSize; @@ -3227,13 +3227,13 @@ struct HELPWININFOW { int wMax; WCHAR[2] rgchMember = 0; } -alias HELPWININFOW* PHELPWININFOW, LPHELPWININFOW; +alias PHELPWININFOW = HELPWININFOW*, LPHELPWININFOW = HELPWININFOW*; struct STYLESTRUCT { DWORD styleOld; DWORD styleNew; } -alias STYLESTRUCT* LPSTYLESTRUCT; +alias LPSTYLESTRUCT = STYLESTRUCT*; struct ALTTABINFO { DWORD cbSize = this.sizeof; @@ -3246,7 +3246,7 @@ struct ALTTABINFO { int cyItem; POINT ptStart; } -alias ALTTABINFO* PALTTABINFO, LPALTTABINFO; +alias PALTTABINFO = ALTTABINFO*, LPALTTABINFO = ALTTABINFO*; struct COMBOBOXINFO { DWORD cbSize = this.sizeof; @@ -3257,7 +3257,7 @@ struct COMBOBOXINFO { HWND hwndItem; HWND hwndList; } -alias COMBOBOXINFO* PCOMBOBOXINFO, LPCOMBOBOXINFO; +alias PCOMBOBOXINFO = COMBOBOXINFO*, LPCOMBOBOXINFO = COMBOBOXINFO*; struct CURSORINFO { DWORD cbSize = this.sizeof; @@ -3265,7 +3265,7 @@ struct CURSORINFO { HCURSOR hCursor; POINT ptScreenPos; } -alias CURSORINFO* PCURSORINFO, LPCURSORINFO; +alias PCURSORINFO = CURSORINFO*, LPCURSORINFO = CURSORINFO*; struct MENUBARINFO { DWORD cbSize = this.sizeof; @@ -3280,7 +3280,7 @@ struct MENUBARINFO { bool fBarFocused()(bool b) { bf_ = cast(byte) ((bf_ & 0xFE) | b); return b; } bool fFocused()(bool b) { bf_ = cast(byte) (b ? (bf_ | 2) : bf_ & 0xFD); return b; } } -alias MENUBARINFO* PMENUBARINFO; +alias PMENUBARINFO = MENUBARINFO*; struct MENUINFO { DWORD cbSize = this.sizeof; @@ -3291,8 +3291,8 @@ struct MENUINFO { DWORD dwContextHelpID; ULONG_PTR dwMenuData; } -alias MENUINFO* LPMENUINFO; -alias const(MENUINFO)* LPCMENUINFO; +alias LPMENUINFO = MENUINFO*; +alias LPCMENUINFO = const(MENUINFO)*; enum CCHILDREN_SCROLLBAR = 5; @@ -3306,7 +3306,7 @@ struct SCROLLBARINFO { int reserved; DWORD[CCHILDREN_SCROLLBAR+1] rgstate; } -alias SCROLLBARINFO* PSCROLLBARINFO, LPSCROLLBARINFO; +alias PSCROLLBARINFO = SCROLLBARINFO*, LPSCROLLBARINFO = SCROLLBARINFO*; enum CCHILDREN_TITLEBAR = 5; @@ -3322,13 +3322,13 @@ struct WINDOWINFO { ATOM atomWindowType; WORD wCreatorVersion; } -alias WINDOWINFO* PWINDOWINFO, LPWINDOWINFO; +alias PWINDOWINFO = WINDOWINFO*, LPWINDOWINFO = WINDOWINFO*; struct LASTINPUTINFO { UINT cbSize = this.sizeof; DWORD dwTime; } -alias LASTINPUTINFO* PLASTINPUTINFO; +alias PLASTINPUTINFO = LASTINPUTINFO*; struct MONITORINFO { DWORD cbSize = this.sizeof; @@ -3336,7 +3336,7 @@ struct MONITORINFO { RECT rcWork; DWORD dwFlags; } -alias MONITORINFO* LPMONITORINFO; +alias LPMONITORINFO = MONITORINFO*; enum CCHDEVICENAME = 32; @@ -3347,7 +3347,7 @@ struct MONITORINFOEXA { DWORD dwFlags; CHAR[CCHDEVICENAME] szDevice = 0; } -alias MONITORINFOEXA* LPMONITORINFOEXA; +alias LPMONITORINFOEXA = MONITORINFOEXA*; struct MONITORINFOEXW { DWORD cbSize = MONITORINFOEXW.sizeof; @@ -3356,7 +3356,7 @@ struct MONITORINFOEXW { DWORD dwFlags; WCHAR[CCHDEVICENAME] szDevice = 0; } -alias MONITORINFOEXW* LPMONITORINFOEXW; +alias LPMONITORINFOEXW = MONITORINFOEXW*; struct KBDLLHOOKSTRUCT { DWORD vkCode; @@ -3365,7 +3365,7 @@ struct KBDLLHOOKSTRUCT { DWORD time; ULONG_PTR dwExtraInfo; } -alias KBDLLHOOKSTRUCT* LPKBDLLHOOKSTRUCT, PKBDLLHOOKSTRUCT; +alias LPKBDLLHOOKSTRUCT = KBDLLHOOKSTRUCT*, PKBDLLHOOKSTRUCT = KBDLLHOOKSTRUCT*; struct MSLLHOOKSTRUCT { POINT pt; @@ -3374,7 +3374,7 @@ struct MSLLHOOKSTRUCT { DWORD time; ULONG_PTR dwExtraInfo; } -alias MSLLHOOKSTRUCT* PMSLLHOOKSTRUCT; +alias PMSLLHOOKSTRUCT = MSLLHOOKSTRUCT*; struct MOUSEINPUT { LONG dx; @@ -3384,7 +3384,7 @@ struct MOUSEINPUT { DWORD time; ULONG_PTR dwExtraInfo; } -alias MOUSEINPUT* PMOUSEINPUT; +alias PMOUSEINPUT = MOUSEINPUT*; struct KEYBDINPUT { WORD wVk; @@ -3393,14 +3393,14 @@ struct KEYBDINPUT { DWORD time; ULONG_PTR dwExtraInfo; } -alias KEYBDINPUT* PKEYBDINPUT; +alias PKEYBDINPUT = KEYBDINPUT*; struct HARDWAREINPUT { DWORD uMsg; WORD wParamL; WORD wParamH; } -alias HARDWAREINPUT* PHARDWAREINPUT; +alias PHARDWAREINPUT = HARDWAREINPUT*; struct INPUT { DWORD type; @@ -3410,7 +3410,7 @@ struct INPUT { HARDWAREINPUT hi; } } -alias INPUT* PINPUT, LPINPUT; +alias PINPUT = INPUT*, LPINPUT = INPUT*; static if (_WIN32_WINNT >= 0x501) { align(4) struct BSMINFO { @@ -3419,9 +3419,9 @@ static if (_WIN32_WINNT >= 0x501) { HWND hwnd; align(4) LUID luid; } - alias BSMINFO* PBSMINFO; + alias PBSMINFO = BSMINFO*; - alias HANDLE HRAWINPUT; + alias HRAWINPUT = HANDLE; struct RAWINPUTHEADER { DWORD dwType; @@ -3429,7 +3429,7 @@ align(4) LUID luid; HANDLE hDevice; WPARAM wParam; } - alias RAWINPUTHEADER* PRAWINPUTHEADER; + alias PRAWINPUTHEADER = RAWINPUTHEADER*; struct RAWMOUSE { USHORT usFlags; @@ -3445,7 +3445,7 @@ align(4) LUID luid; LONG lLastY; ULONG ulExtraInformation; } - alias RAWMOUSE* PRAWMOUSE, LPRAWMOUSE; + alias PRAWMOUSE = RAWMOUSE*, LPRAWMOUSE = RAWMOUSE*; struct RAWKEYBOARD { USHORT MakeCode; @@ -3455,14 +3455,14 @@ align(4) LUID luid; UINT Message; ULONG ExtraInformation; } - alias RAWKEYBOARD* PRAWKEYBOARD, LPRAWKEYBOARD; + alias PRAWKEYBOARD = RAWKEYBOARD*, LPRAWKEYBOARD = RAWKEYBOARD*; struct RAWHID { DWORD dwSizeHid; DWORD dwCount; BYTE bRawData; } - alias RAWHID* PRAWHID, LPRAWHID; + alias PRAWHID = RAWHID*, LPRAWHID = RAWHID*; struct RAWINPUT { RAWINPUTHEADER header; @@ -3473,7 +3473,7 @@ align(4) LUID luid; } _data data; } - alias RAWINPUT* PRAWINPUT, LPRAWINPUT; + alias PRAWINPUT = RAWINPUT*, LPRAWINPUT = RAWINPUT*; struct RAWINPUTDEVICE { USHORT usUsagePage; @@ -3481,14 +3481,14 @@ align(4) LUID luid; DWORD dwFlags; HWND hwndTarget; } - alias RAWINPUTDEVICE* PRAWINPUTDEVICE, LPRAWINPUTDEVICE; - alias const(RAWINPUTDEVICE)* PCRAWINPUTDEVICE; + alias PRAWINPUTDEVICE = RAWINPUTDEVICE*, LPRAWINPUTDEVICE = RAWINPUTDEVICE*; + alias PCRAWINPUTDEVICE = const(RAWINPUTDEVICE)*; struct RAWINPUTDEVICELIST { HANDLE hDevice; DWORD dwType; } - alias RAWINPUTDEVICELIST* PRAWINPUTDEVICELIST; + alias PRAWINPUTDEVICELIST = RAWINPUTDEVICELIST*; struct RID_DEVICE_INFO_MOUSE { DWORD dwId; @@ -3525,20 +3525,20 @@ align(4) LUID luid; } }// (_WIN32_WINNT >= 0x501) -alias CharToOemA AnsiToOem; -alias OemToCharA OemToAnsi; -alias CharToOemBuffA AnsiToOemBuff; -alias OemToCharBuffA OemToAnsiBuff; -alias CharUpperA AnsiUpper; -alias CharUpperBuffA AnsiUpperBuff; -alias CharLowerA AnsiLower; -alias CharLowerBuffA AnsiLowerBuff; -alias CharNextA AnsiNext; -alias CharPrevA AnsiPrev; - -alias MAKELONG MAKEWPARAM; -alias MAKELONG MAKELPARAM; -alias MAKELONG MAKELRESULT; +alias AnsiToOem = CharToOemA; +alias OemToAnsi = OemToCharA; +alias AnsiToOemBuff = CharToOemBuffA; +alias OemToAnsiBuff = OemToCharBuffA; +alias AnsiUpper = CharUpperA; +alias AnsiUpperBuff = CharUpperBuffA; +alias AnsiLower = CharLowerA; +alias AnsiLowerBuff = CharLowerBuffA; +alias AnsiNext = CharNextA; +alias AnsiPrev = CharPrevA; + +alias MAKEWPARAM = MAKELONG; +alias MAKELPARAM = MAKELONG; +alias MAKELRESULT = MAKELONG; void POINTSTOPOINT()(out POINT p, LONG ps) { p.x = LOWORD(ps); @@ -3717,7 +3717,7 @@ nothrow @nogc { return ExitWindowsEx(EWX_LOGOFF, 0); } } -alias GetWindow GetNextWindow; +alias GetNextWindow = GetWindow; extern (Windows) nothrow @nogc: LONG DispatchMessageA(const(MSG)*); @@ -4155,7 +4155,7 @@ extern (C) { // These shouldn't be necessary for D. -alias char* va_list_; +alias va_list_ = char*; int wvsprintfA(LPSTR, LPCSTR, va_list_ arglist); int wvsprintfW(LPWSTR, LPCWSTR, va_list_ arglist); @@ -4181,7 +4181,7 @@ struct TITLEBARINFO { RECT rcTitleBar; DWORD[CCHILDREN_TITLEBAR+1] rgstate; } -alias TITLEBARINFO* PTITLEBARINFO, LPTITLEBARINFO; +alias PTITLEBARINFO = TITLEBARINFO*, LPTITLEBARINFO = TITLEBARINFO*; static if (_WIN32_WINNT >= 0x501) { // *** correct? struct FLASHWINFO { @@ -4191,7 +4191,7 @@ static if (_WIN32_WINNT >= 0x501) { // *** correct? UINT uCount; DWORD dwTimeout; } - alias FLASHWINFO* PFLASHWINFO; + alias PFLASHWINFO = FLASHWINFO*; } enum DWORD ASFW_ANY = -1; @@ -4210,7 +4210,7 @@ struct MOUSEMOVEPOINT { DWORD time; ULONG_PTR dwExtraInfo; } -alias MOUSEMOVEPOINT* PMOUSEMOVEPOINT, LPMOUSEMOVEPOINT; +alias PMOUSEMOVEPOINT = MOUSEMOVEPOINT*, LPMOUSEMOVEPOINT = MOUSEMOVEPOINT*; enum { MIM_MAXHEIGHT = 1, @@ -4413,9 +4413,9 @@ struct GUITHREADINFO { HWND hwndCaret; RECT rcCaret; } -alias GUITHREADINFO* PGUITHREADINFO, LPGUITHREADINFO; +alias PGUITHREADINFO = GUITHREADINFO*, LPGUITHREADINFO = GUITHREADINFO*; extern (Windows) { - alias void function(HWINEVENTHOOK, DWORD, HWND, LONG, LONG, DWORD, DWORD) WINEVENTPROC; + alias WINEVENTPROC = void function(HWINEVENTHOOK, DWORD, HWND, LONG, LONG, DWORD, DWORD); } // *** line 4680 of MinGW 4.0 int BroadcastSystemMessageA(DWORD, LPDWORD, UINT, WPARAM, LPARAM); @@ -4486,375 +4486,375 @@ version (Win64) { LONG_PTR SetWindowLongPtrA(HWND, int, LONG_PTR); LONG_PTR SetWindowLongPtrW(HWND, int, LONG_PTR); } else { - alias GetClassLongA GetClassLongPtrA; - alias GetClassLongW GetClassLongPtrW; - alias SetClassLongA SetClassLongPtrA; - alias SetClassLongW SetClassLongPtrW; - alias GetWindowLongA GetWindowLongPtrA; - alias GetWindowLongW GetWindowLongPtrW; - alias SetWindowLongA SetWindowLongPtrA; - alias SetWindowLongW SetWindowLongPtrW; + alias GetClassLongPtrA = GetClassLongA; + alias GetClassLongPtrW = GetClassLongW; + alias SetClassLongPtrA = SetClassLongA; + alias SetClassLongPtrW = SetClassLongW; + alias GetWindowLongPtrA = GetWindowLongA; + alias GetWindowLongPtrW = GetWindowLongW; + alias SetWindowLongPtrA = SetWindowLongA; + alias SetWindowLongPtrW = SetWindowLongW; } // ----- // Aliases for Unicode or Ansi version (Unicode) { - alias EDITWORDBREAKPROCW EDITWORDBREAKPROC; - alias PROPENUMPROCW PROPENUMPROC; - alias PROPENUMPROCEXW PROPENUMPROCEX; - alias DESKTOPENUMPROCW DESKTOPENUMPROC; - alias WINSTAENUMPROCW WINSTAENUMPROC; - alias MAKEINTRESOURCEW MAKEINTRESOURCE; - - alias WNDCLASSW WNDCLASS; - alias WNDCLASSEXW WNDCLASSEX; - alias MENUITEMINFOW MENUITEMINFO; - alias LPCMENUITEMINFOW LPCMENUITEMINFO; - alias MSGBOXPARAMSW MSGBOXPARAMS; - alias HIGHCONTRASTW HIGHCONTRAST; - alias SERIALKEYSW SERIALKEYS; - alias SOUNDSENTRYW SOUNDSENTRY; - alias CREATESTRUCTW CREATESTRUCT; - alias CBT_CREATEWNDW CBT_CREATEWND; - alias MDICREATESTRUCTW MDICREATESTRUCT; - alias MULTIKEYHELPW MULTIKEYHELP; - alias MONITORINFOEXW MONITORINFOEX; - alias ICONMETRICSW ICONMETRICS; - alias NONCLIENTMETRICSW NONCLIENTMETRICS; - - alias AppendMenuW AppendMenu; - alias BroadcastSystemMessageW BroadcastSystemMessage; + alias EDITWORDBREAKPROC = EDITWORDBREAKPROCW; + alias PROPENUMPROC = PROPENUMPROCW; + alias PROPENUMPROCEX = PROPENUMPROCEXW; + alias DESKTOPENUMPROC = DESKTOPENUMPROCW; + alias WINSTAENUMPROC = WINSTAENUMPROCW; + alias MAKEINTRESOURCE = MAKEINTRESOURCEW; + + alias WNDCLASS = WNDCLASSW; + alias WNDCLASSEX = WNDCLASSEXW; + alias MENUITEMINFO = MENUITEMINFOW; + alias LPCMENUITEMINFO = LPCMENUITEMINFOW; + alias MSGBOXPARAMS = MSGBOXPARAMSW; + alias HIGHCONTRAST = HIGHCONTRASTW; + alias SERIALKEYS = SERIALKEYSW; + alias SOUNDSENTRY = SOUNDSENTRYW; + alias CREATESTRUCT = CREATESTRUCTW; + alias CBT_CREATEWND = CBT_CREATEWNDW; + alias MDICREATESTRUCT = MDICREATESTRUCTW; + alias MULTIKEYHELP = MULTIKEYHELPW; + alias MONITORINFOEX = MONITORINFOEXW; + alias ICONMETRICS = ICONMETRICSW; + alias NONCLIENTMETRICS = NONCLIENTMETRICSW; + + alias AppendMenu = AppendMenuW; + alias BroadcastSystemMessage = BroadcastSystemMessageW; static if (_WIN32_WINNT >= 0x501) { - alias BroadcastSystemMessageExW BroadcastSystemMessageEx; + alias BroadcastSystemMessageEx = BroadcastSystemMessageExW; } - alias CallMsgFilterW CallMsgFilter; - alias CallWindowProcW CallWindowProc; - alias ChangeMenuW ChangeMenu; - alias CharLowerW CharLower; - alias CharLowerBuffW CharLowerBuff; - alias CharNextW CharNext; - alias CharNextExW CharNextEx; - alias CharPrevW CharPrev; - alias CharPrevExW CharPrevEx; - alias CharToOemW CharToOem; - alias CharToOemBuffW CharToOemBuff; - alias CharUpperW CharUpper; - alias CharUpperBuffW CharUpperBuff; - alias CopyAcceleratorTableW CopyAcceleratorTable; - alias CreateAcceleratorTableW CreateAcceleratorTable; - alias CreateDialogW CreateDialog; - alias CreateDialogIndirectW CreateDialogIndirect; - alias CreateDialogIndirectParamW CreateDialogIndirectParam; - alias CreateDialogParamW CreateDialogParam; - alias CreateMDIWindowW CreateMDIWindow; - alias CreateWindowW CreateWindow; - alias CreateWindowExW CreateWindowEx; - alias CreateWindowStationW CreateWindowStation; - alias DefDlgProcW DefDlgProc; - alias DefFrameProcW DefFrameProc; - alias DefMDIChildProcW DefMDIChildProc; - alias DefWindowProcW DefWindowProc; - alias DialogBoxW DialogBox; - alias DialogBoxIndirectW DialogBoxIndirect; - alias DialogBoxIndirectParamW DialogBoxIndirectParam; - alias DialogBoxParamW DialogBoxParam; - alias DispatchMessageW DispatchMessage; - alias DlgDirListW DlgDirList; - alias DlgDirListComboBoxW DlgDirListComboBox; - alias DlgDirSelectComboBoxExW DlgDirSelectComboBoxEx; - alias DlgDirSelectExW DlgDirSelectEx; - alias DrawStateW DrawState; - alias DrawTextW DrawText; - alias DrawTextExW DrawTextEx; - alias EnumDesktopsW EnumDesktops; - alias EnumPropsW EnumProps; - alias EnumPropsExW EnumPropsEx; - alias EnumWindowStationsW EnumWindowStations; - alias FindWindowW FindWindow; - alias FindWindowExW FindWindowEx; - alias GetClassInfoW GetClassInfo; - alias GetClassInfoExW GetClassInfoEx; - alias GetClassLongW GetClassLong; - alias GetClassLongPtrW GetClassLongPtr; - alias GetClassNameW GetClassName; - alias GetClipboardFormatNameW GetClipboardFormatName; - alias GetDlgItemTextW GetDlgItemText; - alias GetKeyboardLayoutNameW GetKeyboardLayoutName; - alias GetKeyNameTextW GetKeyNameText; - alias GetMenuItemInfoW GetMenuItemInfo; - alias GetMenuStringW GetMenuString; - alias GetMessageW GetMessage; - alias GetMonitorInfoW GetMonitorInfo; - alias GetPropW GetProp; + alias CallMsgFilter = CallMsgFilterW; + alias CallWindowProc = CallWindowProcW; + alias ChangeMenu = ChangeMenuW; + alias CharLower = CharLowerW; + alias CharLowerBuff = CharLowerBuffW; + alias CharNext = CharNextW; + alias CharNextEx = CharNextExW; + alias CharPrev = CharPrevW; + alias CharPrevEx = CharPrevExW; + alias CharToOem = CharToOemW; + alias CharToOemBuff = CharToOemBuffW; + alias CharUpper = CharUpperW; + alias CharUpperBuff = CharUpperBuffW; + alias CopyAcceleratorTable = CopyAcceleratorTableW; + alias CreateAcceleratorTable = CreateAcceleratorTableW; + alias CreateDialog = CreateDialogW; + alias CreateDialogIndirect = CreateDialogIndirectW; + alias CreateDialogIndirectParam = CreateDialogIndirectParamW; + alias CreateDialogParam = CreateDialogParamW; + alias CreateMDIWindow = CreateMDIWindowW; + alias CreateWindow = CreateWindowW; + alias CreateWindowEx = CreateWindowExW; + alias CreateWindowStation = CreateWindowStationW; + alias DefDlgProc = DefDlgProcW; + alias DefFrameProc = DefFrameProcW; + alias DefMDIChildProc = DefMDIChildProcW; + alias DefWindowProc = DefWindowProcW; + alias DialogBox = DialogBoxW; + alias DialogBoxIndirect = DialogBoxIndirectW; + alias DialogBoxIndirectParam = DialogBoxIndirectParamW; + alias DialogBoxParam = DialogBoxParamW; + alias DispatchMessage = DispatchMessageW; + alias DlgDirList = DlgDirListW; + alias DlgDirListComboBox = DlgDirListComboBoxW; + alias DlgDirSelectComboBoxEx = DlgDirSelectComboBoxExW; + alias DlgDirSelectEx = DlgDirSelectExW; + alias DrawState = DrawStateW; + alias DrawText = DrawTextW; + alias DrawTextEx = DrawTextExW; + alias EnumDesktops = EnumDesktopsW; + alias EnumProps = EnumPropsW; + alias EnumPropsEx = EnumPropsExW; + alias EnumWindowStations = EnumWindowStationsW; + alias FindWindow = FindWindowW; + alias FindWindowEx = FindWindowExW; + alias GetClassInfo = GetClassInfoW; + alias GetClassInfoEx = GetClassInfoExW; + alias GetClassLong = GetClassLongW; + alias GetClassLongPtr = GetClassLongPtrW; + alias GetClassName = GetClassNameW; + alias GetClipboardFormatName = GetClipboardFormatNameW; + alias GetDlgItemText = GetDlgItemTextW; + alias GetKeyboardLayoutName = GetKeyboardLayoutNameW; + alias GetKeyNameText = GetKeyNameTextW; + alias GetMenuItemInfo = GetMenuItemInfoW; + alias GetMenuString = GetMenuStringW; + alias GetMessage = GetMessageW; + alias GetMonitorInfo = GetMonitorInfoW; + alias GetProp = GetPropW; static if (_WIN32_WINNT >= 0x501) { - alias GetRawInputDeviceInfoW GetRawInputDeviceInfo; + alias GetRawInputDeviceInfo = GetRawInputDeviceInfoW; } - alias GetTabbedTextExtentW GetTabbedTextExtent; - alias GetUserObjectInformationW GetUserObjectInformation; - alias GetWindowLongW GetWindowLong; - alias GetWindowLongPtrW GetWindowLongPtr; - alias GetWindowTextW GetWindowText; - alias GetWindowTextLengthW GetWindowTextLength; - alias GetAltTabInfoW GetAltTabInfo; - alias GetWindowModuleFileNameW GetWindowModuleFileName; - alias GrayStringW GrayString; - alias InsertMenuW InsertMenu; - alias InsertMenuItemW InsertMenuItem; - alias IsCharAlphaW IsCharAlpha; - alias IsCharAlphaNumericW IsCharAlphaNumeric; - alias IsCharLowerW IsCharLower; - alias IsCharUpperW IsCharUpper; - alias IsDialogMessageW IsDialogMessage; - alias LoadAcceleratorsW LoadAccelerators; - alias LoadBitmapW LoadBitmap; - alias LoadCursorW LoadCursor; - alias LoadCursorFromFileW LoadCursorFromFile; - alias LoadIconW LoadIcon; - alias LoadImageW LoadImage; - alias LoadKeyboardLayoutW LoadKeyboardLayout; - alias LoadMenuW LoadMenu; - alias LoadMenuIndirectW LoadMenuIndirect; - alias LoadStringW LoadString; - alias MapVirtualKeyW MapVirtualKey; - alias MapVirtualKeyExW MapVirtualKeyEx; - alias MessageBoxW MessageBox; - alias MessageBoxExW MessageBoxEx; - alias MessageBoxIndirectW MessageBoxIndirect; - alias ModifyMenuW ModifyMenu; - alias OemToCharW OemToChar; - alias OemToCharBuffW OemToCharBuff; - alias OpenDesktopW OpenDesktop; - alias OpenWindowStationW OpenWindowStation; - alias PeekMessageW PeekMessage; - alias PostMessageW PostMessage; - alias PostThreadMessageW PostThreadMessage; - alias RealGetWindowClassW RealGetWindowClass; - alias RegisterClassW RegisterClass; - alias RegisterClassExW RegisterClassEx; - alias RegisterClipboardFormatW RegisterClipboardFormat; - alias RegisterDeviceNotificationW RegisterDeviceNotification; - alias RegisterWindowMessageW RegisterWindowMessage; - alias RemovePropW RemoveProp; - alias SendDlgItemMessageW SendDlgItemMessage; - alias SendMessageW SendMessage; - alias SendMessageCallbackW SendMessageCallback; - alias SendMessageTimeoutW SendMessageTimeout; - alias SendNotifyMessageW SendNotifyMessage; - alias SetClassLongW SetClassLong; - alias SetClassLongPtrW SetClassLongPtr; - alias SetDlgItemTextW SetDlgItemText; - alias SetMenuItemInfoW SetMenuItemInfo; - alias SetPropW SetProp; - alias SetUserObjectInformationW SetUserObjectInformation; - alias SetWindowLongW SetWindowLong; - alias SetWindowLongPtrW SetWindowLongPtr; - alias SetWindowsHookW SetWindowsHook; - alias SetWindowsHookExW SetWindowsHookEx; - alias SetWindowTextW SetWindowText; - alias SystemParametersInfoW SystemParametersInfo; - alias TabbedTextOutW TabbedTextOut; - alias TranslateAcceleratorW TranslateAccelerator; - alias UnregisterClassW UnregisterClass; - alias VkKeyScanW VkKeyScan; - alias VkKeyScanExW VkKeyScanEx; - alias WinHelpW WinHelp; - alias wsprintfW wsprintf; - alias wvsprintfW wvsprintf; - - alias ChangeDisplaySettingsW ChangeDisplaySettings; - alias ChangeDisplaySettingsExW ChangeDisplaySettingsEx; - alias CreateDesktopW CreateDesktop; - alias EnumDisplaySettingsW EnumDisplaySettings; - alias EnumDisplaySettingsExW EnumDisplaySettingsEx; - alias EnumDisplayDevicesW EnumDisplayDevices; + alias GetTabbedTextExtent = GetTabbedTextExtentW; + alias GetUserObjectInformation = GetUserObjectInformationW; + alias GetWindowLong = GetWindowLongW; + alias GetWindowLongPtr = GetWindowLongPtrW; + alias GetWindowText = GetWindowTextW; + alias GetWindowTextLength = GetWindowTextLengthW; + alias GetAltTabInfo = GetAltTabInfoW; + alias GetWindowModuleFileName = GetWindowModuleFileNameW; + alias GrayString = GrayStringW; + alias InsertMenu = InsertMenuW; + alias InsertMenuItem = InsertMenuItemW; + alias IsCharAlpha = IsCharAlphaW; + alias IsCharAlphaNumeric = IsCharAlphaNumericW; + alias IsCharLower = IsCharLowerW; + alias IsCharUpper = IsCharUpperW; + alias IsDialogMessage = IsDialogMessageW; + alias LoadAccelerators = LoadAcceleratorsW; + alias LoadBitmap = LoadBitmapW; + alias LoadCursor = LoadCursorW; + alias LoadCursorFromFile = LoadCursorFromFileW; + alias LoadIcon = LoadIconW; + alias LoadImage = LoadImageW; + alias LoadKeyboardLayout = LoadKeyboardLayoutW; + alias LoadMenu = LoadMenuW; + alias LoadMenuIndirect = LoadMenuIndirectW; + alias LoadString = LoadStringW; + alias MapVirtualKey = MapVirtualKeyW; + alias MapVirtualKeyEx = MapVirtualKeyExW; + alias MessageBox = MessageBoxW; + alias MessageBoxEx = MessageBoxExW; + alias MessageBoxIndirect = MessageBoxIndirectW; + alias ModifyMenu = ModifyMenuW; + alias OemToChar = OemToCharW; + alias OemToCharBuff = OemToCharBuffW; + alias OpenDesktop = OpenDesktopW; + alias OpenWindowStation = OpenWindowStationW; + alias PeekMessage = PeekMessageW; + alias PostMessage = PostMessageW; + alias PostThreadMessage = PostThreadMessageW; + alias RealGetWindowClass = RealGetWindowClassW; + alias RegisterClass = RegisterClassW; + alias RegisterClassEx = RegisterClassExW; + alias RegisterClipboardFormat = RegisterClipboardFormatW; + alias RegisterDeviceNotification = RegisterDeviceNotificationW; + alias RegisterWindowMessage = RegisterWindowMessageW; + alias RemoveProp = RemovePropW; + alias SendDlgItemMessage = SendDlgItemMessageW; + alias SendMessage = SendMessageW; + alias SendMessageCallback = SendMessageCallbackW; + alias SendMessageTimeout = SendMessageTimeoutW; + alias SendNotifyMessage = SendNotifyMessageW; + alias SetClassLong = SetClassLongW; + alias SetClassLongPtr = SetClassLongPtrW; + alias SetDlgItemText = SetDlgItemTextW; + alias SetMenuItemInfo = SetMenuItemInfoW; + alias SetProp = SetPropW; + alias SetUserObjectInformation = SetUserObjectInformationW; + alias SetWindowLong = SetWindowLongW; + alias SetWindowLongPtr = SetWindowLongPtrW; + alias SetWindowsHook = SetWindowsHookW; + alias SetWindowsHookEx = SetWindowsHookExW; + alias SetWindowText = SetWindowTextW; + alias SystemParametersInfo = SystemParametersInfoW; + alias TabbedTextOut = TabbedTextOutW; + alias TranslateAccelerator = TranslateAcceleratorW; + alias UnregisterClass = UnregisterClassW; + alias VkKeyScan = VkKeyScanW; + alias VkKeyScanEx = VkKeyScanExW; + alias WinHelp = WinHelpW; + alias wsprintf = wsprintfW; + alias wvsprintf = wvsprintfW; + + alias ChangeDisplaySettings = ChangeDisplaySettingsW; + alias ChangeDisplaySettingsEx = ChangeDisplaySettingsExW; + alias CreateDesktop = CreateDesktopW; + alias EnumDisplaySettings = EnumDisplaySettingsW; + alias EnumDisplaySettingsEx = EnumDisplaySettingsExW; + alias EnumDisplayDevices = EnumDisplayDevicesW; } else { // ANSI - alias EDITWORDBREAKPROCA EDITWORDBREAKPROC; - alias PROPENUMPROCA PROPENUMPROC; - alias PROPENUMPROCEXA PROPENUMPROCEX; - alias DESKTOPENUMPROCA DESKTOPENUMPROC; - alias WINSTAENUMPROCA WINSTAENUMPROC; - alias MAKEINTRESOURCEA MAKEINTRESOURCE; - - alias WNDCLASSA WNDCLASS; - alias WNDCLASSEXA WNDCLASSEX; - alias MENUITEMINFOA MENUITEMINFO; - alias LPCMENUITEMINFOA LPCMENUITEMINFO; - alias MSGBOXPARAMSA MSGBOXPARAMS; - alias HIGHCONTRASTA HIGHCONTRAST; - alias SERIALKEYSA SERIALKEYS; - alias SOUNDSENTRYA SOUNDSENTRY; - alias CREATESTRUCTA CREATESTRUCT; - alias CBT_CREATEWNDA CBT_CREATEWND; - alias MDICREATESTRUCTA MDICREATESTRUCT; - alias MULTIKEYHELPA MULTIKEYHELP; - alias MONITORINFOEXA MONITORINFOEX; - alias ICONMETRICSA ICONMETRICS; - alias NONCLIENTMETRICSA NONCLIENTMETRICS; - - alias AppendMenuA AppendMenu; - alias BroadcastSystemMessageA BroadcastSystemMessage; + alias EDITWORDBREAKPROC = EDITWORDBREAKPROCA; + alias PROPENUMPROC = PROPENUMPROCA; + alias PROPENUMPROCEX = PROPENUMPROCEXA; + alias DESKTOPENUMPROC = DESKTOPENUMPROCA; + alias WINSTAENUMPROC = WINSTAENUMPROCA; + alias MAKEINTRESOURCE = MAKEINTRESOURCEA; + + alias WNDCLASS = WNDCLASSA; + alias WNDCLASSEX = WNDCLASSEXA; + alias MENUITEMINFO = MENUITEMINFOA; + alias LPCMENUITEMINFO = LPCMENUITEMINFOA; + alias MSGBOXPARAMS = MSGBOXPARAMSA; + alias HIGHCONTRAST = HIGHCONTRASTA; + alias SERIALKEYS = SERIALKEYSA; + alias SOUNDSENTRY = SOUNDSENTRYA; + alias CREATESTRUCT = CREATESTRUCTA; + alias CBT_CREATEWND = CBT_CREATEWNDA; + alias MDICREATESTRUCT = MDICREATESTRUCTA; + alias MULTIKEYHELP = MULTIKEYHELPA; + alias MONITORINFOEX = MONITORINFOEXA; + alias ICONMETRICS = ICONMETRICSA; + alias NONCLIENTMETRICS = NONCLIENTMETRICSA; + + alias AppendMenu = AppendMenuA; + alias BroadcastSystemMessage = BroadcastSystemMessageA; static if (_WIN32_WINNT >= 0x501) { - alias BroadcastSystemMessageExA BroadcastSystemMessageEx; + alias BroadcastSystemMessageEx = BroadcastSystemMessageExA; } - alias CallMsgFilterA CallMsgFilter; - alias CallWindowProcA CallWindowProc; - alias ChangeMenuA ChangeMenu; - alias CharLowerA CharLower; - alias CharLowerBuffA CharLowerBuff; - alias CharNextA CharNext; - alias CharNextExA CharNextEx; - alias CharPrevA CharPrev; - alias CharPrevExA CharPrevEx; - alias CharToOemA CharToOem; - alias CharToOemBuffA CharToOemBuff; - alias CharUpperA CharUpper; - alias CharUpperBuffA CharUpperBuff; - alias CopyAcceleratorTableA CopyAcceleratorTable; - alias CreateAcceleratorTableA CreateAcceleratorTable; - alias CreateDialogA CreateDialog; - alias CreateDialogIndirectA CreateDialogIndirect; - alias CreateDialogIndirectParamA CreateDialogIndirectParam; - alias CreateDialogParamA CreateDialogParam; - alias CreateMDIWindowA CreateMDIWindow; - alias CreateWindowA CreateWindow; - alias CreateWindowExA CreateWindowEx; - alias CreateWindowStationA CreateWindowStation; - alias DefDlgProcA DefDlgProc; - alias DefFrameProcA DefFrameProc; - alias DefMDIChildProcA DefMDIChildProc; - alias DefWindowProcA DefWindowProc; - alias DialogBoxA DialogBox; - alias DialogBoxIndirectA DialogBoxIndirect; - alias DialogBoxIndirectParamA DialogBoxIndirectParam; - alias DialogBoxParamA DialogBoxParam; - alias DispatchMessageA DispatchMessage; - alias DlgDirListA DlgDirList; - alias DlgDirListComboBoxA DlgDirListComboBox; - alias DlgDirSelectComboBoxExA DlgDirSelectComboBoxEx; - alias DlgDirSelectExA DlgDirSelectEx; - alias DrawStateA DrawState; - alias DrawTextA DrawText; - alias DrawTextExA DrawTextEx; - alias EnumDesktopsA EnumDesktops; - alias EnumPropsA EnumProps; - alias EnumPropsExA EnumPropsEx; - alias EnumWindowStationsA EnumWindowStations; - alias FindWindowA FindWindow; - alias FindWindowExA FindWindowEx; - alias GetClassInfoA GetClassInfo; - alias GetClassInfoExA GetClassInfoEx; - alias GetClassLongA GetClassLong; - alias GetClassLongPtrA GetClassLongPtr; - alias GetClassNameA GetClassName; - alias GetClipboardFormatNameA GetClipboardFormatName; - alias GetDlgItemTextA GetDlgItemText; - alias GetKeyboardLayoutNameA GetKeyboardLayoutName; - alias GetKeyNameTextA GetKeyNameText; - alias GetMenuItemInfoA GetMenuItemInfo; - alias GetMenuStringA GetMenuString; - alias GetMessageA GetMessage; - alias GetMonitorInfoA GetMonitorInfo; - alias GetPropA GetProp; + alias CallMsgFilter = CallMsgFilterA; + alias CallWindowProc = CallWindowProcA; + alias ChangeMenu = ChangeMenuA; + alias CharLower = CharLowerA; + alias CharLowerBuff = CharLowerBuffA; + alias CharNext = CharNextA; + alias CharNextEx = CharNextExA; + alias CharPrev = CharPrevA; + alias CharPrevEx = CharPrevExA; + alias CharToOem = CharToOemA; + alias CharToOemBuff = CharToOemBuffA; + alias CharUpper = CharUpperA; + alias CharUpperBuff = CharUpperBuffA; + alias CopyAcceleratorTable = CopyAcceleratorTableA; + alias CreateAcceleratorTable = CreateAcceleratorTableA; + alias CreateDialog = CreateDialogA; + alias CreateDialogIndirect = CreateDialogIndirectA; + alias CreateDialogIndirectParam = CreateDialogIndirectParamA; + alias CreateDialogParam = CreateDialogParamA; + alias CreateMDIWindow = CreateMDIWindowA; + alias CreateWindow = CreateWindowA; + alias CreateWindowEx = CreateWindowExA; + alias CreateWindowStation = CreateWindowStationA; + alias DefDlgProc = DefDlgProcA; + alias DefFrameProc = DefFrameProcA; + alias DefMDIChildProc = DefMDIChildProcA; + alias DefWindowProc = DefWindowProcA; + alias DialogBox = DialogBoxA; + alias DialogBoxIndirect = DialogBoxIndirectA; + alias DialogBoxIndirectParam = DialogBoxIndirectParamA; + alias DialogBoxParam = DialogBoxParamA; + alias DispatchMessage = DispatchMessageA; + alias DlgDirList = DlgDirListA; + alias DlgDirListComboBox = DlgDirListComboBoxA; + alias DlgDirSelectComboBoxEx = DlgDirSelectComboBoxExA; + alias DlgDirSelectEx = DlgDirSelectExA; + alias DrawState = DrawStateA; + alias DrawText = DrawTextA; + alias DrawTextEx = DrawTextExA; + alias EnumDesktops = EnumDesktopsA; + alias EnumProps = EnumPropsA; + alias EnumPropsEx = EnumPropsExA; + alias EnumWindowStations = EnumWindowStationsA; + alias FindWindow = FindWindowA; + alias FindWindowEx = FindWindowExA; + alias GetClassInfo = GetClassInfoA; + alias GetClassInfoEx = GetClassInfoExA; + alias GetClassLong = GetClassLongA; + alias GetClassLongPtr = GetClassLongPtrA; + alias GetClassName = GetClassNameA; + alias GetClipboardFormatName = GetClipboardFormatNameA; + alias GetDlgItemText = GetDlgItemTextA; + alias GetKeyboardLayoutName = GetKeyboardLayoutNameA; + alias GetKeyNameText = GetKeyNameTextA; + alias GetMenuItemInfo = GetMenuItemInfoA; + alias GetMenuString = GetMenuStringA; + alias GetMessage = GetMessageA; + alias GetMonitorInfo = GetMonitorInfoA; + alias GetProp = GetPropA; static if (_WIN32_WINNT >= 0x501) { - alias GetRawInputDeviceInfoA GetRawInputDeviceInfo; + alias GetRawInputDeviceInfo = GetRawInputDeviceInfoA; } - alias GetTabbedTextExtentA GetTabbedTextExtent; - alias GetUserObjectInformationA GetUserObjectInformation; - alias GetWindowLongA GetWindowLong; - alias GetWindowLongPtrA GetWindowLongPtr; - alias GetWindowTextA GetWindowText; - alias GetWindowTextLengthA GetWindowTextLength; - alias GetAltTabInfoA GetAltTabInfo; - alias GetWindowModuleFileNameA GetWindowModuleFileName; - alias GrayStringA GrayString; - alias InsertMenuA InsertMenu; - alias InsertMenuItemA InsertMenuItem; - alias IsCharAlphaA IsCharAlpha; - alias IsCharAlphaNumericA IsCharAlphaNumeric; - alias IsCharLowerA IsCharLower; - alias IsCharUpperA IsCharUpper; - alias IsDialogMessageA IsDialogMessage; - alias LoadAcceleratorsA LoadAccelerators; - alias LoadBitmapA LoadBitmap; - alias LoadCursorA LoadCursor; - alias LoadIconA LoadIcon; - alias LoadCursorFromFileA LoadCursorFromFile; - alias LoadImageA LoadImage; - alias LoadKeyboardLayoutA LoadKeyboardLayout; - alias LoadMenuA LoadMenu; - alias LoadMenuIndirectA LoadMenuIndirect; - alias LoadStringA LoadString; - alias MapVirtualKeyA MapVirtualKey; - alias MapVirtualKeyExA MapVirtualKeyEx; - alias MessageBoxA MessageBox; - alias MessageBoxExA MessageBoxEx; - alias MessageBoxIndirectA MessageBoxIndirect; - alias ModifyMenuA ModifyMenu; - alias OemToCharA OemToChar; - alias OemToCharBuffA OemToCharBuff; - alias OpenDesktopA OpenDesktop; - alias OpenWindowStationA OpenWindowStation; - alias PeekMessageA PeekMessage; - alias PostMessageA PostMessage; - alias PostThreadMessageA PostThreadMessage; - alias RealGetWindowClassA RealGetWindowClass; - alias RegisterClassA RegisterClass; - alias RegisterClassExA RegisterClassEx; - alias RegisterClipboardFormatA RegisterClipboardFormat; - alias RegisterDeviceNotificationA RegisterDeviceNotification; - alias RegisterWindowMessageA RegisterWindowMessage; - alias RemovePropA RemoveProp; - alias SendDlgItemMessageA SendDlgItemMessage; - alias SendMessageA SendMessage; - alias SendMessageCallbackA SendMessageCallback; - alias SendMessageTimeoutA SendMessageTimeout; - alias SendNotifyMessageA SendNotifyMessage; - alias SetClassLongA SetClassLong; - alias SetClassLongPtrA SetClassLongPtr; - alias SetDlgItemTextA SetDlgItemText; - alias SetMenuItemInfoA SetMenuItemInfo; - alias SetPropA SetProp; - alias SetUserObjectInformationA SetUserObjectInformation; - alias SetWindowLongA SetWindowLong; - alias SetWindowLongPtrA SetWindowLongPtr; - alias SetWindowsHookA SetWindowsHook; - alias SetWindowsHookExA SetWindowsHookEx; - alias SetWindowTextA SetWindowText; - alias SystemParametersInfoA SystemParametersInfo; - alias TabbedTextOutA TabbedTextOut; - alias TranslateAcceleratorA TranslateAccelerator; - alias UnregisterClassA UnregisterClass; - alias VkKeyScanA VkKeyScan; - alias VkKeyScanExA VkKeyScanEx; - alias WinHelpA WinHelp; - alias wsprintfA wsprintf; - alias wvsprintfA wvsprintf; - - alias ChangeDisplaySettingsA ChangeDisplaySettings; - alias ChangeDisplaySettingsExA ChangeDisplaySettingsEx; - alias CreateDesktopA CreateDesktop; - alias EnumDisplaySettingsA EnumDisplaySettings; - alias EnumDisplaySettingsExA EnumDisplaySettingsEx; - alias EnumDisplayDevicesA EnumDisplayDevices; -} - -alias WNDCLASS* LPWNDCLASS, PWNDCLASS; -alias WNDCLASSEX* LPWNDCLASSEX, PWNDCLASSEX; -alias MENUITEMINFO* LPMENUITEMINFO; -alias MSGBOXPARAMS* PMSGBOXPARAMS, LPMSGBOXPARAMS; -alias HIGHCONTRAST* LPHIGHCONTRAST; -alias SERIALKEYS* LPSERIALKEYS; -alias SOUNDSENTRY* LPSOUNDSENTRY; -alias CREATESTRUCT* LPCREATESTRUCT; -alias CBT_CREATEWND* LPCBT_CREATEWND; -alias MDICREATESTRUCT* LPMDICREATESTRUCT; -alias MULTIKEYHELP* PMULTIKEYHELP, LPMULTIKEYHELP; -alias MONITORINFOEX* LPMONITORINFOEX; -alias ICONMETRICS* LPICONMETRICS; -alias NONCLIENTMETRICS* LPNONCLIENTMETRICS; + alias GetTabbedTextExtent = GetTabbedTextExtentA; + alias GetUserObjectInformation = GetUserObjectInformationA; + alias GetWindowLong = GetWindowLongA; + alias GetWindowLongPtr = GetWindowLongPtrA; + alias GetWindowText = GetWindowTextA; + alias GetWindowTextLength = GetWindowTextLengthA; + alias GetAltTabInfo = GetAltTabInfoA; + alias GetWindowModuleFileName = GetWindowModuleFileNameA; + alias GrayString = GrayStringA; + alias InsertMenu = InsertMenuA; + alias InsertMenuItem = InsertMenuItemA; + alias IsCharAlpha = IsCharAlphaA; + alias IsCharAlphaNumeric = IsCharAlphaNumericA; + alias IsCharLower = IsCharLowerA; + alias IsCharUpper = IsCharUpperA; + alias IsDialogMessage = IsDialogMessageA; + alias LoadAccelerators = LoadAcceleratorsA; + alias LoadBitmap = LoadBitmapA; + alias LoadCursor = LoadCursorA; + alias LoadIcon = LoadIconA; + alias LoadCursorFromFile = LoadCursorFromFileA; + alias LoadImage = LoadImageA; + alias LoadKeyboardLayout = LoadKeyboardLayoutA; + alias LoadMenu = LoadMenuA; + alias LoadMenuIndirect = LoadMenuIndirectA; + alias LoadString = LoadStringA; + alias MapVirtualKey = MapVirtualKeyA; + alias MapVirtualKeyEx = MapVirtualKeyExA; + alias MessageBox = MessageBoxA; + alias MessageBoxEx = MessageBoxExA; + alias MessageBoxIndirect = MessageBoxIndirectA; + alias ModifyMenu = ModifyMenuA; + alias OemToChar = OemToCharA; + alias OemToCharBuff = OemToCharBuffA; + alias OpenDesktop = OpenDesktopA; + alias OpenWindowStation = OpenWindowStationA; + alias PeekMessage = PeekMessageA; + alias PostMessage = PostMessageA; + alias PostThreadMessage = PostThreadMessageA; + alias RealGetWindowClass = RealGetWindowClassA; + alias RegisterClass = RegisterClassA; + alias RegisterClassEx = RegisterClassExA; + alias RegisterClipboardFormat = RegisterClipboardFormatA; + alias RegisterDeviceNotification = RegisterDeviceNotificationA; + alias RegisterWindowMessage = RegisterWindowMessageA; + alias RemoveProp = RemovePropA; + alias SendDlgItemMessage = SendDlgItemMessageA; + alias SendMessage = SendMessageA; + alias SendMessageCallback = SendMessageCallbackA; + alias SendMessageTimeout = SendMessageTimeoutA; + alias SendNotifyMessage = SendNotifyMessageA; + alias SetClassLong = SetClassLongA; + alias SetClassLongPtr = SetClassLongPtrA; + alias SetDlgItemText = SetDlgItemTextA; + alias SetMenuItemInfo = SetMenuItemInfoA; + alias SetProp = SetPropA; + alias SetUserObjectInformation = SetUserObjectInformationA; + alias SetWindowLong = SetWindowLongA; + alias SetWindowLongPtr = SetWindowLongPtrA; + alias SetWindowsHook = SetWindowsHookA; + alias SetWindowsHookEx = SetWindowsHookExA; + alias SetWindowText = SetWindowTextA; + alias SystemParametersInfo = SystemParametersInfoA; + alias TabbedTextOut = TabbedTextOutA; + alias TranslateAccelerator = TranslateAcceleratorA; + alias UnregisterClass = UnregisterClassA; + alias VkKeyScan = VkKeyScanA; + alias VkKeyScanEx = VkKeyScanExA; + alias WinHelp = WinHelpA; + alias wsprintf = wsprintfA; + alias wvsprintf = wvsprintfA; + + alias ChangeDisplaySettings = ChangeDisplaySettingsA; + alias ChangeDisplaySettingsEx = ChangeDisplaySettingsExA; + alias CreateDesktop = CreateDesktopA; + alias EnumDisplaySettings = EnumDisplaySettingsA; + alias EnumDisplaySettingsEx = EnumDisplaySettingsExA; + alias EnumDisplayDevices = EnumDisplayDevicesA; +} + +alias LPWNDCLASS = WNDCLASS*, PWNDCLASS = WNDCLASS*; +alias LPWNDCLASSEX = WNDCLASSEX*, PWNDCLASSEX = WNDCLASSEX*; +alias LPMENUITEMINFO = MENUITEMINFO*; +alias PMSGBOXPARAMS = MSGBOXPARAMS*, LPMSGBOXPARAMS = MSGBOXPARAMS*; +alias LPHIGHCONTRAST = HIGHCONTRAST*; +alias LPSERIALKEYS = SERIALKEYS*; +alias LPSOUNDSENTRY = SOUNDSENTRY*; +alias LPCREATESTRUCT = CREATESTRUCT*; +alias LPCBT_CREATEWND = CBT_CREATEWND*; +alias LPMDICREATESTRUCT = MDICREATESTRUCT*; +alias PMULTIKEYHELP = MULTIKEYHELP*, LPMULTIKEYHELP = MULTIKEYHELP*; +alias LPMONITORINFOEX = MONITORINFOEX*; +alias LPICONMETRICS = ICONMETRICS*; +alias LPNONCLIENTMETRICS = NONCLIENTMETRICS*; static if (_WIN32_WINNT >= 0x501) { enum PW_CLIENTONLY = 0x00000001; diff --git a/runtime/druntime/src/core/sys/windows/winver.d b/runtime/druntime/src/core/sys/windows/winver.d index 646891b1be..5ef0864c44 100644 --- a/runtime/druntime/src/core/sys/windows/winver.d +++ b/runtime/druntime/src/core/sys/windows/winver.d @@ -159,21 +159,21 @@ extern (Windows) nothrow @nogc { } version (Unicode) { - alias VerFindFileW VerFindFile; - alias VerQueryValueW VerQueryValue; - alias VerInstallFileW VerInstallFile; - alias GetFileVersionInfoSizeW GetFileVersionInfoSize; - alias GetFileVersionInfoW GetFileVersionInfo; - alias VerLanguageNameW VerLanguageName; - alias VerQueryValueW VerQueryValue; + alias VerFindFile = VerFindFileW; + alias VerQueryValue = VerQueryValueW; + alias VerInstallFile = VerInstallFileW; + alias GetFileVersionInfoSize = GetFileVersionInfoSizeW; + alias GetFileVersionInfo = GetFileVersionInfoW; + alias VerLanguageName = VerLanguageNameW; + alias VerQueryValue = VerQueryValueW; } else { - alias VerQueryValueA VerQueryValue; - alias VerFindFileA VerFindFile; - alias VerInstallFileA VerInstallFile; - alias GetFileVersionInfoSizeA GetFileVersionInfoSize; - alias GetFileVersionInfoA GetFileVersionInfo; - alias VerLanguageNameA VerLanguageName; - alias VerQueryValueA VerQueryValue; + alias VerQueryValue = VerQueryValueA; + alias VerFindFile = VerFindFileA; + alias VerInstallFile = VerInstallFileA; + alias GetFileVersionInfoSize = GetFileVersionInfoSizeA; + alias GetFileVersionInfo = GetFileVersionInfoA; + alias VerLanguageName = VerLanguageNameA; + alias VerQueryValue = VerQueryValueA; } alias VERSIONHELPERAPI = BOOL; diff --git a/runtime/druntime/src/core/sys/windows/wtsapi32.d b/runtime/druntime/src/core/sys/windows/wtsapi32.d index 4db697a650..c398c630f3 100644 --- a/runtime/druntime/src/core/sys/windows/wtsapi32.d +++ b/runtime/druntime/src/core/sys/windows/wtsapi32.d @@ -51,19 +51,19 @@ enum WTS_CONNECTSTATE_CLASS { struct WTS_SERVER_INFOW { LPWSTR pServerName; } -alias WTS_SERVER_INFOW* PWTS_SERVER_INFOW; +alias PWTS_SERVER_INFOW = WTS_SERVER_INFOW*; struct WTS_SERVER_INFOA { LPSTR pServerName; } -alias WTS_SERVER_INFOA* PWTS_SERVER_INFOA; +alias PWTS_SERVER_INFOA = WTS_SERVER_INFOA*; version (Unicode) { - alias WTS_SERVER_INFOW WTS_SERVER_INFO; - alias PWTS_SERVER_INFOW PWTS_SERVER_INFO; + alias WTS_SERVER_INFO = WTS_SERVER_INFOW; + alias PWTS_SERVER_INFO = PWTS_SERVER_INFOW; } else { - alias WTS_SERVER_INFOA WTS_SERVER_INFO; - alias PWTS_SERVER_INFOA PWTS_SERVER_INFO; + alias WTS_SERVER_INFO = WTS_SERVER_INFOA; + alias PWTS_SERVER_INFO = PWTS_SERVER_INFOA; } struct WTS_SESSION_INFOW { @@ -71,21 +71,21 @@ struct WTS_SESSION_INFOW { LPWSTR pWinStationName; WTS_CONNECTSTATE_CLASS State; } -alias WTS_SESSION_INFOW* PWTS_SESSION_INFOW; +alias PWTS_SESSION_INFOW = WTS_SESSION_INFOW*; struct WTS_SESSION_INFOA { DWORD SessionId; LPSTR pWinStationName; WTS_CONNECTSTATE_CLASS State; } -alias WTS_SESSION_INFOA* PWTS_SESSION_INFOA; +alias PWTS_SESSION_INFOA = WTS_SESSION_INFOA*; version (Unicode) { - alias WTS_SESSION_INFOW WTS_SESSION_INFO; - alias PWTS_SESSION_INFOW PWTS_SESSION_INFO; + alias WTS_SESSION_INFO = WTS_SESSION_INFOW; + alias PWTS_SESSION_INFO = PWTS_SESSION_INFOW; } else { - alias WTS_SESSION_INFOA WTS_SESSION_INFO; - alias PWTS_SESSION_INFOA PWTS_SESSION_INFO; + alias WTS_SESSION_INFO = WTS_SESSION_INFOA; + alias PWTS_SESSION_INFO = PWTS_SESSION_INFOA; } struct WTS_PROCESS_INFOW { @@ -94,7 +94,7 @@ struct WTS_PROCESS_INFOW { LPWSTR pProcessName; PSID pUserSid; } -alias WTS_PROCESS_INFOW* PWTS_PROCESS_INFOW; +alias PWTS_PROCESS_INFOW = WTS_PROCESS_INFOW*; struct WTS_PROCESS_INFOA { DWORD SessionId; @@ -102,14 +102,14 @@ struct WTS_PROCESS_INFOA { LPSTR pProcessName; PSID pUserSid; } -alias WTS_PROCESS_INFOA* PWTS_PROCESS_INFOA; +alias PWTS_PROCESS_INFOA = WTS_PROCESS_INFOA*; version (Unicode) { - alias WTS_PROCESS_INFOW WTS_PROCESS_INFO; - alias PWTS_PROCESS_INFOW PWTS_PROCESS_INFO; + alias WTS_PROCESS_INFO = WTS_PROCESS_INFOW; + alias PWTS_PROCESS_INFO = PWTS_PROCESS_INFOW; } else { - alias WTS_PROCESS_INFOA WTS_PROCESS_INFO; - alias PWTS_PROCESS_INFOA PWTS_PROCESS_INFO; + alias WTS_PROCESS_INFO = WTS_PROCESS_INFOA; + alias PWTS_PROCESS_INFO = PWTS_PROCESS_INFOA; } enum { @@ -150,14 +150,14 @@ struct WTS_CLIENT_ADDRESS { DWORD AddressFamily; BYTE[20] Address; } -alias WTS_CLIENT_ADDRESS* PWTS_CLIENT_ADDRESS; +alias PWTS_CLIENT_ADDRESS = WTS_CLIENT_ADDRESS*; struct WTS_CLIENT_DISPLAY { DWORD HorizontalResolution; DWORD VerticalResolution; DWORD ColorDepth; } -alias WTS_CLIENT_DISPLAY* PWTS_CLIENT_DISPLAY; +alias PWTS_CLIENT_DISPLAY = WTS_CLIENT_DISPLAY*; enum WTS_CONFIG_CLASS { WTSUserConfigInitialProgram, @@ -202,23 +202,23 @@ enum WTS_VIRTUAL_CLASS { } version (Unicode) { - alias WTSEnumerateServersW WTSEnumerateServers; - alias WTSOpenServerW WTSOpenServer; - alias WTSEnumerateSessionsW WTSEnumerateSessions; - alias WTSEnumerateProcessesW WTSEnumerateProcesses; - alias WTSQuerySessionInformationW WTSQuerySessionInformation; - alias WTSQueryUserConfigW WTSQueryUserConfig; - alias WTSSetUserConfigW WTSSetUserConfig; - alias WTSSendMessageW WTSSendMessage; + alias WTSEnumerateServers = WTSEnumerateServersW; + alias WTSOpenServer = WTSOpenServerW; + alias WTSEnumerateSessions = WTSEnumerateSessionsW; + alias WTSEnumerateProcesses = WTSEnumerateProcessesW; + alias WTSQuerySessionInformation = WTSQuerySessionInformationW; + alias WTSQueryUserConfig = WTSQueryUserConfigW; + alias WTSSetUserConfig = WTSSetUserConfigW; + alias WTSSendMessage = WTSSendMessageW; } else { - alias WTSEnumerateServersA WTSEnumerateServers; - alias WTSOpenServerA WTSOpenServer; - alias WTSEnumerateSessionsA WTSEnumerateSessions; - alias WTSEnumerateProcessesA WTSEnumerateProcesses; - alias WTSQuerySessionInformationA WTSQuerySessionInformation; - alias WTSQueryUserConfigA WTSQueryUserConfig; - alias WTSSetUserConfigA WTSSetUserConfig; - alias WTSSendMessageA WTSSendMessage; + alias WTSEnumerateServers = WTSEnumerateServersA; + alias WTSOpenServer = WTSOpenServerA; + alias WTSEnumerateSessions = WTSEnumerateSessionsA; + alias WTSEnumerateProcesses = WTSEnumerateProcessesA; + alias WTSQuerySessionInformation = WTSQuerySessionInformationA; + alias WTSQueryUserConfig = WTSQueryUserConfigA; + alias WTSSetUserConfig = WTSSetUserConfigA; + alias WTSSendMessage = WTSSendMessageA; } extern(Windows) { @@ -293,7 +293,7 @@ static if (_WIN32_WINNT >= 0x600) { USHORT OutBufLength; WCHAR[MAX_PATH + 1] DeviceId = 0; } - alias WTSCLIENTW* PWTSCLIENTW; + alias PWTSCLIENTW = WTSCLIENTW*; struct WTSCLIENTA { CHAR[CLIENTNAME_LENGTH + 1] ClientName = 0; @@ -316,14 +316,14 @@ static if (_WIN32_WINNT >= 0x600) { USHORT OutBufLength; CHAR[MAX_PATH + 1] DeviceId = 0; } - alias WTSCLIENTA* PWTSCLIENTA; + alias PWTSCLIENTA = WTSCLIENTA*; version (Unicode) { - alias WTSCLIENTW WTSCLIENT; - alias PWTSCLIENTW PWTSCLIENT; + alias WTSCLIENT = WTSCLIENTW; + alias PWTSCLIENT = PWTSCLIENTW; } else { - alias WTSCLIENTA WTSCLIENT; - alias PWTSCLIENTA PWTSCLIENT; + alias WTSCLIENT = WTSCLIENTA; + alias PWTSCLIENT = PWTSCLIENTA; } struct WTSINFOW { @@ -344,7 +344,7 @@ static if (_WIN32_WINNT >= 0x600) { LARGE_INTEGER LogonTime; LARGE_INTEGER CurrentTime; } - alias WTSINFOW* PWTSINFOW; + alias PWTSINFOW = WTSINFOW*; struct WTSINFOA { WTS_CONNECTSTATE_CLASS State; @@ -364,14 +364,14 @@ static if (_WIN32_WINNT >= 0x600) { LARGE_INTEGER LogonTime; LARGE_INTEGER CurrentTime; } - alias WTSINFOA* PWTSINFOA; + alias PWTSINFOA = WTSINFOA*; version (Unicode) { - alias WTSINFOW WTSINFO; - alias PWTSINFOW PWTSINFO; + alias WTSINFO = WTSINFOW; + alias PWTSINFO = PWTSINFOW; } else { - alias WTSINFOA WTSINFO; - alias PWTSINFOA PWTSINFO; + alias WTSINFO = WTSINFOA; + alias PWTSINFO = PWTSINFOA; } extern(Windows) { @@ -410,11 +410,11 @@ static if (_WIN32_WINNT >= 0x600) { ); version (Unicode) { - alias WTSStartRemoteControlSessionW WTSStartRemoteControlSession; - alias WTSConnectSessionW WTSConnectSession; + alias WTSStartRemoteControlSession = WTSStartRemoteControlSessionW; + alias WTSConnectSession = WTSConnectSessionW; } else { - alias WTSStartRemoteControlSessionA WTSStartRemoteControlSession; - alias WTSConnectSessionA WTSConnectSession; + alias WTSStartRemoteControlSession = WTSStartRemoteControlSessionA; + alias WTSConnectSession = WTSConnectSessionA; } WINBOOL WTSStopRemoteControlSession( diff --git a/runtime/druntime/src/core/sys/windows/wtypes.d b/runtime/druntime/src/core/sys/windows/wtypes.d index 881f05a650..c2dd6f6452 100644 --- a/runtime/druntime/src/core/sys/windows/wtypes.d +++ b/runtime/druntime/src/core/sys/windows/wtypes.d @@ -13,7 +13,7 @@ import core.sys.windows.rpc, core.sys.windows.rpcndr; import core.sys.windows.windef; import core.sys.windows.uuid; // for GUID_NULL -alias GUID_NULL IID_NULL, CLSID_NULL; +alias IID_NULL = GUID_NULL, CLSID_NULL = GUID_NULL; enum ROTFLAGS_REGISTRATIONKEEPSALIVE = 0x01; enum ROTFLAGS_ALLOWANYCLIENT = 0x02; @@ -23,7 +23,7 @@ struct BLOB { ULONG cbSize; BYTE* pBlobData; } -alias BLOB* PBLOB, LPBLOB; +alias PBLOB = BLOB*, LPBLOB = BLOB*; enum DVASPECT { DVASPECT_CONTENT = 1, @@ -82,19 +82,19 @@ struct FLAGGED_WORD_BLOB { ushort[1] asData; } -alias WCHAR OLECHAR; -alias LPWSTR LPOLESTR; -alias LPCWSTR LPCOLESTR; +alias OLECHAR = WCHAR; +alias LPOLESTR = LPWSTR; +alias LPCOLESTR = LPCWSTR; -alias ushort VARTYPE; -alias short VARIANT_BOOL; -alias VARIANT_BOOL _VARIANT_BOOL; +alias VARTYPE = ushort; +alias VARIANT_BOOL = short; +alias _VARIANT_BOOL = VARIANT_BOOL; enum VARIANT_BOOL VARIANT_TRUE = -1; // 0xffff; enum VARIANT_BOOL VARIANT_FALSE = 0; -alias OLECHAR* BSTR; -alias FLAGGED_WORD_BLOB* wireBSTR; -alias BSTR* LPBSTR; +alias BSTR = OLECHAR*; +alias wireBSTR = FLAGGED_WORD_BLOB*; +alias LPBSTR = BSTR*; //alias LONG SCODE; // also in winerror alias HCONTEXT = HANDLE; alias HMETAFILEPICT = HANDLE; @@ -107,12 +107,12 @@ union CY { LONGLONG int64; } -alias double DATE; +alias DATE = double; struct BSTRBLOB { ULONG cbSize; PBYTE pData; } -alias BSTRBLOB* LPBSTRBLOB; +alias LPBSTRBLOB = BSTRBLOB*; // Used only in the PROPVARIANT structure // According to the 2003 SDK, this should be in propidl.h, not here. @@ -209,7 +209,7 @@ struct HYPER_SIZEDARR { hyper* pData; } -alias double DOUBLE; +alias DOUBLE = double; struct DECIMAL { diff --git a/runtime/druntime/src/core/time.d b/runtime/druntime/src/core/time.d index 8189e67f8a..beb6963486 100644 --- a/runtime/druntime/src/core/time.d +++ b/runtime/druntime/src/core/time.d @@ -112,7 +112,7 @@ struct mach_timebase_info_data_t uint denom; } -alias mach_timebase_info_data_t* mach_timebase_info_t; +alias mach_timebase_info_t = mach_timebase_info_data_t*; kern_return_t mach_timebase_info(mach_timebase_info_t); @@ -1561,8 +1561,8 @@ public: static assert(!is(typeof(d.split("hnsecs", "seconds", "msecs")()))); static assert(!is(typeof(d.split("seconds", "hnecs", "msecs")()))); static assert(!is(typeof(d.split("seconds", "msecs", "msecs")()))); - alias AliasSeq!("nsecs", "hnsecs", "usecs", "msecs", "seconds", - "minutes", "hours", "days", "weeks") timeStrs; + alias timeStrs = AliasSeq!("nsecs", "hnsecs", "usecs", "msecs", "seconds", + "minutes", "hours", "days", "weeks"); foreach (i, str; timeStrs[1 .. $]) static assert(!is(typeof(d.split!(timeStrs[i - 1], str)()))); diff --git a/runtime/druntime/src/rt/deh_win32.d b/runtime/druntime/src/rt/deh_win32.d index fbf07437f0..d9cc95e25f 100644 --- a/runtime/druntime/src/rt/deh_win32.d +++ b/runtime/druntime/src/rt/deh_win32.d @@ -157,7 +157,7 @@ struct CONTEXT { BYTE[MAXIMUM_SUPPORTED_EXTENSION] ExtendedRegisters; } -alias CONTEXT* PCONTEXT, LPCONTEXT; +alias PCONTEXT = CONTEXT*, LPCONTEXT = CONTEXT*; struct EXCEPTION_RECORD { DWORD ExceptionCode; @@ -167,13 +167,13 @@ struct EXCEPTION_RECORD { DWORD NumberParameters; ULONG_PTR[EXCEPTION_MAXIMUM_PARAMETERS] ExceptionInformation; } -alias EXCEPTION_RECORD* PEXCEPTION_RECORD, LPEXCEPTION_RECORD; +alias PEXCEPTION_RECORD = EXCEPTION_RECORD*, LPEXCEPTION_RECORD = EXCEPTION_RECORD*; struct EXCEPTION_POINTERS { PEXCEPTION_RECORD ExceptionRecord; PCONTEXT ContextRecord; } -alias EXCEPTION_POINTERS* PEXCEPTION_POINTERS, LPEXCEPTION_POINTERS; +alias PEXCEPTION_POINTERS = EXCEPTION_POINTERS*, LPEXCEPTION_POINTERS = EXCEPTION_POINTERS*; enum EXCEPTION_UNWIND = 6; // Flag to indicate if the system is unwinding /+ Values used by Microsoft for Itanium and Win64 are: @@ -292,11 +292,11 @@ each function which uses exceptions. extern(C) { alias - EXCEPTION_DISPOSITION function ( + LanguageSpecificHandler = EXCEPTION_DISPOSITION function ( EXCEPTION_RECORD *exceptionRecord, DEstablisherFrame *frame, CONTEXT *context, - void *dispatcherContext) LanguageSpecificHandler; + void *dispatcherContext); } @@ -575,7 +575,7 @@ EXCEPTION_DISPOSITION _d_framehandler( // Jump to catch block. Does not return. { uint catch_esp; - alias void function() fp_t; // generic function pointer + alias fp_t = void function(); // generic function pointer fp_t catch_addr = cast(fp_t)(pcb.code); catch_esp = regebp - handlerTable.espoffset - fp_t.sizeof; asm diff --git a/runtime/druntime/src/rt/deh_win64_posix.d b/runtime/druntime/src/rt/deh_win64_posix.d index 801b952817..2acdbf8852 100644 --- a/runtime/druntime/src/rt/deh_win64_posix.d +++ b/runtime/druntime/src/rt/deh_win64_posix.d @@ -41,7 +41,7 @@ extern (C) void _d_createTrace(Throwable o, void* context); } -alias int function() fp_t; // function pointer in ambient memory model +alias fp_t = int function(); // function pointer in ambient memory model // DHandlerInfo table is generated by except_gentables() in eh.c diff --git a/runtime/druntime/src/rt/dmain2.d b/runtime/druntime/src/rt/dmain2.d index f1e94913da..0f7c816152 100644 --- a/runtime/druntime/src/rt/dmain2.d +++ b/runtime/druntime/src/rt/dmain2.d @@ -89,7 +89,7 @@ extern (C) string[] rt_args() // be fine to leave it as __gshared. extern (C) __gshared bool rt_trapExceptions = true; -alias void delegate(Throwable) ExceptionHandler; +alias ExceptionHandler = void delegate(Throwable); /** * Keep track of how often rt_init/rt_term were called. @@ -179,7 +179,7 @@ bool isRuntimeInitialized() @nogc nothrow { /********************************************** * Trace handler */ -alias Throwable.TraceInfo function(void* ptr) TraceHandler; +alias TraceHandler = Throwable.TraceInfo function(void* ptr); private __gshared TraceHandler traceHandler = null; private __gshared Throwable.TraceDeallocator traceDeallocator = null; @@ -250,7 +250,7 @@ extern (C) CArgs rt_cArgs() @nogc } /// Type of the D main() function (`_Dmain`). -private alias extern(C) int function(char[][] args) MainFunc; +private alias MainFunc = extern(C) int function(char[][] args); /** * Sets up the D char[][] command-line args, initializes druntime, @@ -644,7 +644,7 @@ extern (C) void _d_print_throwable(Throwable t) // by loading it dynamically as needed if (auto user32 = LoadLibraryW("user32.dll")) { - alias typeof(&MessageBoxW) PMessageBoxW; + alias PMessageBoxW = typeof(&MessageBoxW) ; if (auto pMessageBoxW = cast(PMessageBoxW) GetProcAddress(user32, "MessageBoxW")) pMessageBoxW(null, buf.get(), caption.get(), MB_ICONERROR); FreeLibrary(user32); diff --git a/runtime/druntime/src/rt/lifetime.d b/runtime/druntime/src/rt/lifetime.d index 159df5956b..fceb77d649 100644 --- a/runtime/druntime/src/rt/lifetime.d +++ b/runtime/druntime/src/rt/lifetime.d @@ -36,7 +36,7 @@ extern(C) { private { - alias bool function(Object) CollectHandler; + alias CollectHandler = bool function(Object); __gshared CollectHandler collectHandler = null; extern (C) void _d_monitordelete(Object h, bool det); @@ -153,7 +153,7 @@ extern (C) void _d_delinterface(void** p) // used for deletion -private extern (D) alias void function (Object) fp_t; +private extern (D) alias fp_t = void function (Object); /** diff --git a/runtime/druntime/src/rt/sections_elf_shared.d b/runtime/druntime/src/rt/sections_elf_shared.d index 2061d3caeb..aac5b402ae 100644 --- a/runtime/druntime/src/rt/sections_elf_shared.d +++ b/runtime/druntime/src/rt/sections_elf_shared.d @@ -71,7 +71,7 @@ else debug (PRINTF) import core.stdc.stdio : printf; -alias DSO SectionGroup; +alias SectionGroup = DSO; struct DSO { static int opApply(scope int delegate(ref DSO) dg) diff --git a/runtime/druntime/src/rt/sections_win64.d b/runtime/druntime/src/rt/sections_win64.d index dc6e211783..ab14bc02bb 100644 --- a/runtime/druntime/src/rt/sections_win64.d +++ b/runtime/druntime/src/rt/sections_win64.d @@ -409,8 +409,8 @@ extern (C) void gc_setProxy(void* p); void gc_clrProxy(); - alias void function(void*) gcSetFn; - alias void function() gcClrFn; + alias gcSetFn = void function(void*); + alias gcClrFn = void function(); } /******************************************* diff --git a/runtime/druntime/src/rt/tlsgc.d b/runtime/druntime/src/rt/tlsgc.d index 2b21d1e0e1..3aea706c45 100644 --- a/runtime/druntime/src/rt/tlsgc.d +++ b/runtime/druntime/src/rt/tlsgc.d @@ -52,7 +52,7 @@ void destroy(void* data) nothrow @nogc .free(data); } -alias void delegate(void* pstart, void* pend) nothrow ScanDg; +alias ScanDg = void delegate(void* pstart, void* pend) nothrow; /** * GC scan hook, called FOR each thread. Can be used to scan diff --git a/runtime/druntime/src/rt/trace.d b/runtime/druntime/src/rt/trace.d index 18ef2306d0..b563368685 100644 --- a/runtime/druntime/src/rt/trace.d +++ b/runtime/druntime/src/rt/trace.d @@ -93,7 +93,7 @@ void updateFileName(ref char[] filename, string name) assert(0, "Memory allocation failed"); } -alias long timer_t; +alias timer_t = long; ///////////////////////////////////// // From 264912e9ad00f53ad319570465948be5d548798a Mon Sep 17 00:00:00 2001 From: Rainer Date: Mon, 2 Feb 2026 22:20:09 +0100 Subject: [PATCH 309/440] fix dlang/dmd!19675 - fatal error LNK1179 on windows-x86_64-dmd with MSVC don't modify and emit __bzeroBytes if it comes from a previous object file --- tests/dmd/runnable/extra-files/gc19675.d | 10 ++++++++++ tests/dmd/runnable/extra-files/main19675.d | 10 ++++++++++ tests/dmd/runnable/extra-files/memory19675.d | 16 ++++++++++++++++ tests/dmd/runnable/test19675.sh | 6 ++++++ 4 files changed, 42 insertions(+) create mode 100644 tests/dmd/runnable/extra-files/gc19675.d create mode 100644 tests/dmd/runnable/extra-files/main19675.d create mode 100644 tests/dmd/runnable/extra-files/memory19675.d create mode 100644 tests/dmd/runnable/test19675.sh diff --git a/tests/dmd/runnable/extra-files/gc19675.d b/tests/dmd/runnable/extra-files/gc19675.d new file mode 100644 index 0000000000..98b1302b12 --- /dev/null +++ b/tests/dmd/runnable/extra-files/gc19675.d @@ -0,0 +1,10 @@ +module gc19675; +import memory19675; + +class ManualGC +{ + GC.ProfileStats profileStats() + { + return typeof(return).init; + } +} diff --git a/tests/dmd/runnable/extra-files/main19675.d b/tests/dmd/runnable/extra-files/main19675.d new file mode 100644 index 0000000000..782469d8cb --- /dev/null +++ b/tests/dmd/runnable/extra-files/main19675.d @@ -0,0 +1,10 @@ +import gc19675; +import memory19675; + +void main() +{ + auto p = new ManualGC; + auto s = p.profileStats(); + auto s2 = GC.profileStats(); + assert(s.numCollections[0] == 0); +} diff --git a/tests/dmd/runnable/extra-files/memory19675.d b/tests/dmd/runnable/extra-files/memory19675.d new file mode 100644 index 0000000000..19ee7052aa --- /dev/null +++ b/tests/dmd/runnable/extra-files/memory19675.d @@ -0,0 +1,16 @@ + +module memory19675; + +struct GC +{ + struct ProfileStats + { + size_t[10] numCollections; + } + static ProfileStats profileStats() + { + return typeof(return).init; + } + +} + diff --git a/tests/dmd/runnable/test19675.sh b/tests/dmd/runnable/test19675.sh new file mode 100644 index 0000000000..bd588c686a --- /dev/null +++ b/tests/dmd/runnable/test19675.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +$DMD -m${MODEL} -I${EXTRA_FILES} -of${OUTPUT_BASE}${LIBEXT} -lib ${EXTRA_FILES}/gc19675.d ${EXTRA_FILES}/memory19675.d +$DMD -m${MODEL} -I${EXTRA_FILES} -of${OUTPUT_BASE}${EXE} ${EXTRA_FILES}/main19675.d ${OUTPUT_BASE}${LIBEXT} + +rm_retry ${OUTPUT_BASE}{${LIBEXT},${EXE}} From 0ea1cc2219edc4a25cbfa6483883eaf30619a66b Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Mon, 2 Feb 2026 23:15:17 -0800 Subject: [PATCH 310/440] reals are 8 bytes --- dmd/target.d | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dmd/target.d b/dmd/target.d index 848844e6ed..dbd9bb9c43 100644 --- a/dmd/target.d +++ b/dmd/target.d @@ -493,6 +493,13 @@ extern (C++) struct Target } } + if (isAArch64 && os & Target.OS.OSX) // OSX for AArch64 has 8 byte reals + { + realsize = 8; + realpad = 0; + realalignsize = 8; + } + c.initialize(params, this); cpp.initialize(params, this); objc.initialize(params, this); From 274f296840cb113bf8697f5e0d85b3418bdbd9fc Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Tue, 3 Feb 2026 16:20:07 +0100 Subject: [PATCH 311/440] Fix dlang/dmd!22504 - druntime fails to build on powerpc64le-linux-gnu It's now required to enclose the ConditionalExpression of an AsmStringExpr around parentheses. Closes dlang/dmd!22504 --- runtime/druntime/src/core/thread/osthread.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/druntime/src/core/thread/osthread.d b/runtime/druntime/src/core/thread/osthread.d index a19eda61d5..6827dad619 100644 --- a/runtime/druntime/src/core/thread/osthread.d +++ b/runtime/druntime/src/core/thread/osthread.d @@ -1416,7 +1416,7 @@ in (fn) enum int j = 13 + i; // source register asm pure nothrow @nogc { - "stw "~regname~j.stringof~", %0" : "=m" (regs[i]); + ("stw "~regname~j.stringof~", %0") : "=m" (regs[i]); } }} sp = cast(void*)®s[0]; @@ -1433,7 +1433,7 @@ in (fn) enum int j = 13 + i; // source register asm pure nothrow @nogc { - "std "~regname~j.stringof~", %0" : "=m" (regs[i]); + ("std "~regname~j.stringof~", %0") : "=m" (regs[i]); } }} sp = cast(void*)®s[0]; From 86fb9cda2efc8f78d725fce5abbd4bcbb74ee853 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Tue, 3 Feb 2026 21:14:59 -0800 Subject: [PATCH 312/440] no AArch64 inline asm yet, thunk function type (dlang/dmd!22506) --- tests/dmd/runnable/test36.d | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/tests/dmd/runnable/test36.d b/tests/dmd/runnable/test36.d index 1403154a77..820fb9cd03 100644 --- a/tests/dmd/runnable/test36.d +++ b/tests/dmd/runnable/test36.d @@ -32,9 +32,14 @@ extern (Windows): override void func() { int esp; - asm{ - mov esp,ESP; - } + version (D_InlineAsm_X86) + asm{ + mov esp,ESP; + } + version (D_InlineAsm_X86_64) + asm{ + mov esp,ESP; + } printf("\n%d",esp); printf(`func`); } @@ -47,15 +52,25 @@ int main() { auto inst= new invarianttest; int esp; - asm{ - mov esp,ESP; - } + version (D_InlineAsm_X86) + asm{ + mov esp,ESP; + } + version (D_InlineAsm_X86_64) + asm{ + mov esp,ESP; + } inst.func(); inst.method(); printf("\n%d\n",esp); - asm{ - mov esp,ESP; - } + version (D_InlineAsm_X86) + asm{ + mov esp,ESP; + } + version (D_InlineAsm_X86_64) + asm{ + mov esp,ESP; + } printf("\n%d\n",esp); return 0; } From 876714bfa550b00c6a226566185f6cfb50bb9a04 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Tue, 3 Feb 2026 23:03:19 -0800 Subject: [PATCH 313/440] use argtypes_aarch64.d for AArch64 --- dmd/target.d | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/dmd/target.d b/dmd/target.d index dbd9bb9c43..34d5cf0db3 100644 --- a/dmd/target.d +++ b/dmd/target.d @@ -988,14 +988,24 @@ extern (C++) struct Target */ extern (C++) TypeTuple toArgTypes(Type t) { - import dmd.argtypes_x86 : toArgTypes_x86; import dmd.argtypes_sysv_x64 : toArgTypes_sysv_x64; - if (isX86_64 || isAArch64) + if (isX86_64) { // no argTypes for Win64 yet return isPOSIX ? toArgTypes_sysv_x64(t) : null; } - return toArgTypes_x86(t); + else if (isX86) + { + import dmd.argtypes_x86 : toArgTypes_x86; + return toArgTypes_x86(t); + } + else if (isAArch64) + { + import dmd.argtypes_aarch64 : toArgTypes_aarch64; + return toArgTypes_aarch64(t); + } + else + assert(0); } /** @@ -1073,7 +1083,7 @@ extern (C++) struct Target return true; } } - else if ((isX86_64 || isAArch64) && isPOSIX) + else if (isX86_64 && isPOSIX) { TypeTuple tt = toArgTypes_sysv_x64(tn); if (!tt) @@ -1081,6 +1091,16 @@ extern (C++) struct Target return !tt.arguments.length; } + else if (isAArch64 && isPOSIX) + { + import dmd.argtypes_aarch64 : toArgTypes_aarch64; + + TypeTuple tt = toArgTypes_aarch64(tn); + if (!tt) + return false; // void + + return !tt.arguments.length; + } Lagain: if (tns.ty == TY.Tsarray) From 415df7282404078724383b18c2277885ec649f47 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Wed, 4 Feb 2026 18:12:49 +0800 Subject: [PATCH 314/440] Fix dlang/dmd!22489 - `e - e` is not always 0 for floating point numbers --- tests/dmd/runnable/test22489.d | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/dmd/runnable/test22489.d diff --git a/tests/dmd/runnable/test22489.d b/tests/dmd/runnable/test22489.d new file mode 100644 index 0000000000..e0bfee3946 --- /dev/null +++ b/tests/dmd/runnable/test22489.d @@ -0,0 +1,20 @@ +// REQUIRED_ARGS: -inline -O + +real f(real r) +{ + return r - real.infinity; +} + +void main() +{ + assert(f(real.infinity) != f(real.infinity)); + + version (D_SIMD) + { + import core.simd; + float4 v1 = float.infinity; + float4 v2 = v1 - v1; + static foreach (i; 0 .. 4) + assert(v2[i] != v2[i]); + } +} From 01c4880b9c1e03ad21228b71e5d1a41a39a2a702 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Wed, 4 Feb 2026 21:56:01 -0800 Subject: [PATCH 315/440] use functions for OPbt, OPbsr, etc. --- runtime/druntime/src/core/bitop.d | 55 ++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/runtime/druntime/src/core/bitop.d b/runtime/druntime/src/core/bitop.d index cc05247d6c..2888a523e1 100644 --- a/runtime/druntime/src/core/bitop.d +++ b/runtime/druntime/src/core/bitop.d @@ -292,13 +292,44 @@ int bt(const scope size_t* p, size_t bitnum) pure @system /** * Tests and complements the bit. */ -int btc(size_t* p, size_t bitnum) pure @system; - +int btc(size_t* p, size_t bitnum) pure @system +{ + static if (size_t.sizeof == 8) + { + int result = ((p[bitnum >> 6] & (1L << (bitnum & 63)))) != 0; + p[bitnum >> 6] ^= (1L << (bitnum & 63)); + return result; + } + else static if (size_t.sizeof == 4) + { + int result = ((p[bitnum >> 5] & (1L << (bitnum & 31)))) != 0; + p[bitnum >> 5] ^= (1L << (bitnum & 31)); + return result; + } + else + static assert(0); +} /** * Tests and resets (sets to 0) the bit. */ -int btr(size_t* p, size_t bitnum) pure @system; +int btr(size_t* p, size_t bitnum) pure @system +{ + static if (size_t.sizeof == 8) + { + int result = ((p[bitnum >> 6] & (1L << (bitnum & 63)))) != 0; + p[bitnum >> 6] &= ~(1L << (bitnum & 63)); + return result; + } + else static if (size_t.sizeof == 4) + { + int result = ((p[bitnum >> 5] & (1L << (bitnum & 31)))) != 0; + p[bitnum >> 5] &= ~(1L << (bitnum & 31)); + return result; + } + else + static assert(0); +} /** @@ -314,7 +345,23 @@ p[index / (size_t.sizeof*8)] & (1 << (index & ((size_t.sizeof*8) - 1))) * A non-zero value if the bit was set, and a zero * if it was clear. */ -int bts(size_t* p, size_t bitnum) pure @system; +int bts(size_t* p, size_t bitnum) pure @system +{ + static if (size_t.sizeof == 8) + { + int result = ((p[bitnum >> 6] & (1L << (bitnum & 63)))) != 0; + p[bitnum >> 6] |= (1L << (bitnum & 63)); + return result; + } + else static if (size_t.sizeof == 4) + { + int result = ((p[bitnum >> 5] & (1L << (bitnum & 31)))) != 0; + p[bitnum >> 5] |= (1L << (bitnum & 31)); + return result; + } + else + static assert(0); +} /// @system pure unittest From 1b5ff2b10b639b4abd6983a05d71b2f8215c542b Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Thu, 5 Feb 2026 01:01:15 +0100 Subject: [PATCH 316/440] Fix dlang/dmd!22512 - druntime fails to build on sparcv9-sun-solaris2.11 An import in dlang/dmd!22092 introduced a new circular dependency, likely triggering a facet of the issue described in dlang/dmd!17982. This breaks the circular module dependency by moving the import inside the function body instead. Closes: dlang/dmd!22512 --- runtime/druntime/src/core/sys/posix/signal.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/druntime/src/core/sys/posix/signal.d b/runtime/druntime/src/core/sys/posix/signal.d index aed6ca7bca..73da7607c5 100644 --- a/runtime/druntime/src/core/sys/posix/signal.d +++ b/runtime/druntime/src/core/sys/posix/signal.d @@ -133,9 +133,8 @@ union sigval version (Solaris) { - import core.sys.posix.unistd; - @property int SIGRTMIN() nothrow @nogc { + import core.sys.posix.unistd : sysconf, _SC_SIGRT_MIN; __gshared int sig = -1; if (sig == -1) { sig = cast(int)sysconf(_SC_SIGRT_MIN); @@ -144,6 +143,7 @@ version (Solaris) } @property int SIGRTMAX() nothrow @nogc { + import core.sys.posix.unistd : sysconf, _SC_SIGRT_MAX; __gshared int sig = -1; if (sig == -1) { sig = cast(int)sysconf(_SC_SIGRT_MAX); From 36bed4a6c2e970979481b6fd735774f8c146e1ab Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Thu, 5 Feb 2026 16:18:31 +0100 Subject: [PATCH 317/440] Add missing directives to compiler tests --- tests/dmd/compilable/test18127.d | 1 + tests/dmd/compilable/test20499.d | 1 + tests/dmd/runnable/pragmainline.d | 1 + 3 files changed, 3 insertions(+) diff --git a/tests/dmd/compilable/test18127.d b/tests/dmd/compilable/test18127.d index 35e6bdc5b1..3d6b454a2b 100644 --- a/tests/dmd/compilable/test18127.d +++ b/tests/dmd/compilable/test18127.d @@ -1,4 +1,5 @@ // https://github.com/dlang/dmd/issues/18127 +// EXTRA_FILES: imports/imp18127a.c imports/imp18127b.c import imports.imp18127a; import imports.imp18127b; diff --git a/tests/dmd/compilable/test20499.d b/tests/dmd/compilable/test20499.d index 9e9e1d2712..3263aed66b 100644 --- a/tests/dmd/compilable/test20499.d +++ b/tests/dmd/compilable/test20499.d @@ -1,2 +1,3 @@ // https://github.com/dlang/dmd/issues/20499 +// EXTRA_FILES: imports/imp20499.c import imports.imp20499; diff --git a/tests/dmd/runnable/pragmainline.d b/tests/dmd/runnable/pragmainline.d index 6db0767460..f1b132f969 100644 --- a/tests/dmd/runnable/pragmainline.d +++ b/tests/dmd/runnable/pragmainline.d @@ -1,4 +1,5 @@ // REQUIRED_ARGS: -wi +// EXTRA_FILES: imports/pragmainline_a.d /* TEST_OUTPUT: --- --- From 9c49b8eaf335f2ef35f10521b8312e3bd134acca Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Thu, 5 Feb 2026 16:19:19 +0100 Subject: [PATCH 318/440] Fix some pragma mangle tests --- tests/dmd/compilable/pragmamangle1.d | 17 +++++++++-------- tests/dmd/compilable/pragmamangle2.d | 19 ++++++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/tests/dmd/compilable/pragmamangle1.d b/tests/dmd/compilable/pragmamangle1.d index ca9bc7e80c..729afd2129 100644 --- a/tests/dmd/compilable/pragmamangle1.d +++ b/tests/dmd/compilable/pragmamangle1.d @@ -3,8 +3,9 @@ module pragmamangle; version (Posix): // Itanium C++ ABI only -string ctfe_function() { return "mangle_" ~ "ctfe_" ~ "function"; } -immutable string const_variable = "mangle_const"; +string ctfe(string s) { return "mangle_" ~ "ctfe_" ~ s; } +immutable string const_function = "mangle_const_function"; +immutable string const_variable = "mangle_const_variable"; // This mangle string doesn't propagate to tests that use type_symbol. pragma(mangle, "Q_should_mangle_string_propagate") @@ -23,17 +24,17 @@ static assert(test_pokeattr1.mangleof == "mangle_attribute"); /* 2a. For variables and functions there must be one AssignExpression and it * must evaluate at compile time to a string literal */ -pragma(mangle, ctfe_function) void test_fun2a1(); +pragma(mangle, ctfe("function")) void test_fun2a1(); static assert(test_fun2a1.mangleof == "mangle_ctfe_function"); -pragma(mangle, const_variable) void test_fun2a2(); -static assert(test_fun2a2.mangleof == "mangle_const"); +pragma(mangle, const_function) void test_fun2a2(); +static assert(test_fun2a2.mangleof == "mangle_const_function"); -pragma(mangle, ctfe_function) int test_var2a1; -static assert(test_var2a1.mangleof == "mangle_ctfe_function"); +pragma(mangle, ctfe("variable")) int test_var2a1; +static assert(test_var2a1.mangleof == "mangle_ctfe_variable"); pragma(mangle, const_variable) int test_var2a2; -static assert(test_var2a2.mangleof == "mangle_const"); +static assert(test_var2a2.mangleof == "mangle_const_variable"); /* 2b. For aggregates there may be one or two AssignExpressions, one of which * must evaluate at compile time to a string literal and one which must diff --git a/tests/dmd/compilable/pragmamangle2.d b/tests/dmd/compilable/pragmamangle2.d index e1e6e7a28b..a3ac71a083 100644 --- a/tests/dmd/compilable/pragmamangle2.d +++ b/tests/dmd/compilable/pragmamangle2.d @@ -3,8 +3,9 @@ module pragmamangle; version (Posix): // Itanium C++ ABI only -string ctfe_function() { return "mangle_" ~ "ctfe_" ~ "function"; } -immutable string const_variable = "mangle_const"; +string ctfe(string s) { return "mangle_" ~ "ctfe_" ~ s; } +immutable string const_function = "mangle_const_function"; +immutable string const_variable = "mangle_const_variable"; // This mangle string doesn't propagate to tests that use type_symbol. pragma(mangle, "Q_should_mangle_string_propagate") @@ -25,17 +26,17 @@ void pragma_statement_test() /* 2a. For variables and functions there must be one AssignExpression and it * must evaluate at compile time to a string literal */ - pragma(mangle, ctfe_function) void test_fun2a1(); + pragma(mangle, ctfe("function")) void test_fun2a1(); static assert(test_fun2a1.mangleof == "mangle_ctfe_function"); - pragma(mangle, const_variable) void test_fun2a2(); - static assert(test_fun2a2.mangleof == "mangle_const"); + pragma(mangle, const_function) void test_fun2a2(); + static assert(test_fun2a2.mangleof == "mangle_const_function"); - pragma(mangle, ctfe_function) static int test_var2a1; - static assert(test_var2a1.mangleof == "mangle_ctfe_function"); + pragma(mangle, ctfe("variable")) int test_var2a1; + static assert(test_var2a1.mangleof == "mangle_ctfe_variable"); - pragma(mangle, const_variable) static int test_var2a2; - static assert(test_var2a2.mangleof == "mangle_const"); + pragma(mangle, const_variable) int test_var2a2; + static assert(test_var2a2.mangleof == "mangle_const_variable"); /* 2b. For aggregates there may be one or two AssignExpressions, one of which * must evaluate at compile time to a string literal and one which must From e60613d5d6f920b6e886fc20b41462aeeae5e929 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Fri, 30 Jan 2026 14:59:09 +0800 Subject: [PATCH 319/440] Convert ThrowStatement to ThrowExp when inlining --- dmd/inline.d | 9 ++++++--- dmd/inlinecost.d | 4 ++-- tests/dmd/runnable/imports/pragmainline_a.d | 6 ++++++ tests/dmd/runnable/pragmainline.d | 7 +++++++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/dmd/inline.d b/dmd/inline.d index e199a598a1..bb5821c0f1 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -471,7 +471,10 @@ public: static if (asStatements) result = new ThrowStatement(s.loc, doInlineAs!Expression(s.exp, ids)); else - result = null; // cannot be inlined as an Expression + { + result = new ThrowExp(s.loc, doInlineAs!Expression(s.exp, ids)); + result.type = Type.tnoreturn; + } } // Expression -> (Statement | Expression) @@ -2081,7 +2084,7 @@ private bool canInline(FuncDeclaration fd, bool hasThis, bool statementsToo, PAS { /* for the isTypeSArray() case see https://github.com/dlang/dmd/pull/16145#issuecomment-1932776873 */ - if (tfnext.ty != Tvoid && + if (tfnext.ty != Tvoid && tfnext.ty != Tnoreturn && (!fd.hasReturnExp || hasDtor(tfnext) && (statementsToo || tfnext.isTypeSArray()))) { @@ -2470,7 +2473,7 @@ private void expandInline(CallExp ecall, FuncDeclaration fd, FuncDeclaration par e = e.toLvalue(null, "`ref` return"); // https://issues.dlang.org/show_bug.cgi?id=15210 - if (tf.next.ty == Tvoid && e && e.type.ty != Tvoid) + if (tf.next.ty == Tvoid && e && e.type.ty != Tvoid && e.type.ty != Tnoreturn) { e = new CastExp(callLoc, e, Type.tvoid); e.type = Type.tvoid; diff --git a/dmd/inlinecost.d b/dmd/inlinecost.d index ea792f77ce..95e3bd70ec 100644 --- a/dmd/inlinecost.d +++ b/dmd/inlinecost.d @@ -323,8 +323,8 @@ public: override void visit(ThrowStatement s) { - cost += STATEMENT_COST; - s.exp.accept(this); + cost++; + expressionInlineCost(s.exp); } /* -------------------------- */ diff --git a/tests/dmd/runnable/imports/pragmainline_a.d b/tests/dmd/runnable/imports/pragmainline_a.d index f8d2480bc0..cc87fbba7d 100644 --- a/tests/dmd/runnable/imports/pragmainline_a.d +++ b/tests/dmd/runnable/imports/pragmainline_a.d @@ -37,3 +37,9 @@ int value() { return 10; } + +pragma(inline, true) +noreturn throws(T)(T param) +{ + throw new Exception(""); +} diff --git a/tests/dmd/runnable/pragmainline.d b/tests/dmd/runnable/pragmainline.d index f1b132f969..f71c4b08c0 100644 --- a/tests/dmd/runnable/pragmainline.d +++ b/tests/dmd/runnable/pragmainline.d @@ -51,4 +51,11 @@ void main() assert(bar()() == baz()); testAlwaysInline(); + + bool caught = false; + try + throws(throws(1)); + catch (Exception e) + caught = true; + assert(caught); } From 2264a2396d39e4d25deb836a1b75cb426892d542 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Mon, 2 Feb 2026 15:44:38 +0800 Subject: [PATCH 320/440] Allow RVO into closure variable --- tests/dmd/runnable/test28.d | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/dmd/runnable/test28.d b/tests/dmd/runnable/test28.d index 06c77467c2..5491474f13 100644 --- a/tests/dmd/runnable/test28.d +++ b/tests/dmd/runnable/test28.d @@ -1287,7 +1287,6 @@ struct S67 @disable this(this); } -pragma(inline, false) S67 make67() { return S67(1); @@ -1306,6 +1305,10 @@ void test67() { S67 s = f67(); assert(s.ptr == &s); + + S67 s2 = make67(); + auto closure = () { assert(s2.ptr == &s2); }; + closure(); } /*******************************************/ From 193722051abb59729f8de4a802db170ee3b5ce5d Mon Sep 17 00:00:00 2001 From: Kuzko Sergii Date: Mon, 2 Feb 2026 03:15:12 +0300 Subject: [PATCH 321/440] refactoring optimization semantic array reserve --- dmd/semantic3.d | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dmd/semantic3.d b/dmd/semantic3.d index a1c7662592..7053f41c75 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -1888,6 +1888,10 @@ extern (D) bool checkClosure(FuncDeclaration fd) } FuncDeclarations a; + + if (fd.closureVars.length > 0) + a.reserve(fd.closureVars.length); + foreach (v; fd.closureVars) { foreach (f; v.nestedrefs) From b61a17d12630abcd96b101e04de05cb10f4822a2 Mon Sep 17 00:00:00 2001 From: Kuzko Sergii Date: Mon, 2 Feb 2026 04:51:55 +0300 Subject: [PATCH 322/440] refactoring optimization semantic array reserve in funcdecl --- dmd/semantic3.d | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dmd/semantic3.d b/dmd/semantic3.d index 7053f41c75..30daeff5ff 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -1102,6 +1102,10 @@ private extern(C++) final class Semantic3Visitor : Visitor else { auto a = new Statements(); + + size_t expectedSize = (funcdecl.parameters ? funcdecl.parameters.length : 0) + 7; + a.reserve(expectedSize); + // Merge in initialization of 'out' parameters if (funcdecl.parameters) { From 5e029cdeb425d56e44dc09f2bc91347bc1e78f4a Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Mon, 2 Feb 2026 17:45:48 -0800 Subject: [PATCH 323/440] add AI generated test cases for code generator --- tests/dmd/runnable/ai.d | 115 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 tests/dmd/runnable/ai.d diff --git a/tests/dmd/runnable/ai.d b/tests/dmd/runnable/ai.d new file mode 100644 index 0000000000..9a07dde750 --- /dev/null +++ b/tests/dmd/runnable/ai.d @@ -0,0 +1,115 @@ +/* +PERMUTE_ARGS: -O -release +Test cases generated by AI. +*/ + +import core.stdc.stdio; + +void arithmetic_expression_selftest() +{ + /* If a bit is set in `fail`, that test expression evaluated differently than expected. */ + uint fail = 0; + uint t = 0; + + /* ---- precedence & associativity (integers) ---- */ + /* 1) * binds tighter than + */ + t = ((3 + 4 * 5) == (3 + (4 * 5))); + fail |= cast(uint)(!t) << 0; + + /* 2) / binds tighter than - */ + t = ((20 - 12 / 3) == (20 - (12 / 3))); + fail |= cast(uint)(!t) << 1; + + /* 3) left-associative subtraction: (a-b)-c */ + t = ((100 - 30 - 20) == ((100 - 30) - 20)); + fail |= cast(uint)(!t) << 2; + + /* 4) left-associative division: (a/b)/c */ + t = ((100 / 10 / 2) == ((100 / 10) / 2)); + fail |= cast(uint)(!t) << 3; + + /* 5) shift lower precedence than +: a << (b+c) is NOT (a< u); + /* In practice this is true because u+s becomes huge, but we only check + relative ordering; if the implementation got conversions wrong, it may differ. */ + fail |= cast(uint)(!t) << 8; + } + + /* ---- exact integer identities (no UB) ---- */ + /* 10) distributive property with small ints */ + t = ((7 * (9 + 11)) == (7 * 9 + 7 * 11)); + fail |= cast(uint)(!t) << 9; + + /* 11) (a^b)^b == a for uint */ + { + uint a = 0xA5A5A5A5u, b = 0x3C3C3C3Cu; + t = (((a ^ b) ^ b) == a); + fail |= cast(uint)(!t) << 10; + } + + /* ---- floating evaluation / conversion tests ---- */ + /* 12) conversion changes the meaning: cast(int)(x+y) vs cast(int)x + cast(int)y */ + { + double x = 1.6, y = 1.6; + t = ((cast(int)(x + y)) != (cast(int)x + cast(int)y)); /* 3 != 2 */ + fail |= cast(uint)(!t) << 11; + } + + /* 13) float vs double rounding differences (should differ on most IEEE-754 systems) */ + { + float xf = 16777217.0f; /* 2^24 + 1 cannot be represented in float */ + double xd = 16777217.0; /* representable exactly in double */ + t = ((cast(double)xf) != xd); + fail |= cast(uint)(!t) << 12; + } + + /* 14) (a+b)+c vs a+(b+c) can differ in floating-point */ + { + double a = 1e16, b = -1e16, c = 1.0; + double left = (a + b) + c; /* (1e16-1e16)+1 = 1 */ + double right = a + (b + c); /* 1e16+(-1e16+1) may round to 0 */ + t = (left != right); + fail |= cast(uint)(!t) << 13; + } + + /* 15) multiplication/division reassociation differs for floats */ + { + double a = 1e308, b = 1e-308, c = 1e-308; + double left = (a * b) * c; + double right = a * (b * c); + /* one side likely underflows differently; we just expect "not always equal" */ + t = (left != right); + fail |= cast(uint)(!t) << 14; + } + + if (fail) + printf("fail: x%x\n", fail); +} + +int main() +{ + arithmetic_expression_selftest(); + return 0; +} From 8bec37a5ccacbd278b893b94395cb81c94c8c0ef Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Wed, 4 Feb 2026 21:13:51 -0800 Subject: [PATCH 324/440] argtypes for AArch64 --- dmd/argtypes_aarch64.d | 2 ++ dmd/argtypes_sysv_x64.d | 4 ++++ dmd/target.d | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/dmd/argtypes_aarch64.d b/dmd/argtypes_aarch64.d index ef87edf320..7c01e1723b 100644 --- a/dmd/argtypes_aarch64.d +++ b/dmd/argtypes_aarch64.d @@ -11,6 +11,7 @@ module dmd.argtypes_aarch64; +import core.stdc.stdio; import dmd.astenums; import dmd.dsymbolsem : isPOD; import dmd.mtype; @@ -32,6 +33,7 @@ import dmd.expressionsem : toUInteger; */ TypeTuple toArgTypes_aarch64(Type t) { + //printf("toArgTypes_aarch64() %s\n", t.toChars()); if (t == Type.terror) return new TypeTuple(t); diff --git a/dmd/argtypes_sysv_x64.d b/dmd/argtypes_sysv_x64.d index 622a069de8..1b1308a00c 100644 --- a/dmd/argtypes_sysv_x64.d +++ b/dmd/argtypes_sysv_x64.d @@ -11,6 +11,7 @@ module dmd.argtypes_sysv_x64; +import core.stdc.stdio; import dmd.astenums; import dmd.declaration; import dmd.dsymbolsem : isPOD; @@ -95,7 +96,10 @@ TypeTuple toArgTypes_sysv_x64(Type t) Type.tfloat32; } else + { + debug printf("class: %d\n", c); assert(0, "Unexpected class"); + } } return N == 1 diff --git a/dmd/target.d b/dmd/target.d index 34d5cf0db3..a6b497d72b 100644 --- a/dmd/target.d +++ b/dmd/target.d @@ -1002,6 +1002,17 @@ extern (C++) struct Target else if (isAArch64) { import dmd.argtypes_aarch64 : toArgTypes_aarch64; + static if (0) + { + auto tt = toArgTypes_aarch64(t); + if (tt) + foreach (i; 0 .. tt.arguments.length) + { + Parameter p = (*tt.arguments)[i]; + printf("i: %d t: %s\n", cast(int)i, p.type.toChars()); + } + return tt; + } return toArgTypes_aarch64(t); } else From 893debc167e670eca995c68f361e9600a2c93496 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Fri, 6 Feb 2026 13:34:56 +0100 Subject: [PATCH 325/440] druntime: Add FreeBSD_16 version --- runtime/druntime/src/core/sys/freebsd/config.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/druntime/src/core/sys/freebsd/config.d b/runtime/druntime/src/core/sys/freebsd/config.d index c57d2e4aa8..932f166d2d 100644 --- a/runtime/druntime/src/core/sys/freebsd/config.d +++ b/runtime/druntime/src/core/sys/freebsd/config.d @@ -14,7 +14,8 @@ public import core.sys.posix.config; // NOTE: When adding newer versions of FreeBSD, verify all current versioned // bindings are still compatible with the release. - version (FreeBSD_15) enum __FreeBSD_version = 1500063; + version (FreeBSD_16) enum __FreeBSD_version = 1600011; +else version (FreeBSD_15) enum __FreeBSD_version = 1500063; else version (FreeBSD_14) enum __FreeBSD_version = 1400097; else version (FreeBSD_13) enum __FreeBSD_version = 1301000; else version (FreeBSD_12) enum __FreeBSD_version = 1203000; From 59bd6187c67644b0a2c024e7c747de0d95912bf8 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Fri, 6 Feb 2026 19:27:15 +0800 Subject: [PATCH 326/440] [optlink] remove detritus in `dmd/main.d` --- dmd/main.d | 3 --- 1 file changed, 3 deletions(-) diff --git a/dmd/main.d b/dmd/main.d index 7d6b4ff7aa..9a04c16b9f 100644 --- a/dmd/main.d +++ b/dmd/main.d @@ -964,9 +964,6 @@ bool parseCommandlineAndConfig(const(char)[][] argv, out Param params, ref Strin bool isX86_64 = arch[0] == '6'; - version(Windows) // delete LIB entry in [Environment] (necessary for optlink) to allow inheriting environment for MS-COFF - environment.update("LIB", 3).value = null; - // read from DFLAGS in [Environment{arch}] section char[80] envsection = void; snprintf(envsection.ptr, envsection.length, "Environment%.*s", cast(int) arch.length, arch.ptr); From 23b8f3ae05c69e2b64754dbea55dabc7a4c72ed9 Mon Sep 17 00:00:00 2001 From: Abul Hossain Khan <140191921+abulgit@users.noreply.github.com> Date: Sat, 7 Feb 2026 12:14:51 +0530 Subject: [PATCH 327/440] Fix opBinaryRight error message to suggest lhs instead of rhs (dlang/dmd!22527) --- dmd/opover.d | 2 +- tests/dmd/fail_compilation/dep_d1_ops.d | 40 ++++++++++++------------- tests/dmd/fail_compilation/diag16499.d | 4 +-- tests/dmd/fail_compilation/issue22147.d | 16 ++++++++++ 4 files changed, 39 insertions(+), 23 deletions(-) create mode 100644 tests/dmd/fail_compilation/issue22147.d diff --git a/dmd/opover.d b/dmd/opover.d index 868b22b29c..d086927db9 100644 --- a/dmd/opover.d +++ b/dmd/opover.d @@ -612,7 +612,7 @@ bool suggestBinaryOverloads(BinExp e, Scope* sc) return true; } error(e.loc, "operator `%s` is not defined for type `%s`", EXPtoString(e.op).ptr, e.e2.type.toChars); - errorSupplemental(ad2.loc, "perhaps overload the operator with `auto opBinaryRight(string op : \"%s\")(%s rhs) {}`", EXPtoString(e.op).ptr, e.e1.type.toChars); + errorSupplemental(ad2.loc, "perhaps overload the operator with `auto opBinaryRight(string op : \"%s\")(%s lhs) {}`", EXPtoString(e.op).ptr, e.e1.type.toChars); return true; } return false; diff --git a/tests/dmd/fail_compilation/dep_d1_ops.d b/tests/dmd/fail_compilation/dep_d1_ops.d index 83e700632a..2b51051a00 100644 --- a/tests/dmd/fail_compilation/dep_d1_ops.d +++ b/tests/dmd/fail_compilation/dep_d1_ops.d @@ -5,23 +5,23 @@ TEST_OUTPUT: fail_compilation/dep_d1_ops.d(281): Error: operator `+` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "+")(int rhs) {}` fail_compilation/dep_d1_ops.d(282): Error: operator `+` is not defined for type `S` -fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "+")(int rhs) {}` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "+")(int lhs) {}` fail_compilation/dep_d1_ops.d(283): Error: operator `-` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "-")(int rhs) {}` fail_compilation/dep_d1_ops.d(284): Error: operator `-` is not defined for type `S` -fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "-")(int rhs) {}` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "-")(int lhs) {}` fail_compilation/dep_d1_ops.d(285): Error: operator `*` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "*")(int rhs) {}` fail_compilation/dep_d1_ops.d(286): Error: operator `*` is not defined for type `S` -fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "*")(int rhs) {}` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "*")(int lhs) {}` fail_compilation/dep_d1_ops.d(287): Error: operator `/` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "/")(int rhs) {}` fail_compilation/dep_d1_ops.d(288): Error: operator `/` is not defined for type `S` -fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "/")(int rhs) {}` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "/")(int lhs) {}` fail_compilation/dep_d1_ops.d(289): Error: operator `%` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "%")(int rhs) {}` fail_compilation/dep_d1_ops.d(290): Error: operator `%` is not defined for type `S` -fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "%")(int rhs) {}` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "%")(int lhs) {}` fail_compilation/dep_d1_ops.d(292): Error: operator `&` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "&")(int rhs) {}` fail_compilation/dep_d1_ops.d(293): Error: operator `|` is not defined for type `S` @@ -31,19 +31,19 @@ fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `a fail_compilation/dep_d1_ops.d(296): Error: operator `<<` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "<<")(int rhs) {}` fail_compilation/dep_d1_ops.d(297): Error: operator `<<` is not defined for type `S` -fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "<<")(int rhs) {}` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "<<")(int lhs) {}` fail_compilation/dep_d1_ops.d(298): Error: operator `>>` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : ">>")(int rhs) {}` fail_compilation/dep_d1_ops.d(299): Error: operator `>>` is not defined for type `S` -fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : ">>")(int rhs) {}` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : ">>")(int lhs) {}` fail_compilation/dep_d1_ops.d(300): Error: operator `>>>` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : ">>>")(int rhs) {}` fail_compilation/dep_d1_ops.d(301): Error: operator `>>>` is not defined for type `S` -fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : ">>>")(int rhs) {}` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : ">>>")(int lhs) {}` fail_compilation/dep_d1_ops.d(303): Error: operator `~` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "~")(int rhs) {}` fail_compilation/dep_d1_ops.d(304): Error: operator `~` is not defined for type `S` -fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "~")(int rhs) {}` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "~")(int lhs) {}` fail_compilation/dep_d1_ops.d(306): Error: operator `+` is not defined for `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opUnary(string op : "+")() {}` fail_compilation/dep_d1_ops.d(307): Error: operator `-` is not defined for `S` @@ -59,7 +59,7 @@ fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `a fail_compilation/dep_d1_ops.d(313): Error: operator `in` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "in")(int rhs) {}` fail_compilation/dep_d1_ops.d(314): Error: operator `in` is not defined for type `S` -fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "in")(int rhs) {}` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "in")(int lhs) {}` fail_compilation/dep_d1_ops.d(316): Error: operator `+=` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "+")(int) {}` fail_compilation/dep_d1_ops.d(317): Error: operator `-=` not supported for `s` of type `S` @@ -87,23 +87,23 @@ fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(st fail_compilation/dep_d1_ops.d(331): Error: operator `+` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "+")(int rhs) {}` fail_compilation/dep_d1_ops.d(332): Error: operator `+` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "+")(int rhs) {}` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "+")(int lhs) {}` fail_compilation/dep_d1_ops.d(333): Error: operator `-` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "-")(int rhs) {}` fail_compilation/dep_d1_ops.d(334): Error: operator `-` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "-")(int rhs) {}` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "-")(int lhs) {}` fail_compilation/dep_d1_ops.d(335): Error: operator `*` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "*")(int rhs) {}` fail_compilation/dep_d1_ops.d(336): Error: operator `*` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "*")(int rhs) {}` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "*")(int lhs) {}` fail_compilation/dep_d1_ops.d(337): Error: operator `/` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "/")(int rhs) {}` fail_compilation/dep_d1_ops.d(338): Error: operator `/` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "/")(int rhs) {}` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "/")(int lhs) {}` fail_compilation/dep_d1_ops.d(339): Error: operator `%` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "%")(int rhs) {}` fail_compilation/dep_d1_ops.d(340): Error: operator `%` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "%")(int rhs) {}` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "%")(int lhs) {}` fail_compilation/dep_d1_ops.d(342): Error: operator `&` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "&")(int rhs) {}` fail_compilation/dep_d1_ops.d(343): Error: operator `|` is not defined for type `dep_d1_ops.C` @@ -113,19 +113,19 @@ fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `a fail_compilation/dep_d1_ops.d(346): Error: operator `<<` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "<<")(int rhs) {}` fail_compilation/dep_d1_ops.d(347): Error: operator `<<` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "<<")(int rhs) {}` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "<<")(int lhs) {}` fail_compilation/dep_d1_ops.d(348): Error: operator `>>` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : ">>")(int rhs) {}` fail_compilation/dep_d1_ops.d(349): Error: operator `>>` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : ">>")(int rhs) {}` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : ">>")(int lhs) {}` fail_compilation/dep_d1_ops.d(350): Error: operator `>>>` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : ">>>")(int rhs) {}` fail_compilation/dep_d1_ops.d(351): Error: operator `>>>` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : ">>>")(int rhs) {}` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : ">>>")(int lhs) {}` fail_compilation/dep_d1_ops.d(353): Error: operator `~` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "~")(int rhs) {}` fail_compilation/dep_d1_ops.d(354): Error: operator `~` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "~")(int rhs) {}` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "~")(int lhs) {}` fail_compilation/dep_d1_ops.d(356): Error: operator `+` is not defined for `C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opUnary(string op : "+")() {}` fail_compilation/dep_d1_ops.d(357): Error: operator `-` is not defined for `C` @@ -141,7 +141,7 @@ fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `a fail_compilation/dep_d1_ops.d(363): Error: operator `in` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "in")(int rhs) {}` fail_compilation/dep_d1_ops.d(364): Error: operator `in` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "in")(int rhs) {}` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "in")(int lhs) {}` fail_compilation/dep_d1_ops.d(366): Error: operator `+=` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "+")(int) {}` fail_compilation/dep_d1_ops.d(367): Error: operator `-=` not supported for `c` of type `C` diff --git a/tests/dmd/fail_compilation/diag16499.d b/tests/dmd/fail_compilation/diag16499.d index f3757954d4..34de73523b 100644 --- a/tests/dmd/fail_compilation/diag16499.d +++ b/tests/dmd/fail_compilation/diag16499.d @@ -2,9 +2,9 @@ TEST_OUTPUT: --- fail_compilation/diag16499.d(24): Error: operator `in` is not defined for type `A` -fail_compilation/diag16499.d(11): perhaps overload the operator with `auto opBinaryRight(string op : "in")(int rhs) {}` +fail_compilation/diag16499.d(11): perhaps overload the operator with `auto opBinaryRight(string op : "in")(int lhs) {}` fail_compilation/diag16499.d(26): Error: operator `in` is not defined for type `B` -fail_compilation/diag16499.d(12): perhaps overload the operator with `auto opBinaryRight(string op : "in")(double rhs) {}` +fail_compilation/diag16499.d(12): perhaps overload the operator with `auto opBinaryRight(string op : "in")(double lhs) {}` --- */ diff --git a/tests/dmd/fail_compilation/issue22147.d b/tests/dmd/fail_compilation/issue22147.d new file mode 100644 index 0000000000..77c4967892 --- /dev/null +++ b/tests/dmd/fail_compilation/issue22147.d @@ -0,0 +1,16 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/issue22147.d(15): Error: operator `/` is not defined for type `T` +fail_compilation/issue22147.d(9): perhaps overload the operator with `auto opBinaryRight(string op : "/")(int lhs) {}` +--- +*/ + +struct T +{ +} + +void test() +{ + auto result = 10 / T(); // int / T requires opBinaryRight on T +} From 96d8c76e6755c4443a54c88a3260c91bc30a8d89 Mon Sep 17 00:00:00 2001 From: Abul Date: Sat, 7 Feb 2026 17:14:20 +0530 Subject: [PATCH 328/440] -preview=safer should ignore C files --- dmd/semantic3.d | 2 +- tests/dmd/compilable/safer_cfile.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/compilable/safer_cfile.c diff --git a/dmd/semantic3.d b/dmd/semantic3.d index 30daeff5ff..15677f1fc6 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -294,7 +294,7 @@ private extern(C++) final class Semantic3Visitor : Visitor return; funcdecl.semanticRun = PASS.semantic3; funcdecl.hasSemantic3Errors = false; - funcdecl.saferD = sc.previews.safer; + funcdecl.saferD = sc.previews.safer && !sc.inCfile; if (!funcdecl.type || funcdecl.type.ty != Tfunction) return; diff --git a/tests/dmd/compilable/safer_cfile.c b/tests/dmd/compilable/safer_cfile.c new file mode 100644 index 0000000000..3ad9f94b11 --- /dev/null +++ b/tests/dmd/compilable/safer_cfile.c @@ -0,0 +1,7 @@ +// https://github.com/dlang/dmd/issues/22453 +// -preview=safer should ignore C files +// REQUIRED_ARGS: -preview=safer +int f(int *p) +{ + return p[1]; +} From e98f784e8ee4e13e01a8ce43576250cdc88f68db Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 7 Feb 2026 22:03:27 -0800 Subject: [PATCH 329/440] add assert to test case (dlang/dmd!22531) --- tests/dmd/runnable/ai.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/dmd/runnable/ai.d b/tests/dmd/runnable/ai.d index 9a07dde750..3c974db197 100644 --- a/tests/dmd/runnable/ai.d +++ b/tests/dmd/runnable/ai.d @@ -105,7 +105,8 @@ void arithmetic_expression_selftest() } if (fail) - printf("fail: x%x\n", fail); + printf("fail: x%x\n", fail); + assert(!fail); } int main() From 3ff1e13afe44368d5e64b2372243ee3bfead94a4 Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Wed, 11 Feb 2026 03:37:14 +1300 Subject: [PATCH 330/440] Simplify null deref check test (dlang/dmd!22549) --- tests/dmd/runnable/nullderefcheck.d | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/tests/dmd/runnable/nullderefcheck.d b/tests/dmd/runnable/nullderefcheck.d index 1e35503c8b..b2b6af18f8 100644 --- a/tests/dmd/runnable/nullderefcheck.d +++ b/tests/dmd/runnable/nullderefcheck.d @@ -26,27 +26,13 @@ void main() void wrap(alias test)(int expectedLine) { - gotFile = null; - gotLine = 0; try { test(); + assert(0); } - catch (Error) + catch (Error e) { + assert(e.line == expectedLine); } - assert(gotFile == __FILE__); - assert(gotLine == expectedLine); -} - -string gotFile; -uint gotLine; - -extern (C) void _d_nullpointerp(immutable(char*) file, uint line) -{ - import core.stdc.string : strlen; - - gotFile = file[0 .. strlen(file)]; - gotLine = line; - throw new Error(""); } From 1ff309b619b3913b9039015393119b6e90c22ef8 Mon Sep 17 00:00:00 2001 From: Atila Neves Date: Wed, 11 Feb 2026 10:43:33 +0100 Subject: [PATCH 331/440] Fix some `-preview=nosharedaccess` compilation errors in druntime (dlang/dmd!22559) * Make condition.d compile with -preview=nosharedaccess * Make gc.d compile with -preview=nosharedaccess * Make mutex.d compile with -preview=nosharedaccess --- .../core/internal/gc/impl/conservative/gc.d | 4 ++-- runtime/druntime/src/core/sync/condition.d | 4 ++-- runtime/druntime/src/core/sync/mutex.d | 18 +++++++++++------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d b/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d index ae40bd363d..a693c361c1 100644 --- a/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d +++ b/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d @@ -3525,8 +3525,8 @@ Lmark: cstdlib.free(Gcx.instance.scanThreadData); Gcx.instance.numScanThreads = 0; Gcx.instance.scanThreadData = null; - Gcx.instance.busyThreads = 0; - Gcx.instance.stackLock = shared(AlignedSpinLock)(SpinLock.Contention.brief); + atomicStore(Gcx.instance.busyThreads, 0); + (cast() Gcx.instance.stackLock) = AlignedSpinLock(SpinLock.Contention.brief); memset(&Gcx.instance.evStackFilled, 0, Gcx.instance.evStackFilled.sizeof); memset(&Gcx.instance.evDone, 0, Gcx.instance.evDone.sizeof); diff --git a/runtime/druntime/src/core/sync/condition.d b/runtime/druntime/src/core/sync/condition.d index 3acee7a7f4..9328f6d488 100644 --- a/runtime/druntime/src/core/sync/condition.d +++ b/runtime/druntime/src/core/sync/condition.d @@ -246,7 +246,7 @@ class Condition } else version (Posix) { - int rc = pthread_cond_wait( cast(pthread_cond_t*) &m_hndl, (cast(Mutex) m_assocMutex).handleAddr() ); + int rc = pthread_cond_wait( cast(pthread_cond_t*) &m_hndl, (cast(Mutex) mutex()).handleAddr() ); if ( rc ) throw staticError!AssertError("Unable to wait for condition", __FILE__, __LINE__); } @@ -307,7 +307,7 @@ class Condition mktspec( t, val ); int rc = pthread_cond_timedwait( cast(pthread_cond_t*) &m_hndl, - (cast(Mutex) m_assocMutex).handleAddr(), + (cast(Mutex) mutex()).handleAddr(), &t ); if ( !rc ) return true; diff --git a/runtime/druntime/src/core/sync/mutex.d b/runtime/druntime/src/core/sync/mutex.d index 8993f85071..86a112119d 100644 --- a/runtime/druntime/src/core/sync/mutex.d +++ b/runtime/druntime/src/core/sync/mutex.d @@ -100,7 +100,8 @@ class Mutex : abort("Error: pthread_mutex_init failed."); } - m_proxy.link = this; + auto self = cast(Mutex) this; + self.m_proxy.link = self; this.__monitor = cast(void*) &m_proxy; } @@ -183,13 +184,14 @@ class Mutex : final void lock_nothrow(this Q)() nothrow @trusted @nogc if (is(Q == Mutex) || is(Q == shared Mutex)) { + auto self = cast(Mutex) this; version (Windows) { - EnterCriticalSection(&m_hndl); + EnterCriticalSection(&self.m_hndl); } else version (Posix) { - if (pthread_mutex_lock(&m_hndl) == 0) + if (pthread_mutex_lock(&self.m_hndl) == 0) return; SyncError syncErr = cast(SyncError) __traits(initSymbol, SyncError).ptr; @@ -221,13 +223,14 @@ class Mutex : final void unlock_nothrow(this Q)() nothrow @trusted @nogc if (is(Q == Mutex) || is(Q == shared Mutex)) { + auto self = cast(Mutex) this; version (Windows) { - LeaveCriticalSection(&m_hndl); + LeaveCriticalSection(&self.m_hndl); } else version (Posix) { - if (pthread_mutex_unlock(&m_hndl) == 0) + if (pthread_mutex_unlock(&self.m_hndl) == 0) return; SyncError syncErr = cast(SyncError) __traits(initSymbol, SyncError).ptr; @@ -263,13 +266,14 @@ class Mutex : final bool tryLock_nothrow(this Q)() nothrow @trusted @nogc if (is(Q == Mutex) || is(Q == shared Mutex)) { + auto self = cast(Mutex) this; version (Windows) { - return TryEnterCriticalSection(&m_hndl) != 0; + return TryEnterCriticalSection(&self.m_hndl) != 0; } else version (Posix) { - return pthread_mutex_trylock(&m_hndl) == 0; + return pthread_mutex_trylock(&self.m_hndl) == 0; } } From d56be7303c66eacd867a2ee17ee84c91e9061aba Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 13 Feb 2026 01:02:47 +0100 Subject: [PATCH 332/440] Fix dlang/dmd!22560 - Can supposedly index AA with mismatching key type (dlang/dmd!22564) --- dmd/dcast.d | 2 -- tests/dmd/runnable/testaa2.d | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dmd/dcast.d b/dmd/dcast.d index 66c0b8a8c2..fdc29094aa 100644 --- a/dmd/dcast.d +++ b/dmd/dcast.d @@ -4374,8 +4374,6 @@ void fix16997(Scope* sc, UnaExp ue) extern (D) bool keyCompatibleWithoutCasting(Expression ekey, Type t2) { Type t1 = ekey.type; - t1 = t1.toBasetype(); - t2 = t2.toBasetype(); if ((t1.isStaticOrDynamicArray() || t1.ty == Tpointer) && t2.ty == t1.ty) { diff --git a/tests/dmd/runnable/testaa2.d b/tests/dmd/runnable/testaa2.d index 9247bbf84e..7104b12dd8 100644 --- a/tests/dmd/runnable/testaa2.d +++ b/tests/dmd/runnable/testaa2.d @@ -335,6 +335,14 @@ void foo() @safe aa[key] = 123; } +// https://github.com/dlang/dmd/issues/22560 +void test22560() +{ + enum E { a } + bool[E] aa; + static assert(!__traits(compiles, aa[0])); +} + /************************************************/ void testEvaluationOrder() From 8ee2f3d4585489a62e684d2c7cd8b8436ccf5590 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 14 Feb 2026 18:32:00 -0800 Subject: [PATCH 333/440] implement complex assignment (dlang/dmd!22568) --- tests/dmd/runnable/ai.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/dmd/runnable/ai.d b/tests/dmd/runnable/ai.d index 3c974db197..26d515f071 100644 --- a/tests/dmd/runnable/ai.d +++ b/tests/dmd/runnable/ai.d @@ -91,7 +91,7 @@ void arithmetic_expression_selftest() double left = (a + b) + c; /* (1e16-1e16)+1 = 1 */ double right = a + (b + c); /* 1e16+(-1e16+1) may round to 0 */ t = (left != right); - fail |= cast(uint)(!t) << 13; +// fail |= cast(uint)(!t) << 13; } /* 15) multiplication/division reassociation differs for floats */ @@ -101,7 +101,7 @@ void arithmetic_expression_selftest() double right = a * (b * c); /* one side likely underflows differently; we just expect "not always equal" */ t = (left != right); - fail |= cast(uint)(!t) << 14; +// fail |= cast(uint)(!t) << 14; } if (fail) From 685a66aff12550d92ea2763a68226e600213d86b Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Mon, 16 Feb 2026 14:43:19 +0100 Subject: [PATCH 334/440] runnable/test20275.d: Add UNICODE_NAMES MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So that this test is skipped on targets where the assembler lacks UTF8 support. ``` Assembler: test20275.d "/var/tmp//ccR1Muva.s", line 12 : Syntax error Near line: " call _D7imports6你好3fooFZi" ``` --- tests/dmd/runnable/test20275.d | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/dmd/runnable/test20275.d b/tests/dmd/runnable/test20275.d index cbdf1f6e7f..1288397264 100644 --- a/tests/dmd/runnable/test20275.d +++ b/tests/dmd/runnable/test20275.d @@ -1,4 +1,5 @@ // EXTRA_SOURCES: imports/你好.d +// UNICODE_NAMES: import imports.你好; From 0313d128cb0c020410594c68d2e915d0bfa4bc2a Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Wed, 18 Feb 2026 14:57:43 +0000 Subject: [PATCH 335/440] [internal/traits] Fix regression in `hasElaborateDestructor` (dlang/dmd!22554) --- runtime/druntime/src/core/internal/traits.d | 41 ++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/runtime/druntime/src/core/internal/traits.d b/runtime/druntime/src/core/internal/traits.d index 7ffee2ec0b..a94ee377d4 100644 --- a/runtime/druntime/src/core/internal/traits.d +++ b/runtime/druntime/src/core/internal/traits.d @@ -298,8 +298,14 @@ template hasElaborateDestructor(S) // this should be the implementation, but until that's fixed, we need the // uncommented code. // enum hasElaborateDestructor = __traits(hasMember, S, "__xdtor"); - - enum hasElaborateDestructor = hasDtor([__traits(allMembers, S)]); + // Note: we have to avoid triggering opDispatch to placate runnable/b6400.d + enum hasElaborateDestructor = __traits(compiles, { + static struct S2 + { + S s; + static assert(is(typeof(__xdtor))); + } + }); } else { @@ -307,17 +313,6 @@ template hasElaborateDestructor(S) } } -private bool hasDtor(string[] members) -{ - foreach (name; members) - { - if (name == "__xdtor") - return true; - } - - return false; -} - @safe unittest { static struct NoDestructor {} @@ -331,6 +326,7 @@ private bool hasDtor(string[] members) static assert( hasElaborateDestructor!(HasDestructor[42])); static assert(!hasElaborateDestructor!(HasDestructor[0])); static assert(!hasElaborateDestructor!(HasDestructor[])); + static assert( hasElaborateDestructor!(immutable HasDestructor)); static struct HasDestructor2 { HasDestructor s; } static assert( hasElaborateDestructor!HasDestructor2); @@ -365,6 +361,25 @@ private bool hasDtor(string[] members) static assert(!hasElaborateDestructor!S6); } +// https://github.com/dlang/dmd/issues/21967 +version (CoreUnittest) +private struct Test21967 +{ + // Note: Foward referencing was failing due to: + // https://github.com/dlang/dmd/issues/22524 + static assert(hasElaborateDestructor!C); + enum before = hasElaborateDestructor!C; + static assert(before); + + struct C + { + ~this() {} + } + static assert(hasElaborateDestructor!C); + enum after = hasElaborateDestructor!C; + static assert(after); +} + // std.traits.hasElaborateCopyDestructor template hasElaborateCopyConstructor(S) { From a978c23c9fa8956f682cbfa2fa8ab91cde126454 Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Tue, 17 Feb 2026 14:38:28 +0100 Subject: [PATCH 336/440] Change int8_t etc. to signed char on Solaris GCC recently changed int8_t etc. to signed char for C99 conformance: Change int8_t to signed char on Solaris [PR113450,PR123176] https://gcc.gnu.org/pipermail/gcc-patches/2026-February/708533.html As documented in PR d/123509 Switch int8_t etc. to byte on Solaris https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123509 this leads to a couple of testsuite failures with GDC since druntime has its own idea of those types. This patch fixes this by adjusting those types to match GCC for GDC only. The int8_t change is expected to be integrated into the Solaris headers later, but for now it only exists in GCC 16+. Tested on GCC trunk on i386-pc-solaris2.11 and sparc-sun-solaris2.11. --- runtime/druntime/src/core/stdc/stdint.d | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/runtime/druntime/src/core/stdc/stdint.d b/runtime/druntime/src/core/stdc/stdint.d index 4f9b98cd8c..385f4ca5dd 100644 --- a/runtime/druntime/src/core/stdc/stdint.d +++ b/runtime/druntime/src/core/stdc/stdint.d @@ -337,7 +337,10 @@ else version (OpenBSD) } else version (Solaris) { - alias int8_t = char; /// + version (GNU) + alias int8_t = byte; /// + else + alias int8_t = char; /// alias int16_t = short; /// alias uint8_t = ubyte; /// alias uint16_t = ushort; /// @@ -346,7 +349,10 @@ else version (Solaris) alias int64_t = long; /// alias uint64_t = ulong; /// - alias int_least8_t = char; /// + version (GNU) + alias int_least8_t = byte; /// + else + alias int_least8_t = char; /// alias uint_least8_t = ubyte; /// alias int_least16_t = short; /// alias uint_least16_t = ushort; /// @@ -355,7 +361,10 @@ else version (Solaris) alias int_least64_t = long; /// alias uint_least64_t = ulong; /// - alias int_fast8_t = char; /// + version (GNU) + alias int_fast8_t = byte; /// + else + alias int_fast8_t = char; /// alias uint_fast8_t = ubyte; /// alias int_fast16_t = int; /// alias uint_fast16_t = uint; /// From 809c08a9482e6801bd6bc130769b800f44b11ec6 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Wed, 18 Feb 2026 17:35:41 -0800 Subject: [PATCH 337/440] rename ldouble to real (dlang/dmd!22589) --- dmd/cparse.d | 1 - 1 file changed, 1 deletion(-) diff --git a/dmd/cparse.d b/dmd/cparse.d index 32b4e0146a..3ebbfe04f2 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -2395,7 +2395,6 @@ final class CParser(AST) : Parser!AST xllong = 0x40, xfloat = 0x80, xdouble = 0x100, - xldouble = 0x200, xtag = 0x400, xident = 0x800, xvoid = 0x1000, From 9bcf814329b0fb25b299a12cc4acb353b67b4619 Mon Sep 17 00:00:00 2001 From: Atila Neves Date: Thu, 19 Feb 2026 13:22:48 +0100 Subject: [PATCH 338/440] Make modules in druntime compile with nosharedaccess (dlang/dmd!22592) --- runtime/druntime/src/core/thread/osthread.d | 4 +++- runtime/druntime/src/rt/cover.d | 2 +- runtime/druntime/src/rt/critical_.d | 8 ++++---- runtime/druntime/src/rt/dmain2.d | 16 ++++++++-------- runtime/druntime/src/rt/dwarfeh.d | 16 ++++++++-------- runtime/druntime/src/rt/minfo.d | 6 +++--- runtime/druntime/src/rt/monitor_.d | 12 ++++++------ runtime/druntime/src/rt/profilegc.d | 4 ++-- runtime/druntime/src/rt/trace.d | 8 ++++---- 9 files changed, 39 insertions(+), 37 deletions(-) diff --git a/runtime/druntime/src/core/thread/osthread.d b/runtime/druntime/src/core/thread/osthread.d index 6827dad619..c24dde4a5d 100644 --- a/runtime/druntime/src/core/thread/osthread.d +++ b/runtime/druntime/src/core/thread/osthread.d @@ -653,7 +653,9 @@ class Thread : ThreadBase auto local = atomicLoad(mixin("cache." ~ which)); if (local != local.min) return local; // There will be benign races - cache = loadPriorities; + auto loaded = loadPriorities; + static foreach (i, _; loaded.tupleof) + atomicStore(cache.tupleof[i], loaded.tupleof[i]); return atomicLoad(mixin("cache." ~ which)); } diff --git a/runtime/druntime/src/rt/cover.d b/runtime/druntime/src/rt/cover.d index 0b1902104c..86723cfb4b 100644 --- a/runtime/druntime/src/rt/cover.d +++ b/runtime/druntime/src/rt/cover.d @@ -313,7 +313,7 @@ shared static ~this() fprintf(flst, "%.*s is %d%% covered\n", cast(int)c.filename.length, c.filename.ptr, percent); if (percent < c.minPercent) { - fprintf(stderr, "Error: %.*s is %d%% covered, less than required %d%%\n", + fprintf(cast()stderr, "Error: %.*s is %d%% covered, less than required %d%%\n", cast(int)c.filename.length, c.filename.ptr, percent, c.minPercent); exit(EXIT_FAILURE); } diff --git a/runtime/druntime/src/rt/critical_.d b/runtime/druntime/src/rt/critical_.d index 36552a3ce1..8513c67037 100644 --- a/runtime/druntime/src/rt/critical_.d +++ b/runtime/druntime/src/rt/critical_.d @@ -21,14 +21,14 @@ import rt.monitor_, core.atomic; extern (C) void _d_critical_init() @nogc nothrow { initMutex(cast(Mutex*)&gcs.mtx); - head = &gcs; + atomicStore(head, &gcs); } extern (C) void _d_critical_term() @nogc nothrow { // This function is only ever called by the runtime shutdown code // and therefore is single threaded so the following cast is fine. - auto h = cast()head; + auto h = cast(D_CRITICAL_SECTION*) atomicLoad(head); for (auto p = h; p; p = p.next) destroyMutex(cast(Mutex*)&p.mtx); } @@ -81,8 +81,8 @@ void ensureMutex(shared(D_CRITICAL_SECTION)* cs) if (atomicLoad!(MemoryOrder.raw)(cs.next) is null) { initMutex(cast(Mutex*)&cs.mtx); - auto ohead = head; - head = cs; + auto ohead = atomicLoad(head); + atomicStore(head, cs); atomicStore!(MemoryOrder.rel)(cs.next, ohead); } unlockMutex(cast(Mutex*)&gcs.mtx); diff --git a/runtime/druntime/src/rt/dmain2.d b/runtime/druntime/src/rt/dmain2.d index 0f7c816152..0f9593f894 100644 --- a/runtime/druntime/src/rt/dmain2.d +++ b/runtime/druntime/src/rt/dmain2.d @@ -515,9 +515,9 @@ private extern (C) int _d_run_main2(char[][] args, size_t totalArgsLength, MainF if (utResult.summarize) { if (utResult.passed == 0) - .fprintf(.stderr, "No unittests run\n"); + .fprintf(cast().stderr, "No unittests run\n"); else - .fprintf(.stderr, "%d modules passed unittests\n", + .fprintf(cast().stderr, "%d modules passed unittests\n", cast(int)utResult.passed); } if (utResult.runMain) @@ -528,7 +528,7 @@ private extern (C) int _d_run_main2(char[][] args, size_t totalArgsLength, MainF else { if (utResult.summarize) - .fprintf(.stderr, "%d/%d modules FAILED unittests\n", + .fprintf(cast().stderr, "%d/%d modules FAILED unittests\n", cast(int)(utResult.executed - utResult.passed), cast(int)utResult.executed); result = EXIT_FAILURE; @@ -549,9 +549,9 @@ private extern (C) int _d_run_main2(char[][] args, size_t totalArgsLength, MainF tryExec(&runAll); // Issue 10344: flush stdout and return nonzero on failure - if (.fflush(.stdout) != 0) + if (.fflush(cast().stdout) != 0) { - .fprintf(.stderr, "Failed to flush stdout: %s\n", .strerror(.errno)); + .fprintf(cast().stderr, "Failed to flush stdout: %s\n", .strerror(.errno)); if (result == 0) { result = EXIT_FAILURE; @@ -628,7 +628,7 @@ extern (C) void _d_print_throwable(Throwable t) // ensure the exception is shown at the beginning of the line, while also // checking whether stderr is a valid file - int written = fprintf(stderr, "\n"); + int written = fprintf(cast()stderr, "\n"); if (written <= 0) { WSink buf; @@ -654,7 +654,7 @@ extern (C) void _d_print_throwable(Throwable t) } return; } - auto hStdErr = windowsHandle(fileno(stderr)); + auto hStdErr = windowsHandle(fileno(cast()stderr)); CONSOLE_SCREEN_BUFFER_INFO sbi = void; const isConsole = GetConsoleScreenBufferInfo(hStdErr, &sbi) != 0; if (isConsole) @@ -682,7 +682,7 @@ extern (C) void _d_print_throwable(Throwable t) void sink(in char[] buf) scope nothrow { - fwrite(buf.ptr, char.sizeof, buf.length, stderr); + fwrite(buf.ptr, char.sizeof, buf.length, cast()stderr); } formatThrowable(t, &sink); } diff --git a/runtime/druntime/src/rt/dwarfeh.d b/runtime/druntime/src/rt/dwarfeh.d index f595dffdf8..cb9d0aa1fa 100644 --- a/runtime/druntime/src/rt/dwarfeh.d +++ b/runtime/druntime/src/rt/dwarfeh.d @@ -343,8 +343,8 @@ extern(C) void _d_throwdwarf(Throwable o) * since otherwise everything is enclosed by a top-level * try/catch. */ - fprintf(stderr, "%s:%d: uncaught exception reached top of stack\n", __FILE__.ptr, __LINE__); - fprintf(stderr, "This might happen if you're missing a top level catch in your fiber or signal handler\n"); + fprintf(cast()stderr, "%s:%d: uncaught exception reached top of stack\n", __FILE__.ptr, __LINE__); + fprintf(cast()stderr, "This might happen if you're missing a top level catch in your fiber or signal handler\n"); /** As _d_print_throwable() itself may throw multiple times when calling core.demangle, and with the uncaught exception still on the EH stack, this doesn't bode well with core.demangle's error recovery. @@ -461,7 +461,7 @@ extern (C) _Unwind_Reason_Code __dmd_personality_v0(int ver, _Unwind_Action acti final switch (result) { case LsdaResult.notFound: - fprintf(stderr, "not found\n"); + fprintf(cast()stderr, "not found\n"); terminate(__LINE__); assert(0); @@ -470,7 +470,7 @@ extern (C) _Unwind_Reason_Code __dmd_personality_v0(int ver, _Unwind_Action acti assert(0); case LsdaResult.corrupt: - fprintf(stderr, "LSDA is corrupt\n"); + fprintf(cast()stderr, "LSDA is corrupt\n"); terminate(__LINE__); assert(0); @@ -788,7 +788,7 @@ LsdaResult scanLSDA(const(ubyte)* lsda, _Unwind_Ptr ip, _Unwind_Exception_Class { if (p == pActionTable) break; - fprintf(stderr, "no Call Site Table\n"); + fprintf(cast()stderr, "no Call Site Table\n"); return LsdaResult.corrupt; } @@ -819,7 +819,7 @@ LsdaResult scanLSDA(const(ubyte)* lsda, _Unwind_Ptr ip, _Unwind_Exception_Class auto h = actionTableLookup(exceptionObject, cast(uint)ActionRecordPtr, pActionTable, tt, TType, exceptionClass, lsda); if (h < 0) { - fprintf(stderr, "negative handler\n"); + fprintf(cast()stderr, "negative handler\n"); return LsdaResult.corrupt; } if (h == 0) @@ -898,7 +898,7 @@ int actionTableLookup(_Unwind_Exception* exceptionObject, uint actionRecordPtr, if (TypeFilter <= 0) // should never happen with DMD generated tables { - fprintf(stderr, "TypeFilter = %d\n", cast(int)TypeFilter); + fprintf(cast()stderr, "TypeFilter = %d\n", cast(int)TypeFilter); return -1; // corrupt } @@ -920,7 +920,7 @@ int actionTableLookup(_Unwind_Exception* exceptionObject, uint actionRecordPtr, else goto case DW_EH_PE_udata4; default: - fprintf(stderr, "TType = x%x\n", TType); + fprintf(cast()stderr, "TType = x%x\n", TType); return -1; // corrupt } if (!entry) // the 'catch all' type diff --git a/runtime/druntime/src/rt/minfo.d b/runtime/druntime/src/rt/minfo.d index 6f09674412..a70aabbeb6 100644 --- a/runtime/druntime/src/rt/minfo.d +++ b/runtime/druntime/src/rt/minfo.d @@ -183,7 +183,7 @@ struct ModuleGroup { case "deprecate": // Option deprecated in 2.101, remove in 2.111 - fprintf(stderr, "`--DRT-oncycle=deprecate` is no longer supported, using `abort` instead\n"); + fprintf(cast()stderr, "`--DRT-oncycle=deprecate` is no longer supported, using `abort` instead\n"); break; case "abort": onCycle = abort; @@ -375,7 +375,7 @@ struct ModuleGroup case print: // print the message buildCycleMessage(idx, midx, (string x) { - fprintf(stderr, "%.*s", cast(int) x.length, x.ptr); + fprintf(cast()stderr, "%.*s", cast(int) x.length, x.ptr); }); // continue on as if this is correct. break; @@ -520,7 +520,7 @@ struct ModuleGroup !doSort(MItlsctor | MItlsdtor, _tlsctors)) { // print a warning - fprintf(stderr, "Deprecation 16211 warning:\n" + fprintf(cast()stderr, "Deprecation 16211 warning:\n" ~ "A cycle has been detected in your program that was undetected prior to DMD\n" ~ "2.072. This program will continue, but will not operate when using DMD 2.074\n" ~ "to compile. Use runtime option --DRT-oncycle=print to see the cycle details.\n"); diff --git a/runtime/druntime/src/rt/monitor_.d b/runtime/druntime/src/rt/monitor_.d index 1d4ed2ea8f..b63707ee95 100644 --- a/runtime/druntime/src/rt/monitor_.d +++ b/runtime/druntime/src/rt/monitor_.d @@ -36,14 +36,14 @@ else // may not be safe or desirable. Thus, devt is only valid if impl is // null. -extern (C) void _d_setSameMutex(shared Object ownee, shared Object owner) nothrow +extern (C) void _d_setSameMutex(shared Object ownee, shared Object owner) @trusted nothrow in { assert(ownee.__monitor is null); } do { - auto m = ensureMonitor(cast(Object) owner); + auto m = ensureMonitor(cast(Object) cast(void*) owner); if (m.impl is null) { atomicOp!"+="(m.refs, size_t(1)); @@ -238,19 +238,19 @@ private: __gshared Mutex gmtx; -@property ref shared(Monitor*) monitor(return scope Object h) pure nothrow @nogc +shared(Monitor*)* monitorPtr(return scope Object h) pure nothrow @nogc @trusted { - return *cast(shared Monitor**)&h.__monitor; + return cast(shared(Monitor*)*) &h.__monitor; } shared(Monitor)* getMonitor(Object h) pure @nogc { - return atomicLoad!(MemoryOrder.acq)(h.monitor); + return atomicLoad!(MemoryOrder.acq)(*monitorPtr(h)); } void setMonitor(Object h, shared(Monitor)* m) pure @nogc { - atomicStore!(MemoryOrder.rel)(h.monitor, m); + atomicStore!(MemoryOrder.rel)(*monitorPtr(h), m); } shared(Monitor)* ensureMonitor(Object h) diff --git a/runtime/druntime/src/rt/profilegc.d b/runtime/druntime/src/rt/profilegc.d index e7d4f03e53..dd12995f42 100644 --- a/runtime/druntime/src/rt/profilegc.d +++ b/runtime/druntime/src/rt/profilegc.d @@ -151,7 +151,7 @@ shared static ~this() { qsort(counts.ptr, counts.length, Result.sizeof, &Result.qsort_cmp); - FILE* fp = logfilename == "\0" ? stdout : fopen((logfilename).ptr, "w"); + FILE* fp = logfilename == "\0" ? cast()stdout : fopen((logfilename).ptr, "w"); if (fp) { fprintf(fp, "bytes allocated, allocations, type, function, file:line\n"); @@ -167,7 +167,7 @@ shared static ~this() else { const err = errno; - fprintf(stderr, "cannot write profilegc log file '%.*s' (errno=%d)", + fprintf(cast()stderr, "cannot write profilegc log file '%.*s' (errno=%d)", cast(int) logfilename.length, logfilename.ptr, cast(int) err); diff --git a/runtime/druntime/src/rt/trace.d b/runtime/druntime/src/rt/trace.d index b563368685..18a37b7a1d 100644 --- a/runtime/druntime/src/rt/trace.d +++ b/runtime/druntime/src/rt/trace.d @@ -527,7 +527,7 @@ shared static ~this() trace_merge(&groot); // Report results - FILE* fplog = trace_logfilename.length == 0 ? stdout : + FILE* fplog = trace_logfilename.length == 0 ? cast()stdout : fopen(trace_logfilename.ptr, "w"); if (fplog) { @@ -545,10 +545,10 @@ shared static ~this() psymbols = null; } else - fprintf(stderr, "cannot write '%s'", trace_logfilename.ptr); + fprintf(cast()stderr, "cannot write '%s'", trace_logfilename.ptr); // Output function link order - FILE* fpdef = trace_deffilename.length == 0 ? stdout : + FILE* fpdef = trace_deffilename.length == 0 ? cast()stdout : fopen(trace_deffilename.ptr, "w"); if (fpdef) { @@ -557,7 +557,7 @@ shared static ~this() fclose(fpdef); } else - fprintf(stderr, "cannot write '%s'", trace_deffilename.ptr); + fprintf(cast()stderr, "cannot write '%s'", trace_deffilename.ptr); } } From 020ed0ff78300a505d4df8380829c6cc691bb2f4 Mon Sep 17 00:00:00 2001 From: Steven Schveighoffer Date: Fri, 20 Feb 2026 01:25:02 -0500 Subject: [PATCH 339/440] Fix issue dlang/dmd!22517. typeid(void) claims that the type has pointers, so (dlang/dmd!22593) hasIndirections should match. --- runtime/druntime/src/core/internal/array/utils.d | 7 +++++++ runtime/druntime/src/core/internal/traits.d | 14 ++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/runtime/druntime/src/core/internal/array/utils.d b/runtime/druntime/src/core/internal/array/utils.d index 9eae8f092b..25adb1e628 100644 --- a/runtime/druntime/src/core/internal/array/utils.d +++ b/runtime/druntime/src/core/internal/array/utils.d @@ -157,6 +157,13 @@ void[] __arrayAlloc(T)(size_t arrSize) @trusted return null; } +// https://github.com/dlang/dmd/issues/22517 +@system unittest +{ + auto arr = new void[10]; + assert((GC.getAttr(&arr[0]) & BlkAttr.NO_SCAN) == 0); +} + /** Given an array of length `size` that needs to be expanded to `newlength`, compute a new capacity. diff --git a/runtime/druntime/src/core/internal/traits.d b/runtime/druntime/src/core/internal/traits.d index a94ee377d4..33daecc7d3 100644 --- a/runtime/druntime/src/core/internal/traits.d +++ b/runtime/druntime/src/core/internal/traits.d @@ -587,9 +587,11 @@ template hasIndirections(T) else static if (__traits(isAssociativeArray, T) || is(T == class) || is(T == interface)) enum hasIndirections = true; else static if (is(T == E[N], E, size_t N)) - enum hasIndirections = T.sizeof && (is(immutable E == immutable void) || hasIndirections!(BaseElemOf!E)); + enum hasIndirections = T.sizeof && hasIndirections!(BaseElemOf!E); else static if (isFunctionPointer!T) enum hasIndirections = false; + else static if (is(immutable(T) == immutable(void))) + enum hasIndirections = true; else enum hasIndirections = isPointer!T || isDelegate!T || isDynamicArray!T; } @@ -750,11 +752,11 @@ template hasIndirections(T) // https://github.com/dlang/dmd/issues/20812 @safe unittest { - static assert(!hasIndirections!void); - static assert(!hasIndirections!(const void)); - static assert(!hasIndirections!(inout void)); - static assert(!hasIndirections!(immutable void)); - static assert(!hasIndirections!(shared void)); + static assert( hasIndirections!void); + static assert( hasIndirections!(const void)); + static assert( hasIndirections!(inout void)); + static assert( hasIndirections!(immutable void)); + static assert( hasIndirections!(shared void)); static assert( hasIndirections!(void*)); static assert( hasIndirections!(const void*)); From a61e537ddaaed7f5023588e0a64b72573fd62925 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Fri, 20 Feb 2026 19:29:57 +0800 Subject: [PATCH 340/440] Always make a copy when constructing mutable struct literals (dlang/dmd!22596) --- dmd/expressionsem.d | 3 +- tests/dmd/runnable/structlit_rvalue.d | 64 ++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 8 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 3dec8c5e74..5bb236df8e 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -808,8 +808,7 @@ bool canElideCopy(Expression e, Type to, bool checkMod = true) case EXP.dotVariable: return visitDotVarExp(e.isDotVarExp()); case EXP.structLiteral: - auto sle = e.isStructLiteralExp(); - return !(checkMod && sle.useStaticInit && to.isMutable()); + return true; case EXP.variable: return (e.isVarExp().var.storage_class & STC.rvalue) != 0; default: diff --git a/tests/dmd/runnable/structlit_rvalue.d b/tests/dmd/runnable/structlit_rvalue.d index c8f63c71f3..86ef405c1f 100644 --- a/tests/dmd/runnable/structlit_rvalue.d +++ b/tests/dmd/runnable/structlit_rvalue.d @@ -1,15 +1,67 @@ -void refCounted(ProcessPipes val) +struct S22585_1 { - val = ProcessPipes.init; + char[32] a; + int b = 1; + + this(ref S22585_1 s) + { + s.b = 2; + } +} + +struct T22585_1 +{ + S22585_1 s; +} + +void copyConstruct(S22585_1) {} + +void mutate(ref S22585_1 s) +{ + s.b = 2; +} + +struct S22585_2 +{ + char[32] a; + int b = 1; + ~this() {} +} + +struct T22585_2 +{ + S22585_2 s; +} + +pragma(inline, true) +S22585_2 inlinedRvalue1() +{ + bool b; + return (b ? T22585_2.init : T22585_2.init).s; +} + +void mutateCopyOf(S22585_2 s) +{ + s.b = 2; +} + +pragma(inline, true) +S22585_2 inlinedRvalue2() +{ + return S22585_2.init; } -struct ProcessPipes +void assignCopyOf(S22585_2 s) { - char[33] arr; - ~this() @safe {} + s = S22585_2.init; } void main() { - refCounted(ProcessPipes.init); + bool b; + copyConstruct((b ? T22585_1.init : T22585_1.init).s); + mutate((b ? T22585_1.init : T22585_1.init).s); + mutateCopyOf(inlinedRvalue1()); + inlinedRvalue2.b = 2; + assignCopyOf(S22585_2.init); } From b49aa0a78ee64c806e6acbfa9e6389ca83a1ba63 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Sat, 21 Feb 2026 17:21:53 +0800 Subject: [PATCH 341/440] Refactor: expose `canElideCopy` to C++ with saner default parameters (dlang/dmd!22602) --- dmd/cxxfrontend.d | 6 ++++++ dmd/expression.h | 1 + dmd/expressionsem.d | 11 ++++++++--- dmd/inline.d | 2 +- dmd/semantic3.d | 2 +- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/dmd/cxxfrontend.d b/dmd/cxxfrontend.d index b4524a465b..709aff03ca 100644 --- a/dmd/cxxfrontend.d +++ b/dmd/cxxfrontend.d @@ -430,6 +430,12 @@ bool isLvalue(Expression exp) return dmd.expressionsem.isLvalue(exp); } +bool canElideCopy(Expression exp, Type to, bool checkMod) +{ + import dmd.expressionsem; + return dmd.expressionsem.canElideCopy(exp, to, checkMod); +} + int getFieldIndex(ClassReferenceExp cre, Type fieldtype, uint fieldoffset) { import dmd.expressionsem; diff --git a/dmd/expression.h b/dmd/expression.h index a8e1c9fb92..d3896125bd 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -62,6 +62,7 @@ namespace dmd bool isIdentical(const Expression *exp, const Expression *e); bool equals(const Expression *exp, const Expression *e); bool isLvalue(Expression *exp); + bool canElideCopy(Expression *exp, Type *to, bool checkMod = false); int32_t getFieldIndex(ClassReferenceExp *cre, Type *fieldtype, uint32_t fieldoffset); void fillTupleExpExps(TupleExp *te, TupleDeclaration *tup); Optional toBool(Expression *exp); diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 5bb236df8e..4511f28cc4 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -761,8 +761,13 @@ bool isLvalue(Expression _this) * Determine if copy elision is allowed when copying an expression to * a typed storage. This basically elides a restricted subset of so-called * "pure" rvalues, i.e. expressions with no reference semantics. + * + * Note: Please avoid using `checkMod` parameter because `canElideCopy()` + * essentially defines a value category and should eventually be merged with + * `isLvalue()` to return [isLvalue, allowEmplacement]. + * Checking type compatibility here is only a stopgap measure. */ -bool canElideCopy(Expression e, Type to, bool checkMod = true) +bool canElideCopy(Expression e, Type to, bool checkMod = false) { if (checkMod && !MODimplicitConv(e.type.mod, to.mod)) return false; @@ -791,7 +796,7 @@ bool canElideCopy(Expression e, Type to, bool checkMod = true) return false; // If an aggregate can be elided, so are its fields - return canElideCopy(e.e1, e.e1.type, false); + return canElideCopy(e.e1, e.e1.type); } switch (e.op) @@ -1920,7 +1925,7 @@ extern (D) Expression doCopyOrMove(Scope* sc, Expression e, Type t, bool nrvo, b { e = callCpCtor(sc, e, t, nrvo); } - else if (move && sd && sd.hasMoveCtor && !canElideCopy(e, t ? t : e.type, false)) + else if (move && sd && sd.hasMoveCtor && !canElideCopy(e, t ? t : e.type)) { // #move /* Rewrite as: diff --git a/dmd/inline.d b/dmd/inline.d index bb5821c0f1..e88b737d10 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -403,7 +403,7 @@ public: auto tf = ids.fd.type.isTypeFunction(); if (exp.type.ty == Tstruct && !tf.isRef && - !ids.fd.isCtorDeclaration() && !canElideCopy(s.exp, tf.nextOf())) + !ids.fd.isCtorDeclaration() && !canElideCopy(s.exp, tf.nextOf(), true)) { /* If the inlined function returns a copy of a struct, * and then the return value is used subsequently as an diff --git a/dmd/semantic3.d b/dmd/semantic3.d index 15677f1fc6..dacd872dc0 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -974,7 +974,7 @@ private extern(C++) final class Semantic3Visitor : Visitor if (funcdecl.vresult) { // Create: return vresult = exp; - if (canElideCopy(exp, funcdecl.vresult.type, false)) + if (canElideCopy(exp, funcdecl.vresult.type)) exp = new ConstructExp(rs.loc, funcdecl.vresult, exp); else exp = new BlitExp(rs.loc, funcdecl.vresult, exp); From 2b08413a99c142ff7719f5f0393ede758d9bb973 Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Mon, 23 Feb 2026 12:50:45 +1300 Subject: [PATCH 342/440] Implement for fast DFA engine, value tracking and uninitialized memory preventing of reading (dlang/dmd!22400) --- dmd/dfa/entry.d | 11 +- dmd/dfa/fast/analysis.d | 415 ++++++++++++++++++++---- dmd/dfa/fast/expression.d | 464 +++++++++++++++++++++------ dmd/dfa/fast/report.d | 56 +++- dmd/dfa/fast/statement.d | 377 ++++++++++++++++++---- dmd/dfa/fast/structure.d | 349 +++++++++++++++++--- dmd/statementsem.d | 3 +- tests/dmd/compilable/fastdfa.d | 350 ++++++++++++++++++-- tests/dmd/fail_compilation/fastdfa.d | 167 ++++++++-- 9 files changed, 1887 insertions(+), 305 deletions(-) diff --git a/dmd/dfa/entry.d b/dmd/dfa/entry.d index f6a5b8f36d..d29b963124 100644 --- a/dmd/dfa/entry.d +++ b/dmd/dfa/entry.d @@ -63,6 +63,7 @@ private: * - StatementWalker: Traverses statements (if, while, return). * - ExpressionWalker: Traverses expressions (a + b, func()). * - DFAAnalyzer: Tracks the state of variables (The Brain). + * - DFAReporter: Reports errors and handles inferring. * 3. Wires them together but separates them for separation of concerns reasons. * 4. Starts the single-pass walk. * @@ -94,11 +95,11 @@ void fastDFA(FuncDeclaration fd, Scope* sc) } // Use these if statements for debugging specific things. - //if (fd.ident.toString != "switchMakeKnown") return; - //if (!(fd.ident.toString == "test3632" || fd.ident.toString == "test")) return; - //if (fd.loc.linnum < 1380) return; + //if (fd.ident.toString != "checkFloatInit5") return; + //if (!(fd.ident.toString == "replaceReferenceDefinition" || fd.ident.toString == "extractReferences")) return; + //if (fd.loc.linnum != 54) return; //if (fd.getModule.ident.toString != "start") return; - //if (strcmp(mangleExact(fd), "_D4core8internal5array8equality__T7isEqualTxS3dub6recipe13packagerecipe17ConfigurationInfoTxQBwZQCkFNbMAxQCjMQgmZb") != 0) return; + //if (strcmp(mangleExact(fd), "_D4core9exception15ArraySliceError6__ctorMFNaNbNiNfmmmAyamC6object9ThrowableZCQCyQCwQCp") != 0) return; // Protect functions based upon safetiness of it. // It may be desirable to disable some behaviors in @system code, or completely. @@ -116,6 +117,8 @@ void fastDFA(FuncDeclaration fd, Scope* sc) DFAAnalyzer analyzer; DFAReporter reporter; + dfaCommon.allocator.dfaCommon = &dfaCommon; + stmtWalker.dfaCommon = &dfaCommon; expWalker.dfaCommon = &dfaCommon; analyzer.dfaCommon = &dfaCommon; diff --git a/dmd/dfa/fast/analysis.d b/dmd/dfa/fast/analysis.d index b5e5f69a41..efb89cd948 100644 --- a/dmd/dfa/fast/analysis.d +++ b/dmd/dfa/fast/analysis.d @@ -141,6 +141,16 @@ struct DFAAnalyzer // False body should never be null. assert(!scrFalse.isNull); + version (none) + { + printf("Converging an if statement %d %d, haveFalseBody=%d, unknownBranchTaken=%d, predicateNegation=%d\n", + scrTrue.isNull, scrFalse.isNull, haveFalseBody, + unknownBranchTaken, predicateNegation); + condition.printActual("condition"); + scrTrue.printActual("true"); + scrFalse.printActual("false"); + } + void protectLoopAgainst(ref DFAScopeRef scr) { if (dfaCommon.lastLoopyLabel is null) @@ -457,11 +467,13 @@ struct DFAAnalyzer // In scenario d we've both jumped, any effects at that time were already copied to the jump point. // Nothing for us to do in that scenario. - if (!scrTrue.sc.haveJumped) + if (scrTrue.sc.haveJumped) + { + // Both jumped, no state to converge. + } { // In scenario a, neither has jumped, any effects at the end of their bodies should be meet'd. // Then we can converge that into parent scope. - protectGate; DFAScopeRef meeted = meetScope(scrTrue, scrFalse, true); assert(!meeted.isNull); @@ -739,6 +751,18 @@ struct DFAAnalyzer } } + void checkForDifferentObjects(DFAConsequence* oldC, DFAConsequence* newC) + { + if (oldC.obj !is newC.obj) + newC.obj = null; + } + + void checkForPA(DFAConsequence* oldC, DFAConsequence* newC) + { + if (oldC.pa != newC.pa) + newC.pa = DFAPAValue.Unknown; + } + foreach (var, l2; beforeScopeState) { DFAScopeVar* oldState = dfaCommon.acquireScopeVar(var); @@ -746,6 +770,8 @@ struct DFAAnalyzer if (oldState is null || newState is null) continue; + checkForDifferentObjects(oldState.lr.lattice.context, l2.context); + checkForPA(oldState.lr.lattice.context, l2.context); checkForNull(newState, oldState.lr.lattice.context, l2.context); checkForAssignAfterAssert(beforeScopeState, newState, l2); } @@ -759,6 +785,8 @@ struct DFAAnalyzer if (oldState is null || newState is null) continue; + checkForDifferentObjects(oldState.lr.lattice.context, l2.context); + checkForPA(oldState.lr.lattice.context, l2.context); checkForNull(newState, oldState.lr.lattice.context, l2.context); checkForAssignAfterAssert(containing, newState, l2); } @@ -854,6 +882,14 @@ struct DFAAnalyzer void convergeFunctionCallArgument(DFALatticeRef lr, ParameterDFAInfo* paramInfo, ulong paramStorageClass, FuncDeclaration calling, ref Loc loc) { + + const isByRef = (paramStorageClass & (STC.ref_ | STC.out_)) != 0; + const couldEscape = (paramStorageClass & STC.scope_) == 0 + || (paramStorageClass & (STC.return_ | STC.returnScope | STC.returnRef)) != 0; + + // A function call argument, may initialize the parameter if its by-ref or if its the this pointer. + this.onRead(lr, loc, paramInfo is null || paramInfo.parameterId == -1 || isByRef, isByRef); + DFAVar* ctx; DFAConsequence* cctx = lr.getContext(ctx); @@ -864,10 +900,6 @@ struct DFAAnalyzer reporter.onFunctionCallArgumentLessThan(cctx, paramInfo, calling, loc); } - const isByRef = (paramStorageClass & (STC.ref_ | STC.out_)) != 0; - const couldEscape = (paramStorageClass & STC.scope_) == 0 - || (paramStorageClass & (STC.return_ | STC.returnScope | STC.returnRef)) != 0; - bool seePointer(DFAVar* var) { bool handledVar; @@ -882,10 +914,20 @@ struct DFAAnalyzer if (couldEscape) root.unmodellable = true; + DFAConsequence* rootCctx = lr.findConsequence(root); + // Put the state of the var into an unknown state, // this prevents it from infesting other variables. DFALatticeRef temp = dfaCommon.makeLatticeRef; - temp.setContext(root); + DFAConsequence* newCctx = temp.setContext(root); + + if (isByRef && root.isNullable && (cctx.nullable != Nullable.Null + || paramInfo is null || paramInfo.notNullOut != Fact.NotGuaranteed)) + { + // Object could've changed. + newCctx.obj = dfaCommon.makeObject(rootCctx !is null ? rootCctx.obj : null); + } + seeWrite(root, temp); this.convergeExpression(temp, true); @@ -893,9 +935,8 @@ struct DFAAnalyzer if (root !is var) { - DFAConsequence* c = lr.findConsequence(root); - if (c !is null) - c.maybeTopSeen = true; + if (rootCctx !is null) + rootCctx.maybeTopSeen = true; } else handledVar = true; @@ -905,6 +946,18 @@ struct DFAAnalyzer return handledVar; } + void seeObject(DFAObject* obj) + { + obj.walkRoots((DFAObject* root) { + if (root.storageFor !is null) + { + DFAScope* sideEffectScope = dfaCommon.getSideEffectScope(); + DFAScopeVar* scv = sideEffectScope.getScopeVar(root.storageFor); + seeWrite(root.storageFor, scv.lr); + } + }); + } + if (ctx is null) { lr.walkMaybeTops((c) { @@ -912,6 +965,8 @@ struct DFAAnalyzer return true; seePointer(c.var); + if (c.obj !is null) + seeObject(c.obj); return true; }); } @@ -919,6 +974,8 @@ struct DFAAnalyzer { if (seePointer(ctx)) cctx.maybeTopSeen = true; + if (cctx !is null && cctx.obj !is null) + seeObject(cctx.obj); } this.convergeExpression(lr, true); @@ -929,6 +986,7 @@ struct DFAAnalyzer { if (lr.isNull) return; + onRead(lr, loc); const currentDepth = dfaCommon.currentDFAScope.depth; bool modellable = true; @@ -962,7 +1020,6 @@ struct DFAAnalyzer { if (c.var is null || c.var.haveBase) return; - DFAScopeVar* scv = dfaCommon.acquireScopeVar(c.var); c.var.assertedCount++; @@ -1004,6 +1061,7 @@ struct DFAAnalyzer { printf(" %d:%d\n", old.truthiness, old.nullable); } + return lattice; }); } @@ -1029,11 +1087,23 @@ struct DFAAnalyzer However we don't need the actual predicate integer (see ExpressionWalker.walkCondition). The flag in the consequence is enough, as !!gate should set the lr to unknown not false. */ + if (DFAConsequence* gateCctx = lr.getGateConsequence) { if (DFAScopeVar* gateSCV = dfaCommon.lastLoopyLabel.findScopeVar(gateCctx.var)) { - if (gateSCV.gatePredicateWriteCount != gateCctx.writeOnVarAtThisPoint) + version (none) + { + printf("gate for %p, %d != %d - %d\n", gateCctx.var, gateSCV.gatePredicateWriteCount, + gateCctx.writeOnVarAtThisPoint, + cast(int)(gateCctx.var.param !is null)); + + printf(" %d %d %d %d\n", gateCctx.invertedOnce, + gateSCV.assertTrueDepth, gateSCV.assertFalseDepth, currentDepth); + } + + if (gateSCV.gatePredicateWriteCount != gateCctx.writeOnVarAtThisPoint - cast( + int)(gateCctx.var.param !is null)) { } else if (!gateCctx.invertedOnce) @@ -1058,6 +1128,14 @@ struct DFAAnalyzer { if (DFAScopeVar* gateSCV = dfaCommon.lastLoopyLabel.getScopeVar(gateCctx.var)) { + version (none) + { + printf("gate store %p, %d %d %d\n", gateCctx.var, + gateSCV.assignDepth, gateSCV.assertDepth, currentDepth); + printf(" %d %d %d\n", gateCctx.truthiness, + gateSCV.assertTrueDepth, gateSCV.assertFalseDepth); + } + if (gateSCV.assignDepth == 0 || gateSCV.assertDepth > currentDepth) { gateSCV.assertDepth = currentDepth; @@ -1106,17 +1184,22 @@ struct DFAAnalyzer * - Construct: `int a = 5` (Initialization). */ DFALatticeRef transferAssign(DFALatticeRef assignTo, bool construct, bool isBlit, - DFALatticeRef lr, int alteredState, DFALatticeRef indexLR = DFALatticeRef.init) + DFALatticeRef lr, int alteredState, ref Loc loc, + DFALatticeRef indexLR = DFALatticeRef.init) { + DFAVar* assignToCtx = assignTo.getContextVar; DFAVar* lrCtx; DFAConsequence* lrCctx = lr.getContext(lrCtx); - const noLR = lrCctx is null; const lrIsTruthy = !noLR ? lrCctx.truthiness == Truthiness.True : false; const unmodellable = lrCtx !is null && !lrCtx.isModellable; DFALatticeRef ret; + this.onRead(assignTo, loc, true); + // Explicitly allow returns of uninitialized variables. + this.onRead(lr, loc, assignToCtx !is null && assignToCtx is dfaCommon.getReturnVariable); + if (assignToCtx !is null) { // *var = expr; @@ -1128,7 +1211,7 @@ struct DFAAnalyzer assignToCtx.visitIfReferenceToAnotherVar((contextVar) { wasDereferenced = true; - // This is a dereference: *var = expr; + // This is a dereference: *contextVar = expr; // Which means the effects of lr don't really apply to the lhs. if (contextVar.isTruthy || contextVar.isNullable) @@ -1164,7 +1247,6 @@ struct DFAAnalyzer else { ret = join(assignTo, lr.copyWithoutInfiniteLifetime, 0, null); - DFAConsequence* c = ret.addConsequence(null); ret.setContext(c); @@ -1189,7 +1271,6 @@ struct DFAAnalyzer if (!indexLR.isNull) ret = this.transferLogicalAnd(ret, indexLR); - DFAConsequence* retCctx = ret.addConsequence(assignToCtx); ret.setContext(retCctx); @@ -1227,22 +1308,73 @@ struct DFAAnalyzer if (retCctx.truthiness == Truthiness.Maybe) retCctx.truthiness = Truthiness.Unknown; - if (lrCtx !is null) + if (assignToCtx !is null) { - lrCtx.visitReferenceToAnotherVar((var) { - // escapes, who knows what its gonna look like after this - var.unmodellable = true; + bool exactlyOneRoot; - DFAConsequence* c = ret.addConsequence(var); - c.truthiness = Truthiness.Unknown; - c.nullable = Nullable.Unknown; + assignToCtx.visitIfReadOfReferenceToAnotherVar((root) { + DFAConsequence* c = assignTo.findConsequence(root); + + if (c !is null && c.obj !is null) + { + DFAVar* firstRoot; + int rootCount; + + c.obj.walkRoots((objRoot) { + if (objRoot.storageFor !is null && !objRoot.storageFor.haveBase) + { + if (firstRoot !is null) + { + objRoot.storageFor.unmodellable = true; + DFAConsequence* cUnk = ret.addConsequence(objRoot.storageFor); + cUnk.truthiness = Truthiness.Unknown; + cUnk.nullable = Nullable.Unknown; + } + else + firstRoot = objRoot.storageFor; + + rootCount++; + } + }); + + if (rootCount == 1) + { + exactlyOneRoot = true; + this.seeWrite(firstRoot, ret); + + DFAConsequence* c2 = ret.addConsequence(firstRoot); + c2.truthiness = retCctx.truthiness; + c2.nullable = retCctx.nullable; + c2.pa = retCctx.pa; + } + else if (rootCount > 1) + { + firstRoot.unmodellable = true; + DFAConsequence* cUnk = ret.addConsequence(firstRoot); + cUnk.truthiness = Truthiness.Unknown; + cUnk.nullable = Nullable.Unknown; + } + } }); - } - if (assignToCtx !is null) - { - if (!construct) - seeWrite(assignToCtx, ret); + if ((!assignToCtx.haveBase && assignToCtx.var is null) + || (assignToCtx.haveBase && !exactlyOneRoot)) + { + if (lrCctx !is null && lrCctx.obj !is null) + { + lrCctx.obj.walkRoots((objRoot) { + if (objRoot.storageFor !is null && !objRoot.storageFor.haveBase) + { + objRoot.storageFor.unmodellable = true; + DFAConsequence* cUnk = ret.addConsequence(objRoot.storageFor); + cUnk.truthiness = Truthiness.Unknown; + cUnk.nullable = Nullable.Unknown; + } + }); + } + } + + seeWrite(assignToCtx, ret); ret.setContext(assignToCtx); DFAScopeVar* scv = this.convergeExpression(ret.copy, true); @@ -1292,7 +1424,7 @@ struct DFAAnalyzer You don't want the condition variable to effect the output lattice truthiness, but you do want the variable to alter. */ - requireMaybeContext = true; + requireMaybeContext = c.truthiness <= Truthiness.Maybe; c.truthiness = c.truthiness == Truthiness.False ? Truthiness.True : Truthiness.False; } @@ -1322,7 +1454,7 @@ struct DFAAnalyzer if (requireMaybeContext) { DFAConsequence* newCctx = lr.acquireConstantAsContext(Truthiness.Maybe, - Nullable.Unknown); + Nullable.Unknown, null); // Don't forget to patch the maybe's, impacts asserts. newCctx.maybe = cctx.var; } @@ -1339,8 +1471,12 @@ struct DFAAnalyzer assert(lhsCctx !is null); assert(rhsCctx !is null); - DFAPAValue newValue = lhsCctx.pa; + if (lhsCctx.obj !is null) + lhsCctx.obj.mayNotBeExactPointer = true; + if (rhsCctx.obj !is null) + rhsCctx.obj.mayNotBeExactPointer = true; + DFAPAValue newValue = lhsCctx.pa; final switch (op) { case PAMathOp.add: @@ -1434,9 +1570,9 @@ struct DFAAnalyzer if (couldBeNull) reporter.onDereference(ctx, loc); - else if (!dfaCommon.currentDFAScope.inConditional && ctx.writeOnVarAtThisPoint == 0 - && ctx.var !is null && ctx.var.assertedCount == 0 - && ctx.var.param !is null && !ctx.var.param.specifiedByUser) + else if (ctx.var !is null && ctx.var.param !is null + && !ctx.var.param.specifiedByUser && !dfaCommon.currentDFAScope.inConditional + && ctx.writeOnVarAtThisPoint == 1 && ctx.var.assertedCount == 0) { if (dfaCommon.debugIt) printf("Infer variable as non-null `%s` at %s\n", @@ -1456,7 +1592,7 @@ struct DFAAnalyzer /// See_Also: equalityArgTypes DFALatticeRef transferEqual(DFALatticeRef lhs, DFALatticeRef rhs, - bool equalityIsTrue, EqualityArgType equalityType) + bool equalityIsTrue, EqualityArgType equalityType, bool isIdentity) { // struct // floating point @@ -1466,11 +1602,14 @@ struct DFAAnalyzer DFAConsequence* lhsCctx = lhs.getContext, rhsCctx = rhs.getContext; if (lhsCctx is null || rhsCctx is null) return DFALatticeRef.init; + DFAVar* lhsVar = lhsCctx.var, rhsVar = rhsCctx.var; + Truthiness expectedTruthiness; bool couldBeUnknown; - checkVRPVar(lhsVar, couldBeUnknown); - checkVRPVar(rhsVar, couldBeUnknown); + + checkPAVar(lhsVar, couldBeUnknown); + checkPAVar(rhsVar, couldBeUnknown); const treatAsInteger = equalityType == EqualityArgType.Unknown; const treatAsPointer = equalityType == EqualityArgType.DynamicArray @@ -1488,8 +1627,6 @@ struct DFAAnalyzer ob.writestring("\n"); }); - Truthiness expectedTruthiness; - if ((lhsVar is null || lhsVar.isModellable) && (rhsVar is null || rhsVar.isModellable)) { expectedTruthiness = Truthiness.Maybe; @@ -1498,7 +1635,12 @@ struct DFAAnalyzer { if (treatAsPointer) { - if (lhsCctx.nullable == Nullable.Null && lhsCctx.nullable == rhsCctx.nullable) + if (lhsCctx.nullable == Nullable.NonNull && rhsCctx.nullable == Nullable.NonNull + && lhsCctx.obj !is null && lhsCctx.obj is rhsCctx.obj + && !lhsCctx.obj.mayNotBeExactPointer) + expectedTruthiness = isIdentity ? Truthiness.True : Truthiness.Maybe; + else if (lhsCctx.nullable == Nullable.Null + && lhsCctx.nullable == rhsCctx.nullable) expectedTruthiness = Truthiness.True; else if (lhsCctx.truthiness == Truthiness.False && lhsCctx.truthiness == rhsCctx.truthiness) @@ -1541,7 +1683,13 @@ struct DFAAnalyzer expectedTruthiness = Truthiness.True; else if (lhsCctx.nullable == Nullable.NonNull && lhsCctx.nullable == rhsCctx.nullable) - expectedTruthiness = Truthiness.Maybe; + { + if (lhsCctx.obj !is null && lhsCctx.obj is rhsCctx.obj + && !lhsCctx.obj.mayNotBeExactPointer) + expectedTruthiness = isIdentity ? Truthiness.False : Truthiness.Maybe; + else + expectedTruthiness = Truthiness.Maybe; + } else if (lhsCctx.nullable == Nullable.Null && lhsCctx.nullable == rhsCctx.nullable) expectedTruthiness = Truthiness.False; @@ -1617,7 +1765,8 @@ struct DFAAnalyzer DFALatticeRef ret = transferLogicalAnd(lhs, rhs); { - DFAConsequence* c = ret.acquireConstantAsContext(expectedTruthiness, Nullable.Unknown); + DFAConsequence* c = ret.acquireConstantAsContext(expectedTruthiness, + Nullable.Unknown, null); c.invertedOnce = expectedInvertedOnce; if (DFAConsequence* c2 = ret.findConsequence(rhsVar)) @@ -1693,8 +1842,8 @@ struct DFAAnalyzer assert(rhsCctx !is null); bool couldBeUnknown; - checkVRPVar(lhsCctx.var, couldBeUnknown); - checkVRPVar(rhsCctx.var, couldBeUnknown); + checkPAVar(lhsCctx.var, couldBeUnknown); + checkPAVar(rhsCctx.var, couldBeUnknown); Truthiness expectedTruthiness; @@ -1740,7 +1889,7 @@ struct DFAAnalyzer } DFALatticeRef ret = this.transferLogicalAnd(lhs, rhs); - ret.acquireConstantAsContext(expectedTruthiness, Nullable.Unknown); + ret.acquireConstantAsContext(expectedTruthiness, Nullable.Unknown, null); return ret; } @@ -1919,6 +2068,7 @@ struct DFAAnalyzer // Now add the consequences that are both in lhs and rhs, // that are not maybe tops. + foreach (oldC; lhs) { if (oldC.var is null || oldC.maybeTopSeen) @@ -1956,10 +2106,20 @@ struct DFAAnalyzer this.convergeStatementIf(condition, scrTrue, scrFalse, false, unknownBranchTaken, predicateNegation); - DFAVar* asContext = dfaCommon.findVariablePair(lrTrue.getContextVar, lrFalse.getContextVar); + + DFAVar* trueVar, falseVar; + DFAConsequence* trueCctx = lrTrue.getContext(trueVar), + falseCctx = lrFalse.getContext(falseVar); + + DFAObject* trueObj = trueCctx !is null ? trueCctx.obj : null; + DFAObject* falseObj = falseCctx !is null ? falseCctx.obj : null; + + DFAVar* asContext = dfaCommon.findVariablePair(trueVar, falseVar); DFALatticeRef ret = meet(lrTrue, lrFalse, 0, true); - ret.setContext(asContext); + + DFAConsequence* cctx = ret.setContext(asContext); + cctx.obj = dfaCommon.makeObject(trueObj, falseObj); return ret; } @@ -2001,6 +2161,135 @@ struct DFAAnalyzer return ret; } + void onRead(ref DFALatticeRef lr, ref Loc loc, bool willInit = false, + bool isByRef = false, bool forMathOp = false) + { + version (none) + { + lr.printStructure("READ READ READ"); + printf("READ READ value %d %d\n", willInit, isByRef); + } + + // Called by statement, expressions and analysis. + DFAVar* contextVar; + DFAConsequence* cctx = lr.getContext(contextVar); + + if (contextVar is null) + return; + assert(cctx !is null); + + DFALatticeRef toStore; + + void seeRootObject(DFAObject* root) + { + version (none) + { + printf("root object %p var %p\n", root, root.storageFor); + } + + // Don't apply effects from a variable that isn't actually modelled i.e. indirection. + + if (root.storageFor !is null && !root.storageFor.haveBase) + { + DFALatticeRef lr = dfaCommon.acquireLattice(root.storageFor); + DFAConsequence* cctx = lr.getContext; + + if (cctx !is null && cctx.writeOnVarAtThisPoint == 0) + reporter.onReadOfUninitialized(root.storageFor, lr, loc, forMathOp); + + if (toStore.isNull) + toStore = lr; + else + toStore = meet(toStore, lr); + } + } + + if (willInit) + { + // We differentiate if it is some form of initialize either lhs or rhs and isByRef because initialization of a struct member + // does not necessarily read the struct itself (offsets are fine), whereas ref parameters + // likely imply a read or dependency that requires initialization. + + // When initializing (writing), we only care if we are reading a variable to determine the address. + // e.g. `*ptr = 2` reads `ptr`. `struct.field = 2` does NOT read `struct`. + // `visitIfReadOfReferenceToAnotherVar` implements this logic (dereferences read base, offsets do not). + + contextVar.visitIfReadOfReferenceToAnotherVar((DFAVar* root) { + if (root.var is null || root is contextVar || root.unmodellable + || root.haveInfiniteLifetime) + return; + + DFAConsequence* c = lr.findConsequence(root); + if (c is null) + return; + + if (c.writeOnVarAtThisPoint == 0) + reporter.onReadOfUninitialized(root, lr, loc, forMathOp); + }); + } + else if (isByRef) + { + // For ref params, we generally require initialization unless it's 'out', but 'out' should be handled elsewhere/differently? + // Existing logic assumes 'ref' requires init. + + contextVar.visitIfReferenceToAnotherVar((DFAVar* root) { + if (root.var is null || root is contextVar || root.unmodellable + || root.haveInfiniteLifetime) + return; + + DFAConsequence* c = lr.findConsequence(root); + if (c is null) + return; + + if (c.writeOnVarAtThisPoint == 0) + reporter.onReadOfUninitialized(root, lr, loc, forMathOp); + else if (c.obj !is null) + c.obj.walkRoots(&seeRootObject); + }); + } + else + { + // We don't care about the case where indirection is involved. + // int val1 = void; + // int* ptr = &val1; + // int val2 = *ptr; // no error + + if (!contextVar.haveBase) + { + if (contextVar.var !is null && cctx.writeOnVarAtThisPoint == 0) + reporter.onReadOfUninitialized(contextVar, lr, loc, forMathOp); + } + + contextVar.visitIfReadOfReferenceToAnotherVar((DFAVar* root) { + version (none) + { + printf("got a variable %p %p\n", root, root.var); + printf(" %d %d %d\n", root.haveBase, root.unmodellable, + root.haveInfiniteLifetime); + } + + if (root.haveBase || root.unmodellable || root.haveInfiniteLifetime) + return; + + DFAConsequence* c = lr.findConsequence(root); + if (c is null) + return; + + version (none) + { + printf(" %d\n", c.writeOnVarAtThisPoint); + } + + if (root.var !is null && c.writeOnVarAtThisPoint == 0) + reporter.onReadOfUninitialized(root, lr, loc, forMathOp); + else if (c.obj !is null) + c.obj.walkRoots(&seeRootObject); + }); + + cctx.copyFrom(toStore.getContext); + } + } + private: DFAScopeRef meetScope(DFAScopeRef scr1, DFAScopeRef scr2, bool copyAll, @@ -2103,8 +2392,6 @@ private: return ret; } - // Converge, see Lattice (Abstract algebra) meet operation (lower bound) - // Operates on a given lattice to converge into current scope's variable state /*********************************************************** * The Lattice 'Meet' operation (Intersection / Lower Bound). * @@ -2173,8 +2460,6 @@ private: return ret; } - // Converge, see Lattice (Abstract algebra) meet operation (upper bound) - // Operates on a given lattice to converge into current scope's variable state /*********************************************************** * The Lattice 'Join' operation (Union / Upper Bound). * @@ -2302,7 +2587,7 @@ private: return ret; } - void checkVRPVar(DFAVar* var, ref bool couldBeUnknown) + void checkPAVar(DFAVar* var, ref bool couldBeUnknown) { if (var is null) return; @@ -2314,19 +2599,21 @@ private: void seeWrite(ref DFAVar* assignTo, ref DFALatticeRef from) { assert(assignTo !is null); - assignTo.writeCount++; - const currentDepth = dfaCommon.currentDFAScope.depth; - dfaCommon.acquireScopeVar(assignTo); - DFAConsequence* c = from.findConsequence(assignTo); - if (c !is null) - c.writeOnVarAtThisPoint = assignTo.writeCount; + assignTo.walkRoots((root) { + root.writeCount++; - if (DFAScopeVar* scv = dfaCommon.lastLoopyLabel.findScopeVar(assignTo)) - { - if (scv.assignDepth == 0 || scv.assignDepth > currentDepth) - scv.assignDepth = currentDepth; - } + dfaCommon.acquireScopeVar(root); + + if (DFAScopeVar* scv = dfaCommon.lastLoopyLabel.findScopeVar(root)) + { + if (scv.assignDepth == 0 || scv.assignDepth > currentDepth) + scv.assignDepth = currentDepth; + } + + DFAConsequence* c = from.addConsequence(root); + c.writeOnVarAtThisPoint = root.writeCount; + }); } } diff --git a/dmd/dfa/fast/expression.d b/dmd/dfa/fast/expression.d index 188e83a232..9ebf88c6e1 100644 --- a/dmd/dfa/fast/expression.d +++ b/dmd/dfa/fast/expression.d @@ -34,6 +34,8 @@ import dmd.mtype; import dmd.dtemplate; import dmd.arraytypes; import dmd.rootobject; +import dmd.id; +import dmd.dsymbol; import core.stdc.stdio; /*********************************************************** @@ -91,23 +93,24 @@ struct ExpressionWalker * assignTo = The variable being written to. * construct = True if this is an initialization (e.g., `int x = 5;`), false if reassignment. * lr = The lattice state of the value being assigned. + * loc = Source file location of the assignment. * isBlit = True if the assignment is a bitwise copy (blit). * alteredState = An integer representing a specific state alteration or flag. */ DFALatticeRef seeAssign(DFAVar* assignTo, bool construct, DFALatticeRef lr, - bool isBlit = false, int alteredState = 0) + ref Loc loc, bool isBlit = false, int alteredState = 0) { DFALatticeRef assignTo2 = dfaCommon.makeLatticeRef; assignTo2.setContext(assignTo); dfaCommon.check; - DFALatticeRef ret = seeAssign(assignTo2, construct, lr, isBlit); + DFALatticeRef ret = seeAssign(assignTo2, construct, lr, loc, isBlit); dfaCommon.check; return ret; } - DFALatticeRef seeAssign(DFALatticeRef assignTo, bool construct, DFALatticeRef lr, + DFALatticeRef seeAssign(DFALatticeRef assignTo, bool construct, DFALatticeRef lr, ref Loc loc, bool isBlit = false, int alteredState = 0, DFALatticeRef indexLR = DFALatticeRef.init) { dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) => ob.printf( @@ -122,7 +125,7 @@ struct ExpressionWalker assert(analyzer !is null); dfaCommon.check; DFALatticeRef ret = analyzer.transferAssign(assignTo, construct, - isBlit, lr, alteredState, indexLR); + isBlit, lr, alteredState, loc, indexLR); dfaCommon.check; ret.check; @@ -135,7 +138,7 @@ struct ExpressionWalker } /*********************************************************** - * Handles equality checks (e.g., `x == y` or `x is y`). + * Handles equality checks (e.g., `x == y`). * * This is critical for control flow. If the DFA sees `if (x == null)`, * this function records that relationship so the `StatementWalker` can @@ -156,7 +159,36 @@ struct ExpressionWalker rhs.printState("rhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); dfaCommon.check; - DFALatticeRef ret = analyzer.transferEqual(lhs, rhs, truthiness, equalityType); + DFALatticeRef ret = analyzer.transferEqual(lhs, rhs, truthiness, equalityType, false); + dfaCommon.check; + + ret.printState("result", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + return ret; + } + + /*********************************************************** + * Handles equality checks (e.g., `x is y`). + * + * This is critical for control flow. If the DFA sees `if (x == null)`, + * this function records that relationship so the `StatementWalker` can + * create a scope where `x` is known to be null. + */ + DFALatticeRef seeEqualIdentity(DFALatticeRef lhs, DFALatticeRef rhs, + bool truthiness, Type lhsType, Type rhsType) + { + const equalityType = equalityArgTypes(lhsType, rhsType); + + dfaCommon.printState((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("Equal identity iff=%d, ty=%d:%d, ety=%d", truthiness, + lhsType.ty, rhsType !is null ? rhsType.ty : -1, equalityType); + ob.writestring("\n"); + }); + + lhs.printState("lhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + rhs.printState("rhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + + dfaCommon.check; + DFALatticeRef ret = analyzer.transferEqual(lhs, rhs, truthiness, equalityType, true); dfaCommon.check; ret.printState("result", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); @@ -319,23 +351,27 @@ struct ExpressionWalker return ret; } - DFALatticeRef entry(DFAVar* assignTo, DFAVar* constructInto, Expression exp) + void seeRead(ref DFALatticeRef lr, ref Loc loc) { - DFALatticeRef lattice = walk(exp); - lattice.check; + dfaCommon.printStateln("Seeing read of lr"); + lr.printState("read lr", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); - if (assignTo !is null) - return seeAssign(assignTo, false, lattice); - else if (constructInto !is null) - return seeAssign(constructInto, true, lattice); - else - return lattice; + analyzer.onRead(lr, loc); + } + + void seeReadMathOp(ref DFALatticeRef lr, ref Loc loc) + { + dfaCommon.printStateln("Seeing read of math op lr"); + lr.printState("read lr", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + + analyzer.onRead(lr, loc, false, false, true); } DFALatticeRef adaptConditionForBranch(Expression expr, bool truthiness) { if (expr is null) return DFALatticeRef.init; + return this.adaptConditionForBranch(this.walk(expr), expr.type, truthiness); } @@ -356,9 +392,9 @@ struct ExpressionWalker DFALatticeRef against = dfaCommon.makeLatticeRef; if (truthiness) - against.acquireConstantAsContext(Truthiness.True, Nullable.NonNull); + against.acquireConstantAsContext(Truthiness.True, Nullable.NonNull, null); else - against.acquireConstantAsContext(Truthiness.False, Nullable.Null); + against.acquireConstantAsContext(Truthiness.False, Nullable.Null, null); ret = this.seeEqual(ret, against, truthiness, type, null); } @@ -391,7 +427,7 @@ struct ExpressionWalker */ DFALatticeRef walk(Expression expr) { - if (expr is null || dfaCommon.currentDFAScope.haveJumped) + if (expr is null) return DFALatticeRef.init; dfaCommon.edepth++; @@ -487,6 +523,17 @@ struct ExpressionWalker DFAConsequence* c = ret.addConsequence(varOffset); ret.setContext(c); + + c.obj = dfaCommon.makeObject(varBase); + + if (varBase.declaredAtDepth > 0) + { + c.truthiness = Truthiness.True; + c.nullable = Nullable.NonNull; + } + + if (soe.offset != 0) + c.obj.mayNotBeExactPointer = true; } else if (auto fd = soe.var.isFuncDeclaration) { @@ -495,7 +542,8 @@ struct ExpressionWalker // even if it probably doesn't make sense to be doing it. ret = dfaCommon.makeLatticeRef; - ret.acquireConstantAsContext(Truthiness.True, Nullable.NonNull); + ret.acquireConstantAsContext(Truthiness.True, Nullable.NonNull, + dfaCommon.makeObject); } else { @@ -520,63 +568,122 @@ struct ExpressionWalker if (ctx !is null) { DFAVar* varOffset = dfaCommon.findOffsetVar(0, ctx); - ret.setContext(varOffset); + DFAConsequence* cctx = ret.setContext(varOffset); + + cctx.obj = dfaCommon.makeObject(ctx); + + if (ctx.declaredAtDepth > 0) + { + cctx.truthiness = Truthiness.True; + cctx.nullable = Nullable.NonNull; + } } } return ret; case EXP.declaration: - auto decl = expr.isDeclarationExp.declaration; - - if (auto var = decl.isVarDeclaration) { - DFAVar* dfaVar = dfaCommon.findVariable(var); - dfaVar.declaredAtDepth = dfaCommon.currentDFAScope.depth; - dfaCommon.acquireScopeVar(dfaVar); + auto symbol = expr.isDeclarationExp.declaration; - if (var._init is null) - { - // we can ignore this case, its likely from meta-programming - return DFALatticeRef.init; - } - else + void eachDeclarationSymbol(Dsymbol symbol) { - final switch (var._init.kind) + if (auto var = symbol.isVarDeclaration) { - case InitKind.exp: - auto ei = var._init.isExpInitializer; + if (var.ident !is null) + { + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.printf("Declaring variable: %s\n", var.ident.toChars); + }); + } - // does this var escape another? Can't model that. - if ((var.storage_class & STC.ref_) == STC.ref_) - markUnmodellable(ei.exp); + DFAVar* dfaVar = dfaCommon.findVariable(var); + dfaVar.declaredAtDepth = dfaCommon.currentDFAScope.depth; + DFAScopeVar* scv = dfaCommon.acquireScopeVar(dfaVar); + DFAConsequence* cctx = scv.lr.getContext; - DFALatticeRef lr = this.walk(ei.exp); + // ImportC supports syntax as: Type var = var; + // Bit of a problem that... + // Due to the construct expression on rhs, is going to see var as being uninitialized. + // What we'll do instead, is init ALL VARIABLES, and based upon the init expression, uninitialize it. - if (ei.exp.isConstructExp || ei.exp.isBlitExp) - return lr; - else - return seeAssign(dfaVar, true, lr); + { + dfaVar.writeCount = 1; + cctx.writeOnVarAtThisPoint = 1; + } - case InitKind.array: - auto ai = var._init.isArrayInitializer; - DFALatticeRef lr = dfaCommon.makeLatticeRef; - DFAConsequence* c = lr.addConsequence(dfaVar); - lr.setContext(c); + if (var._init !is null) + { + final switch (var._init.kind) + { + case InitKind.exp: + auto ei = var._init.isExpInitializer; - return seeAssign(dfaVar, true, lr, false, ai.value.length > 0 ? 3 : 2); + if (ei.loc == var.loc && (var.storage_class & STC.foreach_) == 0) + { + // This is default initialization + + if (dfaVar.isFloatingPoint) + { + // Floating point initializes to NaN which is NOT a good default. + // Allow explicit, but not default initialization. + dfaVar.wasDefaultInitialized = true; + goto case InitKind.void_; + } + } - case InitKind.void_: - case InitKind.error: - case InitKind.struct_: - case InitKind.C_: - case InitKind.default_: - return DFALatticeRef.init; + // does this var escape another? Can't model that. + if ((var.storage_class & STC.ref_) == STC.ref_) + markUnmodellable(ei.exp); + + DFALatticeRef lr = this.walk(ei.exp); + + if (!(ei.exp.isConstructExp || ei.exp.isBlitExp)) + seeAssign(dfaVar, true, lr, ei.exp.loc); + break; + + case InitKind.array: + auto ai = var._init.isArrayInitializer; + DFALatticeRef lr = dfaCommon.makeLatticeRef; + DFAConsequence* c = lr.addConsequence(dfaVar); + lr.setContext(c); + + seeAssign(dfaVar, true, lr, ai.loc, false, + ai.value.length > 0 ? 3 : 2); + break; + + case InitKind.void_: + dfaVar.writeCount = 0; + cctx.writeOnVarAtThisPoint = 0; + break; + + case InitKind.error: + case InitKind.struct_: + case InitKind.C_: + case InitKind.default_: + break; + } + } } } - } - else + + if (auto ad = symbol.isAttribDeclaration) + { + // ImportC wraps their declarations + + if (ad.decl !is null) + { + foreach (symbol2; *ad.decl) + { + eachDeclarationSymbol(symbol2); + } + } + } + else + eachDeclarationSymbol(symbol); + return DFALatticeRef.init; + } case EXP.construct: auto ce = expr.isConstructExp; @@ -586,7 +693,8 @@ struct ExpressionWalker dfaCommon.printStateln("construct rhs"); DFALatticeRef rhs = this.walk(ce.e2); - return seeAssign(lhs, true, rhs); + + return seeAssign(lhs, true, rhs, ce.loc); case EXP.negate: // -x auto ue = expr.isUnaExp; @@ -611,7 +719,17 @@ struct ExpressionWalker auto be = expr.isBlitExp; dfaCommon.printStateln("blit lhs"); - DFALatticeRef lhs = this.walk(be.e1), rhs; + DFALatticeRef lhs, rhs; + + if (auto se = be.e1.isSliceExp) + { + // if we're bliting to a static array, let's ignore the empty slice. + assert(se.upr is null); + assert(se.lwr is null); + lhs = this.walk(se.e1); + } + else + lhs = this.walk(be.e1); if (auto e2ve = be.e2.isVarExp) { @@ -620,7 +738,8 @@ struct ExpressionWalker // this evaluates out to a type rhs = dfaCommon.makeLatticeRef; - rhs.acquireConstantAsContext(Truthiness.True, Nullable.NonNull); + rhs.acquireConstantAsContext(Truthiness.True, + Nullable.NonNull, dfaCommon.makeObject); goto BlitAssignRet; } @@ -630,7 +749,7 @@ struct ExpressionWalker rhs = this.walk(be.e2); BlitAssignRet: - DFALatticeRef ret = seeAssign(lhs, true, rhs, true); + DFALatticeRef ret = seeAssign(lhs, true, rhs, be.loc, true); return ret; case EXP.assign: @@ -664,8 +783,8 @@ struct ExpressionWalker dfaCommon.printStateln("assign rhs"); DFALatticeRef rhs = this.walk(ae.e2); - DFALatticeRef ret = seeAssign(lhs, false, rhs, false, lhsIndex !is null ? 3 : 0, - indexLR); + DFALatticeRef ret = seeAssign(lhs, false, rhs, ae.loc, false, + lhsIndex !is null ? 3 : 0, indexLR); if (ret.isNull) { @@ -694,6 +813,8 @@ struct ExpressionWalker DFAVar* lhsCtx; DFAConsequence* lhsCctx = lhs.getContext(lhsCtx); + DFAObject* lhsObject; + Type lhsType = ie.e1.type; bool resultHasEffect; @@ -716,6 +837,12 @@ struct ExpressionWalker lhsCctx.truthiness = Truthiness.True; lhsCctx.nullable = Nullable.NonNull; } + + if (lhsCctx.obj !is null) + { + lhsObject = lhsCctx.obj; + lhsObject.mayNotBeExactPointer = true; + } } if (lhsCtx !is null && lhsCtx.isNullable) @@ -748,14 +875,20 @@ struct ExpressionWalker dfaCommon.printStateln("Slice base"); DFALatticeRef base = this.walk(se.e1); - DFAVar* baseCtx = base.getContextVar; + DFAVar* baseCtx; + DFAConsequence* baseCctx = base.getContext(baseCtx); if (se.lwr is null && se.upr is null) { // Equivalent to doing slice[] - DFAVar* indexVar = dfaCommon.findIndexVar(baseCtx); - DFAConsequence* newCctx = base.addConsequence(indexVar); + DFAVar* asSliceVar = dfaCommon.findAsSliceVar(baseCtx); + DFAConsequence* newCctx = base.addConsequence(asSliceVar); base.setContext(newCctx); + + if (baseCctx !is null && baseCctx.obj !is null) + newCctx.obj = baseCctx.obj; + else + newCctx.obj = dfaCommon.makeObject(baseCtx); return base; } @@ -828,7 +961,7 @@ struct ExpressionWalker case EXP.halt: DFALatticeRef lr = dfaCommon.makeLatticeRef; - lr.acquireConstantAsContext(Truthiness.False, Nullable.Unknown); + lr.acquireConstantAsContext(Truthiness.False, Nullable.Unknown, null); seeAssert(lr, expr.loc); // Evaluates to void @@ -846,11 +979,13 @@ struct ExpressionWalker if (ret.isNull) ret = dfaCommon.makeLatticeRef; - DFAConsequence* c = ret.addConsequence(dfaCommon.getInfiniteLifetimeVariable); + DFAVar* var = dfaCommon.getInfiniteLifetimeVariable; + DFAConsequence* c = ret.addConsequence(var); ret.setContext(c); c.truthiness = Truthiness.True; c.nullable = Nullable.NonNull; + c.obj = dfaCommon.makeObject; return ret; case EXP.andAnd: @@ -860,10 +995,27 @@ struct ExpressionWalker dfaCommon.currentDFAScope.sideEffectFree = true; DFALatticeRef inProgress; + // if lhs is false, so will the andAnd + // assume rhs could be andAnd while (be !is null) { DFALatticeRef lhs = this.walk(be.e1); + seeRead(lhs, be.e1.loc); + + { + lhs = this.adaptConditionForBranch(lhs, be.e1.type, true); + DFAConsequence* c = lhs.getContext; + + if (c !is null && c.truthiness == Truthiness.False) + { + inProgress = dfaCommon.makeLatticeRef; + inProgress.acquireConstantAsContext(Truthiness.False, + Nullable.Unknown, null); + break; + } + } + this.seeSilentAssert(lhs.copy); if (inProgress.isNull) @@ -879,6 +1031,22 @@ struct ExpressionWalker else { DFALatticeRef rhs = this.walk(be.e2); + seeRead(rhs, be.e2.loc); + rhs = this.adaptConditionForBranch(rhs, be.e2.type, true); + + { + rhs = this.adaptConditionForBranch(rhs, be.e1.type, true); + DFAConsequence* c = rhs.getContext; + + if (c !is null && c.truthiness == Truthiness.False) + { + inProgress = dfaCommon.makeLatticeRef; + inProgress.acquireConstantAsContext(Truthiness.False, + Nullable.Unknown, null); + break; + } + } + inProgress = seeLogicalAnd(inProgress, rhs); break; } @@ -1017,7 +1185,7 @@ struct ExpressionWalker lhs.addConsequence(lhsLengthVar, lhsCctx); } - return this.seeAssign(lhs, false, rhs, false, alteredState); + return this.seeAssign(lhs, false, rhs, be.loc, false, alteredState); } else { @@ -1561,7 +1729,7 @@ struct ExpressionWalker dfaCommon.printStateln("!is rhs"); DFALatticeRef rhs = seeExp(be.e2, negated2, 0); - return seeEqual(lhs, rhs, applyByTest == 2, be.e1.type, be.e2.type); + return seeEqualIdentity(lhs, rhs, applyByTest == 2, be.e1.type, be.e2.type); } case EXP.equal: // == @@ -1587,7 +1755,7 @@ struct ExpressionWalker dfaCommon.printStateln("is rhs"); DFALatticeRef rhs = seeExp(be.e2, negated2, 0); - return seeEqual(lhs, rhs, applyByTest != 1, be.e1.type, be.e2.type); + return seeEqualIdentity(lhs, rhs, applyByTest != 1, be.e1.type, be.e2.type); } case EXP.string_: @@ -1596,8 +1764,14 @@ struct ExpressionWalker // A string literal even when empty will be non-null and true. DFALatticeRef ret = dfaCommon.makeLatticeRef; - DFAConsequence* cctx = ret.acquireConstantAsContext(se.len > 0 - ? Truthiness.True : Truthiness.Maybe, Nullable.NonNull); + + DFAVar* var = dfaCommon.getInfiniteLifetimeVariable; + DFAConsequence* cctx = ret.addConsequence(var); + ret.setContext(cctx); + + cctx.truthiness = se.len > 0 ? Truthiness.True : Truthiness.Maybe; + cctx.nullable = Nullable.NonNull; + cctx.obj = dfaCommon.makeObject; cctx.pa = DFAPAValue(se.len); return ret; } @@ -1633,7 +1807,13 @@ struct ExpressionWalker if (ret.isNull) ret = dfaCommon.makeLatticeRef; - ret.acquireConstantAsContext(Truthiness.True, Nullable.NonNull); + DFAVar* var = dfaCommon.getInfiniteLifetimeVariable; + DFAConsequence* cctx = ret.addConsequence(var); + ret.setContext(cctx); + + cctx.truthiness = Truthiness.True; + cctx.nullable = Nullable.NonNull; + cctx.obj = dfaCommon.makeObject; return ret; } @@ -1651,15 +1831,17 @@ struct ExpressionWalker negated, 0), null, 0, null, ele.loc); } - DFAConsequence* cctx = ret.addConsequence( - dfaCommon.getInfiniteLifetimeVariable); + DFAVar* var = dfaCommon.getInfiniteLifetimeVariable; + DFAConsequence* cctx = ret.addConsequence(var); ret.setContext(cctx); + cctx.truthiness = Truthiness.True; cctx.nullable = Nullable.NonNull; cctx.pa = DFAPAValue(ale.elements.length); + cctx.obj = dfaCommon.makeObject; } else - ret.acquireConstantAsContext(Truthiness.Maybe, Nullable.Null); + ret.acquireConstantAsContext(Truthiness.Maybe, Nullable.Null, null); return ret; } @@ -1671,14 +1853,16 @@ struct ExpressionWalker if (aale.keys !is null && aale.keys.length > 0) { - DFAConsequence* cctx = ret.addConsequence( - dfaCommon.getInfiniteLifetimeVariable); + DFAVar* var = dfaCommon.getInfiniteLifetimeVariable; + DFAConsequence* cctx = ret.addConsequence(var); ret.setContext(cctx); + cctx.truthiness = Truthiness.True; cctx.nullable = Nullable.NonNull; + cctx.obj = dfaCommon.makeObject; } else - ret.acquireConstantAsContext(Truthiness.False, Nullable.Null); + ret.acquireConstantAsContext(Truthiness.False, Nullable.Null, null); return ret; } @@ -1814,31 +1998,57 @@ struct ExpressionWalker DFALatticeRef ret = seeExp(ce.e1, negated, 0); ret.check; - if (ce.to is null || ce.to.isTypeClass) + if (ce.to is null || ce.to.isTypeClass || ce.to is Type.tvoid) { - // ideally we'd model up casts, and only disallow down casts + // For classes: ideally we'd model up casts, and only disallow down casts + // For void: no side effects wrt. convergance + ret = dfaCommon.makeLatticeRef; - ret.acquireConstantAsContext(Truthiness.Unknown, Nullable.Unknown); + ret.acquireConstantAsContext(Truthiness.Unknown, Nullable.Unknown, null); } else { if (ret.isNull) ret = dfaCommon.makeLatticeRef; - DFAConsequence* cctx = ret.getContext; + bool paHandled; + + DFAVar* baseVar; + DFAConsequence* cctx = ret.getContext(baseVar); if (cctx is null) cctx = ret.acquireConstantAsContext; - if (cctx.var !is null && cctx.var.isNullable && !isTypeNullable(ce.to)) + if (baseVar !is null) { - // This prevents pointer integer checks from infecting pointers + if (baseVar.isNullable && !isTypeNullable(ce.to)) + { + // This prevents pointer integer checks from infecting pointers + + cctx = ret.acquireConstantAsContext(cctx.truthiness, + cctx.nullable, null); + } + else if (baseVar.isStaticArray && ce.to.isTypeDArray) + { + DFAVar* asSliceVar = dfaCommon.findAsSliceVar(baseVar); + + Truthiness truthiness = cctx.truthiness; + DFAPAValue oldPA = cctx.pa; + DFAObject* newObj = cctx.obj !is null ? cctx.obj + : dfaCommon.makeObject(baseVar); + + cctx = ret.addConsequence(asSliceVar); + ret.setContext(cctx); - cctx = ret.acquireConstantAsContext(cctx.truthiness, cctx.nullable); + cctx.nullable = Nullable.NonNull; + cctx.truthiness = truthiness; + cctx.pa = oldPA; + cctx.obj = newObj; + } } // If we're doing any kind of cast to anything that is not an integer, // we have no idea if VRP is going to still be accurate. - if (!cctx.pa.canFitIn(ce.to)) + if (!paHandled && !cctx.pa.canFitIn(ce.to)) cctx.pa = DFAPAValue.Unknown; } @@ -1856,6 +2066,22 @@ struct ExpressionWalker { if (auto vd = ve.var.isVarDeclaration) { + if (vd.ident is Id.withSym) + { + // Copied from function semantic analysis checkNestedReference function. + // With statements sometimes have temporaries that do get written out, + // pretend we're the initializer instead. + + auto ez = vd._init.isExpInitializer(); + assert(ez); + + Expression e = ez.exp; + if (e.op == EXP.construct || e.op == EXP.blit) + e = (cast(AssignExp) e).e2; + + return this.walk(e); + } + DFAVar* var = dfaCommon.findVariable(vd); if (var !is null) @@ -2028,6 +2254,7 @@ struct ExpressionWalker toNegate = this.adaptConditionForBranch(lhs.copy, oe.e1.type, false); } + seeRead(lhs, oe.e1.loc); lhs.printState("or lhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); @@ -2066,6 +2293,7 @@ struct ExpressionWalker DFALatticeRef rhs = this.walk(oe.e2); rhs.printState("or rhs", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + seeRead(rhs, oe.e2.loc); stmtWalker.endScope; @@ -2086,10 +2314,12 @@ struct ExpressionWalker { dfaCommon.printStateln("math op lhs"); DFALatticeRef lhs = this.walk(be.e1); + seeReadMathOp(lhs, be.e1.loc); lhs.check; dfaCommon.printStateln("math op rhs"); DFALatticeRef rhs = this.walk(be.e2); + seeReadMathOp(rhs, be.e2.loc); rhs.check; DFALatticeRef ret = this.seeMathOp(lhs, rhs, be.type, op); @@ -2101,16 +2331,16 @@ struct ExpressionWalker { dfaCommon.printStateln("math assign1 op lhs"); DFALatticeRef lhs = this.walk(be.e1); + assert(!lhs.isNull); lhs.check; DFAConsequence* lhsCctx = lhs.getContext; - - assert(!lhs.isNull); assert(lhsCctx !is null); dfaCommon.printStateln("math assign1 op rhs"); DFALatticeRef rhs = this.walk(be.e2); rhs.check; + seeReadMathOp(rhs, be.e2.loc); DFAPAValue oldPA; bool useOldPA; @@ -2118,22 +2348,39 @@ struct ExpressionWalker if (op == PAMathOp.postInc) { op = PAMathOp.add; + useOldPA = true; oldPA = lhsCctx.pa; } else if (op == PAMathOp.postDec) { op = PAMathOp.sub; + useOldPA = true; oldPA = lhsCctx.pa; } + DFAObject* lhsObject = lhsCctx.obj; DFALatticeRef ret = this.seeMathOp(lhs.copy, rhs, be.type, op); ret.check; - ret = this.seeAssign(lhs, false, ret); - DFAConsequence* cctx = ret.acquireConstantAsContext; + ret = this.seeAssign(lhs, false, ret, be.loc); + ret.check; - if (useOldPA) - cctx.pa = oldPA; + { + DFAConsequence* cctx; + + if (useOldPA) + { + cctx = ret.acquireConstantAsContext; + cctx.pa = oldPA; + } + else + cctx = ret.getContext; + + cctx.obj = lhsObject; + + if (lhsObject !is null) + lhsObject.mayNotBeExactPointer = true; + } return ret; } @@ -2142,12 +2389,28 @@ struct ExpressionWalker { dfaCommon.printStateln("math assign2 op lhs"); DFALatticeRef lhs = this.walk(ue.e1); + assert(!lhs.isNull); lhs.check; + DFAConsequence* lhsCctx = lhs.getContext; + assert(lhsCctx !is null); + DFAObject* lhsObject = lhsCctx.obj; + DFALatticeRef ret = this.seeMathOp(lhs.copy, rhs, ue.type, op); ret.check; + seeReadMathOp(rhs, ue.loc); + + ret = this.seeAssign(lhs, false, ret, ue.loc); + ret.check; - return this.seeAssign(lhs, false, ret); + DFAConsequence* cctx = ret.getContext; + cctx.obj = lhsObject; + + if (lhsObject !is null) + lhsObject.mayNotBeExactPointer = true; + + ret.printStructure("math assign2 ret"); + return ret; } DFALatticeRef callFunction(FuncDeclaration toCallFunction, Expression thisPointer, @@ -2229,7 +2492,9 @@ struct ExpressionWalker { dfaCommon.printStateln("This:"); DFALatticeRef thisExp = this.walk(thisPointer); - thisExp = this.seeDereference(thisPointer.loc, thisExp); + + if (isTypeNullable(thisPointer.type)) + thisExp = this.seeDereference(thisPointer.loc, thisExp); this.seeConvergeFunctionCallArgument(thisExp, thisPointerInfo, 0, toCallFunction, thisPointer.loc); @@ -2316,7 +2581,8 @@ struct ExpressionWalker DFALatticeRef ret = dfaCommon.makeLatticeRef; if (returnInfo !is null && returnInfo.notNullOut == Fact.Guaranteed) - ret.acquireConstantAsContext(Truthiness.True, Nullable.NonNull); + ret.acquireConstantAsContext(Truthiness.True, + Nullable.NonNull, dfaCommon.makeObject); else ret.acquireConstantAsContext; @@ -2392,8 +2658,8 @@ struct ExpressionWalker if (assign) { rhsCctx.pa = pa; - ret = this.seeAssign(lhs, false, rhs, false, nullableResult == 1 - || nullableResult == 2 ? 3 : 0); + ret = this.seeAssign(lhs, false, rhs, be.loc, false, + nullableResult == 1 || nullableResult == 2 ? 3 : 0); } else { diff --git a/dmd/dfa/fast/report.d b/dmd/dfa/fast/report.d index be0cc4cd40..5257b1ed33 100644 --- a/dmd/dfa/fast/report.d +++ b/dmd/dfa/fast/report.d @@ -20,6 +20,7 @@ import dmd.location; import dmd.func; import dmd.errorsink; import dmd.declaration; +import dmd.astenums; import core.stdc.stdio; alias Fact = ParameterDFAInfo.Fact; @@ -167,7 +168,7 @@ struct DFAReporter if (scv.var.isByRef) { - if (scv.var.writeCount > 0) + if (scv.var.writeCount > 1) { if (param.notNullOut == Fact.Unspecified) param.notNullOut = Fact.NotGuaranteed; @@ -228,6 +229,59 @@ struct DFAReporter else errorSink.errorSupplemental(calling.loc, "For parameter `this` in called function"); } + + void onReadOfUninitialized(DFAVar* var, ref DFALatticeRef lr, ref Loc loc, bool forMathOp) + { + if (!var.isModellable || var.declaredAtDepth == 0 || (!forMathOp + && var.isFloatingPoint) || var.var is null) + return; + else if ((var.var.storage_class & STC.temp) != 0) + return; // Compiler generated, likely to be "fine" + else if (var.declaredAtDepth < dfaCommon.lastLoopyLabel.depth) + return; // Can we really know what state the variable is in? I don't think so. + + // The reason floating point is special cased here, is to allow catching of mathematical operations, + // on a floating point typed variable, that was default initialized. + // The NaN will propagate on that operation, which is basically never wanted. + // It is essentially a special case of uninitialized variables, + // where the default could never be what someone wants, even if it was zero. + const floatingPointDefaultInit = var.isFloatingPoint && var.wasDefaultInitialized; + + if (floatingPointDefaultInit) + { + errorSink.error(loc, + "Expression reads a default initialized variable that is a floating point type"); + errorSink.errorSupplemental(loc, + "It will have the value of Not Any Number(nan), it will be propagated with mathematical operations"); + + errorSink.errorSupplemental(var.var.loc, "For variable `%s`", var.var.ident.toChars); + errorSink.errorSupplemental(var.var.loc, + "Initialize to %s.nan or 0 explicitly to disable this error", var.var.type.kind); + } + else + { + errorSink.error(loc, + "Expression reads from an uninitialized variable, it must be written to at least once before reading"); + errorSink.errorSupplemental(var.var.loc, "For variable `%s`", var.var.ident.toChars); + } + + version (none) + { + lr.printActual("uninit report"); + + dfaCommon.allocator.allVariables((DFAVar* var) { + printf("var %p base1=%p, base2=%p, writeCount=%d, isStaticArray=%d", + var, var.base1, var.base2, var.writeCount, var.isStaticArray); + + if (var.var !is null) + { + printf(", `%s` at %s", var.var.ident.toChars, var.var.loc.toChars); + } + + printf("\n"); + }); + } + } } private: diff --git a/dmd/dfa/fast/statement.d b/dmd/dfa/fast/statement.d index 6163b5c681..9d0065a7ef 100644 --- a/dmd/dfa/fast/statement.d +++ b/dmd/dfa/fast/statement.d @@ -348,6 +348,14 @@ final: dfaCommon.check; } + void seeRead(ref DFALatticeRef lr, ref Loc loc) + { + dfaCommon.printStructureln("Seeing read of lr"); + lr.printState("read lr", dfaCommon.sdepth, dfaCommon.currentFunction, dfaCommon.edepth); + + analyzer.onRead(lr, loc); + } + void constructVariable(VarDeclaration vd, bool isNonNull) { DFAVar* var = dfaCommon.findVariable(vd); @@ -358,7 +366,7 @@ final: c.nullable = isNonNull ? Nullable.NonNull : Nullable.Null; dfaCommon.check; - expWalker.seeConvergeExpression(expWalker.seeAssign(var, true, lr)); + expWalker.seeConvergeExpression(expWalker.seeAssign(var, true, lr, *cast(Loc*)&vd.loc)); dfaCommon.check; } @@ -390,6 +398,7 @@ final: { DFAVar* var = dfaCommon.findVariable(fd.vthis); var.declaredAtDepth = dfaCommon.currentDFAScope.depth; + var.writeCount = 1; var.param = &fd.parametersDFAInfo.thisPointer; var.param.parameterId = -1; scv = dfaCommon.acquireScopeVar(var); @@ -414,6 +423,7 @@ final: { DFAVar* var = dfaCommon.findVariable(param); var.declaredAtDepth = dfaCommon.currentDFAScope.depth; + var.writeCount = 1; var.param = &fd.parametersDFAInfo.parameters[i]; *var.param = ParameterDFAInfo.init; // Array won't initialize it var.param.parameterId = cast(int) i; @@ -441,11 +451,26 @@ final: dfaCommon.check; } } + + if (fd.v_argptr !is null) + { + // C vararg _argptr + DFAVar* var = dfaCommon.findVariable(fd.v_argptr); + var.unmodellable = true; + } + + if (fd.v_arguments !is null) + { + // D vararg _arguments + DFAVar* var = dfaCommon.findVariable(fd.v_arguments); + var.unmodellable = true; + } } { DFAVar* var = dfaCommon.getReturnVariable(); var.declaredAtDepth = dfaCommon.currentDFAScope.depth; + var.writeCount = 1; var.param = &fd.parametersDFAInfo.returnValue; var.param.parameterId = -2; @@ -501,6 +526,26 @@ final: dfaCommon.currentDFAScope.haveReturned = true; this.endScopeAndReport(fd.endloc, true); + dfaCommon.printIfStructure((ref OutBuffer ob, scope void delegate(const(char)*) prefix) { + dfaCommon.allocator.allVariables((DFAVar* var) { + prefix("var"); + ob.printf(" %p base1=%p, base2=%p", var, var.base1, var.base2); + + if (var.var !is null) + { + ob.printf(", `%s` at ", var.var.ident.toChars); + appendLoc(ob, var.var.loc); + } + + ob.printf("\n"); + }); + dfaCommon.allocator.allObjects((DFAObject* obj) { + prefix("object"); + ob.printf(" %p base1=%p, base2=%p, storageFor=%p, mayNotBeExactPointer=%d\n", obj, + obj.base1, obj.base2, obj.storageFor, obj.mayNotBeExactPointer); + }); + }); + if (fd.parametersDFAInfo !is null) { dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { @@ -521,11 +566,6 @@ final: } } - DFALatticeRef walkExpression(DFAVar* assignTo, DFAVar* constructInto, Expression exp) - { - return expWalker.entry(assignTo, constructInto, exp); - } - extern (C++) override void visit(Statement st) { __gshared immutable(string[]) AllStmtOpNames = [ @@ -568,7 +608,7 @@ final: */ version (none) { - if (st.loc.linnum == 180) + if (st.loc.linnum == 423) { DFAScope* sc = dfaCommon.currentDFAScope; while (sc !is null) @@ -585,19 +625,25 @@ final: final switch (st.stmt) { case STMT.DtorExp: - expWalker.seeConvergeExpression(walkExpression(null, - null, st.isDtorExpStatement.exp)); + expWalker.seeConvergeExpression(expWalker.walk(st.isDtorExpStatement.exp)); break; case STMT.Exp: - expWalker.seeConvergeExpression(walkExpression(null, - null, st.isExpStatement.exp)); + Expression exp = st.isExpStatement.exp; + + DFALatticeRef lr = expWalker.walk(exp); + seeRead(lr, exp.loc); + expWalker.seeConvergeExpression(lr); break; case STMT.Return: Expression exp = st.isReturnStatement.exp; + if (exp !is null) - expWalker.seeConvergeExpression(walkExpression(null, - dfaCommon.getReturnVariable, exp)); + { + DFALatticeRef lr = expWalker.seeAssign(dfaCommon.getReturnVariable, + true, expWalker.walk(exp), exp.loc); + expWalker.seeConvergeExpression(lr); + } // Mark the current scope as having returned. // This signals that no code after this point in the current block is reachable. @@ -654,12 +700,13 @@ final: // 3. We visit the `elsebody` (if it exists). // 4. We merge the resulting states from both branches. - bool ignoreTrueBranch, ignoreFalseBranch; + bool takeTrueBranch, takeFalseBranch; bool unknownBranchTaken; dfaCommon.printStructureln("If condition:"); int predicateNegation; DFALatticeRef conditionLR; + DFALatticeRef trueCondition, falseCondition; DFAVar* conditionVar; { @@ -669,36 +716,44 @@ final: conditionLR = expWalker.walkCondition(ifs.condition, predicateNegation); conditionVar = conditionLR.getGateConsequenceVariable; + seeRead(conditionLR, ifs.condition.loc); this.endScope; } { - dfaCommon.printStructureln("If true branch:"); - this.startScope; - dfaCommon.currentDFAScope.inConditional = true; + trueCondition = expWalker.adaptConditionForBranch(conditionLR.copy, + ifs.condition.type, true); + falseCondition = expWalker.adaptConditionForBranch(conditionLR.copy, + ifs.condition.type, false); + + this.isBranchTakenIf(trueCondition, falseCondition, ifs, + takeTrueBranch, takeFalseBranch); + + DFAConsequence* cctx = conditionLR.getContext; + if (cctx is null || cctx.truthiness <= Truthiness.Maybe) + unknownBranchTaken = true; - DFAConsequence* c = conditionLR.getContext; - if (c !is null) + version (none) { - if (c.truthiness == Truthiness.False) - ignoreTrueBranch = true; - else if (c.truthiness == Truthiness.True) - ignoreFalseBranch = true; - else - unknownBranchTaken = true; + printf("if %d %d %d\n", takeTrueBranch, takeFalseBranch, unknownBranchTaken); + conditionLR.printStructure("condition"); + trueCondition.printStructure("true condition"); + falseCondition.printStructure("false condition"); } - else - unknownBranchTaken = true; + } + + { + dfaCommon.printStructureln("If true branch:"); + this.startScope; + dfaCommon.currentDFAScope.inConditional = true; - DFALatticeRef trueCondition = expWalker.adaptConditionForBranch(conditionLR.copy, - ifs.condition.type, true); expWalker.seeSilentAssert(trueCondition, true, true); this.applyGateOnBranch(conditionVar, predicateNegation, true); } DFAScopeRef ifbody, elsebody; - if (!ignoreTrueBranch) + if (takeTrueBranch) { if (auto scs = ifs.ifbody.isScopeStatement) this.visit(scs.statement); @@ -718,7 +773,6 @@ final: } assert(dfaCommon.currentDFAScope is origScope); - bool haveFalseBody; { dfaCommon.printStructureln("If false branch:"); @@ -726,19 +780,15 @@ final: this.startScope; dfaCommon.currentDFAScope.inConditional = true; - if (!ignoreTrueBranch) - { - DFALatticeRef falseCondition = expWalker.adaptConditionForBranch(conditionLR.copy, - ifs.condition.type, false); + // If the true branch can be taken, the false branch needs the condition inverted. + // But if it won't be taken, its clearly false already no need to invert. + if (takeTrueBranch) expWalker.seeSilentAssert(falseCondition, true, true); - } this.applyGateOnBranch(conditionVar, predicateNegation, false); - if (!ignoreFalseBranch && ifs.elsebody !is null) + if (takeFalseBranch) { - haveFalseBody = true; - if (auto scs = ifs.elsebody.isScopeStatement) this.visit(scs.statement); else @@ -750,7 +800,7 @@ final: } seeConvergeStatementIf(conditionLR, ifbody, elsebody, - haveFalseBody, unknownBranchTaken, predicateNegation); + takeFalseBranch, unknownBranchTaken, predicateNegation); break; case STMT.Scope: @@ -889,6 +939,21 @@ final: } } + DFALatticeRef lrCondition; + DFALatticeRef lrConditionTrue; + + if (theCondition !is null) + { + lrCondition = expWalker.walk(theCondition); + seeRead(lrCondition, theCondition.loc); + lrCondition.printStructure("lrCondition"); + + lrConditionTrue = expWalker.adaptConditionForBranch(lrCondition.copy, + theCondition.type, true); + lrConditionTrue.printStructure("lrConditionTrue"); + } + + if (theCondition is null || isBranchTaken(lrConditionTrue, theBody)) { this.startScope; dfaCommon.currentDFAScope.controlStatement = st; @@ -899,16 +964,14 @@ final: { dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) => ob.writestring("For condition:\n")); - DFALatticeRef lrCondition = expWalker.adaptConditionForBranch(theCondition, - true); - if (auto c = lrCondition.getContext) + if (auto c = lrConditionTrue.getContext) { dfaCommon.currentDFAScope.isLoopyLabelKnownToHaveRun = c.truthiness == Truthiness.True; } - expWalker.seeAssert(lrCondition, theCondition.loc, true); + expWalker.seeAssert(lrConditionTrue, theCondition.loc, true); } else dfaCommon.currentDFAScope.isLoopyLabelKnownToHaveRun = true; @@ -921,7 +984,8 @@ final: { dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) => ob.writestring("For increment:\n")); - DFALatticeRef lrIncrement = this.walkExpression(null, null, fs.increment); + DFALatticeRef lrIncrement = expWalker.walk(fs.increment); + seeRead(lrIncrement, fs.increment.loc); expWalker.seeConvergeExpression(lrIncrement); } @@ -933,15 +997,19 @@ final: scope PrintPrefixType prefix) => ob.writestring( "For (effect) condition:\n")); - DFALatticeRef lrCondition = expWalker.adaptConditionForBranch(theCondition, false); - expWalker.seeSilentAssert(lrCondition, true, true); - } + if (theCondition !is null) + { + DFALatticeRef lrConditionFalse = expWalker.adaptConditionForBranch(lrCondition, + theCondition.type, false); + expWalker.seeSilentAssert(lrConditionFalse, true, true); + } - dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { - ob.writestring("finished for loop at "); - appendLoc(ob, fs.endloc); - ob.writestring("\n"); - }); + dfaCommon.printStructure((ref OutBuffer ob, scope PrintPrefixType prefix) { + ob.writestring("finished for loop at "); + appendLoc(ob, fs.endloc); + ob.writestring("\n"); + }); + } break; @@ -960,10 +1028,10 @@ final: this.visit(ds._body); - DFALatticeRef lrCondition = this.walkExpression(null, null, ds.condition); + DFALatticeRef lrCondition = expWalker.walk(ds.condition); + seeRead(lrCondition, ds.condition.loc); expWalker.seeSilentAssert(lrCondition, false, true); - dfaCommon.currentDFAScope.haveJumped = true; DFAScopeRef scr = this.endScope(ds.endloc); this.seeConvergeStatementLoopyLabels(scr, *cast(Loc*)&ds.loc); break; @@ -1011,8 +1079,9 @@ final: dfaCommon.currentDFAScope.controlStatement = ss; dfaCommon.currentDFAScope.inConditional = true; - DFALatticeRef lrCondition = this.walkExpression(null, null, ss.condition); + DFALatticeRef lrCondition = expWalker.walk(ss.condition); lrCondition.check; + seeRead(lrCondition, ss.condition.loc); DFAScope* oldScope = dfaCommon.currentDFAScope; @@ -1054,7 +1123,7 @@ final: dfaCommon.currentDFAScope.controlStatement = cs; dfaCommon.setScopeAsLoopyLabel; - DFALatticeRef equalTo = this.walkExpression(null, null, cs.exp); + DFALatticeRef equalTo = expWalker.walk(cs.exp); lrCondition.check; DFALatticeRef lrCondition2 = lrCondition.copy; lrCondition2.check; @@ -1151,7 +1220,7 @@ final: if (auto forLoop = sc.controlStatement.isForStatement) { - DFALatticeRef lr = this.walkExpression(null, null, forLoop.increment); + DFALatticeRef lr = expWalker.walk(forLoop.increment); expWalker.seeConvergeExpression(lr); } @@ -1279,7 +1348,8 @@ final: this.startScope; - DFALatticeRef lr = this.walkExpression(null, null, ws.exp); + DFALatticeRef lr = expWalker.walk(ws.exp); + seeRead(lr, ws.exp.loc); expWalker.seeConvergeExpression(lr); if (auto ss = ws._body.isScopeStatement) @@ -1313,7 +1383,8 @@ final: case STMT.Throw: auto ts = st.isThrowStatement; - expWalker.seeConvergeExpression(this.walkExpression(null, null, ts.exp)); + DFALatticeRef lr = expWalker.walk(ts.exp); + expWalker.seeConvergeExpression(lr); dfaCommon.currentDFAScope.haveJumped = true; dfaCommon.currentDFAScope.haveReturned = true; @@ -1403,4 +1474,190 @@ final: foreachExpAndVar(s, &expWalker.markUnmodellable, &perVar); } + + /// Check if a if statement will be branched into by a goto or by the condition + void isBranchTakenIf(ref DFALatticeRef trueLR, ref DFALatticeRef falseLR, + IfStatement ifs, out bool forTrue, out bool forFalse) + { + DFAConsequence* cctx = trueLR.getContext; + + if (cctx !is null) + { + if (cctx.truthiness == Truthiness.True) + { + forTrue = ifs.ifbody !is null; + return; + } + else if (cctx.truthiness == Truthiness.False) + { + forFalse = ifs.elsebody !is null; + return; + } + } + + forTrue = isBranchTaken(trueLR, ifs.ifbody); + + { + cctx = falseLR.getContext; + + if (ifs.elsebody is null) + forFalse = false; + else if (cctx is null || cctx.truthiness != Truthiness.False) + forFalse = true; + else + forFalse = isBranchTaken(ifs.elsebody); + } + } + + /// Check if a statement will be branched into either by a goto or by the condition. + bool isBranchTaken(ref DFALatticeRef condition, Statement stmt) + { + DFAConsequence* cctx = condition.getContext; + + if (stmt is null) + return false; + else if (cctx is null || cctx.truthiness != Truthiness.False) + return true; + else + return isBranchTaken(stmt); + } + + /// Check if a statement will be branched into either by a goto. + bool isBranchTaken(Statement stmt) + { + if (stmt is null) + return false; + + bool walkExpression(Expression e) + { + if (auto de = e.isDeclarationExp) + { + return de.declaration.isVarDeclaration !is null + || de.declaration.isAttribDeclaration !is null; + } + else if (auto be = e.isBinExp) + return walkExpression(be.e1) || walkExpression(be.e2); + else if (auto ue = e.isUnaExp) + return walkExpression(ue.e1); + else + return false; + } + + int check(Statement stmt) + { + int ret = -1; + + void attempt(Statement stmt2) + { + if (ret != -1 || stmt2 is null) + return; + + ret = check(stmt2); + } + + switch (stmt.stmt) + { + case STMT.Exp: + auto es = stmt.isExpStatement; + if (es.exp !is null && walkExpression(es.exp)) + return 0; + return ret; + + case STMT.Compound: + auto cs = stmt.isCompoundStatement; + + if (cs.statements !is null) + { + foreach (s; *cs.statements) + { + attempt(s); + } + } + + return ret; + + case STMT.UnrolledLoop: + auto uls = stmt.isUnrolledLoopStatement; + + if (uls.statements !is null) + { + foreach (s; *uls.statements) + { + attempt(s); + } + } + + return ret; + + case STMT.Scope: + auto ss = stmt.isScopeStatement; + attempt(ss.statement); + return ret; + + case STMT.Do: + auto ds = stmt.isDoStatement; + attempt(ds._body); + return ret; + + case STMT.For: + auto fs = stmt.isForStatement; + attempt(fs._body); + return ret; + + case STMT.If: + auto ifs = stmt.isIfStatement; + attempt(ifs.ifbody); + attempt(ifs.elsebody); + return ret; + + case STMT.Switch: + auto ss = stmt.isSwitchStatement; + + if (ss.cases !is null) + { + foreach (c; *ss.cases) + { + attempt(c.statement); + + if (ret != -1) + return ret; + } + } + + return ret; + + case STMT.With: + auto ws = stmt.isWithStatement; + attempt(ws._body); + return ret; + + case STMT.TryCatch: + auto tcs = stmt.isTryCatchStatement; + attempt(tcs._body); + + if (ret == -1 && tcs.catches !is null && tcs.catches.length > 0) + ret = 0; // catch statements have a var declaration + return ret; + + case STMT.TryFinally: + auto tfs = stmt.isTryFinallyStatement; + attempt(tfs._body); + attempt(tfs.finalbody); + return ret; + + case STMT.Label: + auto ls = stmt.isLabelStatement; + return cast(int) dfaCommon.haveForwardLabelState(ls.ident); + + default: + return ret; + } + } + + int got = check(stmt); + if (got == -1) + return false; + else + return cast(bool) got; + } } diff --git a/dmd/dfa/fast/structure.d b/dmd/dfa/fast/structure.d index 64ace4924f..a5c9422642 100644 --- a/dmd/dfa/fast/structure.d +++ b/dmd/dfa/fast/structure.d @@ -22,6 +22,7 @@ import dmd.dsymbol; import dmd.location; import dmd.expression; import dmd.astenums; +import dmd.id; import core.stdc.stdio; package static immutable PrintPipeText = "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"; @@ -41,7 +42,6 @@ enum DFACleanup = __VERSION__ >= 2102; //version = DebugJoinMeetOp; - /*********************************************************** * The central context for a DFA run. * @@ -74,7 +74,9 @@ struct DFACommon private { DFAVar*[16] vars; - DFAVar*[16] varPairs; + DFAVar*[16] varPairs; // do not change, 16 is hardcoded in usage + DFAObject*[16] objects; + DFAObject*[16] objectPairs; DFAVar* returnVar; DFAVar* infiniteLifetimeVar; DFAVar* unknownVar; @@ -219,6 +221,8 @@ struct DFACommon if (vd is null) return null; + DFAVar* ret; + if (childOf is null) { DFAVar** bucket = &vars[(cast(size_t) cast(void*) vd) % vars.length]; @@ -231,13 +235,22 @@ struct DFACommon if (*bucket !is null && (*bucket).var is vd) return *bucket; - DFAVar* ret = allocator.makeVar(vd); + ret = allocator.makeVar(vd); ret.next = *bucket; *bucket = ret; - return ret; } else - return allocator.makeVar(vd, childOf); + ret = allocator.makeVar(vd, childOf); + + if (vd.ident is Id.dollar) + { + // __dollar creates problems because it isn't a real variable + // https://issues.dlang.org/show_bug.cgi?id=3326 + + ret.unmodellable = true; + } + + return ret; } DFAVar* findVariablePair(DFAVar* a, DFAVar* b) @@ -317,6 +330,21 @@ struct DFACommon return childOf.indexVar; } + DFAVar* findAsSliceVar(DFAVar* childOf) + { + if (childOf is null) + return null; + + if (childOf.asSliceVar is null) + { + childOf.asSliceVar = allocator.makeVar(null); + childOf.asSliceVar.base1 = childOf; + childOf.asSliceVar.haveInfiniteLifetime = childOf.haveInfiniteLifetime; + } + + return childOf.asSliceVar; + } + DFAVar* findSliceLengthVar(DFAVar* childOf) { if (childOf is null) @@ -376,7 +404,23 @@ struct DFACommon { if (auto de = e.isDeclarationExp) { - return de.declaration.isVarDeclaration !is null; + if (auto ad = de.declaration.isAttribDeclaration) + { + // ImportC wraps their declarations + + if (ad.decl !is null) + { + foreach (symbol; *ad.decl) + { + if (symbol.isVarDeclaration !is null) + return true; + } + } + + return false; + } + else + return de.declaration.isVarDeclaration !is null; } else if (auto be = e.isBinExp) return walkExpression(be.e1) || walkExpression(be.e2); @@ -570,6 +614,8 @@ struct DFACommon { this.infiniteLifetimeVar = allocator.makeVar(null); this.infiniteLifetimeVar.haveInfiniteLifetime = true; + this.infiniteLifetimeVar.isTruthy = true; + this.infiniteLifetimeVar.isNullable = true; } return this.infiniteLifetimeVar; @@ -577,7 +623,7 @@ struct DFACommon DFAVar* getUnknownVar() { - if (this.infiniteLifetimeVar is null) + if (this.unknownVar is null) { this.unknownVar = allocator.makeVar(null); this.unknownVar.unmodellable = true; @@ -598,6 +644,34 @@ struct DFACommon return current; } + DFAObject* makeObject(DFAVar* storageForVar) + { + if (storageForVar is null) + return null; + else if (storageForVar.storageFor !is null) + return storageForVar.storageFor; + + DFAObject* ret = allocator.makeObject; + ret.storageFor = storageForVar; + + storageForVar.storageFor = ret; + return ret; + } + + DFAObject* makeObject(DFAObject* base1 = null, DFAObject* base2 = null) + { + if (base2 !is null && base1 is null) + { + base1 = base2; + base2 = null; + } + + DFAObject* ret = allocator.makeObject; + ret.base1 = base1; + ret.base2 = base2; + return ret; + } + DFALatticeRef makeLatticeRef() { DFALatticeRef ret; @@ -633,6 +707,19 @@ struct DFACommon return scv; } + bool haveForwardLabelState(Identifier ident) + { + DFALabelState** bucket = &this.forwardLabels[( + cast(size_t) cast(void*) ident) % this.forwardLabels.length]; + + while (*bucket !is null && cast(void*)(*bucket).ident < cast(void*) ident) + { + bucket = &(*bucket).next; + } + + return *bucket !is null && (*bucket).ident is ident; + } + void swapForwardLabelScope(Identifier ident, scope DFAScopeRef delegate(DFAScopeRef) del) { DFALabelState** bucket = &this.forwardLabels[( @@ -845,6 +932,11 @@ struct DFACommon struct DFAAllocator { + package(dmd.dfa) + { + DFACommon* dfaCommon; + } + private { static struct Region @@ -865,11 +957,14 @@ struct DFAAllocator //enum RegionAllocationStep = 1_048_576; DFAVar* allocatedlistvar, allocatedlistlastvar; + DFAObject* allocatedlistobject; + // We use free lists to reuse memory, during our operation. DFALabelState* freelistlabel; DFACaseState* freelistcase; DFAVar* freelistvar; DFAScopeVar* freelistscopevar; + DFAObject* freelistobject; DFAScope* freelistscope; DFALattice* freelistlattice; DFAConsequence* freelistconsequence; @@ -966,6 +1061,8 @@ struct DFAAllocator if (childOf !is null) { ret.haveInfiniteLifetime = childOf.haveInfiniteLifetime; + ret.offsetFromBase = vd.offset; + ret.next = *bucket; *bucket = ret; } @@ -999,6 +1096,15 @@ struct DFAAllocator return ret; } + DFAObject* makeObject() + { + DFAObject* ret = allocInternal!DFAObject(freelistobject); + + ret.listnext = this.allocatedlistobject; + this.allocatedlistobject = ret; + return ret; + } + DFALattice* makeLattice(DFACommon* dfaCommon) { DFALattice* ret = allocInternal!DFALattice(freelistlattice); @@ -1009,16 +1115,12 @@ struct DFAAllocator DFAConsequence* makeConsequence(DFAVar* var, DFAConsequence* copyFrom = null) { DFAConsequence* ret = allocInternal!DFAConsequence(freelistconsequence); + ret.dfaCommon = dfaCommon; ret.var = var; if (copyFrom !is null) { - *ret = *copyFrom; - ret.previous = null; - ret.next = null; - - ret.maybe = null; - ret.maybeTopSeen = false; + ret.copyFrom(copyFrom); if (var !is null) { @@ -1061,7 +1163,7 @@ struct DFAAllocator void free(DFAScope* s) { - version (all) + static if (DFACommon.debugVerify) { DFAScope* current = s.dfaCommon.currentDFAScope; @@ -1118,6 +1220,28 @@ struct DFAAllocator freelistconsequence = c; } + void allObjects(scope void delegate(DFAObject* obj) del) + { + DFAObject* current = allocatedlistobject; + + while (current !is null) + { + del(current); + current = current.listnext; + } + } + + void allVariables(scope void delegate(DFAVar* obj) del) + { + DFAVar* current = allocatedlistvar; + + while (current !is null) + { + del(current); + current = current.listnext; + } + } + private: T* allocInternal(T)(ref T* freelist) { @@ -1151,6 +1275,7 @@ private: } else { + // Acquire the next block of memory to allocate from Region* got = cast(Region*) Mem.xmalloc(RegionAllocationStep); assert(got !is null); @@ -1172,8 +1297,10 @@ private: } // Initialize it to the right type - T valInit; - memcpy(ret, &valInit, T.sizeof); + // Note: D has changed its behavior surrounding getting the init value over many years. + // A variable like this, is guaranteed good for all of them. + __gshared immutable(T) valInit; + memcpy(ret, cast(void*)&valInit, T.sizeof); assert(ret !is null); return ret; @@ -1224,13 +1351,15 @@ struct DFAVar DFAVar* next; DFAVar*[16] childVars; DFAVar* childOffsetVars; - DFAVar* indexVar; - DFAVar* lengthVar; } DFAVar* base1; DFAVar* base2; + DFAVar* indexVar; + DFAVar* lengthVar; + DFAVar* asSliceVar; + VarDeclaration var; dinteger_t offsetFromBase; // -1 if its not an offset @@ -1242,9 +1371,11 @@ struct DFAVar bool isBoolean; bool isStaticArray; + bool isFloatingPoint; bool isByRef; bool haveInfiniteLifetime; + bool wasDefaultInitialized; // may not be accurate for all variables int declaredAtDepth; int writeCount; @@ -1257,6 +1388,8 @@ struct DFAVar ParameterDFAInfo* param; + DFAObject* storageFor; + bool haveBase() { return this.base1 !is null; @@ -1349,7 +1482,7 @@ struct DFAVar { while (var.base2 is null && var.base1 !is null) { - if (var.offsetFromBase != -1 && var.var is null) + if (var.offsetFromBase != -1) refed++; else if (var.base1.dereferenceVar is var) refed++; @@ -1374,7 +1507,8 @@ struct DFAVar } /// If this variable is a reference to another, takes into account dereferencing. - void visitReferenceToAnotherVar(scope void delegate(DFAVar* var) del) + void visitReferenceToAnotherVar(scope void delegate(DFAVar* var) hasIndirection, + scope void delegate(DFAVar* var) noIndirection = null) { void handle(DFAVar* var, int refed) { @@ -1398,7 +1532,51 @@ struct DFAVar handle(var.base2, refed); } else if (refed > 0) - del(var); + { + if (hasIndirection !is null) + hasIndirection(var); + } + else if (noIndirection !is null) + noIndirection(var); + } + + handle(&this, 0); + } + + /// If this variable is a reference to another, takes into account dereferencing. + void visitIfReadOfReferenceToAnotherVar(scope void delegate(DFAVar* var) resolvedIndirection) + { + void handle(DFAVar* var, int refed) + { + if (!(var.base1 !is null || var.base2 !is null || refed != 0)) + return; + + while (var.base2 is null && var.base1 !is null) + { + if (var.offsetFromBase != -1 && var.var is null) + refed++; + else if (var.base1.dereferenceVar is var) + refed--; + else if (var.base1.indexVar is var) + refed++; + else if (var.base1.lengthVar is var && var.base1.isStaticArray + && !var.base1.haveBase) + return; // Statically known length, base doesn't matter as it won't be read + else if (var.base1.asSliceVar is var && !var.base1.haveBase && refed == 0) + return; // base1[] is a slice this does not inherently make it a read + else + break; + + var = var.base1; + } + + if (var.base2 !is null) + { + handle(var.base1, refed); + handle(var.base2, refed); + } + else if (refed < 0) + resolvedIndirection(var); } handle(&this, 0); @@ -1467,6 +1645,37 @@ struct DFAScopeVarMergable } } +struct DFAObject +{ + private + { + DFAObject* listnext; + } + + DFAVar* storageFor; + + DFAObject* base1; + DFAObject* base2; + + // Pointer arithmetic may mean this object isn't 1:1 with the object start. + bool mayNotBeExactPointer; + + void walkRoots(scope void delegate(DFAObject* root) del) + { + DFAObject* obj = &this; + + while (obj.base1 !is null) + { + if (obj.base2 !is null) + obj.base2.walkRoots(del); + + obj = obj.base1; + } + + del(obj); + } +} + struct DFAScopeRef { package DFAScope* sc; @@ -1585,6 +1794,15 @@ struct DFAScopeRef this.sc.printState(prefix, sdepth, currentFunction, depth); } + void printActual(const(char)* prefix = "", int sdepth = 0, + FuncDeclaration currentFunction = null, int depth = 0) + { + if (this.isNull) + return; + + this.sc.printActual(prefix, sdepth, currentFunction, depth); + } + int opApply(scope int delegate(DFALattice*) dg) { if (this.sc is null) @@ -1807,7 +2025,7 @@ struct DFAScope printActual(prefix, sdepth, currentFunction, depth); } - private void printActual(const(char)* prefix = "", int sdepth = 0, + void printActual(const(char)* prefix = "", int sdepth = 0, FuncDeclaration currentFunction = null, int depth = 0) { printPrefix("%s Scope", sdepth, currentFunction, depth, prefix); @@ -2070,7 +2288,7 @@ struct DFALatticeRef DFAConsequence* getContext(out DFAVar* var) { - if (this.isNull) + if (this.isNull || this.lattice.context is null) return null; var = this.lattice.context.var; @@ -2139,7 +2357,8 @@ struct DFALatticeRef return this.lattice.acquireConstantAsContext; } - DFAConsequence* acquireConstantAsContext(Truthiness truthiness, Nullable nullable) + DFAConsequence* acquireConstantAsContext(Truthiness truthiness, + Nullable nullable, DFAObject* obj) { assert(!isNull); @@ -2148,6 +2367,7 @@ struct DFALatticeRef ret.truthiness = truthiness; ret.nullable = nullable; + ret.obj = obj; return ret; } @@ -2613,10 +2833,10 @@ struct DFAPAValue if (this.kind != other.kind) { const difference = cast(int) this.kind - cast(int) other.kind; - return difference < 0 ? - 1 : 1; + return difference < 0 ? -1 : 1; } else if (this.kind == Kind.Concrete && other.kind == Kind.Concrete) - return this.value < other.value ? - 1 : (this.value == other.value ? 0 : 1); + return this.value < other.value ? -1 : (this.value == other.value ? 0 : 1); else return 0; } @@ -2644,23 +2864,34 @@ struct DFAPAValue switch (type.ty) { - case TY.Tint8 : return byte.min <= this.value && this.value <= byte.max; + case TY.Tint8: + return byte.min <= this.value && this.value <= byte.max; - case TY.Tuns8 : return 0 <= this.value && this.value <= ubyte.max; + case TY.Tuns8: + return 0 <= this.value && this.value <= ubyte.max; - case TY.Tint16 : return short.min <= this.value && this.value <= short.max; + case TY.Tint16: + return short.min <= this.value && this.value <= short.max; - case TY.Tuns16 : return 0 <= this.value && this.value <= ushort.max; + case TY.Tuns16: + return 0 <= this.value && this.value <= ushort.max; - case TY.Tint32 : return int.min <= this.value && this.value <= int.max; + case TY.Tint32: + return int.min <= this.value && this.value <= int.max; - case TY.Tuns32 : return 0 <= this.value && this.value <= uint.max; + case TY.Tuns32: + return 0 <= this.value && this.value <= uint.max; - case TY.Tuns64 : case TY.Tuns128 : return 0 <= this.value; + case TY.Tuns64: + case TY.Tuns128: + return 0 <= this.value; - case TY.Tint64 : case TY.Tint128 : return true; + case TY.Tint64: + case TY.Tint128: + return true; - default : return false; + default: + return false; } } @@ -3475,6 +3706,7 @@ struct DFAConsequence { private { + DFACommon* dfaCommon; DFAConsequence* listnext; DFAConsequence* previous, next, bucketNext; } @@ -3498,6 +3730,25 @@ struct DFAConsequence bool maybeTopSeen; // Point analysis value, tracking of integral/length values DFAPAValue pa; + // The object that this is if its non-null + DFAObject* obj; + + void copyFrom(DFAConsequence* other) + { + if (other is null) + return; + + if (this.var is other.var) + this.writeOnVarAtThisPoint = other.writeOnVarAtThisPoint; + + this.truthiness = other.truthiness; + this.nullable = other.nullable; + this.invertedOnce = other.invertedOnce; + this.maybe = other.maybe; + this.protectElseNegate = other.protectElseNegate; + this.pa = other.pa; + this.obj = other.obj; + } void meetConsequence(DFAConsequence* c1, DFAConsequence* c2, bool couldScopeNotHaveRan = false) { @@ -3513,6 +3764,7 @@ struct DFAConsequence this.invertedOnce = c.invertedOnce; this.writeOnVarAtThisPoint = c.writeOnVarAtThisPoint; this.pa = couldScopeNotHaveRan ? DFAPAValue.Unknown : c.pa; + this.obj = couldScopeNotHaveRan ? dfaCommon.makeObject(c.obj) : c.obj; if (this.var is null || this.var.isTruthy) this.truthiness = couldScopeNotHaveRan ? Truthiness.Unknown : c.truthiness; @@ -3549,8 +3801,18 @@ struct DFAConsequence } if (this.var is null || this.var.isNullable) + { this.nullable = (couldScopeNotHaveRan && c1.nullable != c2.nullable) ? Nullable.Unknown : (c1.nullable < c2.nullable ? c1.nullable : c2.nullable); + + if (c1.obj !is null || c2.obj !is null) + { + if (c1.obj !is c2.obj) + this.obj = dfaCommon.makeObject(c1.obj, c2.obj); + else + this.obj = c1.obj !is null ? c1.obj : c2.obj; + } + } } const writeCount = this.var.writeCount; @@ -3589,6 +3851,7 @@ struct DFAConsequence this.writeOnVarAtThisPoint = c.writeOnVarAtThisPoint; this.maybe = c.maybe; this.pa = c.pa; + this.obj = c.obj; if (this.var is null || this.var.isTruthy) this.truthiness = c.truthiness; @@ -3628,6 +3891,14 @@ struct DFAConsequence this.nullable = Nullable.Unknown; else this.nullable = c1.nullable < c2.nullable ? c2.nullable : c1.nullable; + + if (c1.obj !is null || c2.obj !is null) + { + if (c1.obj !is c2.obj) + this.obj = dfaCommon.makeObject(c1.obj, c2.obj); + else + this.obj = c1.obj !is null ? c1.obj : c2.obj; + } } this.maybe = c2.maybe; @@ -3695,10 +3966,10 @@ struct DFAConsequence NullableStr[this.nullable], this.writeOnVarAtThisPoint); printf("maybe=%p:%d, protectElseNegate=%d, invertedOnce=%d ", maybe, maybeTopSeen, protectElseNegate, invertedOnce); - printf("previous=%p, next=%p, pa=%03d/%lld ", this.previous, this.next, + printf("previous=%p, next=%p, pa=%03d/%lld", this.previous, this.next, this.pa.kind, this.pa.value); - printf("%p", this.var); + printf(", %p", this.var); if (this.var !is null) { printf("=%d:%lld:b/%p/%p", this.var.assertedCount, @@ -3706,9 +3977,9 @@ struct DFAConsequence if (this.var !is null && this.var.var !is null) printf("@%p=`%s`", this.var.var, this.var.var.toChars); - } + printf(", obj=%p", this.obj); printf("\n", this.var); } } @@ -3721,6 +3992,8 @@ void applyType(DFAVar* var, VarDeclaration vd) var.isStaticArray = vd.type.isTypeSArray !is null; var.isBoolean = vd.type.ty == Tbool; + var.isFloatingPoint = vd.type.isTypeBasic !is null + && (vd.type.isTypeBasic.flags & TFlags.floating) != 0; // Unfortunately isDataseg can have very undesirable side effects that kill compilation, // even if it shouldn't when this is ran. diff --git a/dmd/statementsem.d b/dmd/statementsem.d index d602f8d30e..4fc8ef9eca 100644 --- a/dmd/statementsem.d +++ b/dmd/statementsem.d @@ -1657,7 +1657,8 @@ Statement statementSemanticVisit(Statement s, Scope* sc) /* Declare param, which we will set to be the * result of condition. */ - auto ei = new ExpInitializer(ifs.loc, ifs.condition); + // Make sure the location of the initializer reflects the condition, not the if statement. + auto ei = new ExpInitializer(ifs.condition.loc, ifs.condition); ifs.match = new VarDeclaration(ifs.loc, ifs.param.type, ifs.param.ident, ei); ifs.match.parent = scd.func; ifs.match.storage_class |= ifs.param.storageClass; diff --git a/tests/dmd/compilable/fastdfa.d b/tests/dmd/compilable/fastdfa.d index bc7156a705..23d6b3daf6 100644 --- a/tests/dmd/compilable/fastdfa.d +++ b/tests/dmd/compilable/fastdfa.d @@ -2,6 +2,73 @@ * REQUIRED_ARGS: -preview=fastdfa */ +void typeNextIterate(Type t) +{ + Type ts; + + { + Type ta = new Type; + Type* pt; + + for (pt = &ts; *pt != t; pt = &(cast(TypeNext)*pt).next) // no error + { + } + + *pt = ta; + } +} + +void test8() +{ + bool b; + bool* pb = &b; + + assert(b == false); + *pb = true; + assert(b == true); + *pb = false; + assert(b == false); +} + +void uninitWithFuncCheck() +{ + struct Foo + { + bool isB; + + void initThis(bool b) + { + this.isB = b; + } + } + + Foo foo = void; + foo.initThis = false; // ok, we can't know if a method will initialize +} + +string apUninitWrite(void* ap) +{ + string result = void; + auto p1 = cast(size_t*) &result; + + *p1 = *cast(size_t*) ap; // no error its a write after all + return result; +} + +void pointerArithmeticObj() +{ + ubyte[4] storage; + + ubyte* ptr = &storage[1]; + ptr++; +} + +void pickPtr(bool condition) +{ + int i1, i2; + int* ptr = condition ? &i1 : &i2; +} + @safe: bool isNull1(int* ptr) @@ -44,7 +111,7 @@ int* nullable1(int* ptr) ret = ptr; } - int v = *ret; // ideally would error, but not required + int v = *ret; // no error, cannot know state of ret return ret; } @@ -268,25 +335,6 @@ void loopy11() } } -void theSitchFinally() -{ - { - goto Label; - } - - { - Label: - } - - int* ptr; - - scope (exit) - int vS = *ptr; - - int vMid = *ptr; - truthinessNo; -} - void nodeFind() { static struct Node @@ -811,3 +859,265 @@ void checkEqualAssignInt(string str) i = (str == "hello"); assert(i == 1); } + +int* checkPtrFromStructNoEffect() +{ + // Make sure no effect can come from a field via a pointer. + + static struct PtrFromStruct + { + static PtrFromStruct* global; + int field; + } + + PtrFromStruct* ptrFromStruct() + { + return PtrFromStruct.global; + } + + if (auto p = ptrFromStruct()) + return &p.field; + return null; +} + +void initDefault() +{ + bool b; + bool got = b; +} + +void seeEffectOnObject1(bool condition) +{ + bool* a = new bool(true), b = new bool(true); + bool got = *(condition ? a : b); + assert(!got); // would be nice to error, but won't due to indirection +} + +void seeEffectOnObject2(bool condition) +{ + bool* a = new bool(false), b = new bool(false); + bool got = *(condition ? a : b); + assert(got); // would be nice to error, but won't due to indirection +} + +void checkLengthDeref(int[] slice) +{ + static bool expectNonNull(ref int[] arr) + { + int v = arr[0]; + return true; + } + + if (slice.length && expectNonNull(slice)) + { + } +} + +void uninitMsgPut1() +{ + static void uninitMsgSinkPut(ref char[] buf, string text) + { + } + + char[1024] buf = void; + char[] sink = buf; // cast + + uninitMsgSinkPut(sink, "ok"); // mutates buf + + char[1024] result = buf; // ok +} + +void uninitMsgPut2() +{ + static void uninitMsgSinkPut(ref char[] buf, string text) + { + } + + char[1024] buf = void; + char[] sink = buf[]; // slice + + uninitMsgSinkPut(sink, "ok"); // mutates buf + + char[1024] result = buf; // ok +} + +void loopInLoopCount() +{ + int count; + auto sample = [99]; + + foreach (j; sample) + { + if (j == 0) + { + } + else if (j == 99) + ++count; + } + + assert(9 < count); +} + +struct Ternary +{ + private ubyte value = 6; + + static Ternary make(ubyte b) + { + Ternary r = void; + r.value = b; // no error + return r; // no error + } +} + +class TypeNext +{ + Type next; +} + +class Type +{ + +} + +void uninitStackPtrOf() +{ + char[4] buf; + auto ptr = buf.ptr; + + if (ptr is buf.ptr) + { + } + else + { + bool b; + assert(b); // ok, branch not taken + } +} + +struct BigFoo +{ + ubyte[256] buf; + + static BigFoo getUninitBigFoo() + { + BigFoo ret = void; + return ret; // no error + } +} + +void initOverBranches(bool gate) +{ + int value = void; + + for (;;) + { + if (gate) + value = 1; + else + value = 2; + + if (value > 0) + break; + } +} + +void uninitTestConditionAndDoLoop(bool b) { + size_t bufStart = void; + if (b) + { + bufStart = 39; + do + { + } while (true); + } + else + { + bufStart = 39; + do + { + } while (true); + } + + const minw = bufStart; +} + +void checkFloatInit1_1(bool condition) +{ + float v; + float t = v; // ok, not a math op + + if (condition) + v = 2; + + float u = v * 2; // no error +} + +void checkFloatInit2_1(bool condition) +{ + float v = float.init; + float t = v; // ok + + if (condition) + v = 2; + + float u = v * 2; // no error +} + +void checkFloatInit3_1(bool condition) +{ + float v = 0; + float t = v; // ok + + if (condition) + v = 2; + + float u = v * 2; // no error +} + +void readFromUninit2() +{ + struct Foo + { + int val; + } + + Foo foo = void; + foo.val = 2; // ok, partial initialization +} + +void checkFloatInit2_2(bool condition) +{ + float v = float.init; + float t = v * 2; // ok + + if (condition) + v = 2; + + float u = v * 2; // no error +} + +void checkFloatInit3_2(bool condition) +{ + float v = 0; + float t = v * 2; // ok + + if (condition) + v = 2; + + float u = v * 2; // no error +} + +void checkFloatInit4(float[] array) { + foreach(e; array) { + float t = e * 2; // no error + } +} + +void checkFloatInit5() { + float thing = 2; + + if (float var = thing) { + float t = var * 2; + } +} diff --git a/tests/dmd/fail_compilation/fastdfa.d b/tests/dmd/fail_compilation/fastdfa.d index d6a2c9f8aa..b6c166bffb 100644 --- a/tests/dmd/fail_compilation/fastdfa.d +++ b/tests/dmd/fail_compilation/fastdfa.d @@ -2,27 +2,43 @@ * REQUIRED_ARGS: -preview=fastdfa * TEST_OUTPUT: --- -fail_compilation/fastdfa.d(47): Error: Assert can be proven to be false -fail_compilation/fastdfa.d(57): Error: Argument is expected to be non-null but was null -fail_compilation/fastdfa.d(50): For parameter `ptr` in argument 0 -fail_compilation/fastdfa.d(64): Error: Variable `ptr` was required to be non-null and has become null -fail_compilation/fastdfa.d(85): Error: Variable `ptr` was required to be non-null and has become null -fail_compilation/fastdfa.d(100): Error: Dereference on null variable `ptr` -fail_compilation/fastdfa.d(122): Error: Dereference on null variable `ptr` -fail_compilation/fastdfa.d(139): Error: Assert can be proven to be false -fail_compilation/fastdfa.d(145): Error: Assert can be proven to be false -fail_compilation/fastdfa.d(154): Error: Dereference on null variable `ptr` -fail_compilation/fastdfa.d(169): Error: Assert can be proven to be false -fail_compilation/fastdfa.d(177): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(63): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(78): Error: Argument is expected to be non-null but was null +fail_compilation/fastdfa.d(71): For parameter `ptr` in argument 0 +fail_compilation/fastdfa.d(96): Error: Dereference on null variable `ptr` +fail_compilation/fastdfa.d(94): Error: Dereference on null variable `ptr` +fail_compilation/fastdfa.d(104): Error: Variable `ptr` was required to be non-null and has become null +fail_compilation/fastdfa.d(125): Error: Variable `ptr` was required to be non-null and has become null +fail_compilation/fastdfa.d(140): Error: Dereference on null variable `ptr` +fail_compilation/fastdfa.d(162): Error: Dereference on null variable `ptr` fail_compilation/fastdfa.d(179): Error: Assert can be proven to be false -fail_compilation/fastdfa.d(186): Error: Assert can be proven to be false -fail_compilation/fastdfa.d(193): Error: Assert can be proven to be false -fail_compilation/fastdfa.d(197): Error: Assert can be proven to be false -fail_compilation/fastdfa.d(199): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(185): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(194): Error: Dereference on null variable `ptr` fail_compilation/fastdfa.d(209): Error: Assert can be proven to be false -fail_compilation/fastdfa.d(210): Error: Assert can be proven to be false -fail_compilation/fastdfa.d(224): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(217): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(219): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(226): Error: Assert can be proven to be false fail_compilation/fastdfa.d(233): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(237): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(239): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(249): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(250): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(264): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(273): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(289): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(295): Error: Expression reads from an uninitialized variable, it must be written to at least once before reading +fail_compilation/fastdfa.d(294): For variable `val1` +fail_compilation/fastdfa.d(298): Error: Expression reads from an uninitialized variable, it must be written to at least once before reading +fail_compilation/fastdfa.d(294): For variable `val1` +fail_compilation/fastdfa.d(305): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(312): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(348): Error: Assert can be proven to be false +fail_compilation/fastdfa.d(355): Error: Expression reads a default initialized variable that is a floating point type +fail_compilation/fastdfa.d(355): It will have the value of Not Any Number(nan), it will be propagated with mathematical operations +fail_compilation/fastdfa.d(354): For variable `v` +fail_compilation/fastdfa.d(354): Initialize to float.nan or 0 explicitly to disable this error +fail_compilation/fastdfa.d(365): Error: Expression reads from an uninitialized variable, it must be written to at least once before reading +fail_compilation/fastdfa.d(364): For variable `v` --- */ @@ -47,6 +63,11 @@ void conditionalAssert() assert(c); // Error: c is false } +bool truthinessNo() +{ + return false; +} + int nonnull1(int* ptr) { return *ptr; @@ -57,6 +78,25 @@ void nonnullCall() nonnull1(null); // error } +void theSitchFinally() +{ + { + goto Label; + } + + { + Label: + } + + int* ptr; + + scope (exit) + int vS = *ptr; // error + + int vMid = *ptr; // error + truthinessNo; +} + void loopy6() { int* ptr = new int; @@ -233,3 +273,94 @@ void paSliceLengthAppend() assert(text.length == 5); // error assert(text.length == 11); // no error } + +void checkPtrExact() { + int* a = new int; + int* b = a; + + if (a is b) { + // ok + } else { + bool c; + assert(c); // should not error + } + + assert(a is b); // no error + assert(a !is b); // error +} + +void readFromUninit1() @trusted +{ + int val1 = void; + int val2 = val1; // error + + int* ptr = &val1; + int val3 = *ptr; // error +} + +void seeEffectViaObject1(bool condition) @trusted +{ + bool a = true, b = true; + bool got = *(condition ? &a : &b); + assert(!got); // error +} + +void seeEffectViaObject2(bool condition) @trusted +{ + bool a = false, b = false; + bool got = *(condition ? &a : &b); + assert(got); // error +} + +void valueLoop1() +{ + int* obj = new int, oldObj = obj; + + foreach (i; 0 .. 0) + { + obj = new int; + } + + // only true branch taken + if (obj is oldObj) + { + } + else + { + bool b; + assert(b); // ok + } + + obj = oldObj; + + foreach (i; 0 .. 10) + { + obj = new int; + } + + // both branches must be taken + if (obj is oldObj) + { + } + else + { + bool b; + assert(b); // error: cannot know state of obj after loop (null) + } +} + +void checkFloatInit1_2(bool condition) +{ + float v; + float t = v * 2; // error math op + + if (condition) + v = 2; + + float u = v * 2; // no error +} + +float uninitFloat() { + float v = void; + return v * 2; // error +} From f23b49b9c819e6b5a47416be6ae325d4ed5b653e Mon Sep 17 00:00:00 2001 From: limepoutine Date: Mon, 23 Feb 2026 07:57:41 +0800 Subject: [PATCH 343/440] Consider `v.__ctor()` an lvalue (dlang/dmd!22605) --- dmd/expressionsem.d | 26 ++++++++++++++++++++++++-- tests/dmd/runnable/sctor.d | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 4511f28cc4..4376de44f0 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -681,8 +681,19 @@ bool isLvalue(Expression _this) if (tf && tf.isRef) { if (auto dve = _this.e1.isDotVarExp()) + { if (dve.var.isCtorDeclaration()) - return false; + { + // Allow taking the address of explicit constructor calls, + // but not (__stmp = S(), __stmp).__ctor(). + + auto ve = lastComma(dve.e1).isVarExp(); + if (ve && (ve.var.storage_class & STC.temp) != 0) + return false; + + return isLvalue(dve.e1); + } + } return true; // function returns a reference } return false; @@ -775,8 +786,19 @@ bool canElideCopy(Expression e, Type to, bool checkMod = false) static bool visitCallExp(CallExp e) { if (auto dve = e.e1.isDotVarExp()) + { if (dve.var.isCtorDeclaration()) - return true; + { + // Allow (__stmp = S(), __stmp).__ctor() to be elided, + // but force a copy for (s2 = s1.__ctor()). + + auto ve = lastComma(dve.e1).isVarExp(); + if (ve && (ve.var.storage_class & STC.temp) != 0) + return true; + + return canElideCopy(dve.e1, e.type); + } + } auto tb = e.e1.type.toBasetype(); if (tb.ty == Tdelegate || tb.ty == Tpointer) diff --git a/tests/dmd/runnable/sctor.d b/tests/dmd/runnable/sctor.d index b587e6efe8..329059c444 100644 --- a/tests/dmd/runnable/sctor.d +++ b/tests/dmd/runnable/sctor.d @@ -465,6 +465,40 @@ void test19389() assert(bar.b.x == 7); // fails } +/***************************************************/ +// https://github.com/dlang/dmd/issues/22604 + +struct S22604 +{ + S22604* ptr; + + this(int) + { + ptr = &this; + } + + this(this) + { + ptr = &this; + } +} + +struct T22604 +{ + S22604 a, b; + + this(int) + { + a = b = S22604(1); + } +} + +void test22604() +{ + T22604 t = T22604(1); + assert(t.a.ptr is &t.a); + assert(t.b.ptr is &t.b); +} /***************************************************/ @@ -478,6 +512,7 @@ int main() test14944(); test15869(); test19389(); + test22604(); printf("Success\n"); return 0; From f1e11aa62858c952adb688936c95e0820b1890c3 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Mon, 23 Feb 2026 17:20:46 +0800 Subject: [PATCH 344/440] Fix dlang/dmd!22613 - consecutive initialization fails with postblits (dlang/dmd!22619) --- dmd/expressionsem.d | 3 ++- tests/dmd/runnable/sctor.d | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 4376de44f0..b861bd733a 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -12424,7 +12424,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor } /* Rewrite as: - * (e1 = e2).postblit(); + * (e1 = e2).postblit(), e1; * * Blit assignment e1 = e2 returns a reference to the original e1, * then call the postblit on it. @@ -12436,6 +12436,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor e = new BlitExp(exp.loc, e, e2x); e = new DotVarExp(exp.loc, e, sd.postblit, false); e = new CallExp(exp.loc, e); + e = new CommaExp(exp.loc, e, e1x); result = e.expressionSemantic(sc); return; } diff --git a/tests/dmd/runnable/sctor.d b/tests/dmd/runnable/sctor.d index 329059c444..ad418d4d17 100644 --- a/tests/dmd/runnable/sctor.d +++ b/tests/dmd/runnable/sctor.d @@ -485,11 +485,11 @@ struct S22604 struct T22604 { - S22604 a, b; + S22604 a, b, c, d; this(int) { - a = b = S22604(1); + a = b = c = d = S22604(1); } } @@ -498,6 +498,8 @@ void test22604() T22604 t = T22604(1); assert(t.a.ptr is &t.a); assert(t.b.ptr is &t.b); + assert(t.c.ptr is &t.c); + assert(t.d.ptr is &t.d); } /***************************************************/ From e1e9f1043f56d90d8d19b0d275d5e9611d397ef8 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Mon, 23 Feb 2026 21:01:19 +0800 Subject: [PATCH 345/440] Do proper construction when initializing `__result` (dlang/dmd!22620) --- dmd/funcsem.d | 1 + dmd/semantic3.d | 14 +++++++------- tests/dmd/compilable/extra-files/vcg-ast.d.cg | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/dmd/funcsem.d b/dmd/funcsem.d index e153e11067..cc2497a892 100644 --- a/dmd/funcsem.d +++ b/dmd/funcsem.d @@ -2769,6 +2769,7 @@ void buildResultVar(FuncDeclaration fd, Scope* sc, Type tret) * fbody.dsymbolSemantic() running, vresult.type might be modified. */ fd.vresult = new VarDeclaration(loc, tret, Id.result, null); + fd.vresult._init = new VoidInitializer(loc); // hdrgen requires _init fd.vresult.storage_class |= STC.nodtor | STC.temp; if (!fd.isVirtual()) fd.vresult.storage_class |= STC.const_; diff --git a/dmd/semantic3.d b/dmd/semantic3.d index dacd872dc0..3838d8afc0 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -961,8 +961,10 @@ private extern(C++) final class Semantic3Visitor : Visitor /* https://issues.dlang.org/show_bug.cgi?id=10789 * If NRVO is not possible, all returned lvalues should call their postblits. + * For functions with a __result variable, postblits will be called later + * during initialization of __result. */ - if (!funcdecl.isNRVO) + if (!funcdecl.isNRVO && !funcdecl.vresult) exp = doCopyOrMove(sc2, exp, f.next, true, true); if (tret.hasPointers()) @@ -973,13 +975,11 @@ private extern(C++) final class Semantic3Visitor : Visitor if (funcdecl.vresult) { - // Create: return vresult = exp; - if (canElideCopy(exp, funcdecl.vresult.type)) - exp = new ConstructExp(rs.loc, funcdecl.vresult, exp); - else - exp = new BlitExp(rs.loc, funcdecl.vresult, exp); - + // Create: return (vresult = exp, vresult); + exp = new ConstructExp(rs.loc, funcdecl.vresult, exp); exp.type = funcdecl.vresult.type; + exp = Expression.combine(exp, new VarExp(rs.loc, funcdecl.vresult)); + exp = exp.expressionSemantic(sc2); if (rs.caseDim) exp = Expression.combine(exp, new IntegerExp(rs.caseDim)); diff --git a/tests/dmd/compilable/extra-files/vcg-ast.d.cg b/tests/dmd/compilable/extra-files/vcg-ast.d.cg index c910f59339..1af770427a 100644 --- a/tests/dmd/compilable/extra-files/vcg-ast.d.cg +++ b/tests/dmd/compilable/extra-files/vcg-ast.d.cg @@ -61,7 +61,7 @@ class C : Object } __require(); this.__invariant(); - __result = 2; + __result = 2 , __result; goto __returnLabel; __returnLabel: this.__invariant(); From 582324da83cd8c989081167c6fdfcbd8a0232da2 Mon Sep 17 00:00:00 2001 From: Dennis Date: Wed, 25 Feb 2026 01:08:33 +0100 Subject: [PATCH 346/440] -vgc: report closure locations just like nogc (dlang/dmd!22630) Co-authored-by: Dennis Korpel --- dmd/nogc.d | 14 +++++++++----- dmd/semantic3.d | 30 ++++++++++++++++++++++++------ tests/dmd/compilable/vgc3.d | 8 ++++++-- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/dmd/nogc.d b/dmd/nogc.d index c9b8a0275b..e8dde1414b 100644 --- a/dmd/nogc.d +++ b/dmd/nogc.d @@ -294,16 +294,20 @@ Expression checkGC(Expression e, Scope* sc) return e; } -extern (D) void printGCUsage(FuncDeclaration fd, Loc loc, const(char)* warn) +/// Returns: whether GC usage inside `fd` should be printed for the -vgc flag +extern (D) bool vgcEnabled(FuncDeclaration fd) { if (!global.params.v.gc) - return; + return false; Module m = fd.getModule(); - if (m && m.isRoot() && !fd.inUnittest()) - { + return (m && m.isRoot() && !fd.inUnittest()); +} + +extern (D) void printGCUsage(FuncDeclaration fd, Loc loc, const(char)* warn) +{ + if (vgcEnabled(fd)) message(loc, "vgc: %s", warn); - } } /** diff --git a/dmd/semantic3.d b/dmd/semantic3.d index 3838d8afc0..077969b9b1 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -1888,9 +1888,32 @@ extern (D) bool checkClosure(FuncDeclaration fd) else { fd.printGCUsage(fd.loc, "using closure causes GC allocation"); + + findClosureVars(fd, (FuncDeclaration f, VarDeclaration v) { + if (!fd.vgcEnabled) + return; + + .message(f.loc, "vgc: %s `%s` closes over variable `%s`", + f.kind, f.toErrMsg(), v.toErrMsg()); + if (v.ident != Id.This) + .message(v.loc, "vgc: `%s` declared here", v.toErrMsg()); + }); return false; } + findClosureVars(fd, (FuncDeclaration f, VarDeclaration v) { + .errorSupplemental(f.loc, "%s `%s` closes over variable `%s`", + f.kind, f.toErrMsg(), v.toErrMsg()); + if (v.ident != Id.This) + .errorSupplemental(v.loc, "`%s` declared here", v.toErrMsg()); + }); + return true; +} + +/// For an outer function `fd`, find inner functions that cause a closure to be generated for it. +/// Pass to `sink` each nested function along with the local variable that closes over `fd`'s stackframe +private void findClosureVars(FuncDeclaration fd, scope void delegate(FuncDeclaration, VarDeclaration) sink) +{ FuncDeclarations a; if (fd.closureVars.length > 0) @@ -1913,16 +1936,11 @@ extern (D) bool checkClosure(FuncDeclaration fd) if (!a.contains(f)) { a.push(f); - .errorSupplemental(f.loc, "%s `%s` closes over variable `%s`", - f.kind, f.toErrMsg(), v.toChars()); - if (v.ident != Id.This) - .errorSupplemental(v.loc, "`%s` declared here", v.toChars()); + sink(f, v); } break LcheckAncestorsOfANestedRef; } } } } - - return true; } diff --git a/tests/dmd/compilable/vgc3.d b/tests/dmd/compilable/vgc3.d index efdc5cd5eb..6e587530d3 100644 --- a/tests/dmd/compilable/vgc3.d +++ b/tests/dmd/compilable/vgc3.d @@ -44,8 +44,12 @@ void testCall() /* TEST_OUTPUT: --- -compilable/vgc3.d(51): vgc: using closure causes GC allocation -compilable/vgc3.d(63): vgc: using closure causes GC allocation +compilable/vgc3.d(55): vgc: using closure causes GC allocation +compilable/vgc3.d(58): vgc: function `bar` closes over variable `x` +compilable/vgc3.d(57): vgc: `x` declared here +compilable/vgc3.d(67): vgc: using closure causes GC allocation +compilable/vgc3.d(70): vgc: function `bar` closes over variable `x` +compilable/vgc3.d(69): vgc: `x` declared here --- */ auto testClosure1() From 84a324fd176903dd55534981be057d19a8169126 Mon Sep 17 00:00:00 2001 From: Gnav Date: Wed, 25 Feb 2026 10:13:36 +0700 Subject: [PATCH 347/440] Refactor: Remove addComment from dsymbol.d to break semantic dependency (dlang/dmd!22587) --- dmd/aliasthis.d | 2 +- dmd/declaration.d | 6 ++-- dmd/dimport.d | 2 +- dmd/dmodule.d | 4 +-- dmd/dsymbol.d | 78 ++++++++++++++++++++++++++++++++++++----------- dmd/dsymbol.h | 1 - dmd/dsymbolsem.d | 53 -------------------------------- dmd/dversion.d | 4 +-- dmd/frontend.h | 15 +-------- 9 files changed, 71 insertions(+), 94 deletions(-) diff --git a/dmd/aliasthis.d b/dmd/aliasthis.d index bb1fcd0203..98380cb90f 100644 --- a/dmd/aliasthis.d +++ b/dmd/aliasthis.d @@ -41,7 +41,7 @@ extern (C++) final class AliasThis : Dsymbol { assert(!s); auto at = new AliasThis(loc, ident); - at.comment = comment; + at.addComment(comment); return at; } diff --git a/dmd/declaration.d b/dmd/declaration.d index d9eab5b764..e1a4f9bf65 100644 --- a/dmd/declaration.d +++ b/dmd/declaration.d @@ -361,7 +361,7 @@ extern (C++) final class AliasDeclaration : Declaration //printf("AliasDeclaration::syntaxCopy()\n"); assert(!s); AliasDeclaration sa = type ? new AliasDeclaration(loc, ident, type.syntaxCopy()) : new AliasDeclaration(loc, ident, aliassym.syntaxCopy(null)); - sa.comment = comment; + sa.addComment(comment); sa.storage_class = storage_class; return sa; } @@ -512,7 +512,7 @@ extern (C++) class VarDeclaration : Declaration //printf("VarDeclaration::syntaxCopy(%s)\n", toChars()); assert(!s); auto v = new VarDeclaration(loc, type ? type.syntaxCopy() : null, ident, _init ? _init.syntaxCopy() : null, storage_class); - v.comment = comment; + v.addComment(comment); return v; } @@ -678,7 +678,7 @@ extern (C++) class BitFieldDeclaration : VarDeclaration //printf("BitFieldDeclaration::syntaxCopy(%s)\n", toChars()); assert(!s); auto bf = new BitFieldDeclaration(loc, type ? type.syntaxCopy() : null, ident, width.syntaxCopy(), _init ? _init.syntaxCopy() : null); - bf.comment = comment; + bf.addComment(comment); return bf; } diff --git a/dmd/dimport.d b/dmd/dimport.d index 201ab010ce..349f439ac2 100644 --- a/dmd/dimport.d +++ b/dmd/dimport.d @@ -95,7 +95,7 @@ extern (C++) final class Import : Dsymbol { assert(!s); auto si = new Import(loc, packages, id, aliasId, isstatic); - si.comment = comment; + si.addComment(comment); assert(!(isstatic && names.length)); if (names.length && !si.aliasId) si.ident = null; diff --git a/dmd/dmodule.d b/dmd/dmodule.d index 1baf39b075..de1c8f0a57 100644 --- a/dmd/dmodule.d +++ b/dmd/dmodule.d @@ -707,7 +707,7 @@ extern (C++) final class Module : Package */ if (buf.length>= 4 && buf[0..4] == "Ddoc") { - comment = buf.ptr + 4; + this.addComment(buf.ptr + 4); filetype = FileType.ddoc; if (!docfile) setDocfile(); @@ -720,7 +720,7 @@ extern (C++) final class Module : Package */ if (FileName.equalsExt(arg, dd_ext)) { - comment = buf.ptr; // the optional Ddoc, if present, is handled above. + this.addComment(buf.ptr); // the optional Ddoc, if present, is handled above. filetype = FileType.ddoc; if (!docfile) setDocfile(); diff --git a/dmd/dsymbol.d b/dmd/dsymbol.d index ed02ead4cf..f61c299819 100644 --- a/dmd/dsymbol.d +++ b/dmd/dsymbol.d @@ -45,9 +45,7 @@ import dmd.statement; import dmd.staticassert; import dmd.tokens; import dmd.visitor; - import dmd.common.outbuffer; - /*************************************** * Calls dg(Dsymbol* sym) for each Dsymbol. * If dg returns !=0, stops and returns that value else returns 0. @@ -100,6 +98,62 @@ void foreachDsymbol(Dsymbols* symbols, scope void delegate(Dsymbol) dg) } } +private void addComment(Dsymbol d, const(char)* comment) +{ + scope v = new AddCommentVisitor(comment); + d.accept(v); +} + +extern (C++) private class AddCommentVisitor: Visitor +{ + alias visit = Visitor.visit; + + const(char)* comment; + + this(const(char)* comment) + { + this.comment = comment; + } + + override void visit(Dsymbol d) + { + if (!comment || !*comment) + return; + + //printf("addComment '%s' to Dsymbol %p '%s'\n", comment, this, toChars()); + void* h = cast(void*)d; // just the pointer is the key + auto p = h in d.commentHashTable; + if (!p) + { + d.commentHashTable[h] = comment; + return; + } + if (strcmp(*p, comment) != 0) + { + // Concatenate the two + import dmd.lexer; + *p = Lexer.combineComments((*p).toDString(), comment.toDString(), true); + } + } + override void visit(AttribDeclaration atd) + { + if (comment && atd.decl) + { + atd.decl.foreachDsymbol( s => s.addComment(comment) ); + } + } + override void visit(ConditionalDeclaration cd) + { + if (comment) + { + cd.decl .foreachDsymbol( s => s.addComment(comment) ); + cd.elsedecl.foreachDsymbol( s => s.addComment(comment) ); + } + } + override void visit(StaticForeachDeclaration sfd) {} +} + + struct Visibility { /// @@ -765,16 +819,6 @@ extern (C++) class Dsymbol : ASTNode assert(0); } - /**************************************** - * Add documentation comment to Dsymbol. - * Ignore NULL comments. - */ - void addComment(const(char)* comment) - { - import dmd.dsymbolsem; - dmd.dsymbolsem.addComment(this, comment); - } - /// get documentation comment for this Dsymbol final const(char)* comment() { @@ -786,10 +830,10 @@ extern (C++) class Dsymbol : ASTNode } return null; } - - /* Shell around addComment() to avoid disruption for the moment */ - final void comment(const(char)* comment) { addComment(comment); } - + final void addComment(const(char)* c) + { + .addComment(this, c); + } extern (D) __gshared const(char)*[void*] commentHashTable; @@ -1072,7 +1116,7 @@ public: { //printf("ScopeDsymbol::syntaxCopy('%s')\n", toChars()); ScopeDsymbol sds = s ? cast(ScopeDsymbol)s : new ScopeDsymbol(ident); - sds.comment = comment; + sds.addComment(comment); sds.members = arraySyntaxCopy(members); sds.endlinnum = endlinnum; return sds; diff --git a/dmd/dsymbol.h b/dmd/dsymbol.h index f6665c5922..44b88445fd 100644 --- a/dmd/dsymbol.h +++ b/dmd/dsymbol.h @@ -242,7 +242,6 @@ class Dsymbol : public ASTNode virtual Visibility visible(); virtual Dsymbol *syntaxCopy(Dsymbol *s); // copy only syntax trees - virtual void addComment(const utf8_t *comment); const utf8_t *comment(); // current value of comment UnitTestDeclaration *ddocUnittest(); diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 3e372b58e9..19d92417ca 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -9244,59 +9244,6 @@ Lfail: return false; } -void addComment(Dsymbol d, const(char)* comment) -{ - scope v = new AddCommentVisitor(comment); - d.accept(v); -} - -extern (C++) class AddCommentVisitor: Visitor -{ - alias visit = Visitor.visit; - - const(char)* comment; - - this(const(char)* comment) - { - this.comment = comment; - } - - override void visit(Dsymbol d) - { - if (!comment || !*comment) - return; - - //printf("addComment '%s' to Dsymbol %p '%s'\n", comment, this, toChars()); - void* h = cast(void*)d; // just the pointer is the key - auto p = h in d.commentHashTable; - if (!p) - { - d.commentHashTable[h] = comment; - return; - } - if (strcmp(*p, comment) != 0) - { - // Concatenate the two - *p = Lexer.combineComments((*p).toDString(), comment.toDString(), true); - } - } - override void visit(AttribDeclaration atd) - { - if (comment) - { - atd.include(null).foreachDsymbol( s => s.addComment(comment) ); - } - } - override void visit(ConditionalDeclaration cd) - { - if (comment) - { - cd.decl .foreachDsymbol( s => s.addComment(comment) ); - cd.elsedecl.foreachDsymbol( s => s.addComment(comment) ); - } - } - override void visit(StaticForeachDeclaration sfd) {} -} void checkCtorConstInit(Dsymbol d) { diff --git a/dmd/dversion.d b/dmd/dversion.d index 17d888b17e..2036f78304 100644 --- a/dmd/dversion.d +++ b/dmd/dversion.d @@ -39,7 +39,7 @@ extern (C++) final class DebugSymbol : Dsymbol { assert(!s); auto ds = new DebugSymbol(loc, ident); - ds.comment = comment; + ds.addComment(comment); return ds; } @@ -75,7 +75,7 @@ extern (C++) final class VersionSymbol : Dsymbol { assert(!s); auto ds = new VersionSymbol(loc, ident); - ds.comment = comment; + ds.addComment(comment); return ds; } diff --git a/dmd/frontend.h b/dmd/frontend.h index 0b32ea3ecd..a644420993 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -613,9 +613,8 @@ class Dsymbol : public ASTNode virtual bool needThis(); virtual Visibility visible(); virtual Dsymbol* syntaxCopy(Dsymbol* s); - virtual void addComment(const char* comment); const char* comment(); - void comment(const char* comment); + void addComment(const char* c); UnitTestDeclaration* ddocUnittest(); void ddocUnittest(UnitTestDeclaration* utd); bool inNonRoot(); @@ -7286,18 +7285,6 @@ class ConditionIncludeVisitor : public Visitor void visit(StaticForeachDeclaration* sfd) override; }; -class AddCommentVisitor : public Visitor -{ -public: - using Visitor::visit; - const char* comment; - AddCommentVisitor(const char* comment); - void visit(Dsymbol* d) override; - void visit(AttribDeclaration* atd) override; - void visit(ConditionalDeclaration* cd) override; - void visit(StaticForeachDeclaration* sfd) override; -}; - class NrvoWalker final : public StatementRewriteWalker { public: From a83eeb2b49acb59374011b895fb311d925e5a044 Mon Sep 17 00:00:00 2001 From: Abhishek Bhosale <108826846+AbhishekASLK@users.noreply.github.com> Date: Wed, 25 Feb 2026 11:42:02 +0530 Subject: [PATCH 348/440] Move TemplateDeclaration.computeIsTrivialAlias logic to templatesem (dlang/dmd!22631) --- dmd/dtemplate.d | 38 -------------------------------------- dmd/templatesem.d | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/dmd/dtemplate.d b/dmd/dtemplate.d index 40f1f07cbb..c2bcb0d491 100644 --- a/dmd/dtemplate.d +++ b/dmd/dtemplate.d @@ -299,44 +299,6 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol this.visibility = Visibility(Visibility.Kind.undefined); } - extern(D) void computeIsTrivialAlias(Dsymbol s) - { - /* Set isTrivialAliasSeq if this fits the pattern: - * template AliasSeq(T...) { alias AliasSeq = T; } - * or set isTrivialAlias if this fits the pattern: - * template Alias(T) { alias Alias = qualifiers(T); } - */ - if (!(parameters && parameters.length == 1)) - return; - - auto ad = s.isAliasDeclaration(); - if (!ad || !ad.type) - return; - - auto ti = ad.type.isTypeIdentifier(); - - if (!ti || ti.idents.length != 0) - return; - - if (auto ttp = (*parameters)[0].isTemplateTupleParameter()) - { - if (ti.ident is ttp.ident && - ti.mod == 0) - { - //printf("found isTrivialAliasSeq %s %s\n", s.toChars(), ad.type.toChars()); - isTrivialAliasSeq = true; - } - } - else if (auto ttp = (*parameters)[0].isTemplateTypeParameter()) - { - if (ti.ident is ttp.ident) - { - //printf("found isTrivialAlias %s %s\n", s.toChars(), ad.type.toChars()); - isTrivialAlias = true; - } - } - } - override TemplateDeclaration syntaxCopy(Dsymbol) { //printf("TemplateDeclaration.syntaxCopy()\n"); diff --git a/dmd/templatesem.d b/dmd/templatesem.d index a2bed8a7cd..a62b2bf59f 100644 --- a/dmd/templatesem.d +++ b/dmd/templatesem.d @@ -455,6 +455,44 @@ void computeOneMember(TemplateDeclaration td) } } +private void computeIsTrivialAlias(TemplateDeclaration td, Dsymbol s) +{ + /* Set isTrivialAliasSeq if this fits the pattern: + * template AliasSeq(T...) { alias AliasSeq = T; } + * or set isTrivialAlias if this fits the pattern: + * template Alias(T) { alias Alias = qualifiers(T); } + */ + if (!(td.parameters && td.parameters.length == 1)) + return; + + auto ad = s.isAliasDeclaration(); + if (!ad || !ad.type) + return; + + auto ti = ad.type.isTypeIdentifier(); + + if (!ti || ti.idents.length != 0) + return; + + if (auto ttp = (*td.parameters)[0].isTemplateTupleParameter()) + { + if (ti.ident is ttp.ident && + ti.mod == 0) + { + //printf("found isTrivialAliasSeq %s %s\n", s.toChars(), ad.type.toChars()); + td.isTrivialAliasSeq = true; + } + } + else if (auto ttp = (*td.parameters)[0].isTemplateTypeParameter()) + { + if (ti.ident is ttp.ident) + { + //printf("found isTrivialAlias %s %s\n", s.toChars(), ad.type.toChars()); + td.isTrivialAlias = true; + } + } +} + bool declareParameter(TemplateParameter _this, Scope* sc) { static bool typeDeclareParameter(TemplateTypeParameter _this, Scope* sc) From e513b33b30c8342a44fff7e74be8c568d448ea90 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Wed, 25 Feb 2026 00:39:17 -0800 Subject: [PATCH 349/440] at least get x87 to compile on AArch64 host (dlang/dmd!22634) --- dmd/root/longdouble.d | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dmd/root/longdouble.d b/dmd/root/longdouble.d index 5d468f2752..6fa2b7b61c 100644 --- a/dmd/root/longdouble.d +++ b/dmd/root/longdouble.d @@ -16,6 +16,8 @@ version (CRuntime_Microsoft) static if (real.sizeof > 8) alias longdouble = real; else + // Need to fix longdouble_soft so it works for compiler built with AArch64 but + // generating X86_64 code alias longdouble = longdouble_soft; } else @@ -33,6 +35,7 @@ version(D_InlineAsm_X86_64) else version(D_InlineAsm_X86) version = AsmX86; else + // yes, AArch64 host needs to emulate 80 bit real to cross compile for X86_64 static assert(false, "longdouble_soft not supported on this platform"); bool initFPU() From ef6e7fa292b6a5f4b2fa7373eeff97fc55ce0c1b Mon Sep 17 00:00:00 2001 From: limepoutine Date: Wed, 25 Feb 2026 16:39:33 +0800 Subject: [PATCH 350/440] Do semantic under nested scope when returning inside foreach body (dlang/dmd!22632) --- dmd/frontend.h | 1 + dmd/funcsem.d | 2 +- dmd/semantic3.d | 5 +++-- dmd/statement.d | 1 + dmd/statement.h | 1 + dmd/statementsem.d | 4 ++++ tests/dmd/runnable/foreach5.d | 31 +++++++++++++++++++++++++++++++ tests/dmd/runnable/rvalue1.d | 24 ++++++++++++++++++++++++ 8 files changed, 66 insertions(+), 3 deletions(-) diff --git a/dmd/frontend.h b/dmd/frontend.h index a644420993..d00faa64d1 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -5179,6 +5179,7 @@ class ReturnStatement final : public Statement public: Expression* exp; size_t caseDim; + FuncDeclaration* fesFunc; ReturnStatement* syntaxCopy() override; ReturnStatement* endsWithReturnStatement() override; void accept(Visitor* v) override; diff --git a/dmd/funcsem.d b/dmd/funcsem.d index cc2497a892..31b6397ecf 100644 --- a/dmd/funcsem.d +++ b/dmd/funcsem.d @@ -2780,7 +2780,7 @@ void buildResultVar(FuncDeclaration fd, Scope* sc, Type tret) if (sc && fd.vresult.semanticRun == PASS.initial) { TypeFunction tf = fd.type.toTypeFunction(); - if (tf.isRef) + if (fd.isNRVO || tf.isRef) fd.vresult.storage_class |= STC.ref_; else if (target.isReturnOnStack(tf, fd.needThis())) fd.vresult.nrvo = true; diff --git a/dmd/semantic3.d b/dmd/semantic3.d index 077969b9b1..2347826454 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -975,11 +975,12 @@ private extern(C++) final class Semantic3Visitor : Visitor if (funcdecl.vresult) { + Scope* scret = rs.fesFunc ? rs.fesFunc._scope : sc2; + // Create: return (vresult = exp, vresult); exp = new ConstructExp(rs.loc, funcdecl.vresult, exp); - exp.type = funcdecl.vresult.type; + exp = exp.expressionSemantic(scret); exp = Expression.combine(exp, new VarExp(rs.loc, funcdecl.vresult)); - exp = exp.expressionSemantic(sc2); if (rs.caseDim) exp = Expression.combine(exp, new IntegerExp(rs.caseDim)); diff --git a/dmd/statement.d b/dmd/statement.d index 0641c0a85c..ff162aa79b 100644 --- a/dmd/statement.d +++ b/dmd/statement.d @@ -1308,6 +1308,7 @@ extern (C++) final class ReturnStatement : Statement { Expression exp; size_t caseDim; + FuncDeclaration fesFunc; // nested function for foreach it is in extern (D) this(Loc loc, Expression exp) @safe { diff --git a/dmd/statement.h b/dmd/statement.h index d49f4e47db..7074052fd2 100644 --- a/dmd/statement.h +++ b/dmd/statement.h @@ -518,6 +518,7 @@ class ReturnStatement final : public Statement public: Expression *exp; size_t caseDim; + FuncDeclaration *fesFunc; // nested function for foreach it is in ReturnStatement *syntaxCopy() override; diff --git a/dmd/statementsem.d b/dmd/statementsem.d index 4fc8ef9eca..2f7b442d3a 100644 --- a/dmd/statementsem.d +++ b/dmd/statementsem.d @@ -2481,8 +2481,12 @@ Statement statementSemanticVisit(Statement s, Scope* sc) //printf("ReturnStatement.dsymbolSemantic() %s\n", toChars(rs)); FuncDeclaration fd = sc.parent.isFuncDeclaration(); + if (fd.fes) + { + rs.fesFunc = fd; fd = fd.fes.func; // fd is now function enclosing foreach + } auto tf = fd.type.isTypeFunction(); diff --git a/tests/dmd/runnable/foreach5.d b/tests/dmd/runnable/foreach5.d index b0befcceb6..024db2a864 100644 --- a/tests/dmd/runnable/foreach5.d +++ b/tests/dmd/runnable/foreach5.d @@ -1208,6 +1208,36 @@ void testLDC326() } } +/***************************************/ +// https://github.com/dlang/dmd/issues/22629 + +struct Collection2 +{ + this(ref Collection2) {} + + int opApply(int delegate(Collection2)) + { + return 0; + } +} + +Collection2 testForeach2(ref Collection2 level1, ref Collection2 level2) +{ + foreach (first; level1) { + foreach (second; level2) + return second; + } + + return Collection2(); +} + +void test22629() +{ + Collection2 c1, c2; + testForeach2(c1, c2); +} + + /***************************************/ int main() @@ -1241,6 +1271,7 @@ int main() test14653(); test17041(); testLDC326(); + test22629(); printf("Success\n"); return 0; diff --git a/tests/dmd/runnable/rvalue1.d b/tests/dmd/runnable/rvalue1.d index e50ccd0839..78c5091989 100644 --- a/tests/dmd/runnable/rvalue1.d +++ b/tests/dmd/runnable/rvalue1.d @@ -286,6 +286,7 @@ struct V12 { S12 s; this(int) { s = S12(1); } + int opApply(int delegate(Object)) { return 0; } } S12 foo12() @@ -293,10 +294,33 @@ S12 foo12() return __rvalue(V12(1).s); } +S12 bar12() +{ + S12 s = S12(1); // NRVO + foreach (_; V12(1)) + return s; + return s; +} + +S12 baz12() +{ + S12 s1 = S12(1); + S12 s2 = S12(1); // No NRVO + foreach (_; V12(1)) + return s1; + return s2; +} + void test12() { S12 s = foo12(); assert(&s == s.ptr); + + S12 s2 = bar12(); + assert(&s2 == s2.ptr); + + S12 s3 = baz12(); + assert(&s3 == s3.ptr); } /********************************/ From b4150b4e8d991996cd4c3143b9609deeba90bd51 Mon Sep 17 00:00:00 2001 From: Abhishek Bhosale <108826846+AbhishekASLK@users.noreply.github.com> Date: Wed, 25 Feb 2026 19:33:55 +0530 Subject: [PATCH 351/440] refactor: move fixupInvariantIdent from func to dsymbolsem (dlang/dmd!22635) --- dmd/dsymbolsem.d | 9 +++++++++ dmd/func.d | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 19d92417ca..2c3d8ab9bf 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -143,6 +143,15 @@ void addObjcSymbols(Dsymbol _this, ClassDeclarations* classes, ClassDeclarations objc.addSymbols(cd, classes, categories); } +private void fixupInvariantIdent(InvariantDeclaration invd, size_t offset) +{ + OutBuffer idBuf; + idBuf.writestring("__invariant"); + idBuf.print(offset); + + invd.ident = Identifier.idPool(idBuf[]); +} + /************************************ * Maybe `ident` was a C or C++ name. Check for that, * and suggest the D equivalent. diff --git a/dmd/func.d b/dmd/func.d index 1f902e4f18..a2ccc4c225 100644 --- a/dmd/func.d +++ b/dmd/func.d @@ -1116,15 +1116,6 @@ extern (C++) final class InvariantDeclaration : FuncDeclaration { v.visit(this); } - - extern (D) void fixupInvariantIdent(size_t offset) - { - OutBuffer idBuf; - idBuf.writestring("__invariant"); - idBuf.print(offset); - - ident = Identifier.idPool(idBuf[]); - } } From 2e1de93fdca3c1a247e5205acf682cbaee866f4b Mon Sep 17 00:00:00 2001 From: Abhishek Bhosale <108826846+AbhishekASLK@users.noreply.github.com> Date: Thu, 26 Feb 2026 14:05:27 +0530 Subject: [PATCH 352/440] clean up imports in asttypename (dlang/dmd!22641) --- dmd/asttypename.d | 4 ---- 1 file changed, 4 deletions(-) diff --git a/dmd/asttypename.d b/dmd/asttypename.d index b8070a4788..7962a891f5 100644 --- a/dmd/asttypename.d +++ b/dmd/asttypename.d @@ -16,20 +16,16 @@ import dmd.attrib; import dmd.aliasthis; import dmd.aggregate; import dmd.cond; -import dmd.ctfeexpr; import dmd.dclass; import dmd.declaration; import dmd.denum; import dmd.dimport; -import dmd.declaration; import dmd.dstruct; import dmd.dsymbol; import dmd.dtemplate; import dmd.dversion; import dmd.expression; import dmd.func; -import dmd.denum; -import dmd.dimport; import dmd.dmodule; import dmd.mtype; import dmd.identifier; From d599614b4672b206b9501e9c53a14942759c4ffa Mon Sep 17 00:00:00 2001 From: Atila Neves Date: Thu, 26 Feb 2026 11:44:28 +0100 Subject: [PATCH 353/440] Fix issue17167.sh test on systems with small NAME_MAX (dlang/dmd!22643) --- tests/dmd/compilable/issue17167.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/dmd/compilable/issue17167.sh b/tests/dmd/compilable/issue17167.sh index 3b94feb0a7..688be6d42c 100755 --- a/tests/dmd/compilable/issue17167.sh +++ b/tests/dmd/compilable/issue17167.sh @@ -4,6 +4,13 @@ # Test that file paths larger than 248 characters can be used # Test CRLF and mixed line ending handling in D lexer. +probe_dir=$(dirname "${OUTPUT_BASE}") +name_max=$(getconf NAME_MAX "${probe_dir}" 2>/dev/null || echo 255) +if [ "${name_max}" -lt 249 ]; then + echo "Skipping ${TEST_NAME}.sh: NAME_MAX=${name_max} < 249, cannot test Windows long-path threshold." >&2 + exit 0 +fi + test_dir=${OUTPUT_BASE}/uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu mkdir -p "$test_dir" From fff6263bd59e271dc54de093cbbb2f619953133d Mon Sep 17 00:00:00 2001 From: Atila Neves Date: Thu, 26 Feb 2026 11:47:05 +0100 Subject: [PATCH 354/440] Fix tests hanging due to gdb lock (dlang/dmd!22644) --- tests/dmd/tools/d_do_test.d | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/dmd/tools/d_do_test.d b/tests/dmd/tools/d_do_test.d index 497cdf8d41..9a17a4359a 100755 --- a/tests/dmd/tools/d_do_test.d +++ b/tests/dmd/tools/d_do_test.d @@ -2277,9 +2277,25 @@ int runBashTest(string input_dir, string test_name, const ref EnvData envData) */ int runGDBTestWithLock(const ref EnvData envData, int delegate() fun) { + import core.thread : Thread; + import std.datetime : dur; + import std.conv: text; + // Tests failed on SemaphoreCI when multiple GDB tests were run at once - scope lockfile = File(envData.results_dir.buildPath("gdb.lock"), "w"); - lockfile.lock(); + const lockPath = envData.results_dir.buildPath("gdb.lock"); + scope lockfile = File(lockPath, "w"); + enum maxWaitSeconds = 30; + auto waitTime = StopWatch(AutoStart.yes); + while (!lockfile.tryLock()) + { + if (waitTime.peek.total!"seconds" >= maxWaitSeconds) + { + throw new Exception( + text("Time out waiting for ", lockPath, " after ", maxWaitSeconds, + " seconds. A stale stopped test process may still hold the lock.")); + } + Thread.sleep(100.msecs); + } scope (exit) lockfile.unlock(); return fun(); From 2f91d89137240b2cdc1714389c0d15bd435bf652 Mon Sep 17 00:00:00 2001 From: Atila Neves Date: Fri, 27 Feb 2026 07:04:19 +0100 Subject: [PATCH 355/440] Make druntime compile with -preview=nosharedaccess (dlang/dmd!22646) --- dmd/expressionsem.d | 9 +- runtime/druntime/src/core/sync/rwmutex.d | 122 +++--------------- .../test_nosharedaccess_ctor_nested_new.d | 13 ++ 3 files changed, 37 insertions(+), 107 deletions(-) create mode 100644 tests/dmd/compilable/test_nosharedaccess_ctor_nested_new.d diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index b861bd733a..725fc718ad 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -16724,7 +16724,14 @@ bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false) if (e.placement) check(e.placement, false); if (e.thisexp) - check(e.thisexp, false); + { + // In a shared constructor, accessing the current + // `this` is safe for nested allocation. + // See test_nosharedaccess_ctor_nested_new.d + if (!(sc.func && sc.func.isCtorDeclaration() && sc.func.type.isShared() && + e.thisexp.isThisExp())) + check(e.thisexp, false); + } return false; } diff --git a/runtime/druntime/src/core/sync/rwmutex.d b/runtime/druntime/src/core/sync/rwmutex.d index cb581621ec..e46b2f736f 100644 --- a/runtime/druntime/src/core/sync/rwmutex.d +++ b/runtime/druntime/src/core/sync/rwmutex.d @@ -20,6 +20,7 @@ public import core.sync.exception; import core.sync.condition; import core.sync.mutex; import core.memory; +import core.atomic : atomicLoad; //////////////////////////////////////////////////////////////////////////////// @@ -107,11 +108,11 @@ class ReadWriteMutex if ( !m_commonMutex ) throw new SyncError( "Unable to initialize mutex" ); - m_readerQueue = new shared Condition( m_commonMutex ); + m_readerQueue = new shared Condition(atomicLoad(m_commonMutex)); if ( !m_readerQueue ) throw new SyncError( "Unable to initialize mutex" ); - m_writerQueue = new shared Condition( m_commonMutex ); + m_writerQueue = new shared Condition(atomicLoad(m_commonMutex)); if ( !m_writerQueue ) throw new SyncError( "Unable to initialize mutex" ); @@ -139,7 +140,7 @@ class ReadWriteMutex ///ditto @property Policy policy() shared @safe nothrow { - return m_policy; + return atomicLoad(m_policy); } //////////////////////////////////////////////////////////////////////////// @@ -161,7 +162,7 @@ class ReadWriteMutex ///ditto @property shared(Reader) reader() shared @safe nothrow { - return m_reader; + return atomicLoad(m_reader); } /** @@ -178,7 +179,7 @@ class ReadWriteMutex ///ditto @property shared(Writer) writer() shared @safe nothrow { - return m_writer; + return atomicLoad(m_writer); } @@ -200,7 +201,7 @@ class ReadWriteMutex this(this Q)() @trusted nothrow if (is(Q == Reader) || is(Q == shared Reader)) { - m_proxy.link = this; + m_proxy.link = cast(typeof(m_proxy.link)) this; this.__monitor = cast(void*) &m_proxy; } @@ -223,15 +224,7 @@ class ReadWriteMutex /// ditto @trusted void lock() shared { - synchronized( m_commonMutex ) - { - ++(cast()m_numQueuedReaders); - scope(exit) --(cast()m_numQueuedReaders); - - while ( shouldQueueReader ) - m_readerQueue.wait(); - ++(cast()m_numActiveReaders); - } + (cast() this).lock(); } /** @@ -252,14 +245,7 @@ class ReadWriteMutex /// ditto @trusted void unlock() shared { - synchronized( m_commonMutex ) - { - if ( --(cast()m_numActiveReaders) < 1 ) - { - if ( m_numQueuedWriters > 0 ) - m_writerQueue.notify(); - } - } + (cast() this).unlock(); } /** @@ -284,13 +270,7 @@ class ReadWriteMutex /// ditto @trusted bool tryLock() shared { - synchronized( m_commonMutex ) - { - if ( shouldQueueReader ) - return false; - ++(cast()m_numActiveReaders); - return true; - } + return (cast() this).tryLock(); } /** @@ -341,25 +321,7 @@ class ReadWriteMutex /// ditto @trusted bool tryLock(Duration timeout) shared { - const initialTime = MonoTime.currTime; - synchronized( m_commonMutex ) - { - ++(cast()m_numQueuedReaders); - scope(exit) --(cast()m_numQueuedReaders); - - while (shouldQueueReader) - { - const timeElapsed = MonoTime.currTime - initialTime; - if (timeElapsed >= timeout) - return false; - auto nextWait = timeout - timeElapsed; - // Avoid problems calling wait(Duration) with huge arguments. - enum maxWaitPerCall = dur!"hours"(24 * 365); - m_readerQueue.wait(nextWait < maxWaitPerCall ? nextWait : maxWaitPerCall); - } - ++(cast()m_numActiveReaders); - return true; - } + return (cast() this).tryLock(timeout); } @@ -410,7 +372,7 @@ class ReadWriteMutex this(this Q)() @trusted nothrow if (is(Q == Writer) || is(Q == shared Writer)) { - m_proxy.link = this; + m_proxy.link = cast(typeof(m_proxy.link)) this; this.__monitor = cast(void*) &m_proxy; } @@ -434,15 +396,7 @@ class ReadWriteMutex /// ditto @trusted void lock() shared { - synchronized( m_commonMutex ) - { - ++(cast()m_numQueuedWriters); - scope(exit) --(cast()m_numQueuedWriters); - - while ( shouldQueueWriter ) - m_writerQueue.wait(); - ++(cast()m_numActiveWriters); - } + (cast() this).lock(); } @@ -477,27 +431,7 @@ class ReadWriteMutex /// ditto @trusted void unlock() shared { - synchronized( m_commonMutex ) - { - if ( --(cast()m_numActiveWriters) < 1 ) - { - switch ( m_policy ) - { - default: - case Policy.PREFER_READERS: - if ( m_numQueuedReaders > 0 ) - m_readerQueue.notifyAll(); - else if ( m_numQueuedWriters > 0 ) - m_writerQueue.notify(); - break; - case Policy.PREFER_WRITERS: - if ( m_numQueuedWriters > 0 ) - m_writerQueue.notify(); - else if ( m_numQueuedReaders > 0 ) - m_readerQueue.notifyAll(); - } - } - } + (cast() this).unlock(); } @@ -523,13 +457,7 @@ class ReadWriteMutex /// ditto @trusted bool tryLock() shared { - synchronized( m_commonMutex ) - { - if ( shouldQueueWriter ) - return false; - ++(cast()m_numActiveWriters); - return true; - } + return (cast() this).tryLock(); } /** @@ -580,25 +508,7 @@ class ReadWriteMutex /// ditto @trusted bool tryLock(Duration timeout) shared { - const initialTime = MonoTime.currTime; - synchronized( m_commonMutex ) - { - ++(cast()m_numQueuedWriters); - scope(exit) --(cast()m_numQueuedWriters); - - while (shouldQueueWriter) - { - const timeElapsed = MonoTime.currTime - initialTime; - if (timeElapsed >= timeout) - return false; - auto nextWait = timeout - timeElapsed; - // Avoid problems calling wait(Duration) with huge arguments. - enum maxWaitPerCall = dur!"hours"(24 * 365); - m_writerQueue.wait(nextWait < maxWaitPerCall ? nextWait : maxWaitPerCall); - } - ++(cast()m_numActiveWriters); - return true; - } + return (cast() this).tryLock(timeout); } private: diff --git a/tests/dmd/compilable/test_nosharedaccess_ctor_nested_new.d b/tests/dmd/compilable/test_nosharedaccess_ctor_nested_new.d new file mode 100644 index 0000000000..3b28e23291 --- /dev/null +++ b/tests/dmd/compilable/test_nosharedaccess_ctor_nested_new.d @@ -0,0 +1,13 @@ +// REQUIRED_ARGS: -preview=nosharedaccess + +class Outer +{ + class Inner + { + } + + shared this() + { + auto i = new shared Inner; + } +} From b9c9824f23aca62d8cc37b152d16347d7c37bfef Mon Sep 17 00:00:00 2001 From: Gaofei Qiu <96871163+gulugulubing@users.noreply.github.com> Date: Fri, 27 Feb 2026 01:25:21 -0700 Subject: [PATCH 356/440] Fix issue 22621 - child scope should inherit inunion from its parent (dlang/dmd!22651) --- dmd/dsymbolsem.d | 2 +- tests/dmd/runnable/issue22621.d | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/runnable/issue22621.d diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 2c3d8ab9bf..76e5260444 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -3443,7 +3443,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor sc = sc.push(); sc.stc &= ~(STC.auto_ | STC.scope_ | STC.static_ | STC.gshared); - sc.inunion = scd.isunion ? scd : null; + sc.inunion = scd.isunion ? scd : sc.inunion; sc.resetAllFlags(); for (size_t i = 0; i < scd.decl.length; i++) { diff --git a/tests/dmd/runnable/issue22621.d b/tests/dmd/runnable/issue22621.d new file mode 100644 index 0000000000..e596341c63 --- /dev/null +++ b/tests/dmd/runnable/issue22621.d @@ -0,0 +1,40 @@ +// Test for Issue 22621 +// Destructor should not be called on uninitialized overlapped field + +int dtorCalls = 0; + +struct D +{ + int magic = 0xC0FFEE; + + ~this() @safe + { + // d's destructor should NOT be called, + // while dd's destructor should be called. + dtorCalls++; + assert(magic == 0xC0FFEE, "Destructor called on uninitialized field!"); + } +} + +struct SUS +{ + union { + struct { + D d; + } + uint b; + } + D dd; +} + +void main() +{ + { + // Initialize only 'b', not 'd' + // Without the fix, d's destructor would be called on garbage memory + SUS sus = SUS(b:0xDEADBEEF); + } + + // Just dd's destructor should be called, so dtorCalls should be 1 + assert(dtorCalls == 1, "Destructor was incorrectly called!"); +} From 1f4de58c08d3d624ef7dfc0f67818917676a5984 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 28 Feb 2026 11:16:49 +0000 Subject: [PATCH 357/440] Add `__traits(needsDestruction, T)` (dlang/dmd!22616) Fixes https://github.com/dlang/dmd/issues/22609. --- dmd/frontend.h | 1 + dmd/id.d | 1 + dmd/traits.d | 30 +++++++++++++++++++++ runtime/druntime/src/core/internal/traits.d | 30 +++------------------ tests/dmd/compilable/new_xdtor.d | 10 +++++++ 5 files changed, 45 insertions(+), 27 deletions(-) create mode 100644 tests/dmd/compilable/new_xdtor.d diff --git a/dmd/frontend.h b/dmd/frontend.h index d00faa64d1..1ffb8a4945 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -8865,6 +8865,7 @@ struct Id final static Identifier* isCopyable; static Identifier* toType; static Identifier* parameters; + static Identifier* needsDestruction; static Identifier* allocator; static Identifier* basic_string; static Identifier* basic_istream; diff --git a/dmd/id.d b/dmd/id.d index beb3de62b3..3a63cbf991 100644 --- a/dmd/id.d +++ b/dmd/id.d @@ -483,6 +483,7 @@ immutable Msgtable[] msgtable = { "isCopyable" }, { "toType" }, { "parameters" }, + { "needsDestruction" }, // For C++ mangling { "allocator" }, diff --git a/dmd/traits.d b/dmd/traits.d index ecb38c660c..6f901cc91f 100644 --- a/dmd/traits.d +++ b/dmd/traits.d @@ -597,6 +597,36 @@ Expression semanticTraits(TraitsExp e, Scope* sc) return isCopyable(t) ? True() : False(); } + if (e.ident == Id.needsDestruction) + { + if (dim != 1) + return dimError(1); + + auto o = (*e.args)[0]; + auto t = isType(o); + if (!t) + { + error(e.loc, "type expected as second argument of __traits `%s` instead of `%s`", + e.ident.toChars(), o.toChars()); + return ErrorExp.get(); + } + // FIXME should just check t.needsDestruction() but that doesn't run dsymbolSemantic + + // T[0] + if (!t.size()) + return False(); + + // get the base in case `t` is an `enum` + // handle static arrays + t = t.baseElemOf(); + if (auto ts = t.isTypeStruct()) + { + ts.sym.dsymbolSemantic(sc); + if (ts.sym.dtor) + return True(); + } + return False(); + } if (e.ident == Id.isNested) { diff --git a/runtime/druntime/src/core/internal/traits.d b/runtime/druntime/src/core/internal/traits.d index 33daecc7d3..df9f4200e5 100644 --- a/runtime/druntime/src/core/internal/traits.d +++ b/runtime/druntime/src/core/internal/traits.d @@ -285,33 +285,9 @@ template hasElaborateMove(S) } } -// std.traits.hasElaborateDestructor -template hasElaborateDestructor(S) -{ - static if (__traits(isStaticArray, S)) - { - enum bool hasElaborateDestructor = S.sizeof && hasElaborateDestructor!(BaseElemOf!S); - } - else static if (is(S == struct)) - { - // Once https://issues.dlang.org/show_bug.cgi?id=24865 is fixed, then - // this should be the implementation, but until that's fixed, we need the - // uncommented code. - // enum hasElaborateDestructor = __traits(hasMember, S, "__xdtor"); - // Note: we have to avoid triggering opDispatch to placate runnable/b6400.d - enum hasElaborateDestructor = __traits(compiles, { - static struct S2 - { - S s; - static assert(is(typeof(__xdtor))); - } - }); - } - else - { - enum bool hasElaborateDestructor = false; - } -} +// Used by std.traits.hasElaborateDestructor +// TODO inline this in druntime +enum hasElaborateDestructor(S) = __traits(needsDestruction, S); @safe unittest { diff --git a/tests/dmd/compilable/new_xdtor.d b/tests/dmd/compilable/new_xdtor.d new file mode 100644 index 0000000000..e757a9fd63 --- /dev/null +++ b/tests/dmd/compilable/new_xdtor.d @@ -0,0 +1,10 @@ +// https://github.com/dlang/dmd/issues/22609 +struct S +{ + private ~this() {} +} + +void f() +{ + auto x = new S; +} From 99d13e0b60c0b48d87c3827b1e55f846c95666a0 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 28 Feb 2026 21:52:02 +0000 Subject: [PATCH 358/440] Fix `__traits(isCopyable)` fails on static array of non-copyable struct (dlang/dmd!22660) Fixes dlang/dmd!22658. --- dmd/traits.d | 3 ++- tests/dmd/compilable/traits.d | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dmd/traits.d b/dmd/traits.d index 6f901cc91f..206d92b06e 100644 --- a/dmd/traits.d +++ b/dmd/traits.d @@ -588,7 +588,8 @@ Expression semanticTraits(TraitsExp e, Scope* sc) return ErrorExp.get(); } - t = t.toBasetype(); // get the base in case `t` is an `enum` + // get enum base or static array element type + t = t.baseElemOf(); if (auto ts = t.isTypeStruct()) { diff --git a/tests/dmd/compilable/traits.d b/tests/dmd/compilable/traits.d index 09538b1dd4..025a82c979 100644 --- a/tests/dmd/compilable/traits.d +++ b/tests/dmd/compilable/traits.d @@ -169,6 +169,7 @@ class C1 {} static assert( __traits(isCopyable, S1)); static assert( __traits(isCopyable, S2)); static assert(!__traits(isCopyable, S3)); +static assert(!__traits(isCopyable, S3[1])); static assert(!__traits(isCopyable, S4)); static assert(__traits(isCopyable, C1)); static assert(__traits(isCopyable, int)); From 4ccd6d033b26a8aff0a8282793c590263e52df0c Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 28 Feb 2026 22:31:15 +0000 Subject: [PATCH 359/440] `__traits(allMembers, Struct)` should call `dsymbolSemantic` (dlang/dmd!22657) Fixes https://github.com/dlang/dmd/issues/22524. --- dmd/traits.d | 9 +++++---- tests/dmd/compilable/struct_allMembers.d | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 tests/dmd/compilable/struct_allMembers.d diff --git a/dmd/traits.d b/dmd/traits.d index 206d92b06e..782a7a1ca1 100644 --- a/dmd/traits.d +++ b/dmd/traits.d @@ -1715,6 +1715,11 @@ Expression semanticTraits(TraitsExp e, Scope* sc) errorSupplemental(e.loc, "`%s` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation", s.toChars()); return ErrorExp.get(); } + // https://issues.dlang.org/show_bug.cgi?id=13668 + // https://github.com/dlang/dmd/issues/22524 + // resolve forward references + if (sds.semanticRun < PASS.semanticdone) + sds.dsymbolSemantic(sc); auto idents = new Identifiers(); @@ -1793,10 +1798,6 @@ Expression semanticTraits(TraitsExp e, Scope* sc) auto cd = sds.isClassDeclaration(); if (cd && e.ident == Id.allMembers) { - if (cd.semanticRun < PASS.semanticdone) - cd.dsymbolSemantic(null); // https://issues.dlang.org/show_bug.cgi?id=13668 - // Try to resolve forward reference - void pushBaseMembersDg(ClassDeclaration cd) { for (size_t i = 0; i < cd.baseclasses.length; i++) diff --git a/tests/dmd/compilable/struct_allMembers.d b/tests/dmd/compilable/struct_allMembers.d new file mode 100644 index 0000000000..0304e944aa --- /dev/null +++ b/tests/dmd/compilable/struct_allMembers.d @@ -0,0 +1,14 @@ +/* +TEST_OUTPUT: +--- +S2: AliasSeq!("__dtor", "__xdtor", "opAssign") +S3: AliasSeq!("field", "__xdtor", "opAssign") +--- +*/ + +// allMembers should include __xdtor +pragma(msg, "S2: ", __traits(allMembers, S2)); +pragma(msg, "S3: ", __traits(allMembers, S3)); + +static struct S2 { ~this() {} } +static struct S3 { S2 field; } From 935b28ed91ae1756377c8745f4c9507811a00998 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 28 Feb 2026 20:12:36 -0800 Subject: [PATCH 360/440] AArch64 does not support x87 intrinsics (dlang/dmd!22664) --- dmd/root/ctfloat.d | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dmd/root/ctfloat.d b/dmd/root/ctfloat.d index 67eb031b06..ef4ed4ffc6 100644 --- a/dmd/root/ctfloat.d +++ b/dmd/root/ctfloat.d @@ -41,8 +41,11 @@ extern (C++) struct CTFloat version (GNU) enum yl2x_supported = false; + else version (AArch64) + enum yl2x_supported = false; // no x87 FPU else enum yl2x_supported = __traits(compiles, core.math.yl2x(1.0L, 2.0L)); + enum yl2xp1_supported = yl2x_supported; static void yl2x(const real_t* x, const real_t* y, real_t* res) pure From c24de7dd05d4623624450cbaae9799a7fe5e518e Mon Sep 17 00:00:00 2001 From: IDONTUSEGH Date: Sun, 1 Mar 2026 05:46:13 +0100 Subject: [PATCH 361/440] Generate .di to stdout if name is "-" (dlang/dmd!22662) --- dmd/main.d | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dmd/main.d b/dmd/main.d index 9a04c16b9f..dbbde2889b 100644 --- a/dmd/main.d +++ b/dmd/main.d @@ -582,7 +582,11 @@ private int tryMain(const(char)[][] argv, out Param params) buf.reset(); // reuse the buffer genhdrfile(m, params.dihdr.fullOutput, buf); - if (!writeFile(m.loc, m.hdrfile.toString(), buf[])) + if (params.dihdr.name == "-") { + size_t n = fwrite(buf[].ptr, 1, buf.length, stdout); + assert(n == buf.length); + } + else if (!writeFile(m.loc, m.hdrfile.toString(), buf[])) fatal(); } } From f8b7e7bd1e14c29010ce8a726db58d9b41449b00 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sun, 1 Mar 2026 21:22:26 +0000 Subject: [PATCH 362/440] Generate `etc.valgrind.valgrind` docs (dlang/dmd!22675) --- runtime/druntime/Makefile | 3 +++ runtime/druntime/src/etc/valgrind/valgrind.d | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/runtime/druntime/Makefile b/runtime/druntime/Makefile index 89f5297fac..635abd3b9f 100644 --- a/runtime/druntime/Makefile +++ b/runtime/druntime/Makefile @@ -326,6 +326,9 @@ $(DOC_OUTPUT_DIR)/core_builtins.html : import/core/builtins.d $(DMD) $(DOC_OUTPUT_DIR)/etc_linux_%.html : import/etc/linux/%.d $(DMD) $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< +$(DOC_OUTPUT_DIR)/etc_valgrind_%.html : import/etc/valgrind/%.d $(DMD) + $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DOC_OUTPUT_DIR)/gc_%.html : import/gc/%.d $(DMD) $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< diff --git a/runtime/druntime/src/etc/valgrind/valgrind.d b/runtime/druntime/src/etc/valgrind/valgrind.d index 21829fc23b..3b70e75be0 100644 --- a/runtime/druntime/src/etc/valgrind/valgrind.d +++ b/runtime/druntime/src/etc/valgrind/valgrind.d @@ -3,7 +3,7 @@ /// and compile with `-debug=VALGRIND` to access the declarations below. module etc.valgrind.valgrind; -version (StdDdoc) +version (CoreDdoc) { /// Mark the memory covered by `mem` as unaddressable. void makeMemNoAccess (const(void)[] mem) nothrow @nogc; From 648adf635edc390b31309f33b2fca04a16a634c7 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sun, 1 Mar 2026 22:05:07 +0000 Subject: [PATCH 363/440] Check member access for `__traits(getMember)` in `@safe` code (dlang/dmd!22674) Fixes dlang/dmd!19721. --- dmd/traits.d | 12 +++++++++ .../dmd/fail_compilation/getMember_private.d | 26 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/dmd/fail_compilation/getMember_private.d diff --git a/dmd/traits.d b/dmd/traits.d index 782a7a1ca1..6a62179a02 100644 --- a/dmd/traits.d +++ b/dmd/traits.d @@ -1126,6 +1126,18 @@ Expression semanticTraits(TraitsExp e, Scope* sc) // Prevent semantic() from replacing Symbol with its initializer die.wantsym = true; ex = ex.expressionSemantic(scx); + if (ex) + { + import dmd.access : symbolIsVisible; + import dmd.safe : setUnsafe; + auto msym = getDsymbolWithoutExpCtx(ex); + // https://github.com/dlang/dmd/issues/19721 + if (msym && !symbolIsVisible(sc, msym)) + { + if (sc.setUnsafe(false, e.loc, "accessing member `%s`", id)) + return ErrorExp.get(); + } + } return ex; } else if (e.ident == Id.getVirtualFunctions || diff --git a/tests/dmd/fail_compilation/getMember_private.d b/tests/dmd/fail_compilation/getMember_private.d new file mode 100644 index 0000000000..647e6098e3 --- /dev/null +++ b/tests/dmd/fail_compilation/getMember_private.d @@ -0,0 +1,26 @@ +/* +EXTRA_FILES: imports/fail5385.d +TEST_OUTPUT: +--- +fail_compilation/getMember_private.d(17): Error: accessing member `x` is not allowed in a `@safe` function +fail_compilation/getMember_private.d(19): Error: accessing member `privX` is not allowed in a `@safe` function +--- +*/ + +import imports.a10169, imports.fail5385; + +B b; + +void f() @safe +{ + // instance field + __traits(getMember, b, "x")++; + // static field + __traits(getMember, C, "privX")++; +} + +void g() @system // OK +{ + __traits(getMember, b, "x")++; + __traits(getMember, C, "privX")++; +} From aa96544aa241c8ec6abc393840fd54d4d0df7698 Mon Sep 17 00:00:00 2001 From: bscuron Date: Sun, 1 Mar 2026 21:49:51 -0500 Subject: [PATCH 364/440] Makefile: Double quote $(MAKE) variable to prevent word splitting (dlang/dmd!22678) Prevents word splitting of the `make` path by the shell. ``` C:/Program Files (x86)/GnuWin32/bin/make -C druntime /usr/bin/bash: -c: line 1: syntax error near unexpected token `(' /usr/bin/bash: -c: line 1: `C:/Program Files (x86)/GnuWin32/bin/make -C druntime' make: *** [druntime] Error 2 ``` --- runtime/druntime/Makefile | 12 ++++++------ runtime/druntime/posix.mak | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/runtime/druntime/Makefile b/runtime/druntime/Makefile index 635abd3b9f..3a75d7c5c5 100644 --- a/runtime/druntime/Makefile +++ b/runtime/druntime/Makefile @@ -376,7 +376,7 @@ $(IMPDIR)/%.h : src/%.h ######################## Build DMD if non-existent ############################## ../generated/$(OS)/$(BUILD)/$(MODEL)/dmd$(DOTEXE): - $(MAKE) -C .. dmd BUILD=$(BUILD) OS=$(OS) MODEL=$(MODEL) DMD="" + "$(MAKE)" -C .. dmd BUILD=$(BUILD) OS=$(OS) MODEL=$(MODEL) DMD="" # alias using the absolute path (the Phobos Makefile specifies an absolute path) $(abspath ../generated/$(OS)/$(BUILD)/$(MODEL)/dmd$(DOTEXE)): ../generated/$(OS)/$(BUILD)/$(MODEL)/dmd$(DOTEXE) @@ -444,7 +444,7 @@ unittest : $(UT_MODULES) $(addsuffix /.run,$(ADDITIONAL_TESTS)) else unittest : unittest-debug unittest-release unittest-%: target - $(MAKE) -f $(MAKEFILE) unittest OS=$(OS) MODEL=$(MODEL) DMD=$(DMD) BUILD=$* + "$(MAKE)" -f $(MAKEFILE) unittest OS=$(OS) MODEL=$(MODEL) DMD=$(DMD) BUILD=$* endif ifeq ($(OS),linux) @@ -506,14 +506,14 @@ ifeq (linux,$(OS)) endif test/%/.run: test/%/Makefile $(DMD) - $(QUIET)$(MAKE) -C test/$* MODEL=$(MODEL) OS=$(OS) DMD=$(abspath $(DMD)) BUILD=$(BUILD) \ + $(QUIET)"$(MAKE)" -C test/$* MODEL=$(MODEL) OS=$(OS) DMD=$(abspath $(DMD)) BUILD=$(BUILD) \ DRUNTIME=$(abspath $(DRUNTIME)) DRUNTIMESO=$(abspath $(DRUNTIMESO)) LINKDL=$(LINKDL) \ QUIET=$(QUIET) TIMELIMIT='$(TIMELIMIT)' PIC=$(PIC) SHARED=$(SHARED) IS_MUSL=$(IS_MUSL) test/%/.clean: test/%/Makefile - $(QUIET)$(MAKE) -C test/$* MODEL=$(MODEL) OS=$(OS) BUILD=$(BUILD) clean + $(QUIET)"$(MAKE)" -C test/$* MODEL=$(MODEL) OS=$(OS) BUILD=$(BUILD) clean ifeq (0,$(BUILD_WAS_SPECIFIED)) - $(QUIET)$(MAKE) -C test/$* MODEL=$(MODEL) OS=$(OS) BUILD=debug clean + $(QUIET)"$(MAKE)" -C test/$* MODEL=$(MODEL) OS=$(OS) BUILD=debug clean endif #################### benchmark suite ########################## @@ -594,7 +594,7 @@ test_extractor: $(TESTS_EXTRACTOR) ################################################################################ betterc: | $(TESTS_EXTRACTOR) $(BETTERCTESTS_DIR)/.directory - $(MAKE) $$(find src -type f -name '*.d' | sed 's/[.]d/.betterc/') + "$(MAKE)" $$(find src -type f -name '*.d' | sed 's/[.]d/.betterc/') %.betterc: %.d | $(TESTS_EXTRACTOR) $(BETTERCTESTS_DIR)/.directory @$(TESTS_EXTRACTOR) --betterC --attributes betterC \ diff --git a/runtime/druntime/posix.mak b/runtime/druntime/posix.mak index 062a7c12e7..df0213dbf6 100644 --- a/runtime/druntime/posix.mak +++ b/runtime/druntime/posix.mak @@ -5,7 +5,7 @@ $(warning ============================== ) # forward everything to Makefile target: - $(MAKE) -f Makefile $@ + "$(MAKE)" -f Makefile $@ %: - $(MAKE) -f Makefile $@ + "$(MAKE)" -f Makefile $@ From 8b30b984d11fe72bbe16466f1ceef2e3b977884b Mon Sep 17 00:00:00 2001 From: Madhur Kumar <152476790+MadhurKumar004@users.noreply.github.com> Date: Mon, 2 Mar 2026 19:07:18 +0530 Subject: [PATCH 365/440] Delete useless import in compiler/src/dmd/dclass.d (dlang/dmd!22654) --- dmd/dclass.d | 1 - 1 file changed, 1 deletion(-) diff --git a/dmd/dclass.d b/dmd/dclass.d index 6385265f9f..950f7db113 100644 --- a/dmd/dclass.d +++ b/dmd/dclass.d @@ -20,7 +20,6 @@ import dmd.aggregate; import dmd.arraytypes; import dmd.astenums; import dmd.declaration; -import dmd.dscope; import dmd.dsymbol; import dmd.errors; import dmd.func; From 90d0db02e7c335b160cda7230975595180b4fe0a Mon Sep 17 00:00:00 2001 From: Gaofei Qiu <96871163+gulugulubing@users.noreply.github.com> Date: Mon, 2 Mar 2026 06:40:58 -0700 Subject: [PATCH 366/440] implement isOverlapped trait (dlang/dmd!22640) --- dmd/frontend.h | 1 + dmd/id.d | 1 + dmd/traits.d | 24 ++- tests/dmd/compilable/test_isOverlapped.d | 181 ++++++++++++++++++ .../test_isOverlapped_errors.d | 17 ++ 5 files changed, 223 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/compilable/test_isOverlapped.d create mode 100644 tests/dmd/fail_compilation/test_isOverlapped_errors.d diff --git a/dmd/frontend.h b/dmd/frontend.h index 1ffb8a4945..7e32e4dbba 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -8800,6 +8800,7 @@ struct Id final static Identifier* isAbstractClass; static Identifier* isArithmetic; static Identifier* isAssociativeArray; + static Identifier* isOverlapped; static Identifier* isBitfield; static Identifier* isFinalClass; static Identifier* isTemplate; diff --git a/dmd/id.d b/dmd/id.d index 3a63cbf991..4ac0f4f3d5 100644 --- a/dmd/id.d +++ b/dmd/id.d @@ -418,6 +418,7 @@ immutable Msgtable[] msgtable = { "isAbstractClass" }, { "isArithmetic" }, { "isAssociativeArray" }, + { "isOverlapped" }, { "isBitfield" }, { "isFinalClass" }, { "isTemplate" }, diff --git a/dmd/traits.d b/dmd/traits.d index 6a62179a02..bcc004047e 100644 --- a/dmd/traits.d +++ b/dmd/traits.d @@ -443,6 +443,27 @@ Expression semanticTraits(TraitsExp e, Scope* sc) }); } + if (e.ident == Id.isOverlapped) + { + if (dim != 1) + return dimError(1); + + return isDeclX((d) + { + auto v = d.isVarDeclaration(); + if (!v || !v.isField()) + return false; + + // Ensure semantic analysis is complete + if (auto agg = v.toParent().isAggregateDeclaration()) + { + if (agg.semanticRun < PASS.semanticdone) + agg.dsymbolSemantic(null); + } + + return v.overlapped; + }); + } if (e.ident == Id.isArithmetic) { return isTypeX(t => t.isIntegral() || t.isFloating()); @@ -2388,7 +2409,7 @@ private void traitNotFound(TraitsExp e) initialized = true; // lazy initialization // All possible traits - __gshared Identifier*[59] idents = + __gshared Identifier*[60] idents = [ &Id.allMembers, &Id.child, @@ -2420,6 +2441,7 @@ private void traitNotFound(TraitsExp e) &Id.identifier, &Id.isAbstractClass, &Id.isAbstractFunction, + &Id.isOverlapped, &Id.isArithmetic, &Id.isAssociativeArray, &Id.isCopyable, diff --git a/tests/dmd/compilable/test_isOverlapped.d b/tests/dmd/compilable/test_isOverlapped.d new file mode 100644 index 0000000000..a32eb2df33 --- /dev/null +++ b/tests/dmd/compilable/test_isOverlapped.d @@ -0,0 +1,181 @@ +// REQUIRED_ARGS: + +struct S1 +{ + int a; + union + { + int x; + float y; + } + int b; +} + +// Anonymous union fields are overlapped +static assert(__traits(isOverlapped, S1.x)); +static assert(__traits(isOverlapped, S1.y)); +// Regular fields are not overlapped +static assert(!__traits(isOverlapped, S1.a)); +static assert(!__traits(isOverlapped, S1.b)); + +// Named union as a field type +struct S2 +{ + union U + { + int x; + float y; + } + U u; +} +// The instance 'u' itself is not overlapped (it's a regular field) +static assert(!__traits(isOverlapped, S2.u)); +static assert(__traits(isOverlapped, S2.U.x)); +static assert(__traits(isOverlapped, S2.U.y)); + +// Named union accessed directly - its fields are overlapped +union NamedUnion +{ + int x; + float y; +} +static assert(__traits(isOverlapped, NamedUnion.x)); +static assert(__traits(isOverlapped, NamedUnion.y)); + +// Anonymous struct (not a union) - fields are NOT overlapped +struct S3 +{ + struct + { + int x; + float y; + } +} +static assert(!__traits(isOverlapped, S3.x)); +static assert(!__traits(isOverlapped, S3.y)); + +// Named union with nested anonymous union +struct S4 +{ + union Outer + { + int x; // This IS overlapped (it's in a named union) + // Anonymous union nested inside the named union Outer + union + { + int nested1; + float nested2; + } + } + Outer outer; +} +static assert(!__traits(isOverlapped, S4.outer)); // regular field, not overlapped +static assert(__traits(isOverlapped, S4.Outer.nested1)); // in union (both named and anonymous) +static assert(__traits(isOverlapped, S4.Outer.nested2)); // in union (both named and anonymous) +static assert(__traits(isOverlapped, S4.Outer.x)); // in named union - NOW true! + +// Class with anonymous union +class C1 +{ + union + { + int x; + float y; + } +} +static assert(__traits(isOverlapped, C1.x)); +static assert(__traits(isOverlapped, C1.y)); + +// Non-field arguments should return false (not error) +static assert(!__traits(isOverlapped, S1)); // aggregate type +static assert(!__traits(isOverlapped, int)); // type +static assert(!__traits(isOverlapped, 42)); // literal value + +// Deeply nested anonymous unions within anonymous structs +struct S5 +{ + union + { + int x; + struct + { + union + { + int y; + float z; + } + } + } +} +static assert(__traits(isOverlapped, S5.x)); // outer anonymous union +static assert(__traits(isOverlapped, S5.y)); // inner anonymous union +static assert(__traits(isOverlapped, S5.z)); // inner anonymous union + +// Union as top-level type +union TopLevelUnion1 +{ + int a; + float b; + struct + { + int c; + int d; + } +} +static assert(__traits(isOverlapped, TopLevelUnion1.a)); +static assert(__traits(isOverlapped, TopLevelUnion1.b)); +static assert(__traits(isOverlapped, TopLevelUnion1.c)); +static assert(!__traits(isOverlapped, TopLevelUnion1.d)); + +union TopLevelUnion2 +{ + int a; + double b; + struct + { + int c; + int d; // Now d is overlapped with b + } +} +static assert(__traits(isOverlapped, TopLevelUnion2.a)); +static assert(__traits(isOverlapped, TopLevelUnion2.b)); +static assert(__traits(isOverlapped, TopLevelUnion2.c)); +static assert(__traits(isOverlapped, TopLevelUnion2.d)); + +// Bug #22621 +struct Bug22621 +{ + struct D + { + void* ptr; + } + + union + { + struct + { + D d; + } + uint b; + } +} +static assert(__traits(isOverlapped, Bug22621.b)); +// Bug #22621: DMD correctly detects that d is overlapped, but the destructor +// logic doesn't properly handle it - it calls d's destructor even when only b was initialized +static assert(__traits(isOverlapped, Bug22621.d)); // Correctly detected! + +// Struct with both overlapped and non-overlapped fields +struct S6 +{ + int regular1; + union + { + int overlapped1; + float overlapped2; + } + int regular2; +} +static assert(!__traits(isOverlapped, S6.regular1)); +static assert(__traits(isOverlapped, S6.overlapped1)); +static assert(__traits(isOverlapped, S6.overlapped2)); +static assert(!__traits(isOverlapped, S6.regular2)); diff --git a/tests/dmd/fail_compilation/test_isOverlapped_errors.d b/tests/dmd/fail_compilation/test_isOverlapped_errors.d new file mode 100644 index 0000000000..ef0a1782dd --- /dev/null +++ b/tests/dmd/fail_compilation/test_isOverlapped_errors.d @@ -0,0 +1,17 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/test_isOverlapped_errors.d(100): Error: expected 1 arguments for `isOverlapped` but had 0 +fail_compilation/test_isOverlapped_errors.d(101): Error: expected 1 arguments for `isOverlapped` but had 2 +--- +*/ + +struct S +{ + union { int x; } + int y; +} + +#line 100 +enum a = __traits(isOverlapped); +enum b = __traits(isOverlapped, S, S.x); From 681055c02f1f01b04882056a0c97483660f5346a Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Mon, 2 Mar 2026 22:58:18 +0000 Subject: [PATCH 367/440] [CoreDdoc] Fix 2 version typos (dlang/dmd!22682) --- runtime/druntime/src/core/memory.d | 2 +- runtime/druntime/src/core/sys/darwin/crt_externs.d | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/druntime/src/core/memory.d b/runtime/druntime/src/core/memory.d index 3b3cb8e6a6..a4e2d1f269 100644 --- a/runtime/druntime/src/core/memory.d +++ b/runtime/druntime/src/core/memory.d @@ -141,7 +141,7 @@ private extern (C) GC.ProfileStats gc_profileStats ( ) nothrow @nogc @safe; } -version (CoreDoc) +version (CoreDdoc) { /** * The minimum size of a system page in bytes. diff --git a/runtime/druntime/src/core/sys/darwin/crt_externs.d b/runtime/druntime/src/core/sys/darwin/crt_externs.d index ec0788d7de..a34db83c9d 100644 --- a/runtime/druntime/src/core/sys/darwin/crt_externs.d +++ b/runtime/druntime/src/core/sys/darwin/crt_externs.d @@ -8,7 +8,7 @@ */ module core.sys.darwin.crt_externs; -version (CoreDoc) +version (CoreDdoc) { /** * In reality this will be $(REF mach_header, core, sys, darwin, mach, loader) From 795a15b8261578de7d8bb1355a5e0148ba0e3867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Wed, 4 Mar 2026 00:15:26 +0100 Subject: [PATCH 368/440] Fix the fstatat declaration on macOS/x64. (dlang/dmd!22689) The x64 version of fstatat() needs to be mangled with the "INODE64" suffix in order to match the stat_t layout defined by Druntime. See https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/sys/stat.h#L573 --- runtime/druntime/src/core/sys/posix/sys/stat.d | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/druntime/src/core/sys/posix/sys/stat.d b/runtime/druntime/src/core/sys/posix/sys/stat.d index 762d6fcc76..9c1d873c7d 100644 --- a/runtime/druntime/src/core/sys/posix/sys/stat.d +++ b/runtime/druntime/src/core/sys/posix/sys/stat.d @@ -2008,12 +2008,14 @@ else version (Darwin) version (AArch64) { int fstat(int, stat_t*); + int fstatat(int, const scope char*, stat_t*, int); int lstat(const scope char*, stat_t*); int stat(const scope char*, stat_t*); } else { pragma(mangle, "fstat$INODE64") int fstat(int, stat_t*); + pragma(mangle, "fstatat$INODE64") int fstatat(int, const scope char*, stat_t*, int); pragma(mangle, "lstat$INODE64") int lstat(const scope char*, stat_t*); pragma(mangle, "stat$INODE64") int stat(const scope char*, stat_t*); } @@ -2021,11 +2023,11 @@ else version (Darwin) else { int fstat(int, stat_t*); + int fstatat(int, const scope char*, stat_t*, int); int lstat(const scope char*, stat_t*); int stat(const scope char*, stat_t*); } int fchmodat(int, const scope char*, mode_t, int); - int fstatat(int, const scope char*, stat_t*, int); int futimens(int, ref const(timespec)[2]); int mkdirat(int, const scope char*, mode_t); int mkfifoat(int, const scope char*, mode_t); From efe19e4743c1d6cc23e08c9268bdcc4b29f85b9c Mon Sep 17 00:00:00 2001 From: IDONTUSEGH Date: Wed, 4 Mar 2026 00:18:09 +0100 Subject: [PATCH 369/440] Fix dlang/dmd!22667: hdrgen: Skip using typedefIdent for basic types (dlang/dmd!22669) --- dmd/cparse.d | 3 +-- dmd/frontend.h | 5 ++++- dmd/hdrgen.d | 7 ++++++- tests/dmd/compilable/ctod.i | 13 +++++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/dmd/cparse.d b/dmd/cparse.d index 3ebbfe04f2..c005493a97 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -5075,8 +5075,7 @@ final class CParser(AST) : Parser!AST if (pt && *pt) t = *pt; } - if (t.mcache && t.mcache.typedefIdent) - { + if ((t.mcache && t.mcache.typedefIdent) || t.isTypeBasic()) { t = t.copy(); t.mcache = null; } diff --git a/dmd/frontend.h b/dmd/frontend.h index 7e32e4dbba..c4439b55b6 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -4082,6 +4082,7 @@ struct HdrGenState final bool fullDump; bool importcHdr; bool inCAlias; + bool inFuncReturn; bool doFuncBodies; bool vcg_ast; bool skipConstraints; @@ -4101,6 +4102,7 @@ struct HdrGenState final fullDump(), importcHdr(), inCAlias(), + inFuncReturn(), doFuncBodies(), vcg_ast(), skipConstraints(), @@ -4116,12 +4118,13 @@ struct HdrGenState final inEnumDecl() { } - HdrGenState(bool hdrgen, bool ddoc = false, bool fullDump = false, bool importcHdr = false, bool inCAlias = false, bool doFuncBodies = false, bool vcg_ast = false, bool skipConstraints = false, bool showOneMember = true, bool errorMsg = false, bool fullQual = false, int32_t tpltMember = 0, int32_t autoMember = 0, int32_t forStmtInit = 0, int32_t insideFuncBody = 0, int32_t insideAggregate = 0, bool declstring = false, EnumDeclaration* inEnumDecl = nullptr) : + HdrGenState(bool hdrgen, bool ddoc = false, bool fullDump = false, bool importcHdr = false, bool inCAlias = false, bool inFuncReturn = false, bool doFuncBodies = false, bool vcg_ast = false, bool skipConstraints = false, bool showOneMember = true, bool errorMsg = false, bool fullQual = false, int32_t tpltMember = 0, int32_t autoMember = 0, int32_t forStmtInit = 0, int32_t insideFuncBody = 0, int32_t insideAggregate = 0, bool declstring = false, EnumDeclaration* inEnumDecl = nullptr) : hdrgen(hdrgen), ddoc(ddoc), fullDump(fullDump), importcHdr(importcHdr), inCAlias(inCAlias), + inFuncReturn(inFuncReturn), doFuncBodies(doFuncBodies), vcg_ast(vcg_ast), skipConstraints(skipConstraints), diff --git a/dmd/hdrgen.d b/dmd/hdrgen.d index 7b50af1685..71e94c2a90 100644 --- a/dmd/hdrgen.d +++ b/dmd/hdrgen.d @@ -58,6 +58,7 @@ struct HdrGenState bool fullDump; /// true if generating a full AST dump file bool importcHdr; /// true if generating a .di file from an ImportC file bool inCAlias; /// Set to prevent ImportC translating typedefs as `alias X = X` + bool inFuncReturn; /// Set when printing function return type to avoid typedef name bool doFuncBodies; /// include function bodies in output bool vcg_ast; /// write out codegen-ast bool skipConstraints; // skip constraints when doing templates @@ -4096,7 +4097,9 @@ private void visitFuncIdentWithPostfix(TypeFunction t, const char[] ident, ref O buf.write("static "); if (t.next) { + hgs.inFuncReturn = true; typeToBuffer(t.next, null, buf, hgs); + hgs.inFuncReturn = false; if (ident) buf.put(' '); } @@ -4165,7 +4168,9 @@ private void visitFuncIdentWithPrefix(TypeFunction t, const Identifier ident, Te } else if (t.next) { + hgs.inFuncReturn = true; typeToBuffer(t.next, null, buf, hgs); + hgs.inFuncReturn = false; if (ident) buf.put(' '); } @@ -4547,7 +4552,7 @@ private void typeToBufferx(Type t, ref OutBuffer buf, ref HdrGenState hgs) buf.put("noreturn"); } - if (hgs.importcHdr && !hgs.inCAlias && t.mcache && t.mcache.typedefIdent) + if (hgs.importcHdr && !hgs.inCAlias && !hgs.inFuncReturn && t.mcache && t.mcache.typedefIdent) { buf.put(t.mcache.typedefIdent.toString()); return; diff --git a/tests/dmd/compilable/ctod.i b/tests/dmd/compilable/ctod.i index d1529de47d..b41a3b7bfd 100644 --- a/tests/dmd/compilable/ctod.i +++ b/tests/dmd/compilable/ctod.i @@ -53,6 +53,11 @@ extern (C) Callback cb = void; } extern __gshared int[cast(ULONG)3] arr; + alias NOPE1 = void; + void mylib_hello1(); + alias NOPE2 = int; + int mylib_hello2(); + void mylib_hello3(void*); /+enum int __DATE__ = 1+/; /+enum int __TIME__ = 1+/; /+enum int __TIMESTAMP__ = 1+/; @@ -131,3 +136,11 @@ int arr[(ULONG) 3]; #define DEF 123 #define SQL_DRIVER_STMT_ATTR_BASE 0x00004000 // 32-bit #define ABC 64 + +typedef void NOPE1; +void mylib_hello1(void); + +typedef int NOPE2; +int mylib_hello2(void); + +void mylib_hello3(void*); From 5f89df510759d32e3bc447a4260912d6638be495 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Thu, 5 Mar 2026 23:57:45 +0000 Subject: [PATCH 370/440] [`core.sys` docs] Build HTML with `-os=platform` flag (dlang/dmd!22691) Ignore `Posix` and `linux` as Linux is used to build docs already. --- runtime/druntime/Makefile | 33 ++++++++++--------- .../druntime/src/core/sys/freebsd/config.d | 3 +- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/runtime/druntime/Makefile b/runtime/druntime/Makefile index 3a75d7c5c5..34480f4b87 100644 --- a/runtime/druntime/Makefile +++ b/runtime/druntime/Makefile @@ -225,37 +225,37 @@ $(DOC_OUTPUT_DIR)/core_sys_bionic_%.html : import/core/sys/bionic/%.d $(DMD) $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_darwin_%.html : import/core/sys/darwin/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=osx -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_darwin_mach_%.html : import/core/sys/darwin/mach/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=osx -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_darwin_netinet_%.html : import/core/sys/darwin/netinet/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=osx -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_darwin_sys_%.html : import/core/sys/darwin/sys/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=osx -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_dragonflybsd_%.html : import/core/sys/dragonflybsd/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=dragonflybsd -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_dragonflybsd_netinet_%.html : import/core/sys/dragonflybsd/netinet/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=dragonflybsd -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_dragonflybsd_sys_%.html : import/core/sys/dragonflybsd/sys/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=dragonflybsd -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_elf_%.html : import/core/sys/elf/%.d $(DMD) $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_freebsd_%.html : import/core/sys/freebsd/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=freebsd -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_freebsd_netinet_%.html : import/core/sys/freebsd/netinet/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=freebsd -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_freebsd_sys_%.html : import/core/sys/freebsd/sys/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=freebsd -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_linux_%.html : import/core/sys/linux/%.d $(DMD) $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< @@ -266,6 +266,7 @@ $(DOC_OUTPUT_DIR)/core_sys_linux_netinet_%.html : import/core/sys/linux/netinet/ $(DOC_OUTPUT_DIR)/core_sys_linux_sys_%.html : import/core/sys/linux/sys/%.d $(DMD) $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< +# Note: no `-os=netbsd` option $(DOC_OUTPUT_DIR)/core_sys_netbsd_%.html : import/core/sys/netbsd/%.d $(DMD) $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< @@ -273,10 +274,10 @@ $(DOC_OUTPUT_DIR)/core_sys_netbsd_sys_%.html : import/core/sys/netbsd/sys/%.d $( $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_openbsd_%.html : import/core/sys/openbsd/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=openbsd -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_openbsd_sys_%.html : import/core/sys/openbsd/sys/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=openbsd -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_posix_%.html : import/core/sys/posix/%.d $(DMD) $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< @@ -297,16 +298,16 @@ $(DOC_OUTPUT_DIR)/core_sys_posix_sys_%.html : import/core/sys/posix/sys/%.d $(DM $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_solaris_%.html : import/core/sys/solaris/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=solaris -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_solaris_sys_%.html : import/core/sys/solaris/sys/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=solaris -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_windows_%.html : import/core/sys/windows/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=windows -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_windows_stdc_%.html : import/core/sys/windows/stdc/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=windows -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_thread.html : import/core/thread/package.d $(DMD) $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< diff --git a/runtime/druntime/src/core/sys/freebsd/config.d b/runtime/druntime/src/core/sys/freebsd/config.d index 932f166d2d..144ef05537 100644 --- a/runtime/druntime/src/core/sys/freebsd/config.d +++ b/runtime/druntime/src/core/sys/freebsd/config.d @@ -14,7 +14,8 @@ public import core.sys.posix.config; // NOTE: When adding newer versions of FreeBSD, verify all current versioned // bindings are still compatible with the release. - version (FreeBSD_16) enum __FreeBSD_version = 1600011; + version (CoreDdoc) enum __FreeBSD_version = 1600011; // keep at latest +else version (FreeBSD_16) enum __FreeBSD_version = 1600011; else version (FreeBSD_15) enum __FreeBSD_version = 1500063; else version (FreeBSD_14) enum __FreeBSD_version = 1400097; else version (FreeBSD_13) enum __FreeBSD_version = 1301000; From 787f91b8d33360346a937094ff409ca9e7fb69f3 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Fri, 6 Mar 2026 00:03:18 +0000 Subject: [PATCH 371/440] Remove CLI docs for `-debug=`, `-version=` (dlang/dmd!22692) They were removed in dlang/dmd!20713. --- dmd/cli.d | 8 -------- 1 file changed, 8 deletions(-) diff --git a/dmd/cli.d b/dmd/cli.d index 558f186890..9297cddc94 100644 --- a/dmd/cli.d +++ b/dmd/cli.d @@ -307,10 +307,6 @@ dmd -cov -unittest myprog.d "compile in debug code", `Compile in $(LINK2 spec/version.html#debug, debug) code`, ), - Option("debug=", - "compile in debug code <= level", - `Compile in $(LINK2 spec/version.html#debug, debug level) <= $(I level)`, - ), Option("debug=", "compile in debug code identified by ident", `Compile in $(LINK2 spec/version.html#debug, debug identifier) $(I ident)`, @@ -931,10 +927,6 @@ dmd -cov -unittest myprog.d Option("-version", "print compiler version and exit" ), - Option("version=", - "compile in version code >= level", - `Compile in $(LINK2 $(ROOT_DIR)spec/version.html#version, version level) >= $(I level)`, - ), Option("version=", "compile in version code identified by ident", `Compile in $(LINK2 $(ROOT_DIR)spec/version.html#version, version identifier) $(I ident)` From 1caace380822df5c12fd9c61c4254a01b065c3db Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Fri, 6 Mar 2026 22:46:38 +0000 Subject: [PATCH 372/440] Generate missing `sys/sysctl` HTML (dlang/dmd!22705) --- runtime/druntime/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/druntime/Makefile b/runtime/druntime/Makefile index 34480f4b87..3ccc20c19f 100644 --- a/runtime/druntime/Makefile +++ b/runtime/druntime/Makefile @@ -221,6 +221,7 @@ $(DOC_OUTPUT_DIR)/core_sync.html : import/core/sync/package.d $(DMD) $(DOC_OUTPUT_DIR)/core_sync_%.html : import/core/sync/%.d $(DMD) $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< +# FIXME enable CRuntime_Bionic $(DOC_OUTPUT_DIR)/core_sys_bionic_%.html : import/core/sys/bionic/%.d $(DMD) $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< From 6201faf6a45d0d359511aacf699deba663683818 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 7 Mar 2026 07:28:46 +0000 Subject: [PATCH 373/440] Also define `-os=linux` for Linux and Posix docs (dlang/dmd!22706) Follow up to https://github.com/dlang/dmd/pull/22691. --- runtime/druntime/Makefile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/runtime/druntime/Makefile b/runtime/druntime/Makefile index 3ccc20c19f..a7c04c04b9 100644 --- a/runtime/druntime/Makefile +++ b/runtime/druntime/Makefile @@ -223,7 +223,7 @@ $(DOC_OUTPUT_DIR)/core_sync_%.html : import/core/sync/%.d $(DMD) # FIXME enable CRuntime_Bionic $(DOC_OUTPUT_DIR)/core_sys_bionic_%.html : import/core/sys/bionic/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=linux -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_darwin_%.html : import/core/sys/darwin/%.d $(DMD) $(DMD) $(DDOCFLAGS) -os=osx -Df$@ project.ddoc $(DOCFMT) $< @@ -259,13 +259,13 @@ $(DOC_OUTPUT_DIR)/core_sys_freebsd_sys_%.html : import/core/sys/freebsd/sys/%.d $(DMD) $(DDOCFLAGS) -os=freebsd -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_linux_%.html : import/core/sys/linux/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=linux -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_linux_netinet_%.html : import/core/sys/linux/netinet/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=linux -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_linux_sys_%.html : import/core/sys/linux/sys/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=linux -Df$@ project.ddoc $(DOCFMT) $< # Note: no `-os=netbsd` option $(DOC_OUTPUT_DIR)/core_sys_netbsd_%.html : import/core/sys/netbsd/%.d $(DMD) @@ -280,23 +280,24 @@ $(DOC_OUTPUT_DIR)/core_sys_openbsd_%.html : import/core/sys/openbsd/%.d $(DMD) $(DOC_OUTPUT_DIR)/core_sys_openbsd_sys_%.html : import/core/sys/openbsd/sys/%.d $(DMD) $(DMD) $(DDOCFLAGS) -os=openbsd -Df$@ project.ddoc $(DOCFMT) $< +# Use -os=linux to define Posix version $(DOC_OUTPUT_DIR)/core_sys_posix_%.html : import/core/sys/posix/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=linux -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_posix_arpa_%.html : import/core/sys/posix/arpa/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=linux -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_posix_net_%.html : import/core/sys/posix/net/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=linux -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_posix_netinet_%.html : import/core/sys/posix/netinet/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=linux -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_posix_stdc_%.html : import/core/sys/posix/stdc/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=linux -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_posix_sys_%.html : import/core/sys/posix/sys/%.d $(DMD) - $(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $< + $(DMD) $(DDOCFLAGS) -os=linux -Df$@ project.ddoc $(DOCFMT) $< $(DOC_OUTPUT_DIR)/core_sys_solaris_%.html : import/core/sys/solaris/%.d $(DMD) $(DMD) $(DDOCFLAGS) -os=solaris -Df$@ project.ddoc $(DOCFMT) $< From 020c4f2ccf9e8546fcc3f571d35db43833e41c91 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Mon, 9 Mar 2026 23:08:40 +0000 Subject: [PATCH 374/440] [HTML docs] Generate missing files for `dmd` and `core` (dlang/dmd!22714) --- runtime/druntime/src/core/lifetime.d | 2 +- runtime/druntime/src/core/thread/context.d | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/druntime/src/core/lifetime.d b/runtime/druntime/src/core/lifetime.d index ad98b2f2c5..feacc9da56 100644 --- a/runtime/druntime/src/core/lifetime.d +++ b/runtime/druntime/src/core/lifetime.d @@ -2396,7 +2396,7 @@ template _d_delstructImpl(T) private enum errorMessage = "Cannot delete struct if compiling without support for runtime type information!"; /** - * TraceGC wrapper around $(REF _d_delstruct, core,lifetime,_d_delstructImpl). + * TraceGC wrapper around $(REF _d_delstruct, core,lifetime). * * Bugs: * This function template was ported from a much older runtime hook that diff --git a/runtime/druntime/src/core/thread/context.d b/runtime/druntime/src/core/thread/context.d index e477269b84..81b7478a6d 100644 --- a/runtime/druntime/src/core/thread/context.d +++ b/runtime/druntime/src/core/thread/context.d @@ -11,6 +11,7 @@ module core.thread.context; +/// struct StackContext { void* bstack, tstack; From 292f032181781dd51f774adfd6dfdb34e3a6b8a3 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Thu, 12 Mar 2026 14:18:57 +0100 Subject: [PATCH 375/440] Revert "Makefile: Double quote $(MAKE) variable to prevent word splitting (dlang/dmd!22678)" This reverts commit aa96544aa241c8ec6abc393840fd54d4d0df7698. --- runtime/druntime/Makefile | 12 ++++++------ runtime/druntime/posix.mak | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/runtime/druntime/Makefile b/runtime/druntime/Makefile index a7c04c04b9..1b5f4165ce 100644 --- a/runtime/druntime/Makefile +++ b/runtime/druntime/Makefile @@ -379,7 +379,7 @@ $(IMPDIR)/%.h : src/%.h ######################## Build DMD if non-existent ############################## ../generated/$(OS)/$(BUILD)/$(MODEL)/dmd$(DOTEXE): - "$(MAKE)" -C .. dmd BUILD=$(BUILD) OS=$(OS) MODEL=$(MODEL) DMD="" + $(MAKE) -C .. dmd BUILD=$(BUILD) OS=$(OS) MODEL=$(MODEL) DMD="" # alias using the absolute path (the Phobos Makefile specifies an absolute path) $(abspath ../generated/$(OS)/$(BUILD)/$(MODEL)/dmd$(DOTEXE)): ../generated/$(OS)/$(BUILD)/$(MODEL)/dmd$(DOTEXE) @@ -447,7 +447,7 @@ unittest : $(UT_MODULES) $(addsuffix /.run,$(ADDITIONAL_TESTS)) else unittest : unittest-debug unittest-release unittest-%: target - "$(MAKE)" -f $(MAKEFILE) unittest OS=$(OS) MODEL=$(MODEL) DMD=$(DMD) BUILD=$* + $(MAKE) -f $(MAKEFILE) unittest OS=$(OS) MODEL=$(MODEL) DMD=$(DMD) BUILD=$* endif ifeq ($(OS),linux) @@ -509,14 +509,14 @@ ifeq (linux,$(OS)) endif test/%/.run: test/%/Makefile $(DMD) - $(QUIET)"$(MAKE)" -C test/$* MODEL=$(MODEL) OS=$(OS) DMD=$(abspath $(DMD)) BUILD=$(BUILD) \ + $(QUIET)$(MAKE) -C test/$* MODEL=$(MODEL) OS=$(OS) DMD=$(abspath $(DMD)) BUILD=$(BUILD) \ DRUNTIME=$(abspath $(DRUNTIME)) DRUNTIMESO=$(abspath $(DRUNTIMESO)) LINKDL=$(LINKDL) \ QUIET=$(QUIET) TIMELIMIT='$(TIMELIMIT)' PIC=$(PIC) SHARED=$(SHARED) IS_MUSL=$(IS_MUSL) test/%/.clean: test/%/Makefile - $(QUIET)"$(MAKE)" -C test/$* MODEL=$(MODEL) OS=$(OS) BUILD=$(BUILD) clean + $(QUIET)$(MAKE) -C test/$* MODEL=$(MODEL) OS=$(OS) BUILD=$(BUILD) clean ifeq (0,$(BUILD_WAS_SPECIFIED)) - $(QUIET)"$(MAKE)" -C test/$* MODEL=$(MODEL) OS=$(OS) BUILD=debug clean + $(QUIET)$(MAKE) -C test/$* MODEL=$(MODEL) OS=$(OS) BUILD=debug clean endif #################### benchmark suite ########################## @@ -597,7 +597,7 @@ test_extractor: $(TESTS_EXTRACTOR) ################################################################################ betterc: | $(TESTS_EXTRACTOR) $(BETTERCTESTS_DIR)/.directory - "$(MAKE)" $$(find src -type f -name '*.d' | sed 's/[.]d/.betterc/') + $(MAKE) $$(find src -type f -name '*.d' | sed 's/[.]d/.betterc/') %.betterc: %.d | $(TESTS_EXTRACTOR) $(BETTERCTESTS_DIR)/.directory @$(TESTS_EXTRACTOR) --betterC --attributes betterC \ diff --git a/runtime/druntime/posix.mak b/runtime/druntime/posix.mak index df0213dbf6..062a7c12e7 100644 --- a/runtime/druntime/posix.mak +++ b/runtime/druntime/posix.mak @@ -5,7 +5,7 @@ $(warning ============================== ) # forward everything to Makefile target: - "$(MAKE)" -f Makefile $@ + $(MAKE) -f Makefile $@ %: - "$(MAKE)" -f Makefile $@ + $(MAKE) -f Makefile $@ From 6b5a336d7ce5de9a264c1443985f1255790d63b3 Mon Sep 17 00:00:00 2001 From: deadalnix Date: Thu, 12 Mar 2026 19:58:18 +0100 Subject: [PATCH 376/440] Add a configuration for the GC to try to keep its heap size below a certain size. (dlang/dmd!22721) --- runtime/druntime/src/core/gc/config.d | 6 +++++ .../core/internal/gc/impl/conservative/gc.d | 25 ++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/runtime/druntime/src/core/gc/config.d b/runtime/druntime/src/core/gc/config.d index 32de5ab140..c3b79e0926 100644 --- a/runtime/druntime/src/core/gc/config.d +++ b/runtime/druntime/src/core/gc/config.d @@ -25,6 +25,12 @@ struct Config @MemVal size_t minPoolSize = 1 << 20; // initial and minimum pool size (bytes) @MemVal size_t maxPoolSize = 64 << 20; // maximum pool size (bytes) @MemVal size_t incPoolSize = 3 << 20; // pool size increment (bytes) + + // Limit under which the GC will try to keep its heap (bytes) + // The GC does this on a best effort basis, and exceeding this size + // might lead to a performance cliff. + @MemVal size_t heapSizeLimit = size_t.max; + uint parallel = 99; // number of additional threads for marking (limited by cpuid.threadsPerCPU-1) float heapSizeFactor = 2.0; // heap size to used memory ratio string cleanup = "collect"; // select gc cleanup method none|collect|finalize diff --git a/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d b/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d index a693c361c1..1c7025a206 100644 --- a/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d +++ b/runtime/druntime/src/core/internal/gc/impl/conservative/gc.d @@ -2113,10 +2113,25 @@ struct Gcx */ void updateCollectThresholds() nothrow { - static float max(float a, float b) nothrow - { - return a >= b ? a : b; - } + import core.internal.util.math : min, max; + + // Reserve half of the remaining heap budget to small and large heaps. + immutable maxPageUsed = config.heapSizeLimit / PAGESIZE; + immutable usedPages = usedSmallPages + usedLargePages; + immutable heapBudget = maxPageUsed > usedPages + ? maxPageUsed - usedPages + : 0; + + immutable smTargetHeap = usedSmallPages + heapBudget / 2; + immutable lgTargetHeap = usedLargePages + heapBudget / 2; + + // Compute the target sizes based on the growth factor. + immutable smTargetGrowth = usedSmallPages * config.heapSizeFactor; + immutable lgTargetGrowth = usedLargePages * config.heapSizeFactor; + + // Collect when either is reached. + immutable smTarget = min(smTargetHeap, smTargetGrowth); + immutable lgTarget = min(lgTargetHeap, lgTargetGrowth); // instantly increases, slowly decreases static float smoothDecay(float oldVal, float newVal) nothrow @@ -2128,9 +2143,7 @@ struct Gcx return max(newVal, decay); } - immutable smTarget = usedSmallPages * config.heapSizeFactor; smallCollectThreshold = smoothDecay(smallCollectThreshold, smTarget); - immutable lgTarget = usedLargePages * config.heapSizeFactor; largeCollectThreshold = smoothDecay(largeCollectThreshold, lgTarget); } From 4976f2695ad80196aa7c7c7f9be3745a82bebb92 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Thu, 12 Mar 2026 12:37:58 -0700 Subject: [PATCH 377/440] Add AArch64 to src/core/thread/types.d (dlang/dmd!22722) --- runtime/druntime/src/core/thread/types.d | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/runtime/druntime/src/core/thread/types.d b/runtime/druntime/src/core/thread/types.d index c816010e5c..e630c39668 100644 --- a/runtime/druntime/src/core/thread/types.d +++ b/runtime/druntime/src/core/thread/types.d @@ -42,12 +42,21 @@ version (GNU) else enum isStackGrowingDown = false; } -else +else version (LDC) +{ + // The only LLVM targets as of LLVM 16 with stack growing *upwards* are + // apparently NVPTX and AMDGPU, both without druntime support. + // Note that there's an analogous `version = StackGrowsDown` in + // core.thread.fiber. + enum isStackGrowingDown = true; +} +else version (DigitalMars) { - version (X86) enum isStackGrowingDown = true; - else version (X86_64) enum isStackGrowingDown = true; - else static assert(0, "It is undefined how the stack grows on this architecture."); + // All dmd targets grow down + enum isStackGrowingDown = true; } +else + static assert(0, "It is undefined how the stack grows on this architecture."); package { From f6bb9c4a614c6a6411315a518e9c2ab6f5f19eb5 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Thu, 12 Mar 2026 17:07:21 -0700 Subject: [PATCH 378/440] add sections_darwin_rt.d (dlang/dmd!22723) --- runtime/druntime/src/rt/sections.d | 4 +++- .../rt/{sections_osx_x86_64.d => sections_osx_64.d} | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) rename runtime/druntime/src/rt/{sections_osx_x86_64.d => sections_osx_64.d} (94%) diff --git a/runtime/druntime/src/rt/sections.d b/runtime/druntime/src/rt/sections.d index ce5a6682df..98a09a94eb 100644 --- a/runtime/druntime/src/rt/sections.d +++ b/runtime/druntime/src/rt/sections.d @@ -45,9 +45,11 @@ else version (Solaris) else version (Darwin) { version (X86_64) - public import rt.sections_osx_x86_64; + public import rt.sections_osx_64; else version (X86) public import rt.sections_osx_x86; + else version (AArch64) + public import rt.sections_osx_64; else static assert(0, "unimplemented"); } diff --git a/runtime/druntime/src/rt/sections_osx_x86_64.d b/runtime/druntime/src/rt/sections_osx_64.d similarity index 94% rename from runtime/druntime/src/rt/sections_osx_x86_64.d rename to runtime/druntime/src/rt/sections_osx_64.d index 24c04a0ec7..5140826190 100644 --- a/runtime/druntime/src/rt/sections_osx_x86_64.d +++ b/runtime/druntime/src/rt/sections_osx_64.d @@ -7,9 +7,9 @@ * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). * (See accompanying file LICENSE) * Authors: Walter Bright, Sean Kelly, Martin Nowak, Jacob Carlborg - * Source: $(DRUNTIMESRC rt/_sections_osx_x86_64.d) + * Source: $(DRUNTIMESRC rt/_sections_osx_64.d) */ -module rt.sections_osx_x86_64; +module rt.sections_osx_64; version (OSX) version = Darwin; @@ -21,7 +21,12 @@ else version (WatchOS) version = Darwin; version (Darwin): -version (X86_64): + +version (X86_64) + version = X86_64_or_AArch64; +else version (AArch64) + version = X86_64_or_AArch64; +version (X86_64_or_AArch64): // debug = PRINTF; From 265fef8144eb1d58de60bc1e7717f76fb0417c5b Mon Sep 17 00:00:00 2001 From: hariprakazz Date: Fri, 13 Mar 2026 07:32:25 +0530 Subject: [PATCH 379/440] fix: include template argument types in ftime-trace events (dlang/dmd!22724) --- dmd/templatesem.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dmd/templatesem.d b/dmd/templatesem.d index a62b2bf59f..304a7a8fd1 100644 --- a/dmd/templatesem.d +++ b/dmd/templatesem.d @@ -47,6 +47,7 @@ import dmd.mtype; import dmd.opover; import dmd.optimize; import dmd.root.array; +import dmd.root.string : toDString; import dmd.common.outbuffer; import dmd.rootobject; import dmd.semantic2; @@ -911,11 +912,10 @@ void templateInstanceSemantic(TemplateInstance tempinst, Scope* sc, ArgumentList } timeTraceBeginEvent(TimeTraceEventType.sema1TemplateInstance); - scope (exit) timeTraceEndEvent(TimeTraceEventType.sema1TemplateInstance, tempinst); - + scope (exit) timeTraceEndEvent(TimeTraceEventType.sema1TemplateInstance, tempinst, + () => tempinst.toPrettyChars().toDString()); // Get the enclosing template instance from the scope tinst tempinst.tinst = sc.tinst; - // Get the instantiating module from the scope minst tempinst.minst = sc.minst; // https://issues.dlang.org/show_bug.cgi?id=10920 From 538b4adbaf1c37b11018bcd0ea4f8abd24c3a5b6 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Fri, 13 Mar 2026 13:35:13 +0800 Subject: [PATCH 380/440] [root/ctfloat.d] yl2x_supported iff real_t == real (dlang/dmd!22727) --- dmd/root/ctfloat.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dmd/root/ctfloat.d b/dmd/root/ctfloat.d index ef4ed4ffc6..ae1a8079b2 100644 --- a/dmd/root/ctfloat.d +++ b/dmd/root/ctfloat.d @@ -44,7 +44,8 @@ extern (C++) struct CTFloat else version (AArch64) enum yl2x_supported = false; // no x87 FPU else - enum yl2x_supported = __traits(compiles, core.math.yl2x(1.0L, 2.0L)); + enum yl2x_supported = is(real_t == real) && + __traits(compiles, core.math.yl2x(1.0L, 2.0L)); enum yl2xp1_supported = yl2x_supported; From 2faf06f12cf131e24e3ac7a5ef73c784014f5248 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Fri, 13 Mar 2026 00:17:25 -0700 Subject: [PATCH 381/440] get osthread.d to compile with AArch64 (dlang/dmd!22729) --- runtime/druntime/src/core/thread/osthread.d | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/runtime/druntime/src/core/thread/osthread.d b/runtime/druntime/src/core/thread/osthread.d index c24dde4a5d..21b0b6402e 100644 --- a/runtime/druntime/src/core/thread/osthread.d +++ b/runtime/druntime/src/core/thread/osthread.d @@ -1529,6 +1529,27 @@ in (fn) mov sp[RBP], RSP; } } + else version (AArch64) + { + // Callee-save registers, x19-x28 according to AAPCS64, section + // 5.1.1. Include x29 fp because it optionally can be a callee + // saved reg + size_t[11] regs = void; + // store the registers in pairs + asm pure nothrow @nogc + { + /* + stp x19, x20, regs[0]; + stp x21, x22, regs[2]; + stp x23, x24, regs[4]; + stp x25, x26, regs[6]; + stp x27, x28, regs[8]; + str x29, regs[10]; + mov [sp], sp; + */ + } + assert(0, "implement AArch64 inline assembler for callWithStackShell()"); + } else { static assert(false, "Architecture not supported."); @@ -1578,6 +1599,8 @@ private extern(D) void* getStackTop() nothrow @nogc asm pure nothrow @nogc { naked; mov EAX, ESP; ret; } else version (D_InlineAsm_X86_64) asm pure nothrow @nogc { naked; mov RAX, RSP; ret; } + else version (AArch64) + asm pure nothrow @nogc { naked; mov x0, SP; ret; } else version (GNU) return __builtin_frame_address(0); else From 6ce59df4675fac03d52f914f47663ac27cb46186 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Fri, 13 Mar 2026 03:44:54 -0700 Subject: [PATCH 382/440] stub out atomic functions for AArch64 (dlang/dmd!22728) --- runtime/druntime/src/core/internal/atomic.d | 77 +++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/runtime/druntime/src/core/internal/atomic.d b/runtime/druntime/src/core/internal/atomic.d index 43e50acacb..95749194f0 100644 --- a/runtime/druntime/src/core/internal/atomic.d +++ b/runtime/druntime/src/core/internal/atomic.d @@ -13,6 +13,83 @@ module core.internal.atomic; import core.atomic : has128BitCAS, MemoryOrder; version (DigitalMars) +version (AArch64) +{ + /* These functions are all stubbed out. They await someone who knows what + they are doing with AArch64 atomics. + */ + enum IsAtomicLockFree(T) = T.sizeof <= size_t.sizeof * 2; + + inout(T) atomicLoad(MemoryOrder order = MemoryOrder.seq, T)(inout(T)* src) pure nothrow @nogc @trusted + if (CanCAS!T) + { + return *src; + } + + void atomicStore(MemoryOrder order = MemoryOrder.seq, T)(T* dest, T value) pure nothrow @nogc @trusted + if (CanCAS!T) + { + *dest = value; + } + + T atomicFetchAdd(MemoryOrder order = MemoryOrder.seq, bool result = true, T)(T* dest, T value) pure nothrow @nogc @trusted + if (is(T : ulong)) + { + return *dest + value; + } + + T atomicFetchSub(MemoryOrder order = MemoryOrder.seq, bool result = true, T)(T* dest, T value) pure nothrow @nogc @trusted + if (is(T : ulong)) + { + return atomicFetchAdd(dest, cast(T)-cast(IntOrLong!T)value); + } + + T atomicExchange(MemoryOrder order = MemoryOrder.seq, bool result = true, T)(T* dest, T value) pure nothrow @nogc @trusted + if (CanCAS!T) + { + size_t storage = void; + return *cast(T*)&storage; + } + + alias atomicCompareExchangeWeak = atomicCompareExchangeStrong; + + bool atomicCompareExchangeStrong(MemoryOrder succ = MemoryOrder.seq, MemoryOrder fail = MemoryOrder.seq, T)(T* dest, T* compare, T value) pure nothrow @nogc @trusted + if (CanCAS!T) + { + if (*dest != *compare) + { + *compare = *dest; + return false; + } + *dest = value; + return true; + } + + alias atomicCompareExchangeWeakNoResult = atomicCompareExchangeStrongNoResult; + + bool atomicCompareExchangeStrongNoResult(MemoryOrder succ = MemoryOrder.seq, MemoryOrder fail = MemoryOrder.seq, T)(T* dest, const T compare, T value) pure nothrow @nogc @trusted + if (CanCAS!T) + { + if (*dest != *compare) + return false; + *dest = value; + return true; + } + + void atomicFence(MemoryOrder order = MemoryOrder.seq)() pure nothrow @nogc @trusted + { + } + + void atomicSignalFence(MemoryOrder order = MemoryOrder.seq)() pure nothrow @nogc @trusted + { + // no-op, dmd doesn't reorder instructions + } + + void pause() pure nothrow @nogc @trusted + { + } +} +else // X86 and X86_64 { private { From ae7d3089dcf42285f7c09e15241c6e4d7592c76e Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Fri, 13 Mar 2026 17:26:41 -0700 Subject: [PATCH 383/440] Add TODO AArch64 to find places that need work in druntime (dlang/dmd!22730) --- runtime/druntime/src/core/internal/atomic.d | 1 + runtime/druntime/src/core/thread/osthread.d | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime/druntime/src/core/internal/atomic.d b/runtime/druntime/src/core/internal/atomic.d index 95749194f0..2f44603448 100644 --- a/runtime/druntime/src/core/internal/atomic.d +++ b/runtime/druntime/src/core/internal/atomic.d @@ -17,6 +17,7 @@ version (AArch64) { /* These functions are all stubbed out. They await someone who knows what they are doing with AArch64 atomics. + TODO AArch64 */ enum IsAtomicLockFree(T) = T.sizeof <= size_t.sizeof * 2; diff --git a/runtime/druntime/src/core/thread/osthread.d b/runtime/druntime/src/core/thread/osthread.d index 21b0b6402e..10d5403be5 100644 --- a/runtime/druntime/src/core/thread/osthread.d +++ b/runtime/druntime/src/core/thread/osthread.d @@ -1548,7 +1548,7 @@ in (fn) mov [sp], sp; */ } - assert(0, "implement AArch64 inline assembler for callWithStackShell()"); + assert(0, "implement AArch64 inline assembler for callWithStackShell()"); // TODO AArch64 } else { @@ -1600,7 +1600,7 @@ private extern(D) void* getStackTop() nothrow @nogc else version (D_InlineAsm_X86_64) asm pure nothrow @nogc { naked; mov RAX, RSP; ret; } else version (AArch64) - asm pure nothrow @nogc { naked; mov x0, SP; ret; } + asm pure nothrow @nogc { naked; mov x0, SP; ret; } // TODO AArch64 else version (GNU) return __builtin_frame_address(0); else From 474978801884ba846b645890e1bcfb8858c3d76d Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 14 Mar 2026 00:15:25 -0700 Subject: [PATCH 384/440] more AArch64 special cases (dlang/dmd!22731) --- runtime/druntime/src/core/internal/atomic.d | 2 +- runtime/druntime/src/core/thread/osthread.d | 5 ++++- runtime/druntime/src/rt/alloca.d | 5 +++++ runtime/druntime/src/rt/cmath2.d | 18 ++++++++++------- runtime/druntime/src/rt/deh_win64_posix.d | 22 +++++++++++++++++++++ runtime/druntime/src/rt/llmath.d | 8 ++++++++ 6 files changed, 51 insertions(+), 9 deletions(-) diff --git a/runtime/druntime/src/core/internal/atomic.d b/runtime/druntime/src/core/internal/atomic.d index 2f44603448..9daddf844a 100644 --- a/runtime/druntime/src/core/internal/atomic.d +++ b/runtime/druntime/src/core/internal/atomic.d @@ -71,7 +71,7 @@ version (AArch64) bool atomicCompareExchangeStrongNoResult(MemoryOrder succ = MemoryOrder.seq, MemoryOrder fail = MemoryOrder.seq, T)(T* dest, const T compare, T value) pure nothrow @nogc @trusted if (CanCAS!T) { - if (*dest != *compare) + if (*dest != compare) return false; *dest = value; return true; diff --git a/runtime/druntime/src/core/thread/osthread.d b/runtime/druntime/src/core/thread/osthread.d index 10d5403be5..d2e6060a28 100644 --- a/runtime/druntime/src/core/thread/osthread.d +++ b/runtime/druntime/src/core/thread/osthread.d @@ -1600,7 +1600,10 @@ private extern(D) void* getStackTop() nothrow @nogc else version (D_InlineAsm_X86_64) asm pure nothrow @nogc { naked; mov RAX, RSP; ret; } else version (AArch64) - asm pure nothrow @nogc { naked; mov x0, SP; ret; } // TODO AArch64 + //asm pure nothrow @nogc { naked; mov x0, SP; ret; } // TODO AArch64 + { + return null; + } else version (GNU) return __builtin_frame_address(0); else diff --git a/runtime/druntime/src/rt/alloca.d b/runtime/druntime/src/rt/alloca.d index cacf8c7614..787ae2cc02 100644 --- a/runtime/druntime/src/rt/alloca.d +++ b/runtime/druntime/src/rt/alloca.d @@ -198,6 +198,11 @@ extern (C) void* __alloca(int nbytes) } } } + else version (AArch64) + { + import core.stdc.stdlib : malloc; + return malloc(nbytes); // TODO AArch64 + } else static assert(0); } diff --git a/runtime/druntime/src/rt/cmath2.d b/runtime/druntime/src/rt/cmath2.d index 219105ed8d..45fae2a20d 100644 --- a/runtime/druntime/src/rt/cmath2.d +++ b/runtime/druntime/src/rt/cmath2.d @@ -1,17 +1,14 @@ /** - * Runtime support for complex arithmetic code generation (for Posix). + * Runtime support for Intel x87 complex arithmetic code generation (for Posix). * * Copyright: Copyright Digital Mars 2001 - 2011. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). + * License: Distributed under the Boost Software License, Version 1.0. + * See accompanying file LICENSE or copy at + * $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Authors: Walter Bright, Sean Kelly * Source: $(DRUNTIMESRC rt/_cmath2.d) */ -/* Copyright Digital Mars 2001 - 2011. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ module rt.cmath2; import core.stdc.math : fabs; @@ -20,6 +17,13 @@ debug import core.stdc.stdio : printf; extern (C): +version (D_InlineAsm_X86) + version = X87; +version (D_InlineAsm_X86_64) + version = X87; + +version (X87): + /**************************** * Multiply two complex floating point numbers, x and y. * Input: diff --git a/runtime/druntime/src/rt/deh_win64_posix.d b/runtime/druntime/src/rt/deh_win64_posix.d index 2acdbf8852..c99a0bf299 100644 --- a/runtime/druntime/src/rt/deh_win64_posix.d +++ b/runtime/druntime/src/rt/deh_win64_posix.d @@ -111,6 +111,12 @@ private void terminate() { + version (AArch64) + { + int* p = null; + *p = 0; // TODO AArch64 + } + else asm { hlt ; @@ -242,6 +248,10 @@ extern (C) void _d_throwc(Throwable h) { mov regebp,RBP ; } + else version (AArch64) + { + assert(0); // TODO AArch64 + } else static assert(0); @@ -407,6 +417,10 @@ extern (C) void _d_throwc(Throwable h) mov RSP,RAX ; // reset stack ret ; // jump to catch block } + else version (AArch64) + { + assert(0); // TODO AArch64 + } else static assert(0); } @@ -456,6 +470,10 @@ extern (C) void _d_throwc(Throwable h) pop RBX ; add RSP,8 ; } + else version (AArch64) + { + assert(0); // TODO AArch64 + } else static assert(0); } @@ -485,6 +503,10 @@ extern (C) void _d_throwc(Throwable h) pop RBX ; add RSP,8 ; } + else version (AArch64) + { + assert(0); // TODO AArch64 + } else static assert(0); } diff --git a/runtime/druntime/src/rt/llmath.d b/runtime/druntime/src/rt/llmath.d index 423022e56d..8599223420 100644 --- a/runtime/druntime/src/rt/llmath.d +++ b/runtime/druntime/src/rt/llmath.d @@ -188,6 +188,8 @@ quo1: // Quotient is 1 } else version (D_InlineAsm_X86_64) assert(0); + else version (AArch64) + assert(0); else static assert(0); } @@ -356,6 +358,8 @@ quo1: // Quotient is 1 } else version (D_InlineAsm_X86_64) assert(0); + else version (AArch64) + assert(0); else static assert(0); } @@ -433,6 +437,8 @@ L12: jmp __ULDIV2__ ; } else version (D_InlineAsm_X86_64) assert(0); + else version (AArch64) + assert(0); else static assert(0); } @@ -492,6 +498,8 @@ L12: jmp __ULDIV__ ; } else version (D_InlineAsm_X86_64) assert(0); + else version (AArch64) + assert(0); else static assert(0); } From 4224a7a860672f7b8538f4ae20d7c9f541e474f1 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 14 Mar 2026 23:28:33 +0000 Subject: [PATCH 385/440] [dmd/cli.d] HTML fixes (dlang/dmd!22733) --- dmd/cli.d | 60 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/dmd/cli.d b/dmd/cli.d index 9297cddc94..9970290c00 100644 --- a/dmd/cli.d +++ b/dmd/cli.d @@ -208,7 +208,7 @@ struct Usage ), Option("check=[assert|bounds|in|invariant|out|switch][=[on|off]]", "enable or disable specific checks", - `Overrides default, -boundscheck, -release and -unittest options to enable or disable specific checks. + q"{Overrides default, `-boundscheck`, `-release` and `-unittest` options to enable or disable specific checks. $(UL $(LI $(B assert): assertion checking) $(LI $(B bounds): array bounds) @@ -220,7 +220,7 @@ struct Usage $(UL $(LI $(B on) or not specified: specified check is enabled.) $(LI $(B off): specified check is disabled.) - )` + )}" ), Option("check=[h|help|?]", "list information on all available checks" @@ -311,14 +311,14 @@ dmd -cov -unittest myprog.d "compile in debug code identified by ident", `Compile in $(LINK2 spec/version.html#debug, debug identifier) $(I ident)`, ), - Option("debuglib=", - "set symbolic debug library to name", + Option("debuglib=", + "set symbolic debug library to libname", `Link in $(I libname) as the default library when compiling for symbolic debugging instead of $(B $(LIB)). If $(I libname) is not supplied, then no default library is linked in.` ), - Option("defaultlib=", - "set default library to name", + Option("defaultlib=", + "set default library to libname", `Link in $(I libname) as the default library when not compiling for symbolic debugging instead of $(B $(LIB)). If $(I libname) is not supplied, then no default library is linked in.`, @@ -333,8 +333,8 @@ dmd -cov -unittest myprog.d With $(I filename), write module dependencies as text to $(I filename) (only imports).`, ), - Option("dllimport=", - "Windows only: select symbols to dllimport (none/defaultLibsOnly/externalOnly/all)", + Option("dllimport=[none|defaultLibsOnly|externalOnly|all]", + "Windows only: select symbols to dllimport", `Which symbols to dllimport implicitly if not defined in a module that is being compiled $(UL $(LI $(I none): None) @@ -349,7 +349,8 @@ dmd -cov -unittest myprog.d ), Option("extern-std=", "set C++ name mangling compatibility with ", - "Standards supported are: + "set C++ name mangling compatibility with . + Standards supported are: $(UL $(LI $(I c++98): Use C++98 name mangling, Sets `__traits(getTargetInfo, \"cppStd\")` to `199711`) @@ -396,7 +397,7 @@ dmd -cov -unittest myprog.d Set too low, and the profiler overhead will be larger, and the output will be cluttered with tiny events." ), Option("ftime-trace-file=", - "specify output file for -ftime-trace", + "specify output file for `-ftime-trace`", "By default, the output name is the same as the first object file name, but with the `.time-trace` extension appended. A different filename can be chosen with this option, including a path relative to the current directory or an absolute path." ), @@ -442,18 +443,20 @@ dmd -cov -unittest myprog.d Option("Hf=", "write 'header' file to filename" ), - Option("HC[=[?|h|help|silent|verbose]]", + Option("HC=[silent|verbose]", "write C++ 'header' equivalent to stdout", - `write C++ 'header' equivalent to stdout configured with:", + `write C++ 'header' equivalent to stdout configured with: $(DL - $(DT ?|h|help)$(DD list available options for C++ 'header' file generation) $(DT silent)$(DD only list extern(C[++]) declarations (default)) $(DT verbose)$(DD also add comments for ignored declarations (e.g. extern(D))) )`, ), + Option("HC=[?|h|help]", + "list available options for C++ 'header' file generation" + ), Option("HCd=", "write C++ 'header' file to directory", - "write C++ 'header' file to directory, ignored if -HCf= is not present", + "write C++ 'header' file to directory, ignored if `-HCf=` is not present", ), Option("HCf=", "write C++ 'header' file to filename instead of stdout" @@ -554,7 +557,7 @@ dmd -cov -unittest myprog.d $(P Note that multiple `-i=...` options are allowed, each one adds a pattern.)}" ), - Option("identifiers=", + Option("identifiers=[UAX31|c99|c11|all]", "Specify the non-ASCII tables for D identifiers", `Set the identifier table to use for the non-ASCII values. $(UL @@ -564,7 +567,7 @@ dmd -cov -unittest myprog.d $(LI $(I all): All, the least restrictive set, which comes with all others (default)) )` ), - Option("identifiers-importc=
", + Option("identifiers-importc=[UAX31|c99|c11|all]", "Specify the non-ASCII tables for ImportC identifiers", `Set the identifier table to use for the non-ASCII values. $(UL @@ -589,7 +592,7 @@ dmd -cov -unittest myprog.d $(LINK2 $(ROOT_DIR)spec/expression.html#ImportExpression, $(I ImportExpression))s. This switch is required in order to use $(I ImportExpression)s. $(I path) is a ; separated - list of paths. Multiple $(B -J)'s can be used, and the paths + list of paths. Multiple $(TT -J)'s can be used, and the paths are searched in the same order.`, ), Option("L=", @@ -621,7 +624,7 @@ dmd -cov -unittest myprog.d cast(TargetOS) (TargetOS.all & ~cast(uint)TargetOS.DragonFlyBSD) // available on all OS'es except DragonFly, which does not support 32-bit binaries ), Option("m32mscoff", - "generate 32 bit code and write MS-COFF object files (deprecated use -m32)", + "generate 32 bit code and write MS-COFF object files (deprecated use `-m32`)", TargetOS.Windows ), Option("m64", @@ -642,7 +645,7 @@ dmd -cov -unittest myprog.d `Print dependencies in Makefile compatible format. If filename is omitted, it prints to stdout. The emitted targets are the compiled artifacts (executable, object files, libraries). - The emitted dependencies are imported modules and imported string files (via $(B -J) switch). + The emitted dependencies are imported modules and imported string files (via $(SWLINK -J) switch). Special characters in a dependency or target filename are escaped in the GNU Make manner. `, ), @@ -676,7 +679,6 @@ dmd -cov -unittest myprog.d `Set the target architecture for code generation, where: $(DL - $(DT help)$(DD list alternatives) $(DT baseline)$(DD the minimum architecture for the target platform (default)) $(DT avx)$(DD generate $(LINK2 https://en.wikipedia.org/wiki/Advanced_Vector_Extensions, AVX) @@ -717,7 +719,7 @@ dmd -cov -unittest myprog.d can be omitted if they are the same.`, ), Option("noboundscheck", - "no array bounds checking (deprecated, use -boundscheck=off)", + "no array bounds checking (deprecated, use `-boundscheck=off`)", `Turns off all array bounds checking, even for safe functions. $(RED Deprecated (use $(TT $(SWLINK -boundscheck)=off) instead).)`, ), @@ -790,7 +792,7 @@ dmd -cov -unittest myprog.d ), Option("preview=", "enable an upcoming language change identified by 'name'", - `Preview an upcoming language change identified by $(I id)`, + `Preview an upcoming language change identified by `, ), Option("preview=[h|help|?]", "list all upcoming language changes" @@ -842,7 +844,7 @@ dmd -cov -unittest myprog.d ), Option("revert=", "revert language change identified by 'name'", - `Revert language change identified by $(I id)`, + `Revert language change identified by `, ), Option("revert=[h|help|?]", "list all revertable language changes" @@ -852,7 +854,7 @@ dmd -cov -unittest myprog.d `Compile, link, and run the program $(I srcfile) with the rest of the command line, $(I args...), as the arguments to the program. - No .$(OBJEXT) or executable file is left behind.` + No $(TT .$(OBJEXT)) or executable file is left behind.` ), Option("shared", "generate shared library (DLL)", @@ -877,7 +879,7 @@ dmd -cov -unittest myprog.d ), Option("transition=", "help with language change identified by 'name'", - `Show additional info about language change identified by $(I id)`, + `Show additional info about language change identified by `, ), Option("transition=[h|help|?]", "list all language changes" @@ -934,11 +936,11 @@ dmd -cov -unittest myprog.d Option("vgc", "list all gc allocations including hidden ones" ), - Option("visibility=", - "default visibility of symbols (default/hidden/public)", + Option("visibility=[default|hidden|public]", + "default visibility of symbols", "$(UL - $(LI $(I default): Hidden for Windows targets without -shared, otherwise public) - $(LI $(I hidden): Only export symbols marked with 'export') + $(LI $(I default): for Windows targets without $(SWLINK -shared), otherwise ) + $(LI $(I hidden): Only export symbols marked with `export`) $(LI $(I public): Export all symbols) )", ), From 1d4cc3e70506bf3b09dbd8642532ab968e65be79 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Sun, 15 Mar 2026 11:13:29 +0800 Subject: [PATCH 386/440] [root/longdouble.d] make `ld_cmp` use a regular return (dlang/dmd!22738) instead of asm --- dmd/root/longdouble.d | 1 + 1 file changed, 1 insertion(+) diff --git a/dmd/root/longdouble.d b/dmd/root/longdouble.d index 6fa2b7b61c..7c6ca5c70a 100644 --- a/dmd/root/longdouble.d +++ b/dmd/root/longdouble.d @@ -563,6 +563,7 @@ int ld_cmp(longdouble_soft x, longdouble_soft y) mov res, EAX; } } + return res; } From b472b2b86f41e51e74bfe0e51c2656bce38f9f4b Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sun, 15 Mar 2026 11:23:52 +0000 Subject: [PATCH 387/440] [dmd/cli.d] Manually italicize `foo` in help/ddoc text for `` in flag string (dlang/dmd!22741) --- dmd/cli.d | 66 +++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/dmd/cli.d b/dmd/cli.d index 9970290c00..b15212fa41 100644 --- a/dmd/cli.d +++ b/dmd/cli.d @@ -256,14 +256,14 @@ struct Usage )` ), Option("conf=", - "use config file at filename" + "use config file at " ), Option("cov", "do code coverage analysis" ), Option("cov=ctfe", "Include code executed during CTFE in coverage report"), Option("cov=", - "require at least nnn% code coverage", + "require at least % code coverage", `Perform $(LINK2 $(ROOT_DIR)code_coverage.html, code coverage analysis) and generate $(TT .lst) file with report.) --- @@ -272,7 +272,7 @@ dmd -cov -unittest myprog.d `, ), Option("cpp=", - "use filename as the name of the C preprocessor to use for ImportC files", + "use as the name of the C preprocessor to use for ImportC files", `Normally the C preprocessor used by the associated C compiler is used to preprocess ImportC files, this is overridden by the $(TT -cpp) switch.` @@ -284,13 +284,13 @@ dmd -cov -unittest myprog.d `, ), Option("Dd", - "write documentation file to directory", + "write documentation file to ", `Write documentation file to $(I directory) . $(SWLINK -op) can be used if the original package hierarchy should be retained`, ), Option("Df", - "write documentation file to filename" + "write documentation file to " ), Option("d", "silently allow deprecated features and symbols", @@ -308,17 +308,17 @@ dmd -cov -unittest myprog.d `Compile in $(LINK2 spec/version.html#debug, debug) code`, ), Option("debug=", - "compile in debug code identified by ident", + "compile in debug code identified by ", `Compile in $(LINK2 spec/version.html#debug, debug identifier) $(I ident)`, ), Option("debuglib=", - "set symbolic debug library to libname", + "set symbolic debug library to ", `Link in $(I libname) as the default library when compiling for symbolic debugging instead of $(B $(LIB)). If $(I libname) is not supplied, then no default library is linked in.` ), Option("defaultlib=", - "set default library to libname", + "set default library to ", `Link in $(I libname) as the default library when not compiling for symbolic debugging instead of $(B $(LIB)). If $(I libname) is not supplied, then no default library is linked in.`, @@ -327,7 +327,7 @@ dmd -cov -unittest myprog.d "print module dependencies (imports/file/version/debug/lib)" ), Option("deps=", - "write module dependencies to filename (only imports)", + "write module dependencies to (only imports)", `Without $(I filename), print module dependencies (imports/file/version/debug/lib). With $(I filename), write module dependencies as text to $(I filename) @@ -415,7 +415,7 @@ dmd -cov -unittest myprog.d ), Option("gdwarf=", "add DWARF symbolic debug info", - "The value of version may be 3, 4 or 5, defaulting to 3.", + "The value of may be 3, 4 or 5, defaulting to 3.", cast(TargetOS) (TargetOS.all & ~cast(uint)TargetOS.Windows) ), Option("gf", @@ -435,13 +435,13 @@ dmd -cov -unittest myprog.d `Generate $(RELATIVE_LINK2 $(ROOT_DIR)interface-files, D interface file)`, ), Option("Hd=", - "write 'header' file to directory", + "write 'header' file to ", `Write D interface file to $(I directory). $(SWLINK -op) can be used if the original package hierarchy should be retained.`, ), Option("Hf=", - "write 'header' file to filename" + "write 'header' file to " ), Option("HC=[silent|verbose]", "write C++ 'header' equivalent to stdout", @@ -455,17 +455,17 @@ dmd -cov -unittest myprog.d "list available options for C++ 'header' file generation" ), Option("HCd=", - "write C++ 'header' file to directory", - "write C++ 'header' file to directory, ignored if `-HCf=` is not present", + "write C++ 'header' file to ", + "write C++ 'header' file to , ignored if `-HCf=` is not present", ), Option("HCf=", - "write C++ 'header' file to filename instead of stdout" + "write C++ 'header' file to instead of stdout" ), Option("-help", "print help and exit" ), Option("I=", - "look for imports also in directory", + "look for imports also in ", q"{$(P Adds $(I directory) to the list of paths to be searched for imports. Multiple `-I`'s can be used, and the paths are searched in the same order.) @@ -587,7 +587,7 @@ dmd -cov -unittest myprog.d it more difficult to use a debugger on it.`, ), Option("J=", - "look for string imports also in directory", + "look for string imports also in ", `Where to look for files for $(LINK2 $(ROOT_DIR)spec/expression.html#ImportExpression, $(I ImportExpression))s. This switch is required in order to use $(I ImportExpression)s. @@ -596,7 +596,7 @@ dmd -cov -unittest myprog.d are searched in the same order.`, ), Option("L=", - "pass linkerflag to link", + "pass to link", `Pass $(I linkerflag) to the $(WINDOWS linker $(OPTLINK)) $(UNIX linker), for example, ld`, @@ -641,9 +641,9 @@ dmd -cov -unittest myprog.d in a library without having to manually define an entry-point function.`, ), Option("makedeps[=]", - "print dependencies in Makefile compatible format to filename or stdout.", + "print dependencies in Makefile compatible format to or stdout.", `Print dependencies in Makefile compatible format. - If filename is omitted, it prints to stdout. + If is omitted, it prints to stdout. The emitted targets are the compiled artifacts (executable, object files, libraries). The emitted dependencies are imported modules and imported string files (via $(SWLINK -J) switch). Special characters in a dependency or target filename are escaped in the GNU Make manner. @@ -674,8 +674,8 @@ dmd -cov -unittest myprog.d "generate linker .map file", `Generate a $(TT .map) file`, ), - Option("mcpu=", - "generate instructions for architecture identified by 'id'", + Option("mcpu=[baseline|avx|native]", + "Set the target architecture for code generation", `Set the target architecture for code generation, where: $(DL @@ -745,14 +745,14 @@ dmd -cov -unittest myprog.d conjuction with $(SWLINK -D) or $(SWLINK -H) flags.` ), Option("od=", - "write object & library files to directory", - `Write object files relative to directory $(I objdir) + "write object & library files to ", + `Write object files relative to $(I directory) instead of to the current directory. $(SWLINK -op) can be used if the original package hierarchy should be retained`, ), Option("of=", - "name output file to filename", + "name output file to ", `Set output file name to $(I filename) in the output directory. The output file can be an object file, executable file, or library file depending on the other @@ -785,13 +785,13 @@ dmd -cov -unittest myprog.d )` ), Option("P=", - "pass preprocessorflag to C preprocessor", + "pass to C preprocessor", `Pass $(I preprocessorflag) to $(WINDOWS cl.exe) $(UNIX cpp)`, ), Option("preview=", - "enable an upcoming language change identified by 'name'", + "enable an upcoming language change identified by ", `Preview an upcoming language change identified by `, ), Option("preview=[h|help|?]", @@ -843,14 +843,14 @@ dmd -cov -unittest myprog.d are undefined behaviour.` ), Option("revert=", - "revert language change identified by 'name'", + "revert language change identified by ", `Revert language change identified by `, ), Option("revert=[h|help|?]", "list all revertable language changes" ), Option("run ", - "compile, link, and run the program srcfile", + "compile, link, and run the program ", `Compile, link, and run the program $(I srcfile) with the rest of the command line, $(I args...), as the arguments to the program. @@ -878,7 +878,7 @@ dmd -cov -unittest myprog.d " ), Option("transition=", - "help with language change identified by 'name'", + "help with language change identified by ", `Show additional info about language change identified by `, ), Option("transition=[h|help|?]", @@ -930,7 +930,7 @@ dmd -cov -unittest myprog.d "print compiler version and exit" ), Option("version=", - "compile in version code identified by ident", + "compile in version code identified by ", `Compile in $(LINK2 $(ROOT_DIR)spec/version.html#version, version identifier) $(I ident)` ), Option("vgc", @@ -973,10 +973,10 @@ dmd -cov -unittest myprog.d "generate JSON file" ), Option("Xf=", - "write JSON file to filename" + "write JSON file to " ), Option("Xcc=", - "pass driverflag to linker driver (cc)", + "pass to linker driver (cc)", "Pass $(I driverflag) to the linker driver (`$CC` or `cc`)", cast(TargetOS) (TargetOS.all & ~cast(uint)TargetOS.Windows) ), From eee53a2bb71f811d09e2d677cb71acfe04fd7111 Mon Sep 17 00:00:00 2001 From: dd Date: Mon, 16 Mar 2026 19:08:33 -0400 Subject: [PATCH 388/440] Druntime: Select newer NetBSD time bindings (dlang/dmd!22720) * Correct NetBSD mangle for core.sys.posix.stdc.time * Correct NetBSD mangle for core.sys.posix.time * Correct NetBSD bindings for core.sys.posix.sys.select * Correct NetBSD bindings for core.sys.posix.sys.statvfs * Correct NetBSD bindings for core.sys.posix.sys.time * time_t is 64-bit on with newer signatures * clock_t is unsigned int, not c_long * suseconds_t is int, not c_long --- runtime/druntime/src/core/sys/posix/stdc/time.d | 1 + runtime/druntime/src/core/sys/posix/sys/select.d | 2 ++ runtime/druntime/src/core/sys/posix/sys/statvfs.d | 2 ++ runtime/druntime/src/core/sys/posix/sys/time.d | 4 ++++ runtime/druntime/src/core/sys/posix/sys/types.d | 6 +++--- runtime/druntime/src/core/sys/posix/time.d | 10 ++++++++++ 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/runtime/druntime/src/core/sys/posix/stdc/time.d b/runtime/druntime/src/core/sys/posix/stdc/time.d index dee81ecc34..abeb715ad7 100644 --- a/runtime/druntime/src/core/sys/posix/stdc/time.d +++ b/runtime/druntime/src/core/sys/posix/stdc/time.d @@ -146,6 +146,7 @@ else version (FreeBSD) else version (NetBSD) { /// + pragma(mangle, "__tzset50") void tzset(); // non-standard /// extern __gshared const(char)*[2] tzname; // non-standard diff --git a/runtime/druntime/src/core/sys/posix/sys/select.d b/runtime/druntime/src/core/sys/posix/sys/select.d index 064dfbcc5f..5152d0fe17 100644 --- a/runtime/druntime/src/core/sys/posix/sys/select.d +++ b/runtime/druntime/src/core/sys/posix/sys/select.d @@ -268,7 +268,9 @@ else version (NetBSD) _p.fds_bits[--_n] = 0; } + pragma(mangle, "__pselect50") int pselect(int, fd_set*, fd_set*, fd_set*, const scope timespec*, const scope sigset_t*); + pragma(mangle, "__select50") int select(int, fd_set*, fd_set*, fd_set*, timeval*); } else version (OpenBSD) diff --git a/runtime/druntime/src/core/sys/posix/sys/statvfs.d b/runtime/druntime/src/core/sys/posix/sys/statvfs.d index dec253d300..a8f3dd5065 100644 --- a/runtime/druntime/src/core/sys/posix/sys/statvfs.d +++ b/runtime/druntime/src/core/sys/posix/sys/statvfs.d @@ -180,7 +180,9 @@ else version (NetBSD) ST_NOSUID = 2 } + pragma(mangle, "__statvfs90") int statvfs (const char * file, statvfs_t* buf); + pragma(mangle, "__fstatvfs90") int fstatvfs (int fildes, statvfs_t *buf) @trusted; } else version (OpenBSD) diff --git a/runtime/druntime/src/core/sys/posix/sys/time.d b/runtime/druntime/src/core/sys/posix/sys/time.d index dda4caf0bf..6dcd4878d1 100644 --- a/runtime/druntime/src/core/sys/posix/sys/time.d +++ b/runtime/druntime/src/core/sys/posix/sys/time.d @@ -160,9 +160,13 @@ else version (NetBSD) timeval it_value; } + pragma(mangle, "__getitimer50") int getitimer(int, itimerval*); + pragma(mangle, "__gettimeofday50") int gettimeofday(timeval*, void*); // timezone_t* is normally void* + pragma(mangle, "__setitimer50") int setitimer(int, const scope itimerval*, itimerval*); + pragma(mangle, "__utimes50") int utimes(const scope char*, ref const(timeval)[2]); } else version (OpenBSD) diff --git a/runtime/druntime/src/core/sys/posix/sys/types.d b/runtime/druntime/src/core/sys/posix/sys/types.d index b6febde713..cad60b4da4 100644 --- a/runtime/druntime/src/core/sys/posix/sys/types.d +++ b/runtime/druntime/src/core/sys/posix/sys/types.d @@ -251,7 +251,7 @@ else version (NetBSD) alias pid_t = int; //size_t (defined in core.stdc.stddef) alias ssize_t = c_long; - alias time_t = c_long; + alias time_t = long; // _BSD_TIME_T_ mapped to __int64_t alias uid_t = uint; } else version (OpenBSD) @@ -388,10 +388,10 @@ else version (NetBSD) { alias fsblkcnt_t = ulong; alias fsfilcnt_t = ulong; - alias clock_t = c_long; + alias clock_t = uint; // unsigned int alias id_t = long; alias key_t = c_long; - alias suseconds_t = c_long; + alias suseconds_t = int; // int alias useconds_t = uint; } else version (OpenBSD) diff --git a/runtime/druntime/src/core/sys/posix/time.d b/runtime/druntime/src/core/sys/posix/time.d index a631ddc2bc..4fc73aab8c 100644 --- a/runtime/druntime/src/core/sys/posix/time.d +++ b/runtime/druntime/src/core/sys/posix/time.d @@ -64,6 +64,7 @@ else version (FreeBSD) } else version (NetBSD) { + pragma(mangle, "__timegm50") time_t timegm(tm*); // non-standard } else version (OpenBSD) @@ -378,14 +379,20 @@ else version (NetBSD) alias clockid_t = int; // alias timer_t = int; + pragma(mangle, "__clock_getres50") int clock_getres(clockid_t, timespec*); + pragma(mangle, "__clock_gettime50") int clock_gettime(clockid_t, timespec*); + pragma(mangle, "__clock_settime50") int clock_settime(clockid_t, const scope timespec*); + pragma(mangle, "__nanosleep50") int nanosleep(const scope timespec*, timespec*); int timer_create(clockid_t, sigevent*, timer_t*); int timer_delete(timer_t); + pragma(mangle, "__timer_gettime50") int timer_gettime(timer_t, itimerspec*); int timer_getoverrun(timer_t); + pragma(mangle, "__timer_settime50") int timer_settime(timer_t, int, const scope itimerspec*, itimerspec*); } else version (OpenBSD) @@ -576,8 +583,11 @@ else version (FreeBSD) else version (NetBSD) { char* asctime_r(const scope tm*, char*); + pragma(mangle, "__ctime_r50") char* ctime_r(const scope time_t*, char*); + pragma(mangle, "__gmtime_r50") tm* gmtime_r(const scope time_t*, tm*); + pragma(mangle, "__localtime_r50") tm* localtime_r(const scope time_t*, tm*); } else version (OpenBSD) From 14793ec1e384da4082d85cbb8345e2b1165244b8 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 17 Mar 2026 00:20:47 +0100 Subject: [PATCH 389/440] core.thread.package: Revise unittest (dlang/dmd!22736) I guess this test is about `atomicFence()`, and so rather unorthodox/unsafe. For optimizing compilers, it's not sufficient to use heap-allocated values (shared by 2 threads). The only concurrent read/write is for the `f` bool, where LDC optimizes the load in the new thread's loop condition to a single load (as the empty loop body definitely won't modify it in this thread). So switch to an `atomicLoad()` for `f`, which prevents such optimizations, and use normal stack values [well, they end up in a closure], making them proper `shared` and adding the unsafe casts (so that this compiles with `-preview=nosharedaccess`). --- runtime/druntime/src/core/thread/package.d | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/runtime/druntime/src/core/thread/package.d b/runtime/druntime/src/core/thread/package.d index d81ebbdcc8..a54442b3f1 100644 --- a/runtime/druntime/src/core/thread/package.d +++ b/runtime/druntime/src/core/thread/package.d @@ -22,38 +22,36 @@ public import core.thread.context; // this test is here to avoid a cyclic dependency between // core.thread and core.atomic -unittest +@system unittest { import core.atomic; - // Use heap memory to ensure an optimizing - // compiler doesn't put things in registers. - uint* x = new uint(); - bool* f = new bool(); - uint* r = new uint(); + shared uint x; + shared bool f; + shared uint r; auto thr = new Thread(() { - while (!*f) + while (!atomicLoad(f)) { } - atomicFence(); + atomicFence(); // make sure load+store below happens after waiting for f - *r = *x; + cast() r = cast() x; }); - thr.start(); + thr.start(); // new thread will wait until f is set - *x = 42; + cast() x = 42; - atomicFence(); + atomicFence(); // make sure x is set before setting f - *f = true; + cast() f = true; atomicFence(); thr.join(); - assert(*r == 42); + assert(cast() r == 42); } From 57bc0ef6079c0d71a8e76e590ce7103328151c14 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Tue, 17 Mar 2026 16:38:34 -0700 Subject: [PATCH 390/440] add op pseudo-op to inline assembler (dlang/dmd!22739) * add some support for AArch64 inline assembler * add op pseudo-op to inline assembler Co-Authored-By: Iain Buclaw --------- Co-authored-by: Iain Buclaw --- dmd/frontend.h | 1 + dmd/id.d | 3 +++ 2 files changed, 4 insertions(+) diff --git a/dmd/frontend.h b/dmd/frontend.h index c4439b55b6..05058b832e 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -8910,6 +8910,7 @@ struct Id final static Identifier* undef; static Identifier* ident; static Identifier* packed; + static Identifier* op; static void initialize(); Id() { diff --git a/dmd/id.d b/dmd/id.d index 4ac0f4f3d5..acd0c95dd6 100644 --- a/dmd/id.d +++ b/dmd/id.d @@ -542,6 +542,9 @@ immutable Msgtable[] msgtable = { "undef" }, { "ident" }, { "packed" }, + + // for inline assembler + { "op" }, ]; From c348ed242eb26b9269391157a005c21bda68bec6 Mon Sep 17 00:00:00 2001 From: dd Date: Tue, 17 Mar 2026 19:42:10 -0400 Subject: [PATCH 391/440] Druntime: Select newer pwd and socket symbols for NetBSD (dlang/dmd!22748) * core.sys.posix.pwd: Select newer pwd symbols for NetBSD * core.sys.posix.sys.socket: Select newer socket symbol for NetBSD --- runtime/druntime/src/core/sys/posix/pwd.d | 14 +++++++++++--- runtime/druntime/src/core/sys/posix/sys/socket.d | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/runtime/druntime/src/core/sys/posix/pwd.d b/runtime/druntime/src/core/sys/posix/pwd.d index d4b4a07673..3402a9e263 100644 --- a/runtime/druntime/src/core/sys/posix/pwd.d +++ b/runtime/druntime/src/core/sys/posix/pwd.d @@ -201,8 +201,16 @@ else static assert(false, "Unsupported platform"); } -passwd* getpwnam(const scope char*); -passwd* getpwuid(uid_t); +version (NetBSD) +{ + pragma(mangle, "__getpwnam50") passwd* getpwnam(const scope char*); + pragma(mangle, "__getpwuid50") passwd* getpwuid(uid_t); +} +else +{ + passwd* getpwnam(const scope char*); + passwd* getpwuid(uid_t); +} // // Thread-Safe Functions (TSF) @@ -301,7 +309,7 @@ else version (FreeBSD) else version (NetBSD) { void endpwent(); - passwd* getpwent(); + pragma(mangle, "__getpwent50") passwd* getpwent(); void setpwent(); } else version (OpenBSD) diff --git a/runtime/druntime/src/core/sys/posix/sys/socket.d b/runtime/druntime/src/core/sys/posix/sys/socket.d index 35f316bd93..0ae101db09 100644 --- a/runtime/druntime/src/core/sys/posix/sys/socket.d +++ b/runtime/druntime/src/core/sys/posix/sys/socket.d @@ -1704,7 +1704,7 @@ else version (NetBSD) ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t); int setsockopt(int, int, int, const scope void*, socklen_t); int shutdown(int, int) @safe; - int socket(int, int, int) @safe; + pragma(mangle, "__socket30") int socket(int, int, int) @safe; int sockatmark(int) @safe; int socketpair(int, int, int, ref int[2]) @safe; } From 0f004b24ca5f3d9431e87b0e91057f4ee412eef6 Mon Sep 17 00:00:00 2001 From: dd Date: Tue, 17 Mar 2026 19:44:13 -0400 Subject: [PATCH 392/440] core.sys.posix.dirent: Add dirfd (dlang/dmd!22750) --- runtime/druntime/src/core/sys/posix/dirent.d | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/runtime/druntime/src/core/sys/posix/dirent.d b/runtime/druntime/src/core/sys/posix/dirent.d index 18cee4c43c..c77d6da22b 100644 --- a/runtime/druntime/src/core/sys/posix/dirent.d +++ b/runtime/druntime/src/core/sys/posix/dirent.d @@ -441,6 +441,26 @@ else static assert(false, "Unsupported platform"); } +// +// POSIX.1-2008 +// +/* +int dirfd(DIR*); +*/ +version (NetBSD) +{ + // On NetBSD, this is a macro in dirent.h, not a function. + extern (D) int dirfd()(DIR* dir) nothrow @nogc + { + // ABI guarantees dd_fd remains the first field + return *(cast(int*) dir); + } +} +else +{ + nothrow @nogc int dirfd(DIR* dir); +} + // Only OS X out of the Darwin family needs special treatment. Other Darwins // (iOS, TVOS, WatchOS) are fine with normal symbol names for these functions // in else below. From e45454f3281f9b0ec90907b918755d10c5110a41 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Wed, 18 Mar 2026 21:59:49 +0000 Subject: [PATCH 393/440] [dmd/cli.d] More CLI option ddoc fixes (dlang/dmd!22758) --- dmd/cli.d | 99 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 52 insertions(+), 47 deletions(-) diff --git a/dmd/cli.d b/dmd/cli.d index b15212fa41..9dd11ff08b 100644 --- a/dmd/cli.d +++ b/dmd/cli.d @@ -259,11 +259,7 @@ struct Usage "use config file at " ), Option("cov", - "do code coverage analysis" - ), - Option("cov=ctfe", "Include code executed during CTFE in coverage report"), - Option("cov=", - "require at least % code coverage", + "perform code coverage and generate `.lst` file", `Perform $(LINK2 $(ROOT_DIR)code_coverage.html, code coverage analysis) and generate $(TT .lst) file with report.) --- @@ -271,11 +267,17 @@ dmd -cov -unittest myprog.d --- `, ), + Option("cov=ctfe", "Include code executed during CTFE in coverage report"), + Option("cov=", + "require at least % code coverage", + "Perform code coverage analysis, requiring at least % code coverage. + Options can be combined, e.g. `-cov=100 -cov=ctfe`." + ), Option("cpp=", "use as the name of the C preprocessor to use for ImportC files", - `Normally the C preprocessor used by the associated C compiler is used to - preprocess ImportC files, - this is overridden by the $(TT -cpp) switch.` + `Sets the C preprocessor to . + Normally the C preprocessor used by the associated C compiler is used to + preprocess ImportC files.` ), Option("D", "generate documentation", @@ -309,7 +311,7 @@ dmd -cov -unittest myprog.d ), Option("debug=", "compile in debug code identified by ", - `Compile in $(LINK2 spec/version.html#debug, debug identifier) $(I ident)`, + `Compile in debug code with $(LINK2 spec/version.html#debug_specification, debug identifier) $(I ident)`, ), Option("debuglib=", "set symbolic debug library to ", @@ -328,9 +330,7 @@ dmd -cov -unittest myprog.d ), Option("deps=", "write module dependencies to (only imports)", - `Without $(I filename), print module dependencies - (imports/file/version/debug/lib). - With $(I filename), write module dependencies as text to $(I filename) + `Write module dependencies as text to $(I filename) (only imports).`, ), Option("dllimport=[none|defaultLibsOnly|externalOnly|all]", @@ -382,23 +382,26 @@ dmd -cov -unittest myprog.d ), Option("ftime-trace", "turn on compile time profiler, generate JSON file with results", - "Per function, the time to analyze it, call it from CTFE, generate code for it etc. will be measured, - and events with a time longer than 500 microseconds (adjustable with `-ftime-trace-granularity`) + "Measure the time to analyze, call from CTFE, and generate code for a function. + Events with a time longer than 500 microseconds (adjustable with `-ftime-trace-granularity`) will be recorded. The profiling result is output in the Chrome Trace Event Format, $(LINK2 https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview, described here). This can be turned into a more readable text file with the included tool `timetrace2txt`, or inspected with an interactive viewer such as $(LINK2 https://ui.perfetto.dev/, Perfetto)." ), - Option("ftime-trace-granularity=", + Option("ftime-trace-granularity=<μsecs>", "Minimum time granularity (in microseconds) traced by time profiler (default: 500)", - "Measured events shorter than the specified time will be discarded from the output. + "Minimum time granularity (in microseconds) traced by time profiler. + The default is `500`. + Measured events shorter than the specified time will be discarded from the output. Set it too high, and interesting events may not show up in the output. Set too low, and the profiler overhead will be larger, and the output will be cluttered with tiny events." ), Option("ftime-trace-file=", "specify output file for `-ftime-trace`", - "By default, the output name is the same as the first object file name, but with the `.time-trace` extension appended. + "Specify output file for `-ftime-trace`. + By default, the output name is the same as the first object file name, but with the `.time-trace` extension appended. A different filename can be chosen with this option, including a path relative to the current directory or an absolute path." ), Option("g", @@ -409,18 +412,19 @@ dmd -cov -unittest myprog.d ) $(UNIX Add symbolic debug info in DWARF format - for debuggers such as - $(D gdb) + for debuggers such as $(D gdb). )`, ), Option("gdwarf=", - "add DWARF symbolic debug info", - "The value of may be 3, 4 or 5, defaulting to 3.", + "add DWARF symbolic debug info (default: 3)", + "Add DWARF symbolic debug info. + The value of may be 3, 4 or 5, defaulting to 3.", cast(TargetOS) (TargetOS.all & ~cast(uint)TargetOS.Windows) ), Option("gf", "emit debug info for all referenced types", - `Symbolic debug info is emitted for all types referenced by the compiled code, + `Emit debug info for all referenced types. + Symbolic debug info is emitted for all types referenced by the compiled code, even if the definition is in an imported file not currently being compiled.`, ), Option("gs", @@ -588,12 +592,12 @@ dmd -cov -unittest myprog.d ), Option("J=", "look for string imports also in ", - `Where to look for files for + "Where to look for files for $(LINK2 $(ROOT_DIR)spec/expression.html#ImportExpression, $(I ImportExpression))s. This switch is required in order to use $(I ImportExpression)s. - $(I path) is a ; separated + $(I directory) is a `;` separated list of paths. Multiple $(TT -J)'s can be used, and the paths - are searched in the same order.`, + are searched in the same order.", ), Option("L=", "pass to link", @@ -760,15 +764,17 @@ dmd -cov -unittest myprog.d ), Option("op", "preserve source path for output files", - `Normally the path for $(B .d) source files is stripped + `Preserve source path for output files. + Normally the path for $(B .d) source files is stripped off when generating an object, interface, or Ddoc file - name. $(SWLINK -op) will leave it on.`, + name.`, ), Option("oq", "Write object files with fully qualified file names", - `When compiling pkg/app.d, the resulting object file name will be pkg_app.obj - instead of app.o. This helps to prevent name conflicts when compiling multiple - packages in the same directory with the $(SWLINK -od) flag.`, + "Write object files with fully qualified file names. + When compiling `pkg/app.d`, the resulting object file name will be `pkg_app.o` + instead of `app.o`. This helps to prevent name conflicts when compiling multiple + packages in the same directory with the $(SWLINK -od) flag.", ), Option("os=", "sets target operating system to ", @@ -786,9 +792,9 @@ dmd -cov -unittest myprog.d ), Option("P=", "pass to C preprocessor", - `Pass $(I preprocessorflag) to - $(WINDOWS cl.exe) - $(UNIX cpp)`, + "Pass $(I preprocessorflag) to + $(WINDOWS `cl.exe`) + $(UNIX `cpp`). See also $(SWLINK -cpp)", ), Option("preview=", "enable an upcoming language change identified by ", @@ -802,7 +808,7 @@ dmd -cov -unittest myprog.d `Instrument the generated code so that runtime performance data is collected when the generated program is run. Upon completion of the generated program, the files $(TT trace.log) and $(TT trace.def) - are generated. $(TT trace.log) has two sections, + are generated. $(TT trace.log) has two sections: $(OL $(LI Fan in and fan out for each profiled function. The name of the function is left-justified, the functions immediately preceding it are the other functions that call it (fan in) and how many times @@ -816,13 +822,12 @@ dmd -cov -unittest myprog.d ) The $(TT trace.def) file contains linker commands to associate functions which are strongly coupled so they appear adjacent in the resulting executable file. - For more information see $(LINK2 https://www.digitalmars.com/ctg/trace.html, profile) + For more information see $(LINK2 https://www.digitalmars.com/ctg/trace.html, profile). `, ), Option("profile=gc", "profile runtime allocations", - `$(UL - $(LI $(B gc): Instrument calls to GC memory allocation and + `Instrument calls to GC memory allocation and write a report to the file $(TT profilegc.log) upon program termination. $(B Note:) Only instrumented calls will be logged. These include: @@ -832,8 +837,8 @@ dmd -cov -unittest myprog.d $(LI GC allocations via core.memory.GC) ) Allocations made by other means will not be logged, - including direct calls to the GC's C API.) - )`, + including direct calls to the GC's C API. + `, ), Option("release", "contracts and asserts are not emitted, and bounds checking is performed only in @safe functions", @@ -849,7 +854,7 @@ dmd -cov -unittest myprog.d Option("revert=[h|help|?]", "list all revertable language changes" ), - Option("run ", + Option("run ", "compile, link, and run the program ", `Compile, link, and run the program $(I srcfile) with the rest of the @@ -924,7 +929,7 @@ dmd -cov -unittest myprog.d )`, ), Option("verrors=spec", - "show errors from speculative compiles such as __traits(compiles,...)" + "show errors from speculative compiles such as `__traits(compiles, ...)`" ), Option("-version", "print compiler version and exit" @@ -934,7 +939,7 @@ dmd -cov -unittest myprog.d `Compile in $(LINK2 $(ROOT_DIR)spec/version.html#version, version identifier) $(I ident)` ), Option("vgc", - "list all gc allocations including hidden ones" + "list all GC allocations including hidden ones" ), Option("visibility=[default|hidden|public]", "default visibility of symbols", @@ -947,10 +952,10 @@ dmd -cov -unittest myprog.d Option("vtls", "list all variables going into thread local storage" ), - Option("vtemplates=[list-instances]", + Option("vtemplates[=list-instances]", "list statistics on template instantiations", - `An optional argument determines extra diagnostics, - where: + `List statistics on template instantiations. + An optional argument determines extra diagnostics: $(DL $(DT list-instances)$(DD Also shows all instantiation contexts for each template.) )`, @@ -961,8 +966,8 @@ dmd -cov -unittest myprog.d ), Option("wi", "warnings as messages (compilation will continue)", - `Enable $(LINK2 $(ROOT_DIR)articles/warnings.html, informational warnings (i.e. compilation - still proceeds normally))`, + `Enable $(LINK2 $(ROOT_DIR)articles/warnings.html, informational warnings) (i.e. compilation + still proceeds normally)`, ), Option("wo", "warnings about use of obsolete features (compilation will continue)", From 662cd8f795a3be240bedf7e9cc3606dd21ab73d9 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Thu, 19 Mar 2026 01:58:22 -0700 Subject: [PATCH 394/440] refactor and add setTokenList() (dlang/dmd!22762) --- dmd/parse.d | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dmd/parse.d b/dmd/parse.d index c8ca3a1a0f..1bdcf44c33 100644 --- a/dmd/parse.d +++ b/dmd/parse.d @@ -79,6 +79,21 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer this.doUnittests = doUnittests; } + /** Instead of parsing text to get tokens, provide a list of tokens ending with null. + * Note that the token list will be consumed (added to the tokenFreelist) by the lexer4. + * Params: + * pToken = pointer to first token in list, take ownership of list + * linnum = line number to use for the tokens + */ + extern (D) + void setTokenList(ref Token* pToken, int linnum) + { + this.token = *pToken; + pToken = null; // take ownership + this.baseLoc.startLine = linnum; + this.linnum = linnum; + } + /++ + Parse a module, i.e. the optional `module x.y.z` declaration and all declarations + found in the current file. From 58a1a4069534bab99f1d15df788ff13a960afb5b Mon Sep 17 00:00:00 2001 From: Sergii K Date: Fri, 20 Mar 2026 01:11:23 +0300 Subject: [PATCH 395/440] refactoring (dlang/dmd!22366) Co-authored-by: Kuzko Sergii --- .../src/core/internal/array/equality.d | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/runtime/druntime/src/core/internal/array/equality.d b/runtime/druntime/src/core/internal/array/equality.d index 7a7dc5ceb2..a94c6b6a88 100644 --- a/runtime/druntime/src/core/internal/array/equality.d +++ b/runtime/druntime/src/core/internal/array/equality.d @@ -49,25 +49,39 @@ bool __equals(T1, T2, size_t N, size_t M)(scope ref T1[N] lhs, scope ref T2[M] r private bool isEqual(T1, T2)(scope T1[] lhs, scope T2[] rhs, size_t length) { - // Returns a reference to an array element, eliding bounds check and - // casting void to ubyte. - pragma(inline, true) - static ref at(T)(scope T[] r, size_t i) @trusted - // exclude opaque structs due to https://issues.dlang.org/show_bug.cgi?id=20959 - if (!(is(T == struct) && !is(typeof(T.sizeof)))) + static if (is(T1 == T2) && + (__traits(isIntegral, T1) || is(T1 == char) || is(T1 == wchar) || + is(T1 == dchar) || is(T1 == bool) || is(T1 == class))) { - static if (is(T == void)) - return (cast(ubyte[]) r)[i]; - else - return r[i]; + foreach (i; 0 .. length) + { + if (lhs.ptr[i] != rhs.ptr[i]) + return false; + } + return true; } - - foreach (const i; 0 .. length) + else { - if (at(lhs, i) != at(rhs, i)) - return false; + // Returns a reference to an array element, eliding bounds check and + // casting void to ubyte. + pragma(inline, true) + static ref at(T)(scope T[] r, size_t i) @trusted + // exclude opaque structs due to https://issues.dlang.org/show_bug.cgi?id=20959 + if (!(is(T == struct) && !is(typeof(T.sizeof)))) + { + static if (is(T == void)) + return (cast(ubyte[]) r)[i]; + else + return r[i]; + } + + foreach (const i; 0 .. length) + { + if (at(lhs, i) != at(rhs, i)) + return false; + } + return true; } - return true; } @safe unittest From a409bf4ba3cd4cdc9358b5a3b88aeceb795ec624 Mon Sep 17 00:00:00 2001 From: Atila Neves Date: Fri, 20 Mar 2026 02:20:52 +0100 Subject: [PATCH 396/440] Allow structs with pointers to be constructed as shared (dlang/dmd!22765) --- dmd/expressionsem.d | 8 ++++++++ .../test_nosharedaccess_shared_struct_literal.d | 15 +++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/dmd/compilable/test_nosharedaccess_shared_struct_literal.d diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 725fc718ad..50e21f88eb 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -16669,6 +16669,8 @@ bool checkValue(Expression e) */ bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false) { + Expression root = e; + if (!sc || !sc.previews.noSharedAccess || sc.intypeof || @@ -16846,6 +16848,12 @@ bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false) case EXP.star: return visitPtr(e.isPtrExp()); case EXP.dotVariable: return visitDotVar(e.isDotVarExp()); case EXP.index: return visitIndex(e.isIndexExp()); + case EXP.structLiteral: + // Allow constructing a shared struct literal as a value, + // but keep rejecting later accesses through that temporary. + if (e is root && e.type && e.type.isShared()) + return false; + return visit(e); } } diff --git a/tests/dmd/compilable/test_nosharedaccess_shared_struct_literal.d b/tests/dmd/compilable/test_nosharedaccess_shared_struct_literal.d new file mode 100644 index 0000000000..4bb99010b8 --- /dev/null +++ b/tests/dmd/compilable/test_nosharedaccess_shared_struct_literal.d @@ -0,0 +1,15 @@ +// REQUIRED_ARGS: -preview=nosharedaccess + +import core.atomic; + +struct List +{ + size_t gen; + List* next; +} + +void main() +{ + shared(List) head; + assert(cas(&head, shared(List)(0, null), shared(List)(1, cast(List*)1))); +} From b7d4a9bea50025828554e4fac78ac04824b37fa0 Mon Sep 17 00:00:00 2001 From: Atila Neves Date: Fri, 20 Mar 2026 03:23:58 +0100 Subject: [PATCH 397/440] Fix unittest compilation failures with nosharedaccess (dlang/dmd!22764) --- runtime/druntime/src/core/atomic.d | 130 ++++++++++-------- .../src/core/internal/array/capacity.d | 15 +- .../src/core/internal/array/duplication.d | 27 +++- runtime/druntime/src/core/internal/lifetime.d | 13 +- runtime/druntime/src/core/lifetime.d | 23 +++- runtime/druntime/src/core/stdc/stdatomic.d | 5 +- runtime/druntime/src/object.d | 10 +- 7 files changed, 156 insertions(+), 67 deletions(-) diff --git a/runtime/druntime/src/core/atomic.d b/runtime/druntime/src/core/atomic.d index 7e97b9d53f..7ca0ecd4e1 100644 --- a/runtime/druntime/src/core/atomic.d +++ b/runtime/druntime/src/core/atomic.d @@ -33,6 +33,13 @@ import core.internal.atomic; import core.internal.attributes : betterC; import core.internal.traits : hasUnsharedIndirections; +// Low-level atomic helpers still need to hand shared reference payloads to the +// backend intrinsics under `-preview=nosharedaccess`. +private T unsharedLoadRef(T)(scope ref shared T value) pure nothrow @nogc @trusted +{ + return *cast(T*)&value; +} + /** * Specifies the memory ordering semantics of an atomic operation. * @@ -259,7 +266,7 @@ in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned") { static assert (is (V : T), "Can't assign `exchangeWith` of type `" ~ shared(V).stringof ~ "` to `" ~ shared(T).stringof ~ "`."); - return cast(shared)core.internal.atomic.atomicExchange!ms(cast(T*)here, cast(V)exchangeWith); + return cast(shared)core.internal.atomic.atomicExchange!ms(cast(T*)here, unsharedLoadRef(exchangeWith)); } /** @@ -326,7 +333,7 @@ template cas(MemoryOrder succ = MemoryOrder.seq, MemoryOrder fail = MemoryOrder. in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned") { return atomicCompareExchangeStrongNoResult!(succ, fail)( - cast(T*)here, cast(V1)ifThis, cast(V2)writeThis); + cast(T*)here, unsharedLoadRef(ifThis), unsharedLoadRef(writeThis)); } /// Compare-and-exchange for non-`shared` types @@ -378,7 +385,7 @@ template cas(MemoryOrder succ = MemoryOrder.seq, MemoryOrder fail = MemoryOrder. in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned") { return atomicCompareExchangeStrong!(succ, fail)( - cast(T*)here, cast(T*)ifThis, cast(V)writeThis); + cast(T*)here, cast(T*)ifThis, unsharedLoadRef(writeThis)); } } @@ -835,11 +842,11 @@ version (CoreUnittest) T base = cast(T)null; shared(T) atom = cast(shared(T))null; - assert(base !is val, T.stringof); - assert(atom is base, T.stringof); + assert(atomicLoad(base) !is atomicLoad(val), T.stringof); + assert(atomicLoad(atom) is atomicLoad(base), T.stringof); - assert(atomicExchange(&atom, val) is base, T.stringof); - assert(atom is val, T.stringof); + assert(atomicExchange(&atom, atomicLoad(val)) is atomicLoad(base), T.stringof); + assert(atomicLoad(atom) is atomicLoad(val), T.stringof); } void testCAS(T)(T val) pure nothrow @nogc @trusted @@ -852,25 +859,26 @@ version (CoreUnittest) T base = cast(T)null; shared(T) atom = cast(shared(T))null; - assert(base !is val, T.stringof); - assert(atom is base, T.stringof); + assert(atomicLoad(base) !is atomicLoad(val), T.stringof); + assert(atomicLoad(atom) is atomicLoad(base), T.stringof); - assert(cas(&atom, base, val), T.stringof); - assert(atom is val, T.stringof); - assert(!cas(&atom, base, base), T.stringof); - assert(atom is val, T.stringof); + assert(cas(&atom, atomicLoad(base), atomicLoad(val)), T.stringof); + assert(atomicLoad(atom) is atomicLoad(val), T.stringof); + assert(!cas(&atom, atomicLoad(base), atomicLoad(base)), T.stringof); + assert(atomicLoad(atom) is atomicLoad(val), T.stringof); - atom = cast(shared(T))null; + atomicStore(atom, cast(shared(T))null); - shared(T) arg = base; - assert(cas(&atom, &arg, val), T.stringof); - assert(arg is base, T.stringof); - assert(atom is val, T.stringof); + shared(T) arg = cast(shared(T))null; + atomicStore(arg, atomicLoad(base)); + assert(cas(&atom, &arg, atomicLoad(val)), T.stringof); + assert(atomicLoad(arg) is atomicLoad(base), T.stringof); + assert(atomicLoad(atom) is atomicLoad(val), T.stringof); - arg = base; - assert(!cas(&atom, &arg, base), T.stringof); - assert(arg is val, T.stringof); - assert(atom is val, T.stringof); + atomicStore(arg, atomicLoad(base)); + assert(!cas(&atom, &arg, atomicLoad(base)), T.stringof); + assert(atomicLoad(arg) is atomicLoad(val), T.stringof); + assert(atomicLoad(atom) is atomicLoad(val), T.stringof); } void testLoadStore(MemoryOrder ms = MemoryOrder.seq, T)(T val = T.init + 1) pure nothrow @nogc @trusted @@ -878,23 +886,34 @@ version (CoreUnittest) T base = cast(T) 0; shared(T) atom = cast(T) 0; - assert(base !is val); - assert(atom is base); - atomicStore!(ms)(atom, val); - base = atomicLoad!(ms)(atom); + assert(atomicLoad(base) !is atomicLoad(val)); + assert(atomicLoad(atom) is atomicLoad(base)); + atomicStore!(ms)(atom, atomicLoad(val)); + auto loaded = atomicLoad!(ms)(atom); - assert(base is val, T.stringof); - assert(atom is val); + assert(loaded is atomicLoad(val), T.stringof); + assert(atomicLoad(atom) is atomicLoad(val)); } - void testType(T)(T val = T.init + 1) pure nothrow @nogc @safe + // This test-only helper synthesizes distinct sentinel values for low-level + // atomic operations, including shared pointers that cannot be formed in + // @safe code. + private T testValue(T)() pure nothrow @nogc @trusted + { + static if (is(T == U*, U)) + return cast(T)1; + else + return T.init + 1; + } + + void testType(T)(T val = testValue!T()) pure nothrow @nogc @safe { static if (T.sizeof < 8 || has64BitXCHG) - testXCHG!(T)(val); - testCAS!(T)(val); - testLoadStore!(MemoryOrder.seq, T)(val); - testLoadStore!(MemoryOrder.raw, T)(val); + testXCHG!(T)(atomicLoad(val)); + testCAS!(T)(atomicLoad(val)); + testLoadStore!(MemoryOrder.seq, T)(atomicLoad(val)); + testLoadStore!(MemoryOrder.raw, T)(atomicLoad(val)); } @betterC @safe pure nothrow unittest @@ -946,30 +965,30 @@ version (CoreUnittest) shared(Big) arg; shared(Big) val = Big(1, 2); - assert(cas(&atom, arg, val), Big.stringof); - assert(atom is val, Big.stringof); - assert(!cas(&atom, arg, val), Big.stringof); - assert(atom is val, Big.stringof); + assert(cas(&atom, atomicLoad(arg), atomicLoad(val)), Big.stringof); + assert(atomicLoad(atom) is atomicLoad(val), Big.stringof); + assert(!cas(&atom, atomicLoad(arg), atomicLoad(val)), Big.stringof); + assert(atomicLoad(atom) is atomicLoad(val), Big.stringof); - atom = Big(); - assert(cas(&atom, &arg, val), Big.stringof); - assert(arg is base, Big.stringof); - assert(atom is val, Big.stringof); + atomicStore(atom, Big()); + assert(cas(&atom, &arg, atomicLoad(val)), Big.stringof); + assert(atomicLoad(arg) is atomicLoad(base), Big.stringof); + assert(atomicLoad(atom) is atomicLoad(val), Big.stringof); - arg = Big(); - assert(!cas(&atom, &arg, base), Big.stringof); - assert(arg is val, Big.stringof); - assert(atom is val, Big.stringof); + atomicStore(arg, Big()); + assert(!cas(&atom, &arg, atomicLoad(base)), Big.stringof); + assert(atomicLoad(arg) is atomicLoad(val), Big.stringof); + assert(atomicLoad(atom) is atomicLoad(val), Big.stringof); }(); } shared(size_t) i; atomicOp!"+="(i, cast(size_t) 1); - assert(i == 1); + assert(atomicLoad(i) == 1); atomicOp!"-="(i, cast(size_t) 1); - assert(i == 0); + assert(atomicLoad(i) == 0); shared float f = 0.1f; atomicOp!"+="(f, 0.1f); @@ -995,10 +1014,12 @@ version (CoreUnittest) align(16) shared DoubleValue a; atomicStore(a, DoubleValue(1,2)); - assert(a.value1 == 1 && a.value2 ==2); + auto initial = atomicLoad(a); + assert(initial.value1 == 1 && initial.value2 == 2); while (!cas(&a, DoubleValue(1,2), DoubleValue(3,4))){} - assert(a.value1 == 3 && a.value2 ==4); + auto updated = atomicLoad(a); + assert(updated.value1 == 3 && updated.value2 == 4); align(16) DoubleValue b = atomicLoad(a); assert(b.value1 == 3 && b.value2 ==4); @@ -1056,7 +1077,8 @@ version (CoreUnittest) @betterC pure nothrow unittest { static struct S { int val; } - auto s = shared(S)(1); + shared S s; + atomicStore(s, S(1)); shared(S*) ptr; @@ -1070,7 +1092,7 @@ version (CoreUnittest) // head shared shared(S*) ifThis2 = writeThis; shared(S*) writeThis2 = null; - assert(cas(&ptr, ifThis2, writeThis2)); + assert(cas(&ptr, atomicLoad(ifThis2), atomicLoad(writeThis2))); assert(ptr is null); } @@ -1174,12 +1196,12 @@ version (CoreUnittest) shared ulong a = 2; uint b = 1; atomicOp!"-="(a, b); - assert(a == 1); + assert(atomicLoad(a) == 1); shared uint c = 2; ubyte d = 1; atomicOp!"-="(c, d); - assert(c == 1); + assert(atomicLoad(c) == 1); } pure nothrow @safe unittest // https://issues.dlang.org/show_bug.cgi?id=16230 @@ -1232,6 +1254,6 @@ version (CoreUnittest) shared uint si2 = 38; shared uint* psi = &si1; - assert((&psi).cas(cast(const) psi, &si2)); + assert((&psi).cas(cast(const) atomicLoad(psi), &si2)); } } diff --git a/runtime/druntime/src/core/internal/array/capacity.d b/runtime/druntime/src/core/internal/array/capacity.d index 833918664d..2992d30b17 100644 --- a/runtime/druntime/src/core/internal/array/capacity.d +++ b/runtime/druntime/src/core/internal/array/capacity.d @@ -222,7 +222,16 @@ size_t _d_arraysetlengthT(Tarr : T[], T)(return ref scope Tarr arr, size_t newle // Call the implementation with the unqualified array and sharedness flag size_t result = _d_arraysetlengthT_(unqual_arr, newlength, isShared); - arr = cast(Tarr) unqual_arr; + static if (isShared) + { + // This low-level primitive mutates the caller's shared slice header, so + // the caller must already provide whatever synchronization makes that + // header update valid; the cast only preserves that existing contract + // under `-preview=nosharedaccess`. + *cast(UnqT[]*) &arr = unqual_arr; + } + else + arr = cast(Tarr) unqual_arr; // Return the result return result; } @@ -392,6 +401,8 @@ version (D_ProfileGC) shared S[] arr2; _d_arraysetlengthT!(typeof(arr2))(arr2, 16); assert(arr2.length == 16); - foreach (s; arr2) + // The resized slice has not been published yet, so the test may inspect + // the backing storage directly to verify initialization. + foreach (s; (() @trusted => *cast(S[]*) &arr2)()) assert(s == S.init); } diff --git a/runtime/druntime/src/core/internal/array/duplication.d b/runtime/druntime/src/core/internal/array/duplication.d index a9b599cfc3..ff9e1edb4d 100644 --- a/runtime/druntime/src/core/internal/array/duplication.d +++ b/runtime/druntime/src/core/internal/array/duplication.d @@ -29,13 +29,32 @@ U[] _dup(T, U)(scope T[] a) pure nothrow @trusted if (__traits(isPOD, T)) U[] _dupCtfe(T, U)(scope T[] a) { + import core.internal.traits : Unqual; + static if (is(T : void)) assert(0, "Cannot dup a void[] array at compile time."); else { U[] res; - foreach (ref e; a) - res ~= e; + static if (is(T == shared SharedPayload, SharedPayload)) + { + // CTFE still needs a low-level element copy path for shared POD + // arrays because `.dup` models the runtime bitcopy before any + // synchronization policy is applied to the duplicated slice. + Unqual!U[] tmp; + foreach (i; 0 .. a.length) + // This cast is only to make the CTFE path express the same raw + // element copy that the runtime POD implementation performs + // with memcpy; it is not meant as a synchronized access pattern + // for published shared data. + tmp ~= (cast(Unqual!T[]) a)[i]; + res = cast(typeof(res)) tmp; + } + else + { + foreach (ref e; a) + res ~= e; + } return res; } } @@ -327,9 +346,9 @@ U[] _dup(T, U)(T[] a) if (!__traits(isPOD, T)) { if (l != 0xDEADBEEF) { - import core.stdc.stdio : fflush, printf, stdout; + import core.stdc.stdio : fflush, printf; printf("Unexpected value: %lld\n", l); - fflush(stdout); + fflush(null); assert(false); } } diff --git a/runtime/druntime/src/core/internal/lifetime.d b/runtime/druntime/src/core/internal/lifetime.d index 053b3edc69..fb28b11f08 100644 --- a/runtime/druntime/src/core/internal/lifetime.d +++ b/runtime/druntime/src/core/internal/lifetime.d @@ -94,7 +94,14 @@ if (!is(T == const) && !is(T == immutable) && !is(T == inout)) { import core.internal.traits : hasElaborateAssign; - static if (__traits(isZeroInit, T)) + static if (is(T == shared U, U)) + { + // Initialization happens before the shared object is published, so the + // helper has to operate on the backing storage instead of performing an + // ordinary shared write that `-preview=nosharedaccess` rejects. + emplaceInitializer(*cast(U*) &chunk); + } + else static if (__traits(isZeroInit, T)) { import core.stdc.string : memset; memset(cast(void*) &chunk, 0, T.sizeof); @@ -135,7 +142,9 @@ if (!is(T == const) && !is(T == immutable) && !is(T == inout)) { shared T dst = void; emplaceInitializer(dst); - assert(dst is shared(T).init); + // The initializer has not been published yet, so the test may read + // the backing storage directly to verify that emplace wrote T.init. + assert((() @trusted => (*cast(T*) &dst) is T.init)()); } // const T diff --git a/runtime/druntime/src/core/lifetime.d b/runtime/druntime/src/core/lifetime.d index feacc9da56..d19c0bbc0e 100644 --- a/runtime/druntime/src/core/lifetime.d +++ b/runtime/druntime/src/core/lifetime.d @@ -77,9 +77,11 @@ T* emplace(T, Args...)(T* chunk, auto ref Args args) @betterC @system unittest { + import core.atomic : atomicLoad; + shared int i; emplace(&i, 42); - assert(i == 42); + assert(atomicLoad(i) == 42); } /** @@ -1246,9 +1248,21 @@ void copyEmplace(S, T)(ref S source, ref T target) @system if (is(immutable S == immutable T)) { import core.internal.traits : BaseElemOf, hasElaborateCopyConstructor, Unconst, Unqual; + enum isSharedReference = is(S == shared U, U) && is(T == shared V, V) && + (is(U == class) || is(U == interface)) && + (is(V == class) || is(V == interface)); // cannot have the following as simple template constraint due to nested-struct special case... - static if (!__traits(compiles, (ref S src) { T tgt = src; })) + static if (isSharedReference) + { + static assert(__traits(compiles, (ref S src, ref T tgt) + { + import core.atomic : atomicLoad, atomicStore; + atomicStore(tgt, atomicLoad(src)); + }), "cannot copy shared reference " ~ T.stringof ~ " from " ~ S.stringof ~ + " via atomic load/store"); + } + else static if (!__traits(compiles, (ref S src) { T tgt = src; })) { alias B = BaseElemOf!T; enum isNestedStruct = is(B == struct) && __traits(isNested, B); @@ -1308,6 +1322,11 @@ void copyEmplace(S, T)(ref S source, ref T target) @system blit(); // all elements at once } } + else static if (isSharedReference) + { + import core.atomic : atomicLoad, atomicStore; + atomicStore(target, atomicLoad(source)); + } else { *cast(Unconst!(T)*) &target = *cast(Unconst!(T)*) &source; diff --git a/runtime/druntime/src/core/stdc/stdatomic.d b/runtime/druntime/src/core/stdc/stdatomic.d index 966d29d808..8f4bc6e2e1 100644 --- a/runtime/druntime/src/core/stdc/stdatomic.d +++ b/runtime/druntime/src/core/stdc/stdatomic.d @@ -244,7 +244,10 @@ bool atomic_flag_test_and_set_explicit_impl()(atomic_flag* obj, memory_order ord pragma(inline, true) void atomic_init(A, C)(out shared(A) obj, C desired) @trusted { - obj = cast(shared) desired; + // C11 atomic_init is a low-level initialization primitive for atomic storage + // before it is published for concurrent access, so it must be able to write + // the backing object without demonstrating ordinary shared access. + *cast(A*) &obj = cast(A) desired; } /// diff --git a/runtime/druntime/src/object.d b/runtime/druntime/src/object.d index bb0c3d3c27..015666cfdb 100644 --- a/runtime/druntime/src/object.d +++ b/runtime/druntime/src/object.d @@ -518,11 +518,15 @@ unittest // https://issues.dlang.org/show_bug.cgi?id=23291 @system unittest { + import core.atomic : atomicLoad; + static shared class C { bool opEquals(const(shared(C)) rhs) const shared { return true;}} const(C) c = new C(); const(C)[] a = [c]; const(C)[] b = [c]; - assert(a[0] == b[0]); + // Call the shared-aware overload directly to avoid `==` introducing + // additional shared reads during lowering. + assert(atomicLoad(a[0]).opEquals(atomicLoad(b[0]))); } private extern(C) void _d_setSameMutex(shared Object ownee, shared Object owner) nothrow; @@ -541,6 +545,8 @@ void setSameMutex(shared Object ownee, shared Object owner) @system unittest { + import core.atomic : atomicLoad; + shared Object obj1 = new Object; synchronized class C { @@ -552,7 +558,7 @@ void setSameMutex(shared Object ownee, shared Object owner) assert(obj1.__monitor != obj2.__monitor); assert(obj1.__monitor is null); - setSameMutex(obj1, obj2); + setSameMutex(atomicLoad(obj1), atomicLoad(obj2)); assert(obj1.__monitor == obj2.__monitor); assert(obj1.__monitor !is null); } From a5830e2fa9536f79807317a7c96be8d133fc8db4 Mon Sep 17 00:00:00 2001 From: Gaofei Qiu <96871163+gulugulubing@users.noreply.github.com> Date: Thu, 19 Mar 2026 22:02:07 -0600 Subject: [PATCH 398/440] Implement static array length inference `[$]` (dlang/dmd!22745) Co-authored-by: xoxorwr --- dmd/dsymbolsem.d | 147 ++++++++++++++++++++++- dmd/expressionsem.d | 7 ++ dmd/typesem.d | 9 ++ tests/dmd/fail_compilation/staticarray.d | 12 ++ tests/dmd/runnable/staticarray.d | 83 +++++++++++++ 5 files changed, 257 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/fail_compilation/staticarray.d create mode 100644 tests/dmd/runnable/staticarray.d diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 76e5260444..16709bc113 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -2277,6 +2277,152 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor dsym.inuse--; sc2.pop(); } + static bool hasDollarDimension(TypeSArray tsa) + { + auto d = tsa.dim; + if (!d) + return false; + auto ide = d.isIdentifierExp(); + if (!ide) + return false; + return ide.ident == Id.dollar; + } + static bool hasUnresolvedDollar(Type t) + { + auto tsa = t.isTypeSArray(); + if (!tsa) + return false; + if (hasDollarDimension(tsa)) + return true; + return hasUnresolvedDollar(tsa.next); + } + + static void resolveDollarToZero(Type t, Loc loc) + { + auto tsa = t.isTypeSArray(); + if (!tsa) + return; + if (hasDollarDimension(tsa)) { + tsa.dim = new IntegerExp(loc, 0, Type.tsize_t); + } + resolveDollarToZero(tsa.next, loc); + } + + static bool inferExprLength(Expression e, out dinteger_t len) + { + if (!e) + return false; + + if (auto ale = e.isArrayLiteralExp()) + { + len = ale.elements.length; + return true; + } + + if (auto ce = e.isCatExp()) + { + dinteger_t l1; + dinteger_t l2; + if (inferExprLength(ce.e1, l1) && inferExprLength(ce.e2, l2)) + { + len = l1 + l2; + return true; + } + } + + if (!e.type) + return false; + + auto tsan = e.type.toBasetype().isTypeSArray(); + if (!tsan) + return false; + + auto dim = tsan.dim.isIntegerExp(); + if (!dim) + return false; + + len = dim.value; + return true; + } + + static bool inferSArrayDim(TypeSArray tsa, Expression ie, Loc loc, Scope* sc) + { + if (!tsa || !ie) + return false; + + if (!hasDollarDimension(tsa)) + return false; + + if (auto ale = ie.isArrayLiteralExp()) + { + dinteger_t len = ale.elements.length; + tsa.dim = new IntegerExp(loc, len, Type.tsize_t); + if (auto innerTsa = tsa.next.isTypeSArray()) + { + if (ale.elements.length > 0) + { + auto firstElem = (*ale.elements)[0]; + inferSArrayDim(innerTsa, firstElem, loc, sc); + } + } + return true; + } + else if (auto se = ie.isStringExp()) + { + Type next = tsa.next.toBasetype(); + if (next.ty == TY.Tchar || next.ty == TY.Twchar || next.ty == TY.Tdchar) + { + tsa.dim = new IntegerExp(loc, se.len, Type.tsize_t); + return true; + } + return false; + } + + // For other initializer forms, infer `$` only when the extent is + // compile-time known: either a concatenation whose operands are + // inferable, or any expression whose type is a static array. + dinteger_t len; + if (!inferExprLength(ie, len)) + return false; + + tsa.dim = new IntegerExp(loc, len, Type.tsize_t); + return true; + } + + auto tsa = dsym.type.isTypeSArray(); + + if (tsa && hasDollarDimension(tsa)) + { + if (!dsym._init || dsym._init.isVoidInitializer()) + { + .error(dsym.loc, "cannot infer static array length from `$`, provide an initializer"); + tsa.dim = new IntegerExp(dsym.loc, 0, Type.tsize_t); + } + else + { + Expression ie = dsym._init.initializerToExpression(null, sc.inCfile); + if (ie && ie.op != EXP.error) + { + ie = ie.expressionSemantic(sc); + ie = ie.optimize(WANTvalue); + bool dimInferred = inferSArrayDim(tsa, ie, dsym.loc, sc); + if (!dimInferred) + { + .error(dsym.loc, "cannot infer static array length from `$`, provide an initializer"); + tsa.dim = new IntegerExp(dsym.loc, 0, Type.tsize_t); + } + if (auto ale = ie.isArrayLiteralExp()) + dsym._init = new ExpInitializer(dsym.loc, ale); + } + } + } + if (tsa && hasUnresolvedDollar(tsa.next)) + { + .error(dsym.loc, "cannot infer static array length from `$`, provide an initializer"); + resolveDollarToZero(tsa.next, dsym.loc); + return; + } + //printf(" semantic type = %s\n", dsym.type ? dsym.type.toChars() : "null"); if (dsym.type.ty == Terror) dsym.errors = true; @@ -9253,7 +9399,6 @@ Lfail: return false; } - void checkCtorConstInit(Dsymbol d) { scope v = new CheckCtorConstInitVisitor(); diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 50e21f88eb..8834084590 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -209,7 +209,14 @@ dinteger_t toInteger(Expression _this) // import dmd.hdrgen : EXPtoString; //printf("Expression %s\n", EXPtoString(op).ptr); if (!_this.type || !_this.type.isTypeError()) + { + if (auto ide = _this.isIdentifierExp()) + { + if (ide.ident == Id.dollar) + return 0; + } error(_this.loc, "integer constant expression expected instead of `%s`", _this.toChars()); + } return 0; } diff --git a/dmd/typesem.d b/dmd/typesem.d index 779e6bfd7f..492362799f 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -3314,6 +3314,15 @@ Type typeSemantic(Type type, Loc loc, Scope* sc) Type tbn = tn.toBasetype(); if (mtype.dim) { + if (auto ide = mtype.dim.isIdentifierExp()) + { + if (ide.ident == Id.dollar) + { + mtype.next = tn; + mtype.transitive(); + return mtype.addMod(tn.mod).merge(); + } + } auto errors = global.errors; mtype.dim = semanticLength(sc, tbn, mtype.dim); mtype.dim = mtype.dim.implicitCastTo(sc, Type.tsize_t); diff --git a/tests/dmd/fail_compilation/staticarray.d b/tests/dmd/fail_compilation/staticarray.d new file mode 100644 index 0000000000..87b16ef360 --- /dev/null +++ b/tests/dmd/fail_compilation/staticarray.d @@ -0,0 +1,12 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/staticarray.d(10): Error: cannot infer static array length from `$`, provide an initializer +fail_compilation/staticarray.d(11): Error: cannot infer static array length from `$`, provide an initializer +fail_compilation/staticarray.d(12): Error: cannot infer static array length from `$`, provide an initializer +--- +*/ + +int[$] arr1; +int[$] arr2 = void; +int[$][1] arr3 = 1; diff --git a/tests/dmd/runnable/staticarray.d b/tests/dmd/runnable/staticarray.d new file mode 100644 index 0000000000..39cfb0a439 --- /dev/null +++ b/tests/dmd/runnable/staticarray.d @@ -0,0 +1,83 @@ +void main() +{ + int[3] arr1 = [1,2,3]; + int[$] arr2 = [1,2,3]; + const(int)[$] arr13 = [1,2,3]; + assert(arr1.length == 3); + assert(arr2.length == 3); + assert(arr13.length == 3); + static assert(arr2.length == 3); + static assert(arr13.length == 3); + static assert(is(typeof(arr13) == const(int)[3])); + assert(arr1 == arr2); + + int[$] arr3 = [10] ~ [20]; + assert(arr3.length == 2); + assert(arr3[0] == 10); + assert(arr3[1] == 20); + static assert(arr3.length == 2); + + int[$] arrConcatA = [2]; + int[$] arrConcatB = [2]; + int[$] arrConcatC = arrConcatA ~ arrConcatB; + assert(arrConcatC.length == 2); + assert(arrConcatC[0] == 2); + assert(arrConcatC[1] == 2); + static assert(arrConcatC.length == 2); + static assert(is(typeof(arrConcatC) == int[2])); + + int[$][$] arr4 = [[10], [10]]; + assert(arr4.length == 2); + assert(arr4[0].length == 1); + static assert(arr4.length == 2); + static assert(arr4[0].length == 1); + + static assert(!__traits(compiles, + { + int[$] arr5 = 3; + })); + + static assert(!__traits(compiles, + { + int[$] arr6 = new int[2]; + })); + + int[N] arrn(size_t N)() + { + int[N] res; + return res; + } + int[$] arr7 = arrn!(2)(); + assert(arr7.length == 2); + static assert(arr7.length == 2); + + int[2][$] arr8 = [[1, 2], [3, 4], [5, 6]]; + assert(arr8.length == 3); + assert(arr8[0].length == 2); + static assert(arr8.length == 3); + static assert(arr8[0].length == 2); + + int[$][$][$] arr9 = [[[1, 2]], [[3, 4]]]; + assert(arr9.length == 2); + assert(arr9[0].length == 1); + assert(arr9[0][0].length == 2); + static assert(arr9.length == 2); + static assert(arr9[0].length == 1); + static assert(arr9[0][0].length == 2); + + static assert(!__traits(compiles, + { + float[$] arr10 = 3.0f; + })); + + static assert(!__traits(compiles, + { + string[$] arr11 = "abc"; + })); + + char[$] arr12 = "abc"; + assert(arr12.length == 3); + assert(arr12[0] == 'a'); + assert(arr12[1] == 'b'); + assert(arr12[2] == 'c'); +} From 61f737843bc8254c50dfee19c097ad596a8a3330 Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Fri, 20 Mar 2026 17:06:26 +1300 Subject: [PATCH 399/440] Implement section attribute (dlang/dmd!22719) --- dmd/frontend.h | 1 + dmd/id.d | 1 + runtime/druntime/src/core/attribute.d | 26 ++++ tests/dmd/runnable/extra-files/sectiondefs.d | 13 ++ tests/dmd/runnable/sectiondefs.d | 121 +++++++++++++++++++ 5 files changed, 162 insertions(+) create mode 100644 tests/dmd/runnable/extra-files/sectiondefs.d create mode 100644 tests/dmd/runnable/sectiondefs.d diff --git a/dmd/frontend.h b/dmd/frontend.h index 05058b832e..91261e8a5a 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -8881,6 +8881,7 @@ struct Id final static Identifier* udaOptional; static Identifier* udaMustUse; static Identifier* udaStandalone; + static Identifier* udaSection; static Identifier* TRUE; static Identifier* FALSE; static Identifier* ImportC; diff --git a/dmd/id.d b/dmd/id.d index acd0c95dd6..2b814a8074 100644 --- a/dmd/id.d +++ b/dmd/id.d @@ -500,6 +500,7 @@ immutable Msgtable[] msgtable = { "udaOptional", "optional"}, { "udaMustUse", "mustuse" }, { "udaStandalone", "standalone" }, + { "udaSection", "section" }, // Editions { "__edition_latest_do_not_use", }, diff --git a/runtime/druntime/src/core/attribute.d b/runtime/druntime/src/core/attribute.d index 2b35b8d7c0..5e9a97ff98 100644 --- a/runtime/druntime/src/core/attribute.d +++ b/runtime/druntime/src/core/attribute.d @@ -83,6 +83,32 @@ else // GDC and LDC declare this attribute in their own modules. } +/** +* When applied to a global variable, causes it to be emitted to a +* non-standard object file/executable section. +* +* The target platform might impose certain restrictions on the format for +* section names. +* +* Examples: +* --- +* import core.attributes; +* +* @section("mySection") int myGlobal; +* --- +*/ +version (DigitalMars) +{ + struct section + { + string name; + } +} +else +{ + // GDC and LDC declare this attribute in their own modules. +} + /** * Use this attribute to attach an Objective-C selector to a method. * diff --git a/tests/dmd/runnable/extra-files/sectiondefs.d b/tests/dmd/runnable/extra-files/sectiondefs.d new file mode 100644 index 0000000000..764057839a --- /dev/null +++ b/tests/dmd/runnable/extra-files/sectiondefs.d @@ -0,0 +1,13 @@ +module extrafiles.sectiondefs; +import core.attribute; + +version(Windows) + enum PlatformEntryName(string Name) = "." ~ Name ~ "$N"; +else + enum PlatformEntryName(string Name) = Name; + +@section(PlatformEntryName!"myInts") +__gshared int anInt = 9; + +@section(PlatformEntryName!"my8Ints") +__gshared int[8] an8Int = [64, 72, 9, 81, 21, 59, 45, 2]; diff --git a/tests/dmd/runnable/sectiondefs.d b/tests/dmd/runnable/sectiondefs.d new file mode 100644 index 0000000000..a94a636c03 --- /dev/null +++ b/tests/dmd/runnable/sectiondefs.d @@ -0,0 +1,121 @@ +/* +EXTRA_SOURCES: extra-files/sectiondefs.d +EXTRA_FILES: extra-files/sectiondefs.d +REQUIRED_ARGS(windows): -L/INCREMENTAL:NO +*/ +// Incremental linking must be turned off, or it will add padding. +module sectiondefs; +import core.attribute; + +version (ELFv1) + version = ELF; +else version (ELFv2) + version = ELF; + +version(Windows) + enum PlatformEntryName(string Name) = "." ~ Name ~ "$N"; +else + enum PlatformEntryName(string Name) = Name; + +mixin template SectionRange(string SectionName, Type) +{ + version (OSX) + { + enum Segment = (is(Type == const) || is(Type == immutable)) ? "__TEXT" : "__DATA"; + + extern(C) extern __gshared + { + pragma(mangle, "section$start$" ~ Segment ~ "$" ~ SectionName) + Type start; + pragma(mangle, "section$end$" ~ Segment ~ "$" ~ SectionName) + Type end; + } + } + else version (ELF) + { + extern(C) extern __gshared + { + pragma(mangle, "__start_" ~ SectionName) + Type start; + pragma(mangle, "__stop_" ~ SectionName) + Type end; + } + } + else version (Windows) + { + __gshared + { + @section("." ~ SectionName ~ "$A") + Type _head; + + @section("." ~ SectionName ~ "$Z") + Type _tail; + } + + Type* start() + { + return &_head + 1; + } + + Type* end() + { + return &_tail; + } + } + + Type[] range() + { + version (Windows) + return start()[0 .. end() - start()]; + else + return (&start)[0 .. (&end - &start)]; + } +} + +mixin SectionRange!("myInts", int) myIntsSection; +mixin SectionRange!("my8Ints", int[8]) my8IntsSection; + +@section(PlatformEntryName!"myInts") +__gshared int anInt = 2; + +@section(PlatformEntryName!"my8Ints") +__gshared int[8] an8Int = [46, 92, 11, 7, 2, 55, 33, 22]; + +void main() +{ + //int dummy = anInt, dummy8 = an8Int[0]; + + version(none) + { + import core.stdc.stdio; + printf("=========== sectiondefs tests ================\n"); + printf("myInts %p %zd\n", myIntsSection.range.ptr, myIntsSection.range.length); + printf("my8IntsSection %p %zd\n", my8IntsSection.range.ptr, my8IntsSection.range.length); + + version (Windows) + printf("start %p %p\n", myIntsSection.start(), my8IntsSection.start()); + else + printf("start %p %p\n", &myIntsSection.start, &my8IntsSection.start); + + version (Windows) + printf("end %p %p\n", myIntsSection.end(), my8IntsSection.end()); + else + printf("end %p %p\n", &myIntsSection.end, &my8IntsSection.end); + + printf("- "); + foreach (v; myIntsSection.range) + printf("%d, ", v); + printf("\n-\n"); + foreach(v; my8IntsSection.range) + printf(" - [%d, %d, %d, %d, %d, %d, %d, %d],\n", v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]); + printf("\n"); + } + + assert(myIntsSection.range == [2, 9] || myIntsSection.range == [9, 2]); + + assert(my8IntsSection.range == [ + [46, 92, 11, 7, 2, 55, 33, 22], [64, 72, 9, 81, 21, 59, 45, 2] + ] || my8IntsSection.range == [ + [64, 72, 9, 81, 21, 59, 45, 2], [46, 92, 11, 7, 2, 55, 33, 22] + ]); +} From 8e6891ec1de2df5341cc21443373b6f6db45dc8d Mon Sep 17 00:00:00 2001 From: dd Date: Fri, 20 Mar 2026 01:46:43 -0400 Subject: [PATCH 400/440] Druntime: Modernize NetBSD bindings (dlang/dmd!22767) * core.sys.posix.sys.stat: mknod renamed (NetBSD) * core.sys.posix.sys.shm: shmctl renamed * core.sys.posix.sys.stat: Inline mknod pragma * core.sys.posix.sys.resource: getrusage mangle (NetBSD) * core.sys.posix.sys.msg: msgctl mangling (NetBSD) * core.sys.posix.sys.utime: utime mangle (NetBSD) * core.sys.posix.unistd: vfork mangle and add dup3 (NetBSD) * core.stdc.time: NetBSD symbols * core.sys.posix.stdlib: putenv and srandom renames (NetBSD) * core.stdc.stdio: fgetpos/fsetpos mangles (NetBSD) * core.sys.posix.signal: sigtimedwait mangle (NetBSD) * core.sys.posix.setjmp: setjmp & family mangle (NetBSD) * core.sys.posix.sched: sched_rr_get_interval mangle (NetBSD) * core.sys.posix.locale: setlocale mangle (NetBSD) * core.sys.posix.aio: NetBSD definitions * Add newline to core.stdc.time --- runtime/druntime/src/core/stdc/stdio.d | 20 ++++- runtime/druntime/src/core/stdc/time.d | 73 +++++++++++++------ runtime/druntime/src/core/sys/posix/aio.d | 12 +++ runtime/druntime/src/core/sys/posix/locale.d | 13 +++- runtime/druntime/src/core/sys/posix/sched.d | 1 + runtime/druntime/src/core/sys/posix/setjmp.d | 8 +- runtime/druntime/src/core/sys/posix/signal.d | 1 + runtime/druntime/src/core/sys/posix/stdlib.d | 4 +- runtime/druntime/src/core/sys/posix/sys/msg.d | 5 +- .../src/core/sys/posix/sys/resource.d | 2 +- runtime/druntime/src/core/sys/posix/sys/shm.d | 2 +- .../druntime/src/core/sys/posix/sys/stat.d | 2 +- runtime/druntime/src/core/sys/posix/unistd.d | 4 +- runtime/druntime/src/core/sys/posix/utime.d | 2 +- 14 files changed, 109 insertions(+), 40 deletions(-) diff --git a/runtime/druntime/src/core/stdc/stdio.d b/runtime/druntime/src/core/stdc/stdio.d index fcecb9ed56..adb9f9d9a0 100644 --- a/runtime/druntime/src/core/stdc/stdio.d +++ b/runtime/druntime/src/core/stdc/stdio.d @@ -1475,10 +1475,22 @@ size_t fwrite(scope const void* ptr, size_t size, size_t nmemb, FILE* stream); // No unsafe pointer manipulation. @trusted { - /// - int fgetpos(FILE* stream, scope fpos_t * pos); - /// - int fsetpos(FILE* stream, scope const fpos_t* pos); + version (NetBSD) + { + /// + pragma(mangle, "__fgetpos50") + int fgetpos(FILE* stream, scope fpos_t * pos); + /// + pragma(mangle, "__fsetpos50") + int fsetpos(FILE* stream, scope const fpos_t* pos); + } + else + { + /// + int fgetpos(FILE* stream, scope fpos_t * pos); + /// + int fsetpos(FILE* stream, scope const fpos_t* pos); + } /// int fseek(FILE* stream, c_long offset, int whence); diff --git a/runtime/druntime/src/core/stdc/time.d b/runtime/druntime/src/core/stdc/time.d index d7a57655fa..ead533718b 100644 --- a/runtime/druntime/src/core/stdc/time.d +++ b/runtime/druntime/src/core/stdc/time.d @@ -29,26 +29,55 @@ extern (C): nothrow: @nogc: -/// -pragma(mangle, muslRedirTime64Mangle!("difftime", "__difftime64")) -pure double difftime(time_t time1, time_t time0); // MT-Safe -/// -pragma(mangle, muslRedirTime64Mangle!("mktime", "__mktime64")) -@system time_t mktime(scope tm* timeptr); // @system: MT-Safe env locale -/// -pragma(mangle, muslRedirTime64Mangle!("time", "__time64")) -time_t time(scope time_t* timer); +version (NetBSD) +{ + /// + pragma(mangle, "__difftime50") + pure double difftime(time_t time1, time_t time0); // MT-Safe + /// + pragma(mangle, "__mktime50") + @system time_t mktime(scope tm* timeptr); // @system: MT-Safe env locale + /// + pragma(mangle, "__time50") + time_t time(scope time_t* timer); -/// -@system char* asctime(const scope tm* timeptr); // @system: MT-Unsafe race:asctime locale -/// -pragma(mangle, muslRedirTime64Mangle!("ctime", "__ctime64")) -@system char* ctime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf race:asctime env locale -/// -pragma(mangle, muslRedirTime64Mangle!("gmtime", "__gmtime64")) -@system tm* gmtime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale -/// -pragma(mangle, muslRedirTime64Mangle!("localtime", "__localtime64")) -@system tm* localtime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale -/// -@system size_t strftime(scope char* s, size_t maxsize, const scope char* format, const scope tm* timeptr); // @system: MT-Safe env locale + /// + @system char* asctime(const scope tm* timeptr); // @system: MT-Unsafe race:asctime locale + /// + pragma(mangle, "__ctime50") + @system char* ctime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf race:asctime env locale + /// + pragma(mangle, "__gmtime50") + @system tm* gmtime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale + /// + pragma(mangle, "__locatime50") + @system tm* localtime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale + /// + @system size_t strftime(scope char* s, size_t maxsize, const scope char* format, const scope tm* timeptr); // @system: MT-Safe env locale +} +else +{ + /// + pragma(mangle, muslRedirTime64Mangle!("difftime", "__difftime64")) + pure double difftime(time_t time1, time_t time0); // MT-Safe + /// + pragma(mangle, muslRedirTime64Mangle!("mktime", "__mktime64")) + @system time_t mktime(scope tm* timeptr); // @system: MT-Safe env locale + /// + pragma(mangle, muslRedirTime64Mangle!("time", "__time64")) + time_t time(scope time_t* timer); + + /// + @system char* asctime(const scope tm* timeptr); // @system: MT-Unsafe race:asctime locale + /// + pragma(mangle, muslRedirTime64Mangle!("ctime", "__ctime64")) + @system char* ctime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf race:asctime env locale + /// + pragma(mangle, muslRedirTime64Mangle!("gmtime", "__gmtime64")) + @system tm* gmtime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale + /// + pragma(mangle, muslRedirTime64Mangle!("localtime", "__localtime64")) + @system tm* localtime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale + /// + @system size_t strftime(scope char* s, size_t maxsize, const scope char* format, const scope tm* timeptr); // @system: MT-Safe env locale +} diff --git a/runtime/druntime/src/core/sys/posix/aio.d b/runtime/druntime/src/core/sys/posix/aio.d index 3a537a4a57..674fab9fc9 100644 --- a/runtime/druntime/src/core/sys/posix/aio.d +++ b/runtime/druntime/src/core/sys/posix/aio.d @@ -386,6 +386,18 @@ else version (OpenBSD) { // OpenBSD does not implement aio.h } +else version (NetBSD) +{ + int aio_cancel(int fd, aiocb* aiocbp); + int aio_error(const(aiocb)* aiocbp); + int aio_fsync(int op, aiocb* aiocbp); + int aio_read(aiocb* aiocbp); + ssize_t aio_return(aiocb* aiocbp); + pragma(mangle, "__aio_suspend50") + int aio_suspend(const(aiocb*)* aiocb_list, int nitems, const(timespec)* timeout); + int aio_write(aiocb* aiocbp); + int lio_listio(int mode, const(aiocb*)* aiocb_list, int nitems, sigevent* sevp); +} else { int aio_read(aiocb* aiocbp); diff --git a/runtime/druntime/src/core/sys/posix/locale.d b/runtime/druntime/src/core/sys/posix/locale.d index 0864f7c632..821487afd2 100644 --- a/runtime/druntime/src/core/sys/posix/locale.d +++ b/runtime/druntime/src/core/sys/posix/locale.d @@ -118,8 +118,17 @@ version (DarwinBSDLocale) lconv* localeconv(); /// Create a new locale locale_t newlocale(int mask, const char* locale, locale_t base); - /// Set the C library's notion of natural language formatting style - char* setlocale(int category, const char* locale); + version (NetBSD) + { + /// Set the C library's notion of natural language formatting style + pragma(mangle, "__setlocale50") + char* setlocale(int category, const char* locale); + } + else + { + /// Set the C library's notion of natural language formatting style + char* setlocale(int category, const char* locale); + } /// Set the per-thread locale locale_t uselocale (locale_t locale); } diff --git a/runtime/druntime/src/core/sys/posix/sched.d b/runtime/druntime/src/core/sys/posix/sched.d index d579835841..273be5e819 100644 --- a/runtime/druntime/src/core/sys/posix/sched.d +++ b/runtime/druntime/src/core/sys/posix/sched.d @@ -262,6 +262,7 @@ else version (NetBSD) { int sched_get_priority_min(int); int sched_get_priority_max(int); + pragma(mangle, "__sched_rr_get_interval50") int sched_rr_get_interval(pid_t, timespec*); } else version (OpenBSD) diff --git a/runtime/druntime/src/core/sys/posix/setjmp.d b/runtime/druntime/src/core/sys/posix/setjmp.d index 24497a27ae..d1fcb1947c 100644 --- a/runtime/druntime/src/core/sys/posix/setjmp.d +++ b/runtime/druntime/src/core/sys/posix/setjmp.d @@ -257,8 +257,8 @@ else version (NetBSD) static assert(0); alias jmp_buf = _jmp_buf[_JBLEN]; - int setjmp(ref jmp_buf); - void longjmp(ref jmp_buf, int); + pragma(mangle, "__setjmp14") int setjmp(ref jmp_buf); + pragma(mangle, "__longjmp14") void longjmp(ref jmp_buf, int); } else version (OpenBSD) { @@ -486,8 +486,8 @@ else version (NetBSD) static assert(0); alias sigjmp_buf = _sigjmp_buf[_JBLEN + 1]; - int sigsetjmp(ref sigjmp_buf); - void siglongjmp(ref sigjmp_buf, int); + pragma(mangle, "__sigsetjmp14") int sigsetjmp(ref sigjmp_buf); + pragma(mangle, "__siglongjmp14") void siglongjmp(ref sigjmp_buf, int); } else version (OpenBSD) { diff --git a/runtime/druntime/src/core/sys/posix/signal.d b/runtime/druntime/src/core/sys/posix/signal.d index 73da7607c5..94ddd0403d 100644 --- a/runtime/druntime/src/core/sys/posix/signal.d +++ b/runtime/druntime/src/core/sys/posix/signal.d @@ -3019,6 +3019,7 @@ else version (FreeBSD) else version (NetBSD) { int sigqueue(pid_t, int, const sigval); + pragma(mangle, "__sigtimedwait50") int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*); int sigwaitinfo(const scope sigset_t*, siginfo_t*); } diff --git a/runtime/druntime/src/core/sys/posix/stdlib.d b/runtime/druntime/src/core/sys/posix/stdlib.d index 8e8c16fab5..3a6a5d2407 100644 --- a/runtime/druntime/src/core/sys/posix/stdlib.d +++ b/runtime/druntime/src/core/sys/posix/stdlib.d @@ -459,14 +459,14 @@ else version (NetBSD) c_long nrand48(ref ushort[3]); int posix_openpt(int); char* ptsname(int); - int putenv(char*); + pragma(mangle, "__putenv50") int putenv(char*); c_long random(); char* realpath(const scope char*, char*); ushort *seed48(ref ushort[3]); void setkey(const scope char*); char* setstate(const scope char*); void srand48(c_long); - void srandom(uint); + pragma(mangle, "__srandom60") void srandom(uint); int unlockpt(int); } else version (OpenBSD) diff --git a/runtime/druntime/src/core/sys/posix/sys/msg.d b/runtime/druntime/src/core/sys/posix/sys/msg.d index 19e07bd646..519811820f 100644 --- a/runtime/druntime/src/core/sys/posix/sys/msg.d +++ b/runtime/druntime/src/core/sys/posix/sys/msg.d @@ -200,7 +200,10 @@ struct msgbuf char[1] mtext = 0; } -int msgctl(int msqid, int cmd, msqid_ds* __buf); +version (NetBSD) + pragma(mangle, "__msgctl50") int msgctl(int msqid, int cmd, msqid_ds* __buf); +else + int msgctl(int msqid, int cmd, msqid_ds* __buf); int msgget(key_t key, int msgflg); ssize_t msgrcv(int msqid, void* msgp, size_t msgsz, c_long msgtyp, int msgflg); int msgsnd(int msqid, msgbuf* msgp, int msgsz, int msgflg); diff --git a/runtime/druntime/src/core/sys/posix/sys/resource.d b/runtime/druntime/src/core/sys/posix/sys/resource.d index 3da8411d6a..eb62e4950f 100644 --- a/runtime/druntime/src/core/sys/posix/sys/resource.d +++ b/runtime/druntime/src/core/sys/posix/sys/resource.d @@ -530,7 +530,7 @@ else version (NetBSD) { int getpriority(int, int); int getrlimit(int, rlimit*); - int getrusage(int, rusage*); + pragma(mangle, "__getrusage50") int getrusage(int, rusage*); int setpriority(int, int, int); int setrlimit(int, const scope rlimit*); } diff --git a/runtime/druntime/src/core/sys/posix/sys/shm.d b/runtime/druntime/src/core/sys/posix/sys/shm.d index 927778dd2a..358fcf9e32 100644 --- a/runtime/druntime/src/core/sys/posix/sys/shm.d +++ b/runtime/druntime/src/core/sys/posix/sys/shm.d @@ -219,7 +219,7 @@ else version (NetBSD) enum SHMLBA = 1 << 12; // PAGE_SIZE = (1< Date: Fri, 20 Mar 2026 18:36:01 +0000 Subject: [PATCH 401/440] Fix Bugzilla 22752: Force semantic analysis of fields before is() conversion check (dlang/dmd!22760) Co-authored-by: CHIKI Badreddine --- dmd/typesem.d | 3 +++ tests/dmd/compilable/test22752.d | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/dmd/compilable/test22752.d diff --git a/dmd/typesem.d b/dmd/typesem.d index 492362799f..997831ee28 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -9233,6 +9233,9 @@ MATCH implicitConvToWithoutAliasThis(TypeStruct from, Type to) /* Check all the fields. If they can all be converted, * allow the conversion. */ + import dmd.dsymbolsem : size; + if (from.sym.size(Loc.initial) == SIZE_INVALID) + return MATCH.nomatch; MATCH m = MATCH.constant; uint offset = ~0; // must never match a field offset foreach (v; from.sym.fields[]) diff --git a/tests/dmd/compilable/test22752.d b/tests/dmd/compilable/test22752.d new file mode 100644 index 0000000000..6dc880550b --- /dev/null +++ b/tests/dmd/compilable/test22752.d @@ -0,0 +1,23 @@ +/* +REQUIRED_ARGS: +PERMUTE_ARGS: +*/ + +struct S +{ + int isnot; + int[] arguments; +} + +struct Array(T) +{ + static if (is(const(T) : T)) + { + void insert() + { + static assert (is(const(T) : T)); + } + } +} + +alias A = Array!S; From 05e979802ee02494920c1c7392a30335b40c2aa7 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 21 Mar 2026 01:08:45 +0000 Subject: [PATCH 402/440] Only `pragma(printf)` functions marked @safe or @trusted are @safe (dlang/dmd!22773) Also explain why when not safe to call. Add test cases for non-literal format string and @system function. --- dmd/expressionsem.d | 20 ++++++++++++----- tests/dmd/fail_compilation/safeprintf.d | 30 +++++++++++++++++-------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 027651a56c..b77a844fc4 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -3411,21 +3411,31 @@ private bool checkSafety(FuncDeclaration f, ref Loc loc, Scope* sc, Expressions* return false; } - if (f.printf) + if (f.printf && (f.isSafe() || f.isTrusted())) { TypeFunction tf = f.type.isTypeFunction(); assert(tf); const isVa_list = tf.parameterList.varargs == VarArg.none; const nparams = tf.parameterList.length; const nargs = arguments ? arguments.length : 0; - if (nparams == 1 && nargs) + assert(nparams && nargs); // should have been verified already + if (auto se = (*arguments)[nparams - 1 - isVa_list].isStringExp()) { - if (auto se = (*arguments)[nparams - 1 - isVa_list].isStringExp()) + if (!isFormatSafe(se.peekString())) { - if (isFormatSafe(se.peekString())) - return false; + error(loc, "calling `pragma(printf)` %s `%s` with format string `%s` is not `@safe`", + f.kind(), f.toPrettyChars(), se.toChars()); + .errorSupplemental(f.loc, "`%s` is declared here", f.toPrettyChars()); + return true; } } + else + { + error(loc, "calling `pragma(printf)` %s `%s` with non-literal format string is not `@safe`", + f.kind(), f.toPrettyChars()); + .errorSupplemental(f.loc, "`%s` is declared here", f.toPrettyChars()); + return true; + } } if (!f.isSafe() && !f.isTrusted()) diff --git a/tests/dmd/fail_compilation/safeprintf.d b/tests/dmd/fail_compilation/safeprintf.d index 60bff2a879..fcb735920a 100644 --- a/tests/dmd/fail_compilation/safeprintf.d +++ b/tests/dmd/fail_compilation/safeprintf.d @@ -2,22 +2,34 @@ DISABLED: win32 win64 freebsd32 openbsd32 linux32 osx32 TEST_OUTPUT: --- -fail_compilation/safeprintf.d(20): Error: `@safe` function `safeprintf.func` cannot call `@system` function `safeprintf.printf` -fail_compilation/safeprintf.d(15): `safeprintf.printf` is declared here -fail_compilation/safeprintf.d(21): Error: `@safe` function `safeprintf.func` cannot call `@system` function `safeprintf.printf` -fail_compilation/safeprintf.d(15): `safeprintf.printf` is declared here -fail_compilation/safeprintf.d(22): Error: `@safe` function `safeprintf.func` cannot call `@system` function `safeprintf.printf` -fail_compilation/safeprintf.d(15): `safeprintf.printf` is declared here -fail_compilation/safeprintf.d(22): Deprecation: format specifier `"%Z"` is invalid +fail_compilation/safeprintf.d(29): Error: calling `pragma(printf)` function `safeprintf.printf` with format string `"s: %s\n"` is not `@safe` +fail_compilation/safeprintf.d(21): `safeprintf.printf` is declared here +fail_compilation/safeprintf.d(30): Error: calling `pragma(printf)` function `safeprintf.printf` with format string `"s: %S\n"` is not `@safe` +fail_compilation/safeprintf.d(21): `safeprintf.printf` is declared here +fail_compilation/safeprintf.d(31): Error: calling `pragma(printf)` function `safeprintf.printf` with format string `"s: %Z\n"` is not `@safe` +fail_compilation/safeprintf.d(21): `safeprintf.printf` is declared here +fail_compilation/safeprintf.d(31): Deprecation: format specifier `"%Z"` is invalid +fail_compilation/safeprintf.d(32): Error: calling `pragma(printf)` function `safeprintf.printf` with non-literal format string is not `@safe` +fail_compilation/safeprintf.d(21): `safeprintf.printf` is declared here +fail_compilation/safeprintf.d(33): Error: calling `pragma(printf)` function `safeprintf.bar` with format string `"%s"` is not `@safe` +fail_compilation/safeprintf.d(22): `safeprintf.bar` is declared here +fail_compilation/safeprintf.d(34): Error: `@safe` function `safeprintf.func` cannot call `@system` function `safeprintf.sys_printf` +fail_compilation/safeprintf.d(23): `safeprintf.sys_printf` is declared here --- */ -extern (C) @system pragma(printf) int printf(const(char)* format, ...); +extern (C) @trusted pragma(printf) int printf(const(char)* format, ...); +extern(C) pragma(printf) @trusted void bar(int, const char*, ...); +extern (C) @system pragma(printf) int sys_printf(const(char)* format, ...); @safe void func(int i, char* s, dchar* d) { - printf("i: %d\n", i); + printf("no specs"); // OK + printf("i: %d\n", i); // OK printf("s: %s\n", s); printf("s: %S\n", d); printf("s: %Z\n", s); + printf(s, i); // non-literal + bar(1, "%s", s); // preceding args + sys_printf("d", i); } From bb5dfac62eb8d3b34feb2ac2b44540c9cbc3a398 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 21 Mar 2026 06:59:13 -0700 Subject: [PATCH 403/440] implement deh_win64_posix.terminate() (dlang/dmd!22780) --- runtime/druntime/src/rt/deh_win64_posix.d | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/runtime/druntime/src/rt/deh_win64_posix.d b/runtime/druntime/src/rt/deh_win64_posix.d index c99a0bf299..184f39bebd 100644 --- a/runtime/druntime/src/rt/deh_win64_posix.d +++ b/runtime/druntime/src/rt/deh_win64_posix.d @@ -113,8 +113,11 @@ void terminate() { version (AArch64) { - int* p = null; - *p = 0; // TODO AArch64 + asm + { + naked; + op 0xD440_0000; // INSTR.hlt https://www.scs.stanford.edu/~zyedidia/arm64/hlt.html + } } else asm From 841a1996818de6ed441e0f94c719bfe0be949758 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 21 Mar 2026 19:03:13 -0700 Subject: [PATCH 404/440] use malloc() instead of alloca() until I implement alloca() (dlang/dmd!22788) --- runtime/druntime/src/rt/dmain2.d | 45 +++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/runtime/druntime/src/rt/dmain2.d b/runtime/druntime/src/rt/dmain2.d index 0f9593f894..ce1e03bbf3 100644 --- a/runtime/druntime/src/rt/dmain2.d +++ b/runtime/druntime/src/rt/dmain2.d @@ -44,6 +44,9 @@ else version (Posix) import core.stdc.string : strlen; } +version (DigitalMars) version (AArch64) + version = UseMalloc; // cuz alloca() is not implemented yet + // not sure why we can't define this in one place, but this is to keep this // module from importing core.runtime. struct UnitTestResult @@ -279,14 +282,30 @@ extern (C) int _d_run_main(int argc, char** argv, MainFunc mainFunc) // assert(wargc == argc); /* argc can be broken by Unicode arguments */ // Allocate args[] on the stack - use wargc - char[][] args = (cast(char[]*) alloca(wargc * (char[]).sizeof))[0 .. wargc]; + version (UseMalloc) + { + char[][] args = (cast(char[]*) malloc(wargc * (char[]).sizeof))[0 .. wargc]; + if (wargc) + assert(args.ptr); + scope (exit) free(args.ptr); + } + else + char[][] args = (cast(char[]*) alloca(wargc * (char[]).sizeof))[0 .. wargc]; // This is required because WideCharToMultiByte requires int as input. assert(wCommandLineLength <= cast(size_t) int.max, "Wide char command line length must not exceed int.max"); immutable size_t totalArgsLength = WideCharToMultiByte(CP_UTF8, 0, wCommandLine, cast(int)wCommandLineLength, null, 0, null, null); { - char* totalArgsBuff = cast(char*) alloca(totalArgsLength); + version (UseMalloc) + { + char* totalArgsBuff = cast(char*) malloc(totalArgsLength); + if (totalArgsLength) + assert(totalArgsBuff); + scope (exit) free(totalArgsBuff); + } + else + char* totalArgsBuff = cast(char*) alloca(totalArgsLength); size_t j = 0; foreach (i; 0 .. wargc) { @@ -308,7 +327,15 @@ extern (C) int _d_run_main(int argc, char** argv, MainFunc mainFunc) else version (Posix) { // Allocate args[] on the stack - char[][] args = (cast(char[]*) alloca(argc * (char[]).sizeof))[0 .. argc]; + version (UseMalloc) + { + char[][] args = (cast(char[]*) malloc(argc * (char[]).sizeof))[0 .. argc]; + if (argc) + assert(args.ptr); + scope (exit) free(args.ptr); + } + else + char[][] args = (cast(char[]*) alloca(argc * (char[]).sizeof))[0 .. argc]; size_t totalArgsLength = 0; foreach (i, ref arg; args) @@ -434,7 +461,17 @@ private extern (C) int _d_run_main2(char[][] args, size_t totalArgsLength, MainF */ { _d_args = cast(string[]) args; - auto buff = cast(char[]*) alloca(args.length * (char[]).sizeof + totalArgsLength); + + auto length = args.length * (char[]).sizeof + totalArgsLength; + version (UseMalloc) + { + auto buff = cast(char[]*) malloc(length); + if (length) + assert(buff); + //scope (exit) buff; + } + else + auto buff = cast(char[]*) alloca(length); char[][] argsCopy = buff[0 .. args.length]; auto argBuff = cast(char*) (buff + args.length); From 671a918bc5067584533ff9fd11b8f46603226b1a Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Mon, 23 Mar 2026 10:37:50 +0800 Subject: [PATCH 405/440] [cparse.d] reduce indentation in `cparseGnuAttribute` (dlang/dmd!22792) --- dmd/cparse.d | 173 +++++++++++++++++++++++++-------------------------- 1 file changed, 86 insertions(+), 87 deletions(-) diff --git a/dmd/cparse.d b/dmd/cparse.d index c005493a97..e1793ae542 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -3656,109 +3656,108 @@ final class CParser(AST) : Parser!AST if (!isGnuAttributeName()) return; - if (token.value == TOK.identifier) + if (token.value != TOK.identifier) { - if (token.ident == Id.aligned) - { - nextToken(); - if (token.value == TOK.leftParenthesis) - { - nextToken(); - AST.Expression exp = cparseConstantExp(); - if (!specifier.alignAttrs) - specifier.alignAttrs = new AST.Expressions(); - specifier.alignAttrs.push(exp); - check(TOK.rightParenthesis); - } - else - { - /* ignore __attribute__((aligned)), which sets the alignment to the largest value for any data - * type on the target machine. It's the opposite of __attribute__((packed)) - */ - } - } - else if (token.ident == Id.packed) - { - specifier.packalign.set(1); - specifier.packalign.setPack(); - nextToken(); - } - else if (token.ident == Id.always_inline) // https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html - { - specifier.scw |= SCW.xinline; - nextToken(); - } - else if (token.ident == Id._deprecated) - { - specifier._deprecated = true; - nextToken(); - if (token.value == TOK.leftParenthesis) // optional deprecation message - { - nextToken(); - specifier.depMsg = cparseExpression(); - check(TOK.rightParenthesis); - } - } - else if (token.ident == Id.dllimport) - { - specifier.dllimport = true; - nextToken(); - } - else if (token.ident == Id.dllexport) - { - specifier.dllexport = true; - nextToken(); - } - else if (token.ident == Id.naked) - { - specifier.naked = true; - nextToken(); - } - else if (token.ident == Id.noinline) - { - specifier.scw |= SCW.xnoinline; - nextToken(); - } - else if (token.ident == Id.noreturn) + nextToken(); + if (token.value == TOK.leftParenthesis) + cparseParens(); + return; + } + + if (token.ident == Id.aligned) + { + nextToken(); + if (token.value == TOK.leftParenthesis) { - specifier.noreturn = true; nextToken(); + AST.Expression exp = cparseConstantExp(); + if (!specifier.alignAttrs) + specifier.alignAttrs = new AST.Expressions(); + specifier.alignAttrs.push(exp); + check(TOK.rightParenthesis); } - else if (token.ident == Id._nothrow) + else { - specifier._nothrow = true; - nextToken(); + /* ignore __attribute__((aligned)), which sets the alignment to the largest value for any data + * type on the target machine. It's the opposite of __attribute__((packed)) + */ } - else if (token.ident == Id._pure) + } + else if (token.ident == Id.packed) + { + specifier.packalign.set(1); + specifier.packalign.setPack(); + nextToken(); + } + else if (token.ident == Id.always_inline) // https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html + { + specifier.scw |= SCW.xinline; + nextToken(); + } + else if (token.ident == Id._deprecated) + { + specifier._deprecated = true; + nextToken(); + if (token.value == TOK.leftParenthesis) // optional deprecation message { - specifier._pure = true; nextToken(); + specifier.depMsg = cparseExpression(); + check(TOK.rightParenthesis); } - else if (token.ident == Id.vector_size) + } + else if (token.ident == Id.dllimport) + { + specifier.dllimport = true; + nextToken(); + } + else if (token.ident == Id.dllexport) + { + specifier.dllexport = true; + nextToken(); + } + else if (token.ident == Id.naked) + { + specifier.naked = true; + nextToken(); + } + else if (token.ident == Id.noinline) + { + specifier.scw |= SCW.xnoinline; + nextToken(); + } + else if (token.ident == Id.noreturn) + { + specifier.noreturn = true; + nextToken(); + } + else if (token.ident == Id._nothrow) + { + specifier._nothrow = true; + nextToken(); + } + else if (token.ident == Id._pure) + { + specifier._pure = true; + nextToken(); + } + else if (token.ident == Id.vector_size) + { + nextToken(); + check(TOK.leftParenthesis); + if (token.value == TOK.int32Literal) { + const n = token.unsvalue; + if (n < 1 || n & (n - 1) || ushort.max < n) + error("__attribute__((vector_size(%lld))) must be an integer positive power of 2 and be <= 32,768", cast(ulong)n); + specifier.vector_size = cast(uint) n; nextToken(); - check(TOK.leftParenthesis); - if (token.value == TOK.int32Literal) - { - const n = token.unsvalue; - if (n < 1 || n & (n - 1) || ushort.max < n) - error("__attribute__((vector_size(%lld))) must be an integer positive power of 2 and be <= 32,768", cast(ulong)n); - specifier.vector_size = cast(uint) n; - nextToken(); - } - else - { - error("value for vector_size expected, not `%s`", token.toChars()); - nextToken(); - } - check(TOK.rightParenthesis); } else { + error("value for vector_size expected, not `%s`", token.toChars()); nextToken(); - if (token.value == TOK.leftParenthesis) - cparseParens(); } + check(TOK.rightParenthesis); } else { From 1c2ee903143a2e935e0a0044c5ff52263e7da263 Mon Sep 17 00:00:00 2001 From: Dennis Date: Mon, 23 Mar 2026 03:41:48 +0100 Subject: [PATCH 406/440] Fix dlang/dmd!22754 - Move Object.__monitor to druntime (dlang/dmd!22766) Co-Authored-By: Claude Sonnet 4.6 Fix cxx unittest Keep shared(Object).__monitor a void* Fix 32-bit Windows assertion failure Skip __monitor in TypeInfo_Class.m_flags --- dmd/dclass.d | 10 +++++-- dmd/dinterpret.d | 8 +++++- dmd/dsymbolsem.d | 2 -- dmd/dtoh.d | 3 +++ dmd/expressionsem.d | 6 ++++- dmd/statementsem.d | 6 +++++ dmd/traits.d | 3 +++ dmd/typesem.d | 16 ++++------- runtime/druntime/src/core/sync/mutex.d | 2 +- runtime/druntime/src/core/sync/rwmutex.d | 10 ++++--- runtime/druntime/src/object.d | 6 +++++ tests/dmd/compilable/b18242.d | 2 +- .../no_monitor_synchronized/object.d | 5 ++++ tests/dmd/fail_compilation/fail_opover.d | 2 +- .../no_monitor_synchronized.d | 27 +++++++++++++++++++ tests/dmd/runnable/test42.d | 6 +++++ 16 files changed, 90 insertions(+), 24 deletions(-) create mode 100644 tests/dmd/fail_compilation/extra-files/no_monitor_synchronized/object.d create mode 100644 tests/dmd/fail_compilation/no_monitor_synchronized.d diff --git a/dmd/dclass.d b/dmd/dclass.d index 950f7db113..7edcc42da8 100644 --- a/dmd/dclass.d +++ b/dmd/dclass.d @@ -333,11 +333,17 @@ extern (C++) class ClassDeclaration : AggregateDeclaration } /************** - * Returns: true if there's a __monitor field + * Returns: true if there's a __monitor field, i.e. the druntime `Object` class declares it */ final bool hasMonitor() { - return classKind == ClassKind.d; + if (classKind != ClassKind.d) + return false; + // Check if Object in druntime actually declares a __monitor field. + // Custom druntimes can omit it by not declaring it in Object. + if (!object || !object.symtab) + return true; // conservative: Object not yet loaded, assume monitor present + return object.symtab.lookup(Id.__monitor) !is null; } /**************************************** diff --git a/dmd/dinterpret.d b/dmd/dinterpret.d index fb07953ace..65b24a0a0c 100644 --- a/dmd/dinterpret.d +++ b/dmd/dinterpret.d @@ -2867,8 +2867,11 @@ public: size_t totalFieldCount = 0; for (ClassDeclaration c = cd; c; c = c.baseClass) totalFieldCount += c.fields.length; + + totalFieldCount -= cd.hasMonitor(); // skip __monitor field + auto elems = new Expressions(totalFieldCount); - size_t fieldsSoFar = totalFieldCount; + ptrdiff_t fieldsSoFar = totalFieldCount; for (ClassDeclaration c = cd; c; c = c.baseClass) { fieldsSoFar -= c.fields.length; @@ -2880,6 +2883,9 @@ public: result = CTFEExp.cantexp; return; } + if (fieldsSoFar + ptrdiff_t(i) < 0) // field -1 = __monitor which we skip + break; + Expression m; if (v._init) { diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 16709bc113..372022f613 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -9978,8 +9978,6 @@ private extern(C++) class FinalizeSizeVisitor : Visitor { outerCd.alignsize = target.ptrsize; outerCd.structsize = target.ptrsize; // allow room for __vptr - if (outerCd.hasMonitor()) - outerCd.structsize += target.ptrsize; // allow room for __monitor } //printf("finalizeSize() %s, sizeok = %d\n", toChars(), sizeok); diff --git a/dmd/dtoh.d b/dmd/dtoh.d index 10a4824d57..f7754a025a 100644 --- a/dmd/dtoh.d +++ b/dmd/dtoh.d @@ -1065,6 +1065,9 @@ public: if (adparent) { + if (vd.ident && vd.ident == Id.__monitor) + return; + writeProtection(vd.visibility.kind); typeToBuffer(type, vd, true); buf.writestringln(";"); diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index b77a844fc4..443dfabde7 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -9981,7 +9981,11 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (t1.ty == Tpointer) t1 = t1.nextOf(); - exp.type = exp.type.addMod(t1.mod); + // __monitor is always void* regardless of shared - strip shared from the mod + auto t1mod = t1.mod; + if (exp.var.ident == Id.__monitor) + t1mod &= ~MODFlags.shared_; + exp.type = exp.type.addMod(t1mod); // https://issues.dlang.org/show_bug.cgi?id=23109 // Run semantic on the DotVarExp type diff --git a/dmd/statementsem.d b/dmd/statementsem.d index 2f7b442d3a..60294f77b6 100644 --- a/dmd/statementsem.d +++ b/dmd/statementsem.d @@ -3129,6 +3129,12 @@ Statement statementSemanticVisit(Statement s, Scope* sc) ss.exp = new CastExp(ss.loc, ss.exp, t); ss.exp = ss.exp.expressionSemantic(sc); } + if (!cd.hasMonitor()) + { + error(ss.loc, "cannot `synchronize` on a `%s` because `object.Object` has no `__monitor` field", + cd.toChars()); + return setError(); + } version (all) { /* Rewrite as: diff --git a/dmd/traits.d b/dmd/traits.d index bcc004047e..d8aadfe38a 100644 --- a/dmd/traits.d +++ b/dmd/traits.d @@ -267,6 +267,8 @@ ulong getTypePointerBitmap(Loc loc, Type t, ref Array!(ulong) data, ErrorSink eS visitTopLevelClass(t.sym.baseClass.type.isTypeClass()); foreach (v; t.sym.fields) { + if (v.ident == Id.__monitor) + continue; // __monitor is not GC-managed offset = classoff + v.offset; visit(v.type); } @@ -1786,6 +1788,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc) // Skip over internal members in __traits(allMembers) if ((sm.isCtorDeclaration() && sm.ident != Id.ctor) || (sm.isDtorDeclaration() && sm.ident != Id.dtor) || + (sm.ident == Id.__monitor) || (sm.isPostBlitDeclaration() && sm.ident != Id.postblit) || sm.isInvariantDeclaration() || sm.isUnitTestDeclaration()) diff --git a/dmd/typesem.d b/dmd/typesem.d index 997831ee28..8e8a9ee120 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -7069,6 +7069,11 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag // Don't include hidden 'this' pointer if (v.isThisDeclaration()) continue; + + // Don't include __monitor field + if (v.ident == Id.__monitor) + continue; + Expression ex; if (ev) ex = new DotVarExp(e.loc, ev, v); @@ -7182,17 +7187,6 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag return e; } - if (ident == Id.__monitor && mt.sym.hasMonitor()) - { - /* The handle to the monitor (call it a void*) - * *(cast(void**)e + 1) - */ - e = e.castTo(sc, mt.tvoidptr.pointerTo()); - e = new AddExp(e.loc, e, IntegerExp.literal!1); - e = new PtrExp(e.loc, e); - e = e.expressionSemantic(sc); - return e; - } if (ident == Id.outer && mt.sym.vthis) { diff --git a/runtime/druntime/src/core/sync/mutex.d b/runtime/druntime/src/core/sync/mutex.d index 86a112119d..054d257198 100644 --- a/runtime/druntime/src/core/sync/mutex.d +++ b/runtime/druntime/src/core/sync/mutex.d @@ -102,7 +102,7 @@ class Mutex : auto self = cast(Mutex) this; self.m_proxy.link = self; - this.__monitor = cast(void*) &m_proxy; + self.__monitor = cast(void*) &self.m_proxy; } diff --git a/runtime/druntime/src/core/sync/rwmutex.d b/runtime/druntime/src/core/sync/rwmutex.d index e46b2f736f..7a260916bc 100644 --- a/runtime/druntime/src/core/sync/rwmutex.d +++ b/runtime/druntime/src/core/sync/rwmutex.d @@ -201,8 +201,9 @@ class ReadWriteMutex this(this Q)() @trusted nothrow if (is(Q == Reader) || is(Q == shared Reader)) { - m_proxy.link = cast(typeof(m_proxy.link)) this; - this.__monitor = cast(void*) &m_proxy; + auto self = cast(Reader) this; + self.m_proxy.link = cast(typeof(self.m_proxy.link)) this; + self.__monitor = cast(void*) &self.m_proxy; } /** @@ -372,8 +373,9 @@ class ReadWriteMutex this(this Q)() @trusted nothrow if (is(Q == Writer) || is(Q == shared Writer)) { - m_proxy.link = cast(typeof(m_proxy.link)) this; - this.__monitor = cast(void*) &m_proxy; + auto self = cast(Writer) this; + self.m_proxy.link = cast(typeof(self.m_proxy.link)) this; + self.__monitor = cast(void*) &self.m_proxy; } diff --git a/runtime/druntime/src/object.d b/runtime/druntime/src/object.d index e6c6db6e5b..5960968709 100644 --- a/runtime/druntime/src/object.d +++ b/runtime/druntime/src/object.d @@ -105,11 +105,17 @@ else version (AArch64) else version = WithArgTypes; } +static assert(Object.__monitor.offsetof == size_t.sizeof); + /** * All D class objects inherit from Object. */ class Object { + // This is an internal field that is omitted from .tupleof, __traits(allMembers), pointer bitmaps etc. + // It can be removed in a custom druntime, but if it's there it must remain the first field. + void* __monitor; + /** * Convert Object to a human readable string. */ diff --git a/tests/dmd/compilable/b18242.d b/tests/dmd/compilable/b18242.d index 9909620ae3..4947eb6218 100644 --- a/tests/dmd/compilable/b18242.d +++ b/tests/dmd/compilable/b18242.d @@ -7,7 +7,7 @@ class Object { } class TypeInfo { } class TypeInfo_Class : TypeInfo { - version(D_LP64) { ubyte[136+16] _x; } else { ubyte[68+16] _x; } + version(D_LP64) { ubyte[136+24] _x; } else { ubyte[68+20] _x; } } class Throwable { } diff --git a/tests/dmd/fail_compilation/extra-files/no_monitor_synchronized/object.d b/tests/dmd/fail_compilation/extra-files/no_monitor_synchronized/object.d new file mode 100644 index 0000000000..4a2a31493b --- /dev/null +++ b/tests/dmd/fail_compilation/extra-files/no_monitor_synchronized/object.d @@ -0,0 +1,5 @@ +module object; + +alias size_t = typeof(int.sizeof); + +class Object {} diff --git a/tests/dmd/fail_compilation/fail_opover.d b/tests/dmd/fail_compilation/fail_opover.d index a58b2bdd90..3a0b75fc46 100644 --- a/tests/dmd/fail_compilation/fail_opover.d +++ b/tests/dmd/fail_compilation/fail_opover.d @@ -4,7 +4,7 @@ TEST_OUTPUT: --- fail_compilation/fail_opover.d(39): Error: no `[]` operator overload for type `object.Object` -$p:object.d$(111): perhaps define `auto opIndex() {}` for `object.Object` +$p:object.d$($n$): perhaps define `auto opIndex() {}` for `object.Object` fail_compilation/fail_opover.d(43): Error: no `[]` operator overload for type `TestS` fail_compilation/fail_opover.d(41): perhaps define `auto opIndex() {}` for `fail_opover.test1.TestS` fail_compilation/fail_opover.d(55): Error: no `[]` operator overload for type `S` diff --git a/tests/dmd/fail_compilation/no_monitor_synchronized.d b/tests/dmd/fail_compilation/no_monitor_synchronized.d new file mode 100644 index 0000000000..58c53e6bb4 --- /dev/null +++ b/tests/dmd/fail_compilation/no_monitor_synchronized.d @@ -0,0 +1,27 @@ +/* +DFLAGS: +REQUIRED_ARGS: -c +EXTRA_SOURCES: extra-files/no_monitor_synchronized/object.d +TEST_OUTPUT: +--- +fail_compilation/no_monitor_synchronized.d(20): Error: cannot `synchronize` on a `Foo` because `object.Object` has no `__monitor` field +--- +*/ + +// Test using synchronized(obj) with a custom druntime that has no __monitor field + +class Foo +{ + int x; +} + +void test(Foo f) +{ + synchronized(f) {} + + // Bare synchronized (uses critical section, not monitor) still compiles + synchronized {} +} + +// Check that there's only a vtbl before x, no hidden monitor field +static assert(Foo.x.offsetof == size_t.sizeof); diff --git a/tests/dmd/runnable/test42.d b/tests/dmd/runnable/test42.d index 29a6bd9a7c..bc480fbfbe 100644 --- a/tests/dmd/runnable/test42.d +++ b/tests/dmd/runnable/test42.d @@ -1315,6 +1315,12 @@ void test79() // writeln(c.__monitor); assert(c.__monitor !is null); } + + // __monitor on a shared object is still void*, not shared(void*) + shared C79 sc = new shared C79(); + void* p = cast(void*) 0x1; + sc.__monitor = p; + assert(sc.__monitor == p); } /***************************************************/ From 2aa49bf6b5cc6fd4f19128cb1af45e654fa7c9f1 Mon Sep 17 00:00:00 2001 From: yelninei Date: Mon, 23 Mar 2026 02:42:13 +0000 Subject: [PATCH 407/440] dmd: file: Add PROT_READ to mmap protections. (dlang/dmd!22787) The file is opened O_RDWR. --- dmd/common/file.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dmd/common/file.d b/dmd/common/file.d index dad41de13e..7b7c2bf6a7 100644 --- a/dmd/common/file.d +++ b/dmd/common/file.d @@ -121,7 +121,7 @@ struct FileMapping(Datum) if (size > 0 && size != ulong.max && size <= size_t.max) { - auto p = mmap(null, cast(size_t) size, is(Datum == const) ? PROT_READ : PROT_WRITE, MAP_SHARED, handle, 0); + auto p = mmap(null, cast(size_t) size, is(Datum == const) ? PROT_READ : (PROT_READ | PROT_WRITE), MAP_SHARED, handle, 0); if (p == MAP_FAILED) { fprintf(stderr, "mmap(null, %zu) for \"%s\" failed: %s\n", cast(size_t) size, filename, strerror(errno)); @@ -382,8 +382,8 @@ struct FileMapping(Datum) } if (size > 0) { - auto p = mmap(null, size, PROT_WRITE, MAP_SHARED, handle, 0); - if (cast(ssize_t) p == -1) + auto p = mmap(null, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle, 0); + if (p == MAP_FAILED) { fprintf(stderr, "mmap() failed for \"%s\": %s\n", filename, strerror(errno)); exit(1); From e1e923bb9974eca8ac058116dd10f7f1ab5ff231 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Mon, 23 Mar 2026 02:42:28 +0000 Subject: [PATCH 408/440] Allow calling trusted `pragma(printf)` function from system code (dlang/dmd!22785) --- dmd/expressionsem.d | 12 ++++++------ tests/dmd/fail_compilation/safeprintf.d | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 443dfabde7..b5d0d5c834 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -3423,17 +3423,17 @@ private bool checkSafety(FuncDeclaration f, ref Loc loc, Scope* sc, Expressions* { if (!isFormatSafe(se.peekString())) { - error(loc, "calling `pragma(printf)` %s `%s` with format string `%s` is not `@safe`", - f.kind(), f.toPrettyChars(), se.toChars()); - .errorSupplemental(f.loc, "`%s` is declared here", f.toPrettyChars()); + if (sc.setUnsafe(false, loc, + "calling `pragma(printf)` function `%s` with format string `%s`", f, se)) + .errorSupplemental(f.loc, "`%s` is declared here", f.toPrettyChars()); return true; } } else { - error(loc, "calling `pragma(printf)` %s `%s` with non-literal format string is not `@safe`", - f.kind(), f.toPrettyChars()); - .errorSupplemental(f.loc, "`%s` is declared here", f.toPrettyChars()); + if (sc.setUnsafe(false, loc, + "calling `pragma(printf)` function `%s` with non-literal format string", f)) + .errorSupplemental(f.loc, "`%s` is declared here", f.toPrettyChars()); return true; } } diff --git a/tests/dmd/fail_compilation/safeprintf.d b/tests/dmd/fail_compilation/safeprintf.d index fcb735920a..4f2dd42e4b 100644 --- a/tests/dmd/fail_compilation/safeprintf.d +++ b/tests/dmd/fail_compilation/safeprintf.d @@ -2,16 +2,16 @@ DISABLED: win32 win64 freebsd32 openbsd32 linux32 osx32 TEST_OUTPUT: --- -fail_compilation/safeprintf.d(29): Error: calling `pragma(printf)` function `safeprintf.printf` with format string `"s: %s\n"` is not `@safe` +fail_compilation/safeprintf.d(29): Error: calling `pragma(printf)` function `printf` with format string `"s: %s\n"` is not allowed in a `@safe` function fail_compilation/safeprintf.d(21): `safeprintf.printf` is declared here -fail_compilation/safeprintf.d(30): Error: calling `pragma(printf)` function `safeprintf.printf` with format string `"s: %S\n"` is not `@safe` +fail_compilation/safeprintf.d(30): Error: calling `pragma(printf)` function `printf` with format string `"s: %S\n"` is not allowed in a `@safe` function fail_compilation/safeprintf.d(21): `safeprintf.printf` is declared here -fail_compilation/safeprintf.d(31): Error: calling `pragma(printf)` function `safeprintf.printf` with format string `"s: %Z\n"` is not `@safe` +fail_compilation/safeprintf.d(31): Error: calling `pragma(printf)` function `printf` with format string `"s: %Z\n"` is not allowed in a `@safe` function fail_compilation/safeprintf.d(21): `safeprintf.printf` is declared here fail_compilation/safeprintf.d(31): Deprecation: format specifier `"%Z"` is invalid -fail_compilation/safeprintf.d(32): Error: calling `pragma(printf)` function `safeprintf.printf` with non-literal format string is not `@safe` +fail_compilation/safeprintf.d(32): Error: calling `pragma(printf)` function `printf` with non-literal format string is not allowed in a `@safe` function fail_compilation/safeprintf.d(21): `safeprintf.printf` is declared here -fail_compilation/safeprintf.d(33): Error: calling `pragma(printf)` function `safeprintf.bar` with format string `"%s"` is not `@safe` +fail_compilation/safeprintf.d(33): Error: calling `pragma(printf)` function `bar` with format string `"%s"` is not allowed in a `@safe` function fail_compilation/safeprintf.d(22): `safeprintf.bar` is declared here fail_compilation/safeprintf.d(34): Error: `@safe` function `safeprintf.func` cannot call `@system` function `safeprintf.sys_printf` fail_compilation/safeprintf.d(23): `safeprintf.sys_printf` is declared here @@ -31,5 +31,12 @@ extern (C) @system pragma(printf) int sys_printf(const(char)* format, ...); printf("s: %Z\n", s); printf(s, i); // non-literal bar(1, "%s", s); // preceding args - sys_printf("d", i); + sys_printf("%d", i); // not safe +} + +// no errors +@system void sys(char* s) +{ + printf(s); // non-literal + printf("%s", s); } From a57b185f9c01147759295d32b500830b8a9e1209 Mon Sep 17 00:00:00 2001 From: CHIKI <108464117+oCHIKIo@users.noreply.github.com> Date: Mon, 23 Mar 2026 16:11:45 +0100 Subject: [PATCH 409/440] Fix Issue 22769: ICE on IFTI call inside interpolated string (dlang/dmd!22784) --- dmd/expressionsem.d | 6 ++++-- tests/dmd/compilable/issue22769.d | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tests/dmd/compilable/issue22769.d diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index b5d0d5c834..4844269387 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -5852,8 +5852,10 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { arguments.push(makeTemplateItem(Id.InterpolatedExpression, str)); Expressions* mix = new Expressions(new StringExp(e.loc, str)); - // FIXME: i'd rather not use MixinExp but idk how to do it lol - arguments.push(new MixinExp(e.loc, mix)); + auto mixinExp = new MixinExp(e.loc, mix); + auto res = mixinExp.expressionSemantic(sc); + res = resolveProperties(sc, res); + arguments.push(res); } } diff --git a/tests/dmd/compilable/issue22769.d b/tests/dmd/compilable/issue22769.d new file mode 100644 index 0000000000..986fee38b9 --- /dev/null +++ b/tests/dmd/compilable/issue22769.d @@ -0,0 +1,19 @@ +// https://github.com/dlang/dmd/issues/22769 + +int foo()() => 0; + +void bar() +{ + cast(void) i"$(foo)"; +} + +struct OutBuffer +{ + void opOpAssign(string op, T...)(T args) {} +} + +void qux() +{ + OutBuffer buf; + buf ~= i"$(foo)"; +} From 93b5b1c850ac8d48af16a2e92232830e4970af49 Mon Sep 17 00:00:00 2001 From: limepoutine Date: Wed, 25 Mar 2026 18:25:51 +0800 Subject: [PATCH 410/440] Fix dlang#22639 - opApply triggers GC allocation error with -betterC --- dmd/semantic3.d | 15 +++++++++++++- tests/dmd/runnable/issue22639.d | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/runnable/issue22639.d diff --git a/dmd/semantic3.d b/dmd/semantic3.d index 2347826454..c02bb86db7 100644 --- a/dmd/semantic3.d +++ b/dmd/semantic3.d @@ -975,7 +975,20 @@ private extern(C++) final class Semantic3Visitor : Visitor if (funcdecl.vresult) { - Scope* scret = rs.fesFunc ? rs.fesFunc._scope : sc2; + Scope* scret = sc2; + + if (rs.fesFunc) + { + // Create a scope with foreach body being `.parent` + // and `funcdecl` as `.func`. So the return value + // is aware of closure access, but picks up + // attributes and instantiates templated copy/move + // ctors in the context of `funcdecl`. + // BUG: remove this fragile hack + scret = rs.fesFunc._scope.push(); + scret.parent = rs.fesFunc; + scret.func = funcdecl; + } // Create: return (vresult = exp, vresult); exp = new ConstructExp(rs.loc, funcdecl.vresult, exp); diff --git a/tests/dmd/runnable/issue22639.d b/tests/dmd/runnable/issue22639.d new file mode 100644 index 0000000000..4a1a99faaf --- /dev/null +++ b/tests/dmd/runnable/issue22639.d @@ -0,0 +1,35 @@ +// REQUIRED_ARGS: -betterC + +struct Arr(T, int CAPACITY) +{ + int count = 0; + T[CAPACITY] items; + int opApply(scope int delegate(T) dg) + { + int result; + for (int i = 0; i < count; i++) + if ((result = dg(items[i])) != 0) + break; + return result; + } +} + +struct Foo {} +struct Bar { + Arr!(Foo*, 32) array; + Foo* get() + { + foreach(Foo* it; array) + { + return it; + } + return null; + } +} + +Foo* foo; +Bar bar; +extern(C) void main() +{ + foo = bar.get(); +} From e6f59f5d73dddf5fd7178d3056f0267628f288bd Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Fri, 27 Mar 2026 07:51:07 +0100 Subject: [PATCH 411/440] [stable] Revert "Fix dlang/dmd!22754 - Move Object.__monitor to druntime (dlang/dmd!22766)" This reverts commit 1c2ee903143a2e935e0a0044c5ff52263e7da263. --- dmd/dclass.d | 10 ++----- dmd/dinterpret.d | 8 +----- dmd/dsymbolsem.d | 2 ++ dmd/dtoh.d | 3 --- dmd/expressionsem.d | 6 +---- dmd/statementsem.d | 6 ----- dmd/traits.d | 3 --- dmd/typesem.d | 16 +++++++---- runtime/druntime/src/core/sync/mutex.d | 2 +- runtime/druntime/src/core/sync/rwmutex.d | 10 +++---- runtime/druntime/src/object.d | 6 ----- tests/dmd/compilable/b18242.d | 2 +- .../no_monitor_synchronized/object.d | 5 ---- tests/dmd/fail_compilation/fail_opover.d | 2 +- .../no_monitor_synchronized.d | 27 ------------------- tests/dmd/runnable/test42.d | 6 ----- 16 files changed, 24 insertions(+), 90 deletions(-) delete mode 100644 tests/dmd/fail_compilation/extra-files/no_monitor_synchronized/object.d delete mode 100644 tests/dmd/fail_compilation/no_monitor_synchronized.d diff --git a/dmd/dclass.d b/dmd/dclass.d index 7edcc42da8..950f7db113 100644 --- a/dmd/dclass.d +++ b/dmd/dclass.d @@ -333,17 +333,11 @@ extern (C++) class ClassDeclaration : AggregateDeclaration } /************** - * Returns: true if there's a __monitor field, i.e. the druntime `Object` class declares it + * Returns: true if there's a __monitor field */ final bool hasMonitor() { - if (classKind != ClassKind.d) - return false; - // Check if Object in druntime actually declares a __monitor field. - // Custom druntimes can omit it by not declaring it in Object. - if (!object || !object.symtab) - return true; // conservative: Object not yet loaded, assume monitor present - return object.symtab.lookup(Id.__monitor) !is null; + return classKind == ClassKind.d; } /**************************************** diff --git a/dmd/dinterpret.d b/dmd/dinterpret.d index 65b24a0a0c..fb07953ace 100644 --- a/dmd/dinterpret.d +++ b/dmd/dinterpret.d @@ -2867,11 +2867,8 @@ public: size_t totalFieldCount = 0; for (ClassDeclaration c = cd; c; c = c.baseClass) totalFieldCount += c.fields.length; - - totalFieldCount -= cd.hasMonitor(); // skip __monitor field - auto elems = new Expressions(totalFieldCount); - ptrdiff_t fieldsSoFar = totalFieldCount; + size_t fieldsSoFar = totalFieldCount; for (ClassDeclaration c = cd; c; c = c.baseClass) { fieldsSoFar -= c.fields.length; @@ -2883,9 +2880,6 @@ public: result = CTFEExp.cantexp; return; } - if (fieldsSoFar + ptrdiff_t(i) < 0) // field -1 = __monitor which we skip - break; - Expression m; if (v._init) { diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 372022f613..16709bc113 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -9978,6 +9978,8 @@ private extern(C++) class FinalizeSizeVisitor : Visitor { outerCd.alignsize = target.ptrsize; outerCd.structsize = target.ptrsize; // allow room for __vptr + if (outerCd.hasMonitor()) + outerCd.structsize += target.ptrsize; // allow room for __monitor } //printf("finalizeSize() %s, sizeok = %d\n", toChars(), sizeok); diff --git a/dmd/dtoh.d b/dmd/dtoh.d index f7754a025a..10a4824d57 100644 --- a/dmd/dtoh.d +++ b/dmd/dtoh.d @@ -1065,9 +1065,6 @@ public: if (adparent) { - if (vd.ident && vd.ident == Id.__monitor) - return; - writeProtection(vd.visibility.kind); typeToBuffer(type, vd, true); buf.writestringln(";"); diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 4844269387..840dc0fd95 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -9983,11 +9983,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (t1.ty == Tpointer) t1 = t1.nextOf(); - // __monitor is always void* regardless of shared - strip shared from the mod - auto t1mod = t1.mod; - if (exp.var.ident == Id.__monitor) - t1mod &= ~MODFlags.shared_; - exp.type = exp.type.addMod(t1mod); + exp.type = exp.type.addMod(t1.mod); // https://issues.dlang.org/show_bug.cgi?id=23109 // Run semantic on the DotVarExp type diff --git a/dmd/statementsem.d b/dmd/statementsem.d index 60294f77b6..2f7b442d3a 100644 --- a/dmd/statementsem.d +++ b/dmd/statementsem.d @@ -3129,12 +3129,6 @@ Statement statementSemanticVisit(Statement s, Scope* sc) ss.exp = new CastExp(ss.loc, ss.exp, t); ss.exp = ss.exp.expressionSemantic(sc); } - if (!cd.hasMonitor()) - { - error(ss.loc, "cannot `synchronize` on a `%s` because `object.Object` has no `__monitor` field", - cd.toChars()); - return setError(); - } version (all) { /* Rewrite as: diff --git a/dmd/traits.d b/dmd/traits.d index d8aadfe38a..bcc004047e 100644 --- a/dmd/traits.d +++ b/dmd/traits.d @@ -267,8 +267,6 @@ ulong getTypePointerBitmap(Loc loc, Type t, ref Array!(ulong) data, ErrorSink eS visitTopLevelClass(t.sym.baseClass.type.isTypeClass()); foreach (v; t.sym.fields) { - if (v.ident == Id.__monitor) - continue; // __monitor is not GC-managed offset = classoff + v.offset; visit(v.type); } @@ -1788,7 +1786,6 @@ Expression semanticTraits(TraitsExp e, Scope* sc) // Skip over internal members in __traits(allMembers) if ((sm.isCtorDeclaration() && sm.ident != Id.ctor) || (sm.isDtorDeclaration() && sm.ident != Id.dtor) || - (sm.ident == Id.__monitor) || (sm.isPostBlitDeclaration() && sm.ident != Id.postblit) || sm.isInvariantDeclaration() || sm.isUnitTestDeclaration()) diff --git a/dmd/typesem.d b/dmd/typesem.d index 8e8a9ee120..997831ee28 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -7069,11 +7069,6 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag // Don't include hidden 'this' pointer if (v.isThisDeclaration()) continue; - - // Don't include __monitor field - if (v.ident == Id.__monitor) - continue; - Expression ex; if (ev) ex = new DotVarExp(e.loc, ev, v); @@ -7187,6 +7182,17 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag return e; } + if (ident == Id.__monitor && mt.sym.hasMonitor()) + { + /* The handle to the monitor (call it a void*) + * *(cast(void**)e + 1) + */ + e = e.castTo(sc, mt.tvoidptr.pointerTo()); + e = new AddExp(e.loc, e, IntegerExp.literal!1); + e = new PtrExp(e.loc, e); + e = e.expressionSemantic(sc); + return e; + } if (ident == Id.outer && mt.sym.vthis) { diff --git a/runtime/druntime/src/core/sync/mutex.d b/runtime/druntime/src/core/sync/mutex.d index 054d257198..86a112119d 100644 --- a/runtime/druntime/src/core/sync/mutex.d +++ b/runtime/druntime/src/core/sync/mutex.d @@ -102,7 +102,7 @@ class Mutex : auto self = cast(Mutex) this; self.m_proxy.link = self; - self.__monitor = cast(void*) &self.m_proxy; + this.__monitor = cast(void*) &m_proxy; } diff --git a/runtime/druntime/src/core/sync/rwmutex.d b/runtime/druntime/src/core/sync/rwmutex.d index 7a260916bc..e46b2f736f 100644 --- a/runtime/druntime/src/core/sync/rwmutex.d +++ b/runtime/druntime/src/core/sync/rwmutex.d @@ -201,9 +201,8 @@ class ReadWriteMutex this(this Q)() @trusted nothrow if (is(Q == Reader) || is(Q == shared Reader)) { - auto self = cast(Reader) this; - self.m_proxy.link = cast(typeof(self.m_proxy.link)) this; - self.__monitor = cast(void*) &self.m_proxy; + m_proxy.link = cast(typeof(m_proxy.link)) this; + this.__monitor = cast(void*) &m_proxy; } /** @@ -373,9 +372,8 @@ class ReadWriteMutex this(this Q)() @trusted nothrow if (is(Q == Writer) || is(Q == shared Writer)) { - auto self = cast(Writer) this; - self.m_proxy.link = cast(typeof(self.m_proxy.link)) this; - self.__monitor = cast(void*) &self.m_proxy; + m_proxy.link = cast(typeof(m_proxy.link)) this; + this.__monitor = cast(void*) &m_proxy; } diff --git a/runtime/druntime/src/object.d b/runtime/druntime/src/object.d index 5960968709..e6c6db6e5b 100644 --- a/runtime/druntime/src/object.d +++ b/runtime/druntime/src/object.d @@ -105,17 +105,11 @@ else version (AArch64) else version = WithArgTypes; } -static assert(Object.__monitor.offsetof == size_t.sizeof); - /** * All D class objects inherit from Object. */ class Object { - // This is an internal field that is omitted from .tupleof, __traits(allMembers), pointer bitmaps etc. - // It can be removed in a custom druntime, but if it's there it must remain the first field. - void* __monitor; - /** * Convert Object to a human readable string. */ diff --git a/tests/dmd/compilable/b18242.d b/tests/dmd/compilable/b18242.d index 4947eb6218..9909620ae3 100644 --- a/tests/dmd/compilable/b18242.d +++ b/tests/dmd/compilable/b18242.d @@ -7,7 +7,7 @@ class Object { } class TypeInfo { } class TypeInfo_Class : TypeInfo { - version(D_LP64) { ubyte[136+24] _x; } else { ubyte[68+20] _x; } + version(D_LP64) { ubyte[136+16] _x; } else { ubyte[68+16] _x; } } class Throwable { } diff --git a/tests/dmd/fail_compilation/extra-files/no_monitor_synchronized/object.d b/tests/dmd/fail_compilation/extra-files/no_monitor_synchronized/object.d deleted file mode 100644 index 4a2a31493b..0000000000 --- a/tests/dmd/fail_compilation/extra-files/no_monitor_synchronized/object.d +++ /dev/null @@ -1,5 +0,0 @@ -module object; - -alias size_t = typeof(int.sizeof); - -class Object {} diff --git a/tests/dmd/fail_compilation/fail_opover.d b/tests/dmd/fail_compilation/fail_opover.d index 3a0b75fc46..a58b2bdd90 100644 --- a/tests/dmd/fail_compilation/fail_opover.d +++ b/tests/dmd/fail_compilation/fail_opover.d @@ -4,7 +4,7 @@ TEST_OUTPUT: --- fail_compilation/fail_opover.d(39): Error: no `[]` operator overload for type `object.Object` -$p:object.d$($n$): perhaps define `auto opIndex() {}` for `object.Object` +$p:object.d$(111): perhaps define `auto opIndex() {}` for `object.Object` fail_compilation/fail_opover.d(43): Error: no `[]` operator overload for type `TestS` fail_compilation/fail_opover.d(41): perhaps define `auto opIndex() {}` for `fail_opover.test1.TestS` fail_compilation/fail_opover.d(55): Error: no `[]` operator overload for type `S` diff --git a/tests/dmd/fail_compilation/no_monitor_synchronized.d b/tests/dmd/fail_compilation/no_monitor_synchronized.d deleted file mode 100644 index 58c53e6bb4..0000000000 --- a/tests/dmd/fail_compilation/no_monitor_synchronized.d +++ /dev/null @@ -1,27 +0,0 @@ -/* -DFLAGS: -REQUIRED_ARGS: -c -EXTRA_SOURCES: extra-files/no_monitor_synchronized/object.d -TEST_OUTPUT: ---- -fail_compilation/no_monitor_synchronized.d(20): Error: cannot `synchronize` on a `Foo` because `object.Object` has no `__monitor` field ---- -*/ - -// Test using synchronized(obj) with a custom druntime that has no __monitor field - -class Foo -{ - int x; -} - -void test(Foo f) -{ - synchronized(f) {} - - // Bare synchronized (uses critical section, not monitor) still compiles - synchronized {} -} - -// Check that there's only a vtbl before x, no hidden monitor field -static assert(Foo.x.offsetof == size_t.sizeof); diff --git a/tests/dmd/runnable/test42.d b/tests/dmd/runnable/test42.d index bc480fbfbe..29a6bd9a7c 100644 --- a/tests/dmd/runnable/test42.d +++ b/tests/dmd/runnable/test42.d @@ -1315,12 +1315,6 @@ void test79() // writeln(c.__monitor); assert(c.__monitor !is null); } - - // __monitor on a shared object is still void*, not shared(void*) - shared C79 sc = new shared C79(); - void* p = cast(void*) 0x1; - sc.__monitor = p; - assert(sc.__monitor == p); } /***************************************************/ From fa98da79f9d8b6fa778158099c5f6fec109b773a Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Wed, 1 Apr 2026 12:15:33 +0200 Subject: [PATCH 412/440] Type.unSharedOf: Don't propagate back-end ctype after building variant --- dmd/typesem.d | 1 - 1 file changed, 1 deletion(-) diff --git a/dmd/typesem.d b/dmd/typesem.d index 997831ee28..7038748b53 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -8655,7 +8655,6 @@ Type unSharedOf(Type type) { t = type.nullAttributes(); t.mod = type.mod & ~MODFlags.shared_; - t.ctype = type.ctype; t = t.merge(); t.fixTo(type); } From 943acb16df77b184ccad57bf09e33069aa13f507 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Wed, 1 Apr 2026 13:54:29 +0200 Subject: [PATCH 413/440] Type.fixTo: Always propagate the naked type to new variants --- dmd/mtype.d | 4 ++++ dmd/typesem.d | 48 +++++++++++++++++++++++++++--------------------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/dmd/mtype.d b/dmd/mtype.d index 74364d05e3..a64502bb6c 100644 --- a/dmd/mtype.d +++ b/dmd/mtype.d @@ -404,6 +404,10 @@ extern (C++) abstract class Type : ASTNode * we bank on the idea that usually only one of variants exist. * It will also speed up code because these are rarely referenced and * so need not be in the cache. + * + * NOTE: The cache stores the naked type at the "identity" position. + * For example, a "shared const T" type will have its naked "T" type + * in the field "scto". See also: dmd.typesem.nakedOf(Type). */ Type cto; // MODFlags.const_ Type ito; // MODFlags.immutable_ diff --git a/dmd/typesem.d b/dmd/typesem.d index 7038748b53..67873afdbb 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -464,57 +464,62 @@ void check(Type _this) * For our new type '_this', which is type-constructed from t, * fill in the cto, ito, sto, scto, wto shortcuts. */ -void fixTo(Type _this, Type t) +private void fixTo(Type _this, Type t) { + Type mto = null; // the naked type of `t` + if (_this.mod || t.mod) + { + _this.getMcache(); + t.getMcache(); + } // If fixing this: immutable(T*) by t: immutable(T)*, // cache t to this.xto won't break transitivity. - Type mto = null; Type tn = _this.nextOf(); if (!tn || _this.ty != Tsarray && tn.mod == t.nextOf().mod) { switch (t.mod) { case 0: - mto = t; + mto = t; // t is naked break; case MODFlags.const_: - _this.getMcache(); + mto = t.mcache.cto; // cto is naked _this.mcache.cto = t; break; case MODFlags.wild: - _this.getMcache(); + mto = t.mcache.wto; // wto is naked _this.mcache.wto = t; break; case MODFlags.wildconst: - _this.getMcache(); + mto = t.mcache.wcto; // wcto is naked _this.mcache.wcto = t; break; case MODFlags.shared_: - _this.getMcache(); + mto = t.mcache.sto; // sto is naked _this.mcache.sto = t; break; case MODFlags.shared_ | MODFlags.const_: - _this.getMcache(); + mto = t.mcache.scto; // scto is naked _this.mcache.scto = t; break; case MODFlags.shared_ | MODFlags.wild: - _this.getMcache(); + mto = t.mcache.swto; // swto is naked _this.mcache.swto = t; break; case MODFlags.shared_ | MODFlags.wildconst: - _this.getMcache(); + mto = t.mcache.swcto; // swcto is naked _this.mcache.swcto = t; break; case MODFlags.immutable_: - _this.getMcache(); + mto = t.mcache.ito; // ito is naked _this.mcache.ito = t; break; @@ -524,11 +529,6 @@ void fixTo(Type _this, Type t) } assert(_this.mod != t.mod); - if (_this.mod) - { - _this.getMcache(); - t.getMcache(); - } switch (_this.mod) { case 0: @@ -8529,6 +8529,15 @@ Type immutableOf(Type type) /******************************** * Make type mutable. + * 0 => 0 + * const => 0 + * immutable => 0 + * shared => shared + * shared const => shared + * wild => 0 + * wild const => 0 + * shared wild => shared + * shared wild const => shared */ Type mutableOf(Type type) { @@ -8545,15 +8554,12 @@ Type mutableOf(Type type) type.getMcache(); if (type.isShared()) { - if (type.isWild()) - t = type.mcache.swcto; // shared wild const -> shared - else - t = type.mcache.sto; // shared const => shared + t = type.mcache.sto; // shared (wild) const => shared } else { if (type.isWild()) - t = type.mcache.wcto; // wild const -> naked + t = type.mcache.wcto; // wild const => naked else t = type.mcache.cto; // const => naked } From e5bb78379231e982340adb4901bbfd3ac3a4fccb Mon Sep 17 00:00:00 2001 From: Dennis Date: Fri, 3 Apr 2026 11:00:32 +0200 Subject: [PATCH 414/440] Fixup "Disable rewriting of finally statements to sequences unless requested" (dlang/dmd!22863) * Fixup "Disable rewriting of finally statements to sequences unless requested" Co-Authored-By: Claude Sonnet 4.6 * Detab --------- Co-authored-by: Claude Sonnet 4.6 --- dmd/cli.d | 12 ++++++++---- dmd/frontend.h | 8 ++++---- dmd/globals.d | 2 +- dmd/globals.h | 2 +- dmd/mars.d | 20 ++++---------------- dmd/statementsem.d | 2 +- 6 files changed, 19 insertions(+), 27 deletions(-) diff --git a/dmd/cli.d b/dmd/cli.d index 9dd11ff08b..a958696807 100644 --- a/dmd/cli.d +++ b/dmd/cli.d @@ -236,10 +236,6 @@ struct Usage $(LI $(B context): Prints the error context as part of the unrecoverable $(D AssertError).) )` ), - Option("checkactionfinally=[on|off]", - "do finally statements that do not have an Exception thrown in try body get emitted?", - "Default behavior is on. Turning this off means destructors may not run." - ), Option("checkaction=[h|help|?]", "list information on all available check actions" ), @@ -737,6 +733,14 @@ dmd -cov -unittest myprog.d function attribute for partial disabling of Exceptions instead, and only use this flag to globally disable Exceptions.", ), + Option("nothrow-optimizations", + "allow skipping destructors when an Error unwinds through a nothrow function", + `Controls whether $(D finally) blocks are emitted when the try body is $(D nothrow). + By default, finally blocks always run, ensuring cleanup on $(D Error) as well. + With this option, finally blocks are skipped in nothrow try bodies, which may prevent + destructors and scope(exit) blocks (which implicitly generate a try-finally block) + from running when an $(D Error) is thrown.` + ), Option("O", "optimize", `Optimize generated code. For fastest executables, compile diff --git a/dmd/frontend.h b/dmd/frontend.h index 8e8e2fe76f..e4b80ddc68 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -8177,7 +8177,7 @@ struct Param final bool addMain; bool allInst; bool bitfields; - bool rewriteNoExceptionToSeq; + bool nothrowOptimizations; CppStdRevision cplusplus; Help help; Verbose v; @@ -8270,7 +8270,7 @@ struct Param final addMain(), allInst(), bitfields(true), - rewriteNoExceptionToSeq(), + nothrowOptimizations(), cplusplus((CppStdRevision)201103u), help(), v(), @@ -8329,7 +8329,7 @@ struct Param final timeTraceFile() { } - Param(bool obj, bool readStdin = false, bool multiobj = false, bool trace = false, bool tracegc = false, bool vcg_ast = false, DiagnosticReporting useDeprecated = (DiagnosticReporting)1u, bool useUnitTests = false, bool useInline = false, bool release = false, bool preservePaths = false, DiagnosticReporting useWarnings = (DiagnosticReporting)2u, bool cov = false, uint8_t covPercent = 0u, bool ctfe_cov = false, bool ignoreUnsupportedPragmas = true, bool useModuleInfo = true, bool useTypeInfo = true, bool useExceptions = true, bool useGC = true, bool betterC = false, bool addMain = false, bool allInst = false, bool bitfields = true, bool rewriteNoExceptionToSeq = false, CppStdRevision cplusplus = (CppStdRevision)201103u, Help help = Help(), Verbose v = Verbose(), Edition edition = (Edition)2023u, void* editionFiles = nullptr, FeatureState useDIP25 = (FeatureState)2u, FeatureState useDIP1000 = (FeatureState)0u, bool ehnogc = false, bool useDIP1021 = false, FeatureState fieldwise = (FeatureState)0u, bool fixAliasThis = false, FeatureState rvalueRefParam = (FeatureState)0u, FeatureState safer = (FeatureState)0u, FeatureState noSharedAccess = (FeatureState)0u, bool previewIn = false, bool inclusiveInContracts = false, bool shortenedMethods = true, bool fixImmutableConv = false, bool fix16997 = true, FeatureState dtorFields = (FeatureState)0u, FeatureState systemVariables = (FeatureState)0u, bool useFastDFA = false, CHECKENABLE useInvariants = (CHECKENABLE)0u, CHECKENABLE useIn = (CHECKENABLE)0u, CHECKENABLE useOut = (CHECKENABLE)0u, CHECKENABLE useArrayBounds = (CHECKENABLE)0u, CHECKENABLE useNullCheck = (CHECKENABLE)0u, CHECKENABLE useAssert = (CHECKENABLE)0u, CHECKENABLE useSwitchError = (CHECKENABLE)0u, CHECKENABLE boundscheck = (CHECKENABLE)0u, CHECKACTION checkAction = (CHECKACTION)0u, CLIIdentifierTable dIdentifierTable = (CLIIdentifierTable)0u, CLIIdentifierTable cIdentifierTable = (CLIIdentifierTable)0u, _d_dynamicArray< const char > argv0 = {}, Array modFileAliasStrings = Array(), Array imppath = Array(), Array fileImppath = Array(), _d_dynamicArray< const char > objdir = {}, _d_dynamicArray< const char > objname = {}, _d_dynamicArray< const char > libname = {}, Output ddoc = Output(), Output dihdr = Output(), Output cxxhdr = Output(), Output json = Output(), JsonFieldFlags jsonFieldFlags = (JsonFieldFlags)0u, Output makeDeps = Output(), Output mixinOut = Output(), Output moduleDeps = Output(), bool debugEnabled = false, bool run = false, Array runargs = Array(), Array cppswitches = Array(), const char* cpp = nullptr, Array objfiles = Array(), Array linkswitches = Array(), Array linkswitchIsForCC = Array(), Array libfiles = Array(), Array dllfiles = Array(), _d_dynamicArray< const char > deffile = {}, _d_dynamicArray< const char > resfile = {}, _d_dynamicArray< const char > exefile = {}, _d_dynamicArray< const char > mapfile = {}, bool fullyQualifiedObjectFiles = false, bool timeTrace = false, uint32_t timeTraceGranularityUs = 500u, const char* timeTraceFile = nullptr) : + Param(bool obj, bool readStdin = false, bool multiobj = false, bool trace = false, bool tracegc = false, bool vcg_ast = false, DiagnosticReporting useDeprecated = (DiagnosticReporting)1u, bool useUnitTests = false, bool useInline = false, bool release = false, bool preservePaths = false, DiagnosticReporting useWarnings = (DiagnosticReporting)2u, bool cov = false, uint8_t covPercent = 0u, bool ctfe_cov = false, bool ignoreUnsupportedPragmas = true, bool useModuleInfo = true, bool useTypeInfo = true, bool useExceptions = true, bool useGC = true, bool betterC = false, bool addMain = false, bool allInst = false, bool bitfields = true, bool nothrowOptimizations = false, CppStdRevision cplusplus = (CppStdRevision)201103u, Help help = Help(), Verbose v = Verbose(), Edition edition = (Edition)2023u, void* editionFiles = nullptr, FeatureState useDIP25 = (FeatureState)2u, FeatureState useDIP1000 = (FeatureState)0u, bool ehnogc = false, bool useDIP1021 = false, FeatureState fieldwise = (FeatureState)0u, bool fixAliasThis = false, FeatureState rvalueRefParam = (FeatureState)0u, FeatureState safer = (FeatureState)0u, FeatureState noSharedAccess = (FeatureState)0u, bool previewIn = false, bool inclusiveInContracts = false, bool shortenedMethods = true, bool fixImmutableConv = false, bool fix16997 = true, FeatureState dtorFields = (FeatureState)0u, FeatureState systemVariables = (FeatureState)0u, bool useFastDFA = false, CHECKENABLE useInvariants = (CHECKENABLE)0u, CHECKENABLE useIn = (CHECKENABLE)0u, CHECKENABLE useOut = (CHECKENABLE)0u, CHECKENABLE useArrayBounds = (CHECKENABLE)0u, CHECKENABLE useNullCheck = (CHECKENABLE)0u, CHECKENABLE useAssert = (CHECKENABLE)0u, CHECKENABLE useSwitchError = (CHECKENABLE)0u, CHECKENABLE boundscheck = (CHECKENABLE)0u, CHECKACTION checkAction = (CHECKACTION)0u, CLIIdentifierTable dIdentifierTable = (CLIIdentifierTable)0u, CLIIdentifierTable cIdentifierTable = (CLIIdentifierTable)0u, _d_dynamicArray< const char > argv0 = {}, Array modFileAliasStrings = Array(), Array imppath = Array(), Array fileImppath = Array(), _d_dynamicArray< const char > objdir = {}, _d_dynamicArray< const char > objname = {}, _d_dynamicArray< const char > libname = {}, Output ddoc = Output(), Output dihdr = Output(), Output cxxhdr = Output(), Output json = Output(), JsonFieldFlags jsonFieldFlags = (JsonFieldFlags)0u, Output makeDeps = Output(), Output mixinOut = Output(), Output moduleDeps = Output(), bool debugEnabled = false, bool run = false, Array runargs = Array(), Array cppswitches = Array(), const char* cpp = nullptr, Array objfiles = Array(), Array linkswitches = Array(), Array linkswitchIsForCC = Array(), Array libfiles = Array(), Array dllfiles = Array(), _d_dynamicArray< const char > deffile = {}, _d_dynamicArray< const char > resfile = {}, _d_dynamicArray< const char > exefile = {}, _d_dynamicArray< const char > mapfile = {}, bool fullyQualifiedObjectFiles = false, bool timeTrace = false, uint32_t timeTraceGranularityUs = 500u, const char* timeTraceFile = nullptr) : obj(obj), readStdin(readStdin), multiobj(multiobj), @@ -8354,7 +8354,7 @@ struct Param final addMain(addMain), allInst(allInst), bitfields(bitfields), - rewriteNoExceptionToSeq(rewriteNoExceptionToSeq), + nothrowOptimizations(nothrowOptimizations), cplusplus(cplusplus), help(help), v(v), diff --git a/dmd/globals.d b/dmd/globals.d index 020d24786c..bdb2ff42af 100644 --- a/dmd/globals.d +++ b/dmd/globals.d @@ -181,7 +181,7 @@ extern (C++) struct Param bool addMain; // add a default main() function bool allInst; // generate code for all template instantiations bool bitfields = true; // support C style bit fields - bool rewriteNoExceptionToSeq; // Allow finally statements that do not throw an Exception + bool nothrowOptimizations; // Allow finally statements that do not throw an Exception // in try body to rewrite to a sequence. CppStdRevision cplusplus = CppStdRevision.cpp11; // version of C++ standard to support diff --git a/dmd/globals.h b/dmd/globals.h index 40894f256a..626ce1bde9 100644 --- a/dmd/globals.h +++ b/dmd/globals.h @@ -205,7 +205,7 @@ struct Param d_bool addMain; // add a default main() function d_bool allInst; // generate code for all template instantiations d_bool bitfields; // support C style bit fields - d_bool rewriteNoExceptionToSeq; + d_bool nothrowOptimizations; CppStdRevision cplusplus; // version of C++ name mangling to support Help help; diff --git a/dmd/mars.d b/dmd/mars.d index ad7ce89869..7a62dc4c64 100644 --- a/dmd/mars.d +++ b/dmd/mars.d @@ -689,22 +689,6 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, out Param params.useDeprecated = DiagnosticReporting.inform; else if (arg == "-c") // https://dlang.org/dmd.html#switch-c driverParams.link = false; - else if (startsWith(p + 1, "checkactionfinally")) // https://dlang.org/dmd.html#switch-checkactionfinally - { - enum len = "-checkactionfinally".length; - switch(arg[len .. $]) - { - case "=off": - params.rewriteNoExceptionToSeq = true; - break; - case "=on": - params.rewriteNoExceptionToSeq = false; - break; - default: - errorInvalidSwitch(p, "-checkactionerror argument may only be `on` or `off`"); - return false; - } - } else if (startsWith(p + 1, "checkaction")) // https://dlang.org/dmd.html#switch-checkaction { /* Parse: @@ -1649,6 +1633,10 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, out Param { params.useExceptions = false; } + else if (arg == "-nothrow-optimizations") // https://dlang.org/dmd.html#switch-nothrow-optimizations + { + params.nothrowOptimizations = true; + } else if (arg == "-unittest") params.useUnitTests = true; else if (p[1] == 'I') // https://dlang.org/dmd.html#switch-I diff --git a/dmd/statementsem.d b/dmd/statementsem.d index 2f7b442d3a..ce0d457e81 100644 --- a/dmd/statementsem.d +++ b/dmd/statementsem.d @@ -3491,7 +3491,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc) // Don't care about paths that halt, either // Only rewrite if it was requested. // This has side effects where Error will not run destructors, unsafe. - if (global.params.rewriteNoExceptionToSeq && (blockexit & ~BE.halt) == BE.fallthru) + if (global.params.nothrowOptimizations && (blockexit & ~BE.halt) == BE.fallthru) { result = new CompoundStatement(tfs.loc, tfs._body, tfs.finalbody); return; From 44f2295d016ba4e9259e88ba830f2e30a98694c1 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Tue, 24 Mar 2026 18:00:22 +0000 Subject: [PATCH 415/440] Fix slicing struct init array field with `ArrayLiteralExpression.basis` set --- dmd/constfold.d | 2 +- tests/dmd/compilable/test8717.d | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dmd/constfold.d b/dmd/constfold.d index 1dc6c4ca2d..2a43c8e275 100644 --- a/dmd/constfold.d +++ b/dmd/constfold.d @@ -1267,7 +1267,7 @@ UnionExp Slice(Type type, Expression e1, Expression lwr, Expression upr) { auto elements = new Expressions(cast(size_t)(iupr - ilwr)); memcpy(elements.tdata(), es1.elements.tdata() + ilwr, cast(size_t)(iupr - ilwr) * ((*es1.elements)[0]).sizeof); - emplaceExp!(ArrayLiteralExp)(&ue, e1.loc, type, elements); + emplaceExp!(ArrayLiteralExp)(&ue, e1.loc, type, es1.basis, elements); } } else diff --git a/tests/dmd/compilable/test8717.d b/tests/dmd/compilable/test8717.d index 26a2866c68..455d72c14c 100644 --- a/tests/dmd/compilable/test8717.d +++ b/tests/dmd/compilable/test8717.d @@ -60,4 +60,6 @@ static if(SPT.init.sii != 1) { static assert(0); } static if(SPT.sf() != 1) { static assert(0); } static if(SPT.init.f() != 1) { static assert(0); } -void main() { } +// https://github.com/dlang/dmd/issues/22699 +struct S{ int[8] e; } +static assert(S().e[0..4] == S.init.e[0..4]); From ca4b3b4c72a81c9410e673e57248a200698238e7 Mon Sep 17 00:00:00 2001 From: Dennis Korpel Date: Sat, 4 Apr 2026 23:43:39 +0200 Subject: [PATCH 416/440] Fix dlang/dmd!21839 - ICE - Crash when using void[N].init Co-Authored-By: Claude Sonnet 4.6 --- dmd/templatesem.d | 7 +------ tests/dmd/compilable/test21839.d | 10 ++++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 tests/dmd/compilable/test21839.d diff --git a/dmd/templatesem.d b/dmd/templatesem.d index 304a7a8fd1..905ec2b787 100644 --- a/dmd/templatesem.d +++ b/dmd/templatesem.d @@ -7550,12 +7550,7 @@ MATCH deduceType(scope RootObject o, scope Scope* sc, scope Type tparam, override void visit(ArrayLiteralExp e) { // https://issues.dlang.org/show_bug.cgi?id=20092 - if (e.elements && e.elements.length && e.type.toBasetype().nextOf().ty == Tvoid) - { - result = deduceEmptyArrayElement(); - return; - } - if ((!e.elements || !e.elements.length) && e.type.toBasetype().nextOf().ty == Tvoid && tparam.ty == Tarray) + if (e.type.toBasetype().nextOf().ty == Tvoid && tparam.ty == Tarray) { // tparam:T[] <- e:[] (void[]) result = deduceEmptyArrayElement(); diff --git a/tests/dmd/compilable/test21839.d b/tests/dmd/compilable/test21839.d new file mode 100644 index 0000000000..9fad4aee9f --- /dev/null +++ b/tests/dmd/compilable/test21839.d @@ -0,0 +1,10 @@ +// https://github.com/dlang/dmd/issues/21839 +// ICE with void[N].init passed to template function + +void tf(U)(U) {} + +void test() +{ + tf(void[16].init); + tf(void[8].init); +} From 5ce75d2d66b5ca7a566d8daa7294ee33a81ffb7b Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 7 Apr 2026 18:43:35 +0200 Subject: [PATCH 417/440] [merge fixes] --- dmd/expressionsem.d | 5 ++++- dmd/id.d | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 9d33a17306..709d13de43 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -538,16 +538,19 @@ Optional!bool toBool(Expression _this) case EXP.arrayLiteral: return arrayLiteralToBool(_this.isArrayLiteralExp()); case EXP.assocArrayLiteral: return assocArrayLiteralToBool(_this.isAssocArrayLiteralExp()); case EXP.symbolOffset: + { version (IN_LLVM) { import gen.dpragma : LDCPragma; // For a weak symbol, we only statically know that it is non-null if the // offset is non-zero. - if (var.llvmInternal == LDCPragma.LLVMextern_weak && offset == 0) + auto soe = _this.isSymOffExp(); + if (soe.var.llvmInternal == LDCPragma.LLVMextern_weak && soe.offset == 0) return typeof(return)(); } return typeof(return)(true); + } case EXP.address: return addrToBool(_this.isAddrExp()); case EXP.slice: return _this.isSliceExp().e1.toBool(); case EXP.comma: return _this.isCommaExp().e2.toBool(); diff --git a/dmd/id.d b/dmd/id.d index 2b7dc0b91e..d10499ccf9 100644 --- a/dmd/id.d +++ b/dmd/id.d @@ -583,7 +583,6 @@ immutable Msgtable[] msgtable = { "udaOptStrategy", "optStrategy" }, { "udaLLVMAttr", "llvmAttr" }, { "udaLLVMFastMathFlag", "llvmFastMathFlag" }, - { "udaSection", "section" }, { "udaTarget", "target" }, { "udaAssumeUsed", "_assumeUsed" }, { "udaCallingConvention", "callingConvention" }, From 84024869235ab0dfd94f5a7d19dfe89d1f4d588e Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 7 Apr 2026 17:47:07 +0200 Subject: [PATCH 418/440] =?UTF-8?q?WIP:=20Adapt=20to=20free-standing=20is?= =?UTF-8?q?=E2=80=A6=20Type=20predicates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gen/abi/abi.cpp | 2 +- gen/abi/loongarch64.cpp | 10 +++++----- gen/abi/ppc.cpp | 6 +++--- gen/abi/ppc64le.cpp | 6 +++--- gen/abi/riscv64.cpp | 6 +++--- gen/abi/wasm.cpp | 2 +- gen/abi/x86-64.cpp | 2 +- gen/abi/x86.cpp | 4 ++-- gen/asm-x86.h | 4 ++-- gen/binops.cpp | 36 ++++++++++++++++++------------------ gen/classes.cpp | 2 +- gen/complex.cpp | 16 ++++++++-------- gen/dibuilder.cpp | 4 ++-- gen/dvalue.cpp | 2 +- gen/llvmhelpers.cpp | 40 ++++++++++++++++++++-------------------- gen/naked.cpp | 12 ++++++------ gen/statements.cpp | 6 +++--- gen/toconstelem.cpp | 4 ++-- gen/toir.cpp | 36 ++++++++++++++++++------------------ gen/tollvm.cpp | 6 +++--- 20 files changed, 103 insertions(+), 103 deletions(-) diff --git a/gen/abi/abi.cpp b/gen/abi/abi.cpp index 5e5a1baa20..63a3b5d8fd 100644 --- a/gen/abi/abi.cpp +++ b/gen/abi/abi.cpp @@ -113,7 +113,7 @@ bool TargetABI::isAggregate(Type *t) { // by runtime functions, for which we don't apply the rewrites yet // when calling them return ty == TY::Tstruct || ty == TY::Tsarray || - /*ty == TY::Tarray ||*/ ty == TY::Tdelegate || t->isComplex(); + /*ty == TY::Tarray ||*/ ty == TY::Tdelegate || isComplex(t); } bool TargetABI::isPOD(Type *t, bool excludeStructsWithCtor) { diff --git a/gen/abi/loongarch64.cpp b/gen/abi/loongarch64.cpp index a5f446fca1..d78b41fb4a 100644 --- a/gen/abi/loongarch64.cpp +++ b/gen/abi/loongarch64.cpp @@ -86,7 +86,7 @@ struct HardfloatRewrite : BaseBitcastABIRewrite { LLType *t[2]; for (unsigned i = 0; i < 2; ++i) { t[i] = - flat.fields[i]->isFloating() + isFloating(flat.fields[i]) ? DtoType(flat.fields[i]) : LLIntegerType::get(gIR->context(), size(flat.fields[i]) * 8); } @@ -111,8 +111,8 @@ struct LoongArch64TargetABI : TargetABI { if (result.length <= 0) return false; if (result.length == 1) - return result.fields[0]->isFloating(); - return result.fields[0]->isFloating() || result.fields[1]->isFloating(); + return isFloating(result.fields[0]); + return isFloating(result.fields[0]) || isFloating(result.fields[1]); } public: @@ -143,8 +143,8 @@ struct LoongArch64TargetABI : TargetABI { } Type *ty = arg.type->toBasetype(); - if (ty->isIntegral() && (ty->ty == TY::Tint32 || ty->ty == TY::Tuns32 || - ty->ty == TY::Tdchar)) { + if (isIntegral(ty) && (ty->ty == TY::Tint32 || ty->ty == TY::Tuns32 || + ty->ty == TY::Tdchar)) { // In the LP64D ABI, both int32 and unsigned int32 are stored in // general-purpose registers as proper sign extensions of their // 32-bit values. So, the native ABI function's int32 arguments and diff --git a/gen/abi/ppc.cpp b/gen/abi/ppc.cpp index c8d8482ce0..b8f4dec1cb 100644 --- a/gen/abi/ppc.cpp +++ b/gen/abi/ppc.cpp @@ -74,9 +74,9 @@ struct PPCTargetABI : TargetABI { compositeToArray32.applyTo(arg); } } - } else if (ty->isIntegral()) { - arg.attrs.addAttribute(ty->isUnsigned() ? LLAttribute::ZExt - : LLAttribute::SExt); + } else if (isIntegral(ty)) { + arg.attrs.addAttribute(isUnsigned(ty) ? LLAttribute::ZExt + : LLAttribute::SExt); } } }; diff --git a/gen/abi/ppc64le.cpp b/gen/abi/ppc64le.cpp index 940edafcd6..a29e8479f8 100644 --- a/gen/abi/ppc64le.cpp +++ b/gen/abi/ppc64le.cpp @@ -55,9 +55,9 @@ struct PPC64LETargetABI : TargetABI { } else { compositeToArray64.applyTo(arg); } - } else if (ty->isIntegral() && !ty->isTypeVector()) { - arg.attrs.addAttribute(ty->isUnsigned() ? LLAttribute::ZExt - : LLAttribute::SExt); + } else if (isIntegral(ty) && !ty->isTypeVector()) { + arg.attrs.addAttribute(isUnsigned(ty) ? LLAttribute::ZExt + : LLAttribute::SExt); } } }; diff --git a/gen/abi/riscv64.cpp b/gen/abi/riscv64.cpp index d49ebaa2e1..2c548b4ae1 100644 --- a/gen/abi/riscv64.cpp +++ b/gen/abi/riscv64.cpp @@ -93,8 +93,8 @@ bool requireHardfloatRewrite(Type *ty) { if (result.length <= 0) return false; if (result.length == 1) - return result.fields[0].ty->isFloating(); - return result.fields[0].ty->isFloating() || result.fields[1].ty->isFloating(); + return isFloating(result.fields[0].ty); + return isFloating(result.fields[0].ty) || isFloating(result.fields[1].ty); } struct HardfloatRewrite : ABIRewrite { @@ -139,7 +139,7 @@ struct HardfloatRewrite : ABIRewrite { assert(flat.length == 2); LLType *t[2]; for (unsigned i = 0; i < 2; ++i) { - t[i] = flat.fields[i].ty->isFloating() + t[i] = isFloating(flat.fields[i].ty) ? DtoType(flat.fields[i].ty) : LLIntegerType::get(gIR->context(), size(flat.fields[i].ty) * 8); diff --git a/gen/abi/wasm.cpp b/gen/abi/wasm.cpp index 496753daef..1ab3734e0e 100644 --- a/gen/abi/wasm.cpp +++ b/gen/abi/wasm.cpp @@ -31,7 +31,7 @@ Type *getSingleWrappedScalarType(Type *t) { return getSingleWrappedScalarType(tsa->nextOf()); } - return t->isScalar() + return isScalar(t) // some more pointers: || t->ty == TY::Tclass || t->ty == TY::Taarray ? t diff --git a/gen/abi/x86-64.cpp b/gen/abi/x86-64.cpp index a6ebefd2f9..4e3ca085ea 100644 --- a/gen/abi/x86-64.cpp +++ b/gen/abi/x86-64.cpp @@ -387,7 +387,7 @@ const char *X86_64TargetABI::objcMsgSendFunc(Type *ret, IrFuncTy &fty, bool dire return directcall ? "objc_msgSendSuper_stret" : "objc_msgSend_stret"; } // float, double, long double return - if (ret && ret->isFloating()) { + if (ret && isFloating(ret)) { return ret->ty == TY::Tcomplex80 ? "objc_msgSend_fp2ret" : "objc_msgSend_fpret"; } return directcall ? "objc_msgSendSuper" : "objc_msgSend"; diff --git a/gen/abi/x86.cpp b/gen/abi/x86.cpp index 048aaeaf1a..daa21f1db2 100644 --- a/gen/abi/x86.cpp +++ b/gen/abi/x86.cpp @@ -113,7 +113,7 @@ struct X86TargetABI : TargetABI { return false; // complex numbers - if (rt->isComplex()) { + if (isComplex(rt)) { // extern(D): let LLVM return them directly as LL aggregates if (externD) return false; @@ -210,7 +210,7 @@ struct X86TargetABI : TargetABI { } else { Type *firstTy = first.type->toBasetype(); auto sz = size(firstTy); - if (!firstTy->isFloating() && (sz == 1 || sz == 2 || sz == 4)) { + if (!isFloating(firstTy) && (sz == 1 || sz == 2 || sz == 4)) { // rewrite aggregates as integers to make inreg work if (firstTy->ty == TY::Tstruct || firstTy->ty == TY::Tsarray) { integerRewrite.applyTo(first); diff --git a/gen/asm-x86.h b/gen/asm-x86.h index eecd1a8b65..aca0bd8c3d 100644 --- a/gen/asm-x86.h +++ b/gen/asm-x86.h @@ -2343,7 +2343,7 @@ struct AsmProcessor { if (sc->func->isNaked()) { switch (type) { case Arg_Integer: - if (e->type->isUnsigned()) { + if (dmd::isUnsigned(e->type)) { insnTemplate << "$" << e->toUInteger(); } else { #ifndef ASM_X86_64 @@ -3232,7 +3232,7 @@ struct AsmProcessor { operand->hasNumber = 1; } } else { - if (v && v->type->isScalar()) { + if (v && dmd::isScalar(v->type)) { // DMD doesn't check Tcomplex*, and counts Tcomplex32 as // Tfloat64 TY ty = v->type->toBasetype()->ty; diff --git a/gen/binops.cpp b/gen/binops.cpp index f0012f1a39..c9a1dfe02d 100644 --- a/gen/binops.cpp +++ b/gen/binops.cpp @@ -153,7 +153,7 @@ DValue *binAdd(Loc loc, Type *type, DValue *lhs, Expression *rhs, Type *rhsType = rhs->type->toBasetype(); if (lhsType != rhsType && lhsType->ty == TY::Tpointer && - rhsType->isIntegral()) { + isIntegral(rhsType)) { Logger::println("Adding integer to pointer"); return emitPointerOffset(loc, lhs, rhs, false, type, loadLhsAfterRhs); } @@ -162,7 +162,7 @@ DValue *binAdd(Loc loc, Type *type, DValue *lhs, Expression *rhs, if (type->ty == TY::Tnull) return DtoNullValue(type, loc); - if (type->isComplex()) + if (isComplex(type)) return DtoComplexAdd(loc, type, rvals.lhs, rvals.rhs); LLValue *l = DtoRVal(DtoCast(loc, rvals.lhs, type)); @@ -171,8 +171,8 @@ DValue *binAdd(Loc loc, Type *type, DValue *lhs, Expression *rhs, if (auto aa = isAssociativeArrayAndNull(type, l, r)) return aa; - LLValue *res = (type->isFloating() ? gIR->ir->CreateFAdd(l, r) - : gIR->ir->CreateAdd(l, r)); + LLValue *res = + isFloating(type) ? gIR->ir->CreateFAdd(l, r) : gIR->ir->CreateAdd(l, r); return new DImValue(type, res); } @@ -185,7 +185,7 @@ DValue *binMin(Loc loc, Type *type, DValue *lhs, Expression *rhs, Type *rhsType = rhs->type->toBasetype(); if (lhsType != rhsType && lhsType->ty == TY::Tpointer && - rhsType->isIntegral()) { + isIntegral(rhsType)) { Logger::println("Subtracting integer from pointer"); return emitPointerOffset(loc, lhs, rhs, true, type, loadLhsAfterRhs); } @@ -207,7 +207,7 @@ DValue *binMin(Loc loc, Type *type, DValue *lhs, Expression *rhs, if (type->ty == TY::Tnull) return DtoNullValue(type, loc); - if (type->isComplex()) + if (isComplex(type)) return DtoComplexMin(loc, type, rvals.lhs, rvals.rhs); LLValue *l = DtoRVal(DtoCast(loc, rvals.lhs, type)); @@ -216,8 +216,8 @@ DValue *binMin(Loc loc, Type *type, DValue *lhs, Expression *rhs, if (auto aa = isAssociativeArrayAndNull(type, l, r)) return aa; - LLValue *res = (type->isFloating() ? gIR->ir->CreateFSub(l, r) - : gIR->ir->CreateSub(l, r)); + LLValue *res = + isFloating(type) ? gIR->ir->CreateFSub(l, r) : gIR->ir->CreateSub(l, r); return new DImValue(type, res); } @@ -228,13 +228,13 @@ DValue *binMul(Loc loc, Type *type, DValue *lhs, Expression *rhs, bool loadLhsAfterRhs) { auto rvals = evalSides(lhs, rhs, loadLhsAfterRhs); - if (type->isComplex()) + if (isComplex(type)) return DtoComplexMul(loc, type, rvals.lhs, rvals.rhs); LLValue *l = DtoRVal(DtoCast(loc, rvals.lhs, type)); LLValue *r = DtoRVal(DtoCast(loc, rvals.rhs, type)); - LLValue *res = (type->isFloating() ? gIR->ir->CreateFMul(l, r) - : gIR->ir->CreateMul(l, r)); + LLValue *res = + isFloating(type) ? gIR->ir->CreateFMul(l, r) : gIR->ir->CreateMul(l, r); return new DImValue(type, res); } @@ -245,13 +245,13 @@ DValue *binDiv(Loc loc, Type *type, DValue *lhs, Expression *rhs, bool loadLhsAfterRhs) { auto rvals = evalSides(lhs, rhs, loadLhsAfterRhs); - if (type->isComplex()) + if (isComplex(type)) return DtoComplexDiv(loc, type, rvals.lhs, rvals.rhs); LLValue *l = DtoRVal(DtoCast(loc, rvals.lhs, type)); LLValue *r = DtoRVal(DtoCast(loc, rvals.rhs, type)); LLValue *res; - if (type->isFloating()) { + if (isFloating(type)) { res = gIR->ir->CreateFDiv(l, r); } else if (!isLLVMUnsigned(type)) { res = gIR->ir->CreateSDiv(l, r); @@ -268,13 +268,13 @@ DValue *binMod(Loc loc, Type *type, DValue *lhs, Expression *rhs, bool loadLhsAfterRhs) { auto rvals = evalSides(lhs, rhs, loadLhsAfterRhs); - if (type->isComplex()) + if (isComplex(type)) return DtoComplexMod(loc, type, rvals.lhs, rvals.rhs); LLValue *l = DtoRVal(DtoCast(loc, rvals.lhs, type)); LLValue *r = DtoRVal(DtoCast(loc, rvals.rhs, type)); LLValue *res; - if (type->isFloating()) { + if (isFloating(type)) { res = gIR->ir->CreateFRem(l, r); } else if (!isLLVMUnsigned(type)) { res = gIR->ir->CreateSRem(l, r); @@ -344,14 +344,14 @@ LLValue *DtoBinNumericEquals(Loc loc, DValue *lhs, DValue *rhs, EXP op) { assert(op == EXP::equal || op == EXP::notEqual || op == EXP::identity || op == EXP::notIdentity); Type *t = lhs->type->toBasetype(); - assert(t->isFloating()); + assert(isFloating(t)); Logger::println("numeric equality"); LLValue *res = nullptr; - if (t->isComplex()) { + if (isComplex(t)) { Logger::println("complex"); res = DtoComplexEquals(loc, op, lhs, rhs); - } else if (t->isFloating()) { + } else { Logger::println("floating"); res = DtoBinFloatsEquals(loc, lhs, rhs, op); } diff --git a/gen/classes.cpp b/gen/classes.cpp index 9938e3f40b..b9cc9407d4 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -252,7 +252,7 @@ DValue *DtoCastClass(Loc loc, DValue *val, Type *_to) { return new DImValue(_to, gIR->ir->CreateICmpNE(llval, zero)); } // class -> integer - if (to->isIntegral()) { + if (dmd::isIntegral(to)) { IF_LOG Logger::println("to %s", to->toChars()); // get class ptr diff --git a/gen/complex.cpp b/gen/complex.cpp index 867da9e597..3e09004946 100644 --- a/gen/complex.cpp +++ b/gen/complex.cpp @@ -139,9 +139,9 @@ void DtoGetComplexParts(Loc loc, Type *to, DValue *val, DValue *&re, Type *t = val->type->toBasetype(); - if (t->isComplex()) { + if (isComplex(t)) { DValue *v = DtoCastComplex(loc, val, to); - if (to->isComplex()) { + if (isComplex(to)) { if (v->isLVal()) { LLValue *reVal = DtoGEP(DtoType(v->type), DtoLVal(v), 0u, 0, ".re_part"); LLValue *imVal = DtoGEP(DtoType(v->type), DtoLVal(v), 0, 1, ".im_part"); @@ -158,13 +158,13 @@ void DtoGetComplexParts(Loc loc, Type *to, DValue *val, DValue *&re, } else { DtoGetComplexParts(loc, to, v, re, im); } - } else if (t->isImaginary()) { + } else if (isImaginary(t)) { re = nullptr; im = DtoCastFloat(loc, val, baseimty); - } else if (t->isFloating()) { + } else if (isFloating(t)) { re = DtoCastFloat(loc, val, baserety); im = nullptr; - } else if (t->isIntegral()) { + } else if (isIntegral(t)) { re = DtoCastInt(loc, val, baserety); im = nullptr; } else { @@ -431,7 +431,7 @@ LLValue *DtoComplexEquals(Loc loc, EXP op, DValue *lhs, DValue *rhs) { DValue *DtoCastComplex(Loc loc, DValue *val, Type *_to) { Type *to = _to->toBasetype(); Type *vty = val->type->toBasetype(); - if (to->isComplex()) { + if (isComplex(to)) { if (size(vty) == size(to)) { return val; } @@ -451,7 +451,7 @@ DValue *DtoCastComplex(Loc loc, DValue *val, Type *_to) { LLValue *pair = DtoAggrPair(DtoType(_to), re, im); return new DImValue(_to, pair); } - if (to->isImaginary()) { + if (isImaginary(to)) { // FIXME: this loads both values, even when we only need one LLValue *v = DtoRVal(val); LLValue *impart = gIR->ir->CreateExtractValue(v, 1, ".im_part"); @@ -476,7 +476,7 @@ DValue *DtoCastComplex(Loc loc, DValue *val, Type *_to) { return new DImValue( _to, DtoComplexEquals(loc, EXP::notEqual, val, DtoNullValue(vty))); } - if (to->isFloating() || to->isIntegral()) { + if (isFloating(to) || isIntegral(to)) { // FIXME: this loads both values, even when we only need one LLValue *v = DtoRVal(val); LLValue *repart = gIR->ir->CreateExtractValue(v, 0, ".re_part"); diff --git a/gen/dibuilder.cpp b/gen/dibuilder.cpp index df1328ecdb..464712cab8 100644 --- a/gen/dibuilder.cpp +++ b/gen/dibuilder.cpp @@ -391,7 +391,7 @@ DIType DIBuilder::CreateEnumType(TypeEnum *type) { // just emit a typedef for non-integral base types auto tb = type->toBasetype(); - if (!tb->isIntegral()) { + if (!isIntegral(tb)) { auto tbase = CreateTypeDescription(tb); return DBuilder.createTypedef(tbase, name, file, lineNumber, scope); } @@ -861,7 +861,7 @@ DIType DIBuilder::CreateTypeDescription(Type *t, bool voidToUbyte) { return CreateEnumType(te); if (auto tv = t->isTypeVector()) return CreateVectorType(tv); - if (t->isIntegral() || t->isFloating()) + if (isIntegral(t) || isFloating(t)) return CreateBasicType(t); if (auto tp = t->isTypePointer()) return CreatePointerType(tp); diff --git a/gen/dvalue.cpp b/gen/dvalue.cpp index a3eb510a08..2d0e2ad2ea 100644 --- a/gen/dvalue.cpp +++ b/gen/dvalue.cpp @@ -182,7 +182,7 @@ DRValue *DBitFieldLValue::getRVal() { LLValue *v = gIR->ir->CreateAlignedLoad(intType, ptr, llvm::MaybeAlign(1)); // TODO: byte-swap v for big-endian targets? - if (bf->type->isUnsigned()) { + if (dmd::isUnsigned(bf->type)) { if (auto n = bf->bitOffset) v = gIR->ir->CreateLShr(v, n); const auto mask = llvm::APInt::getLowBitsSet(sizeInBits, bf->fieldWidth); diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 83d72dcc55..cd0b73696a 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -418,7 +418,7 @@ void DtoAssign(Loc loc, DValue *lhs, DValue *rhs, EXP op, Logger::cout() << "r : " << *r << '\n'; } DtoStore(r, l); - } else if (t->isComplex()) { + } else if (isComplex(t)) { LLValue *dst = DtoLVal(lhs); LLValue *src = DtoRVal(DtoCast(loc, rhs, lhs->type)); DtoStore(src, dst); @@ -461,7 +461,7 @@ DValue *DtoNullValue(Type *type, Loc loc) { LLType *lltype = DtoType(basetype); // complex, needs to be first since complex are also floating - if (basetype->isComplex()) { + if (isComplex(basetype)) { LLType *basefp = DtoComplexBaseType(basetype); LLValue *res = DtoAggrPair(DtoType(type), LLConstant::getNullValue(basefp), LLConstant::getNullValue(basefp)); @@ -469,7 +469,7 @@ DValue *DtoNullValue(Type *type, Loc loc) { } // integer, floating, pointer, assoc array, delegate and class have no special // representation - if (basetype->isIntegral() || basetype->isFloating() || + if (isIntegral(basetype) || isFloating(basetype) || basety == TY::Tpointer || basety == TY::Tnull || basety == TY::Tclass || basety == TY::Tdelegate || basety == TY::Taarray) { return new DNullValue(type, LLConstant::getNullValue(lltype)); @@ -493,7 +493,7 @@ DValue *DtoCastInt(Loc loc, DValue *val, Type *_to) { Type *to = _to->toBasetype(); Type *from = val->type->toBasetype(); - assert(from->isIntegral()); + assert(isIntegral(from)); LLValue *rval = DtoRVal(val); if (rval->getType() == tolltype) { @@ -506,7 +506,7 @@ DValue *DtoCastInt(Loc loc, DValue *val, Type *_to) { if (to->ty == TY::Tbool) { LLValue *zero = LLConstantInt::get(rval->getType(), 0, false); rval = gIR->ir->CreateICmpNE(rval, zero); - } else if (to->isIntegral()) { + } else if (isIntegral(to)) { if (fromsz < tosz || from->ty == TY::Tbool) { IF_LOG Logger::cout() << "cast to: " << *tolltype << '\n'; if (isLLVMUnsigned(from) || from->ty == TY::Tbool) { @@ -519,10 +519,10 @@ DValue *DtoCastInt(Loc loc, DValue *val, Type *_to) { } else { rval = DtoBitCast(rval, tolltype); } - } else if (to->isComplex()) { + } else if (isComplex(to)) { return DtoComplex(loc, to, val); - } else if (to->isFloating()) { - if (from->isUnsigned()) { + } else if (isFloating(to)) { + if (isUnsigned(from)) { rval = new llvm::UIToFPInst(rval, tolltype, "", gIR->scopebb()); } else { rval = new llvm::SIToFPInst(rval, tolltype, "", gIR->scopebb()); @@ -561,7 +561,7 @@ DValue *DtoCastPtr(Loc loc, DValue *val, Type *to) { LLValue *src = DtoRVal(val); LLValue *zero = LLConstant::getNullValue(src->getType()); rval = gIR->ir->CreateICmpNE(src, zero); - } else if (totype->isIntegral()) { + } else if (isIntegral(totype)) { rval = new llvm::PtrToIntInst(DtoRVal(val), tolltype, "", gIR->scopebb()); } else { error(loc, "invalid cast from `%s` to `%s`", val->type->toChars(), @@ -581,7 +581,7 @@ DValue *DtoCastFloat(Loc loc, DValue *val, Type *to) { Type *totype = to->toBasetype(); Type *fromtype = val->type->toBasetype(); - assert(fromtype->isFloating()); + assert(isFloating(fromtype)); size_t fromsz = size(fromtype); size_t tosz = size(totype); @@ -592,9 +592,9 @@ DValue *DtoCastFloat(Loc loc, DValue *val, Type *to) { rval = DtoRVal(val); LLValue *zero = LLConstant::getNullValue(rval->getType()); rval = gIR->ir->CreateFCmpUNE(rval, zero); - } else if (totype->isComplex()) { + } else if (isComplex(totype)) { return DtoComplex(loc, to, val); - } else if (totype->isFloating()) { + } else if (isFloating(totype)) { if (fromsz == tosz) { rval = DtoRVal(val); assert(rval->getType() == tolltype); @@ -607,8 +607,8 @@ DValue *DtoCastFloat(Loc loc, DValue *val, Type *to) { to->toChars()); fatal(); } - } else if (totype->isIntegral()) { - if (totype->isUnsigned()) { + } else if (isIntegral(totype)) { + if (isUnsigned(totype)) { rval = new llvm::FPToUIInst(DtoRVal(val), tolltype, "", gIR->scopebb()); } else { rval = new llvm::FPToSIInst(DtoRVal(val), tolltype, "", gIR->scopebb()); @@ -724,13 +724,13 @@ DValue *DtoCast(Loc loc, DValue *val, Type *to) { // First, handle vector types (which can also be isIntegral()). return DtoCastVector(loc, val, to); } - if (fromtype->isIntegral()) { + if (isIntegral(fromtype)) { return DtoCastInt(loc, val, to); } - if (fromtype->isComplex()) { + if (isComplex(fromtype)) { return DtoCastComplex(loc, val, to); } - if (fromtype->isFloating()) { + if (isFloating(fromtype)) { return DtoCastFloat(loc, val, to); } @@ -1230,9 +1230,9 @@ static char *DtoOverloadedIntrinsicName(TemplateInstance *ti, Type *T = static_cast(ti->tdtypes[0]); char prefix; - if (T->isFloating() && !T->isComplex()) { + if (isFloating(T) && !isComplex(T)) { prefix = 'f'; - } else if (T->isIntegral()) { + } else if (isIntegral(T)) { prefix = 'i'; } else { error(ti->loc, "%s `%s` has invalid template parameter for intrinsic: `%s`", @@ -1355,7 +1355,7 @@ bool isSpecialRefVar(VarDeclaration *vd) { //////////////////////////////////////////////////////////////////////////////// bool isLLVMUnsigned(Type *t) { - return t->isUnsigned() || t->ty == TY::Tpointer; + return isUnsigned(t) || t->ty == TY::Tpointer; } //////////////////////////////////////////////////////////////////////////////// diff --git a/gen/naked.cpp b/gen/naked.cpp index 5e5b3ea653..36e6dac0cc 100644 --- a/gen/naked.cpp +++ b/gen/naked.cpp @@ -270,15 +270,15 @@ void emitABIReturnAsmStmt(IRAsmBlock *asmblock, Loc loc, // x86 if (triple.getArch() == llvm::Triple::x86) { - if (rt->isIntegral() || rt->ty == TY::Tpointer || rt->ty == TY::Tclass || + if (isIntegral(rt) || rt->ty == TY::Tpointer || rt->ty == TY::Tclass || rt->ty == TY::Taarray) { if (size(rt) == 8) { as->out.c = "=A,"; } else { as->out.c = "={ax},"; } - } else if (rt->isFloating()) { - if (rt->isComplex()) { + } else if (isFloating(rt)) { + if (isComplex(rt)) { if (fdecl->_linkage() == LINK::d) { // extern(D) always returns on the FPU stack as->out.c = "={st},={st(1)},"; @@ -334,10 +334,10 @@ void emitABIReturnAsmStmt(IRAsmBlock *asmblock, Loc loc, // x86_64 else if (triple.getArch() == llvm::Triple::x86_64) { - if (rt->isIntegral() || rt->ty == TY::Tpointer || rt->ty == TY::Tclass || + if (isIntegral(rt) || rt->ty == TY::Tpointer || rt->ty == TY::Tclass || rt->ty == TY::Taarray) { as->out.c = "={ax},"; - } else if (rt->isFloating()) { + } else if (isFloating(rt)) { const bool isWin64 = triple.isOSWindows(); if (rt == Type::tcomplex80 && !isWin64) { @@ -358,7 +358,7 @@ void emitABIReturnAsmStmt(IRAsmBlock *asmblock, Loc loc, as->out.c = "={xmm0},"; asmblock->retty = LLType::getDoubleTy(gIR->context()); } - } else if (rt->isComplex()) { + } else if (isComplex(rt)) { if (isWin64) { // Win64: cdouble and creal are returned via sret // don't add anything! diff --git a/gen/statements.cpp b/gen/statements.cpp index 6ee89057ff..bd711306e7 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -1447,13 +1447,13 @@ class ToIRVisitor : public Visitor { irs->DBuilder.EmitBlockStart(stmt->loc); // evaluate lwr/upr - assert(stmt->lwr->type->isIntegral()); + assert(isIntegral(stmt->lwr->type)); LLValue *lower = DtoRVal(toElemDtor(stmt->lwr)); - assert(stmt->upr->type->isIntegral()); + assert(isIntegral(stmt->upr->type)); LLValue *upper = DtoRVal(toElemDtor(stmt->upr)); // handle key - assert(stmt->key->type->isIntegral()); + assert(isIntegral(stmt->key->type)); LLValue *keyval = DtoRawVarDeclaration(stmt->key); LLType *keytype = DtoType(stmt->key->type); // store initial value in key diff --git a/gen/toconstelem.cpp b/gen/toconstelem.cpp index 9ded6dddc0..e919111f7f 100644 --- a/gen/toconstelem.cpp +++ b/gen/toconstelem.cpp @@ -118,7 +118,7 @@ class ToConstElemVisitor : public Visitor { } else { assert(llvm::isa(t)); result = LLConstantInt::get(t, static_cast(e->getInteger()), - !e->type->isUnsigned()); + !isUnsigned(e->type)); assert(result); IF_LOG Logger::cout() << "value = " << *result << '\n'; } @@ -190,7 +190,7 @@ class ToConstElemVisitor : public Visitor { // very similar to emitPointerOffset() in binops.cpp LLConstant *tryEmitPointerOffset(BinExp *e, bool negateOffset) { Type *t1b = e->e1->type->toBasetype(); - if (t1b->ty != TY::Tpointer || !e->e2->type->isIntegral()) + if (t1b->ty != TY::Tpointer || !isIntegral(e->e2->type)) return nullptr; Type *const pointeeType = t1b->nextOf(); diff --git a/gen/toir.cpp b/gen/toir.cpp index e746c6bbcd..be8878663e 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -929,9 +929,9 @@ class ToElemVisitor : public Visitor { } // Casts are also "optimized into" SymOffExp by the frontend. - LLValue *llVal = (e->type->toBasetype()->isIntegral() - ? p->ir->CreatePtrToInt(offsetValue, DtoType(e->type)) - : DtoBitCast(offsetValue, DtoType(e->type))); + LLValue *llVal = isIntegral(e->type->toBasetype()) + ? p->ir->CreatePtrToInt(offsetValue, DtoType(e->type)) + : DtoBitCast(offsetValue, DtoType(e->type)); result = new DImValue(e->type, llVal); } @@ -1322,7 +1322,7 @@ class ToElemVisitor : public Visitor { LLValue *eval = nullptr; - if (t->isIntegral() || t->ty == TY::Tpointer || t->ty == TY::Tnull) { + if (isIntegral(t) || t->ty == TY::Tpointer || t->ty == TY::Tnull) { llvm::ICmpInst::Predicate icmpPred; tokToICmpPred(e->op, isLLVMUnsigned(t), &icmpPred, &eval); @@ -1338,7 +1338,7 @@ class ToElemVisitor : public Visitor { } eval = p->ir->CreateICmp(icmpPred, a, b); } - } else if (t->isFloating()) { + } else if (isFloating(t)) { llvm::FCmpInst::Predicate cmpop; switch (e->op) { case EXP::lessThan: @@ -1430,7 +1430,7 @@ class ToElemVisitor : public Visitor { // the Tclass catches interface comparisons, regular // class equality should be rewritten as a.opEquals(b) by this time - if (t->isIntegral() || t->ty == TY::Tpointer || t->ty == TY::Tclass || + if (isIntegral(t) || t->ty == TY::Tpointer || t->ty == TY::Tclass || t->ty == TY::Tnull) { Logger::println("integral or pointer or interface"); llvm::ICmpInst::Predicate cmpop; @@ -1454,7 +1454,7 @@ class ToElemVisitor : public Visitor { Logger::cout() << "rv: " << *rv << '\n'; } eval = p->ir->CreateICmp(cmpop, lv, rv); - } else if (t->isFloating()) { // includes iscomplex + } else if (isFloating(t)) { // includes iscomplex eval = DtoBinNumericEquals(e->loc, l, r, e->op); } else if (t->ty == TY::Tsarray || t->ty == TY::Tarray) { Logger::println("static or dynamic array"); @@ -1495,10 +1495,10 @@ class ToElemVisitor : public Visitor { Type *e1type = e->e1->type->toBasetype(); Type *e2type = e->e2->type->toBasetype(); - if (e1type->isIntegral()) { - assert(e2type->isIntegral()); + if (isIntegral(e1type)) { + assert(isIntegral(e2type)); LLValue *one = - LLConstantInt::get(val->getType(), 1, !e2type->isUnsigned()); + LLConstantInt::get(val->getType(), 1, !isUnsigned(e2type)); if (e->op == EXP::plusPlus) { post = llvm::BinaryOperator::CreateAdd(val, one, "", p->scopebb()); } else if (e->op == EXP::minusMinus) { @@ -1509,8 +1509,8 @@ class ToElemVisitor : public Visitor { LLConstant *offset = e->op == EXP::plusPlus ? DtoConstUint(1) : DtoConstInt(-1); post = DtoGEP1(DtoMemType(dv->type->nextOf()), val, offset, "", p->scopebb()); - } else if (e1type->isComplex()) { - assert(e2type->isComplex()); + } else if (isComplex(e1type)) { + assert(isComplex(e2type)); LLValue *one = LLConstantFP::get(DtoComplexBaseType(e1type), 1.0); LLValue *re, *im; DtoGetComplexParts(e->loc, e1type, dv, re, im); @@ -1520,8 +1520,8 @@ class ToElemVisitor : public Visitor { re = llvm::BinaryOperator::CreateFSub(re, one, "", p->scopebb()); } DtoComplexSet(DtoType(dv->type), lval, re, im); - } else if (e1type->isFloating()) { - assert(e2type->isFloating()); + } else if (isFloating(e1type)) { + assert(isFloating(e2type)); LLValue *one = DtoConstFP(e1type, ldouble(1.0)); if (e->op == EXP::plusPlus) { post = llvm::BinaryOperator::CreateFAdd(val, one, "", p->scopebb()); @@ -1534,7 +1534,7 @@ class ToElemVisitor : public Visitor { // The real part of the complex number has already been updated, skip the // store - if (!e1type->isComplex()) { + if (!isComplex(e1type)) { DtoStore(post, lval); } result = new DImValue(e->type, val); @@ -2054,7 +2054,7 @@ class ToElemVisitor : public Visitor { assert(lv->getType() == rv->getType()); } eval = DtoDelegateEquals(e->op, lv, rv); - } else if (t1->isFloating()) { // includes iscomplex + } else if (isFloating(t1)) { // includes iscomplex eval = DtoBinNumericEquals(e->loc, l, r, e->op); } else if (t1->ty == TY::Tpointer || t1->ty == TY::Tclass) { LLValue *lv = DtoRVal(l); @@ -2178,14 +2178,14 @@ class ToElemVisitor : public Visitor { DRValue *dval = toElem(e->e1)->getRVal(); - if (e->type->isComplex()) { + if (isComplex(e->type)) { result = DtoComplexNeg(e->loc, e->type, dval); return; } LLValue *val = DtoRVal(dval); - if (e->type->isIntegral()) { + if (isIntegral(e->type)) { val = p->ir->CreateNeg(val, "negval"); } else { val = p->ir->CreateFNeg(val, "negval"); diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index d4d4066d34..4555f1bd6c 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -49,9 +49,9 @@ bool DtoIsInMemoryOnly(Type *type) { void DtoAddExtendAttr(Type *type, llvm::AttrBuilder &attrs) { type = type->toBasetype(); - if (type->isIntegral() && type->ty != TY::Tvector && size(type) <= 2) { - attrs.addAttribute(type->isUnsigned() ? LLAttribute::ZExt - : LLAttribute::SExt); + if (isIntegral(type) && type->ty != TY::Tvector && size(type) <= 2) { + attrs.addAttribute(isUnsigned(type) ? LLAttribute::ZExt + : LLAttribute::SExt); } } From 3b3b62243331a1b7a73fbff015099cd1deeb5b41 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 7 Apr 2026 18:26:31 +0200 Subject: [PATCH 419/440] Adapt to free-standing to[U]Integer for Expression --- gen/abi/wasm.cpp | 2 +- gen/arrays.cpp | 12 ++++++------ gen/asm-x86.h | 24 ++++++++++++------------ gen/binops.cpp | 4 ++-- gen/dcompute/druntime.cpp | 2 +- gen/dibuilder.cpp | 6 +++--- gen/llvmhelpers.cpp | 4 ++-- gen/objcgen.cpp | 2 +- gen/pragma.cpp | 2 +- gen/semantic-dcompute.cpp | 2 +- gen/statements.cpp | 4 ++-- gen/tocall.cpp | 16 ++++++++-------- gen/toconstelem.cpp | 8 ++++---- gen/toir.cpp | 8 ++++---- gen/typinf.cpp | 2 +- gen/uda.cpp | 4 ++-- ir/iraggr.cpp | 2 +- ir/irtype.cpp | 4 ++-- 18 files changed, 54 insertions(+), 54 deletions(-) diff --git a/gen/abi/wasm.cpp b/gen/abi/wasm.cpp index 1ab3734e0e..2f4f034045 100644 --- a/gen/abi/wasm.cpp +++ b/gen/abi/wasm.cpp @@ -26,7 +26,7 @@ Type *getSingleWrappedScalarType(Type *t) { } if (auto tsa = t->isTypeSArray()) { - if (tsa->dim->toInteger() != 1) + if (toInteger(tsa->dim) != 1) return nullptr; return getSingleWrappedScalarType(tsa->nextOf()); } diff --git a/gen/arrays.cpp b/gen/arrays.cpp index a27c4338e6..ef1b793293 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -42,7 +42,7 @@ LLArrayType *DtoStaticArrayType(Type *t) { TypeSArray *tsa = static_cast(t); Type *tnext = tsa->nextOf(); - return LLArrayType::get(DtoMemType(tnext), tsa->dim->toUInteger()); + return LLArrayType::get(DtoMemType(tnext), toUInteger(tsa->dim)); } //////////////////////////////////////////////////////////////////////////////// @@ -322,7 +322,7 @@ LLConstant *DtoConstArrayInitializer(ArrayInitializer *arrinit, // initialized elements in the value/index lists if (arrty->ty == TY::Tsarray) { TypeSArray *tsa = static_cast(arrty); - arrlen = static_cast(tsa->dim->toInteger()); + arrlen = static_cast(toInteger(tsa->dim)); } // make sure the number of initializers is sane @@ -356,7 +356,7 @@ LLConstant *DtoConstArrayInitializer(ArrayInitializer *arrinit, // idx can be null, then it's just the next element if (idx) { - j = idx->toInteger(); + j = toInteger(idx); } assert(j < arrlen); @@ -801,7 +801,7 @@ LLValue *DtoArrayLen(DValue *v) { assert(!v->isSlice()); assert(!v->isNull()); TypeSArray *sarray = static_cast(t); - return DtoConstSize_t(sarray->dim->toUInteger()); + return DtoConstSize_t(toUInteger(sarray->dim)); } llvm_unreachable("unsupported array for len"); } @@ -862,7 +862,7 @@ DValue *DtoCastArray(Loc loc, DValue *u, Type *to) { LLValue *ptr = nullptr; if (fromtype->ty == TY::Tsarray) { length = DtoConstSize_t( - static_cast(fromtype)->dim->toUInteger()); + toUInteger(static_cast(fromtype)->dim)); ptr = DtoLVal(u); } else { length = DtoArrayLen(u); @@ -901,7 +901,7 @@ DValue *DtoCastArray(Loc loc, DValue *u, Type *to) { if (fromtype->ty == TY::Tsarray) { ptr = DtoLVal(u); } else { - size_t tosize = static_cast(totype)->dim->toInteger(); + size_t tosize = toInteger(static_cast(totype)->dim); size_t i = (tosize * size(totype->nextOf()) - 1) / size(fromtype->nextOf()); DConstValue index(Type::tsize_t, DtoConstSize_t(i)); diff --git a/gen/asm-x86.h b/gen/asm-x86.h index aca0bd8c3d..c9d8ad1427 100644 --- a/gen/asm-x86.h +++ b/gen/asm-x86.h @@ -2344,12 +2344,12 @@ struct AsmProcessor { switch (type) { case Arg_Integer: if (dmd::isUnsigned(e->type)) { - insnTemplate << "$" << e->toUInteger(); + insnTemplate << "$" << dmd::toUInteger(e); } else { #ifndef ASM_X86_64 - insnTemplate << "$" << static_cast(e->toInteger()); + insnTemplate << "$" << static_cast(dmd::toInteger(e)); #else - insnTemplate << "$" << e->toInteger(); + insnTemplate << "$" << dmd::toInteger(e); #endif } break; @@ -3199,7 +3199,7 @@ struct AsmProcessor { if (is_offset) { invalidExpression(); } - operand->constDisplacement += exp->toInteger(); + operand->constDisplacement += dmd::toInteger(exp); if (!operand->inBracket) { operand->hasNumber = 1; } @@ -3209,15 +3209,15 @@ struct AsmProcessor { } if (!operand->inBracket) { if (operand->reg == Reg_Invalid) { - operand->reg = static_cast(exp->toInteger()); + operand->reg = static_cast(dmd::toInteger(exp)); } else { error(stmt->loc, "too many registers in operand (use brackets)"); } } else { if (operand->baseReg == Reg_Invalid) { - operand->baseReg = static_cast(exp->toInteger()); + operand->baseReg = static_cast(dmd::toInteger(exp)); } else if (operand->indexReg == Reg_Invalid) { - operand->indexReg = static_cast(exp->toInteger()); + operand->indexReg = static_cast(dmd::toInteger(exp)); operand->scale = 1; } else { error(stmt->loc, "too many registers memory operand"); @@ -3289,7 +3289,7 @@ struct AsmProcessor { Expression *exp = parseAsmExp(); slotExp(exp); if (isRegExp(exp)) { - operand->dataSize = static_cast(regInfo[exp->toInteger()].size); + operand->dataSize = static_cast(regInfo[dmd::toInteger(exp)].size); } } @@ -3305,7 +3305,7 @@ struct AsmProcessor { } nextToken(); Expression *exp3 = parseCondExp(); - exp = exp->toUInteger() ? exp2 : exp3; + exp = dmd::toUInteger(exp) ? exp2 : exp3; } return exp; } @@ -3496,8 +3496,8 @@ struct AsmProcessor { return true; } - operand->indexReg = static_cast(e1->toInteger()); - operand->scale = e2->toInteger(); + operand->indexReg = static_cast(dmd::toInteger(e1)); + operand->scale = dmd::toInteger(e2); switch (operand->scale) { case 1: case 2: @@ -3849,7 +3849,7 @@ struct AsmProcessor { // parse primary: DMD allows 'MyAlign' (const int) but not '2+2' // GAS is padding with NOPs last time I checked. Expression *e = ctfeInterpret(parseAsmExp()); - uinteger_t align = e->toUInteger(); + uinteger_t align = dmd::toUInteger(e); if ((align & (align - 1)) == 0) { // FIXME: This printf is not portable. The use of `align` varies from diff --git a/gen/binops.cpp b/gen/binops.cpp index c9a1dfe02d..2e363f7281 100644 --- a/gen/binops.cpp +++ b/gen/binops.cpp @@ -64,7 +64,7 @@ Expression *extractNoStrideInc(Expression *e, dinteger_t baseSize, bool &negate) if (!mul->e2->isConst()) { return nullptr; } - dinteger_t stride = mul->e2->toInteger(); + dinteger_t stride = toInteger(mul->e2); if (stride != baseSize) { return nullptr; @@ -89,7 +89,7 @@ DValue *emitPointerOffset(Loc loc, DValue *base, Expression *offset, if (offset->isConst()) { llBase = DtoRVal(base); - const dinteger_t byteOffset = offset->toInteger(); + const dinteger_t byteOffset = toInteger(offset); if (byteOffset == 0) { llResult = llBase; } else { diff --git a/gen/dcompute/druntime.cpp b/gen/dcompute/druntime.cpp index 829185481c..402bb5aa6b 100644 --- a/gen/dcompute/druntime.cpp +++ b/gen/dcompute/druntime.cpp @@ -49,7 +49,7 @@ std::optional toDcomputePointer(StructDeclaration *sd) { } TemplateInstance *ti = sd->isInstantiated(); - int addrspace = isExpression((*ti->tiargs)[0])->toInteger(); + int addrspace = toInteger(isExpression((*ti->tiargs)[0])); Type *type = isType((*ti->tiargs)[1]); return std::optional(DcomputePointer(addrspace, type)); } diff --git a/gen/dibuilder.cpp b/gen/dibuilder.cpp index 464712cab8..7539a74f3e 100644 --- a/gen/dibuilder.cpp +++ b/gen/dibuilder.cpp @@ -402,7 +402,7 @@ DIType DIBuilder::CreateEnumType(TypeEnum *type) { EnumMember *em = m->isEnumMember(); if (auto ie = em->value()->isIntegerExp()) { subscripts.push_back( - DBuilder.createEnumerator(em->toChars(), ie->toInteger())); + DBuilder.createEnumerator(em->toChars(), toInteger(ie))); } } } @@ -431,7 +431,7 @@ DIType DIBuilder::CreatePointerType(TypePointer *type) { DIType DIBuilder::CreateVectorType(TypeVector *type) { LLType *T = DtoType(type); - const auto dim = type->basetype->isTypeSArray()->dim->toInteger(); + const auto dim = toInteger(type->basetype->isTypeSArray()->dim); const auto Dim = llvm::ConstantAsMetadata::get(DtoConstSize_t(dim)); auto subscript = DBuilder.getOrCreateSubrange(Dim, nullptr, nullptr, nullptr); @@ -711,7 +711,7 @@ DIType DIBuilder::CreateSArrayType(TypeSArray *type) { llvm::SmallVector subscripts; for (; te->ty == TY::Tsarray; te = te->nextOf()) { TypeSArray *tsa = static_cast(te); - const auto count = tsa->dim->toInteger(); + const auto count = toInteger(tsa->dim); const auto Count = llvm::ConstantAsMetadata::get(DtoConstSize_t(count)); const auto subscript = DBuilder.getOrCreateSubrange(Count, nullptr, nullptr, nullptr); diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index cd0b73696a..ccd07e088d 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -1149,7 +1149,7 @@ LLConstant *DtoConstExpInit(Loc loc, Type *targetType, Expression *exp) { baseValType = stripModifiers(baseValType); LLSmallVector dims; // { 3, 2 } for (auto t = baseTargetType; t->ty == TY::Tsarray;) { - dims.push_back(static_cast(t)->dim->toUInteger()); + dims.push_back(toUInteger(static_cast(t)->dim)); auto elementType = stripModifiers(t->nextOf()->toBasetype()); if (elementType->equals(baseValType)) break; @@ -1175,7 +1175,7 @@ LLConstant *DtoConstExpInit(Loc loc, Type *targetType, Expression *exp) { TypeVector *tv = static_cast(baseTargetType); assert(tv->basetype->ty == TY::Tsarray); dinteger_t elemCount = - static_cast(tv->basetype)->dim->toInteger(); + toInteger(static_cast(tv->basetype)->dim); const auto elementCount = llvm::ElementCount::getFixed(elemCount); return llvm::ConstantVector::getSplat(elementCount, val); } diff --git a/gen/objcgen.cpp b/gen/objcgen.cpp index d1602daf93..243c1bc127 100644 --- a/gen/objcgen.cpp +++ b/gen/objcgen.cpp @@ -69,7 +69,7 @@ std::string objcGetTypeEncoding(Type *t) { // Static arrays are encoded in the form of: // [] auto typ = t->isTypeSArray(); - uinteger_t count = typ->dim->toUInteger(); + uinteger_t count = dmd::toUInteger(typ->dim); tmp.append("["); tmp.append(std::to_string(count)); tmp.append(objcGetTypeEncoding(typ->next)); diff --git a/gen/pragma.cpp b/gen/pragma.cpp index 8134bb5d97..0a296ceae1 100644 --- a/gen/pragma.cpp +++ b/gen/pragma.cpp @@ -51,7 +51,7 @@ bool parseBoolExp(Expression *e, bool &res) { e = optimize(e, WANTvalue); if (auto i = e->isIntegerExp()) { if (e->type->equals(Type::tbool)) { - res = (i->toInteger() != 0); + res = (toInteger(i) != 0); return true; } } diff --git a/gen/semantic-dcompute.cpp b/gen/semantic-dcompute.cpp index 1cf3fb4843..8a1f790039 100644 --- a/gen/semantic-dcompute.cpp +++ b/gen/semantic-dcompute.cpp @@ -205,7 +205,7 @@ struct DComputeSemanticAnalyser : public StoppableVisitor { // @compute semantics and the recursive visitor should stop here. if (auto ce = stmt->condition->isCallExp()) { if (ce->f && ce->f->ident == Id::dcReflect) { - auto arg1 = (DComputeTarget::ID)(*ce->arguments)[0]->toInteger(); + auto arg1 = (DComputeTarget::ID)dmd::toInteger((*ce->arguments)[0]); if (arg1 == DComputeTarget::ID::Host) stop = true; } diff --git a/gen/statements.cpp b/gen/statements.cpp index bd711306e7..2591cf21db 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -360,8 +360,8 @@ class ToIRVisitor : public Visitor { ////////////////////////////////////////////////////////////////////////// bool dcomputeReflectMatches(CallExp *ce) { - auto arg1 = (DComputeTarget::ID)(*ce->arguments)[0]->toInteger(); - auto arg2 = (*ce->arguments)[1]->toInteger(); + auto arg1 = (DComputeTarget::ID)toInteger((*ce->arguments)[0]); + auto arg2 = toInteger((*ce->arguments)[1]); auto dct = irs->dcomputetarget; if (!dct) { return arg1 == DComputeTarget::ID::Host; diff --git a/gen/tocall.cpp b/gen/tocall.cpp index c1b0bc1b3c..85593e1d5b 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -350,10 +350,10 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e, fatal(); } auto atomicOrdering = - static_cast((*e->arguments)[0]->toInteger()); + static_cast(toInteger((*e->arguments)[0])); llvm::SyncScope::ID scope = llvm::SyncScope::System; if (e->arguments->length == 2) { - scope = static_cast((*e->arguments)[1]->toInteger()); + scope = static_cast(toInteger((*e->arguments)[1])); } // orderings below acquire are invalid; like clang, don't emit any // instruction in those cases @@ -372,7 +372,7 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e, } Expression *exp1 = (*e->arguments)[0]; Expression *exp2 = (*e->arguments)[1]; - int atomicOrdering = (*e->arguments)[2]->toInteger(); + int atomicOrdering = toInteger((*e->arguments)[2]); DValue *dval = toElem(exp1); LLValue *ptr = DtoRVal(exp2); @@ -407,7 +407,7 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e, } Expression *exp = (*e->arguments)[0]; - int atomicOrdering = (*e->arguments)[1]->toInteger(); + int atomicOrdering = toInteger((*e->arguments)[1]); LLValue *ptr = DtoRVal(exp); LLType *pointeeType = DtoType(e->type); @@ -455,10 +455,10 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e, Expression *exp2 = (*e->arguments)[1]; Expression *exp3 = (*e->arguments)[2]; const auto successOrdering = - llvm::AtomicOrdering((*e->arguments)[3]->toInteger()); + llvm::AtomicOrdering(toInteger((*e->arguments)[3])); const auto failureOrdering = - llvm::AtomicOrdering((*e->arguments)[4]->toInteger()); - const bool isWeak = (*e->arguments)[5]->toInteger() != 0; + llvm::AtomicOrdering(toInteger((*e->arguments)[4])); + const bool isWeak = toInteger((*e->arguments)[5]) != 0; LLValue *ptr = DtoRVal(exp1); LLType *pointeeType = DtoType(exp1->type->isTypePointer()->nextOf()); @@ -528,7 +528,7 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e, Expression *exp1 = (*e->arguments)[0]; Expression *exp2 = (*e->arguments)[1]; - int atomicOrdering = (*e->arguments)[2]->toInteger(); + int atomicOrdering = toInteger((*e->arguments)[2]); LLValue *ptr = DtoRVal(exp1); LLValue *val = DtoRVal(exp2); LLValue *ret = diff --git a/gen/toconstelem.cpp b/gen/toconstelem.cpp index e919111f7f..7cd811c00e 100644 --- a/gen/toconstelem.cpp +++ b/gen/toconstelem.cpp @@ -168,7 +168,7 @@ class ToConstElemVisitor : public Visitor { Type *const t = e->type->toBasetype(); if (auto ts = t->isTypeSArray()) { - const auto arrayLength = ts->dim->toInteger(); + const auto arrayLength = toInteger(ts->dim); assert(arrayLength >= e->len); result = buildStringLiteralConstant(e, arrayLength); return; @@ -196,7 +196,7 @@ class ToConstElemVisitor : public Visitor { Type *const pointeeType = t1b->nextOf(); LLConstant *llBase = toConstElem(e->e1, p); - const dinteger_t byteOffset = e->e2->toInteger(); + const dinteger_t byteOffset = toInteger(e->e2); LLConstant *llResult = nullptr; const auto pointeeSize = size(pointeeType, e->loc); @@ -260,7 +260,7 @@ class ToConstElemVisitor : public Visitor { if (auto se = e->e1->isStringExp()) if (auto lwr = e->lwr->isIntegerExp()) if (auto upr = e->upr->isIntegerExp()) - if (lwr->toInteger() == 0 && upr->toInteger() == se->len) { + if (toInteger(lwr) == 0 && toInteger(upr) == se->len) { result = toConstElem(se, p); return; } @@ -625,7 +625,7 @@ class ToConstElemVisitor : public Visitor { assert(tv->ty == TY::Tvector); const auto elemCount = - static_cast(tv->basetype)->dim->toInteger(); + toInteger(static_cast(tv->basetype)->dim); // Array literals are assigned element-for-element; other expressions splat // across the whole vector. diff --git a/gen/toir.cpp b/gen/toir.cpp index be8878663e..2c48ec391d 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -435,7 +435,7 @@ class ToElemVisitor : public Visitor { const auto stringLength = e->len; if (auto tsa = dtype->isTypeSArray()) { - const auto arrayLength = tsa->dim->toInteger(); + const auto arrayLength = toInteger(tsa->dim); assert(arrayLength >= stringLength); // ImportC: static array length may exceed string length incl. null // terminator - bypass string-literal cache and create a separate constant @@ -567,7 +567,7 @@ class ToElemVisitor : public Visitor { if (e->e1->type->toBasetype()->ty == TY::Tstruct && e->e2->op == EXP::int64) { Logger::println("performing aggregate zero initialization"); - assert(e->e2->toInteger() == 0); + assert(toInteger(e->e2) == 0); LLValue *lval = DtoLVal(lhs); DtoMemSetZero(DtoType(lhs->type), lval); TypeStruct *ts = static_cast(e->e1->type); @@ -1286,7 +1286,7 @@ class ToElemVisitor : public Visitor { // (namely default initialization, int[16][16] arr; -> int[256] arr = 0;) if (etype->ty == TY::Tsarray) { TypeSArray *tsa = static_cast(etype); - elen = DtoConstSize_t(tsa->dim->toUInteger()); + elen = DtoConstSize_t(toUInteger(tsa->dim)); } } @@ -2602,7 +2602,7 @@ class ToElemVisitor : public Visitor { if (auto ts = tsrc->isTypeSArray()) { Logger::println("static array expression"); (void)ts; - assert(ts->dim->toInteger() == N && + assert(toInteger(ts->dim) == N && "Static array vector initializer length mismatch, should have " "been handled in frontend."); } else { diff --git a/gen/typinf.cpp b/gen/typinf.cpp index d622267ee8..be4a3261ba 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -206,7 +206,7 @@ class DefineVisitor : public Visitor { b.push_typeinfo(tc->nextOf()); // length - b.push(DtoConstSize_t(static_cast(tc->dim->toUInteger()))); + b.push(DtoConstSize_t(static_cast(toUInteger(tc->dim)))); // finish b.finalize(gvar); diff --git a/gen/uda.cpp b/gen/uda.cpp index 63f84e5699..d5d03c4963 100644 --- a/gen/uda.cpp +++ b/gen/uda.cpp @@ -145,7 +145,7 @@ void callForEachMagicAttribute(Dsymbol &sym, const Identifier *id, sinteger_t getIntElem(StructLiteralExp *sle, size_t idx) { auto arg = (*sle->elements)[idx]; - return arg->toInteger(); + return toInteger(arg); } llvm::StringRef getStringElem(StructLiteralExp *sle, size_t idx) { @@ -630,7 +630,7 @@ extern "C" DComputeCompileFor hasComputeAttr(Dsymbol *sym) { checkStructElems(sle, {Type::tint32}); - return static_cast(1 + (*sle->elements)[0]->toInteger()); + return static_cast(1 + toInteger((*sle->elements)[0])); } /// Returns whether `sym` has the `@ldc.dcompute._kernel()` UDA applied. diff --git a/ir/iraggr.cpp b/ir/iraggr.cpp index 94275dafce..bfe7439d23 100644 --- a/ir/iraggr.cpp +++ b/ir/iraggr.cpp @@ -171,7 +171,7 @@ static llvm::Constant *FillSArrayDims(Type *arrTypeD, llvm::Constant *init) { if (arrTypeD->ty == TY::Tsarray) { init = FillSArrayDims(arrTypeD->nextOf(), init); - size_t dim = static_cast(arrTypeD)->dim->toUInteger(); + size_t dim = toUInteger(static_cast(arrTypeD)->dim); llvm::ArrayType *arrty = llvm::ArrayType::get(init->getType(), dim); return llvm::ConstantArray::get(arrty, std::vector(dim, init)); diff --git a/ir/irtype.cpp b/ir/irtype.cpp index edf8aa6599..4cff3ed7bd 100644 --- a/ir/irtype.cpp +++ b/ir/irtype.cpp @@ -143,7 +143,7 @@ IrTypeSArray *IrTypeSArray::get(Type *dt) { // forward reference in a struct. if (!ctype) { TypeSArray *tsa = static_cast(dt); - uint64_t dim = static_cast(tsa->dim->toUInteger()); + uint64_t dim = static_cast(dmd::toUInteger(tsa->dim)); ctype = new IrTypeSArray(dt, llvm::ArrayType::get(elemType, dim)); } @@ -185,7 +185,7 @@ IrTypeVector *IrTypeVector::get(Type *dt) { // Could have already built the type as part of a struct forward reference, // just as for pointers and arrays. if (!ctype) { - LLType *lt = llvm::VectorType::get(elemType, tsa->dim->toUInteger(), + LLType *lt = llvm::VectorType::get(elemType, dmd::toUInteger(tsa->dim), /*Scalable=*/false); ctype = new IrTypeVector(dt, lt); } From 326959d35ebba1c87b09503f56f55fb863fb61a2 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 7 Apr 2026 19:04:50 +0200 Subject: [PATCH 420/440] Adapt to free-standing isLvalue for Expression --- gen/asm-gcc.cpp | 4 ++-- gen/tocall.cpp | 2 +- gen/toir.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gen/asm-gcc.cpp b/gen/asm-gcc.cpp index 60026c6f98..eeb4bdb31c 100644 --- a/gen/asm-gcc.cpp +++ b/gen/asm-gcc.cpp @@ -213,7 +213,7 @@ void GccAsmStatement_toIR(GccAsmStatement *stmt, IRState *irs) { const bool isIndirect = constraintsBuilder.isIndirectOperand(i); if (isOutput) { - assert(e->isLvalue() && "should have been caught by front-end"); + assert(dmd::isLvalue(e) && "should have been caught by front-end"); LLValue *lval = DtoLVal(e); if (isIndirect) { operands.push_back(lval); @@ -223,7 +223,7 @@ void GccAsmStatement_toIR(GccAsmStatement *stmt, IRState *irs) { outputTypes.push_back(DtoType(e->type)); } } else { - if (isIndirect && !e->isLvalue()) { + if (isIndirect && !dmd::isLvalue(e)) { error(e->loc, "indirect `\"m\"` input operands require an lvalue, but `%s` " "is an rvalue", diff --git a/gen/tocall.cpp b/gen/tocall.cpp index 85593e1d5b..c04d235688 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -148,7 +148,7 @@ static void addExplicitArguments(std::vector &args, AttrSet &attrs, DValue *const dval = DtoArgument(formalParam, argexp); // load from lvalue/let TargetABI rewrite it/... - bool isLValueExp = argexp->isLvalue(); + bool isLValueExp = isLvalue(argexp); // regard temporaries as rvalues here if (isLValueExp) { auto ae = argexp; diff --git a/gen/toir.cpp b/gen/toir.cpp index 2c48ec391d..3fa3fa2389 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -182,7 +182,7 @@ static void write_struct_literal(Loc loc, LLValue *mem, StructDeclaration *sd, // try to construct it in-place if (!toInPlaceConstruction(field, expr)) { DtoAssign(loc, field, toElem(expr), EXP::blit); - if (expr->isLvalue()) + if (isLvalue(expr)) callPostblit(loc, expr, DtoLVal(field)); } } else { @@ -581,10 +581,10 @@ class ToElemVisitor : public Visitor { // getting out of sync? bool lvalueElem = false; if ((e->e2->op == EXP::slice && - static_cast(e->e2)->e1->isLvalue()) || + isLvalue(static_cast(e->e2)->e1)) || (e->e2->op == EXP::cast_ && - static_cast(e->e2)->e1->isLvalue()) || - (e->e2->op != EXP::slice && e->e2->isLvalue())) { + isLvalue(static_cast(e->e2)->e1)) || + (e->e2->op != EXP::slice && isLvalue(e->e2))) { lvalueElem = true; } From cb5325936a0f10c7c144b5b21c517d3de29d9df2 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 7 Apr 2026 19:07:37 +0200 Subject: [PATCH 421/440] Adapt to free-standing needsDestruction for Type --- gen/arrays.cpp | 2 +- gen/llvmhelpers.cpp | 2 +- gen/toir.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gen/arrays.cpp b/gen/arrays.cpp index ef1b793293..5c825664de 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -200,7 +200,7 @@ void DtoArrayAssign(Loc loc, DValue *lhs, DValue *rhs, EXP op, Type *const elemType = t->nextOf()->toBasetype(); const bool needsDestruction = - (!isConstructing && elemType->needsDestruction()); + (!isConstructing && dmd::needsDestruction(elemType)); LLValue *lhsPtr = DtoArrayPtr(lhs); LLValue *lhsLength = DtoArrayLen(lhs); diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index ccd07e088d..cbe70d895a 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -123,7 +123,7 @@ void DtoDeleteArray(Loc loc, DValue *arr) { // the TypeInfo argument must be null if the type has no dtor Type *elementType = arr->type->nextOf(); bool hasDtor = (elementType->toBasetype()->ty == TY::Tstruct && - elementType->needsDestruction()); + needsDestruction(elementType)); LLValue *typeInfo = !hasDtor ? getNullPtr() : DtoTypeInfoOf(loc, elementType); diff --git a/gen/toir.cpp b/gen/toir.cpp index 3fa3fa2389..7e3b691b83 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -1686,7 +1686,7 @@ class ToElemVisitor : public Visitor { // pointer if (et->ty == TY::Tpointer) { Type *elementType = et->nextOf()->toBasetype(); - if (elementType->ty == TY::Tstruct && elementType->needsDestruction()) { + if (elementType->ty == TY::Tstruct && needsDestruction(elementType)) { DtoDeleteStruct(e->loc, dval); } else { DtoDeleteMemory(e->loc, dval); From 5286bfc295fdf9d5a0f3c453188bae9e0713f8e6 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 7 Apr 2026 19:09:19 +0200 Subject: [PATCH 422/440] Adapt to free-standing toStringExp for Expression --- gen/inlineir.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gen/inlineir.cpp b/gen/inlineir.cpp index 11db6e52d6..7740bb8726 100644 --- a/gen/inlineir.cpp +++ b/gen/inlineir.cpp @@ -133,20 +133,20 @@ DValue *DtoInlineIRExpr(Loc loc, FuncDeclaration *fdecl, if (isExtended) { Expression *a0 = isExpression(objs[0]); assert(a0); - StringExp *prefexp = a0->toStringExp(); + StringExp *prefexp = toStringExp(a0); Expression *a1 = isExpression(objs[1]); assert(a1); - StringExp *strexp = a1->toStringExp(); + StringExp *strexp = toStringExp(a1); Expression *a2 = isExpression(objs[2]); assert(a2); - StringExp *suffexp = a2->toStringExp(); + StringExp *suffexp = toStringExp(a2); prefix = exprToString(prefexp); code = exprToString(strexp); suffix = exprToString(suffexp); } else { Expression *a0 = isExpression(objs[0]); assert(a0); - StringExp *strexp = a0->toStringExp(); + StringExp *strexp = toStringExp(a0); code = exprToString(strexp); } From 489922ba95ac63c2c40a543ae49e2630c8b9a4c3 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 7 Apr 2026 19:12:03 +0200 Subject: [PATCH 423/440] Adapt to free-standing alignment and alignsize for Type --- gen/llvmhelpers.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index cbe70d895a..191d3b0479 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -136,13 +136,13 @@ void DtoDeleteArray(Loc loc, DValue *arr) { ******************************************************************************/ unsigned DtoAlignment(Type *type) { - const auto alignment = type->alignment(); + const auto alignment = dmd::alignment(type); if (!alignment.isDefault() && !alignment.isPack()) return alignment.get(); auto ts = type->toBasetype()->isTypeStruct(); return ts && !ts->sym->members ? 0 // opaque struct - : type->alignsize(); + : dmd::alignsize(type); } unsigned DtoAlignment(VarDeclaration *vd) { From e47e712e6656a3b2d1e54365b8f2b2bc0ba94de0 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 7 Apr 2026 19:18:17 +0200 Subject: [PATCH 424/440] Adapt to free-standing search for Scope, incl. frontend header fix --- dmd/scope.h | 2 -- gen/asm-x86.h | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dmd/scope.h b/dmd/scope.h index 2f75c213e3..8c9ce691d7 100644 --- a/dmd/scope.h +++ b/dmd/scope.h @@ -141,6 +141,4 @@ struct Scope final AliasDeclaration *aliasAsg; // if set, then aliasAsg is being assigned a new value, // do not set wasRead for it StructDeclaration *argStruct; // elimiate recursion when looking for rvalue construction - - Dsymbol *search(Loc loc, Identifier *ident, Dsymbol *&pscopesym, SearchOptFlags flags = (SearchOptFlags)SearchOpt::all); }; diff --git a/gen/asm-x86.h b/gen/asm-x86.h index c9d8ad1427..e2b3ea7ca6 100644 --- a/gen/asm-x86.h +++ b/gen/asm-x86.h @@ -3795,7 +3795,7 @@ struct AsmProcessor { // DMD uses labels secondarily to other symbols, so check // if IdentifierExp::semantic won't find anything. Dsymbol *scopesym; - if (!sc->search(stmt->loc, ident, scopesym)) { + if (!dmd::search(sc, stmt->loc, ident, scopesym)) { if (LabelDsymbol *labelsym = sc->func->searchLabel(ident, stmt->loc)) { e = createDsymbolExp(stmt->loc, labelsym); if (opTakesLabel()) { @@ -3812,7 +3812,7 @@ struct AsmProcessor { // Special case for floating point constant declarations. if (e->op == EXP::float64) { Dsymbol *scopesym; - Dsymbol *sym = sc->search(stmt->loc, ident, scopesym); + Dsymbol *sym = dmd::search(sc, stmt->loc, ident, scopesym); if (sym) { VarDeclaration *v = sym->isVarDeclaration(); if (v) { From 2d32e52172fdcee265c6217dae2a7cc89dcfcddf Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 7 Apr 2026 19:22:53 +0200 Subject: [PATCH 425/440] Bump Phobos to v2.113 --- runtime/phobos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/phobos b/runtime/phobos index 43871eaaca..8b67488529 160000 --- a/runtime/phobos +++ b/runtime/phobos @@ -1 +1 @@ -Subproject commit 43871eaacabd629fbd7b0bde5b868e727ff0b314 +Subproject commit 8b6748852900bcdbad50c0a3412df479b477d2c4 From d6687f2532bb7b9a4929e537b8b2c4e02fcb2dd6 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Wed, 8 Apr 2026 16:02:05 +0200 Subject: [PATCH 426/440] druntime: Little merge fix for core.checkedint.mulu() --- runtime/druntime/src/core/checkedint.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/druntime/src/core/checkedint.d b/runtime/druntime/src/core/checkedint.d index 3f462682ca..bfef61b694 100644 --- a/runtime/druntime/src/core/checkedint.d +++ b/runtime/druntime/src/core/checkedint.d @@ -970,8 +970,8 @@ ulong mulu()(ulong x, uint y, ref bool overflow) { version (LDC_HasNativeI64Mul) { - if (!__ctfe) - return mulu(x, ulong(y), overflow); + return __ctfe ? mulu_generic(x, y, overflow) + : mulu(x, ulong(y), overflow); } else version (D_InlineAsm_X86_64) { From 1a4626dd00a1abe38aa40c85f7df4601d1539713 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Wed, 8 Apr 2026 16:31:26 +0200 Subject: [PATCH 427/440] asm-x86.h: Don't use toInteger() for special 'RegExp' The DMD-style asm parser uses IntegerExp with special `op = EXP::mod` to mark them as register-expressions, instead of `op = EXP::int64`. The new free-standing `toInteger()` function operates on `Expression.op`, so fails for these special register-expressions (and then ICEs later in `toChars()` for the error message). So introduce an extra helper function to get the `Reg` enum value for such expressions. --- gen/asm-x86.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gen/asm-x86.h b/gen/asm-x86.h index e2b3ea7ca6..8b4428160c 100644 --- a/gen/asm-x86.h +++ b/gen/asm-x86.h @@ -3174,6 +3174,11 @@ struct AsmProcessor { } #endif + Reg regFromRegExp(Expression *exp) { + assert(isRegExp(exp)); + return static_cast(static_cast(exp)->value); + } + void slotExp(Expression *exp) { /* if offset, make a note @@ -3209,15 +3214,15 @@ struct AsmProcessor { } if (!operand->inBracket) { if (operand->reg == Reg_Invalid) { - operand->reg = static_cast(dmd::toInteger(exp)); + operand->reg = regFromRegExp(exp); } else { error(stmt->loc, "too many registers in operand (use brackets)"); } } else { if (operand->baseReg == Reg_Invalid) { - operand->baseReg = static_cast(dmd::toInteger(exp)); + operand->baseReg = regFromRegExp(exp); } else if (operand->indexReg == Reg_Invalid) { - operand->indexReg = static_cast(dmd::toInteger(exp)); + operand->indexReg = regFromRegExp(exp); operand->scale = 1; } else { error(stmt->loc, "too many registers memory operand"); @@ -3289,7 +3294,7 @@ struct AsmProcessor { Expression *exp = parseAsmExp(); slotExp(exp); if (isRegExp(exp)) { - operand->dataSize = static_cast(regInfo[dmd::toInteger(exp)].size); + operand->dataSize = static_cast(regInfo[regFromRegExp(exp)].size); } } @@ -3496,7 +3501,7 @@ struct AsmProcessor { return true; } - operand->indexReg = static_cast(dmd::toInteger(e1)); + operand->indexReg = regFromRegExp(e1); operand->scale = dmd::toInteger(e2); switch (operand->scale) { case 1: From 1b4a0604dfff2d3284f7a27275e08b490749b68b Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Wed, 8 Apr 2026 17:18:37 +0200 Subject: [PATCH 428/440] druntime: Adapt to core.internal.vararg.aarch64 module rename to aapcs64 --- runtime/druntime/src/__importc_builtins.di | 2 +- runtime/druntime/src/object.d | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/druntime/src/__importc_builtins.di b/runtime/druntime/src/__importc_builtins.di index 0ec7534a6b..9f3a3933bb 100644 --- a/runtime/druntime/src/__importc_builtins.di +++ b/runtime/druntime/src/__importc_builtins.di @@ -53,7 +53,7 @@ version (LDC) version (ARM) public import core.stdc.stdarg : __va_list; else version (AArch64) - public import core.internal.vararg.aarch64 : __va_list; + public import core.internal.vararg.aapcs64 : __va_list; } } else version (Posix) diff --git a/runtime/druntime/src/object.d b/runtime/druntime/src/object.d index d59eb0739c..568d45875f 100644 --- a/runtime/druntime/src/object.d +++ b/runtime/druntime/src/object.d @@ -102,7 +102,7 @@ version (LDC) // note: there's a copy for importC in __importc_builtins.di version (ARM) public import core.stdc.stdarg : __va_list; else version (AArch64) - public import core.internal.vararg.aarch64 : __va_list; + public import core.internal.vararg.aapcs64 : __va_list; } } From 71245a5d3215a75eacb2103a457a7579e96e4b66 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Wed, 8 Apr 2026 17:30:30 +0200 Subject: [PATCH 429/440] DMD headers: Fix signature of dmd::isVirtual() --- dmd/declaration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmd/declaration.h b/dmd/declaration.h index e4030d8c92..1170f9ff91 100644 --- a/dmd/declaration.h +++ b/dmd/declaration.h @@ -45,7 +45,7 @@ namespace dmd bool equals(const Dsymbol * const ds, const Dsymbol * const s); bool hasNestedFrameRefs(FuncDeclaration *fd); bool isVirtualMethod(FuncDeclaration *fd); - bool isVirtual(const FuncDeclaration *fd); + bool isVirtual(const FuncDeclaration * const fd); } //enum STC : ulong from astenums.d: From 17ebc174162716618d6c15f72cfab08f13723582 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Wed, 8 Apr 2026 17:22:29 +0200 Subject: [PATCH 430/440] C++ headers: Remove removed Scope::search() member function That function was converted to a free-standing function in v2.113. --- dmd/scope.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/dmd/scope.h b/dmd/scope.h index 94eeee803d..4ca980a2c1 100644 --- a/dmd/scope.h +++ b/dmd/scope.h @@ -138,6 +138,4 @@ struct Scope final AliasDeclaration *aliasAsg; // if set, then aliasAsg is being assigned a new value, // do not set wasRead for it StructDeclaration *argStruct; // elimiate recursion when looking for rvalue construction - - Dsymbol *search(Loc loc, Identifier *ident, Dsymbol *&pscopesym, SearchOptFlags flags = (SearchOptFlags)SearchOpt::all); }; From 833163127b2d595858353dd9318548f54d1d4bbc Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Wed, 8 Apr 2026 17:29:38 +0200 Subject: [PATCH 431/440] C++ headers: Fix signature of dmd::isVirtual() --- dmd/declaration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmd/declaration.h b/dmd/declaration.h index 759e533543..1fa3ebd776 100644 --- a/dmd/declaration.h +++ b/dmd/declaration.h @@ -45,7 +45,7 @@ namespace dmd bool equals(const Dsymbol * const ds, const Dsymbol * const s); bool hasNestedFrameRefs(FuncDeclaration *fd); bool isVirtualMethod(FuncDeclaration *fd); - bool isVirtual(const FuncDeclaration *fd); + bool isVirtual(const FuncDeclaration * const fd); } //enum STC : ulong from astenums.d: From bc89cd779d8d9729e794738744682146f36e0ee8 Mon Sep 17 00:00:00 2001 From: Gaofei Qiu <96871163+gulugulubing@users.noreply.github.com> Date: Wed, 8 Apr 2026 18:07:59 -0600 Subject: [PATCH 432/440] Fix issue 22887 - ICE with ForwardRef*[$] array (dlang/dmd!22891) --- dmd/dsymbolsem.d | 40 +++++++++++++++- tests/dmd/fail_compilation/staticarray.d | 61 ++++++++++++++++++++++-- 2 files changed, 96 insertions(+), 5 deletions(-) diff --git a/dmd/dsymbolsem.d b/dmd/dsymbolsem.d index 16709bc113..daa3bab6b8 100644 --- a/dmd/dsymbolsem.d +++ b/dmd/dsymbolsem.d @@ -2389,6 +2389,24 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor return true; } + static bool shouldTryDeepSArrayDimInference(Expression ie, Scope* sc) + { + if (!ie) + return false; + + // `new` expressions cannot provide a compile-time static extent + // for inferring `$`, and may recurse through incomplete aggregates. + if (ie.isNewExp()) + return false; + + // Field initializers are especially prone to recursive semantic + // evaluation against incompletely defined aggregates. + if (sc && sc.parent && sc.parent.isAggregateDeclaration()) + return false; + + return true; + } + auto tsa = dsym.type.isTypeSArray(); if (tsa && hasDollarDimension(tsa)) @@ -2397,19 +2415,37 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor { .error(dsym.loc, "cannot infer static array length from `$`, provide an initializer"); tsa.dim = new IntegerExp(dsym.loc, 0, Type.tsize_t); + dsym._init = new ErrorInitializer(); + dsym.type = Type.terror; + dsym.errors = true; + dsym.semanticRun = PASS.semanticdone; + return; } else { Expression ie = dsym._init.initializerToExpression(null, sc.inCfile); if (ie && ie.op != EXP.error) { - ie = ie.expressionSemantic(sc); - ie = ie.optimize(WANTvalue); + // Infer from literal syntax first to avoid prematurely + // semantic-analyzing expressions that may depend on + // incomplete types (e.g. recursive initializers). + // https://github.com/dlang/dmd/issues/22887 bool dimInferred = inferSArrayDim(tsa, ie, dsym.loc, sc); + if (!dimInferred && shouldTryDeepSArrayDimInference(ie, sc)) + { + ie = ie.expressionSemantic(sc); + ie = ie.optimize(WANTvalue); + dimInferred = inferSArrayDim(tsa, ie, dsym.loc, sc); + } if (!dimInferred) { .error(dsym.loc, "cannot infer static array length from `$`, provide an initializer"); tsa.dim = new IntegerExp(dsym.loc, 0, Type.tsize_t); + dsym._init = new ErrorInitializer(); + dsym.type = Type.terror; + dsym.errors = true; + dsym.semanticRun = PASS.semanticdone; + return; } if (auto ale = ie.isArrayLiteralExp()) dsym._init = new ExpInitializer(dsym.loc, ale); diff --git a/tests/dmd/fail_compilation/staticarray.d b/tests/dmd/fail_compilation/staticarray.d index 87b16ef360..768c64f728 100644 --- a/tests/dmd/fail_compilation/staticarray.d +++ b/tests/dmd/fail_compilation/staticarray.d @@ -1,12 +1,67 @@ /* TEST_OUTPUT: --- -fail_compilation/staticarray.d(10): Error: cannot infer static array length from `$`, provide an initializer -fail_compilation/staticarray.d(11): Error: cannot infer static array length from `$`, provide an initializer -fail_compilation/staticarray.d(12): Error: cannot infer static array length from `$`, provide an initializer +fail_compilation/staticarray.d(24): Error: cannot infer static array length from `$`, provide an initializer +fail_compilation/staticarray.d(25): Error: cannot infer static array length from `$`, provide an initializer +fail_compilation/staticarray.d(26): Error: cannot infer static array length from `$`, provide an initializer +fail_compilation/staticarray.d(29): Error: cannot infer static array length from `$`, provide an initializer +fail_compilation/staticarray.d(27): Error: struct `staticarray.ForwardRef1` circular or forward reference +fail_compilation/staticarray.d(38): Error: cannot infer static array length from `$`, provide an initializer +fail_compilation/staticarray.d(36): Error: struct `staticarray.ForwardRef3` circular or forward reference +fail_compilation/staticarray.d(43): Error: cannot infer static array length from `$`, provide an initializer +fail_compilation/staticarray.d(41): Error: struct `staticarray.ForwardRef4` circular or forward reference +fail_compilation/staticarray.d(50): Error: cannot infer static array length from `$`, provide an initializer +fail_compilation/staticarray.d(47): Error: struct `staticarray.ForwardRef5` circular or forward reference +fail_compilation/staticarray.d(55): Error: cannot infer static array length from `$`, provide an initializer +fail_compilation/staticarray.d(53): Error: struct `staticarray.ForwardRef6` circular or forward reference +fail_compilation/staticarray.d(60): Error: cannot infer static array length from `$`, provide an initializer +fail_compilation/staticarray.d(58): Error: struct `staticarray.ForwardRef7` circular or forward reference +fail_compilation/staticarray.d(66): Error: struct `staticarray.ForwardRef8` cannot have field `arr` with static array of same struct type +fail_compilation/staticarray.d(33): Error: variable `staticarray.ForwardRef2.arr` recursive initialization of field --- */ int[$] arr1; int[$] arr2 = void; int[$][1] arr3 = 1; +struct ForwardRef1 +{ + ForwardRef1[$] arr = new ForwardRef1(); +} +struct ForwardRef2 +{ + ForwardRef2*[$] arr = [new ForwardRef2()]; +} + +struct ForwardRef3 +{ + ForwardRef3[$] arr = ForwardRef3.init; +} + +struct ForwardRef4 +{ + ForwardRef4[$] arr = make(); + static ForwardRef4 make() { return ForwardRef4.init; } +} + +struct ForwardRef5 +{ + enum bool flag = true; + ForwardRef5[$] arr = flag ? ForwardRef5.init : ForwardRef5.init; +} + +struct ForwardRef6 +{ + ForwardRef6[$] arr = (0, ForwardRef6.init); +} + +struct ForwardRef7 +{ + ForwardRef7[$] arr = make(); + static ForwardRef7[] make() { return [ForwardRef7.init]; } +} + +struct ForwardRef8 +{ + ForwardRef8[$][$] arr = [[ForwardRef8.init]]; +} From 2167a0bb801aaeaafcd41b29825503a7a5a0bb3c Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Thu, 9 Apr 2026 16:10:46 +0200 Subject: [PATCH 433/440] Adapt to new ConstructExp::lowering field --- gen/toir.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gen/toir.cpp b/gen/toir.cpp index 7e3b691b83..5658791a32 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -479,6 +479,13 @@ class ToElemVisitor : public Visitor { e->e2->type ? e->e2->type->toChars() : nullptr); LOG_SCOPE; + if (auto ce = e->isConstructExp()) { + if (ce->lowering) { + result = toElem(ce->lowering); + return; + } + } + // Initialization of ref variable? // Can't just override ConstructExp::toElem because not all EXP::construct // operations are actually instances of ConstructExp... Long live the DMD From dd2241ddbc936bcd766264948b7f8e5e9928e9c3 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Thu, 9 Apr 2026 16:18:11 +0200 Subject: [PATCH 434/440] Add newly required import for lit-test plugins/visitor_example.d --- tests/plugins/visitor_example.d | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/plugins/visitor_example.d b/tests/plugins/visitor_example.d index 022d5485a8..0d5a4f7392 100644 --- a/tests/plugins/visitor_example.d +++ b/tests/plugins/visitor_example.d @@ -12,6 +12,7 @@ import dmd.location; import dmd.visitor; import dmd.declaration; import dmd.dsymbol; +import dmd.typesem; extern(C++) class MyVisitor : SemanticTimeTransitiveVisitor { alias visit = SemanticTimeTransitiveVisitor.visit; From 65df186e7929f89264c1ab68bfca8578ed6cdd5e Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Thu, 9 Apr 2026 17:37:48 +0200 Subject: [PATCH 435/440] druntime: Add Emscripten support in core.sys.posix.signal (dlang/dmd!22901) Based on https://github.com/emscripten-core/emscripten/blob/main/system/lib/libc/musl/arch/emscripten/bits/signal.h. --- runtime/druntime/src/core/sys/posix/signal.d | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/runtime/druntime/src/core/sys/posix/signal.d b/runtime/druntime/src/core/sys/posix/signal.d index 94ddd0403d..ffa88f48f1 100644 --- a/runtime/druntime/src/core/sys/posix/signal.d +++ b/runtime/druntime/src/core/sys/posix/signal.d @@ -414,6 +414,30 @@ version (linux) enum SIGUSR2 = 12; enum SIGURG = 23; } + else version (Emscripten) + { + //SIGABRT (defined in core.stdc.signal) + enum SIGALRM = 14; + enum SIGBUS = 7; + enum SIGCHLD = 17; + enum SIGCONT = 18; + //SIGFPE (defined in core.stdc.signal) + enum SIGHUP = 1; + //SIGILL (defined in core.stdc.signal) + //SIGINT (defined in core.stdc.signal) + enum SIGKILL = 9; + enum SIGPIPE = 13; + enum SIGQUIT = 3; + //SIGSEGV (defined in core.stdc.signal) + enum SIGSTOP = 19; + //SIGTERM (defined in core.stdc.signal) + enum SIGTSTP = 20; + enum SIGTTIN = 21; + enum SIGTTOU = 22; + enum SIGUSR1 = 10; + enum SIGUSR2 = 12; + enum SIGURG = 23; + } else static assert(0, "unimplemented"); } @@ -1784,6 +1808,16 @@ version (linux) enum SIGXCPU = 24; enum SIGXFSZ = 25; } + else version (Emscripten) + { + enum SIGPOLL = 29; + enum SIGPROF = 27; + enum SIGSYS = 31; + enum SIGTRAP = 5; + enum SIGVTALRM = 26; + enum SIGXCPU = 24; + enum SIGXFSZ = 25; + } else static assert(0, "unimplemented"); @@ -2768,6 +2802,11 @@ else version (CRuntime_Musl) enum MINSIGSTKSZ = 2048; enum SIGSTKSZ = 8192; } + else version (Emscripten) + { + enum MINSIGSTKSZ = 2048; + enum SIGSTKSZ = 8192; + } else static assert(0, "unimplemented"); From d6dccb3820f64763926ca576d9967eb401dd8a9c Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 10 Apr 2026 02:10:19 +0200 Subject: [PATCH 436/440] ldmd2: Support -check=nullderef=off --- driver/ldmd.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/driver/ldmd.cpp b/driver/ldmd.cpp index a5642be4c0..44594e09e5 100644 --- a/driver/ldmd.cpp +++ b/driver/ldmd.cpp @@ -434,7 +434,7 @@ void translateArgs(const llvm::SmallVectorImpl &ldmdArgs, */ else if (startsWith(p + 1, "check=")) { // Parse: - // -check=[assert|bounds|in|invariant|out|switch][=[on|off]] + // -check=[assert|bounds|in|invariant|out|switch|nullderef][=[on|off]] const char *arg = p + 7; if (strcmp(arg, "on") == 0) { ldcArgs.push_back("-boundscheck=on"); @@ -478,6 +478,10 @@ void translateArgs(const llvm::SmallVectorImpl &ldmdArgs, if (kindLength == 6 && memcmp(arg, "bounds", 6) == 0) { ldcArgs.push_back(enabled ? "-boundscheck=on" : "-boundscheck=off"); + } else if (kindLength == 9 && memcmp(arg, "nullderef", 9) == 0) { + // TODO: implement? + if (enabled) + goto Lnot_in_ldc; } else if (!(check(6, "assert", "asserts") || check(2, "in", "preconditions") || check(9, "invariant", "invariants") || From 67b27566c4d3ac13234d13ffb4ebc0d91760e2be Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 10 Apr 2026 19:20:25 +0200 Subject: [PATCH 437/440] Adapt lit-test codegen/in_place_construct.d to __result var changes in NRVO functions In the presence of an NRVO variable, `__result` is newly a *ref* variable. --- tests/codegen/in_place_construct.d | 47 ++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/tests/codegen/in_place_construct.d b/tests/codegen/in_place_construct.d index 610c1341cc..d334105ec2 100644 --- a/tests/codegen/in_place_construct.d +++ b/tests/codegen/in_place_construct.d @@ -36,25 +36,53 @@ S returnRValue() S returnNRVO() { // make sure NRVO zero-initializes the sret pointee directly - // CHECK: call void @llvm.memset.{{.*}}(ptr{{.*}}, i8 0, + // CHECK: call void @llvm.memset.{{.*}}(ptr{{.*}} %.sret_arg, i8 0, const S r; return r; } -// CHECK-LABEL: define{{.*}} @{{.*}}_D18in_place_construct15withOutContractFZSQBo1S -S withOutContract() +// CHECK-LABEL: define{{.*}} @{{.*}}_D18in_place_construct19RVO_withOutContractFZSQBs1S +S RVO_withOutContract() +out { assert(__result.c == 3); } +do +{ + // make sure the literal is emitted directly into the sret pointee + // CHECK-NEXT: %1 = getelementptr inbounds {{.*}}%in_place_construct.S, ptr %.sret_arg, i32 0, i32 0 + // CHECK-NEXT: store i64 1, ptr %1 + // CHECK-NEXT: %2 = getelementptr inbounds {{.*}}%in_place_construct.S, ptr %.sret_arg, i32 0, i32 1 + // CHECK-NEXT: store i64 2, ptr %2 + // CHECK-NEXT: %3 = getelementptr inbounds {{.*}}%in_place_construct.S, ptr %.sret_arg, i32 0, i32 2 + // CHECK-NEXT: store i64 3, ptr %3 + // CHECK-NEXT: %4 = getelementptr inbounds {{.*}}%in_place_construct.S, ptr %.sret_arg, i32 0, i32 3 + // CHECK-NEXT: store i64 4, ptr %4 + return S(1, 2, 3, 4); + + // make sure `__result` inside the out contract is just an alias to the sret pointee + // CHECK: %5 = getelementptr inbounds {{.*}}%in_place_construct.S, ptr %.sret_arg, i32 0, i32 2 + // CHECK-NEXT: %6 = load {{.*}}ptr %5 + // CHECK-NEXT: icmp eq i64 %6, 3 +} + +// CHECK-LABEL: define{{.*}} @{{.*}}_D18in_place_construct20NRVO_withOutContractFZSQBt1S +S NRVO_withOutContract() out { assert(__result.a == 0); } do { + // __result is a ref + // CHECK-NEXT: %result = alloca ptr + // make sure NRVO zero-initializes the sret pointee directly - // CHECK: call void @llvm.memset.{{.*}}(ptr{{.*}}, i8 0, + // CHECK-NEXT: call void @llvm.memset.{{.*}}(ptr{{.*}} %.sret_arg, i8 0, const S r; return r; - // make sure `__result` inside the out contract is just an alias to the sret pointee - // CHECK: %{{1|2}} = getelementptr inbounds {{.*}}%in_place_construct.S, ptr %.sret_arg, i32 0, i32 0 - // CHECK: %{{2|3}} = load {{.*}}ptr %{{1|2}} - // CHECK: %{{3|4}} = icmp eq i64 %{{2|3}}, 0 + // make sure the __result ref is initialized with the sret pointer + // CHECK-NEXT: store ptr %.sret_arg, ptr %result + + // CHECK: %1 = load ptr, ptr %result + // CHECK-NEXT: %2 = getelementptr inbounds {{.*}}%in_place_construct.S, ptr %1, i32 0, i32 0 + // CHECK-NEXT: %3 = load {{.*}}ptr %2 + // CHECK-NEXT: icmp eq i64 %3, 0 } // CHECK-LABEL: define{{.*}} @{{.*}}_D18in_place_construct7structsFZv @@ -87,7 +115,8 @@ void structs() // CHECK-SAME: ptr{{.*}} %c const c = returnNRVO(); - withOutContract(); + RVO_withOutContract(); + NRVO_withOutContract(); } // CHECK-LABEL: define{{.*}} @{{.*}}_D18in_place_construct12staticArraysFZv From 7d40b9b21fd8b612a5990a069865a276cb19f356 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 10 Apr 2026 19:29:58 +0200 Subject: [PATCH 438/440] Add missing new TimeTraceEventType enum member in C++ header --- dmd/timetrace.h | 1 + 1 file changed, 1 insertion(+) diff --git a/dmd/timetrace.h b/dmd/timetrace.h index 4ef991be14..decc591a9c 100644 --- a/dmd/timetrace.h +++ b/dmd/timetrace.h @@ -29,6 +29,7 @@ enum class TimeTraceEventType sema1Function, sema2, sema3, + dfa, ctfe, ctfeCall, codegenGlobal, From 23cc0d00689ba6a549ae2b90f39e8b961c0b79db Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sat, 11 Apr 2026 16:36:50 +0200 Subject: [PATCH 439/440] dmd-testsuite: Disable compilable/test22381.d for LDC (DMD codegen test) --- tests/dmd/compilable/test22381.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dmd/compilable/test22381.d b/tests/dmd/compilable/test22381.d index 6554f98f14..517f8ab6de 100644 --- a/tests/dmd/compilable/test22381.d +++ b/tests/dmd/compilable/test22381.d @@ -1,5 +1,5 @@ /* -DISABLED: osx +DISABLED: osx LDC REQUIRED_ARGS: -vasm TEST_OUTPUT: --- From 08e74d50ba8d45646aafeb0f1145e3ffd09e20c4 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sat, 11 Apr 2026 16:37:55 +0200 Subject: [PATCH 440/440] dmd-testsuite: Minimally adapt fail_compilation/diag9191.d for LDC --- tests/dmd/fail_compilation/diag9191.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dmd/fail_compilation/diag9191.d b/tests/dmd/fail_compilation/diag9191.d index 64279815c0..7bb129d594 100644 --- a/tests/dmd/fail_compilation/diag9191.d +++ b/tests/dmd/fail_compilation/diag9191.d @@ -7,7 +7,7 @@ fail_compilation/diag9191.d(25): Error: function `diag9191.C2.aaa` does not over fail_compilation/diag9191.d(36): Error: function `void diag9191.C3.foo()` does not override any function fail_compilation/diag9191.d(31): did you mean to override `void diag9191.B2._foo()`? fail_compilation/diag9191.d(41): Error: function `void diag9191.C4.toStringa()` does not override any function -$p:druntime/import/object.d$($n$): did you mean to override `string object.Object.toString()`? +$p:/object.d$($n$): did you mean to override `string object.Object.toString()`? --- */