]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Merge dmd, druntime d8e3976a58, phobos 7a6e95688
authorIain Buclaw <ibuclaw@gdcproject.org>
Wed, 17 Jan 2024 22:49:05 +0000 (23:49 +0100)
committerIain Buclaw <ibuclaw@gdcproject.org>
Fri, 2 Feb 2024 23:16:55 +0000 (00:16 +0100)
D front-end changes:

    - Import dmd v2.107.0-beta.1.
    - A string literal as an assert condition is deprecated.
    - Added `@standalone` for module constructors.

D runtime changes:

    - Import druntime v2.107.0-beta.1.

Phobos changes:

    - Import phobos v2.107.0-beta.1.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd d8e3976a58.
* dmd/VERSION: Bump version to v2.107.0-beta.1.
* d-lang.cc (d_parse_file): Update for new front-end interface.
* modules.cc (struct module_info): Add standalonectors.
(build_module_tree): Implement @standalone.
(register_module_decl): Likewise.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime d8e3976a58.
* src/MERGE: Merge upstream phobos 7a6e95688.

196 files changed:
gcc/d/d-lang.cc
gcc/d/dmd/MERGE
gcc/d/dmd/VERSION
gcc/d/dmd/access.d
gcc/d/dmd/aggregate.d
gcc/d/dmd/aggregate.h
gcc/d/dmd/aliasthis.d
gcc/d/dmd/aliasthis.h
gcc/d/dmd/arrayop.d
gcc/d/dmd/arraytypes.d
gcc/d/dmd/arraytypes.h
gcc/d/dmd/ast_node.d
gcc/d/dmd/ast_node.h
gcc/d/dmd/astenums.d
gcc/d/dmd/attrib.d
gcc/d/dmd/attrib.h
gcc/d/dmd/blockexit.d
gcc/d/dmd/builtin.d
gcc/d/dmd/canthrow.d
gcc/d/dmd/chkformat.d
gcc/d/dmd/clone.d
gcc/d/dmd/common/bitfields.d
gcc/d/dmd/common/file.d
gcc/d/dmd/common/outbuffer.d
gcc/d/dmd/common/outbuffer.h
gcc/d/dmd/common/smallbuffer.d
gcc/d/dmd/compiler.d
gcc/d/dmd/compiler.h
gcc/d/dmd/cond.d
gcc/d/dmd/cond.h
gcc/d/dmd/constfold.d
gcc/d/dmd/cparse.d
gcc/d/dmd/cppmangle.d
gcc/d/dmd/ctfe.h
gcc/d/dmd/ctfeexpr.d
gcc/d/dmd/ctorflow.d
gcc/d/dmd/dcast.d
gcc/d/dmd/dclass.d
gcc/d/dmd/declaration.d
gcc/d/dmd/declaration.h
gcc/d/dmd/delegatize.d
gcc/d/dmd/denum.d
gcc/d/dmd/dimport.d
gcc/d/dmd/dinterpret.d
gcc/d/dmd/dmacro.d
gcc/d/dmd/dmangle.d
gcc/d/dmd/dmodule.d
gcc/d/dmd/doc.d
gcc/d/dmd/doc.h
gcc/d/dmd/dscope.d
gcc/d/dmd/dstruct.d
gcc/d/dmd/dsymbol.d
gcc/d/dmd/dsymbol.h
gcc/d/dmd/dsymbolsem.d
gcc/d/dmd/dtemplate.d
gcc/d/dmd/dtoh.d
gcc/d/dmd/dversion.d
gcc/d/dmd/entity.d
gcc/d/dmd/enum.h
gcc/d/dmd/errors.d
gcc/d/dmd/errors.h
gcc/d/dmd/errorsink.d
gcc/d/dmd/escape.d
gcc/d/dmd/expression.d
gcc/d/dmd/expression.h
gcc/d/dmd/expressionsem.d
gcc/d/dmd/file_manager.d
gcc/d/dmd/foreachvar.d
gcc/d/dmd/func.d
gcc/d/dmd/globals.d
gcc/d/dmd/globals.h
gcc/d/dmd/gluelayer.d
gcc/d/dmd/hdrgen.d
gcc/d/dmd/hdrgen.h
gcc/d/dmd/iasm.d
gcc/d/dmd/iasmgcc.d
gcc/d/dmd/id.d
gcc/d/dmd/id.h
gcc/d/dmd/identifier.d
gcc/d/dmd/identifier.h
gcc/d/dmd/impcnvtab.d
gcc/d/dmd/imphint.d
gcc/d/dmd/import.h
gcc/d/dmd/importc.d
gcc/d/dmd/init.d
gcc/d/dmd/init.h
gcc/d/dmd/initsem.d
gcc/d/dmd/inline.d
gcc/d/dmd/intrange.d
gcc/d/dmd/json.d
gcc/d/dmd/json.h
gcc/d/dmd/lambdacomp.d
gcc/d/dmd/lexer.d
gcc/d/dmd/location.d
gcc/d/dmd/mangle.h
gcc/d/dmd/module.h
gcc/d/dmd/mtype.d
gcc/d/dmd/mtype.h
gcc/d/dmd/mustuse.d
gcc/d/dmd/nogc.d
gcc/d/dmd/nspace.d
gcc/d/dmd/nspace.h
gcc/d/dmd/ob.d
gcc/d/dmd/objc.d
gcc/d/dmd/objc.h
gcc/d/dmd/opover.d
gcc/d/dmd/optimize.d
gcc/d/dmd/parse.d
gcc/d/dmd/postordervisitor.d
gcc/d/dmd/printast.d
gcc/d/dmd/root/aav.d
gcc/d/dmd/root/array.d
gcc/d/dmd/root/array.h
gcc/d/dmd/root/bitarray.d
gcc/d/dmd/root/bitarray.h
gcc/d/dmd/root/complex.d
gcc/d/dmd/root/complex_t.h
gcc/d/dmd/root/ctfloat.d
gcc/d/dmd/root/ctfloat.h
gcc/d/dmd/root/dcompat.h
gcc/d/dmd/root/file.d
gcc/d/dmd/root/filename.d
gcc/d/dmd/root/filename.h
gcc/d/dmd/root/hash.d
gcc/d/dmd/root/object.h
gcc/d/dmd/root/optional.d
gcc/d/dmd/root/optional.h
gcc/d/dmd/root/port.d
gcc/d/dmd/root/port.h
gcc/d/dmd/root/region.d
gcc/d/dmd/root/rmem.d
gcc/d/dmd/root/rmem.h
gcc/d/dmd/root/speller.d
gcc/d/dmd/root/string.d
gcc/d/dmd/root/stringtable.d
gcc/d/dmd/root/utf.d
gcc/d/dmd/rootobject.d
gcc/d/dmd/safe.d
gcc/d/dmd/sapply.d
gcc/d/dmd/scope.h
gcc/d/dmd/semantic2.d
gcc/d/dmd/semantic3.d
gcc/d/dmd/sideeffect.d
gcc/d/dmd/statement.d
gcc/d/dmd/statement.h
gcc/d/dmd/statement_rewrite_walker.d
gcc/d/dmd/statementsem.d
gcc/d/dmd/staticassert.d
gcc/d/dmd/staticassert.h
gcc/d/dmd/staticcond.d
gcc/d/dmd/stmtstate.d
gcc/d/dmd/target.d
gcc/d/dmd/target.h
gcc/d/dmd/template.h
gcc/d/dmd/templateparamsem.d
gcc/d/dmd/tokens.d
gcc/d/dmd/tokens.h
gcc/d/dmd/traits.d
gcc/d/dmd/typesem.d
gcc/d/dmd/typinf.d
gcc/d/dmd/typinf.h
gcc/d/dmd/utils.d
gcc/d/dmd/version.h
gcc/d/dmd/visitor.d
gcc/d/dmd/visitor.h
gcc/d/modules.cc
gcc/testsuite/gdc.test/compilable/issue20339.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/array_bool.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/diag11425.d
gcc/testsuite/gdc.test/fail_compilation/diagin.d
gcc/testsuite/gdc.test/fail_compilation/fail110.d
gcc/testsuite/gdc.test/fail_compilation/fail19890a.d
gcc/testsuite/gdc.test/fail_compilation/fail19890b.d
gcc/testsuite/gdc.test/fail_compilation/fail2195.d
gcc/testsuite/gdc.test/fail_compilation/fail24301.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/fail4611.d
gcc/testsuite/gdc.test/fail_compilation/fail93.d
gcc/testsuite/gdc.test/fail_compilation/standalone_modctor.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/staticarrayoverflow.d
gcc/testsuite/gdc.test/runnable/imports/standalone_b.d [new file with mode: 0644]
gcc/testsuite/gdc.test/runnable/standalone_modctor.d [new file with mode: 0644]
gcc/testsuite/gdc.test/runnable_cxx/extra-files/test24292.cpp [new file with mode: 0644]
gcc/testsuite/gdc.test/runnable_cxx/test24292.d [new file with mode: 0644]
libphobos/libdruntime/MERGE
libphobos/libdruntime/__builtins.di
libphobos/libdruntime/core/attribute.d
libphobos/libdruntime/core/math.d
libphobos/libdruntime/core/stdcpp/new_.d
libphobos/libdruntime/core/sys/posix/net/if_.d
libphobos/libdruntime/rt/sections.d
libphobos/src/MERGE
libphobos/src/std/conv.d
libphobos/src/std/datetime/package.d
libphobos/src/std/datetime/systime.d
libphobos/src/std/math/algebraic.d
libphobos/src/std/net/curl.d

index a25d0316da68f1609d8671b37274651615f1da45..71f8473e0ecc6e24bf852b01dfbce7881222bb4e 100644 (file)
@@ -1209,7 +1209,7 @@ d_parse_file (void)
            message ("import    %s", m->toChars ());
 
          OutBuffer buf;
-         genhdrfile (m, buf);
+         genhdrfile (m, global.params.dihdr.fullOutput, buf);
          d_write_file (m->hdrfile.toChars (), buf.peekChars ());
        }
 
@@ -1373,7 +1373,7 @@ d_parse_file (void)
          OutBuffer buf;
          buf.doindent = 1;
 
-         moduleToBuffer (buf, m);
+         moduleToBuffer (buf, true, m);
          message ("%s", buf.peekChars ());
        }
     }
index fa7004b7a412591e51219a717b7c9a9ca3306596..2b4400f398ed26c0c30473e30e1b01158b542293 100644 (file)
@@ -1,4 +1,4 @@
-f1a045928e03239b9477f9497f43f2cf0e61e959
+d8e3976a58d6aef7c2c9371028a2ca4460b5b2ce
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
index 9d7be5b43263b897a6d990b028d92d019d4d59f0..b9813c7ff3b0fc01651424d0c57164fe31cba2d9 100644 (file)
@@ -1 +1 @@
-v2.106.1-rc.1
+v2.107.0-beta.1
index 1010c140b68ecbfde5a194dafdfd03e6c1e642f0..8d022030173300d71c4d4919b2fe33360c6d9af3 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/attribute.html#visibility_attributes, Visibility Attributes)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/access.d, _access.d)
index 352ca88f470db84d9652fcfda658ecab517be8c5..2d320426c23bfe7a663dd2b375d2c551b83f06ec 100644 (file)
@@ -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-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/aggregate.d, _aggregate.d)
@@ -65,7 +65,7 @@ enum ClassKind : ubyte
  * Returns:
  *     0-terminated string for `c`
  */
-const(char)* toChars(ClassKind c) @safe
+const(char)* ClassKindToChars(ClassKind c) @safe
 {
     final switch (c)
     {
index 98fa6bd1bb00e46c431bc4dad054048d43da42d8..9abdd094b3f21561565ce931043caaa5a40f3c03 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index 0c156360fdc2f4374efbc4d18d73f7c6bbf8ccf6..0e063caa2fcde165181fa89a887b8060ae88b3a5 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/class.html#alias-this, Alias This)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/aliasthis.d, _aliasthis.d)
index 092490fd5ded2ead3ddeff672a296346253144d1..88ba35319b3ebe684546e915d4d38d79babea865 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 2009-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 2009-2024 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.
index c3b8526a9a43b4df1f2196ebb7d361fa92bcb167..afe6054f4aaa4fad320b7892dfaefe056366859d 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/arrays.html#array-operations, Array Operations)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/arrayop.d, _arrayop.d)
index 6634a6af1fc0e2ea04a309444ae1ebc5dba6f73c..feab9a49c7c5f0b180c8261da95d444abb794065 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Provide aliases for arrays of certain declarations or statements.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/arraytypes.d, _arraytypes.d)
index 05126a53d7ee9173f0427716fe11e3c9f2b008c8..779642813f56ca5fc15f029540821e8881a85a3b 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 2006-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 2006-2024 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.
index 313c2bd36912dc799c7a50ad2c64c2019b30c961..c8c95fa0782cc24cd2309c6f85773b680ed390a8 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Defines the base class for all nodes which are part of the AST.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/ast_node.d, _ast_node.d)
index 6154c6d1b3afacc77b8083a07734297b137a8269..a24218a86d02d60c4288d5610327f339e9e53ec6 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index 6a9c0104a7270e3a8fb53e5c3e35106000276983..f19edb9e4b48bb5d323dd1293b24cd949752366c 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Defines enums common to dmd and dmd as parse library.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/astenums.d, _astenums.d)
  * Documentation:  https://dlang.org/phobos/dmd_astenums.html
@@ -63,7 +63,7 @@ enum STC : ulong  // transfer changes to declaration.h
     foreach_            = 0x4000,   /// variable for foreach loop
     variadic            = 0x8000,   /// the `variadic` parameter in: T foo(T a, U b, V variadic...)
 
-    //                  = 0x1_0000,
+    constscoperef       = 0x1_0000,   /// when `in` means const|scope|ref
     templateparameter   = 0x2_0000,   /// template parameter
     ref_                = 0x4_0000,   /// `ref`
     scope_              = 0x8_0000,   /// `scope`
@@ -112,7 +112,7 @@ enum STC : ulong  // transfer changes to declaration.h
     volatile_           = 0x40_0000_0000_0000,   /// destined for volatile in the back end
 
     safeGroup = STC.safe | STC.trusted | STC.system,
-    IOR  = STC.in_ | STC.ref_ | STC.out_,
+    IOR  = STC.constscoperef | STC.in_ | STC.ref_ | STC.out_,
     TYPECTOR = (STC.const_ | STC.immutable_ | STC.shared_ | STC.wild),
     FUNCATTR = (STC.ref_ | STC.nothrow_ | STC.nogc | STC.pure_ | STC.property | STC.live |
                 safeGroup),
index cc6ef9c431b9177911c968160d2561c5be205416..d7d3eca6f8da0859ccdfe020d2f91bd3eecf0551 100644 (file)
@@ -14,7 +14,7 @@
  * - Protection (`private`, `public`)
  * - Deprecated declarations (`@deprecated`)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/attrib.d, _attrib.d)
@@ -137,7 +137,7 @@ extern (C++) abstract class AttribDeclaration : Dsymbol
         return "attribute";
     }
 
-    override bool oneMember(Dsymbol* ps, Identifier ident)
+    override bool oneMember(out Dsymbol ps, Identifier ident)
     {
         Dsymbols* d = include(null);
         return Dsymbol.oneMembers(d, ps, ident);
@@ -225,10 +225,10 @@ extern (C++) class StorageClassDeclaration : AttribDeclaration
             sc.visibility, sc.explicitVisibility, sc.aligndecl, sc.inlining);
     }
 
-    override final bool oneMember(Dsymbol* ps, Identifier ident)
+    override final bool oneMember(out Dsymbol ps, Identifier ident)
     {
         bool t = Dsymbol.oneMembers(decl, ps, ident);
-        if (t && *ps)
+        if (t && ps)
         {
             /* This is to deal with the following case:
              * struct Tick {
@@ -238,7 +238,7 @@ extern (C++) class StorageClassDeclaration : AttribDeclaration
              * before the semantic analysis of 'to', so that template overloading based on the
              * 'this' pointer can be successful.
              */
-            FuncDeclaration fd = (*ps).isFuncDeclaration();
+            FuncDeclaration fd = ps.isFuncDeclaration();
             if (fd)
             {
                 /* Use storage_class2 instead of storage_class otherwise when we do .di generation
@@ -743,7 +743,7 @@ extern (C++) class ConditionalDeclaration : AttribDeclaration
         return new ConditionalDeclaration(loc, condition.syntaxCopy(), Dsymbol.arraySyntaxCopy(decl), Dsymbol.arraySyntaxCopy(elsedecl));
     }
 
-    override final bool oneMember(Dsymbol* ps, Identifier ident)
+    override final bool oneMember(out Dsymbol ps, Identifier ident)
     {
         //printf("ConditionalDeclaration::oneMember(), inc = %d\n", condition.inc);
         if (condition.inc != Include.notComputed)
@@ -753,8 +753,8 @@ extern (C++) class ConditionalDeclaration : AttribDeclaration
         }
         else
         {
-            bool res = (Dsymbol.oneMembers(decl, ps, ident) && *ps is null && Dsymbol.oneMembers(elsedecl, ps, ident) && *ps is null);
-            *ps = null;
+            bool res = (Dsymbol.oneMembers(decl, ps, ident) && ps is null && Dsymbol.oneMembers(elsedecl, ps, ident) && ps is null);
+            ps = null;
             return res;
         }
     }
@@ -901,7 +901,7 @@ extern (C++) final class StaticForeachDeclaration : AttribDeclaration
             Dsymbol.arraySyntaxCopy(decl));
     }
 
-    override bool oneMember(Dsymbol* ps, Identifier ident)
+    override bool oneMember(out Dsymbol ps, Identifier ident)
     {
         // Required to support IFTI on a template that contains a
         // `static foreach` declaration.  `super.oneMember` calls
@@ -912,7 +912,7 @@ extern (C++) final class StaticForeachDeclaration : AttribDeclaration
         {
             return super.oneMember(ps, ident);
         }
-        *ps = null; // a `static foreach` declaration may in general expand to multiple symbols
+        ps = null; // a `static foreach` declaration may in general expand to multiple symbols
         return false;
     }
 
@@ -1296,3 +1296,27 @@ int foreachUdaNoSemantic(Dsymbol sym, int delegate(Expression) dg)
 
     return 0;
 }
+
+
+/**
+ * Returns: true if the given expression is an enum from `core.attribute` named `id`
+ */
+bool isEnumAttribute(Expression e, Identifier id)
+{
+    import dmd.attrib : isCoreUda;
+    import dmd.id : Id;
+
+    // Logic based on dmd.objc.Supported.declaredAsOptionalCount
+    auto typeExp = e.isTypeExp;
+    if (!typeExp)
+        return false;
+
+    auto typeEnum = typeExp.type.isTypeEnum();
+    if (!typeEnum)
+        return false;
+
+    if (isCoreUda(typeEnum.sym, id))
+        return true;
+
+    return false;
+}
index 35628e261055a678266831468adca03378c9ec82..344a7e929a7b65ede7f0e27d0ad82b3c466d8088 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
@@ -28,7 +28,7 @@ public:
     virtual Scope *newScope(Scope *sc);
     void addComment(const utf8_t *comment) override;
     const char *kind() const override;
-    bool oneMember(Dsymbol **ps, Identifier *ident) override;
+    bool oneMember(Dsymbol *&ps, Identifier *ident) override;
     bool hasPointers() override final;
     bool hasStaticCtorOrDtor() override final;
     void checkCtorConstInit() override final;
@@ -44,7 +44,7 @@ public:
 
     StorageClassDeclaration *syntaxCopy(Dsymbol *s) override;
     Scope *newScope(Scope *sc) override;
-    bool oneMember(Dsymbol **ps, Identifier *ident) override final;
+    bool oneMember(Dsymbol *&ps, Identifier *ident) override final;
     StorageClassDeclaration *isStorageClassDeclaration() override { return this; }
 
     void accept(Visitor *v) override { v->visit(this); }
@@ -153,7 +153,7 @@ public:
     Dsymbols *elsedecl; // array of Dsymbol's for else block
 
     ConditionalDeclaration *syntaxCopy(Dsymbol *s) override;
-    bool oneMember(Dsymbol **ps, Identifier *ident) override final;
+    bool oneMember(Dsymbol *&ps, Identifier *ident) override final;
     Dsymbols *include(Scope *sc) override;
     void addComment(const utf8_t *comment) override final;
     void accept(Visitor *v) override { v->visit(this); }
@@ -183,7 +183,7 @@ public:
     Dsymbols *cache;
 
     StaticForeachDeclaration *syntaxCopy(Dsymbol *s) override;
-    bool oneMember(Dsymbol **ps, Identifier *ident) override;
+    bool oneMember(Dsymbol *&ps, Identifier *ident) override;
     Dsymbols *include(Scope *sc) override;
     void addComment(const utf8_t *comment) override;
     const char *kind() const override;
index 5108ecf7ba7fd3932456599ade3da250428289e8..d77af7e1c5c4d5b175031cd03b70a3176458c333 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Find out in what ways control flow can exit a statement block.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/blockexit.d, _blockexit.d)
index 27ba1e03454f4a706c76ae6b5ad12e1ff57f611b..d29092b6903efe9d7b2eebd915e4fd249dc7aa03 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Currently includes functions from `std.math`, `core.math` and `core.bitop`.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/builtin.d, _builtin.d)
index 5a608a9986d9c8abe32bfd2b1f1fa071aa4458b1..31155f188dca62efde2b74009efa8154e21a499a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/function.html#nothrow-functions, Nothrow Functions)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/canthrow.d, _canthrow.d)
index 8cfad5916c7820a166515bcb555621aae932f318..5024f9bb210038245eca36bd416a63e8f5fe2cd9 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Check the arguments to `printf` and `scanf` against the `format` string.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/chkformat.d, _chkformat.d)
index ca7f398ae7aea735e044e2c9512ac3b7948f8476..6fbf8e284deb47ed671ee7d3c4478a7421ecce10 100644 (file)
@@ -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-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/clone.d, _clone.d)
@@ -1571,7 +1571,7 @@ private Statement generateCopyCtorBody(StructDeclaration sd)
  *  `true` if one needs to be generated
  *  `false` otherwise
  */
-private bool needCopyCtor(StructDeclaration sd, out bool hasCpCtor)
+bool needCopyCtor(StructDeclaration sd, out bool hasCpCtor)
 {
     if (global.errors)
         return false;
index b9fcb0995c91448f8edb67bc6a3ebc4be0cd3209..01aa56d1809e663dd12adc5df133d54ecd04596f 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * A library bitfields utility
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/common/bitfields.d, common/bitfields.d)
index 704110f50bd6fb6726fa16c93f19dcd1f4329f54..8a284241fc2e1b25bb8d9e767c468fa2e516e65e 100644 (file)
@@ -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-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/common/file.d, common/_file.d)
index 4e7a82fb565a34ba6c89a6f880e2dda0d160a234..cff08ec5d435670996bc0dbd8a0f76a5039dcf88 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * An expandable buffer in which you can write text or binary data.
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/root/outbuffer.d, root/_outbuffer.d)
index 4c1dceea3f6a770e0599f7bb741c8fe96f0ba428..2250497c38f5d7d24c90f7543d4aae3d8e504a9f 100644 (file)
@@ -1,5 +1,5 @@
 
-/* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 1999-2024 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.
index ec0eaae647f871981ae0db813756e607d813188e..c6aa7abbc6041e99a3a3307d9c416b54ff84c7e1 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Common string functions including filename manipulation.
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/common/smallbuffer.d, common/_smallbuffer.d)
@@ -48,7 +48,7 @@ struct SmallBuffer(Element)
         }
         else
         {
-            assert(len < sizeof.max / (2 * Element.sizeof));
+            assert(len < size_t.max / (2 * Element.sizeof));
             _extent = (cast(typeof(_extent.ptr)) malloc(len * Element.sizeof))[0 .. len];
             _extent.ptr || assert(0, "Out of memory.");
             needsFree = true;
@@ -76,7 +76,7 @@ struct SmallBuffer(Element)
         else
         {
             __dtor();
-            assert(len < sizeof.max / Element.sizeof);
+            assert(len < size_t.max / Element.sizeof);
             _extent = (cast(typeof(_extent.ptr)) malloc(len * Element.sizeof))[0 .. len];
             _extent.ptr || assert(0, "Out of memory.");
             needsFree = true;
index 8b8a453d45e6709a8a2cc0770ba503a058bb84cb..65330cf5d11fe75e0565e259fc5b65c1b0489165 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Describes a back-end compiler and implements compiler-specific actions.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/compiler.d, _compiler.d)
index c7cbce3bd7f5bbfbee60ec29635ca6d987033916..74351edb4498db407e7054cd01711d7a6a09295f 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index 568b639e0b67fdc07423fa0196ba8a4ffb3110a4..1b32ff774c87248dcb6c52a00c47bceb455ceb2c 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/version.html, Conditional Compilation)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/cond.d, _cond.d)
index d02ae1321c5e40be7c7820bd9585bac3a72bbbd3..fe497c2da7e14ddea7235d69aa9c8f7e6137de9b 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index fc3fd3b248600ef06f1c90ae8a9cbd129d6fcc03..7bd9691a4297ebe143b9b627fcccb1f070183a22 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/float.html#fp_const_folding, Floating Point Constant Folding)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/constfold.d, _constfold.d)
index 4c0b96a4c8cfc1a6b9d99100bf3548f07cc9fceb..e0cdc87b7fd2140fa4d1154946ff2919542924cc 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: C11
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/cparse.d, _cparse.d)
@@ -605,15 +605,23 @@ final class CParser(AST) : Parser!AST
         {
             Identifier ident;
             nextToken();
-            if (token.value != TOK.identifier)
+            if (token.value == TOK.identifier)
             {
-                error("identifier expected following `goto`");
+                ident = token.ident;
+                nextToken();
+            }
+            else if (token.value == TOK.mul)
+            {
+                /* https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
+                 */
+                error("`goto *` computed goto extension is not supported");
                 ident = null;
+                cparseUnaryExp();   // parse and throw away
             }
             else
             {
-                ident = token.ident;
-                nextToken();
+                error("identifier expected following `goto`");
+                ident = null;
             }
             s = new AST.GotoStatement(loc, ident);
             check(TOK.semicolon, "`goto` statement");
@@ -1056,6 +1064,14 @@ final class CParser(AST) : Parser!AST
             break;
         }
 
+        case TOK.andAnd:
+            /* https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
+             */
+            error("unary `&&` computed goto extension is not supported");
+            nextToken();
+            e = cparseCastExp();
+            break;
+
         case TOK._Alignof:
         {
             nextToken();
@@ -1931,20 +1947,18 @@ final class CParser(AST) : Parser!AST
                 }
                 else if (auto tt = dt.isTypeTag())
                 {
-                    if (tt.id || tt.tok == TOK.enum_)
-                    {
-                        if (!tt.id && id)
-                            /* This applies for enums declared as
-                             * typedef enum {A} E;
-                             */
-                            tt.id = id;
-                        Specifier spec;
-                        declareTag(tt, spec);
-                    }
+                    if (!tt.id && id)
+                        /* This applies for enums declared as
+                         * typedef enum {A} E;
+                         */
+                        tt.id = id;
+                    Specifier spec;
+                    declareTag(tt, spec);
                     idt = tt.id;
                 }
                 if (isalias)
                 {
+                    //printf("AliasDeclaration %s %s\n", id.toChars(), dt.toChars());
                     auto ad = new AST.AliasDeclaration(token.loc, id, dt);
                     if (id == idt)
                         ad.adFlags |= ad.hidden; // do not print when generating .di files
index 55844ddf606e35f5482f0b7a2e144a7acc6fa708..90b6295ab2fd77673b2e8bedda7006d0fe9fb847 100644 (file)
@@ -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-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/cppmangle.d, _cppmangle.d)
index bb92778e25346e49ba9be4945b9e609dc63d5cf1..72d895c715096a64f3b6c5fd4dbc8fc26a2e28d9 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index 993bab023f9d497dd01cc7fc84a8b5241077bd6f..5fe1e7dccb01043b0263ff245898928c154beccd 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * CTFE for expressions involving pointers, slices, array concatenation etc.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/ctfeexpr.d, _ctfeexpr.d)
index 128c698ab87a1f980dbf2919736355771593d8ba..ba5240e5e101f8c07a9bb538126cdcc5e19e72d7 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Manage flow analysis for constructors.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/ctorflow.d, _ctorflow.d)
index cfa374c970bd8d05bbf0ac0cd82415fdcb4de8be..628c688979f37ae0b0c38e32be75efd77d737719 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Semantic analysis for cast-expressions.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/dcast.d, _dcast.d)
index e066d877e8aaaa0271ec7493c4ad370c71d94fe9..405e8170b2c825819a6c6f468e0c24deda270cbf 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/class.html, Classes)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/dclass.d, _dclass.d)
index bdc91f4f1f23567970da94c1a3773f563c2076eb..5869a2208426482bf868737a2526c06a908f4893 100644 (file)
@@ -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-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/declaration.d, _declaration.d)
@@ -246,8 +246,6 @@ extern (C++) abstract class Declaration : Dsymbol
       enum nounderscore = 4; // don't prepend _ to mangled name
       enum hidden       = 8; // don't print this in .di files
 
-    Symbol* isym;           // import version of csym
-
     // overridden symbol with pragma(mangle, "...")
     const(char)[] mangleOverride;
 
index adbc26bf5702e192f38267e20eb17823ef17c942..0e327bedfbd23415c97e990e008ed6d83de02cfb 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
@@ -54,7 +54,7 @@ struct AttributeViolation;
     #define STCforeach            0x4000ULL    /// variable for foreach loop
     #define STCvariadic           0x8000ULL    /// the `variadic` parameter in: T foo(T a, U b, V variadic...)
 
-    //                            0x10000ULL
+    #define STCconstscoperef      0x10000ULL    /// when `in` means const|scope|ref
     #define STCtemplateparameter  0x20000ULL    /// template parameter
     #define STCref                0x40000ULL    /// `ref`
     #define STCscope              0x80000ULL    /// `scope`
@@ -118,7 +118,6 @@ public:
     LINK _linkage;              // may be `LINK::system`; use `resolvedLinkage()` to resolve it
     short inuse;                // used to detect cycles
     uint8_t adFlags;
-    Symbol* isym;               // import version of csym
     DString mangleOverride;     // overridden symbol with pragma(mangle, "...")
 
     const char *kind() const override;
@@ -843,6 +842,7 @@ public:
 class SharedStaticCtorDeclaration final : public StaticCtorDeclaration
 {
 public:
+    bool standalone;
     SharedStaticCtorDeclaration *syntaxCopy(Dsymbol *) override;
 
     SharedStaticCtorDeclaration *isSharedStaticCtorDeclaration() override { return this; }
index 490ef56646f01a604af041a34327d48d2726eecb..62800d3fdb77541374ac659dff473b5227453bd3 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/function.html#lazy-params, Lazy Parameters)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/delegatize.d, _delegatize.d)
index 5713be1e99e77ce972a063cbc8ef566ca8bfd972..5464ff99f58ce2945be1ce55cc0911145550dc70 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/enum.html, Enums)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/denum.d, _denum.d)
@@ -83,7 +83,7 @@ extern (C++) final class EnumDeclaration : ScopeDsymbol
         return ed;
     }
 
-    override bool oneMember(Dsymbol* ps, Identifier ident)
+    override bool oneMember(out Dsymbol ps, Identifier ident)
     {
         if (isAnonymous())
             return Dsymbol.oneMembers(members, ps, ident);
index 51b9220c18562c5e78946308e82d17924ca2760d..b083c03aebeeee3504b7cef03990c9bb57ccfef9 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * A `Dsymbol` representing a renamed import.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/dimport.d, _dimport.d)
index 90352e32beaf5b6c88aa233e8c1d54ae6335889e..eda91d1ea0580545e0516fe0bd85ce65132b5e63 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: ($LINK2 https://dlang.org/spec/function.html#interpretation, Compile Time Function Execution (CTFE))
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/dinterpret.d, _dinterpret.d)
index 6e6c4b17e99115a50793ea3d7b71353aae6741f2..c04fbec731d350538837b1a868573ad42b7ae742 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Text macro processor for Ddoc.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/dmacro.d, _dmacro.d)
index 2bedccb71c1375cb0cc0d22863b0c7035db6de2c..15b77eaac4c8a4918d02794a88e59e9bf065a65f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/abi.html#name_mangling, Name Mangling)
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/dmangle.d, _dmangle.d)
@@ -528,7 +528,7 @@ void mangleParameter(Parameter p, ref OutBuffer buf, ref Backref backref)
     if (stc & STC.return_)
         buf.writestring("Nk"); // return
 
-    switch (stc & (STC.IOR | STC.lazy_))
+    switch (stc & ((STC.IOR | STC.lazy_) & ~STC.constscoperef))
     {
     case 0:
         break;
index 6c9e90a2c8fc2e3b4a7fc69c37cacf3e31fa1574..022231c1254acd2dc1614114307da870e6b2b56f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/module.html, Modules)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/dmodule.d, _dmodule.d)
index 03848c0274ba92d0d1c219d786635568bc1dc8c5..810642f9f52ffcaf204d02a2a11b5e84110175f9 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/ddoc.html, Documentation Generator)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/doc.d, _doc.d)
@@ -1296,7 +1296,7 @@ void toDocBuffer(Dsymbol s, ref OutBuffer buf, Scope* sc)
                 Type origType = d.originalType ? d.originalType : d.type;
                 if (origType.ty == Tfunction)
                 {
-                    functionToBufferFull(cast(TypeFunction)origType, *buf, d.ident, &hgs, td);
+                    functionToBufferFull(cast(TypeFunction)origType, *buf, d.ident, hgs, td);
                 }
                 else
                     toCBuffer(origType, *buf, d.ident, hgs);
index ebd3094348d99d7ea6e9318094633c27428edf86..71a66b90cb8ef4e5483ef70009f8f2df302efc30 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index cd177a66f50564d9f3acf92e48cc2843946fc28b..7e9499fd28f92715802f6be0e5d34417b4917a7a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Not to be confused with the `scope` storage class.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/dscope.d, _dscope.d)
index 0e0a1f52f88e75e336909f4d89d542b0565e1497..5683d5fb1d575572e643219e46d3949608b6c0ce 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/struct.html, Structs, Unions)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/dstruct.d, _dstruct.d)
@@ -434,7 +434,11 @@ extern (C++) class StructDeclaration : AggregateDeclaration
 
         ispod = ThreeState.yes;
 
-        if (enclosing || postblit || dtor || hasCopyCtor)
+        import dmd.clone;
+        bool hasCpCtorLocal;
+        needCopyCtor(this, hasCpCtorLocal);
+
+        if (enclosing || search(this, loc, Id.postblit) || search(this, loc, Id.dtor) || hasCpCtorLocal)
         {
             ispod = ThreeState.no;
             return false;
index 6613c2bc5c2f39a142a027d09fe2c95580d4a3b3..5e7922ea11dac1a852ea66cde69b241a5d2a581a 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * The base class for a D symbol, which can be a module, variable, function, enum, etc.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/dsymbol.d, _dsymbol.d)
@@ -845,27 +845,27 @@ extern (C++) class Dsymbol : ASTNode
     /**************************************
      * Determine if this symbol is only one.
      * Returns:
-     *      false, *ps = NULL: There are 2 or more symbols
-     *      true,  *ps = NULL: There are zero symbols
-     *      true,  *ps = symbol: The one and only one symbol
+     *      false, ps = null: There are 2 or more symbols
+     *      true,  ps = null: There are zero symbols
+     *      true,  ps = symbol: The one and only one symbol
      */
-    bool oneMember(Dsymbol* ps, Identifier ident)
+    bool oneMember(out Dsymbol ps, Identifier ident)
     {
         //printf("Dsymbol::oneMember()\n");
-        *ps = this;
+        ps = this;
         return true;
     }
 
     /*****************************************
      * Same as Dsymbol::oneMember(), but look at an array of Dsymbols.
      */
-    extern (D) static bool oneMembers(Dsymbols* members, Dsymbol* ps, Identifier ident)
+    extern (D) static bool oneMembers(Dsymbols* members, out Dsymbol ps, Identifier ident)
     {
         //printf("Dsymbol::oneMembers() %d\n", members ? members.length : 0);
         Dsymbol s = null;
         if (!members)
         {
-            *ps = null;
+            ps = null;
             return true;
         }
 
@@ -877,21 +877,21 @@ extern (C++) class Dsymbol : ASTNode
             if (!x)
             {
                 //printf("\tfalse 1\n");
-                assert(*ps is null);
+                assert(ps is null);
                 return false;
             }
-            if (*ps)
+            if (ps)
             {
                 assert(ident);
-                if (!(*ps).ident || !(*ps).ident.equals(ident))
+                if (!ps.ident || !ps.ident.equals(ident))
                     continue;
                 if (!s)
-                    s = *ps;
-                else if (s.isOverloadable() && (*ps).isOverloadable())
+                    s = ps;
+                else if (s.isOverloadable() && ps.isOverloadable())
                 {
                     // keep head of overload set
                     FuncDeclaration f1 = s.isFuncDeclaration();
-                    FuncDeclaration f2 = (*ps).isFuncDeclaration();
+                    FuncDeclaration f2 = ps.isFuncDeclaration();
                     if (f1 && f2)
                     {
                         assert(!f1.isFuncAliasDeclaration());
@@ -908,13 +908,13 @@ extern (C++) class Dsymbol : ASTNode
                 }
                 else // more than one symbol
                 {
-                    *ps = null;
+                    ps = null;
                     //printf("\tfalse 2\n");
                     return false;
                 }
             }
         }
-        *ps = s; // s is the one symbol, null if none
+        ps = s; // s is the one symbol, null if none
         //printf("\ttrue\n");
         return true;
     }
index d029c00fc1ca7dd8be4ba82591de35cb01b40736..7d715b47b310c9491deda637f68cb5b263ce5fa2 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
@@ -246,7 +246,7 @@ public:
     virtual bool needThis();                    // need a 'this' pointer?
     virtual Visibility visible();
     virtual Dsymbol *syntaxCopy(Dsymbol *s);    // copy only syntax trees
-    virtual bool oneMember(Dsymbol **ps, Identifier *ident);
+    virtual bool oneMember(Dsymbol *&ps, Identifier *ident);
     virtual bool hasPointers();
     virtual bool hasStaticCtorOrDtor();
     virtual void addObjcSymbols(ClassDeclarations *, ClassDeclarations *) { }
index df0a9a536f49972a94340dc5f0ab0b7494b15064..23f0bc5b4280ac6f758b2c881ccffef88a5c4be5 100644 (file)
@@ -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-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/dsymbolsem.d, _dsymbolsem.d)
@@ -947,7 +947,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
 
         // At this point we can add `scope` to the STC instead of `in`,
         // because we are never going to use this variable's STC for user messages
-        if (dsym.storage_class & STC.in_ && global.params.previewIn)
+        if (dsym.storage_class & STC.constscoperef)
             dsym.storage_class |= STC.scope_;
 
         if (dsym.storage_class & STC.scope_)
@@ -2964,7 +2964,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         if (tempdecl.members)
         {
             Dsymbol s;
-            if (Dsymbol.oneMembers(tempdecl.members, &s, tempdecl.ident) && s)
+            if (Dsymbol.oneMembers(tempdecl.members, s, tempdecl.ident) && s)
             {
                 tempdecl.onemember = s;
                 s.parent = tempdecl;
@@ -4096,7 +4096,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
 
                     auto fd = s.isFuncDeclaration();
                     functionToBufferFull(cast(TypeFunction)(funcdecl.type), buf,
-                        new Identifier(funcdecl.toPrettyChars()), &hgs, null);
+                        new Identifier(funcdecl.toPrettyChars()), hgs, null);
                     const(char)* funcdeclToChars = buf.peekChars();
 
                     if (fd)
@@ -4119,7 +4119,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
                         else
                         {
                             functionToBufferFull(cast(TypeFunction)(fd.type), buf1,
-                                new Identifier(fd.toPrettyChars()), &hgs, null);
+                                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());
@@ -4592,6 +4592,24 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
             m.needmoduleinfo = 1;
             //printf("module1 %s needs moduleinfo\n", m.toChars());
         }
+
+        foreachUda(scd, sc, (Expression e) {
+            import dmd.attrib : isEnumAttribute;
+            if (!isEnumAttribute(e, Id.udaStandalone))
+                return 0;
+
+            if (auto sharedCtor = scd.isSharedStaticCtorDeclaration())
+            {
+                auto trust = sharedCtor.type.isTypeFunction().trust;
+                if (trust != TRUST.system && trust != TRUST.trusted)
+                    error(e.loc, "a module constructor using `@%s` must be `@system` or `@trusted`", Id.udaStandalone.toChars());
+                sharedCtor.standalone = true;
+            }
+            else
+                .error(e.loc, "`@%s` can only be used on shared static constructors", Id.udaStandalone.toChars());
+
+            return 1;
+        });
     }
 
     override void visit(StaticDtorDeclaration sdd)
@@ -4831,9 +4849,15 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         {
             if (ts.sym != sd)
             {
-                auto ti = ts.sym.isInstantiated();
+                TemplateInstance ti = ts.sym.isInstantiated();
                 if (ti && isError(ti))
                     ts.sym = sd;
+                /* For C modules, if module A contains `struct S;` and
+                 * module B contains `struct S { members...}` then replace
+                 * the former with the latter
+                 */
+                else if (!ts.sym.members && sd.members)
+                    ts.sym = sd;
             }
         }
 
@@ -5357,7 +5381,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
                     cldec.classKind = ClassKind.cpp;
                 if (cldec.classKind != cldec.baseClass.classKind)
                     .error(cldec.loc, "%s `%s` with %s linkage cannot inherit from class `%s` with %s linkage", cldec.kind, cldec.toPrettyChars,
-                        cldec.classKind.toChars(), cldec.baseClass.toChars(), cldec.baseClass.classKind.toChars());
+                        ClassKindToChars(cldec.classKind), cldec.baseClass.toChars(), ClassKindToChars(cldec.baseClass.classKind));
 
                 if (cldec.baseClass.stack)
                     cldec.stack = true;
@@ -6807,7 +6831,7 @@ void templateInstanceSemantic(TemplateInstance tempinst, Scope* sc, ArgumentList
     if (tempinst.members.length)
     {
         Dsymbol s;
-        if (Dsymbol.oneMembers(tempinst.members, &s, tempdecl.ident) && s)
+        if (Dsymbol.oneMembers(tempinst.members, s, tempdecl.ident) && s)
         {
             //printf("tempdecl.ident = %s, s = `%s %s`\n", tempdecl.ident.toChars(), s.kind(), s.toPrettyChars());
             //printf("setting aliasdecl\n");
@@ -6852,7 +6876,7 @@ void templateInstanceSemantic(TemplateInstance tempinst, Scope* sc, ArgumentList
     if (tempinst.members.length)
     {
         Dsymbol s;
-        if (Dsymbol.oneMembers(tempinst.members, &s, tempdecl.ident) && s)
+        if (Dsymbol.oneMembers(tempinst.members, s, tempdecl.ident) && s)
         {
             if (!tempinst.aliasdecl || tempinst.aliasdecl != s)
             {
index e440b9e2eb659031ca9eb536fea30abdd2869529..1d84ccd029547e3ccd2f4f3a0674b550b23073d7 100644 (file)
@@ -28,7 +28,7 @@
  *   arguments, and uses it if found.
  * - Otherwise, the rest of semantic is run on the `TemplateInstance`.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/dtemplate.d, _dtemplate.d)
@@ -615,7 +615,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol
             return;
 
         Dsymbol s;
-        if (!Dsymbol.oneMembers(members, &s, ident) || !s)
+        if (!Dsymbol.oneMembers(members, s, ident) || !s)
             return;
 
         onemember = s;
@@ -6029,9 +6029,9 @@ extern (C++) class TemplateInstance : ScopeDsymbol
         return "template instance";
     }
 
-    override bool oneMember(Dsymbol* ps, Identifier ident)
+    override bool oneMember(out Dsymbol ps, Identifier ident)
     {
-        *ps = null;
+        ps = null;
         return true;
     }
 
@@ -7599,7 +7599,7 @@ extern (C++) class TemplateInstance : ScopeDsymbol
                 if (members.length)
                 {
                     Dsymbol sa;
-                    if (Dsymbol.oneMembers(members, &sa, tempdecl.ident) && sa)
+                    if (Dsymbol.oneMembers(members, sa, tempdecl.ident) && sa)
                         aliasdecl = sa;
                 }
                 done = true;
@@ -7820,7 +7820,7 @@ extern (C++) final class TemplateMixin : TemplateInstance
         return "mixin";
     }
 
-    override bool oneMember(Dsymbol* ps, Identifier ident)
+    override bool oneMember(out Dsymbol ps, Identifier ident)
     {
         return Dsymbol.oneMember(ps, ident);
     }
index ed83a8d9fe1f665c7cfb6970c5c385d2bc2050c0..30991c9171a0a1093a27bba5e6b3cb75a95ef043 100644 (file)
@@ -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-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/dtohd, _dtoh.d)
index 31725c80b9bb2c0c88edb4608fa9ae7de692ac4c..2e3b35264dbe2f4e0ddfd25d92c9d69f69ac164f 100644 (file)
@@ -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-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/dversion.d, _dversion.d)
index c31883f11d90fd5ee073367e0d216c3da73b39f0..af74c3bb8d5d6f86abe8c3f394c6f5ebbff9affe 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification $(LINK2 https://dlang.org/spec/entity.html, Named Character Entities)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/entity.d, _entity.d)
index 5f91ead9e174783c2a7431fa0b76423cf26ce39a..a4bb588cac63feed151ea14845a7af8ec8ba7142 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
@@ -46,7 +46,7 @@ public:
     bool inuse(bool v);
 
     EnumDeclaration *syntaxCopy(Dsymbol *s) override;
-    bool oneMember(Dsymbol **ps, Identifier *ident) override;
+    bool oneMember(Dsymbol *&ps, Identifier *ident) override;
     Type *getType() override;
     const char *kind() const override;
     bool isDeprecated() const override;       // is Dsymbol deprecated?
index 542b97b1ada835467a6e1cdf0f4b43079d4c18b8..79efc6e51aa45b77bfc84ea84f366aa0536095a0 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Functions for raising errors.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/errors.d, _errors.d)
index 759ad277fda927dcfd490a98f50ed2aeb28afe2d..308e81e30ba0f2074b7926cd74b67758e03c7ca2 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index 3811f1d29326675f83d60861f3446fe7e95efbc8..afea689546b110b801fb3137430f3e019485f2c7 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Provides an abstraction for what to do with error messages.
  *
- * Copyright:   Copyright (C) 2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 2023-2024 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/src/dmd/errorsink.d, _errorsink.d)
index f928b08503a0c81584bf2e2784692368c06f4171..433907a17be1a401ceecc4cb4a061a90b0aa3443 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Most of the logic to implement scoped pointers and scoped references is here.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/escape.d, _escape.d)
@@ -1296,7 +1296,7 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag)
     {
         if (log)
         {
-            printf("byref `%s` %s\n", v.toChars(), toChars(buildScopeRef(v.storage_class)));
+            printf("byref `%s` %s\n", v.toChars(), ScopeRefToChars(buildScopeRef(v.storage_class)));
         }
 
         // 'featureState' tells us whether to emit an error or a deprecation,
index f51a8b00891e819a89e0d35e9a9f64e097c37bc0..41eeff923d8ee01e4dfada4c9b1e71fef34525dc 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: ($LINK2 https://dlang.org/spec/expression.html, Expressions)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/expression.d, _expression.d)
@@ -420,10 +420,7 @@ extern (C++) abstract class Expression : ASTNode
 
     override const(char)* toChars() const
     {
-        OutBuffer buf;
-        HdrGenState hgs;
-        toCBuffer(this, buf, hgs);
-        return buf.extractChars();
+        return .toChars(this);
     }
 
     /**********************************
index b4ace74b4962aaf26c4344de83400ffe2afbc320..f57f6a402957fbf7a41f78175ec1bad756a6cab2 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
@@ -434,7 +434,7 @@ public:
 
     union
     {
-        Symbol *sym;                // back end symbol to initialize with literal
+        Symbol *sym;                // back end symbol to initialize with literal (used as a Symbol*)
 
         // those fields need to prevent a infinite recursion when one field of struct initialized with 'this' pointer.
         StructLiteralExp *inlinecopy;
index c21b382c71ec5cfd9b73266e906157d28a3678cc..9ce6f4ded9d7889812cb4d21cc61b71e971a9844 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: ($LINK2 https://dlang.org/spec/expression.html, Expressions)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/expressionsem.d, _expressionsem.d)
@@ -6813,11 +6813,14 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
                             {
                                 if (sc.func.fes)
                                 {
-                                    deprecation(e.loc, "%s `%s` is shadowing %s `%s`. Rename the `foreach` variable.", s.kind(), s.ident.toChars(), s2.kind(), s2.toPrettyChars());
+                                    deprecation(e.loc, "%s `%s` is shadowing %s `%s`", s.kind(), s.ident.toChars(), s2.kind(), s2.toPrettyChars());
+                                    deprecationSupplemental(s2.loc, "declared here");
+
                                 }
                                 else
                                 {
                                     error(e.loc, "%s `%s` is shadowing %s `%s`", s.kind(), s.ident.toChars(), s2.kind(), s2.toPrettyChars());
+                                    errorSupplemental(s2.loc, "declared here");
                                     return setError();
                                 }
                             }
@@ -7592,6 +7595,13 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
         {
             printf("AssertExp::semantic('%s')\n", exp.toChars());
         }
+        if (auto e = exp.e1.isStringExp())
+        {
+            // deprecated in 2.107
+            deprecation(e.loc, "assert condition cannot be a string literal");
+            deprecationSupplemental(e.loc, "If intentional, use `%s !is null` instead to preserve behaviour",
+                e.toChars());
+        }
 
         const generateMsg = !exp.msg &&
                             sc.needsCodegen() && // let ctfe interpreter handle the error message
@@ -15037,6 +15047,8 @@ bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false)
  */
 Expression resolveLoc(Expression exp, const ref Loc loc, Scope* sc)
 {
+    exp.loc = loc;
+
     Expression visit(Expression exp)
     {
         if (auto unaExp = exp.isUnaExp())
@@ -15044,7 +15056,6 @@ Expression resolveLoc(Expression exp, const ref Loc loc, Scope* sc)
             unaExp.e1 = unaExp.e1.resolveLoc(loc, sc);
             return unaExp;
         }
-        exp.loc = loc;
         return exp;
     }
 
index a0e5d0519c8ec3c3ac935b9d171b2a74ac13c9b8..eaef8d545e6312fc5a645531ebe70b235ac9d7b0 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Read a file from disk and store it in memory.
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/file_manager.d, _file_manager.d)
  * Documentation:  https://dlang.org/phobos/dmd_file_manager.html
@@ -10,6 +10,7 @@
 
 module dmd.file_manager;
 
+import core.stdc.stdio;
 import dmd.root.stringtable : StringTable;
 import dmd.root.file : File, Buffer;
 import dmd.root.filename : FileName, isDirSeparator;
@@ -281,63 +282,103 @@ nothrow:
         return fb;
     }
 
-    /**
-     * Looks up the given filename from the internal file buffer table, and returns the lines within the file.
-     * If the file does not already exist within the table, it will be read from the filesystem.
-     * If it has been read before,
-     *
-     * Returns: the loaded source file if it was found in memory,
-     *      otherwise `null`
+    /**********************************
+     * Take `text` and turn it into an InputRange that emits
+     * slices into `text` for each line.
+     * Params:
+     *  text = array of characters
+     * Returns:
+     *  InputRange accessing `text` as a sequence of lines
+     * Reference:
+     *  `std.string.splitLines()`
      */
-    const(char)[][] getLines(FileName file)
+    auto splitLines(const char[] text)
     {
-        const(char)[][] lines;
-        if (const buffer = lookup(file))
+        struct Range
         {
-            const slice = buffer;
-            size_t start, end;
-            for (auto i = 0; i < slice.length; i++)
+          @safe:
+          @nogc:
+          nothrow:
+          pure:
+          private:
+
+            const char[] text;
+            size_t index;       // index of start of line
+            size_t eolIndex;    // index of end of line before newline characters
+            size_t nextIndex;   // index past end of line
+
+            public this(const char[] text)
+            {
+                this.text = text;
+            }
+
+            public bool empty() { return index == text.length; }
+
+            public void popFront() { advance(); index = nextIndex; }
+
+            public const(char)[] front() { advance(); return text[index .. eolIndex]; }
+
+            private void advance()
             {
-                const c = slice[i];
-                if (c == '\n' || c == '\r')
+                if (index != nextIndex) // if already advanced
+                    return;
+
+                for (size_t i = index; i < text.length; ++i)
                 {
-                    if (i != 0)
-                    {
-                        end = i;
-                        // Appending lines one at a time will certainly be slow
-                        lines ~= cast(const(char)[])slice[start .. end];
-                    }
-                    // Check for Windows-style CRLF newlines
-                    if (c == '\r')
+                    switch (text[i])
                     {
-                        if (slice.length > i + 1 && slice[i + 1] == '\n')
-                        {
-                            // This is a CRLF sequence, skip over two characters
-                            start = i + 2;
-                            i++;
-                        }
-                        else
-                        {
-                            // Just a CR sequence
-                            start = i + 1;
-                        }
-                    }
-                    else
-                    {
-                        // The next line should start after the LF sequence
-                        start = i + 1;
+                        case '\v', '\f', '\n':
+                            eolIndex = i;
+                            nextIndex = i + 1;
+                            return;
+
+                        case '\r':
+                            if (i + 1 < text.length && text[i + 1] == '\n') // decode "\r\n"
+                            {
+                                eolIndex = i;
+                                nextIndex = i + 2;
+                                return;
+                            }
+                            eolIndex = i;
+                            nextIndex = i + 1;
+                            return;
+
+                        /* Manually decode:
+                         *  NEL is C2 85
+                         */
+                        case 0xC2:
+                            if (i + 1 < text.length && text[i + 1] == 0x85)
+                            {
+                                eolIndex = i;
+                                nextIndex = i + 2;
+                                return;
+                            }
+                            break;
+
+                        /* Manually decode:
+                         *  lineSep is E2 80 A8
+                         *  paraSep is E2 80 A9
+                         */
+                        case 0xE2:
+                            if (i + 2 < text.length &&
+                                text[i + 1] == 0x80 &&
+                                (text[i + 2] == 0xA8 || text[i + 2] == 0xA9)
+                               )
+                            {
+                                eolIndex = i;
+                                nextIndex = i + 3;
+                                return;
+                            }
+                            break;
+
+                        default:
+                            break;
                     }
                 }
             }
-
-            if (slice[$ - 1] != '\r' && slice[$ - 1] != '\n')
-            {
-                end = slice.length;
-                lines ~= cast(const(char)[])slice[start .. end];
-            }
         }
 
-        return lines;
+        return Range(text);
     }
 
     /**
index dc4b20bf957e377e9feabbb2023202fa19c4b2ff..53b3c041d1e844d23d516afe3a4b682ba34f1709 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Utility to visit every variable in an expression.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/foreachvar.d, _foreachvar.d)
index feaa5bb4d9123c139a0b0ec8138ec54e2d13a2cd..242b4dc99f9cefc3662e16cc96729a91586012ae 100644 (file)
@@ -8,7 +8,7 @@
  * - `invariant`
  * - `unittest`
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/func.d, _func.d)
@@ -4253,6 +4253,9 @@ extern (C++) class StaticCtorDeclaration : FuncDeclaration
  */
 extern (C++) final class SharedStaticCtorDeclaration : StaticCtorDeclaration
 {
+    /// Exclude this constructor from cyclic dependency check
+    bool standalone;
+
     extern (D) this(const ref Loc loc, const ref Loc endloc, StorageClass stc)
     {
         super(loc, endloc, "_sharedStaticCtor", stc);
index 9257bc464f4b0a89bf7fc24887d47aba573fc072..b60a3f8cad155e2356265566966c137f21f6b25a 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Stores command line options and contains other miscellaneous declarations.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/globals.d, _globals.d)
@@ -275,7 +275,7 @@ extern (C++) struct Global
 {
     const(char)[] inifilename; /// filename of configuration file as given by `-conf=`, or default value
 
-    string copyright = "Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved";
+    string copyright = "Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved";
     string written = "written by Walter Bright";
 
     Array!(const(char)*)* path;         /// Array of char*'s which form the import lookup path
index 4284f858466e6b98bea372d333039af166f4d134..c71d2f0499d0d0357b3f62b4114c5c0475403483 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index 756c0e523f917b02b6e6b614448e8984c3dc426c..b3980eb79306024b5aa1c7e5348a8fb85175d1a8 100644 (file)
@@ -3,7 +3,7 @@
  *
  * This 'glues' either the DMC or GCC back-end to the front-end.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/gluelayer.d, _gluelayer.d)
index 0944ade4c28785730857ce3e4966b0684b5d25a6..570c662624c7f0fe9e3e614d17216925a7ed6e86 100644 (file)
@@ -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-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/hdrgen.d, _hdrgen.d)
@@ -35,7 +35,6 @@ import dmd.dtemplate;
 import dmd.dversion;
 import dmd.expression;
 import dmd.func;
-import dmd.globals;
 import dmd.id;
 import dmd.identifier;
 import dmd.init;
@@ -50,7 +49,6 @@ import dmd.rootobject;
 import dmd.root.string;
 import dmd.statement;
 import dmd.staticassert;
-import dmd.target;
 import dmd.tokens;
 import dmd.visitor;
 
@@ -60,6 +58,8 @@ struct HdrGenState
     bool ddoc;          /// true if generating Ddoc file
     bool fullDump;      /// true if generating a full AST dump file
     bool importcHdr;    /// true if generating a .di file from an ImportC file
+    bool doFuncBodies;  /// include function bodies in output
+    bool vcg_ast;       /// write out codegen-ast
 
     bool fullQual;      /// fully qualify types when printing
     int tpltMember;
@@ -78,9 +78,10 @@ enum TEST_EMIT_ALL = 0;
  * Generate a header (.di) file for Module m.
  * Params:
  *      m = Module to generate header for
+ *      doFuncBodies = generate function definitions rather than just declarations
  *      buf = buffer to write the data to
  */
-extern (C++) void genhdrfile(Module m, ref OutBuffer buf)
+extern (C++) void genhdrfile(Module m, bool doFuncBodies, ref OutBuffer buf)
 {
     buf.doindent = 1;
     buf.printf("// D import file generated from '%s'", m.srcfile.toChars());
@@ -88,6 +89,7 @@ extern (C++) void genhdrfile(Module m, ref OutBuffer buf)
     HdrGenState hgs;
     hgs.hdrgen = true;
     hgs.importcHdr = (m.filetype == FileType.c);
+    hgs.doFuncBodies = doFuncBodies;
     toCBuffer(m, buf, hgs);
 }
 
@@ -108,6 +110,14 @@ public extern (C++) const(char)* toChars(const Statement s)
     return buf.extractSlice().ptr;
 }
 
+public extern (C++) const(char)* toChars(const Expression e)
+{
+    HdrGenState hgs;
+    OutBuffer buf;
+    toCBuffer(e, buf, hgs);
+    return buf.extractChars();
+}
+
 public extern (C++) const(char)* toChars(const Initializer i)
 {
     OutBuffer buf;
@@ -116,6 +126,17 @@ public extern (C++) const(char)* toChars(const Initializer i)
     return buf.extractChars();
 }
 
+public extern (C++) const(char)* toChars(const Type t)
+{
+    OutBuffer buf;
+    buf.reserve(16);
+    HdrGenState hgs;
+    hgs.fullQual = (t.ty == Tclass && !t.mod);
+
+    toCBuffer(t, buf, null, hgs);
+    return buf.extractChars();
+}
+
 public const(char)[] toString(const Initializer i)
 {
     OutBuffer buf;
@@ -128,16 +149,18 @@ public const(char)[] toString(const Initializer i)
  * Dumps the full contents of module `m` to `buf`.
  * Params:
  *   buf = buffer to write to.
+ *   vcg_ast = write out codegen ast
  *   m = module to visit all members of.
  */
-extern (C++) void moduleToBuffer(ref OutBuffer buf, Module m)
+extern (C++) void moduleToBuffer(ref OutBuffer buf, bool vcg_ast, Module m)
 {
     HdrGenState hgs;
     hgs.fullDump = true;
+    hgs.vcg_ast = vcg_ast;
     toCBuffer(m, buf, hgs);
 }
 
-void moduleToBuffer2(Module m, ref OutBuffer buf, HdrGenState* hgs)
+void moduleToBuffer2(Module m, ref OutBuffer buf, ref HdrGenState hgs)
 {
     if (m.md)
     {
@@ -171,7 +194,7 @@ void moduleToBuffer2(Module m, ref OutBuffer buf, HdrGenState* hgs)
     }
 }
 
-private void statementToBuffer(Statement s, ref OutBuffer buf, HdrGenState* hgs)
+private void statementToBuffer(Statement s, ref OutBuffer buf, ref HdrGenState hgs)
 {
     void visitDefaultCase(Statement s)
     {
@@ -240,7 +263,7 @@ private void statementToBuffer(Statement s, ref OutBuffer buf, HdrGenState* hgs)
                 auto d = ds.exp.isDeclarationExp().declaration;
                 if (auto v = d.isVarDeclaration())
                 {
-                    visitVarDecl(v, anywritten, buf, *hgs);
+                    visitVarDecl(v, anywritten, buf, hgs);
                 }
                 else
                     d.dsymbolToBuffer(buf, hgs);
@@ -803,7 +826,7 @@ private void statementToBuffer(Statement s, ref OutBuffer buf, HdrGenState* hgs)
         buf.level++;
         while (t)
         {
-            buf.writestring(t.toChars());
+            buf.writestring(t.toString());
             if (t.next &&
                 t.value != TOK.min      &&
                 t.value != TOK.comma    && t.next.value != TOK.comma    &&
@@ -844,9 +867,9 @@ private void statementToBuffer(Statement s, ref OutBuffer buf, HdrGenState* hgs)
     visit.VisitStatement(s);
 }
 
-private void dsymbolToBuffer(Dsymbol s, ref OutBuffer buf, HdrGenState* hgs)
+private void dsymbolToBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
 {
-    toCBuffer(s, buf, *hgs);
+    toCBuffer(s, buf, hgs);
 }
 
 void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
@@ -860,13 +883,13 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
     {
         buf.writestring(s.kind());
         buf.writeByte('(');
-        s.exp.expressionToBuffer(buf, &hgs);
+        s.exp.expressionToBuffer(buf, hgs);
         if (s.msgs)
         {
             foreach (m; (*s.msgs)[])
             {
                 buf.writestring(", ");
-                m.expressionToBuffer(buf, &hgs);
+                m.expressionToBuffer(buf, hgs);
             }
         }
         buf.writestring(");");
@@ -898,13 +921,13 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
     void visitEnumMember(EnumMember em)
     {
         if (em.type)
-            typeToBuffer(em.type, em.ident, buf, &hgs);
+            typeToBuffer(em.type, em.ident, buf, hgs);
         else
             buf.writestring(em.ident.toString());
         if (em.value)
         {
             buf.writestring(" = ");
-            em.value.expressionToBuffer(buf, &hgs);
+            em.value.expressionToBuffer(buf, hgs);
         }
     }
 
@@ -921,7 +944,8 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         }
         foreach (const pid; imp.packages)
         {
-            buf.printf("%s.", pid.toChars());
+            buf.write(pid.toString());
+            buf.writeByte('.');
         }
         buf.writestring(imp.id.toString());
         if (imp.names.length)
@@ -997,7 +1021,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
     void visitDeprecatedDeclaration(DeprecatedDeclaration d)
     {
         buf.writestring("deprecated(");
-        d.msg.expressionToBuffer(buf, &hgs);
+        d.msg.expressionToBuffer(buf, hgs);
         buf.writestring(") ");
         visitAttribDeclaration(d);
     }
@@ -1050,7 +1074,9 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
             {
                 if (i)
                     buf.writeByte(' ');
-                buf.printf("align (%s)", exp.toChars());
+                buf.writestring("align (");
+                toCBuffer(exp, buf, hgs);
+                buf.writeByte(')');
             }
             if (d.decl && d.decl.length < 2)
                 buf.writeByte(' ');
@@ -1085,7 +1111,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         if (d.args && d.args.length)
         {
             buf.writestring(", ");
-            argsToBuffer(d.args, buf, &hgs);
+            argsToBuffer(d.args, buf, hgs);
         }
 
         buf.writeByte(')');
@@ -1093,17 +1119,17 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         // https://issues.dlang.org/show_bug.cgi?id=14690
         // Unconditionally perform a full output dump
         // for `pragma(inline)` declarations.
-        bool savedFullDump = global.params.dihdr.fullOutput;
+        const saved = hgs.doFuncBodies;
         if (d.ident == Id.Pinline)
-            global.params.dihdr.fullOutput = true;
+            hgs.doFuncBodies = true;
 
         visitAttribDeclaration(d);
-        global.params.dihdr.fullOutput = savedFullDump;
+        hgs.doFuncBodies = saved;
     }
 
     void visitConditionalDeclaration(ConditionalDeclaration d)
     {
-        d.condition.conditionToBuffer(buf, &hgs);
+        d.condition.conditionToBuffer(buf, hgs);
         if (d.decl || d.elsedecl)
         {
             buf.writenl();
@@ -1149,12 +1175,12 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
                 if (stcToBuffer(buf, p.storageClass))
                     buf.writeByte(' ');
                 if (p.type)
-                    typeToBuffer(p.type, p.ident, buf, &hgs);
+                    typeToBuffer(p.type, p.ident, buf, hgs);
                 else
                     buf.writestring(p.ident.toString());
             }
             buf.writestring("; ");
-            s.aggr.expressionToBuffer(buf, &hgs);
+            s.aggr.expressionToBuffer(buf, hgs);
             buf.writeByte(')');
             buf.writenl();
         }
@@ -1166,13 +1192,13 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
             buf.writestring(Token.toString(s.op));
             buf.writestring(" (");
             if (s.prm.type)
-                typeToBuffer(s.prm.type, s.prm.ident, buf, &hgs);
+                typeToBuffer(s.prm.type, s.prm.ident, buf, hgs);
             else
                 buf.writestring(s.prm.ident.toString());
             buf.writestring("; ");
-            s.lwr.expressionToBuffer(buf, &hgs);
+            s.lwr.expressionToBuffer(buf, hgs);
             buf.writestring(" .. ");
-            s.upr.expressionToBuffer(buf, &hgs);
+            s.upr.expressionToBuffer(buf, hgs);
             buf.writeByte(')');
             buf.writenl();
         }
@@ -1200,7 +1226,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
     void visitMixinDeclaration(MixinDeclaration d)
     {
         buf.writestring("mixin(");
-        argsToBuffer(d.exps, buf, &hgs, null);
+        argsToBuffer(d.exps, buf, hgs, null);
         buf.writestring(");");
         buf.writenl();
     }
@@ -1208,7 +1234,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
     void visitUserAttributeDeclaration(UserAttributeDeclaration d)
     {
         buf.writestring("@(");
-        argsToBuffer(d.atts, buf, &hgs);
+        argsToBuffer(d.atts, buf, hgs);
         buf.writeByte(')');
         visitAttribDeclaration(d);
     }
@@ -1218,7 +1244,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         if (!constraint)
             return;
         buf.writestring(" if (");
-        constraint.expressionToBuffer(buf, &hgs);
+        constraint.expressionToBuffer(buf, hgs);
         buf.writeByte(')');
     }
 
@@ -1236,7 +1262,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
                 {
                     assert(es.exp && es.exp.op == EXP.assert_);
                     buf.writestring(" (");
-                    (cast(AssertExp)es.exp).e1.expressionToBuffer(buf, &hgs);
+                    (cast(AssertExp)es.exp).e1.expressionToBuffer(buf, hgs);
                     buf.writeByte(')');
                     buf.writenl();
                     requireDo = false;
@@ -1244,7 +1270,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
                 else
                 {
                     buf.writenl();
-                    frequire.statementToBuffer(buf, &hgs);
+                    frequire.statementToBuffer(buf, hgs);
                     requireDo = true;
                 }
             }
@@ -1264,7 +1290,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
                         buf.writestring(fensure.id.toString());
                     }
                     buf.writestring("; ");
-                    (cast(AssertExp)es.exp).e1.expressionToBuffer(buf, &hgs);
+                    (cast(AssertExp)es.exp).e1.expressionToBuffer(buf, hgs);
                     buf.writeByte(')');
                     buf.writenl();
                     requireDo = false;
@@ -1278,7 +1304,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
                         buf.writeByte(')');
                     }
                     buf.writenl();
-                    fensure.ensure.statementToBuffer(buf, &hgs);
+                    fensure.ensure.statementToBuffer(buf, hgs);
                     requireDo = true;
                 }
             }
@@ -1288,7 +1314,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
 
     void bodyToBuffer(FuncDeclaration f)
     {
-        if (!f.fbody || (hgs.hdrgen && global.params.dihdr.fullOutput == false && !hgs.autoMember && !hgs.tpltMember && !hgs.insideFuncBody))
+        if (!f.fbody || (hgs.hdrgen && hgs.doFuncBodies == false && !hgs.autoMember && !hgs.tpltMember && !hgs.insideFuncBody))
         {
             if (!f.fbody && (f.fensures || f.frequires))
             {
@@ -1326,7 +1352,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         buf.writeByte('{');
         buf.writenl();
         buf.level++;
-        f.fbody.statementToBuffer(buf, &hgs);
+        f.fbody.statementToBuffer(buf, hgs);
         buf.level--;
         buf.writeByte('}');
         buf.writenl();
@@ -1344,7 +1370,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         {
             if (i)
                 buf.writestring(", ");
-            typeToBuffer(b.type, null, buf, &hgs);
+            typeToBuffer(b.type, null, buf, hgs);
         }
     }
 
@@ -1360,7 +1386,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
             assert(fd.type);
             if (stcToBuffer(buf, fd.storage_class))
                 buf.writeByte(' ');
-            functionToBufferFull(cast(TypeFunction)fd.type, buf, d.ident, &hgs, d);
+            functionToBufferFull(cast(TypeFunction)fd.type, buf, d.ident, hgs, d);
             visitTemplateConstraint(d.constraint);
             hgs.tpltMember++;
             bodyToBuffer(fd);
@@ -1402,7 +1428,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
             if (stcToBuffer(buf, vd.storage_class))
                 buf.writeByte(' ');
             if (vd.type)
-                typeToBuffer(vd.type, vd.ident, buf, &hgs);
+                typeToBuffer(vd.type, vd.ident, buf, hgs);
             else
                 buf.writestring(vd.ident.toString());
             buf.writeByte('(');
@@ -1413,9 +1439,9 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
                 buf.writestring(" = ");
                 ExpInitializer ie = vd._init.isExpInitializer();
                 if (ie && (ie.exp.op == EXP.construct || ie.exp.op == EXP.blit))
-                    (cast(AssignExp)ie.exp).e2.expressionToBuffer(buf, &hgs);
+                    (cast(AssignExp)ie.exp).e2.expressionToBuffer(buf, hgs);
                 else
-                    vd._init.initializerToBuffer(buf, &hgs);
+                    vd._init.initializerToBuffer(buf, hgs);
             }
             buf.writeByte(';');
             buf.writenl();
@@ -1463,21 +1489,21 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
     void visitTemplateInstance(TemplateInstance ti)
     {
         buf.writestring(ti.name.toChars());
-        tiargsToBuffer(ti, buf, &hgs);
+        tiargsToBuffer(ti, buf, hgs);
 
         if (hgs.fullDump)
         {
             buf.writenl();
-            dumpTemplateInstance(ti, buf, &hgs);
+            dumpTemplateInstance(ti, buf, hgs);
         }
     }
 
     void visitTemplateMixin(TemplateMixin tm)
     {
         buf.writestring("mixin ");
-        typeToBuffer(tm.tqual, null, buf, &hgs);
-        tiargsToBuffer(tm, buf, &hgs);
-        if (tm.ident && memcmp(tm.ident.toChars(), cast(const(char)*)"__mixin", 7) != 0)
+        typeToBuffer(tm.tqual, null, buf, hgs);
+        tiargsToBuffer(tm, buf, hgs);
+        if (tm.ident && memcmp(tm.ident.toString().ptr, cast(const(char)*) "__mixin", 7) != 0)
         {
             buf.writeByte(' ');
             buf.writestring(tm.ident.toString());
@@ -1485,7 +1511,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         buf.writeByte(';');
         buf.writenl();
         if (hgs.fullDump)
-            dumpTemplateInstance(tm, buf, &hgs);
+            dumpTemplateInstance(tm, buf, hgs);
     }
 
     void visitEnumDeclaration(EnumDeclaration d)
@@ -1501,7 +1527,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         if (d.memtype)
         {
             buf.writestring(" : ");
-            typeToBuffer(d.memtype, null, buf, &hgs);
+            typeToBuffer(d.memtype, null, buf, hgs);
         }
         if (!d.members)
         {
@@ -1649,7 +1675,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         {
             if (stcToBuffer(buf, d.storage_class))
                 buf.writeByte(' ');
-            typeToBuffer(d.type, d.ident, buf, &hgs);
+            typeToBuffer(d.type, d.ident, buf, hgs);
         }
         else if (d.ident)
         {
@@ -1658,7 +1684,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
             buf.writestring(" = ");
             if (stcToBuffer(buf, d.storage_class))
                 buf.writeByte(' ');
-            typeToBuffer(d.type, null, buf, &hgs);
+            typeToBuffer(d.type, null, buf, hgs);
             hgs.declstring = false;
         }
         buf.writeByte(';');
@@ -1672,7 +1698,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         if (d.aliassym)
             toCBuffer(d.aliassym, buf, hgs);
         else // d.type
-            typeToBuffer(d.type, null, buf, &hgs);
+            typeToBuffer(d.type, null, buf, hgs);
         buf.writeByte(';');
         buf.writenl();
     }
@@ -1692,7 +1718,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         if (stcToBuffer(buf, f.storage_class))
             buf.writeByte(' ');
         auto tf = f.type.isTypeFunction();
-        typeToBuffer(tf, f.ident, buf, &hgs);
+        typeToBuffer(tf, f.ident, buf, hgs);
 
         if (hgs.hdrgen)
         {
@@ -1706,7 +1732,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
                 bodyToBuffer(f);
                 hgs.autoMember--;
             }
-            else if (hgs.tpltMember == 0 && global.params.dihdr.fullOutput == false && !hgs.insideFuncBody)
+            else if (hgs.tpltMember == 0 && hgs.doFuncBodies == false && !hgs.insideFuncBody)
             {
                 if (!f.fbody)
                 {
@@ -1740,8 +1766,8 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         TypeFunction tf = cast(TypeFunction)f.type;
 
         if (!f.inferRetType && tf.next)
-            typeToBuffer(tf.next, null, buf, &hgs);
-        parametersToBuffer(tf.parameterList, buf, &hgs);
+            typeToBuffer(tf.next, null, buf, hgs);
+        parametersToBuffer(tf.parameterList, buf, hgs);
 
         // https://issues.dlang.org/show_bug.cgi?id=20074
         void printAttribute(string str)
@@ -1764,7 +1790,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         if (rs && rs.exp)
         {
             buf.writestring(" => ");
-            rs.exp.expressionToBuffer(buf, &hgs);
+            rs.exp.expressionToBuffer(buf, hgs);
         }
         else
         {
@@ -1833,7 +1859,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         {
             assert(es.exp && es.exp.op == EXP.assert_);
             buf.writestring(" (");
-            (cast(AssertExp)es.exp).e1.expressionToBuffer(buf, &hgs);
+            (cast(AssertExp)es.exp).e1.expressionToBuffer(buf, hgs);
             buf.writestring(");");
             buf.writenl();
         }
@@ -1858,9 +1884,9 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
         if (stcToBuffer(buf, d.storage_class))
             buf.writeByte(' ');
         Identifier id = d.isAnonymous() ? null : d.ident;
-        typeToBuffer(d.type, id, buf, &hgs);
+        typeToBuffer(d.type, id, buf, hgs);
         buf.writestring(" : ");
-        d.width.expressionToBuffer(buf, &hgs);
+        d.width.expressionToBuffer(buf, hgs);
         buf.writeByte(';');
         buf.writenl();
     }
@@ -1874,7 +1900,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
 
     void visitModule(Module m)
     {
-        moduleToBuffer2(m, buf, &hgs);
+        moduleToBuffer2(m, buf, hgs);
     }
 
     extern (C++)
@@ -1963,9 +1989,9 @@ private void visitVarDecl(VarDeclaration v, bool anywritten, ref OutBuffer buf,
     {
         auto ie = v._init.isExpInitializer();
         if (ie && (ie.exp.op == EXP.construct || ie.exp.op == EXP.blit))
-            (cast(AssignExp)ie.exp).e2.expressionToBuffer(buf, &hgs);
+            (cast(AssignExp)ie.exp).e2.expressionToBuffer(buf, hgs);
         else
-            v._init.initializerToBuffer(buf, &hgs);
+            v._init.initializerToBuffer(buf, hgs);
     }
 
     const commentIt = hgs.importcHdr && isSpecialCName(v.ident);
@@ -1988,7 +2014,7 @@ private void visitVarDecl(VarDeclaration v, bool anywritten, ref OutBuffer buf,
         if (stcToBuffer(buf, stc))
             buf.writeByte(' ');
         if (v.type)
-            typeToBuffer(v.type, v.ident, buf, &hgs);
+            typeToBuffer(v.type, v.ident, buf, hgs);
         else if (useTypeof)
         {
             buf.writestring("typeof(");
@@ -2033,7 +2059,7 @@ private bool isSpecialCName(Identifier id)
 /*********************************************
  * Print expression to buffer.
  */
-private void expressionPrettyPrint(Expression e, ref OutBuffer buf, HdrGenState* hgs)
+private void expressionPrettyPrint(Expression e, ref OutBuffer buf, ref HdrGenState hgs)
 {
     void visit(Expression e)
     {
@@ -2042,7 +2068,7 @@ private void expressionPrettyPrint(Expression e, ref OutBuffer buf, HdrGenState*
 
     void visitInteger(IntegerExp e)
     {
-        const dinteger_t v = e.toInteger();
+        const ulong v = e.toInteger();
         if (e.type)
         {
             Type t = e.type;
@@ -2059,7 +2085,8 @@ private void expressionPrettyPrint(Expression e, ref OutBuffer buf, HdrGenState*
                         {
                             if ((cast(EnumMember)em).value.toInteger == v)
                             {
-                                buf.printf("%s.%s", sym.toChars(), em.ident.toChars());
+                                const id = em.ident.toString();
+                                buf.printf("%s.%.*s", sym.toChars(), cast(int)id.length, id.ptr);
                                 return ;
                             }
                         }
@@ -2119,15 +2146,13 @@ private void expressionPrettyPrint(Expression e, ref OutBuffer buf, HdrGenState*
                 break;
             case Tpointer:
                 buf.writestring("cast(");
-                buf.writestring(t.toChars());
-                buf.writeByte(')');
-                if (target.ptrsize == 8)
-                    goto case Tuns64;
-                else if (target.ptrsize == 4 ||
-                         target.ptrsize == 2)
-                    goto case Tuns32;
-                else
-                    assert(0);
+
+                HdrGenState hgs2;               // should re-examine need for new hgs
+                hgs2.fullQual = (t.ty == Tclass && !t.mod);
+                toCBuffer(t, buf, null, hgs2);
+
+                buf.writestring(")cast(size_t)");
+                goto case Tuns64;
 
             case Tvoid:
                 buf.writestring("cast(void)0");
@@ -2136,11 +2161,8 @@ private void expressionPrettyPrint(Expression e, ref OutBuffer buf, HdrGenState*
             default:
                 /* This can happen if errors, such as
                  * the type is painted on like in fromConstInitializer().
+                 * Just ignore
                  */
-                if (!global.errors)
-                {
-                    assert(0);
-                }
                 break;
             }
         }
@@ -2286,7 +2308,7 @@ private void expressionPrettyPrint(Expression e, ref OutBuffer buf, HdrGenState*
         {
             e.sds.dsymbolToBuffer(buf, hgs);
         }
-        else if (hgs !is null && hgs.ddoc)
+        else if (hgs.ddoc)
         {
             // fixes bug 6491
             if (auto m = e.sds.isModule())
@@ -2403,7 +2425,7 @@ private void expressionPrettyPrint(Expression e, ref OutBuffer buf, HdrGenState*
             //   which isn't correct as regular D code.
                 buf.writeByte('(');
 
-                visitVarDecl(var, false, buf, *hgs);
+                visitVarDecl(var, false, buf, hgs);
 
                 buf.writeByte(';');
                 buf.writeByte(')');
@@ -2446,7 +2468,10 @@ private void expressionPrettyPrint(Expression e, ref OutBuffer buf, HdrGenState*
         typeToBuffer(e.targ, e.id, buf, hgs);
         if (e.tok2 != TOK.reserved)
         {
-            buf.printf(" %s %s", Token.toChars(e.tok), Token.toChars(e.tok2));
+            buf.writeByte(' ');
+            buf.writestring(Token.toString(e.tok));
+            buf.writeByte(' ');
+            buf.writestring(Token.toString(e.tok2));
         }
         else if (e.tspec)
         {
@@ -2459,7 +2484,7 @@ private void expressionPrettyPrint(Expression e, ref OutBuffer buf, HdrGenState*
         if (e.parameters && e.parameters.length)
         {
             buf.writestring(", ");
-            visitTemplateParameters(e.parameters, buf, *hgs);
+            visitTemplateParameters(e.parameters, buf, hgs);
         }
         buf.writeByte(')');
     }
@@ -2472,7 +2497,7 @@ private void expressionPrettyPrint(Expression e, ref OutBuffer buf, HdrGenState*
 
     void visitLoweredAssignExp(LoweredAssignExp e)
     {
-        if (global.params.vcg_ast)
+        if (hgs.vcg_ast)
         {
             expressionToBuffer(e.lowering, buf, hgs);
             return;
@@ -2937,12 +2962,12 @@ public:
         if (tp.specType)
         {
             buf.writestring(" : ");
-            typeToBuffer(tp.specType, null, *buf, hgs);
+            typeToBuffer(tp.specType, null, *buf, *hgs);
         }
         if (tp.defaultType)
         {
             buf.writestring(" = ");
-            typeToBuffer(tp.defaultType, null, *buf, hgs);
+            typeToBuffer(tp.defaultType, null, *buf, *hgs);
         }
     }
 
@@ -2956,33 +2981,33 @@ public:
     {
         buf.writestring("alias ");
         if (tp.specType)
-            typeToBuffer(tp.specType, tp.ident, *buf, hgs);
+            typeToBuffer(tp.specType, tp.ident, *buf, *hgs);
         else
             buf.writestring(tp.ident.toString());
         if (tp.specAlias)
         {
             buf.writestring(" : ");
-            objectToBuffer(tp.specAlias, *buf, hgs);
+            objectToBuffer(tp.specAlias, *buf, *hgs);
         }
         if (tp.defaultAlias)
         {
             buf.writestring(" = ");
-            objectToBuffer(tp.defaultAlias, *buf, hgs);
+            objectToBuffer(tp.defaultAlias, *buf, *hgs);
         }
     }
 
     override void visit(TemplateValueParameter tp)
     {
-        typeToBuffer(tp.valType, tp.ident, *buf, hgs);
+        typeToBuffer(tp.valType, tp.ident, *buf, *hgs);
         if (tp.specValue)
         {
             buf.writestring(" : ");
-            tp.specValue.expressionToBuffer(*buf, hgs);
+            tp.specValue.expressionToBuffer(*buf, *hgs);
         }
         if (tp.defaultValue)
         {
             buf.writestring(" = ");
-            tp.defaultValue.expressionToBuffer(*buf, hgs);
+            tp.defaultValue.expressionToBuffer(*buf, *hgs);
         }
     }
 
@@ -2993,9 +3018,9 @@ public:
     }
 }
 
-private void conditionToBuffer(Condition c, ref OutBuffer buf, HdrGenState* hgs)
+private void conditionToBuffer(Condition c, ref OutBuffer buf, ref HdrGenState hgs)
 {
-    scope v = new ConditionPrettyPrintVisitor(&buf, hgs);
+    scope v = new ConditionPrettyPrintVisitor(&buf, &hgs);
     c.accept(v);
 }
 
@@ -3035,19 +3060,19 @@ public:
     override void visit(StaticIfCondition c)
     {
         buf.writestring("static if (");
-        c.exp.expressionToBuffer(*buf, hgs);
+        c.exp.expressionToBuffer(*buf, *hgs);
         buf.writeByte(')');
     }
 }
 
 void toCBuffer(const Statement s, ref OutBuffer buf, ref HdrGenState hgs)
 {
-    (cast()s).statementToBuffer(buf, &hgs);
+    (cast()s).statementToBuffer(buf, hgs);
 }
 
 void toCBuffer(const Type t, ref OutBuffer buf, const Identifier ident, ref HdrGenState hgs)
 {
-    typeToBuffer(cast() t, ident, buf, &hgs);
+    typeToBuffer(cast() t, ident, buf, hgs);
 }
 
 // used from TemplateInstance::toChars() and TemplateMixin::toChars()
@@ -3057,12 +3082,12 @@ void toCBufferInstance(const TemplateInstance ti, ref OutBuffer buf, bool qualif
     hgs.fullQual = qualifyTypes;
 
     buf.writestring(ti.name.toChars());
-    tiargsToBuffer(cast() ti, buf, &hgs);
+    tiargsToBuffer(cast() ti, buf, hgs);
 }
 
 void toCBuffer(const Initializer iz, ref OutBuffer buf, ref HdrGenState hgs)
 {
-    initializerToBuffer(cast() iz, buf, &hgs);
+    initializerToBuffer(cast() iz, buf, hgs);
 }
 
 bool stcToBuffer(ref OutBuffer buf, StorageClass stc) @safe
@@ -3255,7 +3280,7 @@ extern (D) string visibilityToString(Visibility.Kind kind) nothrow pure @safe
 }
 
 // Print the full function signature with correct ident, attributes and template args
-void functionToBufferFull(TypeFunction tf, ref OutBuffer buf, const Identifier ident, HdrGenState* hgs, TemplateDeclaration td)
+void functionToBufferFull(TypeFunction tf, ref OutBuffer buf, const Identifier ident, ref HdrGenState hgs, TemplateDeclaration td)
 {
     //printf("TypeFunction::toCBuffer() this = %p\n", this);
     visitFuncIdentWithPrefix(tf, ident, td, buf, hgs);
@@ -3265,12 +3290,12 @@ void functionToBufferFull(TypeFunction tf, ref OutBuffer buf, const Identifier i
 void functionToBufferWithIdent(TypeFunction tf, ref OutBuffer buf, const(char)* ident, bool isStatic)
 {
     HdrGenState hgs;
-    visitFuncIdentWithPostfix(tf, ident.toDString(), buf, &hgs, isStatic);
+    visitFuncIdentWithPostfix(tf, ident.toDString(), buf, hgs, isStatic);
 }
 
 void toCBuffer(const Expression e, ref OutBuffer buf, ref HdrGenState hgs)
 {
-    expressionPrettyPrint(cast()e, buf, &hgs);
+    expressionPrettyPrint(cast()e, buf, hgs);
 }
 
 /**************************************************
@@ -3285,7 +3310,7 @@ void argExpTypesToCBuffer(ref OutBuffer buf, Expressions* arguments)
     {
         if (i)
             buf.writestring(", ");
-        typeToBuffer(arg.type, null, buf, &hgs);
+        typeToBuffer(arg.type, null, buf, hgs);
     }
 }
 
@@ -3298,7 +3323,7 @@ void arrayObjectsToBuffer(ref OutBuffer buf, Objects* objects)
     {
         if (i)
             buf.writestring(", ");
-        objectToBuffer(o, buf, &hgs);
+        objectToBuffer(o, buf, hgs);
     }
 }
 
@@ -3312,7 +3337,7 @@ extern (C++) const(char)* parametersTypeToChars(ParameterList pl)
 {
     OutBuffer buf;
     HdrGenState hgs;
-    parametersToBuffer(pl, buf, &hgs);
+    parametersToBuffer(pl, buf, hgs);
     return buf.extractChars();
 }
 
@@ -3330,7 +3355,7 @@ const(char)* parameterToChars(Parameter parameter, TypeFunction tf, bool fullQua
     HdrGenState hgs;
     hgs.fullQual = fullQual;
 
-    parameterToBuffer(parameter, buf, &hgs);
+    parameterToBuffer(parameter, buf, hgs);
 
     if (tf.parameterList.varargs == VarArg.typesafe && parameter == tf.parameterList[tf.parameterList.parameters.length - 1])
     {
@@ -3348,7 +3373,7 @@ const(char)* parameterToChars(Parameter parameter, TypeFunction tf, bool fullQua
  *      hgs = context
  */
 
-private void parametersToBuffer(ParameterList pl, ref OutBuffer buf, HdrGenState* hgs)
+private void parametersToBuffer(ParameterList pl, ref OutBuffer buf, ref HdrGenState hgs)
 {
     buf.writeByte('(');
     foreach (i; 0 .. pl.length)
@@ -3386,7 +3411,7 @@ private void parametersToBuffer(ParameterList pl, ref OutBuffer buf, HdrGenState
  *      buf = buffer to write it to
  *      hgs = context
  */
-private void parameterToBuffer(Parameter p, ref OutBuffer buf, HdrGenState* hgs)
+private void parameterToBuffer(Parameter p, ref OutBuffer buf, ref HdrGenState hgs)
 {
     if (p.userAttribDecl)
     {
@@ -3409,7 +3434,7 @@ private void parameterToBuffer(Parameter p, ref OutBuffer buf, HdrGenState* hgs)
     if (p.storageClass & STC.in_)
     {
         buf.writestring("in ");
-        if (global.params.previewIn && p.storageClass & STC.ref_)
+        if ((p.storageClass & (STC.constscoperef | STC.ref_)) == (STC.constscoperef | STC.ref_))
             stc &= ~STC.ref_;
     }
     else if (p.storageClass & STC.lazy_)
@@ -3424,14 +3449,15 @@ private void parameterToBuffer(Parameter p, ref OutBuffer buf, HdrGenState* hgs)
         STC.return_ | STC.returninferred | STC.scope_ | STC.scopeinferred | STC.out_ | STC.ref_ | STC.returnScope)))
         buf.writeByte(' ');
 
+    const(char)[] s;
     if (p.storageClass & STC.alias_)
     {
         if (p.ident)
             buf.writestring(p.ident.toString());
     }
-    else if (p.type.ty == Tident &&
-             (cast(TypeIdentifier)p.type).ident.toString().length > 3 &&
-             strncmp((cast(TypeIdentifier)p.type).ident.toChars(), "__T", 3) == 0)
+    else if (p.type.isTypeIdentifier() &&
+             (s = p.type.isTypeIdentifier().ident.toString()).length > 3 &&
+             s[0..3] == "__T")
     {
         // print parameter name, instead of undetermined type parameter
         buf.writestring(p.ident.toString());
@@ -3458,7 +3484,7 @@ private void parameterToBuffer(Parameter p, ref OutBuffer buf, HdrGenState* hgs)
  *     basis = replace `null`s in argument list with this expression (for sparse array literals)
  *     names = if non-null, use these as the names for the arguments
  */
-private void argsToBuffer(Expressions* expressions, ref OutBuffer buf, HdrGenState* hgs, Expression basis = null, Identifiers* names = null)
+private void argsToBuffer(Expressions* expressions, ref OutBuffer buf, ref HdrGenState hgs, Expression basis = null, Identifiers* names = null)
 {
     if (!expressions || !expressions.length)
         return;
@@ -3509,26 +3535,23 @@ private void argsToBuffer(Expressions* expressions, ref OutBuffer buf, HdrGenSta
     }
 }
 
-private void sizeToBuffer(Expression e, ref OutBuffer buf, HdrGenState* hgs)
+private void sizeToBuffer(Expression e, ref OutBuffer buf, ref HdrGenState hgs)
 {
     if (e.type == Type.tsize_t)
     {
         Expression ex = (e.op == EXP.cast_ ? (cast(CastExp)e).e1 : e);
         ex = ex.optimize(WANTvalue);
-        const dinteger_t uval = ex.op == EXP.int64 ? ex.toInteger() : cast(dinteger_t)-1;
-        if (cast(sinteger_t)uval >= 0)
-        {
-            dinteger_t sizemax = void;
-            if (target.ptrsize == 8)
-                sizemax = 0xFFFFFFFFFFFFFFFFUL;
-            else if (target.ptrsize == 4)
-                sizemax = 0xFFFFFFFFU;
-            else if (target.ptrsize == 2)
-                sizemax = 0xFFFFU;
-            else
-                assert(0);
-            if (uval <= sizemax && uval <= 0x7FFFFFFFFFFFFFFFUL)
+        const ulong uval = ex.op == EXP.int64 ? ex.toInteger() : cast(ulong)-1;
+        if (cast(long)uval >= 0)
+        {
+            if (uval <= 0xFFFFU)
+            {
+                buf.print(uval);
+                return;
+            }
+            if (uval <= 0x7FFF_FFFF_FFFF_FFFFUL)
             {
+                buf.writestring("cast(size_t)");
                 buf.print(uval);
                 return;
             }
@@ -3537,7 +3560,7 @@ private void sizeToBuffer(Expression e, ref OutBuffer buf, HdrGenState* hgs)
     expToBuffer(e, PREC.assign, buf, hgs);
 }
 
-private void expressionToBuffer(Expression e, ref OutBuffer buf, HdrGenState* hgs)
+private void expressionToBuffer(Expression e, ref OutBuffer buf, ref HdrGenState hgs)
 {
     expressionPrettyPrint(e, buf, hgs);
 }
@@ -3546,7 +3569,7 @@ private void expressionToBuffer(Expression e, ref OutBuffer buf, HdrGenState* hg
  * Write expression out to buf, but wrap it
  * in ( ) if its precedence is less than pr.
  */
-private void expToBuffer(Expression e, PREC pr, ref OutBuffer buf, HdrGenState* hgs)
+private void expToBuffer(Expression e, PREC pr, ref OutBuffer buf, ref HdrGenState hgs)
 {
     debug
     {
@@ -3580,7 +3603,7 @@ private void expToBuffer(Expression e, PREC pr, ref OutBuffer buf, HdrGenState*
 /**************************************************
  * An entry point to pretty-print type.
  */
-private void typeToBuffer(Type t, const Identifier ident, ref OutBuffer buf, HdrGenState* hgs,
+private void typeToBuffer(Type t, const Identifier ident, ref OutBuffer buf, ref HdrGenState hgs,
                           ubyte modMask = 0)
 {
     if (auto tf = t.isTypeFunction())
@@ -3596,7 +3619,7 @@ private void typeToBuffer(Type t, const Identifier ident, ref OutBuffer buf, Hdr
     }
 }
 
-private void visitWithMask(Type t, ubyte modMask, ref OutBuffer buf, HdrGenState* hgs)
+private void visitWithMask(Type t, ubyte modMask, ref OutBuffer buf, ref HdrGenState hgs)
 {
     // Tuples and functions don't use the type constructor syntax
     if (modMask == t.mod || t.ty == Tfunction || t.ty == Ttuple)
@@ -3632,7 +3655,7 @@ private void visitWithMask(Type t, ubyte modMask, ref OutBuffer buf, HdrGenState
 }
 
 
-private void dumpTemplateInstance(TemplateInstance ti, ref OutBuffer buf, HdrGenState* hgs)
+private void dumpTemplateInstance(TemplateInstance ti, ref OutBuffer buf, ref HdrGenState hgs)
 {
     buf.writeByte('{');
     buf.writenl();
@@ -3655,7 +3678,7 @@ private void dumpTemplateInstance(TemplateInstance ti, ref OutBuffer buf, HdrGen
 
 }
 
-private void tiargsToBuffer(TemplateInstance ti, ref OutBuffer buf, HdrGenState* hgs)
+private void tiargsToBuffer(TemplateInstance ti, ref OutBuffer buf, ref HdrGenState hgs)
 {
     buf.writeByte('!');
     if (ti.nest)
@@ -3675,7 +3698,9 @@ private void tiargsToBuffer(TemplateInstance ti, ref OutBuffer buf, HdrGenState*
         {
             if (t.equals(Type.tstring) || t.equals(Type.twstring) || t.equals(Type.tdstring) || t.mod == 0 && (t.isTypeBasic() || t.ty == Tident && (cast(TypeIdentifier)t).idents.length == 0))
             {
-                buf.writestring(t.toChars());
+                HdrGenState hgs2;       // re-examine need for new hgs
+                hgs2.fullQual = (t.ty == Tclass && !t.mod);
+                toCBuffer(t, buf, null, hgs2);
                 return;
             }
         }
@@ -3683,7 +3708,7 @@ private void tiargsToBuffer(TemplateInstance ti, ref OutBuffer buf, HdrGenState*
         {
             if (e.op == EXP.int64 || e.op == EXP.float64 || e.op == EXP.null_ || e.op == EXP.string_ || e.op == EXP.this_)
             {
-                buf.writestring(e.toChars());
+                toCBuffer(e, buf, hgs);
                 return;
             }
         }
@@ -3704,7 +3729,7 @@ private void tiargsToBuffer(TemplateInstance ti, ref OutBuffer buf, HdrGenState*
  * This makes a 'pretty' version of the template arguments.
  * It's analogous to genIdent() which makes a mangled version.
  */
-private void objectToBuffer(RootObject oarg, ref OutBuffer buf, HdrGenState* hgs)
+private void objectToBuffer(RootObject oarg, ref OutBuffer buf, ref HdrGenState hgs)
 {
     //printf("objectToBuffer()\n");
     /* The logic of this should match what genIdent() does. The _dynamic_cast()
@@ -3725,8 +3750,10 @@ private void objectToBuffer(RootObject oarg, ref OutBuffer buf, HdrGenState* hgs
     }
     else if (Dsymbol s = isDsymbol(oarg))
     {
-        const p = s.ident ? s.ident.toChars() : s.toChars();
-        buf.writestring(p);
+        if (s.ident)
+            buf.writestring(s.ident.toString());
+        else
+            buf.writestring(s.toChars());
     }
     else if (auto v = isTuple(oarg))
     {
@@ -3757,7 +3784,7 @@ private void objectToBuffer(RootObject oarg, ref OutBuffer buf, HdrGenState* hgs
 }
 
 
-private void visitFuncIdentWithPostfix(TypeFunction t, const char[] ident, ref OutBuffer buf, HdrGenState* hgs, bool isStatic)
+private void visitFuncIdentWithPostfix(TypeFunction t, const char[] ident, ref OutBuffer buf, ref HdrGenState hgs, bool isStatic)
 {
     if (t.inuse)
     {
@@ -3802,7 +3829,7 @@ private void visitFuncIdentWithPostfix(TypeFunction t, const char[] ident, ref O
 }
 
 private void visitFuncIdentWithPrefix(TypeFunction t, const Identifier ident, TemplateDeclaration td,
-    ref OutBuffer buf, HdrGenState* hgs)
+    ref OutBuffer buf, ref HdrGenState hgs)
 {
     if (t.inuse)
     {
@@ -3858,7 +3885,7 @@ private void visitFuncIdentWithPrefix(TypeFunction t, const Identifier ident, Te
         {
             if (i)
                 buf.writestring(", ");
-            toCBuffer(p, buf, *hgs);
+            toCBuffer(p, buf, hgs);
         }
         buf.writeByte(')');
     }
@@ -3871,7 +3898,7 @@ private void visitFuncIdentWithPrefix(TypeFunction t, const Identifier ident, Te
 }
 
 
-private void initializerToBuffer(Initializer inx, ref OutBuffer buf, HdrGenState* hgs)
+private void initializerToBuffer(Initializer inx, ref OutBuffer buf, ref HdrGenState hgs)
 {
     void visitError(ErrorInitializer iz)
     {
@@ -3944,7 +3971,7 @@ private void initializerToBuffer(Initializer inx, ref OutBuffer buf, HdrGenState
                     if (d.exp)
                     {
                         buf.writeByte('[');
-                        toCBuffer(d.exp, buf, *hgs);
+                        toCBuffer(d.exp, buf, hgs);
                         buf.writeByte(']');
                     }
                     else
@@ -3965,7 +3992,7 @@ private void initializerToBuffer(Initializer inx, ref OutBuffer buf, HdrGenState
 }
 
 
-private void typeToBufferx(Type t, ref OutBuffer buf, HdrGenState* hgs)
+private void typeToBufferx(Type t, ref OutBuffer buf, ref HdrGenState hgs)
 {
     void visitType(Type t)
     {
@@ -4155,13 +4182,13 @@ private void typeToBufferx(Type t, ref OutBuffer buf, HdrGenState* hgs)
             buf.writestring("const ");
         if (hgs.importcHdr && t.id)
         {
-            buf.writestring(t.id.toChars());
+            buf.writestring(t.id.toString());
             return;
         }
-        buf.writestring(Token.toChars(t.tok));
+        buf.writestring(Token.toString(t.tok));
         buf.writeByte(' ');
         if (t.id)
-            buf.writestring(t.id.toChars());
+            buf.writestring(t.id.toString());
         if (t.tok == TOK.enum_ && t.base && t.base.ty != TY.Tint32)
         {
             buf.writestring(" : ");
index e43a35510c286ed2a11b44b6d54799378fd6daea..e38ca5693543022aaed0a1176347091fee4bda6a 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
@@ -15,7 +15,7 @@
 
 class Module;
 
-void genhdrfile(Module *m, OutBuffer &buf);
+void genhdrfile(Module *m, bool doFuncBodies, OutBuffer &buf);
 void genCppHdrFiles(Modules &ms);
-void moduleToBuffer(OutBuffer& buf, Module *m);
+void moduleToBuffer(OutBuffer& buf, bool vcg_ast, Module *m);
 const char *parametersTypeToChars(ParameterList pl);
index c58224f7debdcb701b13fb7c494c422346e9a9bf..24a45136cd5b6f2685f26d7fb5df519166e901e8 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/iasm.html, Inline Assembler)
  *
- *              Copyright (C) 2018-2023 by The D Language Foundation, All Rights Reserved
+ *              Copyright (C) 2018-2024 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/src/dmd/iasm.d, _iasm.d)
index 92837b45842e6b31da11df953419c9c01e6dceac..db51e7341552b68c4473b98a069106a2a3d78772 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Inline assembler for the GCC D compiler.
  *
- *              Copyright (C) 2018-2023 by The D Language Foundation, All Rights Reserved
+ *              Copyright (C) 2018-2024 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/src/dmd/iasmgcc.d, _iasmgcc.d)
index 32221d94744ef97869c83081c7b2fb434ff59657..a66f2af4678305bd3e410d2400ffe71286025558 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Contains the `Id` struct with a list of predefined symbols the compiler knows about.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/id.d, _id.d)
@@ -521,6 +521,7 @@ immutable Msgtable[] msgtable =
     { "udaSelector", "selector" },
     { "udaOptional", "optional"},
     { "udaMustUse", "mustuse" },
+    { "udaStandalone", "standalone" },
 
     // C names, for undefined identifier error messages
     { "NULL" },
index f6cf6e59c34cc5a01af191dba767ddb96bf4d4cf..ddc8da23a8f09caeda15b348948500843912fb7b 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 2017-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 2017-2024 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.
index c2b2fbafa25f42cea93f17cef26e5c6194aaf8b8..8ace310937db9ef47190f5661b97aef1db1850df 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Defines an identifier, which is the name of a `Dsymbol`.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/identifier.d, _identifier.d)
index e7b3ba60b0f0e28f6a24ee78292026251ede0aef..afd3664bfa89483a0b1766684183991565c3b2a0 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index b45880a288724fe1e84069c2335ac3fed1ce02d1..b899f810aab2a45e3e460ad87d35a310c3e8cdbb 100644 (file)
@@ -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-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/impcnvtab.d, _impcnvtab.d)
index 9e9466a38eb283360035f24dde6b0be0f5708a47..ea2f13d91791a34b03d92df0fe26d84c960e288d 100644 (file)
@@ -3,7 +3,7 @@
  *
  * For example, prompt to `import std.stdio` when using `writeln`.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/imphint.d, _imphint.d)
index 2a02f13ba55b18b176e9f99b8112889b93a7d4c8..bfbb5510134beeb74bb130ce30dadd8ac58f270a 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index 2c7699b45ec86574f01ff642f5527f8611be2a2d..69a85ceec9397f610f1f58b84c1ede37f942b245 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: C11
  *
- * Copyright:   Copyright (C) 2021-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 2021-2024 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/src/dmd/importc.d, _importc.d)
index 5aefb0048a644b8aedd525fd2552e48ebc3a80b5..62bd41eea9382d0fba0da3d9771f3fcd3f3c7cbd 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Defines initializers of variables, e.g. the array literal in `int[3] x = [0, 1, 2]`.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/init.d, _init.d)
index 21bd07f4f39debe23fd68768fa990059b6fc3dad..b4e15e3fa9861f58070f4e92202cc43bd4715b1a 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index 19d576d4660824093e1eeaa7c065e27aa58ad3c6..5fe3b9325993fa7ecd59f12c3eac2fb5a2f47c2e 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Semantic analysis of initializers.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/initsem.d, _initsem.d)
index afab8315f928f5786b39581e41f2d4a15f8b60ab..3e163aec4d8b3bb4ffa12559e6b8583d050f494b 100644 (file)
@@ -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-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/inline.d, _inline.d)
index 442668f63377c78b7c4de4a71797b7bc1f93b65d..29c8b505cde1aa20871b78f2cb386fc9413d80e2 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Implement $(LINK2 https://digitalmars.com/articles/b62.html, Value Range Propagation).
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/intrange.d, _intrange.d)
index 11ab8169099ac7b7ff346696552ee61f0ec18ad2..9819c3a90cc9c9d466d147f79377c5d3b51e2f06 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Code for generating .json descriptions of the module when passing the `-X` flag to dmd.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/json.d, _json.d)
index 09fdecdb9eee5cd39abaf0d7e5878a28f1c88435..8a949114feb1ce51175a7c4a1efcc1d8aa7c7c16 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index c90c36069fd4bbf77fa0b544adf1a38362c3dbbe..a1db8d5254852adde33d3e822ba984507f3e4d51 100644 (file)
@@ -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-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/lamdbacomp.d, _lambdacomp.d)
index 2c6a59505698777b1948851b51fedd2b5e757a62..5eadd721f645c42843ae5af99cd8fa4ceb1a2b54 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/lex.html, Lexical)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/lexer.d, _lexer.d)
index 9fe48b88844495f61be89e1d418ec4de29352745..d71ea588c917232de300861cfabb97f758b57d35 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Encapsulates file/line/column locations.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/location.d, _location.d)
index aa246988f2efae7d5554df92f68b139d3a9a6261..68064a9210a948077eae32793e8277b283cd1602 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index 80a6ea25965b4833642545ee2f6dc58b6746639f..d09e873c49542f64fd1c455cd376a0c954d97e0d 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index 626bf7431f008eeb54e1ba1eef65057c75aa8c26..4c741cdd5cce612683bc3344a2777bcfe328b91b 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Defines a D type.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/mtype.d, _mtype.d)
@@ -525,13 +525,7 @@ extern (C++) abstract class Type : ASTNode
      */
     final override const(char)* toChars() const
     {
-        OutBuffer buf;
-        buf.reserve(16);
-        HdrGenState hgs;
-        hgs.fullQual = (ty == Tclass && !mod);
-
-        toCBuffer(this, buf, null, hgs);
-        return buf.extractChars();
+        return dmd.hdrgen.toChars(this);
     }
 
     /// ditto
@@ -4141,7 +4135,7 @@ extern (C++) final class TypeFunction : TypeNext
         auto stc = p.storageClass;
 
         // When the preview switch is enable, `in` parameters are `scope`
-        if (stc & STC.in_ && global.params.previewIn)
+        if (stc & STC.constscoperef)
             return stc | STC.scope_;
 
         if (stc & (STC.scope_ | STC.return_ | STC.lazy_) || purity == PURE.impure)
@@ -6433,28 +6427,22 @@ extern (C++) final class Parameter : ASTNode
      * Params:
      *  returnByRef = true if the function returns by ref
      *  p = Parameter to compare with
-     *  previewIn = Whether `-preview=in` is being used, and thus if
-     *              `in` means `scope [ref]`.
-     *
      * Returns:
      *  true = `this` can be used in place of `p`
      *  false = nope
      */
-    bool isCovariant(bool returnByRef, const Parameter p, bool previewIn = global.params.previewIn)
+    bool isCovariant(bool returnByRef, const Parameter p)
         const pure nothrow @nogc @safe
     {
         ulong thisSTC = this.storageClass;
         ulong otherSTC = p.storageClass;
 
-        if (previewIn)
-        {
-            if (thisSTC & STC.in_)
-                thisSTC |= STC.scope_;
-            if (otherSTC & STC.in_)
-                otherSTC |= STC.scope_;
-        }
+        if (thisSTC & STC.constscoperef)
+            thisSTC |= STC.scope_;
+        if (otherSTC & STC.constscoperef)
+            otherSTC |= STC.scope_;
 
-        const mask = STC.ref_ | STC.out_ | STC.lazy_ | (previewIn ? STC.in_ : 0);
+        const mask = STC.ref_ | STC.out_ | STC.lazy_ | (((thisSTC | otherSTC) & STC.constscoperef) ? STC.in_ : 0);
         if ((thisSTC & mask) != (otherSTC & mask))
             return false;
         return isCovariantScope(returnByRef, thisSTC, otherSTC);
@@ -6739,7 +6727,7 @@ enum ScopeRef
  * Returns:
  *      corresponding string
  */
-const(char)* toChars(ScopeRef sr) pure nothrow @nogc @safe
+const(char)* ScopeRefToChars(ScopeRef sr) pure nothrow @nogc @safe
 {
     with (ScopeRef)
     {
index ef1ce1006402a15e4e9316aa695d015913a17ffe..97a7ae3c5aff8a30bed1413eddac46db2cfee1af 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
@@ -39,6 +39,7 @@ typedef union tree_node type;
 typedef struct TYPE type;
 #endif
 
+extern const char* toChars(const Type* const t);
 Type *typeSemantic(Type *t, const Loc &loc, Scope *sc);
 Type *merge(Type *type);
 
index 693464919e04ae8e59f07901524e21949b920ff8..b5601a214dcafe7c56e4353f2159fd45445d166d 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Compile-time checks associated with the @mustuse attribute.
  *
- * Copyright: Copyright (C) 2022-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 2022-2024 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/src/dmd/mustuse.d, _mustuse.d)
  * Documentation:  https://dlang.org/phobos/dmd_mustuse.html
@@ -222,20 +222,7 @@ private bool hasMustUseAttribute(Dsymbol sym, Scope* sc)
  */
 private bool isMustUseAttribute(Expression e)
 {
-    import dmd.attrib : isCoreUda;
+    import dmd.attrib : isEnumAttribute;
     import dmd.id : Id;
-
-    // Logic based on dmd.objc.Supported.declaredAsOptionalCount
-    auto typeExp = e.isTypeExp;
-    if (!typeExp)
-        return false;
-
-    auto typeEnum = typeExp.type.isTypeEnum();
-    if (!typeEnum)
-        return false;
-
-    if (isCoreUda(typeEnum.sym, Id.udaMustUse))
-        return true;
-
-    return false;
+    return isEnumAttribute(e, Id.udaMustUse);
 }
index e59b01019f42e106386c01a94f3c318d4d5f331f..9e45e4549ffb6dbd7e5a94a8511a081f0ecd173d 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/function.html#nogc-functions, No-GC Functions)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/nogc.d, _nogc.d)
index 65f7d2964cb6f5ed0331cea06eec940056c1e8e3..52c2b79a4e5d4c286b3905c45618936c473efd33 100644 (file)
@@ -36,7 +36,7 @@
  * are valid D identifier.
  *
  * See_Also:    https://github.com/dlang/dmd/pull/10031
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/nspace.d, _nspace.d)
index 4a1bd9141ecc65f0c5e2f75b43b147c82c063f4e..cbee2fb791462f3194f637ffdec355fa5fe305d0 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index dc94aecc61bb419f2d97831078791a7e6e39a6db..785912e19681fe4af1f7351d460208b71e8b906b 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Flow analysis for Ownership/Borrowing
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/ob.d, _ob.d)
@@ -197,7 +197,7 @@ enum PtrState : ubyte
 
 /************
  */
-const(char)* toChars(PtrState state)
+const(char)* PtrStateToChars(PtrState state)
 {
     return toString(state).ptr;
 }
@@ -2490,7 +2490,7 @@ void checkObErrors(ref ObState obstate)
                     if (s1 != s2 && (s1 == PtrState.Owner || s2 == PtrState.Owner))
                     {
                         auto v = obstate.vars[i];
-                        .error(ob.exp ? ob.exp.loc : v.loc, "%s `%s` is both %s and %s", v.kind, v.toPrettyChars, s1.toChars(), s2.toChars());
+                        .error(ob.exp ? ob.exp.loc : v.loc, "%s `%s` is both %s and %s", v.kind, v.toPrettyChars, PtrStateToChars(s1), PtrStateToChars(s2));
                     }
                     pvs1.combine(*pvs2, i, ob.gen);
                 }
index 359474c588ada024fe713ba8f104752e345c1045..2f36d5d13da472a6fdd01232ea9d59b1da281058 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/objc_interface.html, Interfacing to Objective-C)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/objc.d, _objc.d)
index 40f634e91224de57431b3428bf8e8755b27fd00e..0390115aeb116c124679c829e9e700c6d90b0eda 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 2015-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 2015-2024 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.
index b7bc9257b3ed67243ab8f99b4f45b5e91d4de37d..d596b8487f2a862ebf4aa33e4564f968c9d2f121 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/operatoroverloading.html, Operator Overloading)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/opover.d, _opover.d)
index a9791684df44556e886918debf2ae618285fedd7..f86abde5c3e2b88156a658a19adccf07d7a6c161 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Perform constant folding.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/optimize.d, _optimize.d)
index b6f30b93f47d2f34d71f07b16d1a0edf891580ac..a012e0c7c5bf5edc6480ada3f12b47e0049bef24 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/grammar.html, D Grammar)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/parse.d, _parse.d)
@@ -2899,6 +2899,8 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
                     if (transitionIn)
                         eSink.message(scanloc, "Usage of 'in' on parameter");
                     stc = STC.in_;
+                    if (compileEnv.previewIn)
+                        stc |= STC.constscoperef;
                     goto L2;
 
                 case TOK.out_:
@@ -2936,9 +2938,9 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
 
                 default:
                     {
-                        stc = storageClass & (STC.IOR | STC.lazy_);
-                        // if stc is not a power of 2
-                        if (stc & (stc - 1) && !(stc == (STC.in_ | STC.ref_)))
+                        const stcx = storageClass & (STC.in_ | STC.ref_ | STC.out_ | STC.lazy_);
+                        // if stcx is not a power of 2
+                        if (stcx & (stcx - 1) && !(stcx == (STC.in_ | STC.ref_)))
                             error("incompatible parameter storage classes");
                         //if ((storageClass & STC.scope_) && (storageClass & (STC.ref_ | STC.out_)))
                             //error("scope cannot be ref or out");
index 70bd1300feb3c6d16428ac5bb3f2e50cdafde189..fe189d47e9466f6a64cbd1d40578dbf4751982c6 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * A depth-first visitor for expressions.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/apply.d, _apply.d)
index e1deb2c878650b5a22a8b9a4337532ee5d3975a5..02dc65390b03c0b5e4f12e05c748e63deb99f754 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Provides an AST printer for debugging.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/printast.d, _printast.d)
index 1d450505a4dad694ac3f8a0a3f47923fb60a092a..8929679e37ef4fc77a5b6675e8de99150c5c4041 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Associative array implementation.
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/root/aav.d, root/_aav.d)
index f36ddb4f29e2e9360b2d69ed1c15e5d898e1c670..81355774de3d0c36a35f38d072cdee8a5d86abc9 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * Dynamic array implementation.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/root/array.d, root/_array.d)
index ebe2c47d0a0baca127d590d97879debd5e81b5b7..1033b22237a3a17e271a14ae26749a8f6a708f7d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2023 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 2011-2024 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.
index 66adab65877b587df54c120372ea8174d71ede7a..c32d59eec36c559d5f1ca557fca8b4a881fbf195 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Implementation of a bit array.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/root/bitarray.d, root/_bitarray.d)
index 617cc9e2cfae8d823e33ce4c07bc58a5ec809d8f..2cd7152f72539ef6b2232a77d6fb0d882c7dd05c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2023 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 2011-2024 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.
index 57d1e340eff142028eb19195a7b01cbca9fa245e..de4c8d34678500df6193721d9f85b30da98c6976 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Implements a complex number type.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/root/complex.d, _complex.d)
index de2040b88f7854c9f7f7d43b1b10352518ec9ae3..8134f9e2591fe4517dc8c714f07fae862b84be4c 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index aae56fac02b24260b71744f6967d7d05f8097ca4..70446066593d58c6f81db945e88cc9cd439d93fa 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Collects functions for compile-time floating-point calculations.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/root/ctfloat.d, root/_ctfloat.d)
index d2f795bf9e912c442ec4e6c571081e20525fc229..ba8b4478246027345c460fbebafb51e21746c174 100644 (file)
@@ -1,5 +1,5 @@
 
-/* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 1999-2024 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.
index 1a4968801005c8231adb91997750231937c394f8..db2b2c6abcdd3248586995e3ac8afabf67bd0684 100644 (file)
@@ -1,5 +1,5 @@
 
-/* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 1999-2024 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.
index fdf13d4e8b027ac81aafd1509bdc904984dbfa34..a4362e171785cdc282c9028a38d864699e242600 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Read a file from disk and store it in memory.
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/root/file.d, root/_file.d)
index 8f31f21204882b14c4b5d60e946764d73c02b427..5b0bba42fc21fb7297d2df6983d19c1fffc0dd4e 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Encapsulate path and file names.
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/root/filename.d, root/_filename.d)
index 62142331013a04755228762c901c6c730772562d..d8834a19282b38d2b0f40fbde19520a4a052eebc 100644 (file)
@@ -1,5 +1,5 @@
 
-/* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 1999-2024 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.
index 2acee35c4f3705266f5ad1831fb18fbf2a593189..441620e60b4a2e07a4d59c51d3952c718fb3bfc9 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Hash functions for arbitrary binary data.
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/root/hash.d, root/_hash.d)
index 8e505f036c79e33db67bf06c5ec98b381ec8df39..f56cb17601756bd0736269a2cfae4db74fd72a28 100644 (file)
@@ -1,5 +1,5 @@
 
-/* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 1999-2024 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.
index bc1016b102a24b8b706f1b8dbd4f90b06d496244..e7d0e1ef785ea28dc2c76e08243e05788fa5aa93 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Implementation of an 'Optional' type
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/root/optional.d, root/_optional.d)
index 353332c2199e2db60bb8aca3e584b00fb313c451..a92deddc638762b7906bbd16e74d3cbd5ab77502 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * Optional implementation.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/root/optional.h, root/_optional.h)
index 290280f619c990444724a08dd44e17529ecd1350..ee846bdb291db12f6081bcf350ec734b384685d4 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Portable routines for functions that have different implementations on different platforms.
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/root/port.d, root/_port.d)
index 6fa3c000e5ac6aed9fbd3a507f106582683e5f53..6c7dddd43ae28848187a10c069a0ada4a2603257 100644 (file)
@@ -1,5 +1,5 @@
 
-/* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 1999-2024 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.
index 9fc57f1e3a8131c44cb5b88f9e5486619b1d5e8c..a9fab162537fa6f9144b389c0dba45b4d6deb3dc 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Region storage allocator implementation.
  *
- * Copyright:   Copyright (C) 2019-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 2019-2024 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/src/dmd/root/region.d, root/_region.d)
index cff5c4cf7eca38c1795226343780787cd470a30b..19652072376bf52b043fd50523366b9715b898d0 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Allocate memory using `malloc` or the GC depending on the configuration.
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/root/rmem.d, root/_rmem.d)
index 36aa2646fdc68f56f6057a1c7f8907de638710e2..09c0fc07ccc62b3caad58caab97f15c1632d8a32 100644 (file)
@@ -1,5 +1,5 @@
 
-/* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 1999-2024 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.
index 7ad08b7216e9e2d0129265468129ae1526b42ae9..ae09cba37fcaecd3444e7030a994538f657c9415 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Does not have any dependencies on the rest of DMD.
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/root/speller.d, root/_speller.d)
index 5ee81a9b63dd456e7cb8314ea5fa016d88eb9165..e82b0d2fe6d0b4c7194a79b7c8d07e0aab5d1099 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Contains various string related functions.
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/root/string.d, root/_string.d)
index de293eb9b55d968ee73502f951472a4f057024ac..1fba919dec5733659a95852b932831b152ccc62d 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * A specialized associative array with string keys stored in a variable length structure.
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/root/stringtable.d, root/_stringtable.d)
index d7ba17f8a0b1db6b109aca8d95204b823ec46919..7d732f2fbe856fbcf790d76c6c1ed39f452310f6 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Functions related to UTF encoding.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/root/utf.d, _utf.d)
index 7867ad5de319d5bca928a667bf6cbdff5889eac7..7c926fea0555383fae15823854bf377b83b5e379 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Provide the root object that AST classes in dmd inherit from.
  *
- * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2024 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/src/dmd/rootobject.d, _rootobject.d)
index bd531c0081e0fcfc36e794aacc0de9117ebbcc4d..af81bff0dd1d22c2b271c72840d466d7ad6f27ae 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/function.html#function-safety, Function Safety)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/safe.d, _safe.d)
index 13fe69165310fd0862fb97379c3e94b76280d817..340fbad78d4313110df8679df7f3dc890604e583 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Provides a depth-first statement visitor.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/sparse.d, _sparse.d)
index cceb5a7e3a83ebe5b4c182a7abdbc8050871eaa1..1535fd0775543cd55bd9fed44a3906279e4c6127 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index 036560b54076b1dc01102a41739d625958dde699..937e746270ae2f6f8328e63809249f7d693038b6 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Performs the semantic2 stage, which deals with initializer expressions.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/semantic2.d, _semantic2.d)
@@ -93,6 +93,13 @@ private extern(C++) final class Semantic2Visitor : Visitor
     override void visit(StaticAssert sa)
     {
         //printf("StaticAssert::semantic2() %s\n", sa.toChars());
+        if (const e = sa.exp.isStringExp())
+        {
+            // deprecated in 2.107
+            deprecation(e.loc, "static assert condition cannot be a string literal");
+            deprecationSupplemental(e.loc, "If intentional, use `%s !is null` instead to preserve behaviour",
+                e.toChars());
+        }
         auto sds = new ScopeDsymbol();
         sc = sc.push(sds);
         sc.tinst = null;
index 7498eaf445830d08d330bcc51ace778429f0e0f8..520e05f4190cae1ead9ea752db5fa388080f8f84 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Performs the semantic3 stage, which deals with function bodies.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/semantic3.d, _semantic3.d)
index 80c9a46958f56f2a0597e287530853ccb2f1be53..59398a70cb81e1025f9a79ab45fa02af42978331 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Find side-effects of expressions.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/sideeffect.d, _sideeffect.d)
index 430454480e111792249abd1a43b89efff32fb890..a79b78acf247830fdf4353f5274d75cfb9508f2e 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/statement.html, Statements)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/statement.d, _statement.d)
index 1e493f0d188aa59053e07d8fd594b0a1166badfe..ee03d49eb4aed2424d428b5e4cd3a36d63c800ed 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index dcdd96300022f6385e4903f690613e355713bc8a..221c5021c521205745709d18e64041843412b7cf 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Provides a visitor for statements that allows rewriting the currently visited node.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/statement_rewrite_walker.d, _statement_rewrite_walker.d)
index fcc606b6dd58249e5b483ed4b9ca9dd333be91bb..229cf17bb6abaa9bfb17993e287abe2364d30da5 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/statement.html, Statements)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/statementsem.d, _statementsem.d)
@@ -568,8 +568,8 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
             ds._body = ds._body.semanticScope(sc, ds, ds, null);
         sc.inLoop = inLoopSave;
 
-        if (ds.condition.op == EXP.dotIdentifier)
-            (cast(DotIdExp)ds.condition).noderef = true;
+        if (auto dotid = ds.condition.isDotIdExp())
+            dotid.noderef = true;
 
         // check in syntax level
         ds.condition = checkAssignmentAsCondition(ds.condition, sc);
@@ -641,8 +641,8 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
 
         if (fs.condition)
         {
-            if (fs.condition.op == EXP.dotIdentifier)
-                (cast(DotIdExp)fs.condition).noderef = true;
+            if (auto dotid = fs.condition.isDotIdExp())
+                dotid.noderef = true;
 
             // check in syntax level
             fs.condition = checkAssignmentAsCondition(fs.condition, sc);
@@ -729,8 +729,8 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
         if (fs.aggr.op == EXP.error)
             return setError();
         Expression oaggr = fs.aggr;     // remember original for error messages
-        if (fs.aggr.type && fs.aggr.type.toBasetype().ty == Tstruct &&
-            (cast(TypeStruct)(fs.aggr.type.toBasetype())).sym.dtor &&
+        if (fs.aggr.type && fs.aggr.type.toBasetype().isTypeStruct() &&
+            fs.aggr.type.toBasetype().isTypeStruct().sym.dtor &&
             !fs.aggr.isTypeExp() && !fs.aggr.isLvalue())
         {
             // https://issues.dlang.org/show_bug.cgi?id=14653
@@ -804,9 +804,9 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
                         Parameter fparam = fparameters[0];
                         if ((fparam.type.ty == Tpointer ||
                              fparam.type.ty == Tdelegate) &&
-                            fparam.type.nextOf().ty == Tfunction)
+                            fparam.type.nextOf().isTypeFunction())
                         {
-                            TypeFunction tf = cast(TypeFunction)fparam.type.nextOf();
+                            auto tf = fparam.type.nextOf().isTypeFunction();
                             foreachParamCount = tf.parameterList.length;
                             foundMismatch = true;
                         }
@@ -1644,8 +1644,8 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
         }
         else
         {
-            if (ifs.condition.op == EXP.dotIdentifier)
-                (cast(DotIdExp)ifs.condition).noderef = true;
+            if (auto dotid = ifs.condition.isDotIdExp())
+                dotid.noderef = true;
 
             ifs.condition = ifs.condition.expressionSemantic(scd);
             ifs.condition = resolveProperties(scd, ifs.condition);
@@ -1910,8 +1910,8 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
         while (!ss.condition.isErrorExp())
         {
             // preserve enum type for final switches
-            if (ss.condition.type.ty == Tenum)
-                te = cast(TypeEnum)ss.condition.type;
+            if (auto tenum = ss.condition.type.isTypeEnum())
+                te = tenum;
             if (ss.condition.type.isString())
             {
                 // If it's not an array, cast it to one
@@ -2222,14 +2222,13 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
             Expression e = cs.exp;
             // Remove all the casts the user and/or implicitCastTo may introduce
             // otherwise we'd sometimes fail the check below.
-            while (e.op == EXP.cast_)
-                e = (cast(CastExp)e).e1;
+            while (e.isCastExp())
+                e = e.isCastExp().e1;
 
             /* This is where variables are allowed as case expressions.
             */
-            if (e.op == EXP.variable)
+            if (auto ve = e.isVarExp())
             {
-                VarExp ve = cast(VarExp)e;
                 VarDeclaration v = ve.var.isVarDeclaration();
                 Type t = cs.exp.type.toBasetype();
                 if (v && (t.isintegral() || t.ty == Tclass))
@@ -3227,9 +3226,9 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
             sym.parent = sc.scopesym;
             sym.endlinnum = ws.endloc.linnum;
         }
-        else if (ws.exp.op == EXP.type)
+        else if (auto et = ws.exp.isTypeExp())
         {
-            Dsymbol s = (cast(TypeExp)ws.exp).type.toDsymbol(sc);
+            Dsymbol s = et.type.toDsymbol(sc);
             if (!s || !s.isScopeDsymbol())
             {
                 error(ws.loc, "`with` type `%s` has no members", ws.exp.toChars());
@@ -3767,16 +3766,15 @@ public bool throwSemantic(const ref Loc loc, ref Expression exp, Scope* sc)
     if (FuncDeclaration fd = sc.parent.isFuncDeclaration())
         fd.hasReturnExp |= 2;
 
-    if (exp.op == EXP.new_)
+    if (auto ne = exp.isNewExp())
     {
-        NewExp ne = cast(NewExp) exp;
         ne.thrownew = true;
     }
 
     exp = exp.expressionSemantic(sc);
     exp = resolveProperties(sc, exp);
     exp = checkGC(sc, exp);
-    if (exp.op == EXP.error)
+    if (exp.isErrorExp())
         return false;
     if (!exp.type.isNaked())
     {
@@ -3805,12 +3803,12 @@ private extern(D) Expression applyOpApply(ForeachStatement fs, Expression flde,
         {
             message(loc, "To enforce `@safe`, the compiler allocates a closure unless `opApply()` uses `scope`");
         }
-        (cast(FuncExp)flde).fd.tookAddressOf = 1;
+        flde.isFuncExp().fd.tookAddressOf = 1;
     }
     else
     {
         if (sc2.useDIP1000 == FeatureState.enabled)
-            ++(cast(FuncExp)flde).fd.tookAddressOf;  // allocate a closure unless the opApply() uses 'scope'
+            ++flde.isFuncExp().fd.tookAddressOf;  // allocate a closure unless the opApply() uses 'scope'
     }
     assert(tab.ty == Tstruct || tab.ty == Tclass);
     assert(sapply);
@@ -3821,7 +3819,7 @@ private extern(D) Expression applyOpApply(ForeachStatement fs, Expression flde,
     ec = new DotIdExp(fs.loc, fs.aggr, sapply.ident);
     ec = new CallExp(fs.loc, ec, flde);
     ec = ec.expressionSemantic(sc2);
-    if (ec.op == EXP.error)
+    if (ec.isErrorExp())
         return null;
     if (ec.type != Type.tint32)
     {
@@ -3838,11 +3836,12 @@ private extern(D) Expression applyDelegate(ForeachStatement fs, Expression flde,
     /* Call:
      *      aggr(flde)
      */
-    if (fs.aggr.op == EXP.delegate_ && (cast(DelegateExp)fs.aggr).func.isNested() &&
-        !(cast(DelegateExp)fs.aggr).func.needThis())
+    if (auto de = fs.aggr.isDelegateExp())
+    if (de.func.isNested() &&
+        !de.func.needThis())
     {
         // https://issues.dlang.org/show_bug.cgi?id=3560
-        fs.aggr = (cast(DelegateExp)fs.aggr).e1;
+        fs.aggr = de.e1;
     }
     ec = new CallExp(fs.loc, fs.aggr, flde);
     ec = ec.expressionSemantic(sc2);
@@ -4099,7 +4098,7 @@ private FuncExp foreachBodyToFunction(Scope* sc, ForeachStatement fs, TypeFuncti
     fld.tookAddressOf = 0;
     if (flde.op == EXP.error)
         return null;
-    return cast(FuncExp)flde;
+    return flde.isFuncExp();
 }
 
 
@@ -4273,9 +4272,9 @@ Statement scopeCode(Statement statement, Scope* sc, out Statement sentry, out St
 {
     if (auto es = statement.isExpStatement())
     {
-        if (es.exp && es.exp.op == EXP.declaration)
+        if (es.exp && es.exp.isDeclarationExp())
         {
-            auto de = cast(DeclarationExp)es.exp;
+            auto de = es.exp.isDeclarationExp();
             auto v = de.declaration.isVarDeclaration();
             if (v && !v.isDataseg())
             {
@@ -4401,7 +4400,7 @@ public auto makeTupleForeach(Scope* sc, bool isStatic, bool isDecl, ForeachState
     }
 
     Type tab = fs.aggr.type.toBasetype();
-    TypeTuple tuple = cast(TypeTuple)tab;
+    TypeTuple tuple = tab.isTypeTuple();
 
     Statements* statements;
     Dsymbols* declarations;
@@ -4413,12 +4412,12 @@ public auto makeTupleForeach(Scope* sc, bool isStatic, bool isDecl, ForeachState
     //printf("aggr: op = %d, %s\n", fs.aggr.op, fs.aggr.toChars());
     size_t n;
     TupleExp te = null;
-    if (fs.aggr.op == EXP.tuple) // expression tuple
+    if (auto ate =  fs.aggr.isTupleExp()) // expression tuple
     {
-        te = cast(TupleExp)fs.aggr;
+        te = ate;
         n = te.exps.length;
     }
-    else if (fs.aggr.op == EXP.type) // type tuple
+    else if (fs.aggr.isTypeExp()) // type tuple
     {
         n = Parameter.dim(tuple.arguments);
     }
index 760c66a415a41941c54a61027c8e056d4d7264e2..08780ca07819b0ce03652e098739275e8decad15 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/version.html#static-assert, Static Assert)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/staticassert.d, _staticassert.d)
@@ -49,10 +49,10 @@ extern (C++) final class StaticAssert : Dsymbol
         return new StaticAssert(loc, exp.syntaxCopy(), msgs ? Expression.arraySyntaxCopy(msgs) : null);
     }
 
-    override bool oneMember(Dsymbol* ps, Identifier ident)
+    override bool oneMember(out Dsymbol ps, Identifier ident)
     {
         //printf("StaticAssert::oneMember())\n");
-        *ps = null;
+        ps = null;
         return true;
     }
 
index c0d5363a4143d2b4714b5bdcb5307f3852bd8327..ed76de070120c9538f7c38f60b2b6a035288c6fb 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
@@ -21,7 +21,7 @@ public:
     Expressions *msg;
 
     StaticAssert *syntaxCopy(Dsymbol *s) override;
-    bool oneMember(Dsymbol **ps, Identifier *ident) override;
+    bool oneMember(Dsymbol *&ps, Identifier *ident) override;
     const char *kind() const override;
     StaticAssert *isStaticAssert() override { return this; }
     void accept(Visitor *v) override { v->visit(this); }
index 1d18de318296ffe4b0c7c9d81b6881e16803ab15..72afe0296415544c4d7b5fa021796c9f143c3cca 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Lazily evaluate static conditions for `static if`, `static assert` and template constraints.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/staticcond.d, _staticcond.d)
index 7b2ea972f0e55067b747f1763bde8a16a0b1165e..e1ed16594a8cbeef0ae1a55abf0047f01155f662 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Used to help transform statement AST into flow graph.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/stmtstate.d, _stmtstate.d)
index aba3319247b502f46f9af0a267f0efebd6db2c38..e63bf17a5f7cbf88b6f6ad73365a52c947a3c3f5 100644 (file)
@@ -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-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/target.d, _target.d)
index ca0e09c88e04fc3a1e0a7b549cb8ec080695064f..120950570d4c66b124e0d1b68acdecaec81f1071 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 2013-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 2013-2024 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.
index 4be136102c278fe0ba580bd29c545005a856fb43..09c4912a52113ce9f55bc33d0765762f0809d560 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
@@ -290,7 +290,7 @@ public:
     TemplateInstance *syntaxCopy(Dsymbol *) override;
     Dsymbol *toAlias() override final;   // resolve real symbol
     const char *kind() const override;
-    bool oneMember(Dsymbol **ps, Identifier *ident) override;
+    bool oneMember(Dsymbol *&ps, Identifier *ident) override;
     const char *toChars() const override;
     const char* toPrettyCharsHelper() override final;
     Identifier *getIdent() override final;
@@ -309,7 +309,7 @@ public:
 
     TemplateMixin *syntaxCopy(Dsymbol *s) override;
     const char *kind() const override;
-    bool oneMember(Dsymbol **ps, Identifier *ident) override;
+    bool oneMember(Dsymbol *&ps, Identifier *ident) override;
     bool hasPointers() override;
     const char *toChars() const override;
 
index 7762363c8d64d3f39431ce7891bb044f6069800d..89749d6b7f3213af534bcf967fd70f135eff66c7 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Semantic analysis of template parameters.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/templateparamsem.d, _templateparamsem.d)
index 317a6e6c3826d1b0be86d2ee496a9abe2c8ffd4d..589bc2b53cdc3de182f2180477b6879912ce0ed2 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/lex.html#tokens, Tokens)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/tokens.d, _tokens.d)
@@ -947,93 +947,111 @@ nothrow:
     }
 
     extern (C++) const(char)* toChars() const
+    {
+        return toString().ptr;
+    }
+
+    /*********************************
+     * Returns:
+     *  a zero-terminated string representation of the token,
+     *  sometimes reusing a static buffer, sometimes leaking memory
+     */
+    extern (D) const(char)[] toString() const
     {
         const bufflen = 3 + 3 * floatvalue.sizeof + 1;
-        __gshared char[bufflen] buffer;
-        const(char)* p = &buffer[0];
+        __gshared char[bufflen + 2] buffer;     // extra 2 for suffixes
+        char* p = &buffer[0];
         switch (value)
         {
         case TOK.int32Literal:
-            snprintf(&buffer[0], bufflen, "%d", cast(int)intvalue);
-            break;
+            const length = snprintf(p, bufflen, "%d", cast(int)intvalue);
+            return p[0 .. length];
+
         case TOK.uns32Literal:
         case TOK.wchar_tLiteral:
-            snprintf(&buffer[0], bufflen, "%uU", cast(uint)unsvalue);
-            break;
+            const length = snprintf(p, bufflen, "%uU", cast(uint)unsvalue);
+            return p[0 .. length];
+
         case TOK.wcharLiteral:
         case TOK.dcharLiteral:
         case TOK.charLiteral:
-            {
-                OutBuffer buf;
-                buf.writeSingleCharLiteral(cast(dchar) intvalue);
-                buf.writeByte('\0');
-                p = buf.extractChars();
-            }
-            break;
+            OutBuffer buf;
+            buf.writeSingleCharLiteral(cast(dchar) intvalue);
+            return buf.extractSlice(true);
+
         case TOK.int64Literal:
-            snprintf(&buffer[0], bufflen, "%lldL", cast(long)intvalue);
-            break;
+            const length = snprintf(p, bufflen, "%lldL", cast(long)intvalue);
+            return p[0 .. length];
+
         case TOK.uns64Literal:
-            snprintf(&buffer[0], bufflen, "%lluUL", cast(ulong)unsvalue);
-            break;
+            const length = snprintf(p, bufflen, "%lluUL", cast(ulong)unsvalue);
+            return p[0 .. length];
+
         case TOK.float32Literal:
-            CTFloat.sprint(&buffer[0], bufflen, 'g', floatvalue);
-            strcat(&buffer[0], "f");
-            break;
+            const length = CTFloat.sprint(p, bufflen, 'g', floatvalue);
+            p[length] = 'f';
+            p[length + 1] = 0;
+            return p[0 .. length + 1];
+
         case TOK.float64Literal:
-            CTFloat.sprint(&buffer[0], bufflen, 'g', floatvalue);
-            break;
+            const length = CTFloat.sprint(p, bufflen, 'g', floatvalue);
+            return p[0 .. length];
+
         case TOK.float80Literal:
-            CTFloat.sprint(&buffer[0], bufflen, 'g', floatvalue);
-            strcat(&buffer[0], "L");
-            break;
+            const length = CTFloat.sprint(p, bufflen, 'g', floatvalue);
+            p[length] = 'L';
+            p[length + 1] = 0;
+            return p[0 .. length + 1];
+
         case TOK.imaginary32Literal:
-            CTFloat.sprint(&buffer[0], bufflen, 'g', floatvalue);
-            strcat(&buffer[0], "fi");
-            break;
+            const length = CTFloat.sprint(p, bufflen, 'g', floatvalue);
+            p[length    ] = 'f';
+            p[length + 1] = 'i';
+            p[length + 2] = 0;
+            return p[0 .. length + 2];
+
         case TOK.imaginary64Literal:
-            CTFloat.sprint(&buffer[0], bufflen, 'g', floatvalue);
-            strcat(&buffer[0], "i");
-            break;
+            const length = CTFloat.sprint(p, bufflen, 'g', floatvalue);
+            p[length] = 'i';
+            p[length + 1] = 0;
+            return p[0 .. length + 1];
+
         case TOK.imaginary80Literal:
-            CTFloat.sprint(&buffer[0], bufflen, 'g', floatvalue);
-            strcat(&buffer[0], "Li");
-            break;
+            const length = CTFloat.sprint(p, bufflen, 'g', floatvalue);
+            p[length    ] = 'L';
+            p[length + 1] = 'i';
+            p[length + 2] = 0;
+            return p[0 .. length + 2];
+
         case TOK.string_:
+            OutBuffer buf;
+            buf.writeByte('"');
+            for (size_t i = 0; i < len;)
             {
-                OutBuffer buf;
-                buf.writeByte('"');
-                for (size_t i = 0; i < len;)
-                {
-                    dchar c;
-                    utf_decodeChar(ustring[0 .. len], i, c);
-                    writeCharLiteral(buf, c);
-                }
-                buf.writeByte('"');
-                if (postfix)
-                    buf.writeByte(postfix);
-                buf.writeByte(0);
-                p = buf.extractChars();
+                dchar c;
+                utf_decodeChar(ustring[0 .. len], i, c);
+                writeCharLiteral(buf, c);
             }
-            break;
+            buf.writeByte('"');
+            if (postfix)
+                buf.writeByte(postfix);
+            return buf.extractSlice(true);
+
         case TOK.hexadecimalString:
+            OutBuffer buf;
+            buf.writeByte('x');
+            buf.writeByte('"');
+            foreach (size_t i; 0 .. len)
             {
-                OutBuffer buf;
-                buf.writeByte('x');
-                buf.writeByte('"');
-                foreach (size_t i; 0 .. len)
-                {
-                    if (i)
-                        buf.writeByte(' ');
-                    buf.printf("%02x", ustring[i]);
-                }
-                buf.writeByte('"');
-                if (postfix)
-                    buf.writeByte(postfix);
-                buf.writeByte(0);
-                p = buf.extractData();
-                break;
+                if (i)
+                    buf.writeByte(' ');
+                buf.printf("%02x", ustring[i]);
             }
+            buf.writeByte('"');
+            if (postfix)
+                buf.writeByte(postfix);
+            return buf.extractSlice(true);
+
         case TOK.identifier:
         case TOK.enum_:
         case TOK.struct_:
@@ -1062,13 +1080,11 @@ nothrow:
         case TOK.complex64:
         case TOK.complex80:
         case TOK.void_:
-            p = ident.toChars();
-            break;
+            return ident.toString();
+
         default:
-            p = toChars(value);
-            break;
+            return tochars[value];
         }
-        return p;
     }
 
     static const(char)* toChars(TOK value)
index 560942d1e4757ba174f892de74766c11761db828..f944663e43052292ed7676044854b466459a957c 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index aebc0b5512b3e2605f071a9a36f4f06da60df6e4..c67ee816d2c5a9031be4de9435716f1d8a689900 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Specification: $(LINK2 https://dlang.org/spec/traits.html, Traits)
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/traits.d, _traits.d)
index b0e45f4c042f43db1c2990917a93b0582f1f1c48..51b4ef885f1ec29d3482e91ef7b9bc70921aad5c 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Semantic analysis for D types.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/typesem.d, _typesem.d)
@@ -711,7 +711,15 @@ private extern(D) bool isCopyConstructorCallable (StructDeclaration argStruct,
                 s ~= "@safe ";
             if (!f.isNogc && sc.func.setGC(arg.loc, null))
                 s ~= "nogc ";
-            if (s)
+            if (f.isDisabled() && !f.isGenerated())
+            {
+                /* https://issues.dlang.org/show_bug.cgi?id=24301
+                 * Copy constructor is explicitly disabled
+                 */
+                buf.printf("`%s` copy constructor cannot be used because it is annotated with `@disable`",
+                    f.type.toChars());
+            }
+            else if (s)
             {
                 s[$-1] = '\0';
                 buf.printf("`%s` copy constructor cannot be called from a `%s` context", f.type.toChars(), s.ptr);
@@ -843,7 +851,7 @@ private extern(D) MATCH argumentMatchParameter (TypeFunction tf, Parameter p,
                     ta = tn.sarrayOf(dim);
                 }
             }
-            else if ((p.storageClass & STC.in_) && global.params.previewIn)
+            else if (p.storageClass & STC.constscoperef)
             {
                 // Allow converting a literal to an `in` which is `ref`
                 if (arg.op == EXP.arrayLiteral && tp.ty == Tsarray)
@@ -1678,7 +1686,7 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
 
             // default arg must be an lvalue
             if (isRefOrOut && !isAuto &&
-                !(global.params.previewIn && (fparam.storageClass & STC.in_)) &&
+                !(fparam.storageClass & STC.constscoperef) &&
                 global.params.rvalueRefParam != FeatureState.enabled)
                 e = e.toLvalue(sc, "create default argument for `ref` / `out` parameter from");
 
@@ -1784,13 +1792,13 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
                     switch (tf.linkage)
                     {
                     case LINK.cpp:
-                        if (global.params.previewIn)
+                        if (fparam.storageClass & STC.constscoperef)
                             fparam.storageClass |= STC.ref_;
                         break;
                     case LINK.default_, LINK.d:
                         break;
                     default:
-                        if (global.params.previewIn)
+                        if (fparam.storageClass & STC.constscoperef)
                         {
                             .error(loc, "cannot use `in` parameters with `extern(%s)` functions",
                                    linkageToChars(tf.linkage));
@@ -1820,7 +1828,7 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
                     if (tb2.ty == Tstruct && !tb2.isTypeStruct().sym.members ||
                         tb2.ty == Tenum   && !tb2.isTypeEnum().sym.memtype)
                     {
-                        if (global.params.previewIn && (fparam.storageClass & STC.in_))
+                        if (fparam.storageClass & STC.constscoperef)
                         {
                             .error(loc, "cannot infer `ref` for `in` parameter `%s` of opaque type `%s`",
                                    fparam.toChars(), fparam.type.toChars());
@@ -1902,7 +1910,7 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
                 fparam.storageClass &= ~(STC.TYPECTOR);
 
                 // -preview=in: add `ref` storage class to suited `in` params
-                if (global.params.previewIn && (fparam.storageClass & (STC.in_ | STC.ref_)) == STC.in_)
+                if ((fparam.storageClass & (STC.constscoperef | STC.ref_)) == STC.constscoperef)
                 {
                     auto ts = t.baseElemOf().isTypeStruct();
                     const isPOD = !ts || ts.sym.isPOD();
@@ -2318,11 +2326,16 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
     Type visitTag(TypeTag mtype)
     {
         //printf("TypeTag.semantic() %s\n", mtype.toChars());
+        Type returnType(Type t)
+        {
+            return t.deco ? t : t.merge();
+        }
+
         if (mtype.resolved)
         {
             /* struct S s, *p;
              */
-            return mtype.resolved.addSTC(mtype.mod);
+            return returnType(mtype.resolved.addSTC(mtype.mod));
         }
 
         /* Find the current scope by skipping tag scopes.
@@ -2395,7 +2408,7 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
         {
             mtype.id = Identifier.generateId("__tag"[]);
             declareTag();
-            return mtype.resolved.addSTC(mtype.mod);
+            return returnType(mtype.resolved.addSTC(mtype.mod));
         }
 
         /* look for pre-existing declaration
@@ -2408,7 +2421,7 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
             if (mtype.tok == TOK.enum_ && !mtype.members)
                 .error(mtype.loc, "`enum %s` is incomplete without members", mtype.id.toChars()); // C11 6.7.2.3-3
             declareTag();
-            return mtype.resolved.addSTC(mtype.mod);
+            return returnType(mtype.resolved.addSTC(mtype.mod));
         }
 
         /* A redeclaration only happens if both declarations are in
@@ -2508,7 +2521,7 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
                 declareTag();
             }
         }
-        return mtype.resolved.addSTC(mtype.mod);
+        return returnType(mtype.resolved.addSTC(mtype.mod));
     }
 
     switch (type.ty)
index 485ca3ff66c00c10e6ba30029891c4debff3e1ef..9e062bd631d7e376edeab70b70ec67bf40688b8a 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Generate `TypeInfo` objects, which are needed for run-time introspection of types.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/typinf.d, _typinf.d)
index 76f623a0a3ee3ec15ee87f7d6f8e84ee363841f6..fe80b94b4e1420c7b02575bb666ebf09efbac086 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index bb389b6590331f683fe17b1532eddf35150adcb4..75ee78cdd2e5726f25a037a1ca3e95d292c5edf3 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * This module defines some utility functions for DMD.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/utils.d, _utils.d)
index c268bc9b8cf5f84a214fced7ed58ae8cad6034e0..dd83fd67dff0338a1de6f594bc05e825adba151a 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2024 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.
index 5722e10d256b75ed70e767411e84c8c59cd97b33..abfd8caa5844ee34804b5ba32c45d8577fe7b6bb 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Provides a visitor class visiting all AST nodes present in the compiler.
  *
- * Copyright:   Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright:   Copyright (C) 1999-2024 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/src/dmd/visitor.d, _visitor.d)
index 360784a10766d9edc5c31aed68a3eb1e62ecf90d..7fa08cb0e8bcea49183732f536ffe753e958b22c 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Compiler implementation of the D programming language
- * Copyright (C) 2013-2023 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 2013-2024 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
index 16b67338f63d03090979e4beb10cdc227c8910d2..58b15beba34582853a36818a3b4f5d4d3b157e86 100644 (file)
@@ -84,6 +84,7 @@ struct module_info
   vec <tree, va_gc> *sharedctors;
   vec <tree, va_gc> *shareddtors;
   vec <tree, va_gc> *sharedctorgates;
+  vec <tree, va_gc> *standalonectors;
 
   vec <tree, va_gc> *unitTests;
 };
@@ -763,6 +764,11 @@ build_module_tree (Module *decl)
        tm->sdtor = build_funcs_gates_fn (get_identifier ("*__modtestdtor"),
                                          mitest.dtors, NULL);
 
+      if (mi.standalonectors)
+       tm->sictor
+         = build_funcs_gates_fn (get_identifier ("*__modtestsharedictor"),
+                                 mi.standalonectors, NULL);
+
       if (mitest.sharedctors || mitest.sharedctorgates)
        tm->ssharedctor
          = build_funcs_gates_fn (get_identifier ("*__modtestsharedctor"),
@@ -793,6 +799,11 @@ build_module_tree (Module *decl)
        decl->sdtor = build_funcs_gates_fn (get_identifier ("*__moddtor"),
                                            mi.dtors, NULL);
 
+      if (mi.standalonectors)
+       decl->sictor
+         = build_funcs_gates_fn (get_identifier ("*__modsharedictor"),
+                                 mi.standalonectors, NULL);
+
       if (mi.sharedctors || mi.sharedctorgates)
        decl->ssharedctor
          = build_funcs_gates_fn (get_identifier ("*__modsharedctor"),
@@ -858,8 +869,15 @@ register_module_decl (Declaration *d)
       /* If a static constructor, push into the current ModuleInfo.
         Checks for `shared' first because it derives from the non-shared
         constructor type in the front-end.  */
-      if (fd->isSharedStaticCtorDeclaration ())
-       vec_safe_push (minfo->sharedctors, decl);
+      if (SharedStaticCtorDeclaration *sctor
+         = fd->isSharedStaticCtorDeclaration ())
+       {
+         /* The `shared' static constructor was marked `@standalone'.  */
+         if (sctor->standalone)
+           vec_safe_push (minfo->standalonectors, decl);
+         else
+           vec_safe_push (minfo->sharedctors, decl);
+       }
       else if (fd->isStaticCtorDeclaration ())
        vec_safe_push (minfo->ctors, decl);
 
diff --git a/gcc/testsuite/gdc.test/compilable/issue20339.d b/gcc/testsuite/gdc.test/compilable/issue20339.d
new file mode 100644 (file)
index 0000000..3d5bdd8
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+TEST_OUTPUT:
+---
+4
+false
+false
+---
+*/
+
+// https://issues.dlang.org/show_bug.cgi?id=20339
+
+struct S
+{
+    pragma(msg, cast(int)S.sizeof);
+
+    this(this){}
+    ~this(){}
+
+    int f;
+}
+
+static assert(__traits(isPOD, S) == false);
+
+
+pragma(msg, __traits(isPOD, T));
+
+struct T
+{
+    this(this){}
+    ~this(){}
+}
+
+static assert(__traits(isPOD, T) == false);
+
+
+struct U
+{
+    pragma(msg, __traits(isPOD, U));
+
+    this(this){}
+    ~this(){}
+}
+
+static assert(__traits(isPOD, U) == false);
diff --git a/gcc/testsuite/gdc.test/fail_compilation/array_bool.d b/gcc/testsuite/gdc.test/fail_compilation/array_bool.d
new file mode 100644 (file)
index 0000000..923766a
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+REQUIRED_ARGS: -de
+TEST_OUTPUT:
+---
+fail_compilation/array_bool.d(13): Deprecation: assert condition cannot be a string literal
+fail_compilation/array_bool.d(13):        If intentional, use `"foo" !is null` instead to preserve behaviour
+fail_compilation/array_bool.d(14): Deprecation: static assert condition cannot be a string literal
+fail_compilation/array_bool.d(14):        If intentional, use `"foo" !is null` instead to preserve behaviour
+---
+*/
+void main()
+{
+    assert("foo");
+    static assert("foo");
+
+    assert("foo".ptr); // OK
+    static assert("foo".ptr); // OK
+
+    enum e = "bar";
+    static assert(e); // OK
+    assert(e); // OK
+}
index f8edc5c7867ec9d27b6f35bb3db76a756e329e78..dfcddaa5f67a3e6baa7d326b829796f8be3c9839 100644 (file)
@@ -1,7 +1,8 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/diag11425.d(13): Error: variable `x` is shadowing variable `diag11425.main.x`
+fail_compilation/diag11425.d(14): Error: variable `x` is shadowing variable `diag11425.main.x`
+fail_compilation/diag11425.d(11):        declared here
 ---
 */
 
index 1748e92a841a35c30a2da54549c58ae18af244b7..5b8e33162cd818622cc4c7a8e38eab66b8d637c3 100644 (file)
@@ -1,5 +1,5 @@
 /*
-PERMUTE_ARGS: -preview=in
+REQUIRED_ARGS: -preview=in
 TEST_OUTPUT:
 ---
 fail_compilation/diagin.d(14): Error: function `diagin.foo(in int)` is not callable using argument types `()`
index a13922b0fde5af4a1d38dfec0d1a6a852199d13a..4ba2a8c487ecaee3a153437db8e83c9f69262044 100644 (file)
@@ -1,9 +1,12 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail110.d(16): Error: variable `i` is shadowing variable `fail110.main.i`
-fail_compilation/fail110.d(17): Error: variable `i` is shadowing variable `fail110.main.i`
-fail_compilation/fail110.d(18): Error: variable `i` is shadowing variable `fail110.main.i`
+fail_compilation/fail110.d(19): Error: variable `i` is shadowing variable `fail110.main.i`
+fail_compilation/fail110.d(17):        declared here
+fail_compilation/fail110.d(20): Error: variable `i` is shadowing variable `fail110.main.i`
+fail_compilation/fail110.d(17):        declared here
+fail_compilation/fail110.d(21): Error: variable `i` is shadowing variable `fail110.main.i`
+fail_compilation/fail110.d(17):        declared here
 ---
 */
 
index 9b984961f339dc2c0c72587d21cb77ae9acf38cc..2e8e4e6ae9ccaf8e1bad2f6669fddd80bf0b7bb5 100644 (file)
@@ -1,7 +1,7 @@
-/*
+/* REQUIRED_ARGS: -m32
 TEST_OUTPUT:
 ---
-fail_compilation/fail19890a.d(8): Error: `void[$n$$?:64=LU$]` size 1 * $n$ exceeds $?:windows+32omf=0x1000000|0x7fffffff$ size limit for static array
+fail_compilation/fail19890a.d(8): Error: `void[cast(size_t)4294967295]` size 1 * 4294967295 exceeds 0x7fffffff size limit for static array
 ---
 */
 
index 19081d95871a81296619d21a0686616673403900..f9cfb45d533b7ae7b5729f85bebed5a54a5c4a8a 100644 (file)
@@ -1,7 +1,7 @@
-/*
+/* REQUIRED_ARGS: -m32
 TEST_OUTPUT:
 ---
-fail_compilation/fail19890b.d(8): Error: `void[$n$$?:64=LU$]` size 1 * $n$ exceeds $?:windows+32omf=0x1000000|0x7fffffff$ size limit for static array
+fail_compilation/fail19890b.d(8): Error: `void[cast(size_t)4294967294]` size 1 * 4294967294 exceeds 0x7fffffff size limit for static array
 ---
 */
 
index 0eff0663d4b4e8c39478671d2f0e911b9b8a024f..6f6cd53b0e39734e1aa6cc4d76c0d782e346c760 100644 (file)
@@ -3,7 +3,8 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail2195.d(16): Deprecation: variable `variable` is shadowing variable `fail2195.main.variable`. Rename the `foreach` variable.
+fail_compilation/fail2195.d(17): Deprecation: variable `variable` is shadowing variable `fail2195.main.variable`
+fail_compilation/fail2195.d(14):        declared here
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail24301.d b/gcc/testsuite/gdc.test/fail_compilation/fail24301.d
new file mode 100644 (file)
index 0000000..be09c88
--- /dev/null
@@ -0,0 +1,19 @@
+/+
+TEST_OUTPUT:
+---
+fail_compilation/fail24301.d(18): Error: function `fail24301.fun(S __param_0)` is not callable using argument types `(S)`
+fail_compilation/fail24301.d(18):        `ref S(ref S)` copy constructor cannot be used because it is annotated with `@disable`
+---
++/
+struct S
+{
+    @disable this(ref S);
+}
+
+@safe void fun(S) {}
+
+@safe void main()
+{
+    S s;
+    fun(s);
+}
index 04adf13f5e761924239b59f5555949b9748654a8..259a6da847dd83eb9a190bf5906197c2f713dfde 100644 (file)
@@ -1,7 +1,7 @@
-/*
+/* REQUIRED_ARGS: -m32
 TEST_OUTPUT:
 ---
-fail_compilation/fail4611.d(15): Error: `Vec[$n$]` size 4 * $n$ exceeds $?:windows+32omf=0x1000000|0x7fffffff$ size limit for static array
+fail_compilation/fail4611.d(15): Error: `Vec[cast(size_t)2147483647]` size 4 * 2147483647 exceeds 0x7fffffff size limit for static array
 ---
 */
 
index b9ad2941be78869b5d1443188918aa255e592aa1..29893959b17d9587b2e4793760a80c46c14cf45e 100644 (file)
@@ -1,7 +1,8 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail93.d(13): Error: variable `i` is shadowing variable `fail93.main.i`
+fail_compilation/fail93.d(14): Error: variable `i` is shadowing variable `fail93.main.i`
+fail_compilation/fail93.d(13):        declared here
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/standalone_modctor.d b/gcc/testsuite/gdc.test/fail_compilation/standalone_modctor.d
new file mode 100644 (file)
index 0000000..cb36ed6
--- /dev/null
@@ -0,0 +1,15 @@
+/**
+TEST_OUTPUT:
+---
+fail_compilation/standalone_modctor.d(11): Error: `@standalone` can only be used on shared static constructors
+fail_compilation/standalone_modctor.d(12): Error: a module constructor using `@standalone` must be `@system` or `@trusted`
+fail_compilation/standalone_modctor.d(13): Error: a module constructor using `@standalone` must be `@system` or `@trusted`
+---
+*/
+import core.attribute : standalone;
+
+@standalone        static this() {}
+@standalone shared static this() {}
+@standalone shared static this() @safe {}
+@standalone shared static this() @trusted {}
+@standalone shared static this() @system {}
index 1305bc55351d51a54b180d6304059dc4e792dd6c..028f8e1248756c3e079cb21e6552c9b2c75fb1e0 100644 (file)
@@ -2,13 +2,13 @@
 REQUIRED_ARGS: -m64
 TEST_OUTPUT:
 ---
-fail_compilation/staticarrayoverflow.d(23): Error: static array `S[1879048192]` size overflowed to 7516192768000
+fail_compilation/staticarrayoverflow.d(23): Error: static array `S[cast(size_t)1879048192]` size overflowed to 7516192768000
 fail_compilation/staticarrayoverflow.d(23): Error: variable `staticarrayoverflow.y` size overflow
-fail_compilation/staticarrayoverflow.d(25): Error: static array `S[8070450532247928832]` size overflowed to 8070450532247928832
+fail_compilation/staticarrayoverflow.d(25): Error: static array `S[cast(size_t)8070450532247928832]` size overflowed to 8070450532247928832
 fail_compilation/staticarrayoverflow.d(25): Error: variable `staticarrayoverflow.a` size overflow
 fail_compilation/staticarrayoverflow.d(26): Error: static array `S[0][18446744073709551615LU]` size overflowed to 18446744073709551615
 fail_compilation/staticarrayoverflow.d(26): Error: variable `staticarrayoverflow.b` size overflow
-fail_compilation/staticarrayoverflow.d(27): Error: static array `S[0][4294967295]` size overflowed to 4294967295
+fail_compilation/staticarrayoverflow.d(27): Error: static array `S[0][cast(size_t)4294967295]` size overflowed to 4294967295
 fail_compilation/staticarrayoverflow.d(27): Error: variable `staticarrayoverflow.c` size overflow
 ---
 */
diff --git a/gcc/testsuite/gdc.test/runnable/imports/standalone_b.d b/gcc/testsuite/gdc.test/runnable/imports/standalone_b.d
new file mode 100644 (file)
index 0000000..bc5500b
--- /dev/null
@@ -0,0 +1,11 @@
+module standalone_b;
+
+import standalone_modctor;
+import core.attribute : standalone;
+
+immutable int* y;
+
+@standalone @system shared static this()
+{
+    y = new int(2);
+}
diff --git a/gcc/testsuite/gdc.test/runnable/standalone_modctor.d b/gcc/testsuite/gdc.test/runnable/standalone_modctor.d
new file mode 100644 (file)
index 0000000..2654407
--- /dev/null
@@ -0,0 +1,19 @@
+// REQUIRED_ARGS: -Irunnable/imports
+// EXTRA_SOURCES: imports/standalone_b.d
+// PERMUTE_ARGS: -cov
+
+import standalone_b;
+import core.attribute : standalone;
+
+immutable int* x;
+
+@standalone @system shared static this()
+{
+    x = new int(1);
+}
+
+void main()
+{
+    assert(*x == 1);
+    assert(*y == 2);
+}
diff --git a/gcc/testsuite/gdc.test/runnable_cxx/extra-files/test24292.cpp b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/test24292.cpp
new file mode 100644 (file)
index 0000000..2fab9af
--- /dev/null
@@ -0,0 +1,46 @@
+template<class T>
+struct List
+{
+    T* begin;
+};
+
+struct StructWithDestructor
+{
+    ~StructWithDestructor();
+
+    int i;
+};
+
+struct StructWithCopyCtor
+{
+    StructWithCopyCtor();
+    StructWithCopyCtor(const StructWithCopyCtor &other);
+
+    int i;
+};
+
+StructWithDestructor::~StructWithDestructor()
+{
+}
+
+StructWithCopyCtor::StructWithCopyCtor()
+{
+}
+
+StructWithCopyCtor::StructWithCopyCtor(const StructWithCopyCtor &other) : i(other.i)
+{
+}
+
+StructWithDestructor getStructWithDestructor()
+{
+    StructWithDestructor r;
+    r.i = 12345;
+    return r;
+}
+
+StructWithCopyCtor getStructWithCopyCtor()
+{
+    StructWithCopyCtor r;
+    r.i = 54321;
+    return r;
+}
diff --git a/gcc/testsuite/gdc.test/runnable_cxx/test24292.d b/gcc/testsuite/gdc.test/runnable_cxx/test24292.d
new file mode 100644 (file)
index 0000000..b71f925
--- /dev/null
@@ -0,0 +1,50 @@
+// EXTRA_CPP_SOURCES: test24292.cpp
+
+extern(C++) struct List(T)
+{
+    // Any of the following static ifs can trigger the problem.
+    static if (T.sizeof > 4) {}
+    static if (__traits(isZeroInit, T)) {}
+    static if (__traits(isPOD, T)) {}
+
+    T* begin;
+}
+
+extern(C++) struct StructWithDestructor
+{
+    ~this();
+
+    alias L = List!StructWithDestructor;
+    int i;
+}
+
+extern(C++) struct StructWithCopyCtor
+{
+    this(ref const(StructWithCopyCtor));
+
+    alias L = List!StructWithCopyCtor;
+    int i;
+}
+
+extern(D) struct StructWithPostblit
+{
+    this(this) {}
+
+    alias L = List!StructWithPostblit;
+    int i;
+}
+
+static assert(!__traits(isPOD, StructWithDestructor));
+static assert(!__traits(isPOD, StructWithCopyCtor));
+static assert(!__traits(isPOD, StructWithPostblit));
+
+extern(C++) StructWithDestructor getStructWithDestructor();
+extern(C++) StructWithCopyCtor getStructWithCopyCtor();
+
+void main()
+{
+    StructWithDestructor structWithDestructor = getStructWithDestructor();
+    assert(structWithDestructor.i == 12345);
+    StructWithCopyCtor structWithCopyCtor = getStructWithCopyCtor();
+    assert(structWithCopyCtor.i == 54321);
+}
index fa7004b7a412591e51219a717b7c9a9ca3306596..2b4400f398ed26c0c30473e30e1b01158b542293 100644 (file)
@@ -1,4 +1,4 @@
-f1a045928e03239b9477f9497f43f2cf0e61e959
+d8e3976a58d6aef7c2c9371028a2ca4460b5b2ce
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
index 74147a095cda6c6d63c1e8cbdcf0dbedfb00f166..b4fef091b5f4562e1007ab7770b1a2b4d2314305 100644 (file)
@@ -53,6 +53,10 @@ version (CRuntime_Microsoft)
 
 version (DigitalMars)
 {
+    immutable float __nan = float.nan;
+
+    float __builtin_nanf()(char*)  { return float.nan; }
+
     double __builtin_inf()()  { return double.infinity; }
     float  __builtin_inff()() { return float.infinity; }
     real   __builtin_infl()() { return real.infinity; }
index c2a7c334eb77a0e8397b5ae9f47bb47b2401c7d1..79ad25ab358bf9be2819c120207db425e2ec3f9d 100644 (file)
@@ -290,3 +290,15 @@ version (UdaGNUAbiTag) struct gnuAbiTag
  * ---
  */
 enum mustuse;
+
+/**
+ * Use this attribute to indicate that a shared module constructor does not depend on any
+ * other module constructor being run first. This avoids errors on cyclic module constructors.
+ *
+ * However, it is now up to the user to enforce safety.
+ * The module constructor must be marked `@system` as a result.
+ * Prefer to refactor the module constructor causing the cycle so it's in its own module if possible.
+ *
+ * This is only allowed on `shared` static constructors, not thread-local module constructors.
+ */
+enum standalone;
index 30fc1308e4b51f9290b8bd71058d2f41a93953ee..941b5de3c4efa1f4323a5723eeb952ef7e9ccd06 100644 (file)
@@ -30,15 +30,6 @@ public:
 nothrow:
 @safe:
 
-/*****************************************
- * Returns x rounded to a long value using the FE_TONEAREST rounding mode.
- * If the integer value of x is
- * greater than long.max, the result is
- * indeterminate.
- */
-deprecated("rndtonl is to be removed by 2.100. Please use round instead")
-extern (C) real rndtonl(real x);
-
 pure:
 /***********************************
  * Returns cosine of x. x is in radians.
index 6a598baec286dc05a82d426939a7bab7909aa219..de9e10ac47c029da76f1bf0c0abc16a4dbb97d23 100644 (file)
@@ -59,6 +59,8 @@ T cpp_new(T, Args...)(auto ref Args args) if (is(T == class))
 ///
 void cpp_delete(T)(T* ptr) if (!is(T == class))
 {
+    if (ptr is null)
+        return;
     destroy!false(*ptr);
     __cpp_delete(ptr);
 }
@@ -66,6 +68,8 @@ void cpp_delete(T)(T* ptr) if (!is(T == class))
 ///
 void cpp_delete(T)(T instance) if (is(T == class))
 {
+    if (instance is null)
+        return;
     destroy!false(instance);
     __cpp_delete(cast(void*) instance);
 }
index e63af4f7c322556230da3378d7c48fc26b474b54..7fadcd884c4345d2db29123ee8cf6b1b32799807 100644 (file)
@@ -143,6 +143,21 @@ else version (CRuntime_Bionic)
     uint            if_nametoindex(const scope char*);
     char*           if_indextoname(uint, char*);
 }
+else version (CRuntime_Musl)
+{
+    struct if_nameindex_t
+    {
+        uint    if_index;
+        char*   if_name;
+    }
+
+    enum IF_NAMESIZE = 16;
+
+    uint            if_nametoindex(const scope char*);
+    char*           if_indextoname(uint, char*);
+    if_nameindex_t* if_nameindex();
+    void            if_freenameindex(if_nameindex_t*);
+}
 else version (CRuntime_UClibc)
 {
     struct if_nameindex_t
@@ -157,4 +172,4 @@ else version (CRuntime_UClibc)
     char*           if_indextoname(uint, char*);
     if_nameindex_t* if_nameindex();
     void            if_freenameindex(if_nameindex_t*);
-}
\ No newline at end of file
+}
index 006d48d97f56c8334d6d2c0d0f8bcf5673c12312..65f57892ee7e881e20ecc7d8393cfff6b85759a5 100644 (file)
@@ -85,7 +85,10 @@ static assert(is(typeof(&initTLSRanges) RT == return) &&
               is(typeof(&finiTLSRanges) == void function(RT) nothrow @nogc) &&
               is(typeof(&scanTLSRanges) == void function(RT, scope void delegate(void*, void*) nothrow) nothrow));
 
-version (Shared)
+version (Windows)
+{
+}
+else version (Shared)
 {
     static assert(is(typeof(&pinLoadedLibraries) == void* function() nothrow @nogc));
     static assert(is(typeof(&unpinLoadedLibraries) == void function(void*) nothrow @nogc));
index 3c0e1b28d316c69c0468c4e7a8069dc2c2d3826a..103a93f5ad6624e201965758f328d677fd3e2ff6 100644 (file)
@@ -1,4 +1,4 @@
-b64bfbf911fcd1675ae9792545649c9d45bb907e
+7a6e9568862f5a0d9eb34707d85dcf7ff889c26f
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/phobos repository.
index 3a533814894444f85a7433af0022dbf1ff149095..23b33c4d78c744c530a4c8097cc61389dfe06961 100644 (file)
@@ -5712,8 +5712,8 @@ private auto hexStrLiteral(String)(scope String hexData)
  *      radix = 2, 8, 10, 16
  *      Char = character type for output
  *      letterCase = lower for deadbeef, upper for DEADBEEF
- *      value = integer to convert. Can be uint or ulong. If radix is 10, can also be
- *              int or long.
+ *      value = integer to convert. Can be ubyte, ushort, uint or ulong. If radix
+ *              is 10, can also be byte, short, int or long.
  * Returns:
  *      Random access range with slicing and everything
  */
@@ -5721,8 +5721,7 @@ private auto hexStrLiteral(String)(scope String hexData)
 auto toChars(ubyte radix = 10, Char = char, LetterCase letterCase = LetterCase.lower, T)(T value)
     pure nothrow @nogc @safe
 if ((radix == 2 || radix == 8 || radix == 10 || radix == 16) &&
-    (is(immutable T == immutable uint) || is(immutable T == immutable ulong) ||
-    radix == 10 && (is(immutable T == immutable int) || is(immutable T == immutable long))))
+        isIntegral!T && (radix == 10 || isUnsigned!T))
 {
     alias UT = Unqual!T;
 
@@ -5870,8 +5869,12 @@ if ((radix == 2 || radix == 8 || radix == 10 || radix == 16) &&
     assert(toChars(123) == toChars(123));
 
     {
+        assert(toChars!2(ubyte(0)).array == "0");
+        assert(toChars!2(ushort(0)).array == "0");
         assert(toChars!2(0u).array == "0");
         assert(toChars!2(0Lu).array == "0");
+        assert(toChars!2(ubyte(1)).array == "1");
+        assert(toChars!2(ushort(1)).array == "1");
         assert(toChars!2(1u).array == "1");
         assert(toChars!2(1Lu).array == "1");
 
@@ -5884,10 +5887,14 @@ if ((radix == 2 || radix == 8 || radix == 10 || radix == 16) &&
         assert(s.retro.array == "01");
     }
     {
+        assert(toChars!8(ubyte(0)).array == "0");
+        assert(toChars!8(ushort(0)).array == "0");
         assert(toChars!8(0u).array == "0");
         assert(toChars!8(0Lu).array == "0");
         assert(toChars!8(1u).array == "1");
         assert(toChars!8(1234567Lu).array == "4553207");
+        assert(toChars!8(ubyte.max).array == "377");
+        assert(toChars!8(ushort.max).array == "177777");
 
         auto r = toChars!8(8u);
         assert(r.length == 2);
@@ -5898,10 +5905,14 @@ if ((radix == 2 || radix == 8 || radix == 10 || radix == 16) &&
         assert(s.retro.array == "01");
     }
     {
+        assert(toChars!10(ubyte(0)).array == "0");
+        assert(toChars!10(ushort(0)).array == "0");
         assert(toChars!10(0u).array == "0");
         assert(toChars!10(0Lu).array == "0");
         assert(toChars!10(1u).array == "1");
         assert(toChars!10(1234567Lu).array == "1234567");
+        assert(toChars!10(ubyte.max).array == "255");
+        assert(toChars!10(ushort.max).array == "65535");
         assert(toChars!10(uint.max).array == "4294967295");
         assert(toChars!10(ulong.max).array == "18446744073709551615");
 
@@ -5918,10 +5929,16 @@ if ((radix == 2 || radix == 8 || radix == 10 || radix == 16) &&
         assert(toChars!10(0L).array == "0");
         assert(toChars!10(1).array == "1");
         assert(toChars!10(1234567L).array == "1234567");
+        assert(toChars!10(byte.max).array == "127");
+        assert(toChars!10(short.max).array == "32767");
         assert(toChars!10(int.max).array == "2147483647");
         assert(toChars!10(long.max).array == "9223372036854775807");
+        assert(toChars!10(-byte.max).array == "-127");
+        assert(toChars!10(-short.max).array == "-32767");
         assert(toChars!10(-int.max).array == "-2147483647");
         assert(toChars!10(-long.max).array == "-9223372036854775807");
+        assert(toChars!10(byte.min).array == "-128");
+        assert(toChars!10(short.min).array == "-32768");
         assert(toChars!10(int.min).array == "-2147483648");
         assert(toChars!10(long.min).array == "-9223372036854775808");
 
@@ -5938,6 +5955,10 @@ if ((radix == 2 || radix == 8 || radix == 10 || radix == 16) &&
         assert(toChars!(16)(0Lu).array == "0");
         assert(toChars!(16)(10u).array == "a");
         assert(toChars!(16, char, LetterCase.upper)(0x12AF34567Lu).array == "12AF34567");
+        assert(toChars!(16)(ubyte(0)).array == "0");
+        assert(toChars!(16)(ushort(0)).array == "0");
+        assert(toChars!(16)(ubyte.max).array == "ff");
+        assert(toChars!(16)(ushort.max).array == "ffff");
 
         auto r = toChars!(16)(16u);
         assert(r.length == 2);
index 8e9f5ae83bee400319e1fc1c985f425c22b94b60..58e71e5aa08387384de22221f0f8a18270c3cabd 100644 (file)
@@ -12,6 +12,7 @@
     $(TR
         $(TD Points in Time)
         $(TD
+            $(REF_ALTTEXT Clock, Clock, std, datetime, systime)$(NBSP)
             $(REF_ALTTEXT Date, Date, std, datetime, date)$(NBSP)
             $(REF_ALTTEXT TimeOfDay, TimeOfDay, std, datetime, date)$(NBSP)
             $(REF_ALTTEXT DateTime, DateTime, std, datetime, date)$(NBSP)
@@ -19,7 +20,7 @@
         )
     )
     $(TR
-        $(TD Timezones)
+        $(TD $(MREF_ALTTEXT Timezones, std, datetime, timezone))
         $(TD
             $(REF_ALTTEXT TimeZone, TimeZone, std, datetime, timezone)$(NBSP)
             $(REF_ALTTEXT UTC, UTC, std, datetime, timezone)$(NBSP)
@@ -38,7 +39,7 @@
         )
     )
     $(TR
-        $(TD Durations of Time)
+        $(TD $(MREF_ALTTEXT Durations of Time, core, time))
         $(TD
             $(REF_ALTTEXT Duration, Duration, core, time)$(NBSP)
             $(REF_ALTTEXT weeks, weeks, core, time)$(NBSP)
@@ -62,7 +63,7 @@
     )
     ))
 
-    This functionality is separated into the following modules
+    This functionality is separated into the following modules:
 
     $(UL
         $(LI $(MREF std, datetime, date) for points in time without timezones.)
@@ -73,6 +74,7 @@
     )
 
     See_Also:
+        $(MREF core, time)$(BR)
         $(DDLINK intro-to-datetime, Introduction to std.datetime,
                  Introduction to std&#46;datetime)<br>
         $(HTTP en.wikipedia.org/wiki/ISO_8601, ISO 8601)<br>
@@ -87,7 +89,7 @@
 +/
 module std.datetime;
 
-/// Get the current time from the system clock
+/// Get the current time from the system clock.
 @safe unittest
 {
     import std.datetime.systime : SysTime, Clock;
index 6898934f809da0ab60bec7746f7811e029fdce14..a1d8ef3604fe066efee663992b6b4c7457539518 100644 (file)
@@ -2,7 +2,6 @@
 
 /++
 
-$(SCRIPT inhibitQuickIndex = 1;)
 $(DIVC quickindex,
 $(BOOKTABLE,
 $(TR $(TH Category) $(TH Functions))
@@ -468,30 +467,38 @@ private:
     `SysTime` (though for local time applications, time zones can be ignored
     and it will work, since it defaults to using the local time zone). It holds
     its internal time in std time (hnsecs since midnight, January 1st, 1 A.D.
-    UTC), so it interfaces well with the system time. However, that means that,
-    unlike $(REF DateTime,std,datetime,date), it is not optimized for
-    calendar-based operations, and getting individual units from it such as
-    years or days is going to involve conversions and be less efficient.
+    UTC), so it interfaces well with the system time.
 
     An $(I hnsec) (hecto-nanosecond) is 100 nanoseconds. There are 10,000,000 hnsecs in a second.
 
+$(PANEL
+    Unlike $(REF_SHORT DateTime,std,datetime,date), `SysTime` is not optimized for
+    calendar-based operations, and getting individual units from it such as
+    years or days is going to involve conversions and be less efficient.
+
     For calendar-based operations that don't
-    care about time zones, then $(REF DateTime,std,datetime,date) would be
+    care about time zones, then $(REF_SHORT DateTime,std,datetime,date) would be
     the type to use. For system time, use `SysTime`.
-
-    $(LREF Clock.currTime) will return the current time as a `SysTime`.
-    To convert a `SysTime` to a $(REF Date,std,datetime,date) or
-    $(REF DateTime,std,datetime,date), simply cast it. To convert a
-    $(REF Date,std,datetime,date) or $(REF DateTime,std,datetime,date) to a
+)
+$(P
+    Casting a `SysTime` to one of the following types will perform a conversion:
+)
+    * $(REF Date,std,datetime,date)
+    * $(REF_SHORT DateTime,std,datetime,date)
+    * $(REF_SHORT TimeOfDay,std,datetime,date)
+$(P
+    To convert a
+    $(REF_SHORT Date,std,datetime,date) or $(REF_SHORT DateTime,std,datetime,date) to a
     `SysTime`, use `SysTime`'s constructor, and pass in the intended time
     zone with it (or don't pass in a $(REF TimeZone,std,datetime,timezone), and
     the local time zone will be used). Be aware, however, that converting from a
-    $(REF DateTime,std,datetime,date) to a `SysTime` will not necessarily
+    $(REF_SHORT DateTime,std,datetime,date) to a `SysTime` will not necessarily
     be 100% accurate due to DST (one hour of the year doesn't exist and another
     occurs twice). To not risk any conversion errors, keep times as
     `SysTime`s. Aside from DST though, there shouldn't be any conversion
     problems.
-
+)
+$(PANEL
     For using time zones other than local time or UTC, use
     $(REF PosixTimeZone,std,datetime,timezone) on Posix systems (or on Windows,
     if providing the TZ Database files), and use
@@ -499,16 +506,20 @@ private:
     `SysTime` is kept internally in hnsecs from midnight, January 1st, 1 A.D.
     UTC. Conversion error cannot happen when changing the time zone of a
     `SysTime`. $(REF LocalTime,std,datetime,timezone) is the
-    $(REF TimeZone,std,datetime,timezone) class which represents the local time,
-    and `UTC` is the $(REF TimeZone,std,datetime,timezone) class which
-    represents UTC. `SysTime` uses $(REF LocalTime,std,datetime,timezone) if
-    no $(REF TimeZone,std,datetime,timezone) is provided. For more details on
-    time zones, see the documentation for $(REF TimeZone,std,datetime,timezone),
-    $(REF PosixTimeZone,std,datetime,timezone), and
-    $(REF WindowsTimeZone,std,datetime,timezone).
-
+    $(REF_SHORT TimeZone,std,datetime,timezone) class which represents the local time,
+    and `UTC` is the $(REF_SHORT TimeZone,std,datetime,timezone) class which
+    represents UTC. `SysTime` uses $(REF_SHORT LocalTime,std,datetime,timezone) if
+    no $(REF_SHORT TimeZone,std,datetime,timezone) is provided. For more details on
+    time zones, see the documentation for $(REF_SHORT TimeZone,std,datetime,timezone),
+    $(REF_SHORT PosixTimeZone,std,datetime,timezone), and
+    $(REF_SHORT WindowsTimeZone,std,datetime,timezone).
+)
+$(P
     `SysTime`'s range is from approximately 29,000 B.C. to approximately
     29,000 A.D.
+)
+See_Also:
+    $(RELATIVE_LINK2 .Clock.currTime, `Clock.currTime`) will return the current time as a `SysTime`.
   +/
 struct SysTime
 {
@@ -9674,16 +9685,25 @@ private:
 @safe unittest
 {
     import core.time : days, hours, seconds;
-    import std.datetime.date : DateTime;
+    import std.datetime.date : Date, DateTime;
     import std.datetime.timezone : SimpleTimeZone, UTC;
 
+    const dt = DateTime(2018, 1, 1, 10, 30, 0);
     // make a specific point in time in the UTC timezone
-    auto st = SysTime(DateTime(2018, 1, 1, 10, 30, 0), UTC());
+    auto st = SysTime(dt, UTC());
+    assert(st.year == 2018);
+    assert(st.hour == 10);
+
+    // cast to convert
+    assert(cast(DateTime) st == dt);
+    assert(cast(Date) st == Date(2018, 1, 1));
+
     // make a specific point in time in the New York timezone
-    auto ny = SysTime(
-        DateTime(2018, 1, 1, 10, 30, 0),
+    const ny = SysTime(dt,
         new immutable SimpleTimeZone(-5.hours, "America/New_York")
     );
+    assert(ny != st);
+    assert(ny.hour == 10);
 
     // ISO standard time strings
     assert(st.toISOString() == "20180101T103000Z");
@@ -9775,7 +9795,7 @@ long unixTimeToStdTime(long unixTime) @safe pure nothrow @nogc
 
     "std time"'s epoch is based on the Proleptic Gregorian Calendar per ISO
     8601 and is what $(LREF SysTime) uses internally. However, holding the time
-    as an integer in hnescs since that epoch technically isn't actually part of
+    as an integer in hnsecs since that epoch technically isn't actually part of
     the standard, much as it's based on it, so the name "std time" isn't
     particularly good, but there isn't an official name for it. C# uses "ticks"
     for the same thing, but they aren't actually clock ticks, and the term
index 4791766ab3ad17898b1eab1c431f95f3a97bced4..9999071646009bed50a862ba25869e0cc407427a 100644 (file)
@@ -43,24 +43,24 @@ import std.traits : CommonType, isFloatingPoint, isIntegral, isSigned, Unqual;
  *     the return type will be the same as the input.
  *
  * Limitations:
- *     Does not work correctly for signed intergal types and value `Num`.min.
+ *     When x is a signed integral equal to `Num.min` the value of x will be returned instead.
+ *     Note for 2's complement; `-Num.min` (= `Num.max + 1`) is not representable due to overflow.
  */
-auto abs(Num)(Num x) @nogc pure nothrow
-if ((is(immutable Num == immutable short) || is(immutable Num == immutable byte)) ||
-    (is(typeof(Num.init >= 0)) && is(typeof(-Num.init))))
+auto abs(Num)(Num x) @nogc nothrow pure
+if (isIntegral!Num || (is(typeof(Num.init >= 0)) && is(typeof(-Num.init))))
 {
     static if (isFloatingPoint!(Num))
         return fabs(x);
     else
     {
-        static if (is(immutable Num == immutable short) || is(immutable Num == immutable byte))
-            return x >= 0 ? x : cast(Num) -int(x);
+        static if (isIntegral!Num)
+            return x >= 0 ? x : cast(Num) -x;
         else
             return x >= 0 ? x : -x;
     }
 }
 
-/// ditto
+///
 @safe pure nothrow @nogc unittest
 {
     import std.math.traits : isIdentical, isNaN;
@@ -70,16 +70,27 @@ if ((is(immutable Num == immutable short) || is(immutable Num == immutable byte)
     assert(abs(-real.infinity) == real.infinity);
     assert(abs(-56) == 56);
     assert(abs(2321312L)  == 2321312L);
+    assert(abs(23u) == 23u);
 }
 
 @safe pure nothrow @nogc unittest
 {
-    short s = -8;
-    byte b = -8;
-    assert(abs(s) == 8);
-    assert(abs(b) == 8);
-    immutable(byte) c = -8;
-    assert(abs(c) == 8);
+    assert(abs(byte(-8)) == 8);
+    assert(abs(ubyte(8u)) == 8);
+    assert(abs(short(-8)) == 8);
+    assert(abs(ushort(8u)) == 8);
+    assert(abs(int(-8)) == 8);
+    assert(abs(uint(8u)) == 8);
+    assert(abs(long(-8)) == 8);
+    assert(abs(ulong(8u)) == 8);
+    assert(is(typeof(abs(byte(-8))) == byte));
+    assert(is(typeof(abs(ubyte(8u))) == ubyte));
+    assert(is(typeof(abs(short(-8))) == short));
+    assert(is(typeof(abs(ushort(8u))) == ushort));
+    assert(is(typeof(abs(int(-8))) == int));
+    assert(is(typeof(abs(uint(8u))) == uint));
+    assert(is(typeof(abs(long(-8))) == long));
+    assert(is(typeof(abs(ulong(8u))) == ulong));
 }
 
 @safe pure nothrow @nogc unittest
index 2fcbf943122de4d5e3c4ada09d6dd160b19c3362..6aec366c657633abd08502701f892588b3d45c67 100644 (file)
@@ -2419,8 +2419,8 @@ struct HTTP
         @system @property void onReceiveHeader(void delegate(in char[] key,
                                                      in char[] value) callback)
         {
-            import std.algorithm.searching : startsWith;
-            import std.regex : regex, match;
+            import std.algorithm.searching : findSplit, startsWith;
+            import std.string : indexOf, chomp;
             import std.uni : toLower;
 
             // Wrap incoming callback in order to separate http status line from
@@ -2447,21 +2447,18 @@ struct HTTP
                         return;
                     }
 
-                    // Normal http header
-                    auto m = match(cast(char[]) header, regex("(.*?): (.*)$"));
-
-                    auto fieldName = m.captures[1].toLower().idup;
+                    auto m = header.findSplit(": ");
+                    auto fieldName = m[0].toLower();
+                    auto fieldContent = m[2].chomp;
                     if (fieldName == "content-type")
                     {
-                        auto mct = match(cast(char[]) m.captures[2],
-                                         regex("charset=([^;]*)", "i"));
-                        if (!mct.empty && mct.captures.length > 1)
-                            charset = mct.captures[1].idup;
+                        auto io = indexOf(fieldContent, "charset=", No.caseSensitive);
+                        if (io != -1)
+                            charset = fieldContent[io + "charset=".length .. $].findSplit(";")[0].idup;
                     }
-
-                    if (!m.empty && callback !is null)
-                        callback(fieldName, m.captures[2]);
-                    headersIn[fieldName] = m.captures[2].idup;
+                    if (!m[1].empty && callback !is null)
+                        callback(fieldName, fieldContent);
+                    headersIn[fieldName] = fieldContent.idup;
                 }
                 catch (UTFException e)
                 {
@@ -2479,20 +2476,27 @@ struct HTTP
     /// Parse status line, as received from / generated by cURL.
     private static bool parseStatusLine(const char[] header, out StatusLine status) @safe
     {
-        import std.conv : to;
-        import std.regex : regex, match;
+        import std.algorithm.searching : findSplit, startsWith;
+        import std.conv : to, ConvException;
 
-        const m = match(header, regex(r"^HTTP/(\d+)(?:\.(\d+))? (\d+)(?: (.*))?$"));
-        if (m.empty)
-            return false; // Invalid status line
-        else
+        if (!header.startsWith("HTTP/"))
+            return false;
+
+        try
         {
-            status.majorVersion = to!ushort(m.captures[1]);
-            status.minorVersion = m.captures[2].length ? to!ushort(m.captures[2]) : 0;
-            status.code = to!ushort(m.captures[3]);
-            status.reason = m.captures[4].idup;
+            const m = header["HTTP/".length .. $].findSplit(" ");
+            const v = m[0].findSplit(".");
+            status.majorVersion = to!ushort(v[0]);
+            status.minorVersion = v[1].length ? to!ushort(v[2]) : 0;
+            const s2 = m[2].findSplit(" ");
+            status.code = to!ushort(s2[0]);
+            status.reason = s2[2].idup;
             return true;
         }
+        catch (ConvException e)
+        {
+            return false;
+        }
     }
 
     @safe unittest
@@ -2505,6 +2509,12 @@ struct HTTP
         // The HTTP2 protocol is binary; cURL generates this fake text header.
         assert(parseStatusLine("HTTP/2 200", status)
             && status == StatusLine(2, 0, 200, null));
+
+        assert(!parseStatusLine("HTTP/2", status));
+        assert(!parseStatusLine("HTTP/2 -1", status));
+        assert(!parseStatusLine("HTTP/2  200", status));
+        assert(!parseStatusLine("HTTP/2.X 200", status));
+        assert(!parseStatusLine("HTTP|2 200", status));
     }
 
     /** Time condition enumeration as an alias of $(REF CurlTimeCond, etc,c,curl)